diff --git a/crates/swc/tests/tsc-references/classStaticBlock17.2.minified.js b/crates/swc/tests/tsc-references/classStaticBlock17.2.minified.js index 86fd46f637a..87452369dbe 100644 --- a/crates/swc/tests/tsc-references/classStaticBlock17.2.minified.js +++ b/crates/swc/tests/tsc-references/classStaticBlock17.2.minified.js @@ -5,9 +5,7 @@ import _class_private_field_set from "@swc/helpers/src/_class_private_field_set. let friendA; var _x = new WeakMap(); friendA = { - getX (obj) { - return _class_private_field_get(obj, _x); - }, + getX: (obj)=>_class_private_field_get(obj, _x), setX (obj, value) { _class_private_field_set(obj, _x, value); } diff --git a/crates/swc/tests/tsc-references/computedPropertyNamesContextualType6_ES6.2.minified.js b/crates/swc/tests/tsc-references/computedPropertyNamesContextualType6_ES6.2.minified.js index eb7975fc1cc..930b32e9b04 100644 --- a/crates/swc/tests/tsc-references/computedPropertyNamesContextualType6_ES6.2.minified.js +++ b/crates/swc/tests/tsc-references/computedPropertyNamesContextualType6_ES6.2.minified.js @@ -1,7 +1,7 @@ //// [computedPropertyNamesContextualType6_ES6.ts] foo({ p: "", - 0: ()=>{}, + 0 () {}, hibye: !0, 1: 0, [NaN]: [ diff --git a/crates/swc/tests/tsc-references/computedPropertyNamesContextualType7_ES6.2.minified.js b/crates/swc/tests/tsc-references/computedPropertyNamesContextualType7_ES6.2.minified.js index b0a31f47d73..80435f7c9b0 100644 --- a/crates/swc/tests/tsc-references/computedPropertyNamesContextualType7_ES6.2.minified.js +++ b/crates/swc/tests/tsc-references/computedPropertyNamesContextualType7_ES6.2.minified.js @@ -1,6 +1,6 @@ //// [computedPropertyNamesContextualType7_ES6.ts] foo({ - 0: ()=>{}, + 0 () {}, hibye: !0, 1: 0, [NaN]: [ diff --git a/crates/swc/tests/tsc-references/importCallExpressionAsyncES2020.2.minified.js b/crates/swc/tests/tsc-references/importCallExpressionAsyncES2020.2.minified.js index b6c76f98326..aaf7acafda0 100644 --- a/crates/swc/tests/tsc-references/importCallExpressionAsyncES2020.2.minified.js +++ b/crates/swc/tests/tsc-references/importCallExpressionAsyncES2020.2.minified.js @@ -8,14 +8,14 @@ export class cl1 { } } export const obj = { - m: async ()=>{ + async m () { await import('./test'); } }; export class cl2 { constructor(){ this.p = { - m: async ()=>{ + async m () { await import('./test'); } }; diff --git a/crates/swc/tests/tsc-references/jsDeclarationsGetterSetter.2.minified.js b/crates/swc/tests/tsc-references/jsDeclarationsGetterSetter.2.minified.js index 424d2af192b..d3e7e20702c 100644 --- a/crates/swc/tests/tsc-references/jsDeclarationsGetterSetter.2.minified.js +++ b/crates/swc/tests/tsc-references/jsDeclarationsGetterSetter.2.minified.js @@ -16,9 +16,7 @@ export class C { export class D { } Object.defineProperty(D.prototype, "x", { - get () { - return 12; - } + get: ()=>12 }); export class E { } @@ -28,8 +26,6 @@ Object.defineProperty(E.prototype, "x", { export class F { } Object.defineProperty(F.prototype, "x", { - get () { - return 12; - }, + get: ()=>12, set (_arg) {} }); diff --git a/crates/swc/tests/tsc-references/privateNameStaticMethodAssignment.2.minified.js b/crates/swc/tests/tsc-references/privateNameStaticMethodAssignment.2.minified.js index 2032e2e0980..5260637817e 100644 --- a/crates/swc/tests/tsc-references/privateNameStaticMethodAssignment.2.minified.js +++ b/crates/swc/tests/tsc-references/privateNameStaticMethodAssignment.2.minified.js @@ -6,7 +6,7 @@ import _class_static_private_method_get from "@swc/helpers/src/_class_static_pri class A3 { constructor(a, b){ _class_static_private_field_spec_set(A3, A3, _method, ()=>{}), _class_static_private_field_spec_set(a, A3, _method, ()=>{}), _class_static_private_field_spec_set(b, A3, _method, ()=>{}), ({ x: _class_static_private_field_destructure(A3, A3, _method).value } = { - x: ()=>{} + x () {} }), _class_static_private_method_get(A3, A3, function() {}), _class_static_private_field_update(b, A3, _method).value++; } } diff --git a/crates/swc/tests/tsc-references/symbolProperty18.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty18.2.minified.js index 6b864993b1f..5eb1528d37c 100644 --- a/crates/swc/tests/tsc-references/symbolProperty18.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty18.2.minified.js @@ -1,9 +1,7 @@ //// [symbolProperty18.ts] var i = { [Symbol.iterator]: 0, - [Symbol.toStringTag] () { - return ""; - }, + [Symbol.toStringTag]: ()=>"", set [Symbol.toPrimitive] (p){} }; i[Symbol.iterator], i[Symbol.toStringTag](), i[Symbol.toPrimitive] = !1; diff --git a/crates/swc/tests/tsc-references/symbolProperty19.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty19.2.minified.js index 12136fd8efe..1765407fe5b 100644 --- a/crates/swc/tests/tsc-references/symbolProperty19.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty19.2.minified.js @@ -3,10 +3,8 @@ var i = { [Symbol.iterator]: { p: null }, - [Symbol.toStringTag] () { - return { + [Symbol.toStringTag]: ()=>({ p: void 0 - }; - } + }) }; i[Symbol.iterator], i[Symbol.toStringTag](); diff --git a/crates/swc/tests/tsc-references/uniqueSymbolsDeclarationsErrors.2.minified.js b/crates/swc/tests/tsc-references/uniqueSymbolsDeclarationsErrors.2.minified.js index a3bdc03699a..e410d30ead5 100644 --- a/crates/swc/tests/tsc-references/uniqueSymbolsDeclarationsErrors.2.minified.js +++ b/crates/swc/tests/tsc-references/uniqueSymbolsDeclarationsErrors.2.minified.js @@ -16,12 +16,8 @@ Object.defineProperty(exports, "__esModule", { ClassWithPrivateNamedAccessors: ()=>ClassWithPrivateNamedAccessors }); const obj = { - method1 (p) { - return p; - }, - method2 (p) { - return p; - } + method1: (p)=>p, + method2: (p)=>p }, classExpression = class { method1(p) { return p; diff --git a/crates/swc_ecma_minifier/src/compress/pure/arrows.rs b/crates/swc_ecma_minifier/src/compress/pure/arrows.rs index dd696ef6405..5ebc5139d38 100644 --- a/crates/swc_ecma_minifier/src/compress/pure/arrows.rs +++ b/crates/swc_ecma_minifier/src/compress/pure/arrows.rs @@ -61,10 +61,6 @@ impl Pure<'_> { } pub(super) fn optimize_arrow_method_prop(&mut self, p: &mut Prop) { - if self.options.ecma < EsVersion::Es2015 { - return; - } - if !self.options.unsafe_methods && !self.options.arrows { return; } diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/firebase-firestore/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/firebase-firestore/1/output.js index fbe00233e16..0b5dd094f47 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/firebase-firestore/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/firebase-firestore/1/output.js @@ -3985,7 +3985,7 @@ const c = s.createWebChannel(o, r); let a = !1, u = !1; const h = new Gr({ - vi: (t)=>{ + vi (t) { u ? $("Connection", "Not sending because WebChannel is closed:", t) : (a || ($("Connection", "Opening WebChannel transport."), c.open(), a = !0), $("Connection", "WebChannel sending:", t), c.send(t)); }, Vi: ()=>c.close() @@ -6060,7 +6060,7 @@ const s = new Q(); return t.asyncQueue.enqueueAndForget(async ()=>(function(t, e, n, s, i) { const r = new Lc({ - next: (n)=>{ + next (n) { e.enqueueAndForget(()=>Uo(t, o)), n.fromCache && "server" === s.source ? i.reject(new j(K.UNAVAILABLE, 'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')) : i.resolve(n); }, error: (t)=>i.reject(t) diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/react-instancesearch/001/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/react-instancesearch/001/output.js index a5ce3ea734b..bf5ebd10da7 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/react-instancesearch/001/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/react-instancesearch/001/output.js @@ -8,14 +8,10 @@ export default function createWidgetsManager(onWidgetsUpdate) { })); } return { - registerWidget (widget) { - return widgets.push(widget), scheduleUpdate(), function() { + registerWidget: (widget)=>(widgets.push(widget), scheduleUpdate(), function() { widgets.splice(widgets.indexOf(widget), 1), scheduleUpdate(); - }; - }, + }), update: scheduleUpdate, - getWidgets () { - return widgets; - } + getWidgets: ()=>widgets }; }; diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/react-instancesearch/003/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/react-instancesearch/003/output.js index 6819cbae685..f84f50d69e0 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/react-instancesearch/003/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/react-instancesearch/003/output.js @@ -41,15 +41,11 @@ export default function createInstantSearchManager({ indexName , initialState ={ })); } return { - registerWidget (widget) { - return widgets.push(widget), scheduleUpdate(), function() { + registerWidget: (widget)=>(widgets.push(widget), scheduleUpdate(), function() { widgets.splice(widgets.indexOf(widget), 1), scheduleUpdate(); - }; - }, + }), update: scheduleUpdate, - getWidgets () { - return widgets; - } + getWidgets: ()=>widgets }; }(function() { const metadata = getMetadata(store.getState().widgets); diff --git a/crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js b/crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js index 3d436ff4d4e..1c809d256b1 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js @@ -17966,25 +17966,25 @@ 'f64.reinterpret/i64': 0xbf }; _exports.typeGenerators = { - function: (json, stream)=>{ + function (json, stream) { leb.unsigned.write(json, stream); }, - table: (json, stream)=>{ + table (json, stream) { stream.write([ LANGUAGE_TYPES[json.elementType] ]), _exports.typeGenerators.memory(json.limits, stream); }, - global: (json, stream)=>{ + global (json, stream) { stream.write([ LANGUAGE_TYPES[json.contentType] ]), stream.write([ json.mutability ]); }, - memory: (json, stream)=>{ + memory (json, stream) { leb.unsigned.write(Number(void 0 !== json.maximum), stream), leb.unsigned.write(json.intial, stream), void 0 !== json.maximum && leb.unsigned.write(json.maximum, stream); }, - initExpr: (json, stream)=>{ + initExpr (json, stream) { _exports.generateOp(json, stream), _exports.generateOp({ name: 'end', type: 'void' @@ -18002,7 +18002,7 @@ block_type: (json, stream)=>(stream.write([ LANGUAGE_TYPES[json] ]), stream), - br_table: (json, stream)=>{ + br_table (json, stream) { for (let target of (leb.unsigned.write(json.targets.length, stream), json.targets))leb.unsigned.write(target, stream); return leb.unsigned.write(json.defaultTarget, stream), stream; }, @@ -18012,7 +18012,7 @@ memory_immediate: (json, stream)=>(leb.unsigned.write(json.flags, stream), leb.unsigned.write(json.offset, stream), stream) }; const entryGenerators = { - type: (entry, stream = new Stream())=>{ + type (entry, stream = new Stream()) { stream.write([ LANGUAGE_TYPES[entry.form] ]); @@ -18023,7 +18023,7 @@ LANGUAGE_TYPES[entry.return_type] ]), stream.buffer; }, - import: (entry, stream = new Stream())=>{ + import (entry, stream = new Stream()) { leb.unsigned.write(entry.moduleStr.length, stream), stream.write(entry.moduleStr), leb.unsigned.write(entry.fieldStr.length, stream), stream.write(entry.fieldStr), stream.write([ EXTERNAL_KIND[entry.kind] ]), _exports.typeGenerators[entry.kind](entry.type, stream); @@ -18032,17 +18032,17 @@ table: _exports.typeGenerators.table, global: (entry, stream = new Stream())=>(_exports.typeGenerators.global(entry.type, stream), _exports.typeGenerators.initExpr(entry.init, stream), stream), memory: _exports.typeGenerators.memory, - export: (entry, stream = new Stream())=>{ + export (entry, stream = new Stream()) { const fieldStr = Buffer.from(entry.field_str), strLen = fieldStr.length; return leb.unsigned.write(strLen, stream), stream.write(fieldStr), stream.write([ EXTERNAL_KIND[entry.kind] ]), leb.unsigned.write(entry.index, stream), stream; }, - element: (entry, stream = new Stream())=>{ + element (entry, stream = new Stream()) { for (let elem of (leb.unsigned.write(entry.index, stream), _exports.typeGenerators.initExpr(entry.offset, stream), leb.unsigned.write(entry.elements.length, stream), entry.elements))leb.unsigned.write(elem, stream); return stream; }, - code: (entry, stream = new Stream())=>{ + code (entry, stream = new Stream()) { let codeStream = new Stream(); for (let local of (leb.unsigned.write(entry.locals.length, codeStream), entry.locals))leb.unsigned.write(local.count, codeStream), codeStream.write([ LANGUAGE_TYPES[local.type] @@ -18359,19 +18359,19 @@ 11: 'data' }; _exports.immediataryParsers = { - varuint1: (stream)=>{ + varuint1 (stream) { const int1 = stream.read(1)[0]; return int1; }, - varuint32: (stream)=>{ + varuint32 (stream) { const int32 = leb.unsigned.read(stream); return int32; }, - varint32: (stream)=>{ + varint32 (stream) { const int32 = leb.signed.read(stream); return int32; }, - varint64: (stream)=>{ + varint64 (stream) { const int64 = leb.signed.read(stream); return int64; }, @@ -18381,11 +18381,11 @@ uint64: (stream)=>[ ...stream.read(8) ], - block_type: (stream)=>{ + block_type (stream) { const type = stream.read(1)[0]; return LANGUAGE_TYPES[type]; }, - br_table: (stream)=>{ + br_table (stream) { const json = { targets: [] }, num = leb.unsigned.readBn(stream).toNumber(); @@ -18395,36 +18395,36 @@ } return json.defaultTarget = leb.unsigned.readBn(stream).toNumber(), json; }, - call_indirect: (stream)=>{ + call_indirect (stream) { const json = {}; return json.index = leb.unsigned.readBn(stream).toNumber(), json.reserved = stream.read(1)[0], json; }, - memory_immediate: (stream)=>{ + memory_immediate (stream) { const json = {}; return json.flags = leb.unsigned.readBn(stream).toNumber(), json.offset = leb.unsigned.readBn(stream).toNumber(), json; } }, _exports.typeParsers = { function: (stream)=>leb.unsigned.readBn(stream).toNumber(), - table: (stream)=>{ + table (stream) { const entry = {}, type = stream.read(1)[0]; return entry.elementType = LANGUAGE_TYPES[type], entry.limits = _exports.typeParsers.memory(stream), entry; }, - global: (stream)=>{ + global (stream) { const global = {}; let type = stream.read(1)[0]; return global.contentType = LANGUAGE_TYPES[type], global.mutability = stream.read(1)[0], global; }, - memory: (stream)=>{ + memory (stream) { const limits = {}; return limits.flags = leb.unsigned.readBn(stream).toNumber(), limits.intial = leb.unsigned.readBn(stream).toNumber(), 1 === limits.flags && (limits.maximum = leb.unsigned.readBn(stream).toNumber()), limits; }, - initExpr: (stream)=>{ + initExpr (stream) { const op = _exports.parseOp(stream); return stream.read(1), op; } }; const sectionParsers = _exports.sectionParsers = { - custom: (stream, header)=>{ + custom (stream, header) { const json = { name: 'custom' }, section = new Stream(stream.read(header.size)), nameLen = leb.unsigned.readBn(section).toNumber(), name = section.read(nameLen); @@ -18432,7 +18432,7 @@ ...section.buffer ], json; }, - type: (stream)=>{ + type (stream) { const numberOfEntries = leb.unsigned.readBn(stream).toNumber(), json = { name: 'type', entries: [] @@ -18452,7 +18452,7 @@ } return json; }, - import: (stream)=>{ + import (stream) { const numberOfEntries = leb.unsigned.readBn(stream).toNumber(), json = { name: 'import', entries: [] @@ -18467,7 +18467,7 @@ } return json; }, - function: (stream)=>{ + function (stream) { const numberOfEntries = leb.unsigned.readBn(stream).toNumber(), json = { name: 'function', entries: [] @@ -18478,7 +18478,7 @@ } return json; }, - table: (stream)=>{ + table (stream) { const numberOfEntries = leb.unsigned.readBn(stream).toNumber(), json = { name: 'table', entries: [] @@ -18489,7 +18489,7 @@ } return json; }, - memory: (stream)=>{ + memory (stream) { const numberOfEntries = leb.unsigned.readBn(stream).toNumber(), json = { name: 'memory', entries: [] @@ -18500,7 +18500,7 @@ } return json; }, - global: (stream)=>{ + global (stream) { const numberOfEntries = leb.unsigned.readBn(stream).toNumber(), json = { name: 'global', entries: [] @@ -18511,7 +18511,7 @@ } return json; }, - export: (stream)=>{ + export (stream) { const numberOfEntries = leb.unsigned.readBn(stream).toNumber(), json = { name: 'export', entries: [] @@ -18524,13 +18524,13 @@ } return json; }, - start: (stream)=>{ + start (stream) { const json = { name: 'start' }; return json.index = leb.unsigned.readBn(stream).toNumber(), json; }, - element: (stream)=>{ + element (stream) { const numberOfEntries = leb.unsigned.readBn(stream).toNumber(), json = { name: 'element', entries: [] @@ -18549,7 +18549,7 @@ } return json; }, - code: (stream)=>{ + code (stream) { const numberOfEntries = leb.unsigned.readBn(stream).toNumber(), json = { name: 'code', entries: [] @@ -18575,7 +18575,7 @@ } return json; }, - data: (stream)=>{ + data (stream) { const numberOfEntries = leb.unsigned.readBn(stream).toNumber(), json = { name: 'data', entries: [] @@ -19829,9 +19829,7 @@ { const { Worker: Worker1 } = dynamicRequire(module, 'worker_threads'); return { - async createWorker (url) { - return new Worker1(url); - }, + createWorker: async (url)=>new Worker1(url), addEventListener (worker, fn) { worker.on('message', (data)=>{ fn({ @@ -19959,9 +19957,7 @@ return reader.sliceAsBlob ? await reader.sliceAsBlob(offset, length, type) : await reader.read(offset, length); } const crc$1 = { - unsigned () { - return 0; - } + unsigned: ()=>0 }; function getUint16LE(uint8View, offset) { return uint8View[offset] + 0x100 * uint8View[offset + 1]; @@ -22858,7 +22854,7 @@ } }, api: { - _readContractState: (fnIndex, contractTxIdPtr)=>{ + _readContractState (fnIndex, contractTxIdPtr) { const contractTxId = wasmInstance.exports.__getString(contractTxIdPtr), callbackFn = getFn(fnIndex); return console.log('Simulating read state of', contractTxId), setTimeout(()=>{ console.log('calling callback'), callbackFn(wasmInstance.exports.__newString(JSON.stringify({ @@ -23024,7 +23020,7 @@ fd_close: ()=>0, fd_fdstat_get: ()=>0, fd_seek: ()=>0, - proc_exit: (code)=>{ + proc_exit (code) { if (__webpack_require__.g.process) process.exit(code); else throw 'trying to exit with code ' + code; }, @@ -23042,29 +23038,29 @@ this._values[id] = null, this._ids.delete(v), this._idPool.push(id); } }, - 'syscall/js.stringVal': (ret_ptr, value_ptr, value_len)=>{ + 'syscall/js.stringVal' (ret_ptr, value_ptr, value_len) { const s = loadString(value_ptr, value_len); storeValue(ret_ptr, s); }, - 'syscall/js.valueGet': (retval, v_addr, p_ptr, p_len)=>{ + 'syscall/js.valueGet' (retval, v_addr, p_ptr, p_len) { let prop = loadString(p_ptr, p_len), value = loadValue(v_addr), result = Reflect.get(value, prop); storeValue(retval, result); }, - 'syscall/js.valueSet': (v_addr, p_ptr, p_len, x_addr)=>{ + 'syscall/js.valueSet' (v_addr, p_ptr, p_len, x_addr) { const v = loadValue(v_addr), p = loadString(p_ptr, p_len), x = loadValue(x_addr); Reflect.set(v, p, x); }, - 'syscall/js.valueDelete': (v_addr, p_ptr, p_len)=>{ + 'syscall/js.valueDelete' (v_addr, p_ptr, p_len) { const v = loadValue(v_addr), p = loadString(p_ptr, p_len); Reflect.deleteProperty(v, p); }, - 'syscall/js.valueIndex': (ret_addr, v_addr, i)=>{ + 'syscall/js.valueIndex' (ret_addr, v_addr, i) { storeValue(ret_addr, Reflect.get(loadValue(v_addr), i)); }, - 'syscall/js.valueSetIndex': (v_addr, i, x_addr)=>{ + 'syscall/js.valueSetIndex' (v_addr, i, x_addr) { Reflect.set(loadValue(v_addr), i, loadValue(x_addr)); }, - 'syscall/js.valueCall': (ret_addr, v_addr, m_ptr, m_len, args_ptr, args_len, args_cap)=>{ + 'syscall/js.valueCall' (ret_addr, v_addr, m_ptr, m_len, args_ptr, args_len, args_cap) { const v = loadValue(v_addr), name = loadString(m_ptr, m_len), args = loadSliceOfValues(args_ptr, args_len, args_cap); try { const m = Reflect.get(v, name); @@ -23073,7 +23069,7 @@ storeValue(ret_addr, err), mem().setUint8(ret_addr + 8, 0); } }, - 'syscall/js.valueInvoke': (ret_addr, v_addr, args_ptr, args_len, args_cap)=>{ + 'syscall/js.valueInvoke' (ret_addr, v_addr, args_ptr, args_len, args_cap) { try { const v = loadValue(v_addr), args = loadSliceOfValues(args_ptr, args_len, args_cap); storeValue(ret_addr, Reflect.apply(v, void 0, args)), mem().setUint8(ret_addr + 8, 1); @@ -23081,7 +23077,7 @@ storeValue(ret_addr, err), mem().setUint8(ret_addr + 8, 0); } }, - 'syscall/js.valueNew': (ret_addr, v_addr, args_ptr, args_len, args_cap)=>{ + 'syscall/js.valueNew' (ret_addr, v_addr, args_ptr, args_len, args_cap) { const v = loadValue(v_addr), args = loadSliceOfValues(args_ptr, args_len, args_cap); try { storeValue(ret_addr, Reflect.construct(v, args)), mem().setUint8(ret_addr + 8, 1); @@ -23090,16 +23086,16 @@ } }, 'syscall/js.valueLength': (v_addr)=>loadValue(v_addr).length, - 'syscall/js.valuePrepareString': (ret_addr, v_addr)=>{ + 'syscall/js.valuePrepareString' (ret_addr, v_addr) { const s = String(loadValue(v_addr)), str = encoder.encode(s); storeValue(ret_addr, str), setInt64(ret_addr + 8, str.length); }, - 'syscall/js.valueLoadString': (v_addr, slice_ptr, slice_len, slice_cap)=>{ + 'syscall/js.valueLoadString' (v_addr, slice_ptr, slice_len, slice_cap) { const str = loadValue(v_addr); loadSlice(slice_ptr, slice_len, slice_cap).set(str); }, 'syscall/js.valueInstanceOf': (v_addr, t_addr)=>loadValue(v_addr) instanceof loadValue(t_addr), - 'syscall/js.copyBytesToGo': (ret_addr, dest_addr, dest_len, dest_cap, source_addr)=>{ + 'syscall/js.copyBytesToGo' (ret_addr, dest_addr, dest_len, dest_cap, source_addr) { let num_bytes_copied_addr = ret_addr, returned_status_addr = ret_addr + 4; const dst = loadSlice(dest_addr, dest_len), src = loadValue(source_addr); if (!(src instanceof Uint8Array)) { @@ -23109,7 +23105,7 @@ const toCopy = src.subarray(0, dst.length); dst.set(toCopy), setInt64(num_bytes_copied_addr, toCopy.length), mem().setUint8(returned_status_addr, 1); }, - 'syscall/js.copyBytesToJS': (ret_addr, dest_addr, source_addr, source_len, source_cap)=>{ + 'syscall/js.copyBytesToJS' (ret_addr, dest_addr, source_addr, source_len, source_cap) { let num_bytes_copied_addr = ret_addr, returned_status_addr = ret_addr + 4; const dst = loadValue(dest_addr), src = loadSlice(source_addr, source_len); if (!(dst instanceof Uint8Array)) { @@ -23657,16 +23653,16 @@ wallets: arweave.wallets, crypto: arweave.crypto }, this.evaluationOptions = evaluationOptions, this.contract = contract, this.transaction = new Transaction(this), this.block = new Block(this), this.contracts = { - readContractState: (contractId, height, returnValidity)=>{ + readContractState (contractId, height, returnValidity) { throw Error('Not implemented - should be set by HandlerApi implementor'); }, - viewContractState: (contractId, input)=>{ + viewContractState (contractId, input) { throw Error('Not implemented - should be set by HandlerApi implementor'); }, - write: (contractId, input)=>{ + write (contractId, input) { throw Error('Not implemented - should be set by HandlerApi implementor'); }, - refreshState: ()=>{ + refreshState () { throw Error('Not implemented - should be set by HandlerApi implementor'); } }, this.vrf = new Vrf(this), this.useGas = this.useGas.bind(this), this.getBalance = this.getBalance.bind(this); diff --git a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js index 5e29dd61cd7..0a1d8f72466 100644 --- a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js +++ b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js @@ -1,11 +1,11 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[634],{6158:function(i,r,n){var o=n(3454);!function(r,n){i.exports=n()}(this,function(){"use strict";var i,r,n;function s(o,s){if(i){if(r){var a="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+i+")(sharedChunk); ("+r+")(sharedChunk); self.onerror = null;",l={};i(l),n=s(l),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(n.workerUrl=window.URL.createObjectURL(new Blob([a],{type:"text/javascript"})))}else r=s}else i=s}return s(["exports"],function(i){var r,n="2.7.0",s=a;function a(i,r,n,o){this.cx=3*i,this.bx=3*(n-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*r,this.by=3*(o-r)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=o,this.p2x=n,this.p2y=o}a.prototype.sampleCurveX=function(i){return((this.ax*i+this.bx)*i+this.cx)*i},a.prototype.sampleCurveY=function(i){return((this.ay*i+this.by)*i+this.cy)*i},a.prototype.sampleCurveDerivativeX=function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},a.prototype.solveCurveX=function(i,r){var n,o,s,a,l;for(void 0===r&&(r=1e-6),s=i,l=0;l<8;l++){if(Math.abs(a=this.sampleCurveX(s)-i)Math.abs(c))break;s-=a/c}if((s=i)<(n=0))return n;if(s>(o=1))return o;for(;na?n=s:o=s,s=.5*(o-n)+n;return s},a.prototype.solve=function(i,r){return this.sampleCurveY(this.solveCurveX(i,r))};var l=c;function c(i,r){this.x=i,this.y=r}c.prototype={clone:function(){return new c(this.x,this.y)},add:function(i){return this.clone()._add(i)},sub:function(i){return this.clone()._sub(i)},multByPoint:function(i){return this.clone()._multByPoint(i)},divByPoint:function(i){return this.clone()._divByPoint(i)},mult:function(i){return this.clone()._mult(i)},div:function(i){return this.clone()._div(i)},rotate:function(i){return this.clone()._rotate(i)},rotateAround:function(i,r){return this.clone()._rotateAround(i,r)},matMult:function(i){return this.clone()._matMult(i)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(i){return this.x===i.x&&this.y===i.y},dist:function(i){return Math.sqrt(this.distSqr(i))},distSqr:function(i){var r=i.x-this.x,n=i.y-this.y;return r*r+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith:function(i){return this.angleWithSep(i.x,i.y)},angleWithSep:function(i,r){return Math.atan2(this.x*r-this.y*i,this.x*i+this.y*r)},_matMult:function(i){var r=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=r,this},_add:function(i){return this.x+=i.x,this.y+=i.y,this},_sub:function(i){return this.x-=i.x,this.y-=i.y,this},_mult:function(i){return this.x*=i,this.y*=i,this},_div:function(i){return this.x/=i,this.y/=i,this},_multByPoint:function(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint:function(i){return this.x/=i.x,this.y/=i.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var i=this.y;return this.y=this.x,this.x=-i,this},_rotate:function(i){var r=Math.cos(i),n=Math.sin(i),o=n*this.x+r*this.y;return this.x=r*this.x-n*this.y,this.y=o,this},_rotateAround:function(i,r){var n=Math.cos(i),o=Math.sin(i),s=r.y+o*(this.x-r.x)+n*(this.y-r.y);return this.x=r.x+n*(this.x-r.x)-o*(this.y-r.y),this.y=s,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},c.convert=function(i){return i instanceof c?i:Array.isArray(i)?new c(i[0],i[1]):i};var u="undefined"!=typeof self?self:{},h="undefined"!=typeof Float32Array?Float32Array:Array;function d(){var i=new h(9);return h!=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 p(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 f(i,r,n){var o=r[0],s=r[1],a=r[2],l=r[3],c=r[4],u=r[5],h=r[6],d=r[7],p=r[8],f=r[9],m=r[10],g=r[11],y=r[12],x=r[13],$=r[14],v=r[15],_=n[0],b=n[1],w=n[2],T=n[3];return i[0]=_*o+b*c+w*p+T*y,i[1]=_*s+b*u+w*f+T*x,i[2]=_*a+b*h+w*m+T*$,i[3]=_*l+b*d+w*g+T*v,i[4]=(_=n[4])*o+(b=n[5])*c+(w=n[6])*p+(T=n[7])*y,i[5]=_*s+b*u+w*f+T*x,i[6]=_*a+b*h+w*m+T*$,i[7]=_*l+b*d+w*g+T*v,i[8]=(_=n[8])*o+(b=n[9])*c+(w=n[10])*p+(T=n[11])*y,i[9]=_*s+b*u+w*f+T*x,i[10]=_*a+b*h+w*m+T*$,i[11]=_*l+b*d+w*g+T*v,i[12]=(_=n[12])*o+(b=n[13])*c+(w=n[14])*p+(T=n[15])*y,i[13]=_*s+b*u+w*f+T*x,i[14]=_*a+b*h+w*m+T*$,i[15]=_*l+b*d+w*g+T*v,i}function m(i,r,n){var o,s,a,l,c,u,h,d,p,f,m,g,y=n[0],x=n[1],$=n[2];return r===i?(i[12]=r[0]*y+r[4]*x+r[8]*$+r[12],i[13]=r[1]*y+r[5]*x+r[9]*$+r[13],i[14]=r[2]*y+r[6]*x+r[10]*$+r[14],i[15]=r[3]*y+r[7]*x+r[11]*$+r[15]):(s=r[1],a=r[2],l=r[3],c=r[4],u=r[5],h=r[6],d=r[7],p=r[8],f=r[9],m=r[10],g=r[11],i[0]=o=r[0],i[1]=s,i[2]=a,i[3]=l,i[4]=c,i[5]=u,i[6]=h,i[7]=d,i[8]=p,i[9]=f,i[10]=m,i[11]=g,i[12]=o*y+c*x+p*$+r[12],i[13]=s*y+u*x+f*$+r[13],i[14]=a*y+h*x+m*$+r[14],i[15]=l*y+d*x+g*$+r[15]),i}function g(i,r,n){var o=n[0],s=n[1],a=n[2];return i[0]=r[0]*o,i[1]=r[1]*o,i[2]=r[2]*o,i[3]=r[3]*o,i[4]=r[4]*s,i[5]=r[5]*s,i[6]=r[6]*s,i[7]=r[7]*s,i[8]=r[8]*a,i[9]=r[9]*a,i[10]=r[10]*a,i[11]=r[11]*a,i[12]=r[12],i[13]=r[13],i[14]=r[14],i[15]=r[15],i}function y(i,r,n){var o=Math.sin(n),s=Math.cos(n),a=r[4],l=r[5],c=r[6],u=r[7],h=r[8],d=r[9],p=r[10],f=r[11];return r!==i&&(i[0]=r[0],i[1]=r[1],i[2]=r[2],i[3]=r[3],i[12]=r[12],i[13]=r[13],i[14]=r[14],i[15]=r[15]),i[4]=a*s+h*o,i[5]=l*s+d*o,i[6]=c*s+p*o,i[7]=u*s+f*o,i[8]=h*s-a*o,i[9]=d*s-l*o,i[10]=p*s-c*o,i[11]=f*s-u*o,i}function x(i,r,n){var o=Math.sin(n),s=Math.cos(n),a=r[0],l=r[1],c=r[2],u=r[3],h=r[8],d=r[9],p=r[10],f=r[11];return r!==i&&(i[4]=r[4],i[5]=r[5],i[6]=r[6],i[7]=r[7],i[12]=r[12],i[13]=r[13],i[14]=r[14],i[15]=r[15]),i[0]=a*s-h*o,i[1]=l*s-d*o,i[2]=c*s-p*o,i[3]=u*s-f*o,i[8]=a*o+h*s,i[9]=l*o+d*s,i[10]=c*o+p*s,i[11]=u*o+f*s,i}Math.hypot||(Math.hypot=function(){for(var i=0,r=arguments.length;r--;)i+=arguments[r]*arguments[r];return Math.sqrt(i)});var $=f;function v(){var i=new h(3);return h!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0),i}function _(i){var r=new h(3);return r[0]=i[0],r[1]=i[1],r[2]=i[2],r}function b(i){return Math.hypot(i[0],i[1],i[2])}function w(i,r,n){var o=new h(3);return o[0]=i,o[1]=r,o[2]=n,o}function T(i,r,n){return i[0]=r[0]+n[0],i[1]=r[1]+n[1],i[2]=r[2]+n[2],i}function E(i,r,n){return i[0]=r[0]-n[0],i[1]=r[1]-n[1],i[2]=r[2]-n[2],i}function S(i,r,n){return i[0]=r[0]*n[0],i[1]=r[1]*n[1],i[2]=r[2]*n[2],i}function I(i,r,n){return i[0]=Math.max(r[0],n[0]),i[1]=Math.max(r[1],n[1]),i[2]=Math.max(r[2],n[2]),i}function C(i,r,n){return i[0]=r[0]*n,i[1]=r[1]*n,i[2]=r[2]*n,i}function z(i,r,n,o){return i[0]=r[0]+n[0]*o,i[1]=r[1]+n[1]*o,i[2]=r[2]+n[2]*o,i}function A(i,r){var n=r[0],o=r[1],s=r[2],a=n*n+o*o+s*s;return a>0&&(a=1/Math.sqrt(a)),i[0]=r[0]*a,i[1]=r[1]*a,i[2]=r[2]*a,i}function k(i,r){return i[0]*r[0]+i[1]*r[1]+i[2]*r[2]}function P(i,r,n){var o=r[0],s=r[1],a=r[2],l=n[0],c=n[1],u=n[2];return i[0]=s*u-a*c,i[1]=a*l-o*u,i[2]=o*c-s*l,i}function D(i,r,n){var o=r[0],s=r[1],a=r[2],l=n[3]*o+n[7]*s+n[11]*a+n[15];return i[0]=(n[0]*o+n[4]*s+n[8]*a+n[12])/(l=l||1),i[1]=(n[1]*o+n[5]*s+n[9]*a+n[13])/l,i[2]=(n[2]*o+n[6]*s+n[10]*a+n[14])/l,i}function L(i,r,n){var o=n[0],s=n[1],a=n[2],l=r[0],c=r[1],u=r[2],h=s*u-a*c,d=a*l-o*u,p=o*c-s*l,f=s*p-a*d,m=a*h-o*p,g=o*d-s*h,y=2*n[3];return d*=y,p*=y,m*=2,g*=2,i[0]=l+(h*=y)+(f*=2),i[1]=c+d+m,i[2]=u+p+g,i}var B,R=E;function M(i,r,n){var o=r[0],s=r[1],a=r[2],l=r[3];return i[0]=n[0]*o+n[4]*s+n[8]*a+n[12]*l,i[1]=n[1]*o+n[5]*s+n[9]*a+n[13]*l,i[2]=n[2]*o+n[6]*s+n[10]*a+n[14]*l,i[3]=n[3]*o+n[7]*s+n[11]*a+n[15]*l,i}function F(){var i=new h(4);return h!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0),i[3]=1,i}function O(i){return i[0]=0,i[1]=0,i[2]=0,i[3]=1,i}function U(i,r,n){n*=.5;var o=r[0],s=r[1],a=r[2],l=r[3],c=Math.sin(n),u=Math.cos(n);return i[0]=o*u+l*c,i[1]=s*u+a*c,i[2]=a*u-s*c,i[3]=l*u-o*c,i}function V(i,r){return i[0]===r[0]&&i[1]===r[1]}v(),B=new h(4),h!=Float32Array&&(B[0]=0,B[1]=0,B[2]=0,B[3]=0),v(),w(1,0,0),w(0,1,0),F(),F(),d(),r=new h(2),h!=Float32Array&&(r[0]=0,r[1]=0);const j=Math.PI/180,N=180/Math.PI;function G(i){return i*j}function Z(i){return i*N}const q=[[0,0],[1,0],[1,1],[0,1],];function X(i){if(i<=0)return 0;if(i>=1)return 1;const r=i*i,n=r*i;return 4*(i<.5?n:3*(i-r)+n-.75)}function W(i,r,n,o){const a=new s(i,r,n,o);return function(i){return a.solve(i)}}const H=W(.25,.1,.25,1);function K(i,r,n){return Math.min(n,Math.max(r,i))}function Y(i,r,n){return(n=K((n-i)/(r-i),0,1))*n*(3-2*n)}function J(i,r,n){const o=n-r,s=((i-r)%o+o)%o+r;return s===r?n:s}function Q(i,r,n){if(!i.length)return n(null,[]);let o=i.length;const s=Array(i.length);let a=null;i.forEach((i,l)=>{r(i,(i,r)=>{i&&(a=i),s[l]=r,0==--o&&n(a,s)})})}function ee(i){const r=[];for(const n in i)r.push(i[n]);return r}function et(i,...r){for(const n of r)for(const o in n)i[o]=n[o];return i}let ei=1;function er(){return ei++}function en(){return function i(r){return r?(r^16*Math.random()>>r/4).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,i)}()}function eo(i){return i<=1?1:Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function es(i){return!!i&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(i)}function ea(i,r){i.forEach(i=>{r[i]&&(r[i]=r[i].bind(r))})}function el(i,r){return -1!==i.indexOf(r,i.length-r.length)}function ec(i,r,n){const o={};for(const s in i)o[s]=r.call(n||this,i[s],s,i);return o}function eu(i,r,n){const o={};for(const s in i)r.call(n||this,i[s],s,i)&&(o[s]=i[s]);return o}function eh(i){return Array.isArray(i)?i.map(eh):"object"==typeof i&&i?ec(i,eh):i}const ed={};function ep(i){ed[i]||("undefined"!=typeof console&&console.warn(i),ed[i]=!0)}function ef(i,r,n){return(n.y-i.y)*(r.x-i.x)>(r.y-i.y)*(n.x-i.x)}function em(i){let r=0;for(let n,o,s=0,a=i.length,l=a-1;s@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(i,n,o,s)=>{const a=o||s;return r[n]=!a||a.toLowerCase(),""}),r["max-age"]){const n=parseInt(r["max-age"],10);isNaN(n)?delete r["max-age"]:r["max-age"]=n}return r}let ey,ex,e$,ev=null;function e_(i){if(null==ev){const r=i.navigator?i.navigator.userAgent:null;ev=!!i.safari||!(!r||!(/\b(iPad|iPhone|iPod)\b/.test(r)||r.match("Safari")&&!r.match("Chrome")))}return ev}function eb(i){try{const r=u[i];return r.setItem("_mapbox_test_",1),r.removeItem("_mapbox_test_"),!0}catch(n){return!1}}const ew={now:()=>void 0!==e$?e$:u.performance.now(),setNow(i){e$=i},restoreNow(){e$=void 0},frame(i){const r=u.requestAnimationFrame(i);return{cancel:()=>u.cancelAnimationFrame(r)}},getImageData(i,r=0){const n=u.document.createElement("canvas"),o=n.getContext("2d");if(!o)throw Error("failed to create canvas 2d context");return n.width=i.width,n.height=i.height,o.drawImage(i,0,0,i.width,i.height),o.getImageData(-r,-r,i.width+2*r,i.height+2*r)},resolveURL:i=>(ey||(ey=u.document.createElement("a")),ey.href=i,ey.href),get devicePixelRatio(){return u.devicePixelRatio},get prefersReducedMotion(){return!!u.matchMedia&&(null==ex&&(ex=u.matchMedia("(prefers-reduced-motion: reduce)")),ex.matches)}};let e0;const eT={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==e0){const eE=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{e0=null!=o.env.API_URL_REGEX?RegExp(o.env.API_URL_REGEX):eE}catch(eS){e0=eE}}return e0},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},eI={supported:!1,testSupport:function(i){!eA&&ez&&(ek?eP(i):eC=i)}};let eC,ez,eA=!1,ek=!1;function eP(i){const r=i.createTexture();i.bindTexture(i.TEXTURE_2D,r);try{if(i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,ez),i.isContextLost())return;eI.supported=!0}catch(n){}i.deleteTexture(r),eA=!0}u.document&&((ez=u.document.createElement("img")).onload=function(){eC&&eP(eC),eC=null,ek=!0},ez.onerror=function(){eA=!0,eC=null},ez.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const eD="NO_ACCESS_TOKEN";function eL(i){return 0===i.indexOf("mapbox:")}function e1(i){return eT.API_URL_REGEX.test(i)}const eB=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function eR(i){const r=i.match(eB);if(!r)throw Error("Unable to parse URL object");return{protocol:r[1],authority:r[2],path:r[3]||"/",params:r[4]?r[4].split("&"):[]}}function e3(i){const r=i.params.length?`?${i.params.join("&")}`:"";return`${i.protocol}://${i.authority}${i.path}${r}`}function eM(i){if(!i)return null;const r=i.split(".");if(!r||3!==r.length)return null;try{return JSON.parse(decodeURIComponent(u.atob(r[1]).split("").map(i=>"%"+("00"+i.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(n){return null}}class e2{constructor(i){this.type=i,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(i){const r=eM(eT.ACCESS_TOKEN);let n="";return n=r&&r.u?u.btoa(encodeURIComponent(r.u).replace(/%([0-9A-F]{2})/g,(i,r)=>String.fromCharCode(Number("0x"+r)))):eT.ACCESS_TOKEN||"",i?`mapbox.eventData.${i}:${n}`:`mapbox.eventData:${n}`}fetchEventData(){const i=eb("localStorage"),r=this.getStorageKey(),n=this.getStorageKey("uuid");if(i)try{const o=u.localStorage.getItem(r);o&&(this.eventData=JSON.parse(o));const s=u.localStorage.getItem(n);s&&(this.anonId=s)}catch(a){ep("Unable to read from LocalStorage")}}saveEventData(){const i=eb("localStorage"),r=this.getStorageKey(),n=this.getStorageKey("uuid");if(i)try{u.localStorage.setItem(n,this.anonId),Object.keys(this.eventData).length>=1&&u.localStorage.setItem(r,JSON.stringify(this.eventData))}catch(o){ep("Unable to write to LocalStorage")}}processRequests(i){}postEvent(i,r,o,s){if(!eT.EVENTS_URL)return;const a=eR(eT.EVENTS_URL);a.params.push(`access_token=${s||eT.ACCESS_TOKEN||""}`);const l={event:this.type,created:new Date(i).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:n,skuId:"01",userId:this.anonId},c=r?et(l,r):l,u={url:e3(a),headers:{"Content-Type":"text/plain"},body:JSON.stringify([c])};this.pendingRequest=eQ(u,i=>{this.pendingRequest=null,o(i),this.saveEventData(),this.processRequests(s)})}queueRequest(i,r){this.queue.push(i),this.processRequests(r)}}const eF=new class extends e2{constructor(i){super("appUserTurnstile"),this._customAccessToken=i}postTurnstileEvent(i,r){eT.EVENTS_URL&&eT.ACCESS_TOKEN&&Array.isArray(i)&&i.some(i=>eL(i)||e1(i))&&this.queueRequest(Date.now(),r)}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const r=eM(eT.ACCESS_TOKEN),n=r?r.u:eT.ACCESS_TOKEN;let o=n!==this.eventData.tokenU;es(this.anonId)||(this.anonId=en(),o=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const a=new Date(this.eventData.lastSuccess),l=new Date(s),c=(s-this.eventData.lastSuccess)/864e5;o=o||c>=1||c<-1||a.getDate()!==l.getDate()}else o=!0;if(!o)return this.processRequests();this.postEvent(s,{"enabled.telemetry":!1},i=>{i||(this.eventData.lastSuccess=s,this.eventData.tokenU=n)},i)}},eO=eF.postTurnstileEvent.bind(eF),e4=new class extends e2{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(i,r,n,o){this.skuToken=r,this.errorCb=o,eT.EVENTS_URL&&(n||eT.ACCESS_TOKEN?this.queueRequest({id:i,timestamp:Date.now()},n):this.errorCb(Error(eD)))}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;const{id:r,timestamp:n}=this.queue.shift();r&&this.success[r]||(this.anonId||this.fetchEventData(),es(this.anonId)||(this.anonId=en()),this.postEvent(n,{skuToken:this.skuToken},i=>{i?this.errorCb(i):r&&(this.success[r]=!0)},i))}},eU=e4.postMapLoadEvent.bind(e4),eV=new class extends e2{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(i,r,n,o){if(!eT.API_URL||!eT.SESSION_PATH)return;const s=eR(eT.API_URL+eT.SESSION_PATH);s.params.push(`sku=${r||""}`),s.params.push(`access_token=${o||eT.ACCESS_TOKEN||""}`);const a={url:e3(s),headers:{"Content-Type":"text/plain"}};this.pendingRequest=te(a,i=>{this.pendingRequest=null,n(i),this.saveEventData(),this.processRequests(o)})}getSessionAPI(i,r,n,o){this.skuToken=r,this.errorCb=o,eT.SESSION_PATH&&eT.API_URL&&(n||eT.ACCESS_TOKEN?this.queueRequest({id:i,timestamp:Date.now()},n):this.errorCb(Error(eD)))}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;const{id:r,timestamp:n}=this.queue.shift();r&&this.success[r]||this.getSession(n,this.skuToken,i=>{i?this.errorCb(i):r&&(this.success[r]=!0)},i)}},e6=eV.getSessionAPI.bind(eV),ej=new Set,eN="mapbox-tiles";let eG,eZ,e9=500,e7=50;function eq(){u.caches&&!eG&&(eG=u.caches.open(eN))}function e5(i){const r=i.indexOf("?");return r<0?i:i.slice(0,r)}let eX=1/0;const eW={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(eW);class eH extends Error{constructor(i,r,n){401===r&&e1(n)&&(i+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(i),this.status=r,this.url=n}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const eK=e8()?()=>self.worker&&self.worker.referrer:()=>("blob:"===u.location.protocol?u.parent:u).location.href,eY=function(i,r){var n;if(!(/^file:/.test(n=i.url)||/^file:/.test(eK())&&!/^\w+:/.test(n))){if(u.fetch&&u.Request&&u.AbortController&&u.Request.prototype.hasOwnProperty("signal"))return function(i,r){var n;const o=new u.AbortController,s=new u.Request(i.url,{method:i.method||"GET",body:i.body,credentials:i.credentials,headers:i.headers,referrer:eK(),signal:o.signal});let a=!1,l=!1;const c=(n=s.url).indexOf("sku=")>0&&e1(n);"json"===i.type&&s.headers.set("Accept","application/json");const h=(n,o,a)=>{if(l)return;if(n&&"SecurityError"!==n.message&&ep(n),o&&a)return d(o);const h=Date.now();u.fetch(s).then(n=>{if(n.ok){const o=c?n.clone():null;return d(n,o,h)}return r(new eH(n.statusText,n.status,i.url))}).catch(i=>{20!==i.code&&r(Error(i.message))})},d=(n,o,c)=>{("arrayBuffer"===i.type?n.arrayBuffer():"json"===i.type?n.json():n.text()).then(i=>{l||(o&&c&&function(i,r,n){if(eq(),!eG)return;const o={status:r.status,statusText:r.statusText,headers:new u.Headers};r.headers.forEach((i,r)=>o.headers.set(r,i));const s=eg(r.headers.get("Cache-Control")||"");s["no-store"]||(s["max-age"]&&o.headers.set("Expires",new Date(n+1e3*s["max-age"]).toUTCString()),new Date(o.headers.get("Expires")).getTime()-n<42e4||function(i,r){if(void 0===eZ)try{new Response(new ReadableStream),eZ=!0}catch(n){eZ=!1}eZ?r(i.body):i.blob().then(r)}(r,r=>{const n=new u.Response(r,o);eq(),eG&&eG.then(r=>r.put(e5(i.url),n)).catch(i=>ep(i.message))}))}(s,o,c),a=!0,r(null,i,n.headers.get("Cache-Control"),n.headers.get("Expires")))}).catch(i=>{l||r(Error(i.message))})};return c?function(i,r){if(eq(),!eG)return r(null);const n=e5(i.url);eG.then(i=>{i.match(n).then(o=>{const s=function(i){if(!i)return!1;const r=new Date(i.headers.get("Expires")||0),n=eg(i.headers.get("Cache-Control")||"");return r>Date.now()&&!n["no-cache"]}(o);i.delete(n),s&&i.put(n,o.clone()),r(null,o,s)}).catch(r)}).catch(r)}(s,h):h(null,null),{cancel:()=>{l=!0,a||o.abort()}}}(i,r);if(e8()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",i,r,void 0,!0)}return function(i,r){const n=new u.XMLHttpRequest;for(const o in n.open(i.method||"GET",i.url,!0),"arrayBuffer"===i.type&&(n.responseType="arraybuffer"),i.headers)n.setRequestHeader(o,i.headers[o]);return"json"===i.type&&(n.responseType="text",n.setRequestHeader("Accept","application/json")),n.withCredentials="include"===i.credentials,n.onerror=()=>{r(Error(n.statusText))},n.onload=()=>{if((n.status>=200&&n.status<300||0===n.status)&&null!==n.response){let o=n.response;if("json"===i.type)try{o=JSON.parse(n.response)}catch(s){return r(s)}r(null,o,n.getResponseHeader("Cache-Control"),n.getResponseHeader("Expires"))}else r(new eH(n.statusText,n.status,i.url))},n.send(i.body),{cancel:()=>n.abort()}}(i,r)},eJ=function(i,r){return eY(et(i,{type:"arrayBuffer"}),r)},eQ=function(i,r){return eY(et(i,{method:"POST"}),r)},te=function(i,r){return eY(et(i,{method:"GET"}),r)};function tt(i){const r=u.document.createElement("a");return r.href=i,r.protocol===u.document.location.protocol&&r.host===u.document.location.host}const ti="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let tr,tn;tr=[],tn=0;const to=function(i,r){if(eI.supported&&(i.headers||(i.headers={}),i.headers.accept="image/webp,*/*"),tn>=eT.MAX_PARALLEL_IMAGE_REQUESTS){const n={requestParameters:i,callback:r,cancelled:!1,cancel(){this.cancelled=!0}};return tr.push(n),n}tn++;let o=!1;const s=()=>{if(!o)for(o=!0,tn--;tr.length&&tn{s(),i?r(i):n&&(u.createImageBitmap?function(i,r){const n=new u.Blob([new Uint8Array(i)],{type:"image/png"});u.createImageBitmap(n).then(i=>{r(null,i)}).catch(i=>{r(Error(`Could not load image because of ${i.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(n,(i,n)=>r(i,n,o,a)):function(i,r){const n=new u.Image,o=u.URL;n.onload=()=>{r(null,n),o.revokeObjectURL(n.src),n.onload=null,u.requestAnimationFrame(()=>{n.src=ti})},n.onerror=()=>r(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 s=new u.Blob([new Uint8Array(i)],{type:"image/png"});n.src=i.byteLength?o.createObjectURL(s):ti}(n,(i,n)=>r(i,n,o,a)))});return{cancel:()=>{a.cancel(),s()}}};function ts(i,r,n){n[i]&&-1!==n[i].indexOf(r)||(n[i]=n[i]||[],n[i].push(r))}function ta(i,r,n){if(n&&n[i]){const o=n[i].indexOf(r);-1!==o&&n[i].splice(o,1)}}class tl{constructor(i,r={}){et(this,r),this.type=i}}class tc extends tl{constructor(i,r={}){super("error",et({error:i},r))}}class tu{on(i,r){return this._listeners=this._listeners||{},ts(i,r,this._listeners),this}off(i,r){return ta(i,r,this._listeners),ta(i,r,this._oneTimeListeners),this}once(i,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},ts(i,r,this._oneTimeListeners),this):new Promise(r=>this.once(i,r))}fire(i,r){"string"==typeof i&&(i=new tl(i,r||{}));const n=i.type;if(this.listens(n)){i.target=this;const o=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const s of o)s.call(this,i);const a=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const l of a)ta(n,l,this._oneTimeListeners),l.call(this,i);const c=this._eventedParent;c&&(et(i,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),c.fire(i))}else i instanceof tc&&console.error(i.error);return this}listens(i){return!!(this._listeners&&this._listeners[i]&&this._listeners[i].length>0||this._oneTimeListeners&&this._oneTimeListeners[i]&&this._oneTimeListeners[i].length>0||this._eventedParent&&this._eventedParent.listens(i))}setEventedParent(i,r){return this._eventedParent=i,this._eventedParentData=r,this}}var th=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":0.1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');class td{constructor(i,r,n,o){this.message=(i?`${i}: `:"")+n,o&&(this.identifier=o),null!=r&&r.__line__&&(this.line=r.__line__)}}function tp(i){const r=i.value;return r?[new td(i.key,r,"constants have been deprecated as of v8"),]:[]}function tf(i,...r){for(const n of r)for(const o in n)i[o]=n[o];return i}function tm(i){return i instanceof Number||i instanceof String||i instanceof Boolean?i.valueOf():i}function t8(i){if(Array.isArray(i))return i.map(t8);if(i instanceof Object&&!(i instanceof Number||i instanceof String||i instanceof Boolean)){const r={};for(const n in i)r[n]=t8(i[n]);return r}return tm(i)}class tg extends Error{constructor(i,r){super(r),this.message=r,this.key=i}}class ty{constructor(i,r=[]){for(const[n,o]of(this.parent=i,this.bindings={},r))this.bindings[n]=o}concat(i){return new ty(this,i)}get(i){if(this.bindings[i])return this.bindings[i];if(this.parent)return this.parent.get(i);throw Error(`${i} not found in scope.`)}has(i){return!!this.bindings[i]||!!this.parent&&this.parent.has(i)}}const tx={kind:"null"},t$={kind:"number"},tv={kind:"string"},t_={kind:"boolean"},tb={kind:"color"},tw={kind:"object"},t0={kind:"value"},tT={kind:"collator"},tE={kind:"formatted"},tS={kind:"resolvedImage"};function tI(i,r){return{kind:"array",itemType:i,N:r}}function tC(i){if("array"===i.kind){const r=tC(i.itemType);return"number"==typeof i.N?`array<${r}, ${i.N}>`:"value"===i.itemType.kind?"array":`array<${r}>`}return i.kind}const tz=[tx,t$,tv,t_,tb,tE,tw,tI(t0),tS];function tA(i,r){if("error"===r.kind)return null;if("array"===i.kind){if("array"===r.kind&&(0===r.N&&"value"===r.itemType.kind||!tA(i.itemType,r.itemType))&&("number"!=typeof i.N||i.N===r.N))return null}else{if(i.kind===r.kind)return null;if("value"===i.kind){for(const n of tz)if(!tA(n,r))return null}}return`Expected ${tC(i)} but found ${tC(r)} instead.`}function tk(i,r){return r.some(r=>r.kind===i.kind)}function tP(i,r){return r.some(r=>"null"===r?null===i:"array"===r?Array.isArray(i):"object"===r?i&&!Array.isArray(i)&&"object"==typeof i:r===typeof i)}function tD(i){var r={exports:{}};return i(r,r.exports),r.exports}var tL=tD(function(i,r){var n={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function o(i){return(i=Math.round(i))<0?0:i>255?255:i}function s(i){return o("%"===i[i.length-1]?parseFloat(i)/100*255:parseInt(i))}function a(i){var r;return(r="%"===i[i.length-1]?parseFloat(i)/100:parseFloat(i))<0?0:r>1?1:r}function l(i,r,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?i+(r-i)*n*6:2*n<1?r:3*n<2?i+(r-i)*(2/3-n)*6:i}try{r.parseCSSColor=function(i){var r,c=i.replace(/ /g,"").toLowerCase();if(c in n)return n[c].slice();if("#"===c[0])return 4===c.length?(r=parseInt(c.substr(1),16))>=0&&r<=4095?[(3840&r)>>4|(3840&r)>>8,240&r|(240&r)>>4,15&r|(15&r)<<4,1,]:null:7===c.length&&(r=parseInt(c.substr(1),16))>=0&&r<=16777215?[(16711680&r)>>16,(65280&r)>>8,255&r,1,]:null;var u=c.indexOf("("),h=c.indexOf(")");if(-1!==u&&h+1===c.length){var d=c.substr(0,u),p=c.substr(u+1,h-(u+1)).split(","),f=1;switch(d){case"rgba":if(4!==p.length)break;f=a(p.pop());case"rgb":return 3!==p.length?null:[s(p[0]),s(p[1]),s(p[2]),f,];case"hsla":if(4!==p.length)break;f=a(p.pop());case"hsl":if(3!==p.length)break;var m=(parseFloat(p[0])%360+360)%360/360,g=a(p[1]),y=a(p[2]),x=y<=.5?y*(g+1):y+g-y*g,$=2*y-x;return[o(255*l($,x,m+1/3)),o(255*l($,x,m)),o(255*l($,x,m-1/3)),f,]}}return null}}catch(c){}});class t1{constructor(i,r,n,o=1){this.r=i,this.g=r,this.b=n,this.a=o}static parse(i){if(!i)return;if(i instanceof t1)return i;if("string"!=typeof i)return;const r=tL.parseCSSColor(i);return r?new t1(r[0]/255*r[3],r[1]/255*r[3],r[2]/255*r[3],r[3]):void 0}toString(){const[i,r,n,o]=this.toArray();return`rgba(${Math.round(i)},${Math.round(r)},${Math.round(n)},${o})`}toArray(){const{r:i,g:r,b:n,a:o}=this;return 0===o?[0,0,0,0]:[255*i/o,255*r/o,255*n/o,o,]}}t1.black=new t1(0,0,0,1),t1.white=new t1(1,1,1,1),t1.transparent=new t1(0,0,0,0),t1.red=new t1(1,0,0,1),t1.blue=new t1(0,0,1,1);class tB{constructor(i,r,n){this.sensitivity=i?r?"variant":"case":r?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(i,r){return this.collator.compare(i,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class tR{constructor(i,r,n,o,s){this.text=i.normalize?i.normalize():i,this.image=r,this.scale=n,this.fontStack=o,this.textColor=s}}class t3{constructor(i){this.sections=i}static fromString(i){return new t3([new tR(i,null,null,null,null),])}isEmpty(){return 0===this.sections.length||!this.sections.some(i=>0!==i.text.length||i.image&&0!==i.image.name.length)}static factory(i){return i instanceof t3?i:t3.fromString(i)}toString(){return 0===this.sections.length?"":this.sections.map(i=>i.text).join("")}serialize(){const i=["format"];for(const r of this.sections){if(r.image){i.push(["image",r.image.name]);continue}i.push(r.text);const n={};r.fontStack&&(n["text-font"]=["literal",r.fontStack.split(","),]),r.scale&&(n["font-scale"]=r.scale),r.textColor&&(n["text-color"]=["rgba"].concat(r.textColor.toArray())),i.push(n)}return i}}class tM{constructor(i){this.name=i.name,this.available=i.available}toString(){return this.name}static fromString(i){return i?new tM({name:i,available:!1}):null}serialize(){return["image",this.name]}}function t2(i,r,n,o){return"number"==typeof i&&i>=0&&i<=255&&"number"==typeof r&&r>=0&&r<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===o||"number"==typeof o&&o>=0&&o<=1?null:`Invalid rgba value [${[i,r,n,o].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof o?[i,r,n,o]:[i,r,n]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function tF(i){if(null===i||"string"==typeof i||"boolean"==typeof i||"number"==typeof i||i instanceof t1||i instanceof tB||i instanceof t3||i instanceof tM)return!0;if(Array.isArray(i)){for(const r of i)if(!tF(r))return!1;return!0}if("object"==typeof i){for(const n in i)if(!tF(i[n]))return!1;return!0}return!1}function tO(i){if(null===i)return tx;if("string"==typeof i)return tv;if("boolean"==typeof i)return t_;if("number"==typeof i)return t$;if(i instanceof t1)return tb;if(i instanceof tB)return tT;if(i instanceof t3)return tE;if(i instanceof tM)return tS;if(Array.isArray(i)){const r=i.length;let n;for(const o of i){const s=tO(o);if(n){if(n===s)continue;n=t0;break}n=s}return tI(n||t0,r)}return tw}function t4(i){const r=typeof i;return null===i?"":"string"===r||"number"===r||"boolean"===r?String(i):i instanceof t1||i instanceof t3||i instanceof tM?i.toString():JSON.stringify(i)}class tU{constructor(i,r){this.type=i,this.value=r}static parse(i,r){if(2!==i.length)return r.error(`'literal' expression requires exactly one argument, but found ${i.length-1} instead.`);if(!tF(i[1]))return r.error("invalid value");const n=i[1];let o=tO(n);const s=r.expectedType;return"array"===o.kind&&0===o.N&&s&&"array"===s.kind&&("number"!=typeof s.N||0===s.N)&&(o=s),new tU(o,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof t1?["rgba"].concat(this.value.toArray()):this.value instanceof t3?this.value.serialize():this.value}}class tV{constructor(i){this.name="ExpressionEvaluationError",this.message=i}toJSON(){return this.message}}const t6={string:tv,number:t$,boolean:t_,object:tw};class tj{constructor(i,r){this.type=i,this.args=r}static parse(i,r){if(i.length<2)return r.error("Expected at least one argument.");let n,o=1;const s=i[0];if("array"===s){let a,l;if(i.length>2){const c=i[1];if("string"!=typeof c||!(c in t6)||"object"===c)return r.error('The item type argument of "array" must be one of string, number, boolean',1);a=t6[c],o++}else a=t0;if(i.length>3){if(null!==i[2]&&("number"!=typeof i[2]||i[2]<0||i[2]!==Math.floor(i[2])))return r.error('The length argument to "array" must be a positive integer literal',2);l=i[2],o++}n=tI(a,l)}else n=t6[s];const u=[];for(;oi.outputDefined())}serialize(){const i=this.type,r=[i.kind];if("array"===i.kind){const n=i.itemType;if("string"===n.kind||"number"===n.kind||"boolean"===n.kind){r.push(n.kind);const o=i.N;("number"==typeof o||this.args.length>1)&&r.push(o)}}return r.concat(this.args.map(i=>i.serialize()))}}class tN{constructor(i){this.type=tE,this.sections=i}static parse(i,r){if(i.length<2)return r.error("Expected at least one argument.");const n=i[1];if(!Array.isArray(n)&&"object"==typeof n)return r.error("First argument must be an image or text section.");const o=[];let s=!1;for(let a=1;a<=i.length-1;++a){const l=i[a];if(s&&"object"==typeof l&&!Array.isArray(l)){s=!1;let c=null;if(l["font-scale"]&&!(c=r.parse(l["font-scale"],1,t$)))return null;let u=null;if(l["text-font"]&&!(u=r.parse(l["text-font"],1,tI(tv))))return null;let h=null;if(l["text-color"]&&!(h=r.parse(l["text-color"],1,tb)))return null;const d=o[o.length-1];d.scale=c,d.font=u,d.textColor=h}else{const p=r.parse(i[a],1,t0);if(!p)return null;const f=p.type.kind;if("string"!==f&&"value"!==f&&"null"!==f&&"resolvedImage"!==f)return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");s=!0,o.push({content:p,scale:null,font:null,textColor:null})}}return new tN(o)}evaluate(i){return new t3(this.sections.map(r=>{const n=r.content.evaluate(i);return tO(n)===tS?new tR("",n,null,null,null):new tR(t4(n),null,r.scale?r.scale.evaluate(i):null,r.font?r.font.evaluate(i).join(","):null,r.textColor?r.textColor.evaluate(i):null)}))}eachChild(i){for(const r of this.sections)i(r.content),r.scale&&i(r.scale),r.font&&i(r.font),r.textColor&&i(r.textColor)}outputDefined(){return!1}serialize(){const i=["format"];for(const r of this.sections){i.push(r.content.serialize());const n={};r.scale&&(n["font-scale"]=r.scale.serialize()),r.font&&(n["text-font"]=r.font.serialize()),r.textColor&&(n["text-color"]=r.textColor.serialize()),i.push(n)}return i}}class tG{constructor(i){this.type=tS,this.input=i}static parse(i,r){if(2!==i.length)return r.error("Expected two arguments.");const n=r.parse(i[1],1,tv);return n?new tG(n):r.error("No image name provided.")}evaluate(i){const r=this.input.evaluate(i),n=tM.fromString(r);return n&&i.availableImages&&(n.available=i.availableImages.indexOf(r)>-1),n}eachChild(i){i(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const tZ={"to-boolean":t_,"to-color":tb,"to-number":t$,"to-string":tv};class t9{constructor(i,r){this.type=i,this.args=r}static parse(i,r){if(i.length<2)return r.error("Expected at least one argument.");const n=i[0];if(("to-boolean"===n||"to-string"===n)&&2!==i.length)return r.error("Expected one argument.");const o=tZ[n],s=[];for(let a=1;a4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:t2(r[0],r[1],r[2],r[3])))return new t1(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new tV(n||`Could not parse color from value '${"string"==typeof r?r:String(JSON.stringify(r))}'`)}if("number"===this.type.kind){let a=null;for(const l of this.args){if(null===(a=l.evaluate(i)))return 0;const c=Number(a);if(!isNaN(c))return c}throw new tV(`Could not convert ${JSON.stringify(a)} to number.`)}return"formatted"===this.type.kind?t3.fromString(t4(this.args[0].evaluate(i))):"resolvedImage"===this.type.kind?tM.fromString(t4(this.args[0].evaluate(i))):t4(this.args[0].evaluate(i))}eachChild(i){this.args.forEach(i)}outputDefined(){return this.args.every(i=>i.outputDefined())}serialize(){if("formatted"===this.type.kind)return new tN([{content:this.args[0],scale:null,font:null,textColor:null},]).serialize();if("resolvedImage"===this.type.kind)return new tG(this.args[0]).serialize();const i=[`to-${this.type.kind}`];return this.eachChild(r=>{i.push(r.serialize())}),i}}const t7=["Unknown","Point","LineString","Polygon",];class tq{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?t7[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const i=this.featureDistanceData.center,r=this.featureDistanceData.scale,{x:n,y:o}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(n*r-i[0])+this.featureDistanceData.bearing[1]*(o*r-i[1])}return 0}parseColor(i){let r=this._parseColorCache[i];return r||(r=this._parseColorCache[i]=t1.parse(i)),r}}class t5{constructor(i,r,n,o){this.name=i,this.type=r,this._evaluate=n,this.args=o}evaluate(i){return this._evaluate(i,this.args)}eachChild(i){this.args.forEach(i)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(i=>i.serialize()))}static parse(i,r){const n=i[0],o=t5.definitions[n];if(!o)return r.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);const s=Array.isArray(o)?o[0]:o.type,a=Array.isArray(o)?[[o[1],o[2]]]:o.overloads,l=a.filter(([r])=>!Array.isArray(r)||r.length===i.length-1);let c=null;for(const[u,h]of l){c=new i8(r.registry,r.path,null,r.scope);const d=[];let p=!1;for(let f=1;f{var r;return Array.isArray(r=i)?`(${r.map(tC).join(", ")})`:`(${tC(r.type)}...)`}).join(" | "),b=[];for(let w=1;w=r[2]||i[1]<=r[1]||i[3]>=r[3])}function tK(i,r){const n=(180+i[0])/360,o=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,s=Math.pow(2,r.z);return[Math.round(n*s*8192),Math.round(o*s*8192),]}function tY(i,r,n){const o=i[0]-r[0],s=i[1]-r[1],a=i[0]-n[0],l=i[1]-n[1];return o*l-a*s==0&&o*a<=0&&s*l<=0}function tJ(i,r){var n,o,s;let a=!1;for(let l=0,c=r.length;l(n=i)[1]!=(s=u[h+1])[1]>n[1]&&n[0]<(s[0]-o[0])*(n[1]-o[1])/(s[1]-o[1])+o[0]&&(a=!a)}}return a}function tQ(i,r){for(let n=0;n0&&c<0||l<0&&c>0}function it(i,r,n){var o,s,a,l,c,u;for(const h of n)for(let d=0;dn[2]){const s=.5*o;let a=i[0]-n[0]>s?-o:n[0]-i[0]>s?o:0;0===a&&(a=i[0]-n[2]>s?-o:n[2]-i[0]>s?o:0),i[0]+=a}tW(r,i)}function il(i,r,n,o){const s=8192*Math.pow(2,o.z),a=[8192*o.x,8192*o.y],l=[];for(const c of i)for(const u of c){const h=[u.x+a[0],u.y+a[1]];ia(h,r,n,s),l.push(h)}return l}function ic(i,r,n,o){var s;const a=8192*Math.pow(2,o.z),l=[8192*o.x,8192*o.y],c=[];for(const u of i){const h=[];for(const d of u){const p=[d.x+l[0],d.y+l[1]];tW(r,p),h.push(p)}c.push(h)}if(r[2]-r[0]<=a/2)for(const f of((s=r)[0]=s[1]=1/0,s[2]=s[3]=-1/0,c))for(const m of f)ia(m,r,n,a);return c}class iu{constructor(i,r){this.type=t_,this.geojson=i,this.geometries=r}static parse(i,r){if(2!==i.length)return r.error(`'within' expression requires exactly one argument, but found ${i.length-1} instead.`);if(tF(i[1])){const n=i[1];if("FeatureCollection"===n.type)for(let o=0;o{r&&!ih(i)&&(r=!1)}),r}function id(i){if(i instanceof t5&&"feature-state"===i.name)return!1;let r=!0;return i.eachChild(i=>{r&&!id(i)&&(r=!1)}),r}function ip(i,r){if(i instanceof t5&&r.indexOf(i.name)>=0)return!1;let n=!0;return i.eachChild(i=>{n&&!ip(i,r)&&(n=!1)}),n}class im{constructor(i,r){this.type=r.type,this.name=i,this.boundExpression=r}static parse(i,r){if(2!==i.length||"string"!=typeof i[1])return r.error("'var' expression requires exactly one string literal argument.");const n=i[1];return r.scope.has(n)?new im(n,r.scope.get(n)):r.error(`Unknown variable "${n}". Make sure "${n}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(i){return this.boundExpression.evaluate(i)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class i8{constructor(i,r=[],n,o=new ty,s=[]){this.registry=i,this.path=r,this.key=r.map(i=>`[${i}]`).join(""),this.scope=o,this.errors=s,this.expectedType=n}parse(i,r,n,o,s={}){return r?this.concat(r,n,o)._parse(i,s):this._parse(i,s)}_parse(i,r){function n(i,r,n){return"assert"===n?new tj(r,[i]):"coerce"===n?new t9(r,[i]):i}if(null!==i&&"string"!=typeof i&&"boolean"!=typeof i&&"number"!=typeof i||(i=["literal",i]),Array.isArray(i)){if(0===i.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const o=i[0];if("string"!=typeof o)return this.error(`Expression name must be a string, but found ${typeof o} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const s=this.registry[o];if(s){let a=s.parse(i,this);if(!a)return null;if(this.expectedType){const l=this.expectedType,c=a.type;if("string"!==l.kind&&"number"!==l.kind&&"boolean"!==l.kind&&"object"!==l.kind&&"array"!==l.kind||"value"!==c.kind){if("color"!==l.kind&&"formatted"!==l.kind&&"resolvedImage"!==l.kind||"value"!==c.kind&&"string"!==c.kind){if(this.checkSubtype(l,c))return null}else a=n(a,l,r.typeAnnotation||"coerce")}else a=n(a,l,r.typeAnnotation||"assert")}if(!(a instanceof tU)&&"resolvedImage"!==a.type.kind&&ig(a)){const u=new tq;try{a=new tU(a.type,a.evaluate(u))}catch(h){return this.error(h.message),null}}return a}return this.error(`Unknown expression "${o}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===i?"'undefined' value invalid. Use null instead.":"object"==typeof i?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof i} instead.`)}concat(i,r,n){const o="number"==typeof i?this.path.concat(i):this.path,s=n?this.scope.concat(n):this.scope;return new i8(this.registry,o,r||null,s,this.errors)}error(i,...r){const n=`${this.key}${r.map(i=>`[${i}]`).join("")}`;this.errors.push(new tg(n,i))}checkSubtype(i,r){const n=tA(i,r);return n&&this.error(n),n}}function ig(i){if(i instanceof im)return ig(i.boundExpression);if(i instanceof t5&&"error"===i.name||i instanceof tX||i instanceof iu)return!1;const r=i instanceof t9||i instanceof tj;let n=!0;return i.eachChild(i=>{n=r?n&&ig(i):n&&i instanceof tU}),!!n&&ih(i)&&ip(i,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center",])}function iy(i,r){const n=i.length-1;let o,s,a=0,l=n,c=0;for(;a<=l;)if(o=i[c=Math.floor((a+l)/2)],s=i[c+1],o<=r){if(c===n||rr))throw new tV("Input is not a number.");l=c-1}return 0}class ix{constructor(i,r,n){for(const[o,s]of(this.type=i,this.input=r,this.labels=[],this.outputs=[],n))this.labels.push(o),this.outputs.push(s)}static parse(i,r){if(i.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${i.length-1}.`);if((i.length-1)%2!=0)return r.error("Expected an even number of arguments.");const n=r.parse(i[1],1,t$);if(!n)return null;const o=[];let s=null;r.expectedType&&"value"!==r.expectedType.kind&&(s=r.expectedType);for(let a=1;a=l)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',u);const d=r.parse(c,h,s);if(!d)return null;s=s||d.type,o.push([l,d])}return new ix(s,n,o)}evaluate(i){const r=this.labels,n=this.outputs;if(1===r.length)return n[0].evaluate(i);const o=this.input.evaluate(i);if(o<=r[0])return n[0].evaluate(i);const s=r.length;return o>=r[s-1]?n[s-1].evaluate(i):n[iy(r,o)].evaluate(i)}eachChild(i){for(const r of(i(this.input),this.outputs))i(r)}outputDefined(){return this.outputs.every(i=>i.outputDefined())}serialize(){const i=["step",this.input.serialize()];for(let r=0;r0&&i.push(this.labels[r]),i.push(this.outputs[r].serialize());return i}}function i$(i,r,n){return i*(1-n)+r*n}var iv=Object.freeze({__proto__:null,number:i$,color:function(i,r,n){return new t1(i$(i.r,r.r,n),i$(i.g,r.g,n),i$(i.b,r.b,n),i$(i.a,r.a,n))},array:function(i,r,n){return i.map((i,o)=>i$(i,r[o],n))}});const i_=4/29,ib=6/29,iw=3*ib*ib,i0=Math.PI/180,iT=180/Math.PI;function iE(i){return i>.008856451679035631?Math.pow(i,1/3):i/iw+i_}function iS(i){return i>ib?i*i*i:iw*(i-i_)}function iI(i){return 255*(i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055)}function iC(i){return(i/=255)<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function iz(i){const r=iC(i.r),n=iC(i.g),o=iC(i.b),s=iE((.4124564*r+.3575761*n+.1804375*o)/.95047),a=iE((.2126729*r+.7151522*n+.072175*o)/1);return{l:116*a-16,a:500*(s-a),b:200*(a-iE((.0193339*r+.119192*n+.9503041*o)/1.08883)),alpha:i.a}}function iA(i){let r=(i.l+16)/116,n=isNaN(i.a)?r:r+i.a/500,o=isNaN(i.b)?r:r-i.b/200;return r=1*iS(r),n=.95047*iS(n),o=1.08883*iS(o),new t1(iI(3.2404542*n-1.5371385*r-.4985314*o),iI(-.969266*n+1.8760108*r+.041556*o),iI(.0556434*n-.2040259*r+1.0572252*o),i.alpha)}const ik={forward:iz,reverse:iA,interpolate:function(i,r,n){return{l:i$(i.l,r.l,n),a:i$(i.a,r.a,n),b:i$(i.b,r.b,n),alpha:i$(i.alpha,r.alpha,n)}}},iP={forward:function(i){const{l:r,a:n,b:o}=iz(i),s=Math.atan2(o,n)*iT;return{h:s<0?s+360:s,c:Math.sqrt(n*n+o*o),l:r,alpha:i.a}},reverse:function(i){const r=i.h*i0,n=i.c;return iA({l:i.l,a:Math.cos(r)*n,b:Math.sin(r)*n,alpha:i.alpha})},interpolate:function(i,r,n){return{h:function(i,r,n){const o=r-i;return i+n*(o>180||o<-180?o-360*Math.round(o/360):o)}(i.h,r.h,n),c:i$(i.c,r.c,n),l:i$(i.l,r.l,n),alpha:i$(i.alpha,r.alpha,n)}}};var iD=Object.freeze({__proto__:null,lab:ik,hcl:iP});class iL{constructor(i,r,n,o,s){for(const[a,l]of(this.type=i,this.operator=r,this.interpolation=n,this.input=o,this.labels=[],this.outputs=[],s))this.labels.push(a),this.outputs.push(l)}static interpolationFactor(i,r,n,o){let a=0;if("exponential"===i.name)a=i1(r,i.base,n,o);else if("linear"===i.name)a=i1(r,1,n,o);else if("cubic-bezier"===i.name){const l=i.controlPoints;a=new s(l[0],l[1],l[2],l[3]).solve(i1(r,1,n,o))}return a}static parse(i,r){let[n,o,s,...a]=i;if(!Array.isArray(o)||0===o.length)return r.error("Expected an interpolation type expression.",1);if("linear"===o[0])o={name:"linear"};else if("exponential"===o[0]){const l=o[1];if("number"!=typeof l)return r.error("Exponential interpolation requires a numeric base.",1,1);o={name:"exponential",base:l}}else{if("cubic-bezier"!==o[0])return r.error(`Unknown interpolation type ${String(o[0])}`,1,0);{const c=o.slice(1);if(4!==c.length||c.some(i=>"number"!=typeof i||i<0||i>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);o={name:"cubic-bezier",controlPoints:c}}}if(i.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${i.length-1}.`);if((i.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(!(s=r.parse(s,2,t$)))return null;const u=[];let h=null;"interpolate-hcl"===n||"interpolate-lab"===n?h=tb:r.expectedType&&"value"!==r.expectedType.kind&&(h=r.expectedType);for(let d=0;d=p)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',m);const y=r.parse(f,g,h);if(!y)return null;h=h||y.type,u.push([p,y])}return"number"===h.kind||"color"===h.kind||"array"===h.kind&&"number"===h.itemType.kind&&"number"==typeof h.N?new iL(h,n,o,s,u):r.error(`Type ${tC(h)} is not interpolatable.`)}evaluate(i){const r=this.labels,n=this.outputs;if(1===r.length)return n[0].evaluate(i);const o=this.input.evaluate(i);if(o<=r[0])return n[0].evaluate(i);const s=r.length;if(o>=r[s-1])return n[s-1].evaluate(i);const a=iy(r,o),l=iL.interpolationFactor(this.interpolation,o,r[a],r[a+1]),c=n[a].evaluate(i),u=n[a+1].evaluate(i);return"interpolate"===this.operator?iv[this.type.kind.toLowerCase()](c,u,l):"interpolate-hcl"===this.operator?iP.reverse(iP.interpolate(iP.forward(c),iP.forward(u),l)):ik.reverse(ik.interpolate(ik.forward(c),ik.forward(u),l))}eachChild(i){for(const r of(i(this.input),this.outputs))i(r)}outputDefined(){return this.outputs.every(i=>i.outputDefined())}serialize(){let i;i="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base,]:["cubic-bezier"].concat(this.interpolation.controlPoints);const r=[this.operator,i,this.input.serialize(),];for(let n=0;ntA(o,i.type));return new iB(c?t0:n,s)}evaluate(i){let r,n=null,o=0;for(const s of this.args){if(o++,(n=s.evaluate(i))&&n instanceof tM&&!n.available&&(r||(r=n),n=null,o===this.args.length))return r;if(null!==n)break}return n}eachChild(i){this.args.forEach(i)}outputDefined(){return this.args.every(i=>i.outputDefined())}serialize(){const i=["coalesce"];return this.eachChild(r=>{i.push(r.serialize())}),i}}class iR{constructor(i,r){this.type=r.type,this.bindings=[].concat(i),this.result=r}evaluate(i){return this.result.evaluate(i)}eachChild(i){for(const r of this.bindings)i(r[1]);i(this.result)}static parse(i,r){if(i.length<4)return r.error(`Expected at least 3 arguments, but found ${i.length-1} instead.`);const n=[];for(let o=1;o=n.length)throw new tV(`Array index out of bounds: ${r} > ${n.length-1}.`);if(r!==Math.floor(r))throw new tV(`Array index must be an integer, but found ${r} instead.`);return n[r]}eachChild(i){i(this.index),i(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize(),]}}class iM{constructor(i,r){this.type=t_,this.needle=i,this.haystack=r}static parse(i,r){if(3!==i.length)return r.error(`Expected 2 arguments, but found ${i.length-1} instead.`);const n=r.parse(i[1],1,t0),o=r.parse(i[2],2,t0);return n&&o?tk(n.type,[t_,tv,t$,tx,t0])?new iM(n,o):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${tC(n.type)} instead`):null}evaluate(i){const r=this.needle.evaluate(i),n=this.haystack.evaluate(i);if(!n)return!1;if(!tP(r,["boolean","string","number","null",]))throw new tV(`Expected first argument to be of type boolean, string, number or null, but found ${tC(tO(r))} instead.`);if(!tP(n,["string","array"]))throw new tV(`Expected second argument to be of type array or string, but found ${tC(tO(n))} instead.`);return n.indexOf(r)>=0}eachChild(i){i(this.needle),i(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize(),]}}class i2{constructor(i,r,n){this.type=t$,this.needle=i,this.haystack=r,this.fromIndex=n}static parse(i,r){if(i.length<=2||i.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${i.length-1} instead.`);const n=r.parse(i[1],1,t0),o=r.parse(i[2],2,t0);if(!n||!o)return null;if(!tk(n.type,[t_,tv,t$,tx,t0]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${tC(n.type)} instead`);if(4===i.length){const s=r.parse(i[3],3,t$);return s?new i2(n,o,s):null}return new i2(n,o)}evaluate(i){const r=this.needle.evaluate(i),n=this.haystack.evaluate(i);if(!tP(r,["boolean","string","number","null",]))throw new tV(`Expected first argument to be of type boolean, string, number or null, but found ${tC(tO(r))} instead.`);if(!tP(n,["string","array"]))throw new tV(`Expected second argument to be of type array or string, but found ${tC(tO(n))} instead.`);if(this.fromIndex){const o=this.fromIndex.evaluate(i);return n.indexOf(r,o)}return n.indexOf(r)}eachChild(i){i(this.needle),i(this.haystack),this.fromIndex&&i(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const i=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),i,]}return["index-of",this.needle.serialize(),this.haystack.serialize(),]}}class iF{constructor(i,r,n,o,s,a){this.inputType=i,this.type=r,this.input=n,this.cases=o,this.outputs=s,this.otherwise=a}static parse(i,r){if(i.length<5)return r.error(`Expected at least 4 arguments, but found only ${i.length-1}.`);if(i.length%2!=1)return r.error("Expected an even number of arguments.");let n,o;r.expectedType&&"value"!==r.expectedType.kind&&(o=r.expectedType);const s={},a=[];for(let l=2;lNumber.MAX_SAFE_INTEGER)return h.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof d&&Math.floor(d)!==d)return h.error("Numeric branch labels must be integer values.");if(n){if(h.checkSubtype(n,tO(d)))return null}else n=tO(d);if(void 0!==s[String(d)])return h.error("Branch labels must be unique.");s[String(d)]=a.length}const p=r.parse(u,l,o);if(!p)return null;o=o||p.type,a.push(p)}const f=r.parse(i[1],1,t0);if(!f)return null;const m=r.parse(i[i.length-1],i.length-1,o);return m?"value"!==f.type.kind&&r.concat(1).checkSubtype(n,f.type)?null:new iF(n,o,f,s,a,m):null}evaluate(i){const r=this.input.evaluate(i);return(tO(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(i)}eachChild(i){i(this.input),this.outputs.forEach(i),i(this.otherwise)}outputDefined(){return this.outputs.every(i=>i.outputDefined())&&this.otherwise.outputDefined()}serialize(){const i=["match",this.input.serialize()],r=Object.keys(this.cases).sort(),n=[],o={};for(const s of r){const a=o[this.cases[s]];void 0===a?(o[this.cases[s]]=n.length,n.push([this.cases[s],[s]])):n[a][1].push(s)}const l=i=>"number"===this.inputType.kind?Number(i):i;for(const[c,u]of n)i.push(1===u.length?l(u[0]):u.map(l)),i.push(this.outputs[c].serialize());return i.push(this.otherwise.serialize()),i}}class iO{constructor(i,r,n){this.type=i,this.branches=r,this.otherwise=n}static parse(i,r){if(i.length<4)return r.error(`Expected at least 3 arguments, but found only ${i.length-1}.`);if(i.length%2!=0)return r.error("Expected an odd number of arguments.");let n;r.expectedType&&"value"!==r.expectedType.kind&&(n=r.expectedType);const o=[];for(let s=1;sr.outputDefined())&&this.otherwise.outputDefined()}serialize(){const i=["case"];return this.eachChild(r=>{i.push(r.serialize())}),i}}class i4{constructor(i,r,n,o){this.type=i,this.input=r,this.beginIndex=n,this.endIndex=o}static parse(i,r){if(i.length<=2||i.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${i.length-1} instead.`);const n=r.parse(i[1],1,t0),o=r.parse(i[2],2,t$);if(!n||!o)return null;if(!tk(n.type,[tI(t0),tv,t0]))return r.error(`Expected first argument to be of type array or string, but found ${tC(n.type)} instead`);if(4===i.length){const s=r.parse(i[3],3,t$);return s?new i4(n.type,n,o,s):null}return new i4(n.type,n,o)}evaluate(i){const r=this.input.evaluate(i),n=this.beginIndex.evaluate(i);if(!tP(r,["string","array"]))throw new tV(`Expected first argument to be of type array or string, but found ${tC(tO(r))} instead.`);if(this.endIndex){const o=this.endIndex.evaluate(i);return r.slice(n,o)}return r.slice(n)}eachChild(i){i(this.input),i(this.beginIndex),this.endIndex&&i(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const i=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),i,]}return["slice",this.input.serialize(),this.beginIndex.serialize(),]}}function iU(i,r){return"=="===i||"!="===i?"boolean"===r.kind||"string"===r.kind||"number"===r.kind||"null"===r.kind||"value"===r.kind:"string"===r.kind||"number"===r.kind||"value"===r.kind}function iV(i,r,n,o){return 0===o.compare(r,n)}function i6(i,r,n){const o="=="!==i&&"!="!==i;return class s{constructor(i,r,n){this.type=t_,this.lhs=i,this.rhs=r,this.collator=n,this.hasUntypedArgument="value"===i.type.kind||"value"===r.type.kind}static parse(i,r){if(3!==i.length&&4!==i.length)return r.error("Expected two or three arguments.");const n=i[0];let a=r.parse(i[1],1,t0);if(!a)return null;if(!iU(n,a.type))return r.concat(1).error(`"${n}" comparisons are not supported for type '${tC(a.type)}'.`);let l=r.parse(i[2],2,t0);if(!l)return null;if(!iU(n,l.type))return r.concat(2).error(`"${n}" comparisons are not supported for type '${tC(l.type)}'.`);if(a.type.kind!==l.type.kind&&"value"!==a.type.kind&&"value"!==l.type.kind)return r.error(`Cannot compare types '${tC(a.type)}' and '${tC(l.type)}'.`);o&&("value"===a.type.kind&&"value"!==l.type.kind?a=new tj(l.type,[a]):"value"!==a.type.kind&&"value"===l.type.kind&&(l=new tj(a.type,[l])));let c=null;if(4===i.length){if("string"!==a.type.kind&&"string"!==l.type.kind&&"value"!==a.type.kind&&"value"!==l.type.kind)return r.error("Cannot use collator to compare non-string types.");if(!(c=r.parse(i[3],3,tT)))return null}return new s(a,l,c)}evaluate(s){const a=this.lhs.evaluate(s),l=this.rhs.evaluate(s);if(o&&this.hasUntypedArgument){const c=tO(a),u=tO(l);if(c.kind!==u.kind||"string"!==c.kind&&"number"!==c.kind)throw new tV(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${c.kind}, ${u.kind}) instead.`)}if(this.collator&&!o&&this.hasUntypedArgument){const h=tO(a),d=tO(l);if("string"!==h.kind||"string"!==d.kind)return r(s,a,l)}return this.collator?n(s,a,l,this.collator.evaluate(s)):r(s,a,l)}eachChild(i){i(this.lhs),i(this.rhs),this.collator&&i(this.collator)}outputDefined(){return!0}serialize(){const r=[i];return this.eachChild(i=>{r.push(i.serialize())}),r}}}const ij=i6("==",function(i,r,n){return r===n},iV),iN=i6("!=",function(i,r,n){return r!==n},function(i,r,n,o){return!iV(0,r,n,o)}),iG=i6("<",function(i,r,n){return ro.compare(r,n)}),iZ=i6(">",function(i,r,n){return r>n},function(i,r,n,o){return o.compare(r,n)>0}),i9=i6("<=",function(i,r,n){return r<=n},function(i,r,n,o){return 0>=o.compare(r,n)}),i7=i6(">=",function(i,r,n){return r>=n},function(i,r,n,o){return o.compare(r,n)>=0});class iq{constructor(i,r,n,o,s){this.type=tv,this.number=i,this.locale=r,this.currency=n,this.minFractionDigits=o,this.maxFractionDigits=s}static parse(i,r){if(3!==i.length)return r.error("Expected two arguments.");const n=r.parse(i[1],1,t$);if(!n)return null;const o=i[2];if("object"!=typeof o||Array.isArray(o))return r.error("NumberFormat options argument must be an object.");let s=null;if(o.locale&&!(s=r.parse(o.locale,1,tv)))return null;let a=null;if(o.currency&&!(a=r.parse(o.currency,1,tv)))return null;let l=null;if(o["min-fraction-digits"]&&!(l=r.parse(o["min-fraction-digits"],1,t$)))return null;let c=null;return!o["max-fraction-digits"]||(c=r.parse(o["max-fraction-digits"],1,t$))?new iq(n,s,a,l,c):null}evaluate(i){return new Intl.NumberFormat(this.locale?this.locale.evaluate(i):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(i):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(i):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(i):void 0}).format(this.number.evaluate(i))}eachChild(i){i(this.number),this.locale&&i(this.locale),this.currency&&i(this.currency),this.minFractionDigits&&i(this.minFractionDigits),this.maxFractionDigits&&i(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const i={};return this.locale&&(i.locale=this.locale.serialize()),this.currency&&(i.currency=this.currency.serialize()),this.minFractionDigits&&(i["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(i["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),i,]}}class i5{constructor(i){this.type=t$,this.input=i}static parse(i,r){if(2!==i.length)return r.error(`Expected 1 argument, but found ${i.length-1} instead.`);const n=r.parse(i[1],1);return n?"array"!==n.type.kind&&"string"!==n.type.kind&&"value"!==n.type.kind?r.error(`Expected argument of type string or array, but found ${tC(n.type)} instead.`):new i5(n):null}evaluate(i){const r=this.input.evaluate(i);if("string"==typeof r||Array.isArray(r))return r.length;throw new tV(`Expected value to be of type string or array, but found ${tC(tO(r))} instead.`)}eachChild(i){i(this.input)}outputDefined(){return!1}serialize(){const i=["length"];return this.eachChild(r=>{i.push(r.serialize())}),i}}const iX={"==":ij,"!=":iN,">":iZ,"<":iG,">=":i7,"<=":i9,array:tj,at:i3,boolean:tj,case:iO,coalesce:iB,collator:tX,format:tN,image:tG,in:iM,"index-of":i2,interpolate:iL,"interpolate-hcl":iL,"interpolate-lab":iL,length:i5,let:iR,literal:tU,match:iF,number:tj,"number-format":iq,object:tj,slice:i4,step:ix,string:tj,"to-boolean":t9,"to-color":t9,"to-number":t9,"to-string":t9,var:im,within:iu};function iW(i,[r,n,o,s]){r=r.evaluate(i),n=n.evaluate(i),o=o.evaluate(i);const a=s?s.evaluate(i):1,l=t2(r,n,o,a);if(l)throw new tV(l);return new t1(r/255*a,n/255*a,o/255*a,a)}function iH(i,r){const n=r[i];return void 0===n?null:n}function iK(i){return{type:i}}function iY(i){return{result:"success",value:i}}function iJ(i){return{result:"error",value:i}}function iQ(i){return"data-driven"===i["property-type"]||"cross-faded-data-driven"===i["property-type"]}function re(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function rt(i){return!!i.expression&&i.expression.interpolated}function ri(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":null===i?"null":typeof i}function rr(i){return"object"==typeof i&&null!==i&&!Array.isArray(i)}function rn(i){return i}function ro(i,r,n){return void 0!==i?i:void 0!==r?r:void 0!==n?n:void 0}function rs(i,r,n,o,s){return ro(typeof n===s?o[n]:void 0,i.default,r.default)}function ra(i,r,n){if("number"!==ri(n))return ro(i.default,r.default);const o=i.stops.length;if(1===o||n<=i.stops[0][0])return i.stops[0][1];if(n>=i.stops[o-1][0])return i.stops[o-1][1];const s=iy(i.stops.map(i=>i[0]),n);return i.stops[s][1]}function rl(i,r,n){const o=void 0!==i.base?i.base:1;if("number"!==ri(n))return ro(i.default,r.default);const s=i.stops.length;if(1===s||n<=i.stops[0][0])return i.stops[0][1];if(n>=i.stops[s-1][0])return i.stops[s-1][1];const a=iy(i.stops.map(i=>i[0]),n),l=function(i,r,n,o){const s=o-n,a=i-n;return 0===s?0:1===r?a/s:(Math.pow(r,a)-1)/(Math.pow(r,s)-1)}(n,o,i.stops[a][0],i.stops[a+1][0]),c=i.stops[a][1],u=i.stops[a+1][1];let h=iv[r.type]||rn;if(i.colorSpace&&"rgb"!==i.colorSpace){const d=iD[i.colorSpace];h=(i,r)=>d.reverse(d.interpolate(d.forward(i),d.forward(r),l))}return"function"==typeof c.evaluate?{evaluate(...i){const r=c.evaluate.apply(void 0,i),n=u.evaluate.apply(void 0,i);if(void 0!==r&&void 0!==n)return h(r,n,l)}}:h(c,u,l)}function rc(i,r,n){return"color"===r.type?n=t1.parse(n):"formatted"===r.type?n=t3.fromString(n.toString()):"resolvedImage"===r.type?n=tM.fromString(n.toString()):ri(n)===r.type||"enum"===r.type&&r.values[n]||(n=void 0),ro(n,i.default,r.default)}t5.register(iX,{error:[{kind:"error"},[tv],(i,[r])=>{throw new tV(r.evaluate(i))},],typeof:[tv,[t0],(i,[r])=>tC(tO(r.evaluate(i))),],"to-rgba":[tI(t$,4),[tb],(i,[r])=>r.evaluate(i).toArray(),],rgb:[tb,[t$,t$,t$],iW],rgba:[tb,[t$,t$,t$,t$],iW],has:{type:t_,overloads:[[[tv],(i,[r])=>r.evaluate(i) in i.properties(),],[[tv,tw],(i,[r,n])=>r.evaluate(i) in n.evaluate(i),],]},get:{type:t0,overloads:[[[tv],(i,[r])=>iH(r.evaluate(i),i.properties()),],[[tv,tw],(i,[r,n])=>iH(r.evaluate(i),n.evaluate(i)),],]},"feature-state":[t0,[tv],(i,[r])=>iH(r.evaluate(i),i.featureState||{}),],properties:[tw,[],i=>i.properties()],"geometry-type":[tv,[],i=>i.geometryType()],id:[t0,[],i=>i.id()],zoom:[t$,[],i=>i.globals.zoom],pitch:[t$,[],i=>i.globals.pitch||0],"distance-from-center":[t$,[],i=>i.distanceFromCenter(),],"heatmap-density":[t$,[],i=>i.globals.heatmapDensity||0,],"line-progress":[t$,[],i=>i.globals.lineProgress||0,],"sky-radial-progress":[t$,[],i=>i.globals.skyRadialProgress||0,],accumulated:[t0,[],i=>void 0===i.globals.accumulated?null:i.globals.accumulated,],"+":[t$,iK(t$),(i,r)=>{let n=0;for(const o of r)n+=o.evaluate(i);return n},],"*":[t$,iK(t$),(i,r)=>{let n=1;for(const o of r)n*=o.evaluate(i);return n},],"-":{type:t$,overloads:[[[t$,t$],(i,[r,n])=>r.evaluate(i)-n.evaluate(i),],[[t$],(i,[r])=>-r.evaluate(i)],]},"/":[t$,[t$,t$],(i,[r,n])=>r.evaluate(i)/n.evaluate(i),],"%":[t$,[t$,t$],(i,[r,n])=>r.evaluate(i)%n.evaluate(i),],ln2:[t$,[],()=>Math.LN2],pi:[t$,[],()=>Math.PI],e:[t$,[],()=>Math.E],"^":[t$,[t$,t$],(i,[r,n])=>Math.pow(r.evaluate(i),n.evaluate(i)),],sqrt:[t$,[t$],(i,[r])=>Math.sqrt(r.evaluate(i)),],log10:[t$,[t$],(i,[r])=>Math.log(r.evaluate(i))/Math.LN10,],ln:[t$,[t$],(i,[r])=>Math.log(r.evaluate(i))],log2:[t$,[t$],(i,[r])=>Math.log(r.evaluate(i))/Math.LN2,],sin:[t$,[t$],(i,[r])=>Math.sin(r.evaluate(i)),],cos:[t$,[t$],(i,[r])=>Math.cos(r.evaluate(i)),],tan:[t$,[t$],(i,[r])=>Math.tan(r.evaluate(i)),],asin:[t$,[t$],(i,[r])=>Math.asin(r.evaluate(i)),],acos:[t$,[t$],(i,[r])=>Math.acos(r.evaluate(i)),],atan:[t$,[t$],(i,[r])=>Math.atan(r.evaluate(i)),],min:[t$,iK(t$),(i,r)=>Math.min(...r.map(r=>r.evaluate(i))),],max:[t$,iK(t$),(i,r)=>Math.max(...r.map(r=>r.evaluate(i))),],abs:[t$,[t$],(i,[r])=>Math.abs(r.evaluate(i)),],round:[t$,[t$],(i,[r])=>{const n=r.evaluate(i);return n<0?-Math.round(-n):Math.round(n)},],floor:[t$,[t$],(i,[r])=>Math.floor(r.evaluate(i)),],ceil:[t$,[t$],(i,[r])=>Math.ceil(r.evaluate(i)),],"filter-==":[t_,[tv,t0],(i,[r,n])=>i.properties()[r.value]===n.value,],"filter-id-==":[t_,[t0],(i,[r])=>i.id()===r.value,],"filter-type-==":[t_,[tv],(i,[r])=>i.geometryType()===r.value,],"filter-<":[t_,[tv,t0],(i,[r,n])=>{const o=i.properties()[r.value],s=n.value;return typeof o==typeof s&&o{const n=i.id(),o=r.value;return typeof n==typeof o&&n":[t_,[tv,t0],(i,[r,n])=>{const o=i.properties()[r.value],s=n.value;return typeof o==typeof s&&o>s},],"filter-id->":[t_,[t0],(i,[r])=>{const n=i.id(),o=r.value;return typeof n==typeof o&&n>o},],"filter-<=":[t_,[tv,t0],(i,[r,n])=>{const o=i.properties()[r.value],s=n.value;return typeof o==typeof s&&o<=s},],"filter-id-<=":[t_,[t0],(i,[r])=>{const n=i.id(),o=r.value;return typeof n==typeof o&&n<=o},],"filter->=":[t_,[tv,t0],(i,[r,n])=>{const o=i.properties()[r.value],s=n.value;return typeof o==typeof s&&o>=s},],"filter-id->=":[t_,[t0],(i,[r])=>{const n=i.id(),o=r.value;return typeof n==typeof o&&n>=o},],"filter-has":[t_,[t0],(i,[r])=>r.value in i.properties(),],"filter-has-id":[t_,[],i=>null!==i.id()&&void 0!==i.id(),],"filter-type-in":[t_,[tI(tv)],(i,[r])=>r.value.indexOf(i.geometryType())>=0,],"filter-id-in":[t_,[tI(t0)],(i,[r])=>r.value.indexOf(i.id())>=0,],"filter-in-small":[t_,[tv,tI(t0)],(i,[r,n])=>n.value.indexOf(i.properties()[r.value])>=0,],"filter-in-large":[t_,[tv,tI(t0)],(i,[r,n])=>(function(i,r,n,o){for(;n<=o;){const s=n+o>>1;if(r[s]===i)return!0;r[s]>i?o=s-1:n=s+1}return!1})(i.properties()[r.value],n.value,0,n.value.length-1),],all:{type:t_,overloads:[[[t_,t_],(i,[r,n])=>r.evaluate(i)&&n.evaluate(i),],[iK(t_),(i,r)=>{for(const n of r)if(!n.evaluate(i))return!1;return!0},],]},any:{type:t_,overloads:[[[t_,t_],(i,[r,n])=>r.evaluate(i)||n.evaluate(i),],[iK(t_),(i,r)=>{for(const n of r)if(n.evaluate(i))return!0;return!1},],]},"!":[t_,[t_],(i,[r])=>!r.evaluate(i)],"is-supported-script":[t_,[tv],(i,[r])=>{const n=i.globals&&i.globals.isSupportedScript;return!n||n(r.evaluate(i))},],upcase:[tv,[tv],(i,[r])=>r.evaluate(i).toUpperCase(),],downcase:[tv,[tv],(i,[r])=>r.evaluate(i).toLowerCase(),],concat:[tv,iK(t0),(i,r)=>r.map(r=>t4(r.evaluate(i))).join(""),],"resolved-locale":[tv,[tT],(i,[r])=>r.evaluate(i).resolvedLocale(),]});class ru{constructor(i,r){var n;this.expression=i,this._warningHistory={},this._evaluator=new tq,this._defaultValue=r?"color"===(n=r).type&&rr(n.default)?new t1(0,0,0,0):"color"===n.type?t1.parse(n.default)||null:void 0===n.default?null:n.default:null,this._enumValues=r&&"enum"===r.type?r.values:null}evaluateWithoutErrorHandling(i,r,n,o,s,a,l,c){return this._evaluator.globals=i,this._evaluator.feature=r,this._evaluator.featureState=n,this._evaluator.canonical=o,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=a,this._evaluator.featureTileCoord=l||null,this._evaluator.featureDistanceData=c||null,this.expression.evaluate(this._evaluator)}evaluate(i,r,n,o,s,a,l,c){this._evaluator.globals=i,this._evaluator.feature=r||null,this._evaluator.featureState=n||null,this._evaluator.canonical=o,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=a||null,this._evaluator.featureTileCoord=l||null,this._evaluator.featureDistanceData=c||null;try{const u=this.expression.evaluate(this._evaluator);if(null==u||"number"==typeof u&&u!=u)return this._defaultValue;if(this._enumValues&&!(u in this._enumValues))throw new tV(`Expected value to be one of ${Object.keys(this._enumValues).map(i=>JSON.stringify(i)).join(", ")}, but found ${JSON.stringify(u)} instead.`);return u}catch(h){return this._warningHistory[h.message]||(this._warningHistory[h.message]=!0,"undefined"!=typeof console&&console.warn(h.message)),this._defaultValue}}}function rh(i){return Array.isArray(i)&&i.length>0&&"string"==typeof i[0]&&i[0]in iX}function rd(i,r){const n=new i8(iX,[],r?function(i){const r={color:tb,string:tv,number:t$,enum:tv,boolean:t_,formatted:tE,resolvedImage:tS};return"array"===i.type?tI(r[i.value]||t0,i.length):r[i.type]}(r):void 0),o=n.parse(i,void 0,void 0,void 0,r&&"string"===r.type?{typeAnnotation:"coerce"}:void 0);return o?iY(new ru(o,r)):iJ(n.errors)}class rp{constructor(i,r){this.kind=i,this._styleExpression=r,this.isStateDependent="constant"!==i&&!id(r.expression)}evaluateWithoutErrorHandling(i,r,n,o,s,a){return this._styleExpression.evaluateWithoutErrorHandling(i,r,n,o,s,a)}evaluate(i,r,n,o,s,a){return this._styleExpression.evaluate(i,r,n,o,s,a)}}class rf{constructor(i,r,n,o){this.kind=i,this.zoomStops=n,this._styleExpression=r,this.isStateDependent="camera"!==i&&!id(r.expression),this.interpolationType=o}evaluateWithoutErrorHandling(i,r,n,o,s,a){return this._styleExpression.evaluateWithoutErrorHandling(i,r,n,o,s,a)}evaluate(i,r,n,o,s,a){return this._styleExpression.evaluate(i,r,n,o,s,a)}interpolationFactor(i,r,n){return this.interpolationType?iL.interpolationFactor(this.interpolationType,i,r,n):0}}function rm(i,r){if("error"===(i=rd(i,r)).result)return i;const n=i.value.expression,o=ih(n);if(!o&&!iQ(r))return iJ([new tg("","data expressions not supported"),]);const s=ip(n,["zoom","pitch","distance-from-center",]);if(!s&&!re(r))return iJ([new tg("","zoom expressions not supported"),]);const a=rg(n);return a||s?a instanceof tg?iJ([a]):a instanceof iL&&!rt(r)?iJ([new tg("",'"interpolate" expressions cannot be used with this property'),]):iY(a?new rf(o?"camera":"composite",i.value,a.labels,a instanceof iL?a.interpolation:void 0):new rp(o?"constant":"source",i.value)):iJ([new tg("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'),])}class r8{constructor(i,r){this._parameters=i,this._specification=r,tf(this,function i(r,n){const o="color"===n.type,s=r.stops&&"object"==typeof r.stops[0][0],a=s||!(s||void 0!==r.property),l=r.type||(rt(n)?"exponential":"interval");if(o&&((r=tf({},r)).stops&&(r.stops=r.stops.map(i=>[i[0],t1.parse(i[1]),])),r.default=t1.parse(r.default?r.default:n.default)),r.colorSpace&&"rgb"!==r.colorSpace&&!iD[r.colorSpace])throw Error(`Unknown color space: ${r.colorSpace}`);let c,u,h;if("exponential"===l)c=rl;else if("interval"===l)c=ra;else if("categorical"===l){for(const d of(c=rs,u=Object.create(null),r.stops))u[d[0]]=d[1];h=typeof r.stops[0][0]}else{if("identity"!==l)throw Error(`Unknown function type "${l}"`);c=rc}if(s){const p={},f=[];for(let m=0;mi[0]),evaluate:({zoom:i},o)=>rl({stops:x,base:r.base},n,i).evaluate(i,o)}}if(a){const _="exponential"===l?{name:"exponential",base:void 0!==r.base?r.base:1}:null;return{kind:"camera",interpolationType:_,interpolationFactor:iL.interpolationFactor.bind(void 0,_),zoomStops:r.stops.map(i=>i[0]),evaluate:({zoom:i})=>c(r,n,i,u,h)}}return{kind:"source",evaluate(i,o){const s=o&&o.properties?o.properties[r.property]:void 0;return void 0===s?ro(r.default,n.default):c(r,n,s,u,h)}}}(this._parameters,this._specification))}static deserialize(i){return new r8(i._parameters,i._specification)}static serialize(i){return{_parameters:i._parameters,_specification:i._specification}}}function rg(i){let r=null;if(i instanceof iR)r=rg(i.result);else if(i instanceof iB){for(const n of i.args)if(r=rg(n))break}else(i instanceof ix||i instanceof iL)&&i.input instanceof t5&&"zoom"===i.input.name&&(r=i);return r instanceof tg||i.eachChild(i=>{const n=rg(i);n instanceof tg?r=n:!r&&n?r=new tg("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):r&&n&&r!==n&&(r=new tg("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),r}function ry(i){const r=i.key,n=i.value,o=i.valueSpec||{},s=i.objectElementValidators||{},a=i.style,l=i.styleSpec;let c=[];const u=ri(n);if("object"!==u)return[new td(r,n,`object expected, ${u} found`),];for(const h in n){const d=h.split(".")[0],p=o[d]||o["*"];let f;if(s[d])f=s[d];else if(o[d])f=rG;else if(s["*"])f=s["*"];else{if(!o["*"]){c.push(new td(r,n[h],`unknown property "${h}"`));continue}f=rG}c=c.concat(f({key:(r?`${r}.`:r)+h,value:n[h],valueSpec:p,style:a,styleSpec:l,object:n,objectKey:h},n))}for(const m in o)s[m]||o[m].required&&void 0===o[m].default&&void 0===n[m]&&c.push(new td(r,n,`missing required property "${m}"`));return c}function rx(i){const r=i.value,n=i.valueSpec,o=i.style,s=i.styleSpec,a=i.key,l=i.arrayElementValidator||rG;if("array"!==ri(r))return[new td(a,r,`array expected, ${ri(r)} found`),];if(n.length&&r.length!==n.length)return[new td(a,r,`array length ${n.length} expected, length ${r.length} found`),];if(n["min-length"]&&r.lengthl)return[new td(r,n,`${n} is greater than the maximum value ${l}`),]}return[]}function rv(i){const r=i.valueSpec,n=tm(i.value.type);let o,s,a,l={};const c="categorical"!==n&&void 0===i.value.property,u="array"===ri(i.value.stops)&&"array"===ri(i.value.stops[0])&&"object"===ri(i.value.stops[0][0]),h=ry({key:i.key,value:i.value,valueSpec:i.styleSpec.function,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(i){if("identity"===n)return[new td(i.key,i.value,'identity function may not have a "stops" property'),];let r=[];const o=i.value;return r=r.concat(rx({key:i.key,value:o,valueSpec:i.valueSpec,style:i.style,styleSpec:i.styleSpec,arrayElementValidator:d})),"array"===ri(o)&&0===o.length&&r.push(new td(i.key,o,"array must have at least one stop")),r},default:function(i){return rG({key:i.key,value:i.value,valueSpec:r,style:i.style,styleSpec:i.styleSpec})}}});return"identity"===n&&c&&h.push(new td(i.key,i.value,'missing required property "property"')),"identity"===n||i.value.stops||h.push(new td(i.key,i.value,'missing required property "stops"')),"exponential"===n&&i.valueSpec.expression&&!rt(i.valueSpec)&&h.push(new td(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(c||iQ(i.valueSpec)?c&&!re(i.valueSpec)&&h.push(new td(i.key,i.value,"zoom functions not supported")):h.push(new td(i.key,i.value,"property functions not supported"))),("categorical"===n||u)&&void 0===i.value.property&&h.push(new td(i.key,i.value,'"property" property is required')),h;function d(i){let n=[];const o=i.value,c=i.key;if("array"!==ri(o))return[new td(c,o,`array expected, ${ri(o)} found`),];if(2!==o.length)return[new td(c,o,`array length 2 expected, length ${o.length} found`),];if(u){if("object"!==ri(o[0]))return[new td(c,o,`object expected, ${ri(o[0])} found`),];if(void 0===o[0].zoom)return[new td(c,o,"object stop key must have zoom"),];if(void 0===o[0].value)return[new td(c,o,"object stop key must have value"),];if(a&&a>tm(o[0].zoom))return[new td(c,o[0].zoom,"stop zoom values must appear in ascending order"),];tm(o[0].zoom)!==a&&(a=tm(o[0].zoom),s=void 0,l={}),n=n.concat(ry({key:`${c}[0]`,value:o[0],valueSpec:{zoom:{}},style:i.style,styleSpec:i.styleSpec,objectElementValidators:{zoom:r$,value:p}}))}else n=n.concat(p({key:`${c}[0]`,value:o[0],valueSpec:{},style:i.style,styleSpec:i.styleSpec},o));return rh(t8(o[1]))?n.concat([new td(`${c}[1]`,o[1],"expressions are not allowed in function stops."),]):n.concat(rG({key:`${c}[1]`,value:o[1],valueSpec:r,style:i.style,styleSpec:i.styleSpec}))}function p(i,a){const c=ri(i.value),u=tm(i.value),h=null!==i.value?i.value:a;if(o){if(c!==o)return[new td(i.key,h,`${c} stop domain type must match previous stop domain type ${o}`),]}else o=c;if("number"!==c&&"string"!==c&&"boolean"!==c)return[new td(i.key,h,"stop domain value must be a number, string, or boolean"),];if("number"!==c&&"categorical"!==n){let d=`number expected, ${c} found`;return iQ(r)&&void 0===n&&(d+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new td(i.key,h,d)]}return"categorical"!==n||"number"!==c||isFinite(u)&&Math.floor(u)===u?"categorical"!==n&&"number"===c&&void 0!==s&&unew td(`${i.key}${r.key}`,i.value,r.message));const n=r.value.expression||r.value._styleExpression.expression;if("property"===i.expressionContext&&"text-font"===i.propertyKey&&!n.outputDefined())return[new td(i.key,i.value,`Invalid data expression for "${i.propertyKey}". Output values must be contained as literals within the expression.`),];if("property"===i.expressionContext&&"layout"===i.propertyType&&!id(n))return[new td(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.'),];if("filter"===i.expressionContext)return rb(n,i);if(i.expressionContext&&0===i.expressionContext.indexOf("cluster")){if(!ip(n,["zoom","feature-state"]))return[new td(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.'),];if("cluster-initial"===i.expressionContext&&!ih(n))return[new td(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties."),]}return[]}function rb(i,r){const n=new Set(["zoom","feature-state","pitch","distance-from-center",]);for(const o of r.valueSpec.expression.parameters)n.delete(o);if(0===n.size)return[];const s=[];return i instanceof t5&&n.has(i.name)?[new td(r.key,r.value,`["${i.name}"] expression is not supported in a filter for a ${r.object.type} layer with id: ${r.object.id}`),]:(i.eachChild(i=>{s.push(...rb(i,r))}),s)}function rw(i){const r=i.key,n=i.value,o=i.valueSpec,s=[];return Array.isArray(o.values)?-1===o.values.indexOf(tm(n))&&s.push(new td(r,n,`expected one of [${o.values.join(", ")}], ${JSON.stringify(n)} found`)):-1===Object.keys(o.values).indexOf(tm(n))&&s.push(new td(r,n,`expected one of [${Object.keys(o.values).join(", ")}], ${JSON.stringify(n)} found`)),s}function r0(i){if(!0===i||!1===i)return!0;if(!Array.isArray(i)||0===i.length)return!1;switch(i[0]){case"has":return i.length>=2&&"$id"!==i[1]&&"$type"!==i[1];case"in":return i.length>=3&&("string"!=typeof i[1]||Array.isArray(i[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==i.length||Array.isArray(i[1])||Array.isArray(i[2]);case"any":case"all":for(const r of i.slice(1))if(!r0(r)&&"boolean"!=typeof r)return!1;return!0;default:return!0}}function rT(i,r="fill"){if(null==i)return{filter:()=>!0,needGeometry:!1,needFeature:!1};r0(i)||(i=rk(i));const n=i;let o=!0;try{o=function(i){if(!rI(i))return i;let r=t8(i);return rS(r),r=rE(r)}(n)}catch(s){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[634],{6158:function(i,r,n){var o=n(3454);!function(r,n){i.exports=n()}(this,function(){"use strict";var i,r,n;function s(o,s){if(i){if(r){var a="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+i+")(sharedChunk); ("+r+")(sharedChunk); self.onerror = null;",l={};i(l),n=s(l),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(n.workerUrl=window.URL.createObjectURL(new Blob([a],{type:"text/javascript"})))}else r=s}else i=s}return s(["exports"],function(i){var r,n="2.7.0",s=a;function a(i,r,n,o){this.cx=3*i,this.bx=3*(n-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*r,this.by=3*(o-r)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=o,this.p2x=n,this.p2y=o}a.prototype.sampleCurveX=function(i){return((this.ax*i+this.bx)*i+this.cx)*i},a.prototype.sampleCurveY=function(i){return((this.ay*i+this.by)*i+this.cy)*i},a.prototype.sampleCurveDerivativeX=function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},a.prototype.solveCurveX=function(i,r){var n,o,s,a,l;for(void 0===r&&(r=1e-6),s=i,l=0;l<8;l++){if(Math.abs(a=this.sampleCurveX(s)-i)Math.abs(c))break;s-=a/c}if((s=i)<(n=0))return n;if(s>(o=1))return o;for(;na?n=s:o=s,s=.5*(o-n)+n;return s},a.prototype.solve=function(i,r){return this.sampleCurveY(this.solveCurveX(i,r))};var l=c;function c(i,r){this.x=i,this.y=r}c.prototype={clone:function(){return new c(this.x,this.y)},add:function(i){return this.clone()._add(i)},sub:function(i){return this.clone()._sub(i)},multByPoint:function(i){return this.clone()._multByPoint(i)},divByPoint:function(i){return this.clone()._divByPoint(i)},mult:function(i){return this.clone()._mult(i)},div:function(i){return this.clone()._div(i)},rotate:function(i){return this.clone()._rotate(i)},rotateAround:function(i,r){return this.clone()._rotateAround(i,r)},matMult:function(i){return this.clone()._matMult(i)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(i){return this.x===i.x&&this.y===i.y},dist:function(i){return Math.sqrt(this.distSqr(i))},distSqr:function(i){var r=i.x-this.x,n=i.y-this.y;return r*r+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith:function(i){return this.angleWithSep(i.x,i.y)},angleWithSep:function(i,r){return Math.atan2(this.x*r-this.y*i,this.x*i+this.y*r)},_matMult:function(i){var r=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=r,this},_add:function(i){return this.x+=i.x,this.y+=i.y,this},_sub:function(i){return this.x-=i.x,this.y-=i.y,this},_mult:function(i){return this.x*=i,this.y*=i,this},_div:function(i){return this.x/=i,this.y/=i,this},_multByPoint:function(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint:function(i){return this.x/=i.x,this.y/=i.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var i=this.y;return this.y=this.x,this.x=-i,this},_rotate:function(i){var r=Math.cos(i),n=Math.sin(i),o=n*this.x+r*this.y;return this.x=r*this.x-n*this.y,this.y=o,this},_rotateAround:function(i,r){var n=Math.cos(i),o=Math.sin(i),s=r.y+o*(this.x-r.x)+n*(this.y-r.y);return this.x=r.x+n*(this.x-r.x)-o*(this.y-r.y),this.y=s,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},c.convert=function(i){return i instanceof c?i:Array.isArray(i)?new c(i[0],i[1]):i};var u="undefined"!=typeof self?self:{},h="undefined"!=typeof Float32Array?Float32Array:Array;function d(){var i=new h(9);return h!=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 p(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 f(i,r,n){var o=r[0],s=r[1],a=r[2],l=r[3],c=r[4],u=r[5],h=r[6],d=r[7],p=r[8],f=r[9],m=r[10],g=r[11],y=r[12],x=r[13],$=r[14],v=r[15],_=n[0],b=n[1],w=n[2],T=n[3];return i[0]=_*o+b*c+w*p+T*y,i[1]=_*s+b*u+w*f+T*x,i[2]=_*a+b*h+w*m+T*$,i[3]=_*l+b*d+w*g+T*v,i[4]=(_=n[4])*o+(b=n[5])*c+(w=n[6])*p+(T=n[7])*y,i[5]=_*s+b*u+w*f+T*x,i[6]=_*a+b*h+w*m+T*$,i[7]=_*l+b*d+w*g+T*v,i[8]=(_=n[8])*o+(b=n[9])*c+(w=n[10])*p+(T=n[11])*y,i[9]=_*s+b*u+w*f+T*x,i[10]=_*a+b*h+w*m+T*$,i[11]=_*l+b*d+w*g+T*v,i[12]=(_=n[12])*o+(b=n[13])*c+(w=n[14])*p+(T=n[15])*y,i[13]=_*s+b*u+w*f+T*x,i[14]=_*a+b*h+w*m+T*$,i[15]=_*l+b*d+w*g+T*v,i}function m(i,r,n){var o,s,a,l,c,u,h,d,p,f,m,g,y=n[0],x=n[1],$=n[2];return r===i?(i[12]=r[0]*y+r[4]*x+r[8]*$+r[12],i[13]=r[1]*y+r[5]*x+r[9]*$+r[13],i[14]=r[2]*y+r[6]*x+r[10]*$+r[14],i[15]=r[3]*y+r[7]*x+r[11]*$+r[15]):(s=r[1],a=r[2],l=r[3],c=r[4],u=r[5],h=r[6],d=r[7],p=r[8],f=r[9],m=r[10],g=r[11],i[0]=o=r[0],i[1]=s,i[2]=a,i[3]=l,i[4]=c,i[5]=u,i[6]=h,i[7]=d,i[8]=p,i[9]=f,i[10]=m,i[11]=g,i[12]=o*y+c*x+p*$+r[12],i[13]=s*y+u*x+f*$+r[13],i[14]=a*y+h*x+m*$+r[14],i[15]=l*y+d*x+g*$+r[15]),i}function g(i,r,n){var o=n[0],s=n[1],a=n[2];return i[0]=r[0]*o,i[1]=r[1]*o,i[2]=r[2]*o,i[3]=r[3]*o,i[4]=r[4]*s,i[5]=r[5]*s,i[6]=r[6]*s,i[7]=r[7]*s,i[8]=r[8]*a,i[9]=r[9]*a,i[10]=r[10]*a,i[11]=r[11]*a,i[12]=r[12],i[13]=r[13],i[14]=r[14],i[15]=r[15],i}function y(i,r,n){var o=Math.sin(n),s=Math.cos(n),a=r[4],l=r[5],c=r[6],u=r[7],h=r[8],d=r[9],p=r[10],f=r[11];return r!==i&&(i[0]=r[0],i[1]=r[1],i[2]=r[2],i[3]=r[3],i[12]=r[12],i[13]=r[13],i[14]=r[14],i[15]=r[15]),i[4]=a*s+h*o,i[5]=l*s+d*o,i[6]=c*s+p*o,i[7]=u*s+f*o,i[8]=h*s-a*o,i[9]=d*s-l*o,i[10]=p*s-c*o,i[11]=f*s-u*o,i}function x(i,r,n){var o=Math.sin(n),s=Math.cos(n),a=r[0],l=r[1],c=r[2],u=r[3],h=r[8],d=r[9],p=r[10],f=r[11];return r!==i&&(i[4]=r[4],i[5]=r[5],i[6]=r[6],i[7]=r[7],i[12]=r[12],i[13]=r[13],i[14]=r[14],i[15]=r[15]),i[0]=a*s-h*o,i[1]=l*s-d*o,i[2]=c*s-p*o,i[3]=u*s-f*o,i[8]=a*o+h*s,i[9]=l*o+d*s,i[10]=c*o+p*s,i[11]=u*o+f*s,i}Math.hypot||(Math.hypot=function(){for(var i=0,r=arguments.length;r--;)i+=arguments[r]*arguments[r];return Math.sqrt(i)});var $=f;function v(){var i=new h(3);return h!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0),i}function _(i){var r=new h(3);return r[0]=i[0],r[1]=i[1],r[2]=i[2],r}function b(i){return Math.hypot(i[0],i[1],i[2])}function w(i,r,n){var o=new h(3);return o[0]=i,o[1]=r,o[2]=n,o}function T(i,r,n){return i[0]=r[0]+n[0],i[1]=r[1]+n[1],i[2]=r[2]+n[2],i}function E(i,r,n){return i[0]=r[0]-n[0],i[1]=r[1]-n[1],i[2]=r[2]-n[2],i}function S(i,r,n){return i[0]=r[0]*n[0],i[1]=r[1]*n[1],i[2]=r[2]*n[2],i}function I(i,r,n){return i[0]=Math.max(r[0],n[0]),i[1]=Math.max(r[1],n[1]),i[2]=Math.max(r[2],n[2]),i}function C(i,r,n){return i[0]=r[0]*n,i[1]=r[1]*n,i[2]=r[2]*n,i}function z(i,r,n,o){return i[0]=r[0]+n[0]*o,i[1]=r[1]+n[1]*o,i[2]=r[2]+n[2]*o,i}function A(i,r){var n=r[0],o=r[1],s=r[2],a=n*n+o*o+s*s;return a>0&&(a=1/Math.sqrt(a)),i[0]=r[0]*a,i[1]=r[1]*a,i[2]=r[2]*a,i}function k(i,r){return i[0]*r[0]+i[1]*r[1]+i[2]*r[2]}function P(i,r,n){var o=r[0],s=r[1],a=r[2],l=n[0],c=n[1],u=n[2];return i[0]=s*u-a*c,i[1]=a*l-o*u,i[2]=o*c-s*l,i}function D(i,r,n){var o=r[0],s=r[1],a=r[2],l=n[3]*o+n[7]*s+n[11]*a+n[15];return i[0]=(n[0]*o+n[4]*s+n[8]*a+n[12])/(l=l||1),i[1]=(n[1]*o+n[5]*s+n[9]*a+n[13])/l,i[2]=(n[2]*o+n[6]*s+n[10]*a+n[14])/l,i}function L(i,r,n){var o=n[0],s=n[1],a=n[2],l=r[0],c=r[1],u=r[2],h=s*u-a*c,d=a*l-o*u,p=o*c-s*l,f=s*p-a*d,m=a*h-o*p,g=o*d-s*h,y=2*n[3];return d*=y,p*=y,m*=2,g*=2,i[0]=l+(h*=y)+(f*=2),i[1]=c+d+m,i[2]=u+p+g,i}var B,R=E;function M(i,r,n){var o=r[0],s=r[1],a=r[2],l=r[3];return i[0]=n[0]*o+n[4]*s+n[8]*a+n[12]*l,i[1]=n[1]*o+n[5]*s+n[9]*a+n[13]*l,i[2]=n[2]*o+n[6]*s+n[10]*a+n[14]*l,i[3]=n[3]*o+n[7]*s+n[11]*a+n[15]*l,i}function F(){var i=new h(4);return h!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0),i[3]=1,i}function O(i){return i[0]=0,i[1]=0,i[2]=0,i[3]=1,i}function U(i,r,n){n*=.5;var o=r[0],s=r[1],a=r[2],l=r[3],c=Math.sin(n),u=Math.cos(n);return i[0]=o*u+l*c,i[1]=s*u+a*c,i[2]=a*u-s*c,i[3]=l*u-o*c,i}function V(i,r){return i[0]===r[0]&&i[1]===r[1]}v(),B=new h(4),h!=Float32Array&&(B[0]=0,B[1]=0,B[2]=0,B[3]=0),v(),w(1,0,0),w(0,1,0),F(),F(),d(),r=new h(2),h!=Float32Array&&(r[0]=0,r[1]=0);const j=Math.PI/180,N=180/Math.PI;function G(i){return i*j}function Z(i){return i*N}const q=[[0,0],[1,0],[1,1],[0,1],];function X(i){if(i<=0)return 0;if(i>=1)return 1;const r=i*i,n=r*i;return 4*(i<.5?n:3*(i-r)+n-.75)}function W(i,r,n,o){const a=new s(i,r,n,o);return function(i){return a.solve(i)}}const H=W(.25,.1,.25,1);function K(i,r,n){return Math.min(n,Math.max(r,i))}function Y(i,r,n){return(n=K((n-i)/(r-i),0,1))*n*(3-2*n)}function J(i,r,n){const o=n-r,s=((i-r)%o+o)%o+r;return s===r?n:s}function Q(i,r,n){if(!i.length)return n(null,[]);let o=i.length;const s=Array(i.length);let a=null;i.forEach((i,l)=>{r(i,(i,r)=>{i&&(a=i),s[l]=r,0==--o&&n(a,s)})})}function ee(i){const r=[];for(const n in i)r.push(i[n]);return r}function et(i,...r){for(const n of r)for(const o in n)i[o]=n[o];return i}let ei=1;function er(){return ei++}function en(){return function i(r){return r?(r^16*Math.random()>>r/4).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,i)}()}function eo(i){return i<=1?1:Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function es(i){return!!i&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(i)}function ea(i,r){i.forEach(i=>{r[i]&&(r[i]=r[i].bind(r))})}function el(i,r){return -1!==i.indexOf(r,i.length-r.length)}function ec(i,r,n){const o={};for(const s in i)o[s]=r.call(n||this,i[s],s,i);return o}function eu(i,r,n){const o={};for(const s in i)r.call(n||this,i[s],s,i)&&(o[s]=i[s]);return o}function eh(i){return Array.isArray(i)?i.map(eh):"object"==typeof i&&i?ec(i,eh):i}const ed={};function ep(i){ed[i]||("undefined"!=typeof console&&console.warn(i),ed[i]=!0)}function ef(i,r,n){return(n.y-i.y)*(r.x-i.x)>(r.y-i.y)*(n.x-i.x)}function em(i){let r=0;for(let n,o,s=0,a=i.length,l=a-1;s@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(i,n,o,s)=>{const a=o||s;return r[n]=!a||a.toLowerCase(),""}),r["max-age"]){const n=parseInt(r["max-age"],10);isNaN(n)?delete r["max-age"]:r["max-age"]=n}return r}let ey,ex,e$,ev=null;function e_(i){if(null==ev){const r=i.navigator?i.navigator.userAgent:null;ev=!!i.safari||!(!r||!(/\b(iPad|iPhone|iPod)\b/.test(r)||r.match("Safari")&&!r.match("Chrome")))}return ev}function eb(i){try{const r=u[i];return r.setItem("_mapbox_test_",1),r.removeItem("_mapbox_test_"),!0}catch(n){return!1}}const ew={now:()=>void 0!==e$?e$:u.performance.now(),setNow(i){e$=i},restoreNow(){e$=void 0},frame(i){const r=u.requestAnimationFrame(i);return{cancel:()=>u.cancelAnimationFrame(r)}},getImageData(i,r=0){const n=u.document.createElement("canvas"),o=n.getContext("2d");if(!o)throw Error("failed to create canvas 2d context");return n.width=i.width,n.height=i.height,o.drawImage(i,0,0,i.width,i.height),o.getImageData(-r,-r,i.width+2*r,i.height+2*r)},resolveURL:i=>(ey||(ey=u.document.createElement("a")),ey.href=i,ey.href),get devicePixelRatio(){return u.devicePixelRatio},get prefersReducedMotion(){return!!u.matchMedia&&(null==ex&&(ex=u.matchMedia("(prefers-reduced-motion: reduce)")),ex.matches)}};let e0;const eT={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==e0){const eE=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{e0=null!=o.env.API_URL_REGEX?RegExp(o.env.API_URL_REGEX):eE}catch(eS){e0=eE}}return e0},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},eI={supported:!1,testSupport:function(i){!eA&&ez&&(ek?eP(i):eC=i)}};let eC,ez,eA=!1,ek=!1;function eP(i){const r=i.createTexture();i.bindTexture(i.TEXTURE_2D,r);try{if(i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,ez),i.isContextLost())return;eI.supported=!0}catch(n){}i.deleteTexture(r),eA=!0}u.document&&((ez=u.document.createElement("img")).onload=function(){eC&&eP(eC),eC=null,ek=!0},ez.onerror=function(){eA=!0,eC=null},ez.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const eD="NO_ACCESS_TOKEN";function eL(i){return 0===i.indexOf("mapbox:")}function e1(i){return eT.API_URL_REGEX.test(i)}const eB=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function eR(i){const r=i.match(eB);if(!r)throw Error("Unable to parse URL object");return{protocol:r[1],authority:r[2],path:r[3]||"/",params:r[4]?r[4].split("&"):[]}}function e3(i){const r=i.params.length?`?${i.params.join("&")}`:"";return`${i.protocol}://${i.authority}${i.path}${r}`}function eM(i){if(!i)return null;const r=i.split(".");if(!r||3!==r.length)return null;try{return JSON.parse(decodeURIComponent(u.atob(r[1]).split("").map(i=>"%"+("00"+i.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(n){return null}}class e2{constructor(i){this.type=i,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(i){const r=eM(eT.ACCESS_TOKEN);let n="";return n=r&&r.u?u.btoa(encodeURIComponent(r.u).replace(/%([0-9A-F]{2})/g,(i,r)=>String.fromCharCode(Number("0x"+r)))):eT.ACCESS_TOKEN||"",i?`mapbox.eventData.${i}:${n}`:`mapbox.eventData:${n}`}fetchEventData(){const i=eb("localStorage"),r=this.getStorageKey(),n=this.getStorageKey("uuid");if(i)try{const o=u.localStorage.getItem(r);o&&(this.eventData=JSON.parse(o));const s=u.localStorage.getItem(n);s&&(this.anonId=s)}catch(a){ep("Unable to read from LocalStorage")}}saveEventData(){const i=eb("localStorage"),r=this.getStorageKey(),n=this.getStorageKey("uuid");if(i)try{u.localStorage.setItem(n,this.anonId),Object.keys(this.eventData).length>=1&&u.localStorage.setItem(r,JSON.stringify(this.eventData))}catch(o){ep("Unable to write to LocalStorage")}}processRequests(i){}postEvent(i,r,o,s){if(!eT.EVENTS_URL)return;const a=eR(eT.EVENTS_URL);a.params.push(`access_token=${s||eT.ACCESS_TOKEN||""}`);const l={event:this.type,created:new Date(i).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:n,skuId:"01",userId:this.anonId},c=r?et(l,r):l,u={url:e3(a),headers:{"Content-Type":"text/plain"},body:JSON.stringify([c])};this.pendingRequest=eQ(u,i=>{this.pendingRequest=null,o(i),this.saveEventData(),this.processRequests(s)})}queueRequest(i,r){this.queue.push(i),this.processRequests(r)}}const eF=new class extends e2{constructor(i){super("appUserTurnstile"),this._customAccessToken=i}postTurnstileEvent(i,r){eT.EVENTS_URL&&eT.ACCESS_TOKEN&&Array.isArray(i)&&i.some(i=>eL(i)||e1(i))&&this.queueRequest(Date.now(),r)}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const r=eM(eT.ACCESS_TOKEN),n=r?r.u:eT.ACCESS_TOKEN;let o=n!==this.eventData.tokenU;es(this.anonId)||(this.anonId=en(),o=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const a=new Date(this.eventData.lastSuccess),l=new Date(s),c=(s-this.eventData.lastSuccess)/864e5;o=o||c>=1||c<-1||a.getDate()!==l.getDate()}else o=!0;if(!o)return this.processRequests();this.postEvent(s,{"enabled.telemetry":!1},i=>{i||(this.eventData.lastSuccess=s,this.eventData.tokenU=n)},i)}},eO=eF.postTurnstileEvent.bind(eF),e4=new class extends e2{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(i,r,n,o){this.skuToken=r,this.errorCb=o,eT.EVENTS_URL&&(n||eT.ACCESS_TOKEN?this.queueRequest({id:i,timestamp:Date.now()},n):this.errorCb(Error(eD)))}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;const{id:r,timestamp:n}=this.queue.shift();r&&this.success[r]||(this.anonId||this.fetchEventData(),es(this.anonId)||(this.anonId=en()),this.postEvent(n,{skuToken:this.skuToken},i=>{i?this.errorCb(i):r&&(this.success[r]=!0)},i))}},eU=e4.postMapLoadEvent.bind(e4),eV=new class extends e2{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(i,r,n,o){if(!eT.API_URL||!eT.SESSION_PATH)return;const s=eR(eT.API_URL+eT.SESSION_PATH);s.params.push(`sku=${r||""}`),s.params.push(`access_token=${o||eT.ACCESS_TOKEN||""}`);const a={url:e3(s),headers:{"Content-Type":"text/plain"}};this.pendingRequest=te(a,i=>{this.pendingRequest=null,n(i),this.saveEventData(),this.processRequests(o)})}getSessionAPI(i,r,n,o){this.skuToken=r,this.errorCb=o,eT.SESSION_PATH&&eT.API_URL&&(n||eT.ACCESS_TOKEN?this.queueRequest({id:i,timestamp:Date.now()},n):this.errorCb(Error(eD)))}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;const{id:r,timestamp:n}=this.queue.shift();r&&this.success[r]||this.getSession(n,this.skuToken,i=>{i?this.errorCb(i):r&&(this.success[r]=!0)},i)}},e6=eV.getSessionAPI.bind(eV),ej=new Set,eN="mapbox-tiles";let eG,eZ,e9=500,e7=50;function eq(){u.caches&&!eG&&(eG=u.caches.open(eN))}function e5(i){const r=i.indexOf("?");return r<0?i:i.slice(0,r)}let eX=1/0;const eW={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(eW);class eH extends Error{constructor(i,r,n){401===r&&e1(n)&&(i+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(i),this.status=r,this.url=n}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const eK=e8()?()=>self.worker&&self.worker.referrer:()=>("blob:"===u.location.protocol?u.parent:u).location.href,eY=function(i,r){var n;if(!(/^file:/.test(n=i.url)||/^file:/.test(eK())&&!/^\w+:/.test(n))){if(u.fetch&&u.Request&&u.AbortController&&u.Request.prototype.hasOwnProperty("signal"))return function(i,r){var n;const o=new u.AbortController,s=new u.Request(i.url,{method:i.method||"GET",body:i.body,credentials:i.credentials,headers:i.headers,referrer:eK(),signal:o.signal});let a=!1,l=!1;const c=(n=s.url).indexOf("sku=")>0&&e1(n);"json"===i.type&&s.headers.set("Accept","application/json");const h=(n,o,a)=>{if(l)return;if(n&&"SecurityError"!==n.message&&ep(n),o&&a)return d(o);const h=Date.now();u.fetch(s).then(n=>{if(n.ok){const o=c?n.clone():null;return d(n,o,h)}return r(new eH(n.statusText,n.status,i.url))}).catch(i=>{20!==i.code&&r(Error(i.message))})},d=(n,o,c)=>{("arrayBuffer"===i.type?n.arrayBuffer():"json"===i.type?n.json():n.text()).then(i=>{l||(o&&c&&function(i,r,n){if(eq(),!eG)return;const o={status:r.status,statusText:r.statusText,headers:new u.Headers};r.headers.forEach((i,r)=>o.headers.set(r,i));const s=eg(r.headers.get("Cache-Control")||"");s["no-store"]||(s["max-age"]&&o.headers.set("Expires",new Date(n+1e3*s["max-age"]).toUTCString()),new Date(o.headers.get("Expires")).getTime()-n<42e4||function(i,r){if(void 0===eZ)try{new Response(new ReadableStream),eZ=!0}catch(n){eZ=!1}eZ?r(i.body):i.blob().then(r)}(r,r=>{const n=new u.Response(r,o);eq(),eG&&eG.then(r=>r.put(e5(i.url),n)).catch(i=>ep(i.message))}))}(s,o,c),a=!0,r(null,i,n.headers.get("Cache-Control"),n.headers.get("Expires")))}).catch(i=>{l||r(Error(i.message))})};return c?function(i,r){if(eq(),!eG)return r(null);const n=e5(i.url);eG.then(i=>{i.match(n).then(o=>{const s=function(i){if(!i)return!1;const r=new Date(i.headers.get("Expires")||0),n=eg(i.headers.get("Cache-Control")||"");return r>Date.now()&&!n["no-cache"]}(o);i.delete(n),s&&i.put(n,o.clone()),r(null,o,s)}).catch(r)}).catch(r)}(s,h):h(null,null),{cancel(){l=!0,a||o.abort()}}}(i,r);if(e8()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",i,r,void 0,!0)}return function(i,r){const n=new u.XMLHttpRequest;for(const o in n.open(i.method||"GET",i.url,!0),"arrayBuffer"===i.type&&(n.responseType="arraybuffer"),i.headers)n.setRequestHeader(o,i.headers[o]);return"json"===i.type&&(n.responseType="text",n.setRequestHeader("Accept","application/json")),n.withCredentials="include"===i.credentials,n.onerror=()=>{r(Error(n.statusText))},n.onload=()=>{if((n.status>=200&&n.status<300||0===n.status)&&null!==n.response){let o=n.response;if("json"===i.type)try{o=JSON.parse(n.response)}catch(s){return r(s)}r(null,o,n.getResponseHeader("Cache-Control"),n.getResponseHeader("Expires"))}else r(new eH(n.statusText,n.status,i.url))},n.send(i.body),{cancel:()=>n.abort()}}(i,r)},eJ=function(i,r){return eY(et(i,{type:"arrayBuffer"}),r)},eQ=function(i,r){return eY(et(i,{method:"POST"}),r)},te=function(i,r){return eY(et(i,{method:"GET"}),r)};function tt(i){const r=u.document.createElement("a");return r.href=i,r.protocol===u.document.location.protocol&&r.host===u.document.location.host}const ti="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let tr,tn;tr=[],tn=0;const to=function(i,r){if(eI.supported&&(i.headers||(i.headers={}),i.headers.accept="image/webp,*/*"),tn>=eT.MAX_PARALLEL_IMAGE_REQUESTS){const n={requestParameters:i,callback:r,cancelled:!1,cancel(){this.cancelled=!0}};return tr.push(n),n}tn++;let o=!1;const s=()=>{if(!o)for(o=!0,tn--;tr.length&&tn{s(),i?r(i):n&&(u.createImageBitmap?function(i,r){const n=new u.Blob([new Uint8Array(i)],{type:"image/png"});u.createImageBitmap(n).then(i=>{r(null,i)}).catch(i=>{r(Error(`Could not load image because of ${i.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(n,(i,n)=>r(i,n,o,a)):function(i,r){const n=new u.Image,o=u.URL;n.onload=()=>{r(null,n),o.revokeObjectURL(n.src),n.onload=null,u.requestAnimationFrame(()=>{n.src=ti})},n.onerror=()=>r(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 s=new u.Blob([new Uint8Array(i)],{type:"image/png"});n.src=i.byteLength?o.createObjectURL(s):ti}(n,(i,n)=>r(i,n,o,a)))});return{cancel(){a.cancel(),s()}}};function ts(i,r,n){n[i]&&-1!==n[i].indexOf(r)||(n[i]=n[i]||[],n[i].push(r))}function ta(i,r,n){if(n&&n[i]){const o=n[i].indexOf(r);-1!==o&&n[i].splice(o,1)}}class tl{constructor(i,r={}){et(this,r),this.type=i}}class tc extends tl{constructor(i,r={}){super("error",et({error:i},r))}}class tu{on(i,r){return this._listeners=this._listeners||{},ts(i,r,this._listeners),this}off(i,r){return ta(i,r,this._listeners),ta(i,r,this._oneTimeListeners),this}once(i,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},ts(i,r,this._oneTimeListeners),this):new Promise(r=>this.once(i,r))}fire(i,r){"string"==typeof i&&(i=new tl(i,r||{}));const n=i.type;if(this.listens(n)){i.target=this;const o=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const s of o)s.call(this,i);const a=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const l of a)ta(n,l,this._oneTimeListeners),l.call(this,i);const c=this._eventedParent;c&&(et(i,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),c.fire(i))}else i instanceof tc&&console.error(i.error);return this}listens(i){return!!(this._listeners&&this._listeners[i]&&this._listeners[i].length>0||this._oneTimeListeners&&this._oneTimeListeners[i]&&this._oneTimeListeners[i].length>0||this._eventedParent&&this._eventedParent.listens(i))}setEventedParent(i,r){return this._eventedParent=i,this._eventedParentData=r,this}}var th=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":0.1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');class td{constructor(i,r,n,o){this.message=(i?`${i}: `:"")+n,o&&(this.identifier=o),null!=r&&r.__line__&&(this.line=r.__line__)}}function tp(i){const r=i.value;return r?[new td(i.key,r,"constants have been deprecated as of v8"),]:[]}function tf(i,...r){for(const n of r)for(const o in n)i[o]=n[o];return i}function tm(i){return i instanceof Number||i instanceof String||i instanceof Boolean?i.valueOf():i}function t8(i){if(Array.isArray(i))return i.map(t8);if(i instanceof Object&&!(i instanceof Number||i instanceof String||i instanceof Boolean)){const r={};for(const n in i)r[n]=t8(i[n]);return r}return tm(i)}class tg extends Error{constructor(i,r){super(r),this.message=r,this.key=i}}class ty{constructor(i,r=[]){for(const[n,o]of(this.parent=i,this.bindings={},r))this.bindings[n]=o}concat(i){return new ty(this,i)}get(i){if(this.bindings[i])return this.bindings[i];if(this.parent)return this.parent.get(i);throw Error(`${i} not found in scope.`)}has(i){return!!this.bindings[i]||!!this.parent&&this.parent.has(i)}}const tx={kind:"null"},t$={kind:"number"},tv={kind:"string"},t_={kind:"boolean"},tb={kind:"color"},tw={kind:"object"},t0={kind:"value"},tT={kind:"collator"},tE={kind:"formatted"},tS={kind:"resolvedImage"};function tI(i,r){return{kind:"array",itemType:i,N:r}}function tC(i){if("array"===i.kind){const r=tC(i.itemType);return"number"==typeof i.N?`array<${r}, ${i.N}>`:"value"===i.itemType.kind?"array":`array<${r}>`}return i.kind}const tz=[tx,t$,tv,t_,tb,tE,tw,tI(t0),tS];function tA(i,r){if("error"===r.kind)return null;if("array"===i.kind){if("array"===r.kind&&(0===r.N&&"value"===r.itemType.kind||!tA(i.itemType,r.itemType))&&("number"!=typeof i.N||i.N===r.N))return null}else{if(i.kind===r.kind)return null;if("value"===i.kind){for(const n of tz)if(!tA(n,r))return null}}return`Expected ${tC(i)} but found ${tC(r)} instead.`}function tk(i,r){return r.some(r=>r.kind===i.kind)}function tP(i,r){return r.some(r=>"null"===r?null===i:"array"===r?Array.isArray(i):"object"===r?i&&!Array.isArray(i)&&"object"==typeof i:r===typeof i)}function tD(i){var r={exports:{}};return i(r,r.exports),r.exports}var tL=tD(function(i,r){var n={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function o(i){return(i=Math.round(i))<0?0:i>255?255:i}function s(i){return o("%"===i[i.length-1]?parseFloat(i)/100*255:parseInt(i))}function a(i){var r;return(r="%"===i[i.length-1]?parseFloat(i)/100:parseFloat(i))<0?0:r>1?1:r}function l(i,r,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?i+(r-i)*n*6:2*n<1?r:3*n<2?i+(r-i)*(2/3-n)*6:i}try{r.parseCSSColor=function(i){var r,c=i.replace(/ /g,"").toLowerCase();if(c in n)return n[c].slice();if("#"===c[0])return 4===c.length?(r=parseInt(c.substr(1),16))>=0&&r<=4095?[(3840&r)>>4|(3840&r)>>8,240&r|(240&r)>>4,15&r|(15&r)<<4,1,]:null:7===c.length&&(r=parseInt(c.substr(1),16))>=0&&r<=16777215?[(16711680&r)>>16,(65280&r)>>8,255&r,1,]:null;var u=c.indexOf("("),h=c.indexOf(")");if(-1!==u&&h+1===c.length){var d=c.substr(0,u),p=c.substr(u+1,h-(u+1)).split(","),f=1;switch(d){case"rgba":if(4!==p.length)break;f=a(p.pop());case"rgb":return 3!==p.length?null:[s(p[0]),s(p[1]),s(p[2]),f,];case"hsla":if(4!==p.length)break;f=a(p.pop());case"hsl":if(3!==p.length)break;var m=(parseFloat(p[0])%360+360)%360/360,g=a(p[1]),y=a(p[2]),x=y<=.5?y*(g+1):y+g-y*g,$=2*y-x;return[o(255*l($,x,m+1/3)),o(255*l($,x,m)),o(255*l($,x,m-1/3)),f,]}}return null}}catch(c){}});class t1{constructor(i,r,n,o=1){this.r=i,this.g=r,this.b=n,this.a=o}static parse(i){if(!i)return;if(i instanceof t1)return i;if("string"!=typeof i)return;const r=tL.parseCSSColor(i);return r?new t1(r[0]/255*r[3],r[1]/255*r[3],r[2]/255*r[3],r[3]):void 0}toString(){const[i,r,n,o]=this.toArray();return`rgba(${Math.round(i)},${Math.round(r)},${Math.round(n)},${o})`}toArray(){const{r:i,g:r,b:n,a:o}=this;return 0===o?[0,0,0,0]:[255*i/o,255*r/o,255*n/o,o,]}}t1.black=new t1(0,0,0,1),t1.white=new t1(1,1,1,1),t1.transparent=new t1(0,0,0,0),t1.red=new t1(1,0,0,1),t1.blue=new t1(0,0,1,1);class tB{constructor(i,r,n){this.sensitivity=i?r?"variant":"case":r?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(i,r){return this.collator.compare(i,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class tR{constructor(i,r,n,o,s){this.text=i.normalize?i.normalize():i,this.image=r,this.scale=n,this.fontStack=o,this.textColor=s}}class t3{constructor(i){this.sections=i}static fromString(i){return new t3([new tR(i,null,null,null,null),])}isEmpty(){return 0===this.sections.length||!this.sections.some(i=>0!==i.text.length||i.image&&0!==i.image.name.length)}static factory(i){return i instanceof t3?i:t3.fromString(i)}toString(){return 0===this.sections.length?"":this.sections.map(i=>i.text).join("")}serialize(){const i=["format"];for(const r of this.sections){if(r.image){i.push(["image",r.image.name]);continue}i.push(r.text);const n={};r.fontStack&&(n["text-font"]=["literal",r.fontStack.split(","),]),r.scale&&(n["font-scale"]=r.scale),r.textColor&&(n["text-color"]=["rgba"].concat(r.textColor.toArray())),i.push(n)}return i}}class tM{constructor(i){this.name=i.name,this.available=i.available}toString(){return this.name}static fromString(i){return i?new tM({name:i,available:!1}):null}serialize(){return["image",this.name]}}function t2(i,r,n,o){return"number"==typeof i&&i>=0&&i<=255&&"number"==typeof r&&r>=0&&r<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===o||"number"==typeof o&&o>=0&&o<=1?null:`Invalid rgba value [${[i,r,n,o].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof o?[i,r,n,o]:[i,r,n]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function tF(i){if(null===i||"string"==typeof i||"boolean"==typeof i||"number"==typeof i||i instanceof t1||i instanceof tB||i instanceof t3||i instanceof tM)return!0;if(Array.isArray(i)){for(const r of i)if(!tF(r))return!1;return!0}if("object"==typeof i){for(const n in i)if(!tF(i[n]))return!1;return!0}return!1}function tO(i){if(null===i)return tx;if("string"==typeof i)return tv;if("boolean"==typeof i)return t_;if("number"==typeof i)return t$;if(i instanceof t1)return tb;if(i instanceof tB)return tT;if(i instanceof t3)return tE;if(i instanceof tM)return tS;if(Array.isArray(i)){const r=i.length;let n;for(const o of i){const s=tO(o);if(n){if(n===s)continue;n=t0;break}n=s}return tI(n||t0,r)}return tw}function t4(i){const r=typeof i;return null===i?"":"string"===r||"number"===r||"boolean"===r?String(i):i instanceof t1||i instanceof t3||i instanceof tM?i.toString():JSON.stringify(i)}class tU{constructor(i,r){this.type=i,this.value=r}static parse(i,r){if(2!==i.length)return r.error(`'literal' expression requires exactly one argument, but found ${i.length-1} instead.`);if(!tF(i[1]))return r.error("invalid value");const n=i[1];let o=tO(n);const s=r.expectedType;return"array"===o.kind&&0===o.N&&s&&"array"===s.kind&&("number"!=typeof s.N||0===s.N)&&(o=s),new tU(o,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof t1?["rgba"].concat(this.value.toArray()):this.value instanceof t3?this.value.serialize():this.value}}class tV{constructor(i){this.name="ExpressionEvaluationError",this.message=i}toJSON(){return this.message}}const t6={string:tv,number:t$,boolean:t_,object:tw};class tj{constructor(i,r){this.type=i,this.args=r}static parse(i,r){if(i.length<2)return r.error("Expected at least one argument.");let n,o=1;const s=i[0];if("array"===s){let a,l;if(i.length>2){const c=i[1];if("string"!=typeof c||!(c in t6)||"object"===c)return r.error('The item type argument of "array" must be one of string, number, boolean',1);a=t6[c],o++}else a=t0;if(i.length>3){if(null!==i[2]&&("number"!=typeof i[2]||i[2]<0||i[2]!==Math.floor(i[2])))return r.error('The length argument to "array" must be a positive integer literal',2);l=i[2],o++}n=tI(a,l)}else n=t6[s];const u=[];for(;oi.outputDefined())}serialize(){const i=this.type,r=[i.kind];if("array"===i.kind){const n=i.itemType;if("string"===n.kind||"number"===n.kind||"boolean"===n.kind){r.push(n.kind);const o=i.N;("number"==typeof o||this.args.length>1)&&r.push(o)}}return r.concat(this.args.map(i=>i.serialize()))}}class tN{constructor(i){this.type=tE,this.sections=i}static parse(i,r){if(i.length<2)return r.error("Expected at least one argument.");const n=i[1];if(!Array.isArray(n)&&"object"==typeof n)return r.error("First argument must be an image or text section.");const o=[];let s=!1;for(let a=1;a<=i.length-1;++a){const l=i[a];if(s&&"object"==typeof l&&!Array.isArray(l)){s=!1;let c=null;if(l["font-scale"]&&!(c=r.parse(l["font-scale"],1,t$)))return null;let u=null;if(l["text-font"]&&!(u=r.parse(l["text-font"],1,tI(tv))))return null;let h=null;if(l["text-color"]&&!(h=r.parse(l["text-color"],1,tb)))return null;const d=o[o.length-1];d.scale=c,d.font=u,d.textColor=h}else{const p=r.parse(i[a],1,t0);if(!p)return null;const f=p.type.kind;if("string"!==f&&"value"!==f&&"null"!==f&&"resolvedImage"!==f)return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");s=!0,o.push({content:p,scale:null,font:null,textColor:null})}}return new tN(o)}evaluate(i){return new t3(this.sections.map(r=>{const n=r.content.evaluate(i);return tO(n)===tS?new tR("",n,null,null,null):new tR(t4(n),null,r.scale?r.scale.evaluate(i):null,r.font?r.font.evaluate(i).join(","):null,r.textColor?r.textColor.evaluate(i):null)}))}eachChild(i){for(const r of this.sections)i(r.content),r.scale&&i(r.scale),r.font&&i(r.font),r.textColor&&i(r.textColor)}outputDefined(){return!1}serialize(){const i=["format"];for(const r of this.sections){i.push(r.content.serialize());const n={};r.scale&&(n["font-scale"]=r.scale.serialize()),r.font&&(n["text-font"]=r.font.serialize()),r.textColor&&(n["text-color"]=r.textColor.serialize()),i.push(n)}return i}}class tG{constructor(i){this.type=tS,this.input=i}static parse(i,r){if(2!==i.length)return r.error("Expected two arguments.");const n=r.parse(i[1],1,tv);return n?new tG(n):r.error("No image name provided.")}evaluate(i){const r=this.input.evaluate(i),n=tM.fromString(r);return n&&i.availableImages&&(n.available=i.availableImages.indexOf(r)>-1),n}eachChild(i){i(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const tZ={"to-boolean":t_,"to-color":tb,"to-number":t$,"to-string":tv};class t9{constructor(i,r){this.type=i,this.args=r}static parse(i,r){if(i.length<2)return r.error("Expected at least one argument.");const n=i[0];if(("to-boolean"===n||"to-string"===n)&&2!==i.length)return r.error("Expected one argument.");const o=tZ[n],s=[];for(let a=1;a4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:t2(r[0],r[1],r[2],r[3])))return new t1(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new tV(n||`Could not parse color from value '${"string"==typeof r?r:String(JSON.stringify(r))}'`)}if("number"===this.type.kind){let a=null;for(const l of this.args){if(null===(a=l.evaluate(i)))return 0;const c=Number(a);if(!isNaN(c))return c}throw new tV(`Could not convert ${JSON.stringify(a)} to number.`)}return"formatted"===this.type.kind?t3.fromString(t4(this.args[0].evaluate(i))):"resolvedImage"===this.type.kind?tM.fromString(t4(this.args[0].evaluate(i))):t4(this.args[0].evaluate(i))}eachChild(i){this.args.forEach(i)}outputDefined(){return this.args.every(i=>i.outputDefined())}serialize(){if("formatted"===this.type.kind)return new tN([{content:this.args[0],scale:null,font:null,textColor:null},]).serialize();if("resolvedImage"===this.type.kind)return new tG(this.args[0]).serialize();const i=[`to-${this.type.kind}`];return this.eachChild(r=>{i.push(r.serialize())}),i}}const t7=["Unknown","Point","LineString","Polygon",];class tq{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?t7[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const i=this.featureDistanceData.center,r=this.featureDistanceData.scale,{x:n,y:o}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(n*r-i[0])+this.featureDistanceData.bearing[1]*(o*r-i[1])}return 0}parseColor(i){let r=this._parseColorCache[i];return r||(r=this._parseColorCache[i]=t1.parse(i)),r}}class t5{constructor(i,r,n,o){this.name=i,this.type=r,this._evaluate=n,this.args=o}evaluate(i){return this._evaluate(i,this.args)}eachChild(i){this.args.forEach(i)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(i=>i.serialize()))}static parse(i,r){const n=i[0],o=t5.definitions[n];if(!o)return r.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);const s=Array.isArray(o)?o[0]:o.type,a=Array.isArray(o)?[[o[1],o[2]]]:o.overloads,l=a.filter(([r])=>!Array.isArray(r)||r.length===i.length-1);let c=null;for(const[u,h]of l){c=new i8(r.registry,r.path,null,r.scope);const d=[];let p=!1;for(let f=1;f{var r;return Array.isArray(r=i)?`(${r.map(tC).join(", ")})`:`(${tC(r.type)}...)`}).join(" | "),b=[];for(let w=1;w=r[2]||i[1]<=r[1]||i[3]>=r[3])}function tK(i,r){const n=(180+i[0])/360,o=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,s=Math.pow(2,r.z);return[Math.round(n*s*8192),Math.round(o*s*8192),]}function tY(i,r,n){const o=i[0]-r[0],s=i[1]-r[1],a=i[0]-n[0],l=i[1]-n[1];return o*l-a*s==0&&o*a<=0&&s*l<=0}function tJ(i,r){var n,o,s;let a=!1;for(let l=0,c=r.length;l(n=i)[1]!=(s=u[h+1])[1]>n[1]&&n[0]<(s[0]-o[0])*(n[1]-o[1])/(s[1]-o[1])+o[0]&&(a=!a)}}return a}function tQ(i,r){for(let n=0;n0&&c<0||l<0&&c>0}function it(i,r,n){var o,s,a,l,c,u;for(const h of n)for(let d=0;dn[2]){const s=.5*o;let a=i[0]-n[0]>s?-o:n[0]-i[0]>s?o:0;0===a&&(a=i[0]-n[2]>s?-o:n[2]-i[0]>s?o:0),i[0]+=a}tW(r,i)}function il(i,r,n,o){const s=8192*Math.pow(2,o.z),a=[8192*o.x,8192*o.y],l=[];for(const c of i)for(const u of c){const h=[u.x+a[0],u.y+a[1]];ia(h,r,n,s),l.push(h)}return l}function ic(i,r,n,o){var s;const a=8192*Math.pow(2,o.z),l=[8192*o.x,8192*o.y],c=[];for(const u of i){const h=[];for(const d of u){const p=[d.x+l[0],d.y+l[1]];tW(r,p),h.push(p)}c.push(h)}if(r[2]-r[0]<=a/2)for(const f of((s=r)[0]=s[1]=1/0,s[2]=s[3]=-1/0,c))for(const m of f)ia(m,r,n,a);return c}class iu{constructor(i,r){this.type=t_,this.geojson=i,this.geometries=r}static parse(i,r){if(2!==i.length)return r.error(`'within' expression requires exactly one argument, but found ${i.length-1} instead.`);if(tF(i[1])){const n=i[1];if("FeatureCollection"===n.type)for(let o=0;o{r&&!ih(i)&&(r=!1)}),r}function id(i){if(i instanceof t5&&"feature-state"===i.name)return!1;let r=!0;return i.eachChild(i=>{r&&!id(i)&&(r=!1)}),r}function ip(i,r){if(i instanceof t5&&r.indexOf(i.name)>=0)return!1;let n=!0;return i.eachChild(i=>{n&&!ip(i,r)&&(n=!1)}),n}class im{constructor(i,r){this.type=r.type,this.name=i,this.boundExpression=r}static parse(i,r){if(2!==i.length||"string"!=typeof i[1])return r.error("'var' expression requires exactly one string literal argument.");const n=i[1];return r.scope.has(n)?new im(n,r.scope.get(n)):r.error(`Unknown variable "${n}". Make sure "${n}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(i){return this.boundExpression.evaluate(i)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class i8{constructor(i,r=[],n,o=new ty,s=[]){this.registry=i,this.path=r,this.key=r.map(i=>`[${i}]`).join(""),this.scope=o,this.errors=s,this.expectedType=n}parse(i,r,n,o,s={}){return r?this.concat(r,n,o)._parse(i,s):this._parse(i,s)}_parse(i,r){function n(i,r,n){return"assert"===n?new tj(r,[i]):"coerce"===n?new t9(r,[i]):i}if(null!==i&&"string"!=typeof i&&"boolean"!=typeof i&&"number"!=typeof i||(i=["literal",i]),Array.isArray(i)){if(0===i.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const o=i[0];if("string"!=typeof o)return this.error(`Expression name must be a string, but found ${typeof o} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const s=this.registry[o];if(s){let a=s.parse(i,this);if(!a)return null;if(this.expectedType){const l=this.expectedType,c=a.type;if("string"!==l.kind&&"number"!==l.kind&&"boolean"!==l.kind&&"object"!==l.kind&&"array"!==l.kind||"value"!==c.kind){if("color"!==l.kind&&"formatted"!==l.kind&&"resolvedImage"!==l.kind||"value"!==c.kind&&"string"!==c.kind){if(this.checkSubtype(l,c))return null}else a=n(a,l,r.typeAnnotation||"coerce")}else a=n(a,l,r.typeAnnotation||"assert")}if(!(a instanceof tU)&&"resolvedImage"!==a.type.kind&&ig(a)){const u=new tq;try{a=new tU(a.type,a.evaluate(u))}catch(h){return this.error(h.message),null}}return a}return this.error(`Unknown expression "${o}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===i?"'undefined' value invalid. Use null instead.":"object"==typeof i?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof i} instead.`)}concat(i,r,n){const o="number"==typeof i?this.path.concat(i):this.path,s=n?this.scope.concat(n):this.scope;return new i8(this.registry,o,r||null,s,this.errors)}error(i,...r){const n=`${this.key}${r.map(i=>`[${i}]`).join("")}`;this.errors.push(new tg(n,i))}checkSubtype(i,r){const n=tA(i,r);return n&&this.error(n),n}}function ig(i){if(i instanceof im)return ig(i.boundExpression);if(i instanceof t5&&"error"===i.name||i instanceof tX||i instanceof iu)return!1;const r=i instanceof t9||i instanceof tj;let n=!0;return i.eachChild(i=>{n=r?n&&ig(i):n&&i instanceof tU}),!!n&&ih(i)&&ip(i,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center",])}function iy(i,r){const n=i.length-1;let o,s,a=0,l=n,c=0;for(;a<=l;)if(o=i[c=Math.floor((a+l)/2)],s=i[c+1],o<=r){if(c===n||rr))throw new tV("Input is not a number.");l=c-1}return 0}class ix{constructor(i,r,n){for(const[o,s]of(this.type=i,this.input=r,this.labels=[],this.outputs=[],n))this.labels.push(o),this.outputs.push(s)}static parse(i,r){if(i.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${i.length-1}.`);if((i.length-1)%2!=0)return r.error("Expected an even number of arguments.");const n=r.parse(i[1],1,t$);if(!n)return null;const o=[];let s=null;r.expectedType&&"value"!==r.expectedType.kind&&(s=r.expectedType);for(let a=1;a=l)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',u);const d=r.parse(c,h,s);if(!d)return null;s=s||d.type,o.push([l,d])}return new ix(s,n,o)}evaluate(i){const r=this.labels,n=this.outputs;if(1===r.length)return n[0].evaluate(i);const o=this.input.evaluate(i);if(o<=r[0])return n[0].evaluate(i);const s=r.length;return o>=r[s-1]?n[s-1].evaluate(i):n[iy(r,o)].evaluate(i)}eachChild(i){for(const r of(i(this.input),this.outputs))i(r)}outputDefined(){return this.outputs.every(i=>i.outputDefined())}serialize(){const i=["step",this.input.serialize()];for(let r=0;r0&&i.push(this.labels[r]),i.push(this.outputs[r].serialize());return i}}function i$(i,r,n){return i*(1-n)+r*n}var iv=Object.freeze({__proto__:null,number:i$,color:function(i,r,n){return new t1(i$(i.r,r.r,n),i$(i.g,r.g,n),i$(i.b,r.b,n),i$(i.a,r.a,n))},array:function(i,r,n){return i.map((i,o)=>i$(i,r[o],n))}});const i_=4/29,ib=6/29,iw=3*ib*ib,i0=Math.PI/180,iT=180/Math.PI;function iE(i){return i>.008856451679035631?Math.pow(i,1/3):i/iw+i_}function iS(i){return i>ib?i*i*i:iw*(i-i_)}function iI(i){return 255*(i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055)}function iC(i){return(i/=255)<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function iz(i){const r=iC(i.r),n=iC(i.g),o=iC(i.b),s=iE((.4124564*r+.3575761*n+.1804375*o)/.95047),a=iE((.2126729*r+.7151522*n+.072175*o)/1);return{l:116*a-16,a:500*(s-a),b:200*(a-iE((.0193339*r+.119192*n+.9503041*o)/1.08883)),alpha:i.a}}function iA(i){let r=(i.l+16)/116,n=isNaN(i.a)?r:r+i.a/500,o=isNaN(i.b)?r:r-i.b/200;return r=1*iS(r),n=.95047*iS(n),o=1.08883*iS(o),new t1(iI(3.2404542*n-1.5371385*r-.4985314*o),iI(-.969266*n+1.8760108*r+.041556*o),iI(.0556434*n-.2040259*r+1.0572252*o),i.alpha)}const ik={forward:iz,reverse:iA,interpolate:function(i,r,n){return{l:i$(i.l,r.l,n),a:i$(i.a,r.a,n),b:i$(i.b,r.b,n),alpha:i$(i.alpha,r.alpha,n)}}},iP={forward:function(i){const{l:r,a:n,b:o}=iz(i),s=Math.atan2(o,n)*iT;return{h:s<0?s+360:s,c:Math.sqrt(n*n+o*o),l:r,alpha:i.a}},reverse:function(i){const r=i.h*i0,n=i.c;return iA({l:i.l,a:Math.cos(r)*n,b:Math.sin(r)*n,alpha:i.alpha})},interpolate:function(i,r,n){return{h:function(i,r,n){const o=r-i;return i+n*(o>180||o<-180?o-360*Math.round(o/360):o)}(i.h,r.h,n),c:i$(i.c,r.c,n),l:i$(i.l,r.l,n),alpha:i$(i.alpha,r.alpha,n)}}};var iD=Object.freeze({__proto__:null,lab:ik,hcl:iP});class iL{constructor(i,r,n,o,s){for(const[a,l]of(this.type=i,this.operator=r,this.interpolation=n,this.input=o,this.labels=[],this.outputs=[],s))this.labels.push(a),this.outputs.push(l)}static interpolationFactor(i,r,n,o){let a=0;if("exponential"===i.name)a=i1(r,i.base,n,o);else if("linear"===i.name)a=i1(r,1,n,o);else if("cubic-bezier"===i.name){const l=i.controlPoints;a=new s(l[0],l[1],l[2],l[3]).solve(i1(r,1,n,o))}return a}static parse(i,r){let[n,o,s,...a]=i;if(!Array.isArray(o)||0===o.length)return r.error("Expected an interpolation type expression.",1);if("linear"===o[0])o={name:"linear"};else if("exponential"===o[0]){const l=o[1];if("number"!=typeof l)return r.error("Exponential interpolation requires a numeric base.",1,1);o={name:"exponential",base:l}}else{if("cubic-bezier"!==o[0])return r.error(`Unknown interpolation type ${String(o[0])}`,1,0);{const c=o.slice(1);if(4!==c.length||c.some(i=>"number"!=typeof i||i<0||i>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);o={name:"cubic-bezier",controlPoints:c}}}if(i.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${i.length-1}.`);if((i.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(!(s=r.parse(s,2,t$)))return null;const u=[];let h=null;"interpolate-hcl"===n||"interpolate-lab"===n?h=tb:r.expectedType&&"value"!==r.expectedType.kind&&(h=r.expectedType);for(let d=0;d=p)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',m);const y=r.parse(f,g,h);if(!y)return null;h=h||y.type,u.push([p,y])}return"number"===h.kind||"color"===h.kind||"array"===h.kind&&"number"===h.itemType.kind&&"number"==typeof h.N?new iL(h,n,o,s,u):r.error(`Type ${tC(h)} is not interpolatable.`)}evaluate(i){const r=this.labels,n=this.outputs;if(1===r.length)return n[0].evaluate(i);const o=this.input.evaluate(i);if(o<=r[0])return n[0].evaluate(i);const s=r.length;if(o>=r[s-1])return n[s-1].evaluate(i);const a=iy(r,o),l=iL.interpolationFactor(this.interpolation,o,r[a],r[a+1]),c=n[a].evaluate(i),u=n[a+1].evaluate(i);return"interpolate"===this.operator?iv[this.type.kind.toLowerCase()](c,u,l):"interpolate-hcl"===this.operator?iP.reverse(iP.interpolate(iP.forward(c),iP.forward(u),l)):ik.reverse(ik.interpolate(ik.forward(c),ik.forward(u),l))}eachChild(i){for(const r of(i(this.input),this.outputs))i(r)}outputDefined(){return this.outputs.every(i=>i.outputDefined())}serialize(){let i;i="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base,]:["cubic-bezier"].concat(this.interpolation.controlPoints);const r=[this.operator,i,this.input.serialize(),];for(let n=0;ntA(o,i.type));return new iB(c?t0:n,s)}evaluate(i){let r,n=null,o=0;for(const s of this.args){if(o++,(n=s.evaluate(i))&&n instanceof tM&&!n.available&&(r||(r=n),n=null,o===this.args.length))return r;if(null!==n)break}return n}eachChild(i){this.args.forEach(i)}outputDefined(){return this.args.every(i=>i.outputDefined())}serialize(){const i=["coalesce"];return this.eachChild(r=>{i.push(r.serialize())}),i}}class iR{constructor(i,r){this.type=r.type,this.bindings=[].concat(i),this.result=r}evaluate(i){return this.result.evaluate(i)}eachChild(i){for(const r of this.bindings)i(r[1]);i(this.result)}static parse(i,r){if(i.length<4)return r.error(`Expected at least 3 arguments, but found ${i.length-1} instead.`);const n=[];for(let o=1;o=n.length)throw new tV(`Array index out of bounds: ${r} > ${n.length-1}.`);if(r!==Math.floor(r))throw new tV(`Array index must be an integer, but found ${r} instead.`);return n[r]}eachChild(i){i(this.index),i(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize(),]}}class iM{constructor(i,r){this.type=t_,this.needle=i,this.haystack=r}static parse(i,r){if(3!==i.length)return r.error(`Expected 2 arguments, but found ${i.length-1} instead.`);const n=r.parse(i[1],1,t0),o=r.parse(i[2],2,t0);return n&&o?tk(n.type,[t_,tv,t$,tx,t0])?new iM(n,o):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${tC(n.type)} instead`):null}evaluate(i){const r=this.needle.evaluate(i),n=this.haystack.evaluate(i);if(!n)return!1;if(!tP(r,["boolean","string","number","null",]))throw new tV(`Expected first argument to be of type boolean, string, number or null, but found ${tC(tO(r))} instead.`);if(!tP(n,["string","array"]))throw new tV(`Expected second argument to be of type array or string, but found ${tC(tO(n))} instead.`);return n.indexOf(r)>=0}eachChild(i){i(this.needle),i(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize(),]}}class i2{constructor(i,r,n){this.type=t$,this.needle=i,this.haystack=r,this.fromIndex=n}static parse(i,r){if(i.length<=2||i.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${i.length-1} instead.`);const n=r.parse(i[1],1,t0),o=r.parse(i[2],2,t0);if(!n||!o)return null;if(!tk(n.type,[t_,tv,t$,tx,t0]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${tC(n.type)} instead`);if(4===i.length){const s=r.parse(i[3],3,t$);return s?new i2(n,o,s):null}return new i2(n,o)}evaluate(i){const r=this.needle.evaluate(i),n=this.haystack.evaluate(i);if(!tP(r,["boolean","string","number","null",]))throw new tV(`Expected first argument to be of type boolean, string, number or null, but found ${tC(tO(r))} instead.`);if(!tP(n,["string","array"]))throw new tV(`Expected second argument to be of type array or string, but found ${tC(tO(n))} instead.`);if(this.fromIndex){const o=this.fromIndex.evaluate(i);return n.indexOf(r,o)}return n.indexOf(r)}eachChild(i){i(this.needle),i(this.haystack),this.fromIndex&&i(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const i=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),i,]}return["index-of",this.needle.serialize(),this.haystack.serialize(),]}}class iF{constructor(i,r,n,o,s,a){this.inputType=i,this.type=r,this.input=n,this.cases=o,this.outputs=s,this.otherwise=a}static parse(i,r){if(i.length<5)return r.error(`Expected at least 4 arguments, but found only ${i.length-1}.`);if(i.length%2!=1)return r.error("Expected an even number of arguments.");let n,o;r.expectedType&&"value"!==r.expectedType.kind&&(o=r.expectedType);const s={},a=[];for(let l=2;lNumber.MAX_SAFE_INTEGER)return h.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof d&&Math.floor(d)!==d)return h.error("Numeric branch labels must be integer values.");if(n){if(h.checkSubtype(n,tO(d)))return null}else n=tO(d);if(void 0!==s[String(d)])return h.error("Branch labels must be unique.");s[String(d)]=a.length}const p=r.parse(u,l,o);if(!p)return null;o=o||p.type,a.push(p)}const f=r.parse(i[1],1,t0);if(!f)return null;const m=r.parse(i[i.length-1],i.length-1,o);return m?"value"!==f.type.kind&&r.concat(1).checkSubtype(n,f.type)?null:new iF(n,o,f,s,a,m):null}evaluate(i){const r=this.input.evaluate(i);return(tO(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(i)}eachChild(i){i(this.input),this.outputs.forEach(i),i(this.otherwise)}outputDefined(){return this.outputs.every(i=>i.outputDefined())&&this.otherwise.outputDefined()}serialize(){const i=["match",this.input.serialize()],r=Object.keys(this.cases).sort(),n=[],o={};for(const s of r){const a=o[this.cases[s]];void 0===a?(o[this.cases[s]]=n.length,n.push([this.cases[s],[s]])):n[a][1].push(s)}const l=i=>"number"===this.inputType.kind?Number(i):i;for(const[c,u]of n)i.push(1===u.length?l(u[0]):u.map(l)),i.push(this.outputs[c].serialize());return i.push(this.otherwise.serialize()),i}}class iO{constructor(i,r,n){this.type=i,this.branches=r,this.otherwise=n}static parse(i,r){if(i.length<4)return r.error(`Expected at least 3 arguments, but found only ${i.length-1}.`);if(i.length%2!=0)return r.error("Expected an odd number of arguments.");let n;r.expectedType&&"value"!==r.expectedType.kind&&(n=r.expectedType);const o=[];for(let s=1;sr.outputDefined())&&this.otherwise.outputDefined()}serialize(){const i=["case"];return this.eachChild(r=>{i.push(r.serialize())}),i}}class i4{constructor(i,r,n,o){this.type=i,this.input=r,this.beginIndex=n,this.endIndex=o}static parse(i,r){if(i.length<=2||i.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${i.length-1} instead.`);const n=r.parse(i[1],1,t0),o=r.parse(i[2],2,t$);if(!n||!o)return null;if(!tk(n.type,[tI(t0),tv,t0]))return r.error(`Expected first argument to be of type array or string, but found ${tC(n.type)} instead`);if(4===i.length){const s=r.parse(i[3],3,t$);return s?new i4(n.type,n,o,s):null}return new i4(n.type,n,o)}evaluate(i){const r=this.input.evaluate(i),n=this.beginIndex.evaluate(i);if(!tP(r,["string","array"]))throw new tV(`Expected first argument to be of type array or string, but found ${tC(tO(r))} instead.`);if(this.endIndex){const o=this.endIndex.evaluate(i);return r.slice(n,o)}return r.slice(n)}eachChild(i){i(this.input),i(this.beginIndex),this.endIndex&&i(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const i=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),i,]}return["slice",this.input.serialize(),this.beginIndex.serialize(),]}}function iU(i,r){return"=="===i||"!="===i?"boolean"===r.kind||"string"===r.kind||"number"===r.kind||"null"===r.kind||"value"===r.kind:"string"===r.kind||"number"===r.kind||"value"===r.kind}function iV(i,r,n,o){return 0===o.compare(r,n)}function i6(i,r,n){const o="=="!==i&&"!="!==i;return class s{constructor(i,r,n){this.type=t_,this.lhs=i,this.rhs=r,this.collator=n,this.hasUntypedArgument="value"===i.type.kind||"value"===r.type.kind}static parse(i,r){if(3!==i.length&&4!==i.length)return r.error("Expected two or three arguments.");const n=i[0];let a=r.parse(i[1],1,t0);if(!a)return null;if(!iU(n,a.type))return r.concat(1).error(`"${n}" comparisons are not supported for type '${tC(a.type)}'.`);let l=r.parse(i[2],2,t0);if(!l)return null;if(!iU(n,l.type))return r.concat(2).error(`"${n}" comparisons are not supported for type '${tC(l.type)}'.`);if(a.type.kind!==l.type.kind&&"value"!==a.type.kind&&"value"!==l.type.kind)return r.error(`Cannot compare types '${tC(a.type)}' and '${tC(l.type)}'.`);o&&("value"===a.type.kind&&"value"!==l.type.kind?a=new tj(l.type,[a]):"value"!==a.type.kind&&"value"===l.type.kind&&(l=new tj(a.type,[l])));let c=null;if(4===i.length){if("string"!==a.type.kind&&"string"!==l.type.kind&&"value"!==a.type.kind&&"value"!==l.type.kind)return r.error("Cannot use collator to compare non-string types.");if(!(c=r.parse(i[3],3,tT)))return null}return new s(a,l,c)}evaluate(s){const a=this.lhs.evaluate(s),l=this.rhs.evaluate(s);if(o&&this.hasUntypedArgument){const c=tO(a),u=tO(l);if(c.kind!==u.kind||"string"!==c.kind&&"number"!==c.kind)throw new tV(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${c.kind}, ${u.kind}) instead.`)}if(this.collator&&!o&&this.hasUntypedArgument){const h=tO(a),d=tO(l);if("string"!==h.kind||"string"!==d.kind)return r(s,a,l)}return this.collator?n(s,a,l,this.collator.evaluate(s)):r(s,a,l)}eachChild(i){i(this.lhs),i(this.rhs),this.collator&&i(this.collator)}outputDefined(){return!0}serialize(){const r=[i];return this.eachChild(i=>{r.push(i.serialize())}),r}}}const ij=i6("==",function(i,r,n){return r===n},iV),iN=i6("!=",function(i,r,n){return r!==n},function(i,r,n,o){return!iV(0,r,n,o)}),iG=i6("<",function(i,r,n){return ro.compare(r,n)}),iZ=i6(">",function(i,r,n){return r>n},function(i,r,n,o){return o.compare(r,n)>0}),i9=i6("<=",function(i,r,n){return r<=n},function(i,r,n,o){return 0>=o.compare(r,n)}),i7=i6(">=",function(i,r,n){return r>=n},function(i,r,n,o){return o.compare(r,n)>=0});class iq{constructor(i,r,n,o,s){this.type=tv,this.number=i,this.locale=r,this.currency=n,this.minFractionDigits=o,this.maxFractionDigits=s}static parse(i,r){if(3!==i.length)return r.error("Expected two arguments.");const n=r.parse(i[1],1,t$);if(!n)return null;const o=i[2];if("object"!=typeof o||Array.isArray(o))return r.error("NumberFormat options argument must be an object.");let s=null;if(o.locale&&!(s=r.parse(o.locale,1,tv)))return null;let a=null;if(o.currency&&!(a=r.parse(o.currency,1,tv)))return null;let l=null;if(o["min-fraction-digits"]&&!(l=r.parse(o["min-fraction-digits"],1,t$)))return null;let c=null;return!o["max-fraction-digits"]||(c=r.parse(o["max-fraction-digits"],1,t$))?new iq(n,s,a,l,c):null}evaluate(i){return new Intl.NumberFormat(this.locale?this.locale.evaluate(i):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(i):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(i):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(i):void 0}).format(this.number.evaluate(i))}eachChild(i){i(this.number),this.locale&&i(this.locale),this.currency&&i(this.currency),this.minFractionDigits&&i(this.minFractionDigits),this.maxFractionDigits&&i(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const i={};return this.locale&&(i.locale=this.locale.serialize()),this.currency&&(i.currency=this.currency.serialize()),this.minFractionDigits&&(i["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(i["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),i,]}}class i5{constructor(i){this.type=t$,this.input=i}static parse(i,r){if(2!==i.length)return r.error(`Expected 1 argument, but found ${i.length-1} instead.`);const n=r.parse(i[1],1);return n?"array"!==n.type.kind&&"string"!==n.type.kind&&"value"!==n.type.kind?r.error(`Expected argument of type string or array, but found ${tC(n.type)} instead.`):new i5(n):null}evaluate(i){const r=this.input.evaluate(i);if("string"==typeof r||Array.isArray(r))return r.length;throw new tV(`Expected value to be of type string or array, but found ${tC(tO(r))} instead.`)}eachChild(i){i(this.input)}outputDefined(){return!1}serialize(){const i=["length"];return this.eachChild(r=>{i.push(r.serialize())}),i}}const iX={"==":ij,"!=":iN,">":iZ,"<":iG,">=":i7,"<=":i9,array:tj,at:i3,boolean:tj,case:iO,coalesce:iB,collator:tX,format:tN,image:tG,in:iM,"index-of":i2,interpolate:iL,"interpolate-hcl":iL,"interpolate-lab":iL,length:i5,let:iR,literal:tU,match:iF,number:tj,"number-format":iq,object:tj,slice:i4,step:ix,string:tj,"to-boolean":t9,"to-color":t9,"to-number":t9,"to-string":t9,var:im,within:iu};function iW(i,[r,n,o,s]){r=r.evaluate(i),n=n.evaluate(i),o=o.evaluate(i);const a=s?s.evaluate(i):1,l=t2(r,n,o,a);if(l)throw new tV(l);return new t1(r/255*a,n/255*a,o/255*a,a)}function iH(i,r){const n=r[i];return void 0===n?null:n}function iK(i){return{type:i}}function iY(i){return{result:"success",value:i}}function iJ(i){return{result:"error",value:i}}function iQ(i){return"data-driven"===i["property-type"]||"cross-faded-data-driven"===i["property-type"]}function re(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function rt(i){return!!i.expression&&i.expression.interpolated}function ri(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":null===i?"null":typeof i}function rr(i){return"object"==typeof i&&null!==i&&!Array.isArray(i)}function rn(i){return i}function ro(i,r,n){return void 0!==i?i:void 0!==r?r:void 0!==n?n:void 0}function rs(i,r,n,o,s){return ro(typeof n===s?o[n]:void 0,i.default,r.default)}function ra(i,r,n){if("number"!==ri(n))return ro(i.default,r.default);const o=i.stops.length;if(1===o||n<=i.stops[0][0])return i.stops[0][1];if(n>=i.stops[o-1][0])return i.stops[o-1][1];const s=iy(i.stops.map(i=>i[0]),n);return i.stops[s][1]}function rl(i,r,n){const o=void 0!==i.base?i.base:1;if("number"!==ri(n))return ro(i.default,r.default);const s=i.stops.length;if(1===s||n<=i.stops[0][0])return i.stops[0][1];if(n>=i.stops[s-1][0])return i.stops[s-1][1];const a=iy(i.stops.map(i=>i[0]),n),l=function(i,r,n,o){const s=o-n,a=i-n;return 0===s?0:1===r?a/s:(Math.pow(r,a)-1)/(Math.pow(r,s)-1)}(n,o,i.stops[a][0],i.stops[a+1][0]),c=i.stops[a][1],u=i.stops[a+1][1];let h=iv[r.type]||rn;if(i.colorSpace&&"rgb"!==i.colorSpace){const d=iD[i.colorSpace];h=(i,r)=>d.reverse(d.interpolate(d.forward(i),d.forward(r),l))}return"function"==typeof c.evaluate?{evaluate(...i){const r=c.evaluate.apply(void 0,i),n=u.evaluate.apply(void 0,i);if(void 0!==r&&void 0!==n)return h(r,n,l)}}:h(c,u,l)}function rc(i,r,n){return"color"===r.type?n=t1.parse(n):"formatted"===r.type?n=t3.fromString(n.toString()):"resolvedImage"===r.type?n=tM.fromString(n.toString()):ri(n)===r.type||"enum"===r.type&&r.values[n]||(n=void 0),ro(n,i.default,r.default)}t5.register(iX,{error:[{kind:"error"},[tv],(i,[r])=>{throw new tV(r.evaluate(i))},],typeof:[tv,[t0],(i,[r])=>tC(tO(r.evaluate(i))),],"to-rgba":[tI(t$,4),[tb],(i,[r])=>r.evaluate(i).toArray(),],rgb:[tb,[t$,t$,t$],iW],rgba:[tb,[t$,t$,t$,t$],iW],has:{type:t_,overloads:[[[tv],(i,[r])=>r.evaluate(i) in i.properties(),],[[tv,tw],(i,[r,n])=>r.evaluate(i) in n.evaluate(i),],]},get:{type:t0,overloads:[[[tv],(i,[r])=>iH(r.evaluate(i),i.properties()),],[[tv,tw],(i,[r,n])=>iH(r.evaluate(i),n.evaluate(i)),],]},"feature-state":[t0,[tv],(i,[r])=>iH(r.evaluate(i),i.featureState||{}),],properties:[tw,[],i=>i.properties()],"geometry-type":[tv,[],i=>i.geometryType()],id:[t0,[],i=>i.id()],zoom:[t$,[],i=>i.globals.zoom],pitch:[t$,[],i=>i.globals.pitch||0],"distance-from-center":[t$,[],i=>i.distanceFromCenter(),],"heatmap-density":[t$,[],i=>i.globals.heatmapDensity||0,],"line-progress":[t$,[],i=>i.globals.lineProgress||0,],"sky-radial-progress":[t$,[],i=>i.globals.skyRadialProgress||0,],accumulated:[t0,[],i=>void 0===i.globals.accumulated?null:i.globals.accumulated,],"+":[t$,iK(t$),(i,r)=>{let n=0;for(const o of r)n+=o.evaluate(i);return n},],"*":[t$,iK(t$),(i,r)=>{let n=1;for(const o of r)n*=o.evaluate(i);return n},],"-":{type:t$,overloads:[[[t$,t$],(i,[r,n])=>r.evaluate(i)-n.evaluate(i),],[[t$],(i,[r])=>-r.evaluate(i)],]},"/":[t$,[t$,t$],(i,[r,n])=>r.evaluate(i)/n.evaluate(i),],"%":[t$,[t$,t$],(i,[r,n])=>r.evaluate(i)%n.evaluate(i),],ln2:[t$,[],()=>Math.LN2],pi:[t$,[],()=>Math.PI],e:[t$,[],()=>Math.E],"^":[t$,[t$,t$],(i,[r,n])=>Math.pow(r.evaluate(i),n.evaluate(i)),],sqrt:[t$,[t$],(i,[r])=>Math.sqrt(r.evaluate(i)),],log10:[t$,[t$],(i,[r])=>Math.log(r.evaluate(i))/Math.LN10,],ln:[t$,[t$],(i,[r])=>Math.log(r.evaluate(i))],log2:[t$,[t$],(i,[r])=>Math.log(r.evaluate(i))/Math.LN2,],sin:[t$,[t$],(i,[r])=>Math.sin(r.evaluate(i)),],cos:[t$,[t$],(i,[r])=>Math.cos(r.evaluate(i)),],tan:[t$,[t$],(i,[r])=>Math.tan(r.evaluate(i)),],asin:[t$,[t$],(i,[r])=>Math.asin(r.evaluate(i)),],acos:[t$,[t$],(i,[r])=>Math.acos(r.evaluate(i)),],atan:[t$,[t$],(i,[r])=>Math.atan(r.evaluate(i)),],min:[t$,iK(t$),(i,r)=>Math.min(...r.map(r=>r.evaluate(i))),],max:[t$,iK(t$),(i,r)=>Math.max(...r.map(r=>r.evaluate(i))),],abs:[t$,[t$],(i,[r])=>Math.abs(r.evaluate(i)),],round:[t$,[t$],(i,[r])=>{const n=r.evaluate(i);return n<0?-Math.round(-n):Math.round(n)},],floor:[t$,[t$],(i,[r])=>Math.floor(r.evaluate(i)),],ceil:[t$,[t$],(i,[r])=>Math.ceil(r.evaluate(i)),],"filter-==":[t_,[tv,t0],(i,[r,n])=>i.properties()[r.value]===n.value,],"filter-id-==":[t_,[t0],(i,[r])=>i.id()===r.value,],"filter-type-==":[t_,[tv],(i,[r])=>i.geometryType()===r.value,],"filter-<":[t_,[tv,t0],(i,[r,n])=>{const o=i.properties()[r.value],s=n.value;return typeof o==typeof s&&o{const n=i.id(),o=r.value;return typeof n==typeof o&&n":[t_,[tv,t0],(i,[r,n])=>{const o=i.properties()[r.value],s=n.value;return typeof o==typeof s&&o>s},],"filter-id->":[t_,[t0],(i,[r])=>{const n=i.id(),o=r.value;return typeof n==typeof o&&n>o},],"filter-<=":[t_,[tv,t0],(i,[r,n])=>{const o=i.properties()[r.value],s=n.value;return typeof o==typeof s&&o<=s},],"filter-id-<=":[t_,[t0],(i,[r])=>{const n=i.id(),o=r.value;return typeof n==typeof o&&n<=o},],"filter->=":[t_,[tv,t0],(i,[r,n])=>{const o=i.properties()[r.value],s=n.value;return typeof o==typeof s&&o>=s},],"filter-id->=":[t_,[t0],(i,[r])=>{const n=i.id(),o=r.value;return typeof n==typeof o&&n>=o},],"filter-has":[t_,[t0],(i,[r])=>r.value in i.properties(),],"filter-has-id":[t_,[],i=>null!==i.id()&&void 0!==i.id(),],"filter-type-in":[t_,[tI(tv)],(i,[r])=>r.value.indexOf(i.geometryType())>=0,],"filter-id-in":[t_,[tI(t0)],(i,[r])=>r.value.indexOf(i.id())>=0,],"filter-in-small":[t_,[tv,tI(t0)],(i,[r,n])=>n.value.indexOf(i.properties()[r.value])>=0,],"filter-in-large":[t_,[tv,tI(t0)],(i,[r,n])=>(function(i,r,n,o){for(;n<=o;){const s=n+o>>1;if(r[s]===i)return!0;r[s]>i?o=s-1:n=s+1}return!1})(i.properties()[r.value],n.value,0,n.value.length-1),],all:{type:t_,overloads:[[[t_,t_],(i,[r,n])=>r.evaluate(i)&&n.evaluate(i),],[iK(t_),(i,r)=>{for(const n of r)if(!n.evaluate(i))return!1;return!0},],]},any:{type:t_,overloads:[[[t_,t_],(i,[r,n])=>r.evaluate(i)||n.evaluate(i),],[iK(t_),(i,r)=>{for(const n of r)if(n.evaluate(i))return!0;return!1},],]},"!":[t_,[t_],(i,[r])=>!r.evaluate(i)],"is-supported-script":[t_,[tv],(i,[r])=>{const n=i.globals&&i.globals.isSupportedScript;return!n||n(r.evaluate(i))},],upcase:[tv,[tv],(i,[r])=>r.evaluate(i).toUpperCase(),],downcase:[tv,[tv],(i,[r])=>r.evaluate(i).toLowerCase(),],concat:[tv,iK(t0),(i,r)=>r.map(r=>t4(r.evaluate(i))).join(""),],"resolved-locale":[tv,[tT],(i,[r])=>r.evaluate(i).resolvedLocale(),]});class ru{constructor(i,r){var n;this.expression=i,this._warningHistory={},this._evaluator=new tq,this._defaultValue=r?"color"===(n=r).type&&rr(n.default)?new t1(0,0,0,0):"color"===n.type?t1.parse(n.default)||null:void 0===n.default?null:n.default:null,this._enumValues=r&&"enum"===r.type?r.values:null}evaluateWithoutErrorHandling(i,r,n,o,s,a,l,c){return this._evaluator.globals=i,this._evaluator.feature=r,this._evaluator.featureState=n,this._evaluator.canonical=o,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=a,this._evaluator.featureTileCoord=l||null,this._evaluator.featureDistanceData=c||null,this.expression.evaluate(this._evaluator)}evaluate(i,r,n,o,s,a,l,c){this._evaluator.globals=i,this._evaluator.feature=r||null,this._evaluator.featureState=n||null,this._evaluator.canonical=o,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=a||null,this._evaluator.featureTileCoord=l||null,this._evaluator.featureDistanceData=c||null;try{const u=this.expression.evaluate(this._evaluator);if(null==u||"number"==typeof u&&u!=u)return this._defaultValue;if(this._enumValues&&!(u in this._enumValues))throw new tV(`Expected value to be one of ${Object.keys(this._enumValues).map(i=>JSON.stringify(i)).join(", ")}, but found ${JSON.stringify(u)} instead.`);return u}catch(h){return this._warningHistory[h.message]||(this._warningHistory[h.message]=!0,"undefined"!=typeof console&&console.warn(h.message)),this._defaultValue}}}function rh(i){return Array.isArray(i)&&i.length>0&&"string"==typeof i[0]&&i[0]in iX}function rd(i,r){const n=new i8(iX,[],r?function(i){const r={color:tb,string:tv,number:t$,enum:tv,boolean:t_,formatted:tE,resolvedImage:tS};return"array"===i.type?tI(r[i.value]||t0,i.length):r[i.type]}(r):void 0),o=n.parse(i,void 0,void 0,void 0,r&&"string"===r.type?{typeAnnotation:"coerce"}:void 0);return o?iY(new ru(o,r)):iJ(n.errors)}class rp{constructor(i,r){this.kind=i,this._styleExpression=r,this.isStateDependent="constant"!==i&&!id(r.expression)}evaluateWithoutErrorHandling(i,r,n,o,s,a){return this._styleExpression.evaluateWithoutErrorHandling(i,r,n,o,s,a)}evaluate(i,r,n,o,s,a){return this._styleExpression.evaluate(i,r,n,o,s,a)}}class rf{constructor(i,r,n,o){this.kind=i,this.zoomStops=n,this._styleExpression=r,this.isStateDependent="camera"!==i&&!id(r.expression),this.interpolationType=o}evaluateWithoutErrorHandling(i,r,n,o,s,a){return this._styleExpression.evaluateWithoutErrorHandling(i,r,n,o,s,a)}evaluate(i,r,n,o,s,a){return this._styleExpression.evaluate(i,r,n,o,s,a)}interpolationFactor(i,r,n){return this.interpolationType?iL.interpolationFactor(this.interpolationType,i,r,n):0}}function rm(i,r){if("error"===(i=rd(i,r)).result)return i;const n=i.value.expression,o=ih(n);if(!o&&!iQ(r))return iJ([new tg("","data expressions not supported"),]);const s=ip(n,["zoom","pitch","distance-from-center",]);if(!s&&!re(r))return iJ([new tg("","zoom expressions not supported"),]);const a=rg(n);return a||s?a instanceof tg?iJ([a]):a instanceof iL&&!rt(r)?iJ([new tg("",'"interpolate" expressions cannot be used with this property'),]):iY(a?new rf(o?"camera":"composite",i.value,a.labels,a instanceof iL?a.interpolation:void 0):new rp(o?"constant":"source",i.value)):iJ([new tg("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'),])}class r8{constructor(i,r){this._parameters=i,this._specification=r,tf(this,function i(r,n){const o="color"===n.type,s=r.stops&&"object"==typeof r.stops[0][0],a=s||!(s||void 0!==r.property),l=r.type||(rt(n)?"exponential":"interval");if(o&&((r=tf({},r)).stops&&(r.stops=r.stops.map(i=>[i[0],t1.parse(i[1]),])),r.default=t1.parse(r.default?r.default:n.default)),r.colorSpace&&"rgb"!==r.colorSpace&&!iD[r.colorSpace])throw Error(`Unknown color space: ${r.colorSpace}`);let c,u,h;if("exponential"===l)c=rl;else if("interval"===l)c=ra;else if("categorical"===l){for(const d of(c=rs,u=Object.create(null),r.stops))u[d[0]]=d[1];h=typeof r.stops[0][0]}else{if("identity"!==l)throw Error(`Unknown function type "${l}"`);c=rc}if(s){const p={},f=[];for(let m=0;mi[0]),evaluate:({zoom:i},o)=>rl({stops:x,base:r.base},n,i).evaluate(i,o)}}if(a){const _="exponential"===l?{name:"exponential",base:void 0!==r.base?r.base:1}:null;return{kind:"camera",interpolationType:_,interpolationFactor:iL.interpolationFactor.bind(void 0,_),zoomStops:r.stops.map(i=>i[0]),evaluate:({zoom:i})=>c(r,n,i,u,h)}}return{kind:"source",evaluate(i,o){const s=o&&o.properties?o.properties[r.property]:void 0;return void 0===s?ro(r.default,n.default):c(r,n,s,u,h)}}}(this._parameters,this._specification))}static deserialize(i){return new r8(i._parameters,i._specification)}static serialize(i){return{_parameters:i._parameters,_specification:i._specification}}}function rg(i){let r=null;if(i instanceof iR)r=rg(i.result);else if(i instanceof iB){for(const n of i.args)if(r=rg(n))break}else(i instanceof ix||i instanceof iL)&&i.input instanceof t5&&"zoom"===i.input.name&&(r=i);return r instanceof tg||i.eachChild(i=>{const n=rg(i);n instanceof tg?r=n:!r&&n?r=new tg("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):r&&n&&r!==n&&(r=new tg("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),r}function ry(i){const r=i.key,n=i.value,o=i.valueSpec||{},s=i.objectElementValidators||{},a=i.style,l=i.styleSpec;let c=[];const u=ri(n);if("object"!==u)return[new td(r,n,`object expected, ${u} found`),];for(const h in n){const d=h.split(".")[0],p=o[d]||o["*"];let f;if(s[d])f=s[d];else if(o[d])f=rG;else if(s["*"])f=s["*"];else{if(!o["*"]){c.push(new td(r,n[h],`unknown property "${h}"`));continue}f=rG}c=c.concat(f({key:(r?`${r}.`:r)+h,value:n[h],valueSpec:p,style:a,styleSpec:l,object:n,objectKey:h},n))}for(const m in o)s[m]||o[m].required&&void 0===o[m].default&&void 0===n[m]&&c.push(new td(r,n,`missing required property "${m}"`));return c}function rx(i){const r=i.value,n=i.valueSpec,o=i.style,s=i.styleSpec,a=i.key,l=i.arrayElementValidator||rG;if("array"!==ri(r))return[new td(a,r,`array expected, ${ri(r)} found`),];if(n.length&&r.length!==n.length)return[new td(a,r,`array length ${n.length} expected, length ${r.length} found`),];if(n["min-length"]&&r.lengthl)return[new td(r,n,`${n} is greater than the maximum value ${l}`),]}return[]}function rv(i){const r=i.valueSpec,n=tm(i.value.type);let o,s,a,l={};const c="categorical"!==n&&void 0===i.value.property,u="array"===ri(i.value.stops)&&"array"===ri(i.value.stops[0])&&"object"===ri(i.value.stops[0][0]),h=ry({key:i.key,value:i.value,valueSpec:i.styleSpec.function,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(i){if("identity"===n)return[new td(i.key,i.value,'identity function may not have a "stops" property'),];let r=[];const o=i.value;return r=r.concat(rx({key:i.key,value:o,valueSpec:i.valueSpec,style:i.style,styleSpec:i.styleSpec,arrayElementValidator:d})),"array"===ri(o)&&0===o.length&&r.push(new td(i.key,o,"array must have at least one stop")),r},default:function(i){return rG({key:i.key,value:i.value,valueSpec:r,style:i.style,styleSpec:i.styleSpec})}}});return"identity"===n&&c&&h.push(new td(i.key,i.value,'missing required property "property"')),"identity"===n||i.value.stops||h.push(new td(i.key,i.value,'missing required property "stops"')),"exponential"===n&&i.valueSpec.expression&&!rt(i.valueSpec)&&h.push(new td(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(c||iQ(i.valueSpec)?c&&!re(i.valueSpec)&&h.push(new td(i.key,i.value,"zoom functions not supported")):h.push(new td(i.key,i.value,"property functions not supported"))),("categorical"===n||u)&&void 0===i.value.property&&h.push(new td(i.key,i.value,'"property" property is required')),h;function d(i){let n=[];const o=i.value,c=i.key;if("array"!==ri(o))return[new td(c,o,`array expected, ${ri(o)} found`),];if(2!==o.length)return[new td(c,o,`array length 2 expected, length ${o.length} found`),];if(u){if("object"!==ri(o[0]))return[new td(c,o,`object expected, ${ri(o[0])} found`),];if(void 0===o[0].zoom)return[new td(c,o,"object stop key must have zoom"),];if(void 0===o[0].value)return[new td(c,o,"object stop key must have value"),];if(a&&a>tm(o[0].zoom))return[new td(c,o[0].zoom,"stop zoom values must appear in ascending order"),];tm(o[0].zoom)!==a&&(a=tm(o[0].zoom),s=void 0,l={}),n=n.concat(ry({key:`${c}[0]`,value:o[0],valueSpec:{zoom:{}},style:i.style,styleSpec:i.styleSpec,objectElementValidators:{zoom:r$,value:p}}))}else n=n.concat(p({key:`${c}[0]`,value:o[0],valueSpec:{},style:i.style,styleSpec:i.styleSpec},o));return rh(t8(o[1]))?n.concat([new td(`${c}[1]`,o[1],"expressions are not allowed in function stops."),]):n.concat(rG({key:`${c}[1]`,value:o[1],valueSpec:r,style:i.style,styleSpec:i.styleSpec}))}function p(i,a){const c=ri(i.value),u=tm(i.value),h=null!==i.value?i.value:a;if(o){if(c!==o)return[new td(i.key,h,`${c} stop domain type must match previous stop domain type ${o}`),]}else o=c;if("number"!==c&&"string"!==c&&"boolean"!==c)return[new td(i.key,h,"stop domain value must be a number, string, or boolean"),];if("number"!==c&&"categorical"!==n){let d=`number expected, ${c} found`;return iQ(r)&&void 0===n&&(d+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new td(i.key,h,d)]}return"categorical"!==n||"number"!==c||isFinite(u)&&Math.floor(u)===u?"categorical"!==n&&"number"===c&&void 0!==s&&unew td(`${i.key}${r.key}`,i.value,r.message));const n=r.value.expression||r.value._styleExpression.expression;if("property"===i.expressionContext&&"text-font"===i.propertyKey&&!n.outputDefined())return[new td(i.key,i.value,`Invalid data expression for "${i.propertyKey}". Output values must be contained as literals within the expression.`),];if("property"===i.expressionContext&&"layout"===i.propertyType&&!id(n))return[new td(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.'),];if("filter"===i.expressionContext)return rb(n,i);if(i.expressionContext&&0===i.expressionContext.indexOf("cluster")){if(!ip(n,["zoom","feature-state"]))return[new td(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.'),];if("cluster-initial"===i.expressionContext&&!ih(n))return[new td(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties."),]}return[]}function rb(i,r){const n=new Set(["zoom","feature-state","pitch","distance-from-center",]);for(const o of r.valueSpec.expression.parameters)n.delete(o);if(0===n.size)return[];const s=[];return i instanceof t5&&n.has(i.name)?[new td(r.key,r.value,`["${i.name}"] expression is not supported in a filter for a ${r.object.type} layer with id: ${r.object.id}`),]:(i.eachChild(i=>{s.push(...rb(i,r))}),s)}function rw(i){const r=i.key,n=i.value,o=i.valueSpec,s=[];return Array.isArray(o.values)?-1===o.values.indexOf(tm(n))&&s.push(new td(r,n,`expected one of [${o.values.join(", ")}], ${JSON.stringify(n)} found`)):-1===Object.keys(o.values).indexOf(tm(n))&&s.push(new td(r,n,`expected one of [${Object.keys(o.values).join(", ")}], ${JSON.stringify(n)} found`)),s}function r0(i){if(!0===i||!1===i)return!0;if(!Array.isArray(i)||0===i.length)return!1;switch(i[0]){case"has":return i.length>=2&&"$id"!==i[1]&&"$type"!==i[1];case"in":return i.length>=3&&("string"!=typeof i[1]||Array.isArray(i[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==i.length||Array.isArray(i[1])||Array.isArray(i[2]);case"any":case"all":for(const r of i.slice(1))if(!r0(r)&&"boolean"!=typeof r)return!1;return!0;default:return!0}}function rT(i,r="fill"){if(null==i)return{filter:()=>!0,needGeometry:!1,needFeature:!1};r0(i)||(i=rk(i));const n=i;let o=!0;try{o=function(i){if(!rI(i))return i;let r=t8(i);return rS(r),r=rE(r)}(n)}catch(s){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md and paste the contents of this message in the report. Thank you! Filter Expression: ${JSON.stringify(n,null,2)} `)}const a=th[`filter_${r}`],l=rd(o,a);let c=null;if("error"===l.result)throw Error(l.value.map(i=>`${i.key}: ${i.message}`).join(", "));c=(i,r,n)=>l.value.evaluate(i,r,{},n);let u=null,h=null;if(o!==n){const d=rd(n,a);if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));u=(i,r,n,o,s)=>d.value.evaluate(i,r,{},n,void 0,void 0,o,s),h=!ih(d.value.expression)}return{filter:c,dynamicFilter:u||void 0,needGeometry:rA(o),needFeature:!!h}}function rE(i){if(!Array.isArray(i))return i;const r=function(i){if(rC.has(i[0])){for(let r=1;rrE(i))}function rS(i){let r=!1;const n=[];if("case"===i[0]){for(let o=1;o",">=","<","<=","to-boolean",]);function rz(i,r){return ir?1:0}function rA(i){if(!Array.isArray(i))return!1;if("within"===i[0])return!0;for(let r=1;r"===r||"<="===r||">="===r?rP(i[1],i[2],r):"any"===r?["any"].concat(i.slice(1).map(rk)):"all"===r?["all"].concat(i.slice(1).map(rk)):"none"===r?["all"].concat(i.slice(1).map(rk).map(r1)):"in"===r?rD(i[1],i.slice(2)):"!in"===r?r1(rD(i[1],i.slice(2))):"has"===r?rL(i[1]):"!has"===r?r1(rL(i[1])):"within"!==r||i}function rP(i,r,n){switch(i){case"$type":return[`filter-type-${n}`,r];case"$id":return[`filter-id-${n}`,r];default:return[`filter-${n}`,i,r]}}function rD(i,r){if(0===r.length)return!1;switch(i){case"$type":return["filter-type-in",["literal",r]];case"$id":return["filter-id-in",["literal",r]];default:return r.length>200&&!r.some(i=>typeof i!=typeof r[0])?["filter-in-large",i,["literal",r.sort(rz)],]:["filter-in-small",i,["literal",r],]}}function rL(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function r1(i){return["!",i]}function rB(i){if(r0(t8(i.value))){const r=t8(i.layerType);return r_(tf({},i,{expressionContext:"filter",valueSpec:i.styleSpec[`filter_${r||"fill"}`]}))}return rR(i)}function rR(i){const r=i.value,n=i.key;if("array"!==ri(r))return[new td(n,r,`array expected, ${ri(r)} found`),];const o=i.styleSpec;let s,a=[];if(r.length<1)return[new td(n,r,"filter array must have at least 1 element"),];switch(a=a.concat(rw({key:`${n}[0]`,value:r[0],valueSpec:o.filter_operator,style:i.style,styleSpec:i.styleSpec})),tm(r[0])){case"<":case"<=":case">":case">=":r.length>=2&&"$type"===tm(r[1])&&a.push(new td(n,r,`"$type" cannot be use with operator "${r[0]}"`));case"==":case"!=":3!==r.length&&a.push(new td(n,r,`filter array for operator "${r[0]}" must have 3 elements`));case"in":case"!in":r.length>=2&&"string"!==(s=ri(r[1]))&&a.push(new td(`${n}[1]`,r[1],`string expected, ${s} found`));for(let l=2;l{i in n&&r.push(new td(o,n[i],`"${i}" is prohibited for ref layers`))}),s.layers.forEach(i=>{tm(i.id)===c&&(p=i)}),p?p.ref?r.push(new td(o,n.ref,"ref cannot reference another ref layer")):l=tm(p.type):r.push(new td(o,n.ref,`ref layer "${c}" not found`))}else if("background"!==l&&"sky"!==l){if(n.source){const f=s.sources&&s.sources[n.source],m=f&&tm(f.type);f?"vector"===m&&"raster"===l?r.push(new td(o,n.source,`layer "${n.id}" requires a raster source`)):"raster"===m&&"raster"!==l?r.push(new td(o,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==m||n["source-layer"]?"raster-dem"===m&&"hillshade"!==l?r.push(new td(o,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===l&&n.paint&&n.paint["line-gradient"]&&("geojson"!==m||!f.lineMetrics)&&r.push(new td(o,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new td(o,n,`layer "${n.id}" must specify a "source-layer"`)):r.push(new td(o,n.source,`source "${n.source}" not found`))}else r.push(new td(o,n,'missing required property "source"'))}return r=r.concat(ry({key:o,value:n,valueSpec:a.layer,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":()=>[],type:()=>rG({key:`${o}.type`,value:n.type,valueSpec:a.layer.type,style:i.style,styleSpec:i.styleSpec,object:n,objectKey:"type"}),filter:i=>rB(tf({layerType:l},i)),layout:i=>ry({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>r2(tf({layerType:l},i))}}),paint:i=>ry({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rM(tf({layerType:l},i))}})}}))}function rO(i){const r=i.value,n=i.key,o=ri(r);return"string"!==o?[new td(n,r,`string expected, ${o} found`)]:[]}const r4={promoteId:function({key:i,value:r}){if("string"===ri(r))return rO({key:i,value:r});{const n=[];for(const o in r)n.push(...rO({key:`${i}.${o}`,value:r[o]}));return n}}};function rU(i){const r=i.value,n=i.key,o=i.styleSpec,s=i.style;if(!r.type)return[new td(n,r,'"type" is required')];const a=tm(r.type);let l;switch(a){case"vector":case"raster":case"raster-dem":return ry({key:n,value:r,valueSpec:o[`source_${a.replace("-","_")}`],style:i.style,styleSpec:o,objectElementValidators:r4});case"geojson":if(l=ry({key:n,value:r,valueSpec:o.source_geojson,style:s,styleSpec:o,objectElementValidators:r4}),r.cluster)for(const c in r.clusterProperties){const[u,h]=r.clusterProperties[c],d="string"==typeof u?[u,["accumulated"],["get",c],]:u;l.push(...r_({key:`${n}.${c}.map`,value:h,expressionContext:"cluster-map"})),l.push(...r_({key:`${n}.${c}.reduce`,value:d,expressionContext:"cluster-reduce"}))}return l;case"video":return ry({key:n,value:r,valueSpec:o.source_video,style:s,styleSpec:o});case"image":return ry({key:n,value:r,valueSpec:o.source_image,style:s,styleSpec:o});case"canvas":return[new td(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas"),];default:return rw({key:`${n}.type`,value:r.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image",]},style:s,styleSpec:o})}}function rV(i){const r=i.value,n=i.styleSpec,o=n.light,s=i.style;let a=[];const l=ri(r);if(void 0===r)return a;if("object"!==l)return a.concat([new td("light",r,`object expected, ${l} found`),]);for(const c in r){const u=c.match(/^(.*)-transition$/);a=a.concat(u&&o[u[1]]&&o[u[1]].transition?rG({key:c,value:r[c],valueSpec:n.transition,style:s,styleSpec:n}):o[c]?rG({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}):[new td(c,r[c],`unknown property "${c}"`),])}return a}function r6(i){const r=i.value,n=i.key,o=i.style,s=i.styleSpec,a=s.terrain;let l=[];const c=ri(r);if(void 0===r)return l;if("object"!==c)return l.concat([new td("terrain",r,`object expected, ${c} found`),]);for(const u in r){const h=u.match(/^(.*)-transition$/);l=l.concat(h&&a[h[1]]&&a[h[1]].transition?rG({key:u,value:r[u],valueSpec:s.transition,style:o,styleSpec:s}):a[u]?rG({key:u,value:r[u],valueSpec:a[u],style:o,styleSpec:s}):[new td(u,r[u],`unknown property "${u}"`),])}if(r.source){const d=o.sources&&o.sources[r.source],p=d&&tm(d.type);d?"raster-dem"!==p&&l.push(new td(n,r.source,`terrain cannot be used with a source of type ${p}, it only be used with a "raster-dem" source type`)):l.push(new td(n,r.source,`source "${r.source}" not found`))}else l.push(new td(n,r,'terrain is missing required property "source"'));return l}function rj(i){const r=i.value,n=i.style,o=i.styleSpec,s=o.fog;let a=[];const l=ri(r);if(void 0===r)return a;if("object"!==l)return a.concat([new td("fog",r,`object expected, ${l} found`),]);for(const c in r){const u=c.match(/^(.*)-transition$/);a=a.concat(u&&s[u[1]]&&s[u[1]].transition?rG({key:c,value:r[c],valueSpec:o.transition,style:n,styleSpec:o}):s[c]?rG({key:c,value:r[c],valueSpec:s[c],style:n,styleSpec:o}):[new td(c,r[c],`unknown property "${c}"`),])}return a}const rN={"*":()=>[],array:rx,boolean:function(i){const r=i.value,n=i.key,o=ri(r);return"boolean"!==o?[new td(n,r,`boolean expected, ${o} found`),]:[]},number:r$,color:function(i){const r=i.key,n=i.value,o=ri(n);return"string"!==o?[new td(r,n,`color expected, ${o} found`),]:null===tL.parseCSSColor(n)?[new td(r,n,`color expected, "${n}" found`),]:[]},constants:tp,enum:rw,filter:rB,function:rv,layer:rF,object:ry,source:rU,light:rV,terrain:r6,fog:rj,string:rO,formatted:function(i){return 0===rO(i).length?[]:r_(i)},resolvedImage:function(i){return 0===rO(i).length?[]:r_(i)},projection:function(i){const r=i.value,n=i.styleSpec,o=n.projection,s=i.style;let a=[];const l=ri(r);if("object"===l)for(const c in r)a=a.concat(rG({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}));else"string"!==l&&(a=a.concat([new td("projection",r,`object or string expected, ${l} found`),]));return a}};function rG(i){const r=i.value,n=i.valueSpec,o=i.styleSpec;return n.expression&&rr(tm(r))?rv(i):n.expression&&rh(t8(r))?r_(i):n.type&&rN[n.type]?rN[n.type](i):ry(tf({},i,{valueSpec:n.type?o[n.type]:n}))}function rZ(i){const r=i.value,n=i.key,o=rO(i);return o.length||(-1===r.indexOf("{fontstack}")&&o.push(new td(n,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&o.push(new td(n,r,'"glyphs" url must include a "{range}" token'))),o}function r9(i,r=th){let n=[];return n=n.concat(rG({key:"",value:i,valueSpec:r.$root,styleSpec:r,style:i,objectElementValidators:{glyphs:rZ,"*":()=>[]}})),i.constants&&(n=n.concat(tp({key:"constants",value:i.constants,style:i,styleSpec:r}))),r7(n)}function r7(i){return[].concat(i).sort((i,r)=>i.line-r.line)}function rq(i){return function(...r){return r7(i.apply(this,r))}}r9.source=rq(rU),r9.light=rq(rV),r9.terrain=rq(r6),r9.fog=rq(rj),r9.layer=rq(rF),r9.filter=rq(rB),r9.paintProperty=rq(rM),r9.layoutProperty=rq(r2);const r5=r9,rX=r5.light,rW=r5.fog,rH=r5.paintProperty,rK=r5.layoutProperty;function rY(i,r){let n=!1;if(r&&r.length)for(const o of r)i.fire(new tc(Error(o.message))),n=!0;return n}var rJ=rQ;function rQ(i,r,n){var o=this.cells=[];if(i instanceof ArrayBuffer){this.arrayBuffer=i;var s=new Int32Array(this.arrayBuffer);i=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a=d[m+0]&&o>=d[m+1])?(l[f]=!0,a.push(h[f])):l[f]=!1}}},rQ.prototype._forEachCell=function(i,r,n,o,s,a,l,c){for(var u=this._convertToCellCoord(i),h=this._convertToCellCoord(r),d=this._convertToCellCoord(n),p=this._convertToCellCoord(o),f=u;f<=d;f++)for(var m=h;m<=p;m++){var g=this.d*m+f;if((!c||c(this._convertFromCellCoord(f),this._convertFromCellCoord(m),this._convertFromCellCoord(f+1),this._convertFromCellCoord(m+1)))&&s.call(this,i,r,n,o,g,a,l,c))return}},rQ.prototype._convertFromCellCoord=function(i){return(i-this.padding)/this.scale},rQ.prototype._convertToCellCoord=function(i){return Math.max(0,Math.min(this.d-1,Math.floor(i*this.scale)+this.padding))},rQ.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var i=this.cells,r=3+this.cells.length+1+1,n=0,o=0;o=0)continue;const h=i[u];c[u]=ni[l].shallow.indexOf(u)>=0?h:na(h,r)}i instanceof Error&&(c.message=i.message)}if(c.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==l&&(c.$name=l),c}throw Error("can't serialize object of type "+typeof i)}function nl(i){if(null==i||"boolean"==typeof i||"number"==typeof i||"string"==typeof i||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||no(i)||ns(i)||ArrayBuffer.isView(i)||i instanceof ne)return i;if(Array.isArray(i))return i.map(nl);if("object"==typeof i){const r=i.$name||"Object",{klass:n}=ni[r];if(!n)throw Error(`can't deserialize unregistered class ${r}`);if(n.deserialize)return n.deserialize(i);const o=Object.create(n.prototype);for(const s of Object.keys(i)){if("$name"===s)continue;const a=i[s];o[s]=ni[r].shallow.indexOf(s)>=0?a:nl(a)}return o}throw Error("can't deserialize object of type "+typeof i)}class nc{constructor(){this.first=!0}update(i,r){const n=Math.floor(i);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=i,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=1536&&i<=1791,nh=i=>i>=1872&&i<=1919,nd=i=>i>=2208&&i<=2303,np=i=>i>=11904&&i<=12031,nf=i=>i>=12032&&i<=12255,nm=i=>i>=12272&&i<=12287,n8=i=>i>=12288&&i<=12351,ng=i=>i>=12352&&i<=12447,ny=i=>i>=12448&&i<=12543,nx=i=>i>=12544&&i<=12591,n$=i=>i>=12704&&i<=12735,nv=i=>i>=12736&&i<=12783,n_=i=>i>=12784&&i<=12799,nb=i=>i>=12800&&i<=13055,nw=i=>i>=13056&&i<=13311,n0=i=>i>=13312&&i<=19903,nT=i=>i>=19968&&i<=40959,nE=i=>i>=40960&&i<=42127,nS=i=>i>=42128&&i<=42191,nI=i=>i>=44032&&i<=55215,nC=i=>i>=63744&&i<=64255,nz=i=>i>=64336&&i<=65023,nA=i=>i>=65040&&i<=65055,nk=i=>i>=65072&&i<=65103,nP=i=>i>=65104&&i<=65135,nD=i=>i>=65136&&i<=65279,nL=i=>i>=65280&&i<=65519;function n1(i){for(const r of i)if(n3(r.charCodeAt(0)))return!0;return!1}function nB(i){for(const r of i)if(!nR(r.charCodeAt(0)))return!1;return!0}function nR(i){return!(nu(i)||nh(i)||nd(i)||nz(i)||nD(i))}function n3(i){var r,n,o,s,a,l,c,u;return!(746!==i&&747!==i&&(i<4352||!(n$(i)||nx(i)||nk(i)&&!(i>=65097&&i<=65103)||nC(i)||nw(i)||np(i)||nv(i)||!(!n8(i)||i>=12296&&i<=12305||i>=12308&&i<=12319||12336===i)||n0(i)||nT(i)||nb(i)||(r=i)>=12592&&r<=12687||(n=i)>=43360&&n<=43391||(o=i)>=55216&&o<=55295||(s=i)>=4352&&s<=4607||nI(i)||ng(i)||nm(i)||(a=i)>=12688&&a<=12703||nf(i)||n_(i)||ny(i)&&12540!==i||!(!nL(i)||65288===i||65289===i||65293===i||i>=65306&&i<=65310||65339===i||65341===i||65343===i||i>=65371&&i<=65503||65507===i||i>=65512&&i<=65519)||!(!nP(i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||(l=i)>=5120&&l<=5759||(c=i)>=6320&&c<=6399||nA(i)||(u=i)>=19904&&u<=19967||nE(i)||nS(i))))}function nM(i){var r,n,o,s,a,l,c,u,h,d,p,f,m;return!(n3(i)||(n=r=i)>=128&&n<=255&&(167===r||169===r||174===r||177===r||188===r||189===r||190===r||215===r||247===r)||(o=r)>=8192&&o<=8303&&(8214===r||8224===r||8225===r||8240===r||8241===r||8251===r||8252===r||8258===r||8263===r||8264===r||8265===r||8273===r)||(s=r)>=8448&&s<=8527||(a=r)>=8528&&a<=8591||(l=r)>=8960&&l<=9215&&(r>=8960&&r<=8967||r>=8972&&r<=8991||r>=8996&&r<=9e3||9003===r||r>=9085&&r<=9114||r>=9150&&r<=9165||9167===r||r>=9169&&r<=9179||r>=9186&&r<=9215)||(c=r)>=9216&&c<=9279&&9251!==r||(u=r)>=9280&&u<=9311||(h=r)>=9312&&h<=9471||(d=r)>=9632&&d<=9727||(p=r)>=9728&&p<=9983&&!(r>=9754&&r<=9759)||(f=r)>=11008&&f<=11263&&(r>=11026&&r<=11055||r>=11088&&r<=11097||r>=11192&&r<=11243)||n8(r)||ny(r)||(m=r)>=57344&&m<=63743||nk(r)||nP(r)||nL(r)||8734===r||8756===r||8757===r||r>=9984&&r<=10087||r>=10102&&r<=10131||65532===r||65533===r)}function n2(i){return i>=1424&&i<=2303||nz(i)||nD(i)}function nF(i,r){var n;return!(!r&&n2(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||(n=i)>=6016&&n<=6143)}function nO(i){for(const r of i)if(n2(r.charCodeAt(0)))return!0;return!1}const n4="deferred",nU="loading",nV="loaded";let n6=null,nj="unavailable",nN=null;const nG=function(i){i&&"string"==typeof i&&i.indexOf("NetworkError")>-1&&(nj="error"),n6&&n6(i)};function nZ(){n9.fire(new tl("pluginStateChange",{pluginStatus:nj,pluginURL:nN}))}const n9=new tu,n7=function(){return nj},nq=function(){if(nj!==n4||!nN)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");nj=nU,nZ(),nN&&eJ({url:nN},i=>{i?nG(i):(nj=nV,nZ())})},n5={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>nj===nV||null!=n5.applyArabicShaping,isLoading:()=>nj===nU,setState(i){nj=i.pluginStatus,nN=i.pluginURL},isParsed:()=>null!=n5.applyArabicShaping&&null!=n5.processBidirectionalText&&null!=n5.processStyledBidirectionalText,getPluginURL:()=>nN};class nX{constructor(i,r){this.zoom=i,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new nc,this.transition={},this.pitch=0)}isSupportedScript(i){return function(i,r){for(const n of i)if(!nF(n.charCodeAt(0),r))return!1;return!0}(i,n5.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const i=this.zoom,r=i-Math.floor(i),n=this.crossFadingFactor();return i>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*r}}}class nW{constructor(i,r){this.property=i,this.value=r,this.expression=function(i,r){if(rr(i))return new r8(i,r);if(rh(i)){const n=rm(i,r);if("error"===n.result)throw Error(n.value.map(i=>`${i.key}: ${i.message}`).join(", "));return n.value}{let o=i;return"string"==typeof i&&"color"===r.type&&(o=t1.parse(i)),{kind:"constant",evaluate:()=>o}}}(void 0===r?i.specification.default:r,i.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(i,r,n){return this.property.possiblyEvaluate(this,i,r,n)}}class nH{constructor(i){this.property=i,this.value=new nW(i,void 0)}transitioned(i,r){return new nY(this.property,this.value,r,et({},i.transition,this.transition),i.now)}untransitioned(){return new nY(this.property,this.value,null,{},0)}}class nK{constructor(i){this._properties=i,this._values=Object.create(i.defaultTransitionablePropertyValues)}getValue(i){return eh(this._values[i].value.value)}setValue(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nH(this._values[i].property)),this._values[i].value=new nW(this._values[i].property,null===r?void 0:eh(r))}getTransition(i){return eh(this._values[i].transition)}setTransition(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nH(this._values[i].property)),this._values[i].transition=eh(r)||void 0}serialize(){const i={};for(const r of Object.keys(this._values)){const n=this.getValue(r);void 0!==n&&(i[r]=n);const o=this.getTransition(r);void 0!==o&&(i[`${r}-transition`]=o)}return i}transitioned(i,r){const n=new nJ(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].transitioned(i,r._values[o]);return n}untransitioned(){const i=new nJ(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].untransitioned();return i}}class nY{constructor(i,r,n,o,s){const a=o.delay||0,l=o.duration||0;s=s||0,this.property=i,this.value=r,this.begin=s+a,this.end=this.begin+l,i.specification.transition&&(o.delay||o.duration)&&(this.prior=n)}possiblyEvaluate(i,r,n){const o=i.now||0,s=this.value.possiblyEvaluate(i,r,n),a=this.prior;if(a){if(o>this.end||this.value.isDataDriven())return this.prior=null,s;if(oo.zoomHistory.lastIntegerZoom?{from:i,to:r,other:n}:{from:n,to:r,other:i}}interpolate(i){return i}}class on{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){if(void 0!==i.value){if("constant"===i.expression.kind){const s=i.expression.evaluate(r,null,{},n,o);return this._calculate(s,s,s,r)}return this._calculate(i.expression.evaluate(new nX(Math.floor(r.zoom-1),r)),i.expression.evaluate(new nX(Math.floor(r.zoom),r)),i.expression.evaluate(new nX(Math.floor(r.zoom+1),r)),r)}}_calculate(i,r,n,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:i,to:r}:{from:n,to:r}}interpolate(i){return i}}class oo{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){return!!i.expression.evaluate(r,null,{},n,o)}interpolate(){return!1}}class os{constructor(i){for(const r in this.properties=i,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],i){const n=i[r];n.specification.overridable&&this.overridableProperties.push(r);const o=this.defaultPropertyValues[r]=new nW(n,void 0),s=this.defaultTransitionablePropertyValues[r]=new nH(n);this.defaultTransitioningPropertyValues[r]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate({})}}}function oa(i,r){return 256*(i=K(Math.floor(i),0,255))+K(Math.floor(r),0,255)}nr("DataDrivenProperty",oi),nr("DataConstantProperty",ot),nr("CrossFadedDataDrivenProperty",or),nr("CrossFadedProperty",on),nr("ColorRampProperty",oo);const ol={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class oc{constructor(i,r){this._structArray=i,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class ou{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(i,r){return i._trim(),r&&(i.isTransferred=!0,r.push(i.arrayBuffer)),{length:i.length,arrayBuffer:i.arrayBuffer}}static deserialize(i){const r=Object.create(this.prototype);return r.arrayBuffer=i.arrayBuffer,r.length=i.length,r.capacity=i.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(i){this.reserve(i),this.length=i}reserve(i){if(i>this.capacity){this.capacity=Math.max(i,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 Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function oh(i,r=1){let n=0,o=0;return{members:i.map(i=>{const s=ol[i.type].BYTES_PER_ELEMENT,a=n=od(n,Math.max(r,s)),l=i.components||1;return o=Math.max(o,s),n+=s*l,{name:i.name,type:i.type,components:l,offset:a}}),size:od(n,Math.max(o,r)),alignment:r}}function od(i,r){return Math.ceil(i/r)*r}class op extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.int16[o+0]=r,this.int16[o+1]=n,i}}op.prototype.bytesPerElement=4,nr("StructArrayLayout2i4",op);class of extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.int16[a+0]=r,this.int16[a+1]=n,this.int16[a+2]=o,this.int16[a+3]=s,i}}of.prototype.bytesPerElement=8,nr("StructArrayLayout4i8",of);class om extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const u=6*i,h=12*i,d=3*i;return this.int16[u+0]=r,this.int16[u+1]=n,this.uint8[h+4]=o,this.uint8[h+5]=s,this.uint8[h+6]=a,this.uint8[h+7]=l,this.float32[d+2]=c,i}}om.prototype.bytesPerElement=12,nr("StructArrayLayout2i4ub1f12",om);class o8 extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.float32[s+0]=r,this.float32[s+1]=n,this.float32[s+2]=o,i}}o8.prototype.bytesPerElement=12,nr("StructArrayLayout3f12",o8);class og extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,u,h){const d=this.length;return this.resize(d+1),this.emplace(d,i,r,n,o,s,a,l,c,u,h)}emplace(i,r,n,o,s,a,l,c,u,h,d){const p=10*i;return this.uint16[p+0]=r,this.uint16[p+1]=n,this.uint16[p+2]=o,this.uint16[p+3]=s,this.uint16[p+4]=a,this.uint16[p+5]=l,this.uint16[p+6]=c,this.uint16[p+7]=u,this.uint16[p+8]=h,this.uint16[p+9]=d,i}}og.prototype.bytesPerElement=20,nr("StructArrayLayout10ui20",og);class oy extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,i,r,n,o,s,a,l,c)}emplace(i,r,n,o,s,a,l,c,u){const h=8*i;return this.uint16[h+0]=r,this.uint16[h+1]=n,this.uint16[h+2]=o,this.uint16[h+3]=s,this.uint16[h+4]=a,this.uint16[h+5]=l,this.uint16[h+6]=c,this.uint16[h+7]=u,i}}oy.prototype.bytesPerElement=16,nr("StructArrayLayout8ui16",oy);class ox extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y){const x=this.length;return this.resize(x+1),this.emplace(x,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y)}emplace(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x){const $=16*i;return this.int16[$+0]=r,this.int16[$+1]=n,this.int16[$+2]=o,this.int16[$+3]=s,this.uint16[$+4]=a,this.uint16[$+5]=l,this.uint16[$+6]=c,this.uint16[$+7]=u,this.int16[$+8]=h,this.int16[$+9]=d,this.int16[$+10]=p,this.int16[$+11]=f,this.int16[$+12]=m,this.int16[$+13]=g,this.int16[$+14]=y,this.int16[$+15]=x,i}}ox.prototype.bytesPerElement=32,nr("StructArrayLayout4i4ui4i4i32",ox);class o$ extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint32[1*i+0]=r,i}}o$.prototype.bytesPerElement=4,nr("StructArrayLayout1ul4",o$);class ov extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,u,h,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,i,r,n,o,s,a,l,c,u,h,d,p,f)}emplace(i,r,n,o,s,a,l,c,u,h,d,p,f,m){const g=20*i,y=10*i;return this.int16[g+0]=r,this.int16[g+1]=n,this.int16[g+2]=o,this.int16[g+3]=s,this.int16[g+4]=a,this.float32[y+3]=l,this.float32[y+4]=c,this.float32[y+5]=u,this.float32[y+6]=h,this.int16[g+14]=d,this.uint32[y+8]=p,this.uint16[g+18]=f,this.uint16[g+19]=m,i}}ov.prototype.bytesPerElement=40,nr("StructArrayLayout5i4f1i1ul2ui40",ov);class o_ extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const u=8*i;return this.int16[u+0]=r,this.int16[u+1]=n,this.int16[u+2]=o,this.int16[u+4]=s,this.int16[u+5]=a,this.int16[u+6]=l,this.int16[u+7]=c,i}}o_.prototype.bytesPerElement=16,nr("StructArrayLayout3i2i2i16",o_);class ob extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,i,r,n,o,s)}emplace(i,r,n,o,s,a){const l=4*i,c=8*i;return this.float32[l+0]=r,this.float32[l+1]=n,this.float32[l+2]=o,this.int16[c+6]=s,this.int16[c+7]=a,i}}ob.prototype.bytesPerElement=16,nr("StructArrayLayout2f1f2i16",ob);class ow extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=12*i,l=3*i;return this.uint8[a+0]=r,this.uint8[a+1]=n,this.float32[l+1]=o,this.float32[l+2]=s,i}}ow.prototype.bytesPerElement=12,nr("StructArrayLayout2ub2f12",ow);class o0 extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.uint16[s+0]=r,this.uint16[s+1]=n,this.uint16[s+2]=o,i}}o0.prototype.bytesPerElement=6,nr("StructArrayLayout3ui6",o0);class oT extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$,v,_,b){const w=this.length;return this.resize(w+1),this.emplace(w,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$,v,_,b)}emplace(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$,v,_,b,w){const T=30*i,E=15*i,S=60*i;return this.int16[T+0]=r,this.int16[T+1]=n,this.int16[T+2]=o,this.float32[E+2]=s,this.float32[E+3]=a,this.uint16[T+8]=l,this.uint16[T+9]=c,this.uint32[E+5]=u,this.uint32[E+6]=h,this.uint32[E+7]=d,this.uint16[T+16]=p,this.uint16[T+17]=f,this.uint16[T+18]=m,this.float32[E+10]=g,this.float32[E+11]=y,this.uint8[S+48]=x,this.uint8[S+49]=$,this.uint8[S+50]=v,this.uint32[E+13]=_,this.int16[T+28]=b,this.uint8[S+58]=w,i}}oT.prototype.bytesPerElement=60,nr("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",oT);class oE extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$,v,_,b,w,T,E,S,I,C,z,A,k){const P=this.length;return this.resize(P+1),this.emplace(P,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$,v,_,b,w,T,E,S,I,C,z,A,k)}emplace(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$,v,_,b,w,T,E,S,I,C,z,A,k,P){const D=38*i,L=19*i;return this.int16[D+0]=r,this.int16[D+1]=n,this.int16[D+2]=o,this.float32[L+2]=s,this.float32[L+3]=a,this.int16[D+8]=l,this.int16[D+9]=c,this.int16[D+10]=u,this.int16[D+11]=h,this.int16[D+12]=d,this.int16[D+13]=p,this.uint16[D+14]=f,this.uint16[D+15]=m,this.uint16[D+16]=g,this.uint16[D+17]=y,this.uint16[D+18]=x,this.uint16[D+19]=$,this.uint16[D+20]=v,this.uint16[D+21]=_,this.uint16[D+22]=b,this.uint16[D+23]=w,this.uint16[D+24]=T,this.uint16[D+25]=E,this.uint16[D+26]=S,this.uint16[D+27]=I,this.uint16[D+28]=C,this.uint32[L+15]=z,this.float32[L+16]=A,this.float32[L+17]=k,this.float32[L+18]=P,i}}oE.prototype.bytesPerElement=76,nr("StructArrayLayout3i2f6i15ui1ul3f76",oE);class oS extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.float32[1*i+0]=r,i}}oS.prototype.bytesPerElement=4,nr("StructArrayLayout1f4",oS);class oI extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.int16[s+0]=r,this.int16[s+1]=n,this.int16[s+2]=o,i}}oI.prototype.bytesPerElement=6,nr("StructArrayLayout3i6",oI);class oC extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const u=7*i;return this.float32[u+0]=r,this.float32[u+1]=n,this.float32[u+2]=o,this.float32[u+3]=s,this.float32[u+4]=a,this.float32[u+5]=l,this.float32[u+6]=c,i}}oC.prototype.bytesPerElement=28,nr("StructArrayLayout7f28",oC);class oz extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=6*i;return this.uint32[3*i+0]=r,this.uint16[a+2]=n,this.uint16[a+3]=o,this.uint16[a+4]=s,i}}oz.prototype.bytesPerElement=12,nr("StructArrayLayout1ul3ui12",oz);class oA extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.uint16[o+0]=r,this.uint16[o+1]=n,i}}oA.prototype.bytesPerElement=4,nr("StructArrayLayout2ui4",oA);class ok extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint16[1*i+0]=r,i}}ok.prototype.bytesPerElement=2,nr("StructArrayLayout1ui2",ok);class oP extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.float32[o+0]=r,this.float32[o+1]=n,i}}oP.prototype.bytesPerElement=8,nr("StructArrayLayout2f8",oP);class oD extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.float32[a+0]=r,this.float32[a+1]=n,this.float32[a+2]=o,this.float32[a+3]=s,i}}oD.prototype.bytesPerElement=16,nr("StructArrayLayout4f16",oD);class oL extends oc{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}oL.prototype.size=40;class o1 extends ov{get(i){return new oL(this,i)}}nr("CollisionBoxArray",o1);class oB extends oc{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(i){this._structArray.uint8[this._pos1+49]=i}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(i){this._structArray.uint8[this._pos1+50]=i}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(i){this._structArray.uint32[this._pos4+13]=i}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(i){this._structArray.uint8[this._pos1+58]=i}}oB.prototype.size=60;class oR extends oT{get(i){return new oB(this,i)}}nr("PlacedSymbolArray",oR);class o3 extends oc{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(i){this._structArray.uint32[this._pos4+15]=i}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}o3.prototype.size=76;class oM extends oE{get(i){return new o3(this,i)}}nr("SymbolInstanceArray",oM);class o2 extends oS{getoffsetX(i){return this.float32[1*i+0]}}nr("GlyphOffsetArray",o2);class oF extends oI{getx(i){return this.int16[3*i+0]}gety(i){return this.int16[3*i+1]}gettileUnitDistanceFromAnchor(i){return this.int16[3*i+2]}}nr("SymbolLineVertexArray",oF);class oO extends oc{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}oO.prototype.size=12;class o4 extends oz{get(i){return new oO(this,i)}}nr("FeatureIndexArray",o4);class oU extends oc{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}oU.prototype.size=4;class oV extends oA{get(i){return new oU(this,i)}}nr("FillExtrusionCentroidArray",oV);const o6=oh([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},]),oj=oh([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"},]);var oN=tD(function(i){i.exports=function(i,r){var n,o,s,a,l,c,u,h;for(o=i.length-(n=3&i.length),s=r,l=3432918353,c=461845907,h=0;h>>16)*l&65535)<<16)&4294967295)<<15|u>>>17))*c+(((u>>>16)*c&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(u=0,n){case 3:u^=(255&i.charCodeAt(h+2))<<16;case 2:u^=(255&i.charCodeAt(h+1))<<8;case 1:s^=u=(65535&(u=(u=(65535&(u^=255&i.charCodeAt(h)))*l+(((u>>>16)*l&65535)<<16)&4294967295)<<15|u>>>17))*c+(((u>>>16)*c&65535)<<16)&4294967295}return s^=i.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}),oG=tD(function(i){i.exports=function(i,r){for(var n,o=i.length,s=r^o,a=0;o>=4;)n=1540483477*(65535&(n=255&i.charCodeAt(a)|(255&i.charCodeAt(++a))<<8|(255&i.charCodeAt(++a))<<16|(255&i.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),o-=4,++a;switch(o){case 3:s^=(255&i.charCodeAt(a+2))<<16;case 2:s^=(255&i.charCodeAt(a+1))<<8;case 1:s=1540483477*(65535&(s^=255&i.charCodeAt(a)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}),oZ=oN;oZ.murmur3=oN,oZ.murmur2=oG;class o9{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(i,r,n,o){this.ids.push(o7(i)),this.positions.push(r,n,o)}getPositions(i){const r=o7(i);let n=0,o=this.ids.length-1;for(;n>1;this.ids[s]>=r?o=s:n=s+1}const a=[];for(;this.ids[n]===r;)a.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return a}static serialize(i,r){const n=new Float64Array(i.ids),o=new Uint32Array(i.positions);return oq(n,o,0,n.length-1),r&&r.push(n.buffer,o.buffer),{ids:n,positions:o}}static deserialize(i){const r=new o9;return r.ids=i.ids,r.positions=i.positions,r.indexed=!0,r}}function o7(i){const r=+i;return!isNaN(r)&&Number.MIN_SAFE_INTEGER<=r&&r<=Number.MAX_SAFE_INTEGER?r:oZ(String(i))}function oq(i,r,n,o){for(;n>1];let a=n-1,l=o+1;for(;;){do a++;while(i[a]s)if(a>=l)break;o5(i,a,l),o5(r,3*a,3*l),o5(r,3*a+1,3*l+1),o5(r,3*a+2,3*l+2)}l-n`u_${i}`),this.type=n}setUniform(i,r,n){i.set(n.constantOr(this.value))}getBinding(i,r,n){return"color"===this.type?new oK(i,r):new oW(i,r)}}class si{constructor(i,r){this.uniformNames=r.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(i,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=i.pixelRatio,this.patternFrom=r.tl.concat(r.br),this.patternTo=i.tl.concat(i.br)}setUniform(i,r,n,o){const s="u_pattern_to"===o||"u_dash_to"===o?this.patternTo:"u_pattern_from"===o||"u_dash_from"===o?this.patternFrom:"u_pixel_ratio_to"===o?this.pixelRatioTo:"u_pixel_ratio_from"===o?this.pixelRatioFrom:null;s&&i.set(s)}getBinding(i,r,n){return"u_pattern_from"===n||"u_pattern_to"===n||"u_dash_from"===n||"u_dash_to"===n?new oH(i,r):new oW(i,r)}}class sr{constructor(i,r,n,o){this.expression=i,this.type=n,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(i,r,n,o,s,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new nX(0),r,{},s,o,a);this.paintVertexArray.resize(i),this._setPaintValue(l,i,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:0},n,o,void 0,s);this._setPaintValue(i,r,a)}_setPaintValue(i,r,n){if("color"===this.type){const o=se(n);for(let s=i;s`u_${i}_t`),this.type=n,this.useIntegerZoom=o,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(i,r,n,o,s,a){const l=this.expression.evaluate(new nX(this.zoom),r,{},s,o,a),c=this.expression.evaluate(new nX(this.zoom+1),r,{},s,o,a),u=this.paintVertexArray.length;this.paintVertexArray.resize(i),this._setPaintValue(u,i,l,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom},n,o,void 0,s),l=this.expression.evaluate({zoom:this.zoom+1},n,o,void 0,s);this._setPaintValue(i,r,a,l)}_setPaintValue(i,r,n,o){if("color"===this.type){const s=se(n),a=se(o);for(let l=i;l!0){this.binders={},this._buffers=[];const o=[];for(const s in i.paint._values){if(!n(s))continue;const a=i.paint.get(s);if(!(a instanceof nQ&&iQ(a.property.specification)))continue;const l=sc(s,i.type),c=a.value,u=a.property.specification.type,h=a.property.useIntegerZoom,d=a.property.specification["property-type"],p="cross-faded"===d||"cross-faded-data-driven"===d,f="line-dasharray"===String(s)&&"constant"!==i.layout.get("line-cap").value.kind;if("constant"!==c.kind||f){if("source"===c.kind||f||p){const m=sd(s,u,"source");this.binders[s]=p?new so(c,l,u,h,r,m,i.id):new sr(c,l,u,m),o.push(`/a_${s}`)}else{const g=sd(s,u,"composite");this.binders[s]=new sn(c,l,u,h,r,g),o.push(`/z_${s}`)}}else this.binders[s]=p?new si(c.value,l):new st(c.value,l,u),o.push(`/u_${s}`)}this.cacheKey=o.sort().join("")}getMaxValue(i){const r=this.binders[i];return r instanceof sr||r instanceof sn?r.maxValue:0}populatePaintArrays(i,r,n,o,s,a){for(const l in this.binders){const c=this.binders[l];(c instanceof sr||c instanceof sn||c instanceof so)&&c.populatePaintArray(i,r,n,o,s,a)}}setConstantPatternPositions(i,r){for(const n in this.binders){const o=this.binders[n];o instanceof si&&o.setConstantPatternPositions(i,r)}}updatePaintArrays(i,r,n,o,s,a){let l=!1;for(const c in i){const u=r.getPositions(c);for(const h of u){const d=n.feature(h.index);for(const p in this.binders){const f=this.binders[p];if((f instanceof sr||f instanceof sn||f instanceof so)&&!0===f.expression.isStateDependent){const m=o.paint.get(p);f.expression=m.value,f.updatePaintArray(h.start,h.end,d,i[c],s,a),l=!0}}}}return l}defines(){const i=[];for(const r in this.binders){const n=this.binders[r];(n instanceof st||n instanceof si)&&i.push(...n.uniformNames.map(i=>`#define HAS_UNIFORM_${i}`))}return i}getBinderAttributes(){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof sr||n instanceof sn||n instanceof so)for(let o=0;o!0){for(const o of(this.programConfigurations={},i))this.programConfigurations[o.id]=new ss(o,r,n);this.needsUpload=!1,this._featureMap=new o9,this._bufferOffset=0}populatePaintArrays(i,r,n,o,s,a,l){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(i,r,o,s,a,l);void 0!==r.id&&this._featureMap.add(r.id,n,this._bufferOffset,i),this._bufferOffset=i,this.needsUpload=!0}updatePaintArrays(i,r,n,o,s){for(const a of n)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(i,this._featureMap,r,a,o,s)||this.needsUpload}get(i){return this.programConfigurations[i]}upload(i){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(i);this.needsUpload=!1}}destroy(){for(const i in this.programConfigurations)this.programConfigurations[i].destroy()}}const sl={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from",],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from",],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from",],"line-dasharray":["dash_to","dash_from"]};function sc(i,r){return sl[i]||[i.replace(`${r}-`,"").replace(/-/g,"_"),]}const su={"line-pattern":{source:og,composite:og},"fill-pattern":{source:og,composite:og},"fill-extrusion-pattern":{source:og,composite:og},"line-dasharray":{source:oy,composite:oy}},sh={color:{source:oP,composite:oD},number:{source:oS,composite:oP}};function sd(i,r,n){const o=su[i];return o&&o[n]||sh[r][n]}nr("ConstantBinder",st),nr("CrossFadedConstantBinder",si),nr("SourceExpressionBinder",sr),nr("CrossFadedCompositeBinder",so),nr("CompositeExpressionBinder",sn),nr("ProgramConfiguration",ss,{omit:["_buffers"]}),nr("ProgramConfigurationSet",sa);const sp="-transition";class sf extends tu{constructor(i,r){if(super(),this.id=i.id,this.type=i.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==i.type&&(this.metadata=i.metadata,this.minzoom=i.minzoom,this.maxzoom=i.maxzoom,"background"!==i.type&&"sky"!==i.type&&(this.source=i.source,this.sourceLayer=i["source-layer"],this.filter=i.filter),r.layout&&(this._unevaluatedLayout=new class{constructor(i){this._properties=i,this._values=Object.create(i.defaultPropertyValues)}getValue(i){return eh(this._values[i].value)}setValue(i,r){this._values[i]=new nW(this._values[i].property,null===r?void 0:eh(r))}serialize(){const i={};for(const r of Object.keys(this._values)){const n=this.getValue(r);void 0!==n&&(i[r]=n)}return i}possiblyEvaluate(i,r,n){const o=new oe(this._properties);for(const s of Object.keys(this._values))o._values[s]=this._values[s].possiblyEvaluate(i,r,n);return o}}(r.layout)),r.paint)){for(const n in this._transitionablePaint=new nK(r.paint),i.paint)this.setPaintProperty(n,i.paint[n],{validate:!1});for(const o in i.layout)this.setLayoutProperty(o,i.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new oe(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(i){return"visibility"===i?this.visibility:this._unevaluatedLayout.getValue(i)}setLayoutProperty(i,r,n={}){null!=r&&this._validate(rK,`layers.${this.id}.layout.${i}`,i,r,n)||("visibility"!==i?this._unevaluatedLayout.setValue(i,r):this.visibility=r)}getPaintProperty(i){return el(i,sp)?this._transitionablePaint.getTransition(i.slice(0,-sp.length)):this._transitionablePaint.getValue(i)}setPaintProperty(i,r,n={}){if(null!=r&&this._validate(rH,`layers.${this.id}.paint.${i}`,i,r,n))return!1;if(el(i,sp))return this._transitionablePaint.setTransition(i.slice(0,-sp.length),r||void 0),!1;{const o=this._transitionablePaint._values[i],s="cross-faded-data-driven"===o.property.specification["property-type"],a=o.value.isDataDriven(),l=o.value;this._transitionablePaint.setValue(i,r),this._handleSpecialPaintPropertyUpdate(i);const c=this._transitionablePaint._values[i].value;return c.isDataDriven()||a||s||this._handleOverridablePaintPropertyUpdate(i,l,c)}}_handleSpecialPaintPropertyUpdate(i){}getProgramIds(){return null}getProgramConfiguration(i){return null}_handleOverridablePaintPropertyUpdate(i,r,n){return!1}isHidden(i){return!!(this.minzoom&&i=this.maxzoom)||"none"===this.visibility}updateTransitions(i){this._transitioningPaint=this._transitionablePaint.transitioned(i,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(i,r){i.getCrossfadeParameters&&(this._crossfadeParameters=i.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(i,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(i,void 0,r)}serialize(){const i={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&&(i.layout=i.layout||{},i.layout.visibility=this.visibility),eu(i,(i,r)=>!(void 0===i||"layout"===r&&!Object.keys(i).length||"paint"===r&&!Object.keys(i).length))}_validate(i,r,n,o,s={}){return(!s||!1!==s.validate)&&rY(this,i.call(r5,{key:r,layerType:this.type,objectKey:n,value:o,styleSpec:th,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const i in this.paint._values){const r=this.paint.get(i);if(r instanceof nQ&&iQ(r.property.specification)&&("source"===r.value.kind||"composite"===r.value.kind)&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=rT(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const sm=oh([{name:"a_pos",components:2,type:"Int16"},],4),{members:s8}=sm;class sg{constructor(i=[]){this.segments=i}prepareSegment(i,r,n,o){let s=this.segments[this.segments.length-1];return i>sg.MAX_VERTEX_ARRAY_LENGTH&&ep(`Max vertices per segment is ${sg.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${i}`),(!s||s.vertexLength+i>sg.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==o)&&(s={vertexOffset:r.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==o&&(s.sortKey=o),this.segments.push(s)),s}get(){return this.segments}destroy(){for(const i of this.segments)for(const r in i.vaos)i.vaos[r].destroy()}static simpleSegment(i,r,n,o){return new sg([{vertexOffset:i,primitiveOffset:r,vertexLength:n,primitiveLength:o,vaos:{},sortKey:0},])}}sg.MAX_VERTEX_ARRAY_LENGTH=65535,nr("SegmentVector",sg);class sy{constructor(i,r){i&&(r?this.setSouthWest(i).setNorthEast(r):4===i.length?this.setSouthWest([i[0],i[1],]).setNorthEast([i[2],i[3]]):this.setSouthWest(i[0]).setNorthEast(i[1]))}setNorthEast(i){return this._ne=i instanceof sx?new sx(i.lng,i.lat):sx.convert(i),this}setSouthWest(i){return this._sw=i instanceof sx?new sx(i.lng,i.lat):sx.convert(i),this}extend(i){const r=this._sw,n=this._ne;let o,s;if(i instanceof sx)o=i,s=i;else{if(!(i instanceof sy))return Array.isArray(i)?4===i.length||i.every(Array.isArray)?this.extend(sy.convert(i)):this.extend(sx.convert(i)):this;if(o=i._sw,s=i._ne,!o||!s)return this}return r||n?(r.lng=Math.min(o.lng,r.lng),r.lat=Math.min(o.lat,r.lat),n.lng=Math.max(s.lng,n.lng),n.lat=Math.max(s.lat,n.lat)):(this._sw=new sx(o.lng,o.lat),this._ne=new sx(s.lng,s.lat)),this}getCenter(){return new sx((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 sx(this.getWest(),this.getNorth())}getSouthEast(){return new sx(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(i){const{lng:r,lat:n}=sx.convert(i);let o=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&o}static convert(i){return!i||i instanceof sy?i:new sy(i)}}class sx{constructor(i,r){if(isNaN(i)||isNaN(r))throw Error(`Invalid LngLat object: (${i}, ${r})`);if(this.lng=+i,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new sx(J(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(i){const r=Math.PI/180,n=this.lat*r,o=i.lat*r,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos((i.lng-this.lng)*r);return 6371008.8*Math.acos(Math.min(s,1))}toBounds(i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*this.lat);return new sy(new sx(this.lng-n,this.lat-r),new sx(this.lng+n,this.lat+r))}static convert(i){if(i instanceof sx)return i;if(Array.isArray(i)&&(2===i.length||3===i.length))return new sx(Number(i[0]),Number(i[1]));if(!Array.isArray(i)&&"object"==typeof i&&null!==i)return new sx(Number("lng"in i?i.lng:i.lon),Number(i.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const s$=2*Math.PI*6371008.8;function sv(i){return s$*Math.cos(i*Math.PI/180)}function s_(i){return(180+i)/360}function sb(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function sw(i,r){return i/sv(r)}function s0(i){return 360*i-180}function sT(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}function sE(i,r){return i*sv(sT(r))}class sS{constructor(i,r,n=0){this.x=+i,this.y=+r,this.z=+n}static fromLngLat(i,r=0){const n=sx.convert(i);return new sS(s_(n.lng),sb(n.lat),r/sv(n.lat))}toLngLat(){return new sx(s0(this.x),sT(this.y))}toAltitude(){return sE(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/s$*(1/Math.cos(sT(this.y)*Math.PI/180))}}function sI(i,r,n,o,s,a,c,u,h){const d=(r+o)/2,p=(n+s)/2,f=new l(d,p);u(f),function(i,r,n,o,s,a){const l=n-s,c=o-a;return Math.abs((o-r)*l-(n-i)*c)/Math.hypot(l,c)}(f.x,f.y,a.x,a.y,c.x,c.y)>=h?(sI(i,r,n,d,p,a,f,u,h),sI(i,d,p,o,s,f,c,u,h)):i.push(c)}function sC(i,r,n){const o=[];let s,a,l;for(const c of i){const{x:u,y:h}=c;r(c),l?sI(o,s,a,u,h,l,c,r,n):o.push(c),s=u,a=h,l=c}return o}const sz=-16383-1;function sA(i,r){const n=Math.round(i.x*r),o=Math.round(i.y*r);return i.x=K(n,sz,16383),i.y=K(o,sz,16383),(ni.x+1||oi.y+1)&&ep("Geometry exceeds allowed extent, reduce your vector tile buffer size"),i}function sk(i,r,n){const o=i.loadGeometry(),s=i.extent,a=8192/s;if(r&&n&&n.projection.isReprojectedInTileSpace){const l=1<{const n=s0((r.x+i.x/s)/l),o=sT((r.y+i.y/s)/l),a=d.project(n,o);i.x=(a.x*c-u)*s,i.y=(a.y*c-h)*s};for(let f=0;f=s||g.y<0||g.y>=s||(p(g),m.push(g));o[f]=m}}for(const y of o)for(const x of y)sA(x,a);return o}function sP(i,r){return{type:i.type,id:i.id,properties:i.properties,geometry:r?sk(i):[]}}function sD(i,r,n,o,s){i.emplaceBack(2*r+(o+1)/2,2*n+(s+1)/2)}class sL{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new op,this.indexArray=new o0,this.segments=new sg,this.programConfigurations=new sa(i.layers,i.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){const s=this.layers[0],a=[];let l=null;for(const{feature:c,id:u,index:h,sourceLayerIndex:d}of("circle"===s.type&&(l=s.layout.get("circle-sort-key")),i)){const p=this.layers[0]._featureFilter.needGeometry,f=sP(c,p);if(!this.layers[0]._featureFilter.filter(new nX(this.zoom),f,n))continue;const m=l?l.evaluate(f,{},n):void 0,g={id:u,properties:c.properties,type:c.type,sourceLayerIndex:d,index:h,geometry:p?f.geometry:sk(c,n,o),patterns:{},sortKey:m};a.push(g)}for(const y of(l&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:x,index:$,sourceLayerIndex:v}=y,_=i[$].feature;this.addFeature(y,x,$,r.availableImages,n),r.featureIndex.insert(_,x,$,v,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,s8),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(i,r,n,o,s){for(const a of r)for(const l of a){const c=l.x,u=l.y;if(c<0||c>=8192||u<0||u>=8192)continue;const h=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,i.sortKey),d=h.vertexLength;sD(this.layoutVertexArray,c,u,-1,-1),sD(this.layoutVertexArray,c,u,1,-1),sD(this.layoutVertexArray,c,u,1,1),sD(this.layoutVertexArray,c,u,-1,1),this.indexArray.emplaceBack(d,d+1,d+2),this.indexArray.emplaceBack(d,d+3,d+2),h.vertexLength+=4,h.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,{},o,s)}}function s1(i,r){for(let n=0;n1){if(sM(i,r))return!0;for(let o=0;o1?n:n.sub(r)._mult(s)._add(r))}function s4(i,r){let n,o,s,a=!1;for(let l=0;lr.y!=s.y>r.y&&r.x<(s.x-o.x)*(r.y-o.y)/(s.y-o.y)+o.x&&(a=!a)}return a}function sU(i,r){let n=!1;for(let o=0,s=i.length-1;or.y!=l.y>r.y&&r.x<(l.x-a.x)*(r.y-a.y)/(l.y-a.y)+a.x&&(n=!n)}return n}function sV(i,r,n,o,s){for(const a of i)if(r<=a.x&&n<=a.y&&o>=a.x&&s>=a.y)return!0;const c=[new l(r,n),new l(r,s),new l(o,s),new l(o,n),];if(i.length>2){for(const u of c)if(sU(i,u))return!0}for(let h=0;hs.x&&r.x>s.x||i.ys.y&&r.y>s.y)return!1;const a=ef(i,r,n[0]);return a!==ef(i,r,n[1])||a!==ef(i,r,n[2])||a!==ef(i,r,n[3])}function sj(i,r,n){const o=r.paint.get(i).value;return"constant"===o.kind?o.value:n.programConfigurations.get(r.id).getMaxValue(i)}function sN(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function sG(i,r,n,o,s){if(!r[0]&&!r[1])return i;const a=l.convert(r)._mult(s);"viewport"===n&&a._rotate(-o);const c=[];for(let u=0;u{var a,l,c;const u=M([],n,i),h=1/u[3]/r*s;return a=u,l=u,c=[h,h,o?1/u[3]:h,h],a[0]=l[0]*c[0],a[1]=l[1]*c[1],a[2]=l[2]*c[2],a[3]=l[3]*c[3],a}),l=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5],].map(i=>{const r=A([],P([],R([],a[i[0]],a[i[1]]),R([],a[i[2]],a[i[1]]))),n=-k(r,a[i[1]]);return r.concat(n)});return new sq(a,l)}}class s5{constructor(i,r){this.min=i,this.max=r,this.center=C([],T([],this.min,this.max),.5)}quadrant(i){const r=[i%2==0,i<2],n=_(this.min),o=_(this.max);for(let s=0;s=0;if(0===a)return 0;a!==r.length&&(n=!1)}if(n)return 2;for(let c=0;c<3;c++){let u=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(let d=0;dthis.max[c]-this.min[c])return 0}return 1}}function sX(i,r,n,o,s,a,l,c,u){if(a&&i.queryGeometry.isAboveHorizon)return!1;for(const h of(a&&(u*=i.pixelToTileUnitsFactor),r))for(const d of h){const p=d.add(c),f=s&&n.elevation?n.elevation.exaggeration()*s.getElevationAt(p.x,p.y,!0):0,m=a?p:sW(p,f,o),g=a?i.tilespaceRays.map(i=>sY(i,f)):i.queryGeometry.screenGeometry,y=M([],[d.x,d.y,f,1],o);if(!l&&a?u*=y[3]/n.cameraToCenterDistance:l&&!a&&(u*=n.cameraToCenterDistance/y[3]),sB(g,m,u))return!0}return!1}function sW(i,r,n){const o=M([],[i.x,i.y,r,1],n);return new l(o[0]/o[3],o[1]/o[3])}const sH=w(0,0,0),sK=w(0,0,1);function sY(i,r){const n=v();return sH[2]=r,i.intersectsPlane(sH,sK,n),new l(n[0],n[1])}class sJ extends sL{}function sQ(i,{width:r,height:n},o,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==r*n*o)throw RangeError("mismatched image size")}else s=new Uint8Array(r*n*o);return i.width=r,i.height=n,i.data=s,i}function ae(i,{width:r,height:n},o){if(r===i.width&&n===i.height)return;const s=sQ({},{width:r,height:n},o);at(i,s,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,r),height:Math.min(i.height,n)},o),i.width=r,i.height=n,i.data=s.data}function at(i,r,n,o,s,a){if(0===s.width||0===s.height)return r;if(s.width>i.width||s.height>i.height||n.x>i.width-s.width||n.y>i.height-s.height)throw RangeError("out of range source coordinates for image copy");if(s.width>r.width||s.height>r.height||o.x>r.width-s.width||o.y>r.height-s.height)throw RangeError("out of range destination coordinates for image copy");const l=i.data,c=r.data;for(let u=0;u{r[i.evaluationKey]=a;const l=i.expression.evaluate(r);s.data[n+o+0]=Math.floor(255*l.r/l.a),s.data[n+o+1]=Math.floor(255*l.g/l.a),s.data[n+o+2]=Math.floor(255*l.b/l.a),s.data[n+o+3]=Math.floor(255*l.a)};if(i.clips)for(let l=0,c=0;l80*n){o=a=i[0],s=l=i[1];for(var g=n;ga&&(a=c),u>l&&(l=u);h=0!==(h=Math.max(a-o,l-s))?1/h:0}return ap(f,m,n,o,s,h),m}function ah(i,r,n,o,s){var a,l;if(s===aD(i,r,n,o)>0)for(a=r;a=r;a-=o)l=aA(a,i[a],i[a+1],l);return l&&aT(l,l.next)&&(ak(l),l=l.next),l}function ad(i,r){if(!i)return i;r||(r=i);var n,o=i;do if(n=!1,o.steiner||!aT(o,o.next)&&0!==a0(o.prev,o,o.next))o=o.next;else{if(ak(o),(o=r=o.prev)===o.next)break;n=!0}while(n||o!==r)return r}function ap(i,r,n,o,s,a,l){if(i){!l&&a&&function(i,r,n,o){var s=i;do null===s.z&&(s.z=av(s.x,s.y,r,n,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i)s.prevZ.nextZ=null,s.prevZ=null,function(i){var r,n,o,s,a,l,c,u,h=1;do{for(n=i,i=null,a=null,l=0;n;){for(l++,o=n,c=0,r=0;r0||u>0&&o;)0!==c&&(0===u||!o||n.z<=o.z)?(s=n,n=n.nextZ,c--):(s=o,o=o.nextZ,u--),a?a.nextZ=s:i=s,s.prevZ=a,a=s;n=o}a.nextZ=null,h*=2}while(l>1)}(s)}(i,o,s,a);for(var c,u,h=i;i.prev!==i.next;)if(c=i.prev,u=i.next,a?am(i,o,s,a):af(i))r.push(c.i/n),r.push(i.i/n),r.push(u.i/n),ak(i),i=u.next,h=u.next;else if((i=u)===h){l?1===l?ap(i=a8(ad(i),r,n),r,n,o,s,a,2):2===l&&ag(i,r,n,o,s,a):ap(ad(i),r,n,o,s,a,1);break}}}function af(i){var r=i.prev,n=i,o=i.next;if(a0(r,n,o)>=0)return!1;for(var s=i.next.next;s!==i.prev;){if(ab(r.x,r.y,n.x,n.y,o.x,o.y,s.x,s.y)&&a0(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function am(i,r,n,o){var s=i.prev,a=i,l=i.next;if(a0(s,a,l)>=0)return!1;for(var c=s.x>a.x?s.x>l.x?s.x:l.x:a.x>l.x?a.x:l.x,u=s.y>a.y?s.y>l.y?s.y:l.y:a.y>l.y?a.y:l.y,h=av(s.x=h&&f&&f.z<=d;){if(p!==i.prev&&p!==i.next&&ab(s.x,s.y,a.x,a.y,l.x,l.y,p.x,p.y)&&a0(p.prev,p,p.next)>=0||(p=p.prevZ,f!==i.prev&&f!==i.next&&ab(s.x,s.y,a.x,a.y,l.x,l.y,f.x,f.y)&&a0(f.prev,f,f.next)>=0))return!1;f=f.nextZ}for(;p&&p.z>=h;){if(p!==i.prev&&p!==i.next&&ab(s.x,s.y,a.x,a.y,l.x,l.y,p.x,p.y)&&a0(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==i.prev&&f!==i.next&&ab(s.x,s.y,a.x,a.y,l.x,l.y,f.x,f.y)&&a0(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function a8(i,r,n){var o=i;do{var s=o.prev,a=o.next.next;!aT(s,a)&&aE(s,o,o.next,a)&&aC(s,a)&&aC(a,s)&&(r.push(s.i/n),r.push(o.i/n),r.push(a.i/n),ak(o),ak(o.next),o=i=a),o=o.next}while(o!==i)return ad(o)}function ag(i,r,n,o,s,a){var l=i;do{for(var c=l.next.next;c!==l.prev;){if(l.i!==c.i&&aw(l,c)){var u=az(l,c);return l=ad(l,l.next),u=ad(u,u.next),ap(l,r,n,o,s,a),void ap(u,r,n,o,s,a)}c=c.next}l=l.next}while(l!==i)}function ay(i,r){return i.x-r.x}function ax(i,r){var n=function(i,r){var n,o=r,s=i.x,a=i.y,l=-1/0;do{if(a<=o.y&&a>=o.next.y&&o.next.y!==o.y){var c=o.x+(a-o.y)*(o.next.x-o.x)/(o.next.y-o.y);if(c<=s&&c>l){if(l=c,c===s){if(a===o.y)return o;if(a===o.next.y)return o.next}n=o.x=o.x&&o.x>=d&&s!==o.x&&ab(an.x||o.x===n.x&&a$(n,o)))&&(n=o,f=u)),o=o.next;while(o!==h)return n}(i,r);if(!n)return r;var o=az(n,i),s=ad(n,n.next);return ad(o,o.next),r===n?s:r}function a$(i,r){return 0>a0(i.prev,i,r.prev)&&0>a0(r.next,i,i.next)}function av(i,r,n,o,s){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=32767*(i-n)*s)|i<<8))|i<<4))|i<<2))|i<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=32767*(r-o)*s)|r<<8))|r<<4))|r<<2))|r<<1))<<1}function a_(i){var r=i,n=i;do(r.x=0&&(i-l)*(o-c)-(n-l)*(r-c)>=0&&(n-l)*(a-c)-(s-l)*(o-c)>=0}function aw(i,r){return i.next.i!==r.i&&i.prev.i!==r.i&&!function(i,r){var n=i;do{if(n.i!==i.i&&n.next.i!==i.i&&n.i!==r.i&&n.next.i!==r.i&&aE(n,n.next,i,r))return!0;n=n.next}while(n!==i)return!1}(i,r)&&(aC(i,r)&&aC(r,i)&&function(i,r){var n=i,o=!1,s=(i.x+r.x)/2,a=(i.y+r.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&s<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==i)return o}(i,r)&&(a0(i.prev,i,r.prev)||a0(i,r.prev,r))||aT(i,r)&&a0(i.prev,i,i.next)>0&&a0(r.prev,r,r.next)>0)}function a0(i,r,n){return(r.y-i.y)*(n.x-r.x)-(r.x-i.x)*(n.y-r.y)}function aT(i,r){return i.x===r.x&&i.y===r.y}function aE(i,r,n,o){var s=aI(a0(i,r,n)),a=aI(a0(i,r,o)),l=aI(a0(n,o,i)),c=aI(a0(n,o,r));return s!==a&&l!==c||!(0!==s||!aS(i,n,r))||!(0!==a||!aS(i,o,r))||!(0!==l||!aS(n,i,o))||!(0!==c||!aS(n,r,o))}function aS(i,r,n){return r.x<=Math.max(i.x,n.x)&&r.x>=Math.min(i.x,n.x)&&r.y<=Math.max(i.y,n.y)&&r.y>=Math.min(i.y,n.y)}function aI(i){return i>0?1:i<0?-1:0}function aC(i,r){return 0>a0(i.prev,i,i.next)?a0(i,r,i.next)>=0&&a0(i,i.prev,r)>=0:0>a0(i,r,i.prev)||0>a0(i,i.next,r)}function az(i,r){var n=new aP(i.i,i.x,i.y),o=new aP(r.i,r.x,r.y),s=i.next,a=r.prev;return i.next=r,r.prev=i,n.next=s,s.prev=n,o.next=n,n.prev=o,a.next=o,o.prev=a,o}function aA(i,r,n,o){var s=new aP(i,r,n);return o?(s.next=o.next,s.prev=o,o.next.prev=s,o.next=s):(s.prev=s,s.next=s),s}function ak(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 aP(i,r,n){this.i=i,this.x=r,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function aD(i,r,n,o){for(var s=0,a=r,l=n-o;an;){if(o-n>600){var a=o-n+1,l=r-n+1,c=Math.log(a),u=.5*Math.exp(2*c/3),h=.5*Math.sqrt(c*u*(a-u)/a)*(l-a/2<0?-1:1);a1(i,r,Math.max(n,Math.floor(r-l*u/a+h)),Math.min(o,Math.floor(r+(a-l)*u/a+h)),s)}var d=i[r],p=n,f=o;for(aB(i,n,r),s(i[o],d)>0&&aB(i,n,o);ps(i[p],d);)p++;for(;s(i[f],d)>0;)f--}0===s(i[n],d)?aB(i,n,f):aB(i,++f,o),f<=r&&(n=f+1),r<=f&&(o=f-1)}}function aB(i,r,n){var o=i[r];i[r]=i[n],i[n]=o}function aR(i,r){return ir?1:0}function a3(i,r){const n=i.length;if(n<=1)return[i];const o=[];let s,a;for(let l=0;l1)for(let u=0;u0&&n.holes.push(o+=i[s-1].length)}return n},ac.default=au;class aO{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new op,this.indexArray=new o0,this.indexArray2=new oA,this.programConfigurations=new sa(i.layers,i.zoom),this.segments=new sg,this.segments2=new sg,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=a2("fill",this.layers,r);const s=this.layers[0].layout.get("fill-sort-key"),a=[];for(const{feature:l,id:c,index:u,sourceLayerIndex:h}of i){const d=this.layers[0]._featureFilter.needGeometry,p=sP(l,d);if(!this.layers[0]._featureFilter.filter(new nX(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n,r.availableImages):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:h,index:u,geometry:d?p.geometry:sk(l,n,o),patterns:{},sortKey:f};a.push(m)}for(const g of(s&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:y,index:x,sourceLayerIndex:$}=g;if(this.hasPattern){const v=aF("fill",this.layers,g,this.zoom,r);this.patternFeatures.push(v)}else this.addFeature(g,y,x,n,{},r.availableImages);r.featureIndex.insert(i[x].feature,y,x,$,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,al),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.indexBuffer2=i.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(i),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(i,r,n,o,s,a=[]){for(const l of a3(r,500)){let c=0;for(const u of l)c+=u.length;const h=this.segments.prepareSegment(c,this.layoutVertexArray,this.indexArray),d=h.vertexLength,p=[],f=[];for(const m of l){if(0===m.length)continue;m!==l[0]&&f.push(p.length/2);const g=this.segments2.prepareSegment(m.length,this.layoutVertexArray,this.indexArray2),y=g.vertexLength;this.layoutVertexArray.emplaceBack(m[0].x,m[0].y),this.indexArray2.emplaceBack(y+m.length-1,y),p.push(m[0].x),p.push(m[0].y);for(let x=1;x>3}if(s--,1===o||2===o)a+=i.readSVarint(),c+=i.readSVarint(),1===o&&(r&&u.push(r),r=[]),r.push(new l(a,c));else{if(7!==o)throw Error("unknown command "+o);r&&r.push(r[0].clone())}}return r&&u.push(r),u},aG.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var r=i.readVarint()+i.pos,n=1,o=0,s=0,a=0,l=1/0,c=-1/0,u=1/0,h=-1/0;i.pos>3}if(o--,1===n||2===n)(s+=i.readSVarint())c&&(c=s),(a+=i.readSVarint())h&&(h=a);else if(7!==n)throw Error("unknown command "+n)}return[l,u,c,h]},aG.prototype.toGeoJSON=function(i,r,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*i,c=this.extent*r,u=this.loadGeometry(),h=aG.types[this.type];function d(i){for(var r=0;r>3;r=1===o?i.readString():2===o?i.readFloat():3===o?i.readDouble():4===o?i.readVarint64():5===o?i.readVarint():6===o?i.readSVarint():7===o?i.readBoolean():null}return r}(n))}function aX(i,r,n){if(3===i){var o=new a7(n,n.readVarint()+n.pos);o.length&&(r[o.name]=o)}}aq.prototype.feature=function(i){if(i<0||i>=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[i];var r=this._pbf.readVarint()+this._pbf.pos;return new aN(this._pbf,r,this.extent,this._keys,this._values)};var aW={VectorTile:function(i,r){this.layers=i.readFields(aX,{},r)},VectorTileFeature:aN,VectorTileLayer:a7};const aH=aW.VectorTileFeature.types;function aK(i,r,n,o,s,a,l,c){i.emplaceBack((r<<1)+l,(n<<1)+a,(Math.floor(8192*o)<<1)+s,Math.round(c))}class aY{constructor(){this.acc=new l(0,0),this.polyCount=[]}startRing(i){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new l(i.x,i.y),this.max=new l(i.x,i.y))}append(i,r){this.currentPolyCount.edges++,this.acc._add(i);let n=!!this.borders;const o=this.min,s=this.max;i.xs.x&&(s.x=i.x,n=!0),i.ys.y&&(s.y=i.y,n=!0),((0===i.x||8192===i.x)&&i.x===r.x)!=((0===i.y||8192===i.y)&&i.y===r.y)&&this.processBorderOverlap(i,r),n&&this.checkBorderIntersection(i,r)}checkBorderIntersection(i,r){r.x<0!=i.x<0&&this.addBorderIntersection(0,i$(r.y,i.y,(0-r.x)/(i.x-r.x))),r.x>8192!=i.x>8192&&this.addBorderIntersection(1,i$(r.y,i.y,(8192-r.x)/(i.x-r.x))),r.y<0!=i.y<0&&this.addBorderIntersection(2,i$(r.x,i.x,(0-r.y)/(i.y-r.y))),r.y>8192!=i.y>8192&&this.addBorderIntersection(3,i$(r.x,i.x,(8192-r.y)/(i.y-r.y)))}addBorderIntersection(i,r){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],]);const n=this.borders[i];rn[1]&&(n[1]=r)}processBorderOverlap(i,r){if(i.x===r.x){if(i.y===r.y)return;const n=0===i.x?0:1;this.addBorderIntersection(n,r.y),this.addBorderIntersection(n,i.y)}else{const o=0===i.y?2:3;this.addBorderIntersection(o,r.x),this.addBorderIntersection(o,i.x)}}centroid(){const i=this.polyCount.reduce((i,r)=>i+r.edges,0);return 0!==i?this.acc.div(i)._round():new l(0,0)}span(){return new l(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((i,r)=>i+ +(r[0]!==Number.MAX_VALUE),0)}}class aJ{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new of,this.centroidVertexArray=new oV,this.indexArray=new o0,this.programConfigurations=new sa(i.layers,i.zoom),this.segments=new sg,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=i.enableTerrain}populate(i,r,n,o){for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of(this.features=[],this.hasPattern=a2("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(i){const r=Math.exp(Math.PI*(1-i.y/(1<i.x<=0)||l.every(i=>i.x>=8192)||l.every(i=>i.y<=0)||l.every(i=>i.y>=8192))continue;for(let p=0;p=1){const x=f[g-1];if(!aQ(y,x)){c&&c.append(y,x),d.vertexLength+4>sg.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const $=y.sub(x)._perp(),v=$.x/(Math.abs($.x)+Math.abs($.y)),_=$.y>0?1:0,b=x.dist(y);m+b>32768&&(m=0),aK(this.layoutVertexArray,y.x,y.y,v,_,0,0,m),aK(this.layoutVertexArray,y.x,y.y,v,_,0,1,m),m+=b,aK(this.layoutVertexArray,x.x,x.y,v,_,0,0,m),aK(this.layoutVertexArray,x.x,x.y,v,_,0,1,m);const w=d.vertexLength;this.indexArray.emplaceBack(w,w+2,w+1),this.indexArray.emplaceBack(w+1,w+2,w+3),d.vertexLength+=4,d.primitiveLength+=2}}}}if(d.vertexLength+h>sg.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(h,this.layoutVertexArray,this.indexArray)),"Polygon"!==aH[i.type])continue;const T=[],E=[],S=d.vertexLength;for(let I=0;I0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const D=c.borders,L=this.featuresOnBorder.push(c)-1;for(let B=0;B<4;B++)D[B][0]!==Number.MAX_VALUE&&this.borders[B].push(L)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}sortBorders(){for(let i=0;i<4;i++)this.borders[i].sort((r,n)=>this.featuresOnBorder[r].borders[i][0]-this.featuresOnBorder[n].borders[i][0])}encodeCentroid(i,r,n=!0){let o,s;if(i){if(0!==i.y){const a=r.span()._mult(this.tileToMeter);o=(Math.max(i.x,1)<<3)+Math.min(7,Math.round(a.x/10)),s=(Math.max(i.y,1)<<3)+Math.min(7,Math.round(a.y/10))}else o=Math.ceil(7*(i.x+450)),s=0}else o=0,s=+n;let l=n?this.centroidVertexArray.length:r.vertexArrayOffset;for(const c of r.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*c.edges+c.top);for(let u=0;u<2*c.edges;u++)this.centroidVertexArray.emplace(l++,0,s),this.centroidVertexArray.emplace(l++,o,s);for(let h=0;h8192)||i.y===r.y&&(i.y<0||i.y>8192)}nr("FillExtrusionBucket",aJ,{omit:["layers","features"]}),nr("PartMetadata",aY);var le={paint:new os({"fill-extrusion-opacity":new ot(th["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new oi(th["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new ot(th["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new ot(th["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new or(th["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new oi(th["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new oi(th["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new ot(th["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function lt(i,r){return i.x*r.x+i.y*r.y}function li(i,r){if(1===i.length){let n=0;const o=r[n++];let s;for(;!s||o.equals(s);)if(!(s=r[n++]))return 1/0;for(;ni.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new om,this.layoutVertexArray2=new o8,this.indexArray=new o0,this.programConfigurations=new sa(i.layers,i.zoom),this.segments=new sg,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=a2("line",this.layers,r);const s=this.layers[0].layout.get("line-sort-key"),a=[];for(const{feature:l,id:c,index:u,sourceLayerIndex:h}of i){const d=this.layers[0]._featureFilter.needGeometry,p=sP(l,d);if(!this.layers[0]._featureFilter.filter(new nX(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:h,index:u,geometry:d?p.geometry:sk(l,n,o),patterns:{},sortKey:f};a.push(m)}s&&a.sort((i,r)=>i.sortKey-r.sortKey);const{lineAtlas:g,featureIndex:y}=r,x=this.addConstantDashes(g);for(const $ of a){const{geometry:v,index:_,sourceLayerIndex:b}=$;if(x&&this.addFeatureDashes($,g),this.hasPattern){const w=aF("line",this.layers,$,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature($,v,_,n,g.positions,r.availableImages);y.insert(i[_].feature,v,_,b,this.index)}}addConstantDashes(i){let r=!1;for(const n of this.layers){const o=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"!==o.kind||"constant"!==s.kind)r=!0;else{const a=s.value,l=o.value;if(!l)continue;i.addDash(l.from,a),i.addDash(l.to,a),l.other&&i.addDash(l.other,a)}}return r}addFeatureDashes(i,r){const n=this.zoom;for(const o of this.layers){const s=o.paint.get("line-dasharray").value,a=o.layout.get("line-cap").value;if("constant"===s.kind&&"constant"===a.kind)continue;let l,c,u,h,d,p;if("constant"===s.kind){const f=s.value;if(!f)continue;l=f.other||f.to,c=f.to,u=f.from}else l=s.evaluate({zoom:n-1},i),c=s.evaluate({zoom:n},i),u=s.evaluate({zoom:n+1},i);"constant"===a.kind?h=d=p=a.value:(h=a.evaluate({zoom:n-1},i),d=a.evaluate({zoom:n},i),p=a.evaluate({zoom:n+1},i)),r.addDash(l,h),r.addDash(c,d),r.addDash(u,p);const m=r.getKey(l,h),g=r.getKey(c,d),y=r.getKey(u,p);i.patterns[o.id]={min:m,mid:g,max:y}}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=i.createVertexBuffer(this.layoutVertexArray2,ll)),this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,ls),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(i){if(i.properties&&i.properties.hasOwnProperty("mapbox_clip_start")&&i.properties.hasOwnProperty("mapbox_clip_end"))return{start:+i.properties.mapbox_clip_start,end:+i.properties.mapbox_clip_end}}addFeature(i,r,n,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(i,{}),u=l.get("line-cap").evaluate(i,{}),h=l.get("line-miter-limit"),d=l.get("line-round-limit");for(const p of(this.lineClips=this.lineFeatureClips(i),r))this.addLine(p,i,c,u,h,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}addLine(i,r,n,o,s,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let l=0;l=2&&i[u-1].equals(i[u-2]);)u--;let h=0;for(;h0;if(E&&$>h){const I=f.dist(m);if(I>2*d){const C=f.sub(f.sub(m)._mult(d/I)._round());this.updateDistance(m,C),this.addCurrentVertex(C,y,0,0,p),m=C}}const z=m&&g;let A=z?n:c?"butt":o;if(z&&"round"===A&&(ws&&(A="bevel"),"bevel"===A&&(w>2&&(A="flipbevel"),w100)v=x.mult(-1);else{const k=w*y.add(x).mag()/y.sub(x).mag();v._perp()._mult(k*(S?-1:1))}this.addCurrentVertex(f,v,0,0,p),this.addCurrentVertex(f,v.mult(-1),0,0,p)}else if("bevel"===A||"fakeround"===A){const P=-Math.sqrt(w*w-1),D=S?P:0,L=S?0:P;if(m&&this.addCurrentVertex(f,y,D,L,p),"fakeround"===A){const B=Math.round(180*T/Math.PI/20);for(let R=1;R2*d){const j=f.add(g.sub(f)._mult(d/V)._round());this.updateDistance(f,j),this.addCurrentVertex(j,x,0,0,p),f=j}}}}addCurrentVertex(i,r,n,o,s,a=!1){const l=r.y*o-r.x,c=-r.y-r.x*o;this.addHalfVertex(i,r.x+r.y*n,r.y-r.x*n,a,!1,n,s),this.addHalfVertex(i,l,c,a,!0,-o,s)}addHalfVertex({x:i,y:r},n,o,s,a,l,c){this.layoutVertexArray.emplaceBack((i<<1)+(s?1:0),(r<<1)+(a?1:0),Math.round(63*n)+128,Math.round(63*o)+128,1+(0===l?0:l<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const u=c.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),c.primitiveLength++),a?this.e2=u:this.e1=u}updateScaledDistance(){if(this.lineClips){const i=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=i*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(i,r){this.distance+=i.dist(r),this.updateScaledDistance()}}nr("LineBucket",lh,{omit:["layers","patternFeatures"]});const ld=new os({"line-cap":new oi(th.layout_line["line-cap"]),"line-join":new oi(th.layout_line["line-join"]),"line-miter-limit":new ot(th.layout_line["line-miter-limit"]),"line-round-limit":new ot(th.layout_line["line-round-limit"]),"line-sort-key":new oi(th.layout_line["line-sort-key"])});var lp={paint:new os({"line-opacity":new oi(th.paint_line["line-opacity"]),"line-color":new oi(th.paint_line["line-color"]),"line-translate":new ot(th.paint_line["line-translate"]),"line-translate-anchor":new ot(th.paint_line["line-translate-anchor"]),"line-width":new oi(th.paint_line["line-width"]),"line-gap-width":new oi(th.paint_line["line-gap-width"]),"line-offset":new oi(th.paint_line["line-offset"]),"line-blur":new oi(th.paint_line["line-blur"]),"line-dasharray":new or(th.paint_line["line-dasharray"]),"line-pattern":new or(th.paint_line["line-pattern"]),"line-gradient":new oo(th.paint_line["line-gradient"])}),layout:ld};const lf=new class extends oi{possiblyEvaluate(i,r){return r=new nX(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(i,r)}evaluate(i,r,n,o){return r=et({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(i,r,n,o)}}(lp.paint.properties["line-width"].specification);function lm(i,r){return r>0?r+2*i:i}lf.useIntegerZoom=!0;const l8=oh([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_z_tile_anchor",components:4,type:"Int16"},],4),lg=oh([{name:"a_projected_pos",components:3,type:"Float32"},],4);oh([{name:"a_fade_opacity",components:1,type:"Uint32"},],4);const ly=oh([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},]),lx=oh([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},]);oh([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"},]);const l$=oh([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"},],4),lv=oh([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"},],4);function l_(i,r){const{expression:n}=r;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new nX(i+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:o,interpolationType:s}=n;let a=0;for(;a{i.text=function(i,r,n){const o=r.layout.get("text-transform").evaluate(n,{});return"uppercase"===o?i=i.toLocaleUpperCase():"lowercase"===o&&(i=i.toLocaleLowerCase()),n5.applyArabicShaping&&(i=n5.applyArabicShaping(i)),i}(i.text,r,n)}),i}const lE={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","\xa2":"¢","\xa3":"£","\xa5":"¥","\xa6":"¦","\xac":"¬","\xaf":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function lS(i){return"︶"===i||"﹈"===i||"︸"===i||"﹄"===i||"﹂"===i||"︾"===i||"︼"===i||"︺"===i||"︘"===i||"﹀"===i||"︐"===i||"︓"===i||"︔"===i||"`"===i||" ̄"===i||"︑"===i||"︒"===i}function lI(i){return"︵"===i||"﹇"===i||"︷"===i||"﹃"===i||"﹁"===i||"︽"===i||"︻"===i||"︹"===i||"︗"===i||"︿"===i}var lC=function(i,r,n,o,s){var a,l,c=8*s-o-1,u=(1<>1,d=-7,p=n?s-1:0,f=n?-1:1,m=i[r+p];for(p+=f,a=m&(1<<-d)-1,m>>=-d,d+=c;d>0;a=256*a+i[r+p],p+=f,d-=8);for(l=a&(1<<-d)-1,a>>=-d,d+=o;d>0;l=256*l+i[r+p],p+=f,d-=8);if(0===a)a=1-h;else{if(a===u)return l?NaN:1/0*(m?-1:1);l+=Math.pow(2,o),a-=h}return(m?-1:1)*l*Math.pow(2,a-o)},lz=function(i,r,n,o,s,a){var l,c,u,h=8*a-s-1,d=(1<>1,f=23===s?5960464477539062e-23:0,m=o?0:a-1,g=o?1:-1,y=r<0||0===r&&1/r<0?1:0;for(isNaN(r=Math.abs(r))||r===1/0?(c=isNaN(r)?1:0,l=d):(l=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-l))<1&&(l--,u*=2),(r+=l+p>=1?f/u:f*Math.pow(2,1-p))*u>=2&&(l++,u/=2),l+p>=d?(c=0,l=d):l+p>=1?(c=(r*u-1)*Math.pow(2,s),l+=p):(c=r*Math.pow(2,p-1)*Math.pow(2,s),l=0));s>=8;i[n+m]=255&c,m+=g,c/=256,s-=8);for(l=l<0;i[n+m]=255&l,m+=g,l/=256,h-=8);i[n+m-g]|=128*y},lA=lk;function lk(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}lk.Varint=0,lk.Fixed64=1,lk.Bytes=2,lk.Fixed32=5;var lP="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function lD(i){return i.type===lk.Bytes?i.readVarint()+i.pos:i.pos+1}function lL(i,r,n){var o=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));n.realloc(o);for(var s=n.pos-1;s>=i;s--)n.buf[s+o]=n.buf[s]}function l1(i,r){for(var n=0;n>>8,i[n+2]=r>>>16,i[n+3]=r>>>24}function l6(i,r){return(i[r]|i[r+1]<<8|i[r+2]<<16)+(i[r+3]<<24)}function lj(i,r,n){r.glyphs=[],1===i&&n.readMessage(lN,r)}function lN(i,r,n){if(3===i){const{id:o,bitmap:s,width:a,height:l,left:c,top:u,advance:h}=n.readMessage(lG,{});r.glyphs.push({id:o,bitmap:new ai({width:a+6,height:l+6},s),metrics:{width:a,height:l,left:c,top:u,advance:h}})}else 4===i?r.ascender=n.readSVarint():5===i&&(r.descender=n.readSVarint())}function lG(i,r,n){1===i?r.id=n.readVarint():2===i?r.bitmap=n.readBytes():3===i?r.width=n.readVarint():4===i?r.height=n.readVarint():5===i?r.left=n.readSVarint():6===i?r.top=n.readSVarint():7===i&&(r.advance=n.readVarint())}function lZ(i){let r=0,n=0;for(const o of i)r+=o.w*o.h,n=Math.max(n,o.w);i.sort((i,r)=>r.h-i.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0},];let a=0,l=0;for(const c of i)for(let u=s.length-1;u>=0;u--){const h=s[u];if(!(c.w>h.w||c.h>h.h)){if(c.x=h.x,c.y=h.y,l=Math.max(l,c.y+c.h),a=Math.max(a,c.x+c.w),c.w===h.w&&c.h===h.h){const d=s.pop();u>3,a=this.pos;this.type=7&o,i(s,r,this),this.pos===a&&this.skip(o)}return r},readMessage:function(i,r){return this.readFields(i,r,this.readVarint()+this.pos)},readFixed32:function(){var i=lU(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=l6(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=lU(this.buf,this.pos)+4294967296*lU(this.buf,this.pos+4);return this.pos+=8,i},readSFixed64:function(){var i=lU(this.buf,this.pos)+4294967296*l6(this.buf,this.pos+4);return this.pos+=8,i},readFloat:function(){var i=lC(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=lC(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var r,n,o=this.buf;return r=127&(n=o[this.pos++]),n<128?r:(r|=(127&(n=o[this.pos++]))<<7,n<128?r:(r|=(127&(n=o[this.pos++]))<<14,n<128?r:(r|=(127&(n=o[this.pos++]))<<21,n<128?r:function(i,r,n){var o,s,a,l,c=n.buf;if(a=(112&(l=c[n.pos++]))>>4,l<128||(a|=(127&(l=c[n.pos++]))<<3,l<128)||(a|=(127&(l=c[n.pos++]))<<10,l<128)||(a|=(127&(l=c[n.pos++]))<<17,l<128)||(a|=(127&(l=c[n.pos++]))<<24,l<128)||(a|=(1&(l=c[n.pos++]))<<31,l<128))return o=i,s=a,r?4294967296*s+(o>>>0):4294967296*(s>>>0)+(o>>>0);throw Error("Expected varint not more than 10 bytes")}(r|=(15&(n=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?-((i+1)/2):i/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var i,r,n,o=this.readVarint()+this.pos,s=this.pos;return this.pos=o,o-s>=12&&lP?(i=this.buf,r=s,n=o,lP.decode(i.subarray(r,n))):function(i,r,n){for(var o="",s=r;s239?4:u>223?3:u>191?2:1;if(s+d>n)break;1===d?u<128&&(h=u):2===d?128==(192&(a=i[s+1]))&&(h=(31&u)<<6|63&a)<=127&&(h=null):3===d?(l=i[s+2],128==(192&(a=i[s+1]))&&128==(192&l)&&((h=(15&u)<<12|(63&a)<<6|63&l)<=2047||h>=55296&&h<=57343)&&(h=null)):4===d&&(l=i[s+2],c=i[s+3],128==(192&(a=i[s+1]))&&128==(192&l)&&128==(192&c)&&((h=(15&u)<<18|(63&a)<<12|(63&l)<<6|63&c)<=65535||h>=1114112)&&(h=null)),null===h?(h=65533,d=1):h>65535&&(h-=65536,o+=String.fromCharCode(h>>>10&1023|55296),h=56320|1023&h),o+=String.fromCharCode(h),s+=d}return o}(this.buf,s,o)},readBytes:function(){var i=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,i);return this.pos=i,r},readPackedVarint:function(i,r){if(this.type!==lk.Bytes)return i.push(this.readVarint(r));var n=lD(this);for(i=i||[];this.pos127;);else if(r===lk.Bytes)this.pos=this.readVarint()+this.pos;else if(r===lk.Fixed32)this.pos+=4;else{if(r!==lk.Fixed64)throw Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(i,r){this.writeVarint(i<<3|r)},realloc:function(i){for(var r=this.length||16;r268435455||i<0?function(i,r){var n,o,s,a,l,c,u;if(i>=0?(n=i%4294967296|0,o=i/4294967296|0):(o=~(-i/4294967296),4294967295^(n=~(-i%4294967296))?n=n+1|0:(n=0,o=o+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");r.realloc(10),s=n,(a=r).buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,a.buf[a.pos]=127&(s>>>=7),l=o,c=r,u=(7&l)<<4,c.buf[c.pos++]|=u|((l>>>=3)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l)))))}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?-(2*i)-1:2*i)},writeBoolean:function(i){this.writeVarint(Boolean(i))},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var r=this.pos;this.pos=function(i,r,n){for(var o,s,a=0;a55295&&o<57344){if(!s){o>56319||a+1===r.length?(i[n++]=239,i[n++]=191,i[n++]=189):s=o;continue}if(o<56320){i[n++]=239,i[n++]=191,i[n++]=189,s=o;continue}o=s-55296<<10|o-56320|65536,s=null}else s&&(i[n++]=239,i[n++]=191,i[n++]=189,s=null);o<128?i[n++]=o:(o<2048?i[n++]=o>>6|192:(o<65536?i[n++]=o>>12|224:(i[n++]=o>>18|240,i[n++]=o>>12&63|128),i[n++]=o>>6&63|128),i[n++]=63&o|128)}return n}(this.buf,i,this.pos);var n=this.pos-r;n>=128&&lL(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeFloat:function(i){this.realloc(4),lz(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),lz(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var r=i.length;this.writeVarint(r),this.realloc(r);for(var n=0;n=128&&lL(n,o,this),this.pos=n-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,r,n){this.writeTag(i,lk.Bytes),this.writeRawMessage(r,n)},writePackedVarint:function(i,r){r.length&&this.writeMessage(i,l1,r)},writePackedSVarint:function(i,r){r.length&&this.writeMessage(i,lB,r)},writePackedBoolean:function(i,r){r.length&&this.writeMessage(i,lM,r)},writePackedFloat:function(i,r){r.length&&this.writeMessage(i,lR,r)},writePackedDouble:function(i,r){r.length&&this.writeMessage(i,l3,r)},writePackedFixed32:function(i,r){r.length&&this.writeMessage(i,l2,r)},writePackedSFixed32:function(i,r){r.length&&this.writeMessage(i,lF,r)},writePackedFixed64:function(i,r){r.length&&this.writeMessage(i,lO,r)},writePackedSFixed64:function(i,r){r.length&&this.writeMessage(i,l4,r)},writeBytesField:function(i,r){this.writeTag(i,lk.Bytes),this.writeBytes(r)},writeFixed32Field:function(i,r){this.writeTag(i,lk.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(i,r){this.writeTag(i,lk.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(i,r){this.writeTag(i,lk.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(i,r){this.writeTag(i,lk.Fixed64),this.writeSFixed64(r)},writeVarintField:function(i,r){this.writeTag(i,lk.Varint),this.writeVarint(r)},writeSVarintField:function(i,r){this.writeTag(i,lk.Varint),this.writeSVarint(r)},writeStringField:function(i,r){this.writeTag(i,lk.Bytes),this.writeString(r)},writeFloatField:function(i,r){this.writeTag(i,lk.Fixed32),this.writeFloat(r)},writeDoubleField:function(i,r){this.writeTag(i,lk.Fixed64),this.writeDouble(r)},writeBooleanField:function(i,r){this.writeVarintField(i,Boolean(r))}};class l9{constructor(i,{pixelRatio:r,version:n,stretchX:o,stretchY:s,content:a}){this.paddedRect=i,this.pixelRatio=r,this.stretchX=o,this.stretchY=s,this.content=a,this.version=n}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1,]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1,]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio,]}}class l7{constructor(i,r){const n={},o={};this.haveRenderCallbacks=[];const s=[];this.addImages(i,n,s),this.addImages(r,o,s);const{w:a,h:l}=lZ(s),c=new ar({width:a||1,height:l||1});for(const u in i){const h=i[u],d=n[u].paddedRect;ar.copy(h.data,c,{x:0,y:0},{x:d.x+1,y:d.y+1},h.data)}for(const p in r){const f=r[p],m=o[p].paddedRect,g=m.x+1,y=m.y+1,x=f.data.width,$=f.data.height;ar.copy(f.data,c,{x:0,y:0},{x:g,y:y},f.data),ar.copy(f.data,c,{x:0,y:$-1},{x:g,y:y-1},{width:x,height:1}),ar.copy(f.data,c,{x:0,y:0},{x:g,y:y+$},{width:x,height:1}),ar.copy(f.data,c,{x:x-1,y:0},{x:g-1,y:y},{width:1,height:$}),ar.copy(f.data,c,{x:0,y:0},{x:g+x,y:y},{width:1,height:$})}this.image=c,this.iconPositions=n,this.patternPositions=o}addImages(i,r,n){for(const o in i){const s=i[o],a={x:0,y:0,w:s.data.width+2,h:s.data.height+2};n.push(a),r[o]=new l9(a,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(i,r){for(const n in i.dispatchRenderCallbacks(this.haveRenderCallbacks),i.updatedImages)this.patchUpdatedImage(this.iconPositions[n],i.getImage(n),r),this.patchUpdatedImage(this.patternPositions[n],i.getImage(n),r)}patchUpdatedImage(i,r,n){if(!i||!r||i.version===r.version)return;i.version=r.version;const[o,s]=i.tl;n.update(r.data,void 0,{x:o,y:s})}}nr("ImagePosition",l9),nr("ImageAtlas",l7);const lq={horizontal:1,vertical:2,horizontalOnly:3};class l5{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(i,r){const n=new l5;return n.scale=i||1,n.fontStack=r,n}static forImage(i){const r=new l5;return r.imageName=i,r}}class lX{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(i,r){const n=new lX;for(let o=0;o=0&&o>=i&&lH[this.text.charCodeAt(o)];o--)n--;this.text=this.text.substring(i,n),this.sectionIndex=this.sectionIndex.slice(i,n)}substring(i,r){const n=new lX;return n.text=this.text.substring(i,r),n.sectionIndex=this.sectionIndex.slice(i,r),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((i,r)=>Math.max(i,this.sections[r].scale),0)}addTextSection(i,r){this.text+=i.text,this.sections.push(l5.forText(i.scale,i.fontStack||r));const n=this.sections.length-1;for(let o=0;o=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function lW(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y){const x=lX.fromFeature(i,s);let $;p===lq.vertical&&x.verticalizePunctuation(f);const{processBidirectionalText:v,processStyledBidirectionalText:_}=n5;if(v&&1===x.sections.length){$=[];const b=v(x.toString(),ct(x,h,a,r,o,m,g));for(const w of b){const T=new lX;T.text=w,T.sections=x.sections;for(let E=0;E0&&q>A&&(A=q)}else{const X=n[L.fontStack];if(!X)continue;X[R]&&(O=X[R]);const W=r[L.fontStack];if(!W)continue;const H=W.glyphs[R];if(!H)continue;if(F=H.metrics,V=8203!==R?24:0,$){const K=void 0!==W.ascender?Math.abs(W.ascender):0,Y=void 0!==W.descender?Math.abs(W.descender):0,J=(K+Y)*M;k=0;let p=0;for(let f=0;f-n/2;){if(--l<0)return!1;c-=i[l].dist(a),a=i[l]}c+=i[l].dist(i[l+1]),l++;const u=[];let h=0;for(;co;)h-=u.shift().angleDelta;if(h>s)return!1;l++,c+=d.dist(p)}return!0}function cl(i){let r=0;for(let n=0;nh){const g=(h-u)/m,y=i$(p.x,f.x,g),x=i$(p.y,f.y,g),$=new cs(y,x,0,f.angleTo(p),d);return!l||ca(i,$,c,l,r)?$:void 0}u+=m}}function cd(i,r,n,o,s,a,l,c,u){const h=cc(o,a,l),d=cu(o,s),p=d*l,f=0===i[0].x||i[0].x===u||0===i[0].y||i[0].y===u;return r-p=0&&b=0&&w=0&&f+h<=d){const T=new cs(b,w,0,v,g);T._round(),o&&!ca(i,T,a,o,s)||m.push(T)}}p+=$}return c||m.length||l||(m=cp(i,p/2,n,o,s,a,l,!0,u)),m}function cf(i,r,n,o,s){const a=[];for(let c=0;c=o&&f.x>=o||(p.x>=o?p=new l(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round():f.x>=o&&(f=new l(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round()),p.y>=s&&f.y>=s||(p.y>=s?p=new l(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round():f.y>=s&&(f=new l(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round()),h&&p.equals(h[h.length-1])||(h=[p],a.push(h)),h.push(f)))))}}return a}function cm(i,r,n,o,s,a,l,c,u){for(let h=r;h-1)a[++u]=c,l[u]=h,l[u+1]=1e20}for(let f=0,m=0;f{let o=this.entries[i];o||(o=this.entries[i]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=o.glyphs[r];if(void 0!==s)return void n(null,{stack:i,id:r,glyph:s});if(s=this._tinySDF(o,i,r))return o.glyphs[r]=s,void n(null,{stack:i,id:r,glyph:s});const a=Math.floor(r/256);if(256*a>65535)return void n(Error("glyphs > 65535 not supported"));if(o.ranges[a])return void n(null,{stack:i,id:r,glyph:s});let l=o.requests[a];l||(l=o.requests[a]=[],cy.loadGlyphRange(i,a,this.url,this.requestManager,(i,r)=>{if(r){for(const n in o.ascender=r.ascender,o.descender=r.descender,r.glyphs)this._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=r.glyphs[+n]);o.ranges[a]=!0}for(const s of l)s(i,r);delete o.requests[a]})),l.push((o,s)=>{o?n(o):s&&n(null,{stack:i,id:r,glyph:s.glyphs[r]||null})})},(i,n)=>{if(i)r(i);else if(n){const o={};for(const{stack:s,id:a,glyph:l}of n)void 0===o[s]&&(o[s]={}),void 0===o[s].glyphs&&(o[s].glyphs={}),o[s].glyphs[a]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics},o[s].ascender=this.entries[s].ascender,o[s].descender=this.entries[s].descender;r(null,o)}})}_doesCharSupportLocalGlyph(i){return this.localGlyphMode!==cg.none&&(this.localGlyphMode===cg.all?!!this.localFontFamily:!!this.localFontFamily&&(nT(i)||nI(i)||ng(i)||ny(i))||n8(i))}_tinySDF(i,r,n){const o=this.localFontFamily;if(!o||!this._doesCharSupportLocalGlyph(n))return;let s=i.tinySDF;if(!s){let a="400";/bold/i.test(r)?a="900":/medium/i.test(r)?a="500":/light/i.test(r)&&(a="200"),(s=i.tinySDF=new cy.TinySDF({fontFamily:o,fontWeight:a,fontSize:48,buffer:6,radius:16})).fontWeight=a}if(this.localGlyphs[s.fontWeight][n])return this.localGlyphs[s.fontWeight][n];const l=String.fromCharCode(n),{data:c,width:u,height:h,glyphWidth:d,glyphHeight:p,glyphLeft:f,glyphTop:m,glyphAdvance:g}=s.draw(l);return this.localGlyphs[s.fontWeight][n]={id:n,bitmap:new ai({width:u,height:h},c),metrics:{width:d/2,height:p/2,left:f/2,top:m/2-27,advance:g/2,localGlyph:!0}}}}function cx(i,r,n,o){const s=[],a=i.image,c=a.pixelRatio,u=a.paddedRect.w-2,h=a.paddedRect.h-2,d=i.right-i.left,p=i.bottom-i.top,f=a.stretchX||[[0,u]],m=a.stretchY||[[0,h]],g=(i,r)=>i+r[1]-r[0],y=f.reduce(g,0),x=m.reduce(g,0),$=u-y,v=h-x;let _=0,b=y,w=0,T=x,E=0,S=$,I=0,C=v;if(a.content&&o){const z=a.content;_=c$(f,0,z[0]),w=c$(m,0,z[1]),b=c$(f,z[0],z[2]),T=c$(m,z[1],z[3]),E=z[0]-_,I=z[1]-w,S=z[2]-z[0]-b,C=z[3]-z[1]-T}const A=(o,s,u,h)=>{var f,m,g,$,v,z,A,k,P,D,L,B,R,M,F,O,U,V,j,N,G,Z,q,X,W,H,K,Y;const J=(f=o.stretch-_,m=b,g=d,f/m*g+i.left),Q=($=o.fixed-E,v=S,z=o.stretch,A=y,$-v*z/A),ee=(k=s.stretch-w,P=T,D=p,k/P*D+i.top),et=(L=s.fixed-I,B=C,R=s.stretch,M=x,L-B*R/M),ei=(F=u.stretch-_,O=b,U=d,F/O*U+i.left),er=(V=u.fixed-E,j=S,N=u.stretch,G=y,V-j*N/G),en=(Z=h.stretch-w,q=T,X=p,Z/q*X+i.top),eo=(W=h.fixed-I,H=C,K=h.stretch,Y=x,W-H*K/Y),es=new l(J,ee),ea=new l(ei,ee),el=new l(ei,en),ec=new l(J,en),eu=new l(Q/c,et/c),eh=new l(er/c,eo/c),ed=r*Math.PI/180;if(ed){const ep=Math.sin(ed),ef=Math.cos(ed),em=[ef,-ep,ep,ef];es._matMult(em),ea._matMult(em),ec._matMult(em),el._matMult(em)}const e8=o.stretch+o.fixed,eg=s.stretch+s.fixed;return{tl:es,tr:ea,bl:ec,br:el,tex:{x:a.paddedRect.x+1+e8,y:a.paddedRect.y+1+eg,w:u.stretch+u.fixed-e8,h:h.stretch+h.fixed-eg},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:eu,pixelOffsetBR:eh,minFontScaleX:S/c/d,minFontScaleY:C/c/p,isSDF:n}};if(o&&(a.stretchX||a.stretchY)){const k=cv(f,$,y),P=cv(m,v,x);for(let D=0;D{if(i)s(i);else if(r){var n;const o={},a=(n=r,new lA(n).readFields(lj,{}));for(const l of a.glyphs)o[l.id]=l;s(null,{glyphs:o,ascender:a.ascender,descender:a.descender})}})},cy.TinySDF=class{constructor({fontSize:i=24,buffer:r=3,radius:n=8,cutoff:o=.25,fontFamily:s="sans-serif",fontWeight:a="normal",fontStyle:l="normal"}){this.buffer=r,this.cutoff=o,this.radius=n;const c=this.size=i+4*r,u=this._createCanvas(c),h=this.ctx=u.getContext("2d",{willReadFrequently:!0});h.font=`${l} ${a} ${i}px ${s}`,h.textBaseline="alphabetic",h.textAlign="left",h.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(i){const r=document.createElement("canvas");return r.width=r.height=i,r}draw(i){const{width:r,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:s,actualBoundingBoxRight:a}=this.ctx.measureText(i),l=Math.floor(n),c=Math.min(this.size-this.buffer,Math.ceil(a-s)),u=Math.min(this.size-this.buffer,Math.ceil(n)+Math.ceil(o)),h=c+2*this.buffer,d=u+2*this.buffer,p=h*d,f=new Uint8ClampedArray(p),m={data:f,width:h,height:d,glyphWidth:c,glyphHeight:u,glyphTop:l,glyphLeft:0,glyphAdvance:r};if(0===c||0===u)return m;const{ctx:g,buffer:y,gridInner:x,gridOuter:$}=this;g.clearRect(y,y,c,u),g.fillText(i,y,y+l+1);const v=g.getImageData(y,y,c,u);$.fill(1e20,0,p),x.fill(0,0,p);for(let _=0;_0?E*E:0,x[T]=E<0?E*E:0}}cm($,0,0,h,d,h,this.f,this.v,this.z),cm(x,y,y,c,u,h,this.f,this.v,this.z);for(let S=0;Sr?1:0}){if(this.data=i,this.length=this.data.length,this.compare=r,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const i=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:r,compare:n}=this,o=r[i];for(;i>0;){const s=i-1>>1,a=r[s];if(n(o,a)>=0)break;r[i]=a,i=s}r[i]=o}_down(i){const{data:r,compare:n}=this,o=this.length>>1,s=r[i];for(;in(r[c],l)&&(a=c,l=r[c]),n(l,s)>=0)break;r[i]=l,i=a}r[i]=s}}function cw(i,r=1,n=!1){let o=1/0,s=1/0,a=-1/0,c=-1/0;const u=i[0];for(let h=0;ha)&&(a=d.x),(!h||d.y>c)&&(c=d.y)}const p=Math.min(a-o,c-s);let f=p/2;const m=new cb([],c0);if(0===p)return new l(o,s);for(let g=o;gx.d||!x.d)&&(x=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,$)),v.max-x.d<=r||(f=v.h/2,m.push(new cT(v.p.x-f,v.p.y-f,f,i)),m.push(new cT(v.p.x+f,v.p.y-f,f,i)),m.push(new cT(v.p.x-f,v.p.y+f,f,i)),m.push(new cT(v.p.x+f,v.p.y+f,f,i)),$+=4)}return n&&(console.log(`num probes: ${$}`),console.log(`best distance: ${x.d}`)),x.p}function c0(i,r){return r.max-i.max}function cT(i,r,n,o){this.p=new l(i,r),this.h=n,this.d=function(i,r){let n=!1,o=1/0;for(let s=0;si.y!=d.y>i.y&&i.x<(d.x-h.x)*(i.y-h.y)/(d.y-h.y)+h.x&&(n=!n),o=Math.min(o,sO(i,h,d))}}return(n?1:-1)*Math.sqrt(o)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}const cE=Number.POSITIVE_INFINITY,cS=Math.sqrt(2);function cI(i,r){return r[1]!==cE?function(i,r,n){let o=0,s=0;switch(r=Math.abs(r),n=Math.abs(n),i){case"top-right":case"top-left":case"top":s=n-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-n}switch(i){case"top-right":case"bottom-right":case"right":o=-r;break;case"top-left":case"bottom-left":case"left":o=r}return[o,s]}(i,r[0],r[1]):function(i,r){let n=0,o=0;r<0&&(r=0);const s=r/cS;switch(i){case"top-right":case"top-left":o=s-7;break;case"bottom-right":case"bottom-left":o=7-s;break;case"bottom":o=7-r;break;case"top":o=r-7}switch(i){case"top-right":case"bottom-right":n=-s;break;case"top-left":case"bottom-left":n=s;break;case"left":n=r;break;case"right":n=-r}return[n,o]}(i,r[0])}function cC(i,r,n,o,s,a,l,c,u,h){i.createArrays(),i.tilePixelRatio=8192/(512*i.overscaling),i.compareText={},i.iconsNeedLinear=!1;const d=i.layers[0].layout,p=i.layers[0]._unevaluatedLayout._values,f={};if("composite"===i.textSizeData.kind){const{minZoom:m,maxZoom:g}=i.textSizeData;f.compositeTextSizes=[p["text-size"].possiblyEvaluate(new nX(m),c),p["text-size"].possiblyEvaluate(new nX(g),c),]}if("composite"===i.iconSizeData.kind){const{minZoom:y,maxZoom:x}=i.iconSizeData;f.compositeIconSizes=[p["icon-size"].possiblyEvaluate(new nX(y),c),p["icon-size"].possiblyEvaluate(new nX(x),c),]}f.layoutTextSize=p["text-size"].possiblyEvaluate(new nX(u+1),c),f.layoutIconSize=p["icon-size"].possiblyEvaluate(new nX(u+1),c),f.textMaxSize=p["text-size"].possiblyEvaluate(new nX(18),c);const $="map"===d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),v=d.get("text-size");for(const _ of i.features){const b=d.get("text-font").evaluate(_,{},c).join(","),w=v.evaluate(_,{},c),T=f.layoutTextSize.evaluate(_,{},c),E=(f.layoutIconSize.evaluate(_,{},c),{horizontal:{},vertical:void 0}),S=_.text;let I,C=[0,0];if(S){const z=S.toString(),A=24*d.get("text-letter-spacing").evaluate(_,{},c),k=24*d.get("text-line-height").evaluate(_,{},c),P=nB(z)?A:0,D=d.get("text-anchor").evaluate(_,{},c),L=d.get("text-variable-anchor");if(!L){const B=d.get("text-radial-offset").evaluate(_,{},c);C=B?cI(D,[24*B,cE]):d.get("text-offset").evaluate(_,{},c).map(i=>24*i)}let R=$?"center":d.get("text-justify").evaluate(_,{},c);const M=d.get("symbol-placement"),F="point"===M,O="point"===M?24*d.get("text-max-width").evaluate(_,{},c):0,U=o=>{i.allowVerticalPlacement&&n1(z)&&(E.vertical=lW(S,r,n,s,b,O,k,D,o,P,C,lq.vertical,!0,M,T,w))};if(!$&&L){const V="auto"===R?L.map(i=>cz(i)):[R];let j=!1;for(let N=0;N=0||!n1(z)){const q=lW(S,r,n,s,b,O,k,D,R,P,C,lq.horizontal,!1,M,T,w);q&&(E.horizontal[R]=q)}U("point"===M?"left":R)}}let X=!1;if(_.icon&&_.icon.name){const W=o[_.icon.name];W&&(I=cn(s[_.icon.name],d.get("icon-offset").evaluate(_,{},c),d.get("icon-anchor").evaluate(_,{},c)),X=W.sdf,void 0===i.sdfIcons?i.sdfIcons=W.sdf:i.sdfIcons!==W.sdf&&ep("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(W.pixelRatio!==i.pixelRatio||0!==d.get("icon-rotate").constantOr(1))&&(i.iconsNeedLinear=!0))}const H=cD(E.horizontal)||E.vertical;i.iconsInText||(i.iconsInText=!!H&&H.iconsInText),(H||I)&&cA(i,_,E,I,o,f,T,0,C,X,l,c,h)}a&&i.generateCollisionDebugBuffers(u,i.collisionBoxArray)}function cz(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 cA(i,r,n,o,s,a,l,c,u,h,d,p,f){let m=a.textMaxSize.evaluate(r,{},p);void 0===m&&(m=l);const g=i.layers[0].layout,y=g.get("icon-offset").evaluate(r,{},p),x=cD(n.horizontal)||n.vertical,$=l/24,v=i.tilePixelRatio*m/24,_=i.tilePixelRatio*g.get("symbol-spacing"),b=g.get("text-padding")*i.tilePixelRatio,w=g.get("icon-padding")*i.tilePixelRatio,T=g.get("text-max-angle")*j,E="map"===g.get("text-rotation-alignment")&&"point"!==g.get("symbol-placement"),S="map"===g.get("icon-rotation-alignment")&&"point"!==g.get("symbol-placement"),I=g.get("symbol-placement"),C=_/2,z=g.get("icon-text-fit");let A;o&&"none"!==z&&(i.allowVerticalPlacement&&n.vertical&&(A=co(o,n.vertical,z,g.get("icon-text-fit-padding"),y,$)),x&&(o=co(o,x,z,g.get("icon-text-fit-padding"),y,$)));const k=(l,c,m)=>{if(c.x<0||c.x>=8192||c.y<0||c.y>=8192)return;const{x:g,y:x,z:$}=f.projectTilePoint(c.x,c.y,m),v=new cs(g,x,$,0,void 0);!function(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$,v,_,b,w,T,E,S){const I=i.addToLineVertexArray(r,o);let C,z,A,k,P,D,L,B=0,R=0,M=0,F=0,O=-1,U=-1;const V={};let j=oZ(""),N=0,G=0;if(void 0===u._unevaluatedLayout.getValue("text-radial-offset")?[N,G]=u.layout.get("text-offset").evaluate(b,{},S).map(i=>24*i):(N=24*u.layout.get("text-radial-offset").evaluate(b,{},S),G=cE),i.allowVerticalPlacement&&s.vertical){const Z=s.vertical;if(g)D=c1(Z),c&&(L=c1(c));else{const q=u.layout.get("text-rotate").evaluate(b,{},S)+90;A=cL(h,n,r,d,p,f,Z,m,q,y),c&&(k=cL(h,n,r,d,p,f,c,$,q))}}if(a){const X=u.layout.get("icon-rotate").evaluate(b,{},S),W="none"!==u.layout.get("icon-text-fit"),H=cx(a,X,T,W),K=c?cx(c,X,T,W):void 0;z=cL(h,n,r,d,p,f,a,$,X),B=4*H.length;const Y=i.iconSizeData;let J=null;"source"===Y.kind?(J=[128*u.layout.get("icon-size").evaluate(b,{},S),])[0]>ck&&ep(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Y.kind&&((J=[128*w.compositeIconSizes[0].evaluate(b,{},S),128*w.compositeIconSizes[1].evaluate(b,{},S),])[0]>ck||J[1]>ck)&&ep(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),i.addSymbols(i.icon,H,J,_,v,b,!1,n,r,I.lineStartIndex,I.lineLength,-1,E,S),O=i.icon.placedSymbolArray.length-1,K&&(R=4*K.length,i.addSymbols(i.icon,K,J,_,v,b,lq.vertical,n,r,I.lineStartIndex,I.lineLength,-1,E,S),U=i.icon.placedSymbolArray.length-1)}for(const Q in s.horizontal){const ee=s.horizontal[Q];C||(j=oZ(ee.text),g?P=c1(ee):C=cL(h,n,r,d,p,f,ee,m,u.layout.get("text-rotate").evaluate(b,{},S),y));const et=1===ee.positionedLines.length;if(M+=cP(i,n,r,ee,l,u,g,b,y,I,s.vertical?lq.horizontal:lq.horizontalOnly,et?Object.keys(s.horizontal):[Q],V,O,w,E,S),et)break}s.vertical&&(F+=cP(i,n,r,s.vertical,l,u,g,b,y,I,lq.vertical,["vertical"],V,U,w,E,S));let ei=-1;const er=(i,r)=>i?Math.max(i,r):r;ei=er(P,ei),ei=er(D,ei),ei=er(L,ei);const en=ei>-1?1:0;i.glyphOffsetArray.length>=cU.MAX_GLYPHS&&ep("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&i.addToSortKeyRanges(i.symbolInstances.length,b.sortKey),i.symbolInstances.emplaceBack(n.x,n.y,n.z,r.x,r.y,V.right>=0?V.right:-1,V.center>=0?V.center:-1,V.left>=0?V.left:-1,V.vertical>=0?V.vertical:-1,O,U,j,void 0!==C?C:i.collisionBoxArray.length,void 0!==C?C+1:i.collisionBoxArray.length,void 0!==A?A:i.collisionBoxArray.length,void 0!==A?A+1:i.collisionBoxArray.length,void 0!==z?z:i.collisionBoxArray.length,void 0!==z?z+1:i.collisionBoxArray.length,k||i.collisionBoxArray.length,k?k+1:i.collisionBoxArray.length,d,M,F,B,R,en,0,N,G,ei)}(i,c,v,l,n,o,s,A,i.layers[0],i.collisionBoxArray,r.index,r.sourceLayerIndex,i.index,b,E,u,0,w,S,y,r,a,h,d,p)};if("line"===I)for(const P of cf(r.geometry,0,0,8192,8192)){const D=cd(P,_,T,n.vertical||x,o,24,v,i.overscaling,8192);for(const L of D){const B=x;B&&cB(i,B.text,C,L)||k(P,L,p)}}else if("line-center"===I){for(const R of r.geometry)if(R.length>1){const M=ch(R,T,n.vertical||x,o,24,v);M&&k(R,M,p)}}else if("Polygon"===r.type)for(const F of a3(r.geometry,0)){const O=cw(F,16);k(F[0],new cs(O.x,O.y,0,0,void 0),p)}else if("LineString"===r.type)for(const U of r.geometry)k(U,new cs(U[0].x,U[0].y,0,0,void 0),p);else if("Point"===r.type)for(const V of r.geometry)for(const N of V)k([N],new cs(N.x,N.y,0,0,void 0),p)}const ck=32640;function cP(i,r,n,o,s,a,c,u,h,d,p,f,m,g,y,x,$){const v=function(i,r,n,o,s,a,c,u){const h=[];if(0===r.positionedLines.length)return h;const d=o.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,p=function(i){const r=i[0],n=i[1],o=r*n;return o>0?[r,-n]:o<0?[-r,n]:0===r?[n,r]:[n,-r]}(n);let f=Math.abs(r.top-r.bottom);for(const m of r.positionedLines)f-=m.lineOffset;const g=r.positionedLines.length,y=f/g;let x=r.top-n[1];for(let $=0;$ck&&ep(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===_.kind&&((b=[128*y.compositeTextSizes[0].evaluate(u,{},$),128*y.compositeTextSizes[1].evaluate(u,{},$),])[0]>ck||b[1]>ck)&&ep(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),i.addSymbols(i.text,v,b,h,c,u,p,r,n,d.lineStartIndex,d.lineLength,g,x,$),f))m[w]=i.text.placedSymbolArray.length-1;return 4*v.length}function cD(i){for(const r in i)return i[r];return null}function cL(i,r,n,o,s,a,c,u,h,d){let p=c.top,f=c.bottom,m=c.left,g=c.right;const y=c.collisionPadding;if(y&&(m-=y[0],p-=y[1],g+=y[2],f+=y[3]),h){const x=new l(m,p),$=new l(g,p),v=new l(m,f),_=new l(g,f),b=h*j;let w=new l(0,0);d&&(w=new l(d[0],d[1])),x._rotateAround(b,w),$._rotateAround(b,w),v._rotateAround(b,w),_._rotateAround(b,w),m=Math.min(x.x,$.x,v.x,_.x),g=Math.max(x.x,$.x,v.x,_.x),p=Math.min(x.y,$.y,v.y,_.y),f=Math.max(x.y,$.y,v.y,_.y)}return i.emplaceBack(r.x,r.y,r.z,n.x,n.y,m,p,g,f,u,o,s,a),i.length-1}function c1(i){i.collisionPadding&&(i.top-=i.collisionPadding[1],i.bottom+=i.collisionPadding[3]);const r=i.bottom-i.top;return r>0?Math.max(10,r):null}function cB(i,r,n,o){const s=i.compareText;if(r in s){const a=s[r];for(let l=a.length-1;l>=0;l--)if(o.dist(a[l])i.id),this.index=i.index,this.pixelRatio=i.pixelRatio,this.sourceLayerIndex=i.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=p([]),this.placementViewportMatrix=p([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=l_(this.zoom,r["text-size"]),this.iconSizeData=l_(this.zoom,r["icon-size"]);const n=this.layers[0].layout,o=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&void 0!==o.constantOr(1),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(i=>lq[i]),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.sourceID=i.sourceID}createArrays(){this.text=new cO(new sa(this.layers,this.zoom,i=>/^text/.test(i))),this.icon=new cO(new sa(this.layers,this.zoom,i=>/^icon/.test(i))),this.glyphOffsetArray=new o2,this.lineVertexArray=new oF,this.symbolInstances=new oM}calculateGlyphDependencies(i,r,n,o,s){for(let a=0;a0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,p=a.get("symbol-sort-key");if(this.features=[],!h&&!d)return;const f=r.iconDependencies,m=r.glyphDependencies,g=r.availableImages,y=new nX(this.zoom);for(const{feature:x,id:$,index:v,sourceLayerIndex:_}of i){const b=s._featureFilter.needGeometry,w=sP(x,b);if(!s._featureFilter.filter(y,w,n))continue;let T,E;if(b||(w.geometry=sk(x,n,o)),h){const S=s.getValueAndResolveTokens("text-field",w,n,g),I=t3.factory(S);cF(I)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===n7()||this.hasRTLText&&n5.isParsed())&&(T=lT(I,s,w))}if(d){const C=s.getValueAndResolveTokens("icon-image",w,n,g);E=C instanceof tM?C:tM.fromString(C)}if(!T&&!E)continue;const z=this.sortFeaturesByKey?p.evaluate(w,{},n):void 0;if(this.features.push({id:$,text:T,icon:E,index:v,sourceLayerIndex:_,geometry:w.geometry,properties:x.properties,type:cR[x.type],sortKey:z}),E&&(f[E.name]=!0),T){const A=l.evaluate(w,{},n).join(","),k="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");for(const P of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(lq.vertical)>=0,T.sections))if(P.image)f[P.image.name]=!0;else{const D=n1(T.toString()),L=P.fontStack||A,B=m[L]=m[L]||{};this.calculateGlyphDependencies(P.text,B,k,this.allowVerticalPlacement,D)}}}"line"===a.get("symbol-placement")&&(this.features=function(i){const r={},n={},o=[];let s=0;function a(r){o.push(i[r]),s++}function l(i,r,s){const a=n[i];return delete n[i],n[r]=a,o[a].geometry[0].pop(),o[a].geometry[0]=o[a].geometry[0].concat(s[0]),a}function c(i,n,s){const a=r[n];return delete r[n],r[i]=a,o[a].geometry[0].shift(),o[a].geometry[0]=s[0].concat(o[a].geometry[0]),a}function u(i,r,n){const o=n?r[0][r[0].length-1]:r[0][0];return`${i}:${o.x}:${o.y}`}for(let h=0;hi.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((i,r)=>i.sortKey-r.sortKey)}update(i,r,n,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(i,r,this.layers,n,o),this.icon.programConfigurations.updatePaintArrays(i,r,this.layers,n,o))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(i),this.iconCollisionBox.upload(i)),this.text.upload(i,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(i,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(i,r){const n=this.lineVertexArray.length;if(void 0!==i.segment){let o=i.dist(r[i.segment+1]),s=i.dist(r[i.segment]);const a={};for(let l=i.segment+1;l=0;c--)a[c]={x:r[c].x,y:r[c].y,tileUnitDistanceFromAnchor:s},c>0&&(s+=r[c-1].dist(r[c]));for(let u=0;u=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:o),a=lb(this.textSizeData,i,s)/24;return this.tilePixelRatio*a}getSymbolInstanceIconSize(i,r,n){const o=this.icon.placedSymbolArray.get(n),s=lb(this.iconSizeData,i,o);return this.tilePixelRatio*s}_commitDebugCollisionVertexUpdate(i,r,n){i.emplaceBack(r,-n,-n),i.emplaceBack(r,n,-n),i.emplaceBack(r,n,n),i.emplaceBack(r,-n,n)}_updateTextDebugCollisionBoxes(i,r,n,o,s,a){for(let l=o;l0}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(i,r){const n=i.placedSymbolArray.get(r),o=n.vertexStartIndex+4*n.numGlyphs;for(let s=n.vertexStartIndex;so[i]-o[r]||s[r]-s[i]),a}addToSortKeyRanges(i,r){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===r?n.symbolInstanceEnd=i+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:i+1})}sortFeatures(i){if(this.sortFeaturesByY&&this.sortedAngle!==i&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const r of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(i),this.sortedAngle=i,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const n=this.symbolInstances.get(r);this.featureSortOrder.push(n.featureIndex),[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex,].forEach((i,r,n)=>{i>=0&&n.indexOf(i)===r&&this.addIndicesForPlacedSymbol(this.text,i)}),n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}nr("SymbolBucket",cU,{omit:["layers","collisionBoxArray","features","compareText",]}),cU.MAX_GLYPHS=65535,cU.addDynamicAttributes=c2;const cV=new os({"symbol-placement":new ot(th.layout_symbol["symbol-placement"]),"symbol-spacing":new ot(th.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new ot(th.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new oi(th.layout_symbol["symbol-sort-key"]),"symbol-z-order":new ot(th.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new ot(th.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new ot(th.layout_symbol["icon-ignore-placement"]),"icon-optional":new ot(th.layout_symbol["icon-optional"]),"icon-rotation-alignment":new ot(th.layout_symbol["icon-rotation-alignment"]),"icon-size":new oi(th.layout_symbol["icon-size"]),"icon-text-fit":new ot(th.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ot(th.layout_symbol["icon-text-fit-padding"]),"icon-image":new oi(th.layout_symbol["icon-image"]),"icon-rotate":new oi(th.layout_symbol["icon-rotate"]),"icon-padding":new ot(th.layout_symbol["icon-padding"]),"icon-keep-upright":new ot(th.layout_symbol["icon-keep-upright"]),"icon-offset":new oi(th.layout_symbol["icon-offset"]),"icon-anchor":new oi(th.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new ot(th.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new ot(th.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new ot(th.layout_symbol["text-rotation-alignment"]),"text-field":new oi(th.layout_symbol["text-field"]),"text-font":new oi(th.layout_symbol["text-font"]),"text-size":new oi(th.layout_symbol["text-size"]),"text-max-width":new oi(th.layout_symbol["text-max-width"]),"text-line-height":new oi(th.layout_symbol["text-line-height"]),"text-letter-spacing":new oi(th.layout_symbol["text-letter-spacing"]),"text-justify":new oi(th.layout_symbol["text-justify"]),"text-radial-offset":new oi(th.layout_symbol["text-radial-offset"]),"text-variable-anchor":new ot(th.layout_symbol["text-variable-anchor"]),"text-anchor":new oi(th.layout_symbol["text-anchor"]),"text-max-angle":new ot(th.layout_symbol["text-max-angle"]),"text-writing-mode":new ot(th.layout_symbol["text-writing-mode"]),"text-rotate":new oi(th.layout_symbol["text-rotate"]),"text-padding":new ot(th.layout_symbol["text-padding"]),"text-keep-upright":new ot(th.layout_symbol["text-keep-upright"]),"text-transform":new oi(th.layout_symbol["text-transform"]),"text-offset":new oi(th.layout_symbol["text-offset"]),"text-allow-overlap":new ot(th.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new ot(th.layout_symbol["text-ignore-placement"]),"text-optional":new ot(th.layout_symbol["text-optional"])});var c6={paint:new os({"icon-opacity":new oi(th.paint_symbol["icon-opacity"]),"icon-color":new oi(th.paint_symbol["icon-color"]),"icon-halo-color":new oi(th.paint_symbol["icon-halo-color"]),"icon-halo-width":new oi(th.paint_symbol["icon-halo-width"]),"icon-halo-blur":new oi(th.paint_symbol["icon-halo-blur"]),"icon-translate":new ot(th.paint_symbol["icon-translate"]),"icon-translate-anchor":new ot(th.paint_symbol["icon-translate-anchor"]),"text-opacity":new oi(th.paint_symbol["text-opacity"]),"text-color":new oi(th.paint_symbol["text-color"],{runtimeType:tb,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new oi(th.paint_symbol["text-halo-color"]),"text-halo-width":new oi(th.paint_symbol["text-halo-width"]),"text-halo-blur":new oi(th.paint_symbol["text-halo-blur"]),"text-translate":new ot(th.paint_symbol["text-translate"]),"text-translate-anchor":new ot(th.paint_symbol["text-translate-anchor"])}),layout:cV};class cj{constructor(i){this.type=i.property.overrides?i.property.overrides.runtimeType:tx,this.defaultValue=i}evaluate(i){if(i.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(i.formattedSection))return r.getOverride(i.formattedSection)}return i.feature&&i.featureState?this.defaultValue.evaluate(i.feature,i.featureState):this.defaultValue.property.specification.default}eachChild(i){this.defaultValue.isConstant()||i(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}nr("FormatSectionOverride",cj,{omit:["defaultValue"]});class cN extends sf{constructor(i){super(i,c6)}recalculate(i,r){super.recalculate(i,r),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const n=this.layout.get("text-writing-mode");if(n){const o=[];for(const s of n)0>o.indexOf(s)&&o.push(s);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(i,r,n,o){var s;const a=this.layout.get(i).evaluate(r,{},n,o),l=this._unevaluatedLayout._values[i];return l.isDataDriven()||rh(l.value)||!a?a:(s=r.properties,a.replace(/{([^{}]+)}/g,(i,r)=>r in s?String(s[r]):""))}createBucket(i){return new cU(i)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const i of c6.paint.overridableProperties){if(!cN.hasPaintOverride(this.layout,i))continue;const r=this.paint.get(i),n=new cj(r),o=new ru(n,r.property.specification);let s=null;s="constant"===r.value.kind||"source"===r.value.kind?new rp("source",o):new rf("composite",o,r.value.zoomStops,r.value._interpolationType),this.paint._values[i]=new nQ(r.property,s,r.parameters)}}_handleOverridablePaintPropertyUpdate(i,r,n){return!(!this.layout||r.isDataDriven()||n.isDataDriven())&&cN.hasPaintOverride(this.layout,i)}static hasPaintOverride(i,r){const n=i.get("text-field"),o=c6.paint.properties[r];let s=!1;const a=i=>{for(const r of i)if(o.overrides&&o.overrides.hasOverride(r))return void(s=!0)};if("constant"===n.value.kind&&n.value.value instanceof t3)a(n.value.value.sections);else if("source"===n.value.kind){const l=i=>{s||(i instanceof tU&&tO(i.value)===tE?a(i.value.sections):i instanceof tN?a(i.sections):i.eachChild(l))},c=n.value;c._styleExpression&&l(c._styleExpression.expression)}return s}getProgramConfiguration(i){return new ss(this,i)}}var cG={paint:new os({"background-color":new ot(th.paint_background["background-color"]),"background-pattern":new on(th.paint_background["background-pattern"]),"background-opacity":new ot(th.paint_background["background-opacity"])})},cZ={paint:new os({"raster-opacity":new ot(th.paint_raster["raster-opacity"]),"raster-hue-rotate":new ot(th.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new ot(th.paint_raster["raster-brightness-min"]),"raster-brightness-max":new ot(th.paint_raster["raster-brightness-max"]),"raster-saturation":new ot(th.paint_raster["raster-saturation"]),"raster-contrast":new ot(th.paint_raster["raster-contrast"]),"raster-resampling":new ot(th.paint_raster["raster-resampling"]),"raster-fade-duration":new ot(th.paint_raster["raster-fade-duration"])})};class c9 extends sf{constructor(i){super(i,{}),this.implementation=i}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(i){this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)}onRemove(i){this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)}}var c7={paint:new os({"sky-type":new ot(th.paint_sky["sky-type"]),"sky-atmosphere-sun":new ot(th.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new ot(th.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new ot(th.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new ot(th.paint_sky["sky-gradient-radius"]),"sky-gradient":new oo(th.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new ot(th.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new ot(th.paint_sky["sky-atmosphere-color"]),"sky-opacity":new ot(th.paint_sky["sky-opacity"])})};function cq(i,r,n){var o,s,a,l,c,u,h,d,p;const f=w(0,0,1),m=O(F());return o=m,s=m,a=n?-(i*j)+Math.PI:i*j,a*=.5,l=s[0],c=s[1],u=s[2],h=s[3],d=Math.sin(a),p=Math.cos(a),o[0]=l*p-u*d,o[1]=c*p+h*d,o[2]=u*p+l*d,o[3]=h*p-c*d,U(m,m,-(r*j)),L(f,f,m),A(f,f)}const c5={circle:class extends sf{constructor(i){super(i,s7)}createBucket(i){return new sL(i)}queryRadius(i){const r=i;return sj("circle-radius",this,r)+sj("circle-stroke-width",this,r)+sN(this.paint.get("circle-translate"))}queryIntersectsFeature(i,r,n,o,s,a,l,c){const u=sZ(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),h=this.paint.get("circle-radius").evaluate(r,n)+this.paint.get("circle-stroke-width").evaluate(r,n);return sX(i,o,a,l,c,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),u,h)}getProgramIds(){return["circle"]}getProgramConfiguration(i){return new ss(this,i)}},heatmap:class extends sf{createBucket(i){return new sJ(i)}constructor(i){super(i,an),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){"heatmap-color"===i&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=ao({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(i){return sj("heatmap-radius",this,i)}queryIntersectsFeature(i,r,n,o,s,a,c,u){const h=this.paint.get("heatmap-radius").evaluate(r,n);return sX(i,o,a,c,u,!0,!0,new l(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(i){return new ss(this,i)}},hillshade:class extends sf{constructor(i){super(i,as)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare",]}getProgramConfiguration(i){return new ss(this,i)}},fill:class extends sf{constructor(i){super(i,aU)}getProgramIds(){const i=this.paint.get("fill-pattern"),r=i&&i.constantOr(1),n=[r?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(r&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(i){return new ss(this,i)}recalculate(i,r){super.recalculate(i,r);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new aO(i)}queryRadius(){return sN(this.paint.get("fill-translate"))}queryIntersectsFeature(i,r,n,o,s,a){return!i.queryGeometry.isAboveHorizon&&sR(sG(i.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),o)}isTileClipped(){return!0}},"fill-extrusion":class extends sf{constructor(i){super(i,le)}createBucket(i){return new aJ(i)}queryRadius(){return sN(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion",]}getProgramConfiguration(i){return new ss(this,i)}queryIntersectsFeature(i,r,n,o,s,a,c,u,h){var d,p,f,m,g,y,x,$,v;const _=sZ(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),b=this.paint.get("fill-extrusion-height").evaluate(r,n),w=this.paint.get("fill-extrusion-base").evaluate(r,n),T=[0,0],E=u&&a.elevation,S=a.elevation?a.elevation.exaggeration():1;if(E){const I=i.tile.getBucket(this).centroidVertexArray,C=h+1;if(C=3){for(let a=0;a1&&(c=i[++l]);const h=Math.abs(u-c.left),d=Math.abs(u-c.right),p=Math.min(h,d);let f;const m=s/n*(o+1);if(c.isDash){const g=o-Math.abs(m);f=Math.sqrt(p*p+g*g)}else f=o-Math.sqrt(p*p+m*m);this.image.data[a+u]=Math.max(0,Math.min(255,f+128))}}}addRegularDash(i,r){for(let n=i.length-1;n>=0;--n){const o=i[n],s=i[n+1];o.zeroLength?i.splice(n,1):s&&s.isDash===o.isDash&&(s.left=o.left,i.splice(n,1))}const a=i[0],l=i[i.length-1];a.isDash===l.isDash&&(a.left=l.left-this.width,l.right=a.right+this.width);const c=this.width*this.nextRow;let u=0,h=i[u];for(let d=0;d1&&(h=i[++u]);const p=Math.abs(d-h.left),f=Math.abs(d-h.right),m=Math.min(p,f);this.image.data[c+d]=Math.max(0,Math.min(255,(h.isDash?m:-m)+r+128))}}addDash(i,r){const n=this.getKey(i,r);if(this.positions[n])return this.positions[n];const o="round"===r,s=o?7:0,a=2*s+1;if(this.nextRow+a>this.height)return ep("LineAtlas out of space"),null;0===i.length&&i.push(1);let l=0;for(let c=0;c0;a--)s+=(r&(o=1<this.canonical.z?new uo(i,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new uo(i,this.wrap,i,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(i,r=!0){if(this.overscaledZ===i&&r)return this.key;if(i>this.canonical.z)return us(this.wrap*+r,i,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-i;return us(this.wrap*+r,i,i,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(i){if(i.wrap!==this.wrap)return!1;const r=this.canonical.z-i.canonical.z;return 0===i.overscaledZ||i.overscaledZ>r&&i.canonical.y===this.canonical.y>>r}children(i){if(this.overscaledZ>=i)return[new uo(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y),];const r=this.canonical.z+1,n=2*this.canonical.x,o=2*this.canonical.y;return[new uo(r,this.wrap,r,n,o),new uo(r,this.wrap,r,n+1,o),new uo(r,this.wrap,r,n,o+1),new uo(r,this.wrap,r,n+1,o+1),]}isLessThan(i){return this.wrapi.wrap)&&(this.overscaledZi.overscaledZ)&&(this.canonical.xi.canonical.x)&&this.canonical.yMath.abs(o[l])){if(n[l]r[l])return null}else{const c=1/o[l];let u=(i[l]-n[l])*c,h=(r[l]-n[l])*c;if(u>h){const d=u;u=h,h=d}if(u>s&&(s=u),ha)return null}return s}function um(i,r,n,o,s,a,l,c,u,h,d){const p=o-i,f=s-r,m=a-n,g=l-i,y=c-r,x=u-n,$=d[1]*x-d[2]*y,v=d[2]*g-d[0]*x,_=d[0]*y-d[1]*g,b=p*$+f*v+m*_;if(1e-15>Math.abs(b))return null;const w=1/b,T=h[0]-i,E=h[1]-r,S=h[2]-n,I=(T*$+E*v+S*_)*w;if(I<0||I>1)return null;const C=E*m-S*f,z=S*p-T*m,A=T*f-E*p,k=(d[0]*C+d[1]*z+d[2]*A)*w;return k<0||I+k>1?null:(g*C+y*z+x*A)*w}function u8(i,r,n,o,s,a,l,c,u){const h=1<{const a=o?1:0;s[0]=i*n,s[1]=r*n,s[2]=(i+1)*n-a,s[3]=(r+1)*n-a};let l=new up(o);const c=[];for(let u=0;u=1;o/=2){const m=n[n.length-1];l=new up(o);for(let g=0;g0;){const{idx:m,t:g,nodex:y,nodey:x,depth:$}=f.pop();if(this.leaves[m]){u8(y,x,$,i,r,n,o,d,p);const v=1<<$,_=(y+0)/v,b=(y+1)/v,w=(x+0)/v,T=(x+1)/v,E=ux(_,w,this.dem)*l,S=ux(b,w,this.dem)*l,I=ux(b,T,this.dem)*l,C=ux(_,T,this.dem)*l,A=um(d[0],d[1],E,p[0],d[1],S,p[0],p[1],I,s,a),k=um(p[0],p[1],I,d[0],p[1],C,d[0],d[1],E,s,a),P=Math.min(null!==A?A:Number.MAX_VALUE,null!==k?k:Number.MAX_VALUE);if(P!==Number.MAX_VALUE)return P;{var D,L;const B=z([],s,a,g);if(uy(E,S,C,I,(B[0]-(D=d[0]))/(p[0]-D),(B[1]-(L=d[1]))/(p[1]-L))>=B[2])return g}continue}let R=0;for(let M=0;M=u[h[V]]&&(h.splice(V,0,M),U=!0);U||(h[R]=M),R++}}for(let j=0;j=this.dim+1||r<-1||r>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(i+1)}_unpackMapbox(i,r,n){return(256*i*256+256*r+n)/10-1e4}_unpackTerrarium(i,r,n){return 256*i+r+n/256-32768}static pack(i,r){const n=[0,0,0,0],o=uv.getUnpackVector(r);let s=Math.floor((i+o[3])/o[2]);return n[2]=s%256,s=Math.floor(s/256),n[1]=s%256,s=Math.floor(s/256),n[0]=s,n}getPixels(){return new ar({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,r,n){if(this.dim!==i.dim)throw Error("dem dimension mismatch");let o=r*this.dim,s=r*this.dim+this.dim,a=n*this.dim,l=n*this.dim+this.dim;switch(r){case -1:o=s-1;break;case 1:s=o+1}switch(n){case -1:a=l-1;break;case 1:l=a+1}const c=-r*this.dim,u=-n*this.dim;for(let h=a;h{"source"===i.dataType&&"metadata"===i.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===i.dataType&&"content"===i.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new class{constructor(i,r){this.max=i,this.onRemove=r,this.reset()}reset(){for(const i in this.data)for(const r of this.data[i])r.timeout&&clearTimeout(r.timeout),this.onRemove(r.value);return this.data={},this.order=[],this}add(i,r,n){const o=i.wrapped().key;void 0===this.data[o]&&(this.data[o]=[]);const s={value:r,timeout:void 0};if(void 0!==n&&(s.timeout=setTimeout(()=>{this.remove(i,s)},n)),this.data[o].push(s),this.order.push(o),this.order.length>this.max){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}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 r=this.data[i].shift();return r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),r.value}getByKey(i){const r=this.data[i];return r?r[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,r){if(!this.has(i))return this;const n=i.wrapped().key,o=void 0===r?0:this.data[n].indexOf(r),s=this.data[n][o];return this.data[n].splice(o,1),s.timeout&&clearTimeout(s.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(s.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(i){const r=[];for(const n in this.data)for(const o of this.data[n])i(o.value)||r.push(o);for(const s of r)this.remove(s.value.tileID,s)}}(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new class{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(i,r,n){const o=String(r);if(this.stateChanges[i]=this.stateChanges[i]||{},this.stateChanges[i][o]=this.stateChanges[i][o]||{},et(this.stateChanges[i][o],n),null===this.deletedStates[i])for(const s in this.deletedStates[i]={},this.state[i])s!==o&&(this.deletedStates[i][s]=null);else if(this.deletedStates[i]&&null===this.deletedStates[i][o])for(const a in this.deletedStates[i][o]={},this.state[i][o])n[a]||(this.deletedStates[i][o][a]=null);else for(const l in n)this.deletedStates[i]&&this.deletedStates[i][o]&&null===this.deletedStates[i][o][l]&&delete this.deletedStates[i][o][l]}removeFeatureState(i,r,n){if(null===this.deletedStates[i])return;const o=String(r);if(this.deletedStates[i]=this.deletedStates[i]||{},n&&void 0!==r)null!==this.deletedStates[i][o]&&(this.deletedStates[i][o]=this.deletedStates[i][o]||{},this.deletedStates[i][o][n]=null);else if(void 0!==r){if(this.stateChanges[i]&&this.stateChanges[i][o])for(n in this.deletedStates[i][o]={},this.stateChanges[i][o])this.deletedStates[i][o][n]=null;else this.deletedStates[i][o]=null}else this.deletedStates[i]=null}getState(i,r){const n=String(r),o=et({},(this.state[i]||{})[n],(this.stateChanges[i]||{})[n]);if(null===this.deletedStates[i])return{};if(this.deletedStates[i]){const s=this.deletedStates[i][r];if(null===s)return{};for(const a in s)delete o[a]}return o}initializeTileState(i,r){i.setFeatureState(this.state,r)}coalesceChanges(i,r){const n={};for(const o in this.stateChanges){this.state[o]=this.state[o]||{};const s={};for(const a in this.stateChanges[o])this.state[o][a]||(this.state[o][a]={}),et(this.state[o][a],this.stateChanges[o][a]),s[a]=this.state[o][a];n[o]=s}for(const l in this.deletedStates){this.state[l]=this.state[l]||{};const c={};if(null===this.deletedStates[l])for(const u in this.state[l])c[u]={},this.state[l][u]={};else for(const h in this.deletedStates[l]){if(null===this.deletedStates[l][h])this.state[l][h]={};else for(const d of Object.keys(this.deletedStates[l][h]))delete this.state[l][h][d];c[h]=this.state[l][h]}n[l]=n[l]||{},et(n[l],c)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(n).length)for(const p in i)i[p].setFeatureState(n,r)}}}onAdd(i){this.map=i,this._minTileCacheSize=i?i._minTileCacheSize:null,this._maxTileCacheSize=i?i._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const i in this._tiles){const r=this._tiles[i];if("loaded"!==r.state&&"errored"!==r.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const i=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,i&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(i,r){return i.isSymbolTile=this._onlySymbols,this._source.loadTile(i,r)}_unloadTile(i){if(this._source.unloadTile)return this._source.unloadTile(i,()=>{})}_abortTile(i){if(this._source.abortTile)return this._source.abortTile(i,()=>{})}serialize(){return this._source.serialize()}prepare(i){for(const r in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const n=this._tiles[r];n.upload(i),n.prepare(this.map.style.imageManager)}}getIds(){return ee(this._tiles).map(i=>i.tileID).sort(ub).map(i=>i.key)}getRenderableIds(i){const r=[];for(const n in this._tiles)this._isIdRenderable(+n,i)&&r.push(this._tiles[n]);return i?r.sort((i,r)=>{const n=i.tileID,o=r.tileID,s=new l(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),a=new l(o.canonical.x,o.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x}).map(i=>i.tileID.key):r.map(i=>i.tileID).sort(ub).map(i=>i.key)}hasRenderableParent(i){const r=this.findLoadedParent(i,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(i,r){return this._tiles[i]&&this._tiles[i].hasData()&&!this._coveredTiles[i]&&(r||!this._tiles[i].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const i in this._cache.reset(),this._tiles)"errored"!==this._tiles[i].state&&this._reloadTile(+i,"reloading")}_reloadTile(i,r){const n=this._tiles[i];n&&("loading"!==n.state&&(n.state=r),this._loadTile(n,this._tileLoaded.bind(this,n,i,r)))}_tileLoaded(i,r,n,o){if(o){if(i.state="errored",404!==o.status)this._source.fire(new tc(o,{tile:i}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const s=this.map.painter.terrain;this.update(this.transform,s.getScaledDemTileSize(),!0),s.resetTileLookupCache(this.id)}else this.update(this.transform)}else i.timeAdded=ew.now(),"expired"===n&&(i.refreshedUponExpiration=!0),this._setTileReloadTimer(r,i),"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),this._state.initializeTileState(i,this.map?this.map.painter:null),this._source.fire(new tl("data",{dataType:"source",tile:i,coord:i.tileID,sourceCacheId:this.id}))}_backfillDEM(i){const r=this.getRenderableIds();for(let n=0;n1||(Math.abs(n)>1&&(1===Math.abs(n+s)?n+=s:1===Math.abs(n-s)&&(n-=s)),r.dem&&i.dem&&(i.dem.backfillBorder(r.dem,n,o),i.neighboringTiles&&i.neighboringTiles[a]&&(i.neighboringTiles[a].backfilled=!0)))}}getTile(i){return this.getTileByID(i.key)}getTileByID(i){return this._tiles[i]}_retainLoadedChildren(i,r,n,o){for(const s in this._tiles){let a=this._tiles[s];if(o[s]||!a.hasData()||a.tileID.overscaledZ<=r||a.tileID.overscaledZ>n)continue;let l=a.tileID;for(;a&&a.tileID.overscaledZ>r+1;){const c=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[c.key])&&a.hasData()&&(l=c)}let u=l;for(;u.overscaledZ>r;)if(i[(u=u.scaledTo(u.overscaledZ-1)).key]){o[l.key]=l;break}}}findLoadedParent(i,r){if(i.key in this._loadedParentTiles){const n=this._loadedParentTiles[i.key];return n&&n.tileID.overscaledZ>=r?n:null}for(let o=i.overscaledZ-1;o>=r;o--){const s=i.scaledTo(o),a=this._getLoadedTile(s);if(a)return a}}_getLoadedTile(i){const r=this._tiles[i.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?i.wrapped().key:i.canonical.key)}updateCacheSize(i,r){r=r||this._source.tileSize;const n=Math.ceil(i.width/r)+1,o=Math.ceil(i.height/r)+1,s=Math.floor(n*o*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,s):s,l="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(l)}handleWrapJump(i){const r=Math.round((i-(void 0===this._prevLng?i:this._prevLng))/360);if(this._prevLng=i,r){const n={};for(const o in this._tiles){const s=this._tiles[o];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+r),n[s.tileID.key]=s}for(const a in this._tiles=n,this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(const l in this._tiles)this._setTileReloadTimer(+l,this._tiles[l])}}update(i,r,n){if(this.transform=i,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;let o;this.updateCacheSize(i,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=i.getVisibleUnwrappedCoordinates(this._source.tileID).map(i=>new uo(i.canonical.z,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y)):(o=i.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter(i=>this._source.hasTile(i)))):o=[];const s=this._updateRetainedTiles(o);if(uw(this._source.type)&&0!==o.length){const a={},l={},c=Object.keys(s);for(const u of c){const h=s[u],d=this._tiles[u];if(!d||d.fadeEndTime&&d.fadeEndTime<=ew.now())continue;const p=this.findLoadedParent(h,Math.max(h.overscaledZ-u_.maxOverzooming,this._source.minzoom));p&&(this._addTile(p.tileID),a[p.tileID.key]=p.tileID),l[u]=h}const f=o[o.length-1].overscaledZ;for(const m in this._tiles){const g=this._tiles[m];if(s[m]||!g.hasData())continue;let y=g.tileID;for(;y.overscaledZ>f;){y=y.scaledTo(y.overscaledZ-1);const x=this._tiles[y.key];if(x&&x.hasData()&&l[y.key]){s[m]=g.tileID;break}}}for(const $ in a)s[$]||(this._coveredTiles[$]=!0,s[$]=a[$])}for(const v in s)this._tiles[v].clearFadeHold();const _=function(i,r){const n=[];for(const o in i)o in r||n.push(o);return n}(this._tiles,s);for(const b of _){const w=this._tiles[b];w.hasSymbolBuckets&&!w.holdingForFade()?w.setHoldDuration(this.map._fadeDuration):w.hasSymbolBuckets&&!w.symbolFadeFinished()||this._removeTile(+b)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const i in this._tiles)this._tiles[i].holdingForFade()&&this._removeTile(+i)}_updateRetainedTiles(i){const r={};if(0===i.length)return r;const n={},o=i.reduce((i,r)=>Math.min(i,r.overscaledZ),1/0),s=i[0].overscaledZ,a=Math.max(s-u_.maxOverzooming,this._source.minzoom),l=Math.max(s+u_.maxUnderzooming,this._source.minzoom),c={};for(const u of i){const h=this._addTile(u);r[u.key]=u,h.hasData()||o=this._source.maxzoom){const f=d.children(this._source.maxzoom)[0],m=this.getTile(f);if(m&&m.hasData()){r[f.key]=f;continue}}else{const g=d.children(this._source.maxzoom);if(r[g[0].key]&&r[g[1].key]&&r[g[2].key]&&r[g[3].key])continue}let y=p.wasRequested();for(let x=d.overscaledZ-1;x>=a;--x){const $=d.scaledTo(x);if(n[$.key]||(n[$.key]=!0,(p=this.getTile($))||!y||(p=this._addTile($)),p&&(r[$.key]=$,y=p.wasRequested(),p.hasData())))break}}return r}_updateLoadedParentTileCache(){for(const i in this._loadedParentTiles={},this._tiles){const r=[];let n,o=this._tiles[i].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){n=this._loadedParentTiles[o.key];break}r.push(o.key);const s=o.scaledTo(o.overscaledZ-1);if(n=this._getLoadedTile(s))break;o=s}for(const a of r)this._loadedParentTiles[a]=n}}_addTile(i){let r=this._tiles[i.key];if(r)return r;(r=this._cache.getAndRemove(i))&&(this._setTileReloadTimer(i.key,r),r.tileID=i,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[i.key]&&(clearTimeout(this._cacheTimers[i.key]),delete this._cacheTimers[i.key],this._setTileReloadTimer(i.key,r)));const n=Boolean(r);if(!n){const o=this.map?this.map.painter:null,s="raster"===this._source.type||"raster-dem"===this._source.type;r=new u6(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,o,s),this._loadTile(r,this._tileLoaded.bind(this,r,i.key,r.state))}return r?(r.uses++,this._tiles[i.key]=r,n||this._source.fire(new tl("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(i,r){i in this._timers&&(clearTimeout(this._timers[i]),delete this._timers[i]);const n=r.getExpiryTimeout();n&&(this._timers[i]=setTimeout(()=>{this._reloadTile(i,"expired"),delete this._timers[i]},n))}_removeTile(i){const r=this._tiles[i];r&&(r.uses--,delete this._tiles[i],this._timers[i]&&(clearTimeout(this._timers[i]),delete this._timers[i]),r.uses>0||(r.hasData()&&"reloading"!==r.state?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){for(const i in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+i);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(i,r,n){const o=[],s=this.transform;if(!s)return o;for(const a in this._tiles){const l=this._tiles[a];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;const c=i.containsTile(l,s,r);c&&o.push(c)}return o}getVisibleCoordinates(i){const r=this.getRenderableIds(i).map(i=>this._tiles[i].tileID);for(const n of r)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(uw(this._source.type))for(const i in this._tiles){const r=this._tiles[i];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=ew.now())return!0}return!1}setFeatureState(i,r,n){this._state.updateState(i=i||"_geojsonTileLayer",r,n)}removeFeatureState(i,r,n){this._state.removeFeatureState(i=i||"_geojsonTileLayer",r,n)}getFeatureState(i,r){return this._state.getState(i=i||"_geojsonTileLayer",r)}setDependencies(i,r,n){const o=this._tiles[i];o&&o.setDependencies(r,n)}reloadTilesForDependencies(i,r){for(const n in this._tiles)this._tiles[n].hasDependency(i,r)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(i,r))}_preloadTiles(i,r){const n=new Map,o=Array.isArray(i)?i:[i],s=this.map.painter.terrain,a=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const l of o){const c=l.coveringTiles({tileSize:a,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const u of c)n.set(u.key,u);this.usedForTerrain&&l.updateElevation(!1)}const h=Array.from(n.values()),d="raster"===this._source.type||"raster-dem"===this._source.type;Q(h,(i,r)=>{const n=new u6(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,this.map.painter,d);this._loadTile(n,i=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),r(i,n)})},r)}}function ub(i,r){const n=Math.abs(2*i.wrap)-+(i.wrap<0),o=Math.abs(2*r.wrap)-+(r.wrap<0);return i.overscaledZ-r.overscaledZ||o-n||r.canonical.y-i.canonical.y||r.canonical.x-i.canonical.x}function uw(i){return"raster"===i||"image"===i||"video"===i}u_.maxOverzooming=10,u_.maxUnderzooming=3;class u0{constructor(i,r,n){this._demTile=i,this._dem=this._demTile.dem,this._scale=r,this._offset=n}static create(i,r,n){const o=n||i.findDEMTileFor(r);if(!o||!o.dem)return;const s=o.dem,a=o.tileID,l=1<=0&&d[3]>=0&&c.insert(l,d[0],d[1],d[2],d[3])}}loadVTLayers(){if(!this.vtLayers)for(const i in this.vtLayers=new aW.VectorTile(new lA(this.rawTileData)).layers,this.sourceLayerCoder=new uh(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[i]=[];return this.vtLayers}query(i,r,n,o){this.loadVTLayers();const s=i.params||{},a=rT(s.filter),l=i.tileResult,c=i.transform,u=l.bufferedTilespaceBounds,h=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(i,r,n,o)=>sV(l.bufferedTilespaceGeometry,i,r,n,o));h.sort(uS);let d=null;c.elevation&&h.length>0&&(d=u0.create(c.elevation,this.tileID));const p={};let f;for(let m=0;m(x||(x=sk(r,this.tileID.canonical,i.tileTransform)),n.queryIntersectsFeature(l,r,o,x,this.z,i.transform,i.pixelPosMatrix,d,s)))}return p}loadMatchingFeature(i,r,n,o,s,a,l,c,u){const{featureIndex:h,bucketIndex:d,sourceLayerIndex:p,layoutVertexArrayOffset:f}=r,m=this.bucketLayerIDs[d];if(o&&!function(i,r){for(let n=0;n=0)return!0;return!1}(o,m))return;const g=this.sourceLayerCoder.decode(p),y=this.vtLayers[g].feature(h);if(n.needGeometry){const x=sP(y,!0);if(!n.filter(new nX(this.tileID.overscaledZ),x,this.tileID.canonical))return}else if(!n.filter(new nX(this.tileID.overscaledZ),y))return;const $=this.getId(y,g);for(let v=0;vo.indexOf(_))continue;const b=a[_];if(!b)continue;let w={};void 0!==$&&c&&(w=c.getState(b.sourceLayer||"_geojsonTileLayer",$));const T=et({},l[_]);T.paint=uE(T.paint,b.paint,y,w,s),T.layout=uE(T.layout,b.layout,y,w,s);const E=!u||u(y,b,w,f);if(!E)continue;const S=new ud(y,this.z,this.x,this.y,$);S.layer=T;let I=i[_];void 0===I&&(I=i[_]=[]),I.push({featureIndex:h,feature:S,intersectionZ:E})}}lookupSymbolFeatures(i,r,n,o,s,a,l,c){const u={};this.loadVTLayers();const h=rT(s);for(const d of i)this.loadMatchingFeature(u,{bucketIndex:n,sourceLayerIndex:o,featureIndex:d,layoutVertexArrayOffset:0},h,a,l,c,r);return u}loadFeature(i){const{featureIndex:r,sourceLayerIndex:n}=i;this.loadVTLayers();const o=this.sourceLayerCoder.decode(n),s=this.vtFeatures[o];if(s[r])return s[r];const a=this.vtLayers[o].feature(r);return s[r]=a,a}hasLayer(i){for(const r of this.bucketLayerIDs)for(const n of r)if(i===n)return!0;return!1}getId(i,r){let n=i.id;return this.promoteId&&"boolean"==typeof(n=i.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[r]])&&(n=Number(n)),n}}function uE(i,r,n,o,s){return ec(i,(i,a)=>{const l=r instanceof oe?r.get(a):null;return l&&l.evaluate?l.evaluate(n,o,s):l})}function uS(i,r){return r-i}nr("FeatureIndex",uT,{omit:["rawTileData","sourceLayerCoder"]});var uI=oh([{name:"a_pos",type:"Int16",components:2},]);const uC=new Uint16Array(8184);for(let uz=0;uz<2046;uz++){let uA=uz+2,uk=0,uP=0,uD=0,uL=0,u1=0,uB=0;for(1&uA?uD=uL=u1=32:uk=uP=uB=32;(uA>>=1)>1;){const uR=uk+uD>>1,u3=uP+uL>>1;1&uA?(uD=uk,uL=uP,uk=u1,uP=uB):(uk=uD,uP=uL,uD=u1,uL=uB),u1=uR,uB=u3}const uM=4*uz;uC[uM+0]=uk,uC[uM+1]=uP,uC[uM+2]=uD,uC[uM+3]=uL}const u2=new Uint16Array(2178),uF=new Uint8Array(1089),uO=new Uint16Array(1089);function u4(i){return 0===i?-.03125:32===i?.03125:0}var uU=oh([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2},]);const uV={type:2,extent:8192,loadGeometry:()=>[[new l(0,0),new l(8193,0),new l(8193,8193),new l(0,8193),new l(0,0),],]};class u6{constructor(i,r,n,o,s){this.tileID=i,this.uid=er(),this.uses=0,this.tileSize=r,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,this.expiredRequestCount=0,this.state="loading",o&&o.transform&&(this.projection=o.transform.projection)}registerFadeDuration(i){const r=i+this.timeAdded;rr.getLayer(i)).filter(Boolean);if(0!==s.length)for(const a of(o.layers=s,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map(i=>s.filter(r=>r.id===i)[0])),s))n[a.id]=o}return n}(i.buckets,r.style),this.hasSymbolBuckets=!1,this.buckets){const s=this.buckets[o];if(s instanceof cU){if(this.hasSymbolBuckets=!0,!n)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const a in this.buckets){const l=this.buckets[a];if(l instanceof cU&&l.hasRTLText){this.hasRTLText=!0,n5.isLoading()||n5.isLoaded()||"deferred"!==n7()||nq();break}}for(const c in this.queryPadding=0,this.buckets){const u=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(c).queryRadius(u))}i.imageAtlas&&(this.imageAtlas=i.imageAtlas),i.glyphAtlasImage&&(this.glyphAtlasImage=i.glyphAtlasImage),i.lineAtlas&&(this.lineAtlas=i.lineAtlas)}else this.collisionBoxArray=new o1}unloadVectorData(){if(this.hasData()){for(const i in this.buckets)this.buckets[i].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this.globeGridBuffer&&(this.globeGridBuffer.destroy(),this.globeGridBuffer=null),this.globePoleBuffer&&(this.globePoleBuffer.destroy(),this.globePoleBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(i){return this.buckets[i.id]}upload(i){for(const r in this.buckets){const n=this.buckets[r];n.uploadPending()&&n.upload(i)}const o=i.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new cJ(i,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new cJ(i,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new cJ(i,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(i){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(i,this.imageAtlasTexture)}queryRenderedFeatures(i,r,n,o,s,a,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:l,transform:a,params:s,tileTransform:this.tileTransform},i,r,n):{}}querySourceFeatures(i,r){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const o=n.loadVTLayers(),s=r?r.sourceLayer:"",a=o._geojsonTileLayer||o[s];if(!a)return;const l=rT(r&&r.filter),{z:c,x:u,y:h}=this.tileID.canonical,d={z:c,x:u,y:h};for(let p=0;po)s=!1;else if(r){if(this.expirationTime=0;d--){const p=4*d,f=uC[p+0],m=uC[p+1],g=uC[p+2],y=uC[p+3],x=f+g>>1,$=m+y>>1,v=x+$-m,_=$+f-x,b=33*m+f,w=33*y+g,T=33*$+x,E=Math.hypot((u2[2*b+0]+u2[2*w+0])/2-u2[2*T+0],(u2[2*b+1]+u2[2*w+1])/2-u2[2*T+1])>=16;if(uF[T]=uF[T]||(E?1:0),d<1022){const S=(m+_>>1)*33+(f+v>>1),I=(y+_>>1)*33+(g+v>>1);uF[T]=uF[T]||uF[S]||uF[I]}}const C=new of,z=new o0;let A=0;function k(i,r){const n=33*r+i;return 0===uO[n]&&(C.emplaceBack(u2[2*n+0],u2[2*n+1],8192*i/32,8192*r/32),uO[n]=++A),uO[n]-1}function P(i,r,n,o,s,a){const l=i+n>>1,c=r+o>>1;if(Math.abs(i-s)+Math.abs(r-a)>1&&uF[33*c+l])P(s,a,i,r,l,c),P(n,o,s,a,l,c);else{const u=k(i,r),h=k(n,o),d=k(s,a);z.emplaceBack(u,h,d)}}return P(0,0,32,32,32,0),P(32,32,0,0,0,32),{vertices:C,indices:z}}(this.tileID.canonical,r);o=a.vertices,s=a.indices}else{for(const{x:l,y:c}of(o=new of,s=new o0,n))o.emplaceBack(l,c,0,0);const u=ac(o.int16,void 0,4);for(let h=0;h{const o=65*n+r;i.emplaceBack(o+1,o,o+65),i.emplaceBack(o+65,o+65+1,o+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}getWirefameBuffer(i){if(!this.wireframeSegments){const r=this._createWireframeGrid();this.wireframeIndexBuffer=i.createIndexBuffer(r),this.wireframeSegments=sg.simpleSegment(0,0,4096,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments,]}_createWireframeGrid(){const i=new oA,r=(r,n)=>{const o=65*n+r;i.emplaceBack(o,o+1),i.emplaceBack(o,o+65),i.emplaceBack(o,o+65+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}}function ht(i,r){if(!r.isReprojectedInTileSpace)return{scale:1<_&&(b(i,h,o,s,c,u),b(h,n,c,u,a,l))}b(p,f,o,a,s,a),b(f,m,s,a,s,l),b(m,g,s,l,o,l),b(g,p,o,l,o,a),y-=_,x-=_,$+=_,v+=_;const w=1/Math.max($-y,v-x);return{scale:w,x:y*w,y:x*w,x2:$*w,y2:v*w,projection:r}}class hi{constructor(i){const r={},n=[];for(const o in i){const s=i[o],a=r[o]={};for(const l in s.glyphs){const c=s.glyphs[+l];if(!c||0===c.bitmap.width||0===c.bitmap.height)continue;const u=c.metrics.localGlyph?2:1,h={x:0,y:0,w:c.bitmap.width+2*u,h:c.bitmap.height+2*u};n.push(h),a[l]=h}}const{w:d,h:p}=lZ(n),f=new ai({width:d||1,height:p||1});for(const m in i){const g=i[m];for(const y in g.glyphs){const x=g.glyphs[+y];if(!x||0===x.bitmap.width||0===x.bitmap.height)continue;const $=r[m][y],v=x.metrics.localGlyph?2:1;ai.copy(x.bitmap,f,{x:0,y:0},{x:$.x+v,y:$.y+v},x.bitmap)}}this.image=f,this.positions=r}}nr("GlyphAtlas",hi);class hr{constructor(i){this.tileID=new uo(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),this.tileZoom=i.tileZoom,this.uid=i.uid,this.zoom=i.zoom,this.canonical=i.tileID.canonical,this.pixelRatio=i.pixelRatio,this.tileSize=i.tileSize,this.source=i.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=i.showCollisionBoxes,this.collectResourceTiming=!!i.collectResourceTiming,this.returnDependencies=!!i.returnDependencies,this.promoteId=i.promoteId,this.enableTerrain=!!i.enableTerrain,this.isSymbolTile=i.isSymbolTile,this.tileTransform=ht(i.tileID.canonical,i.projection),this.projection=i.projection}parse(i,r,n,o,s){this.status="parsing",this.data=i,this.collisionBoxArray=new o1;const a=new uh(Object.keys(i.layers).sort()),l=new uT(this.tileID,this.promoteId);l.bucketLayerIDs=[];const c={},u=new cQ(256,256),h={featureIndex:l,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n},d=r.familiesBySource[this.source];for(const p in d){const f=i.layers[p];if(!f)continue;let m=!1,g=!1;for(const y of d[p])"symbol"===y[0].type?m=!0:g=!0;if(!0===this.isSymbolTile&&!m||!1===this.isSymbolTile&&!g)continue;1===f.version&&ep(`Vector tile source "${this.source}" layer "${p}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const x=a.encode(p),$=[];for(let v=0;v=T.maxzoom||"none"!==T.visibility&&(hn(w,this.zoom,n),(c[T.id]=T.createBucket({index:l.bucketLayerIDs.length,layers:w,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:x,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:n})).populate($,h,this.tileID.canonical,this.tileTransform),l.bucketLayerIDs.push(w.map(i=>i.id)))}}let E,S,I,C;u.trim();const z={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},A=ec(h.glyphDependencies,i=>Object.keys(i).map(Number));Object.keys(A).length?o.send("getGlyphs",{uid:this.uid,stacks:A},(i,r)=>{E||(E=i,S=r,D.call(this))},void 0,!1,z):S={};const k=Object.keys(h.iconDependencies);k.length?o.send("getImages",{icons:k,source:this.source,tileID:this.tileID,type:"icons"},(i,r)=>{E||(E=i,I=r,D.call(this))},void 0,!1,z):I={};const P=Object.keys(h.patternDependencies);function D(){if(E)return s(E);if(S&&I&&C){const i=new hi(S),r=new l7(I,C);for(const o in c){const a=c[o];a instanceof cU?(hn(a.layers,this.zoom,n),cC(a,S,i.positions,I,r.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection),a.projection=this.projection.name):a.hasPattern&&(a instanceof lh||a instanceof aO||a instanceof aJ)&&(hn(a.layers,this.zoom,n),a.addFeatures(h,this.tileID.canonical,r.patternPositions,n))}this.status="done",s(null,{buckets:ee(c).filter(i=>!i.isEmpty()),featureIndex:l,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:u,imageAtlas:r,glyphMap:this.returnDependencies?S:null,iconMap:this.returnDependencies?I:null,glyphPositions:this.returnDependencies?i.positions:null})}}P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"patterns"},(i,r)=>{E||(E=i,C=r,D.call(this))},void 0,!1,z):C={},D.call(this)}}function hn(i,r,n){const o=new nX(r);for(const s of i)s.recalculate(o,n)}class ho{constructor(i){this.entries={},this.scheduler=i}request(i,r,n,o){const s=this.entries[i]=this.entries[i]||{callbacks:[]};if(s.result){const[a,l]=s.result;return this.scheduler?this.scheduler.add(()=>{o(a,l)},r):o(a,l),()=>{}}return s.callbacks.push(o),s.cancel||(s.cancel=n((n,o)=>{for(const a of(s.result=[n,o],s.callbacks))this.scheduler?this.scheduler.add(()=>{a(n,o)},r):a(n,o);setTimeout(()=>delete this.entries[i],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(i=>i!==o),s.callbacks.length||(s.cancel(),delete this.entries[i]))}}}function hs(i,r,n){const o=JSON.stringify(i.request);return i.data&&(this.deduped.entries[o]={result:[null,i.data]}),this.deduped.request(o,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom},r=>{const o=eJ(i.request,(i,o,s,a)=>{i?r(i):o&&r(null,{vectorTile:n?void 0:new aW.VectorTile(new lA(o)),rawData:o,cacheControl:s,expires:a})});return()=>{o.cancel(),r()}},r)}const ha=p(new Float64Array(16));class hl{constructor(i,r){this._tr=i,this._worldSize=r}createInversionMatrix(){return ha}createTileMatrix(i){let r,n,o;const s=i.canonical,a=p(new Float64Array(16)),l=this._tr.projection;if(l.isReprojectedInTileSpace){const c=ht(s,l);r=1,n=c.x+i.wrap*c.scale,o=c.y,g(a,a,[r/c.scale,r/c.scale,this._tr.pixelsPerMeter/this._worldSize,])}else r=this._worldSize/this._tr.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return m(a,a,[n,o,0]),g(a,a,[r/8192,r/8192,1]),a}pointCoordinate(i,r,n){const o=this._tr.horizonLineFromTop(!1),s=new l(i,Math.max(o,r));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(s,n))}upVector(){return[0,0,1]}upVectorScale(){return 1}}const hc=Math.sqrt(3)/2,hu=Math.PI/2;function hh(i){return Math.tan((hu+i)/2)}const hd=85.051129*j,hp=85.051129*j,hf={albers:{name:"albers",range:[4,7],center:[-96,37.5],parallels:[29.5,45.5],zAxisUnit:"meters",conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&V(this.parallels,this.constants.parallels))return;const i=Math.sin(this.parallels[0]*j),r=(i+Math.sin(this.parallels[1]*j))/2,n=1+i*(2*r-i),o=Math.sqrt(n)/r;this.constants={n:r,c:n,r0:o,parallels:this.parallels}},project(i,r){this.initializeConstants();const n=(i-this.center[0])*j,{n:o,c:s,r0:a}=this.constants,l=Math.sqrt(s-2*o*Math.sin(r*j))/o;return{x:l*Math.sin(n*o),y:l*Math.cos(n*o)-a,z:0}},unproject(i,r){this.initializeConstants();const{n:n,c:o,r0:s}=this.constants,a=s+r;let l=Math.atan2(i,Math.abs(a))*Math.sign(a);a*n<0&&(l-=Math.PI*Math.sign(i)*Math.sign(a));const c=this.center[0]*j*n;l=J(l,-Math.PI-c,Math.PI-c);const u=l/n*N+this.center[0],h=Math.asin(K((o-(i*i+a*a)*n*n)/(2*n),-1,1)),d=K(h*N,-85.051129,85.051129);return new sx(u,d)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/sv(i)*r,farthestPixelDistance(i){return uZ(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hl(i,r)},equalEarth:{name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r=r/180*Math.PI,i=i/180*Math.PI;const n=Math.asin(hc*Math.sin(r)),o=n*n,s=o*o*o;return{x:.5*(i*Math.cos(n)/(hc*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o)))/Math.PI+.5),y:1-.5*(n*(1.340264+-.081106*o+s*(893e-6+.003796*o))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=n*n,s=o*o*o;for(let a,l,c=0;c<12&&(l=n*(1.340264+-.081106*o+s*(893e-6+.003796*o))-r,s=(o=(n=K(n-(a=l/(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))),-Math.PI/3,Math.PI/3))*n)*o*o,!(1e-12>Math.abs(a)));++c);const u=hc*i*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))/Math.cos(n),h=Math.asin(Math.sin(n)/hc),d=K(180*u/Math.PI,-180,180),p=K(180*h/Math.PI,-85.051129,85.051129);return new sx(d,p)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/sv(i)*r,farthestPixelDistance(i){return uZ(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hl(i,r)},equirectangular:{name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(i,r)=>({x:.5+i/360,y:.5-r/360,z:0}),unproject(i,r){const n=K(360*(.5-r),-85.051129,85.051129);return new sx(360*(i-.5),n)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/sv(i)*r,farthestPixelDistance(i){return uZ(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hl(i,r)},lambertConformalConic:{name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&V(this.parallels,this.constants.parallels))return;const i=this.parallels[0]*j,r=this.parallels[1]*j,n=Math.cos(i),o=i===r?Math.sin(i):Math.log(n/Math.cos(r))/Math.log(hh(r)/hh(i)),s=n*Math.pow(hh(i),o)/o;this.constants={n:o,f:s,parallels:this.parallels}},project(i,r){this.initializeConstants(),r*=j,i=(i-this.center[0])*j;const{n:n,f:o}=this.constants;o>0?r<-hu+1e-6&&(r=-hu+1e-6):r>hu-1e-6&&(r=hu-1e-6);const s=o/Math.pow(hh(r),n),a=s*Math.sin(n*i),l=o-s*Math.cos(n*i);return{x:.5*(a/Math.PI+.5),y:1-.5*(l/Math.PI+.5),z:0}},unproject(i,r){this.initializeConstants(),i=(2*i-.5)*Math.PI,r=(2*(1-r)-.5)*Math.PI;const{n:n,f:o}=this.constants,s=o-r,a=Math.sign(s),l=Math.sign(n)*Math.sqrt(i*i+s*s);let c=Math.atan2(i,Math.abs(s))*a;s*n<0&&(c-=Math.PI*Math.sign(i)*a);const u=K(c/n*N+this.center[0],-180,180),h=K((2*Math.atan(Math.pow(o/l,1/n))-hu)*N,-85.051129,85.051129);return new sx(u,h)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/sv(i)*r,farthestPixelDistance(i){return uZ(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hl(i,r)},mercator:{name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(i,r)=>({x:s_(i),y:sb(r),z:0}),unproject(i,r){const n=s0(i),o=sT(r);return new sx(n,o)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/sv(i)*r,farthestPixelDistance(i){return uZ(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hl(i,r)},naturalEarth:{name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(i,r){const n=(r*=j)*r,o=n*n;return{x:.5*((i*=j)*(.8707-.131979*n+o*(o*(.003971*n-.001529*o)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+n*(.015085+o*(.028874*n-.044475-.005916*o)))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=25,s=0,a=n*n;do{a=n*n;const l=a*a;s=(n*(1.007226+a*(.015085+l*(.028874*a-.044475-.005916*l)))-r)/(1.007226+a*(.045255+l*(.259866*a-.311325-.005916*11*l))),n=K(n-s,-hd,hd)}while(Math.abs(s)>1e-6&&--o>0)a=n*n;const c=K(i/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*N,-180,180),u=n*N;return new sx(c,u)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/sv(i)*r,farthestPixelDistance(i){return uZ(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hl(i,r)},winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r*=j,i*=j;const n=Math.cos(r),o=2/Math.PI,s=Math.acos(n*Math.cos(i/2)),a=Math.sin(s)/s,l=.5*(i*o+2*n*Math.sin(i/2)/a)||0,c=.5*(r+Math.sin(r)/a)||0;return{x:.5*(l/Math.PI+.5),y:1-.5*(c/Math.PI+1),z:0}},unproject(i,r){let n=i=(2*i-.5)*Math.PI,o=r=(2*(1-r)-1)*Math.PI,s=25,a=0,l=0;do{const c=Math.cos(o),u=Math.sin(o),h=2*u*c,d=u*u,p=c*c,f=Math.cos(n/2),m=Math.sin(n/2),g=2*f*m,y=m*m,x=1-p*f*f,$=x?1/x:0,v=x?Math.acos(c*f)*Math.sqrt(1/x):0,_=.5*(2*v*c*m+2*n/Math.PI)-i,b=.5*(v*u+o)-r,w=.5*$*(p*y+v*c*f*d)+1/Math.PI,T=$*(g*h/4-v*u*m),E=.125*$*(h*m-v*u*p*g),S=.5*$*(d*f+v*y*c)+.5,I=T*E-S*w;a=(b*T-_*S)/I,l=(_*E-b*w)/I,n=K(n-a,-Math.PI,Math.PI),o=K(o-l,-hp,hp)}while((Math.abs(a)>1e-6||Math.abs(l)>1e-6)&&--s>0)return new sx(n*N,o*N)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/sv(i)*r,farthestPixelDistance(i){return uZ(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hl(i,r)}};i.ARRAY_TYPE=h,i.AUTH_ERR_MSG=eD,i.Aabb=s5,i.Actor=class{constructor(i,r,n){this.target=i,this.parent=r,this.mapId=n,this.callbacks={},this.cancelCallbacks={},ea(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=e8()?i:u,this.scheduler=new class{constructor(){this.tasks={},this.taskQueue=[],ea(["process"],this),this.invoker=new class{constructor(i){this._callback=i,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){delete this._channel,this._callback=()=>{}}}(this.process),this.nextId=0}add(i,r){const n=this.nextId++,o=function({type:i,isSymbolTile:r,zoom:n}){return n=n||0,"message"===i?0:"maybePrepare"!==i||r?"parseTile"!==i||r?"parseTile"===i&&r?300-n:"maybePrepare"===i&&r?400-n:500:200-n:100-n}(r);return 0===o?(e8(),i(),{cancel:()=>{}}):(this.tasks[n]={fn:i,metadata:r,priority:o,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}})}process(){e8();{if(this.taskQueue=this.taskQueue.filter(i=>!!this.tasks[i]),!this.taskQueue.length)return;const i=this.pick();if(null===i)return;const r=this.tasks[i];if(delete this.tasks[i],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}}pick(){let i=null,r=1/0;for(let n=0;n{n&&delete this.callbacks[l],this.target.postMessage({id:l,type:"",targetMapId:o,sourceMapId:this.mapId})}}}receive(i){const r=i.data,n=r.id;if(n&&(!r.targetMapId||this.mapId===r.targetMapId)){if(""===r.type){const o=this.cancelCallbacks[n];delete this.cancelCallbacks[n],o&&o.cancel()}else if(r.mustQueue||e8()){const s=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,r),s&&s.metadata||{type:"message"})}else this.processTask(n,r)}}processTask(i,r){if(""===r.type){const n=this.callbacks[i];delete this.callbacks[i],n&&(r.error?n(nl(r.error)):n(null,nl(r.data)))}else{const o=e_(this.globalScope)?void 0:[],s=r.hasCallback?(r,n)=>{delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"",sourceMapId:this.mapId,error:r?na(r):null,data:na(n,o)},o)}:i=>{},a=nl(r.data);if(this.parent[r.type])this.parent[r.type](r.sourceMapId,a,s);else if(this.parent.getWorkerSource){const l=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,l[0],a.source)[l[1]](a,s)}else s(Error(`Could not find function ${r.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=ur,i.Color=t1,i.ColorMode=uc,i.CullFaceMode=uu,i.DEMData=uv,i.DataConstantProperty=ot,i.DedupedRequest=ho,i.DepthMode=ua,i.EXTENT=8192,i.Elevation=class{getAtPointOrZero(i,r=0){return this.getAtPoint(i,r)||0}getAtPoint(i,r,n=!0){null==r&&(r=null);const o=this._source();if(!o||i.y<0||i.y>1)return r;const s=o.getSource().maxzoom,a=1<{const o=this.getAtTileOffset(i,n.x,n.y),s=r.upVector(i.canonical,n.x,n.y);return C(s,s,o*r.upVectorScale(i.canonical)),s}}getForTilePoints(i,r,n,o){const s=u0.create(this,i,o);return!!s&&(r.forEach(i=>{i[2]=this.exaggeration()*s.getElevationAt(i[0],i[1],n)}),!0)}getMinMaxForTile(i){const r=this.findDEMTileFor(i);if(!r||!r.dem)return null;const n=r.dem.tree,o=r.tileID,s=1<Math.abs(o))return!1;const s=((i[0]-this.pos[0])*r[0]+(i[1]-this.pos[1])*r[1]+(i[2]-this.pos[2])*r[2])/o;return n[0]=this.pos[0]+this.dir[0]*s,n[1]=this.pos[1]+this.dir[1]*s,n[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(i,r,n){var o,s,a,l,c,u,h,d;if(o=this.pos,s=i,a=o[0],l=o[1],c=o[2],u=s[0],h=s[1],d=s[2],Math.abs(a-u)<=1e-6*Math.max(1,Math.abs(a),Math.abs(u))&&Math.abs(l-h)<=1e-6*Math.max(1,Math.abs(l),Math.abs(h))&&Math.abs(c-d)<=1e-6*Math.max(1,Math.abs(c),Math.abs(d))||0===r)return n[0]=n[1]=n[2]=0,!1;const[p,f,m]=this.dir,g=this.pos[0]-i[0],y=this.pos[1]-i[1],x=this.pos[2]-i[2],$=p*p+f*f+m*m,v=2*(g*p+y*f+x*m),_=v*v-4*$*(g*g+y*y+x*x-r*r);if(_<0){const b=Math.max(-v/2,0),w=g+p*b,T=y+f*b,E=x+m*b,S=Math.hypot(w,T,E);return n[0]=w*r/S,n[1]=T*r/S,n[2]=E*r/S,!1}{const I=(-v-Math.sqrt(_))/(2*$);if(I<0){const C=Math.hypot(g,y,x);return n[0]=g*r/C,n[1]=y*r/C,n[2]=x*r/C,!1}return n[0]=g+p*I,n[1]=y+f*I,n[2]=x+m*I,!0}}},i.RequestManager=class{constructor(i,r,n){this._transformRequestFn=i,this._customAccessToken=r,this._silenceAuthErrors=!!n,this._createSkuToken()}_createSkuToken(){const i=function(){let i="";for(let r=0;r<10;r++)i+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",i].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(i,r){return this._transformRequestFn&&this._transformRequestFn(i,r)||{url:i}}normalizeStyleURL(i,r){if(!eL(i))return i;const n=eR(i);return n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(i,r){if(!eL(i))return i;const n=eR(i);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeSourceURL(i,r){if(!eL(i))return i;const n=eR(i);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||r)}normalizeSpriteURL(i,r,n,o){const s=eR(i);return eL(i)?(s.path=`/styles/v1${s.path}/sprite${r}${n}`,this._makeAPIURL(s,this._customAccessToken||o)):(s.path+=`${r}${n}`,e3(s))}normalizeTileURL(i,r,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!eL(i))return i;const o=eR(i);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||n&&"raster"!==o.authority&&512===n?"@2x":""}${eI.supported?".webp":"$1"}`),"raster"===o.authority?o.path=`/${eT.RASTER_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${eT.TILE_URL_VERSION}${o.path}`);const s=this._customAccessToken||function(i){for(const r of i){const n=r.match(/^access_token=(.*)$/);if(n)return n[1]}return null}(o.params)||eT.ACCESS_TOKEN;return eT.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,s)}canonicalizeTileURL(i,r){const n=eR(i);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return i;let o="mapbox://";n.path.match(/^\/raster\/v1\//)?o+=`raster/${n.path.replace(`/${eT.RASTER_URL_PREFIX}/`,"")}`:o+=`tiles/${n.path.replace(`/${eT.TILE_URL_VERSION}/`,"")}`;let s=n.params;return r&&(s=s.filter(i=>!i.match(/^access_token=/))),s.length&&(o+=`?${s.join("&")}`),o}canonicalizeTileset(i,r){const n=!!r&&eL(r),o=[];for(const s of i.tiles||[])e1(s)?o.push(this.canonicalizeTileURL(s,n)):o.push(s);return o}_makeAPIURL(i,r){const n="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",o=eR(eT.API_URL);if(i.protocol=o.protocol,i.authority=o.authority,"http"===i.protocol){const s=i.params.indexOf("secure");s>=0&&i.params.splice(s,1)}if("/"!==o.path&&(i.path=`${o.path}${i.path}`),!eT.REQUIRE_ACCESS_TOKEN)return e3(i);if(r=r||eT.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===r[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return i.params=i.params.filter(i=>-1===i.indexOf("access_token")),i.params.push(`access_token=${r||""}`),e3(i)}},i.ResourceType=eW,i.SegmentVector=sg,i.SourceCache=u_,i.StencilMode=ul,i.StructArrayLayout1ui2=ok,i.StructArrayLayout2f1f2i16=ob,i.StructArrayLayout2i4=op,i.StructArrayLayout2ui4=oA,i.StructArrayLayout3f12=o8,i.StructArrayLayout3ui6=o0,i.StructArrayLayout4i8=of,i.Texture=cJ,i.Tile=u6,i.Transitionable=nK,i.Uniform1f=oW,i.Uniform1i=class extends oX{constructor(i,r){super(i,r),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},i.Uniform2f=class extends oX{constructor(i,r){super(i,r),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]))}},i.Uniform3f=class extends oX{constructor(i,r){super(i,r),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]))}},i.Uniform4f=oH,i.UniformColor=oK,i.UniformMatrix2f=class extends oX{constructor(i,r){super(i,r),this.current=oQ}set(i){for(let r=0;r<4;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}},i.UniformMatrix3f=class extends oX{constructor(i,r){super(i,r),this.current=oJ}set(i){for(let r=0;r<9;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},i.UniformMatrix4f=class extends oX{constructor(i,r){super(i,r),this.current=oY}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 r=1;r<16;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},i.UnwrappedTileID=un,i.ValidationError=td,i.VectorTileWorkerSource=class extends tu{constructor(i,r,n,o,s){super(),this.actor=i,this.layerIndex=r,this.availableImages=n,this.loadVectorData=s||hs,this.loading={},this.loaded={},this.deduped=new ho(i.scheduler),this.isSpriteLoaded=o,this.scheduler=i.scheduler}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[n]=new hr(i);a.abort=this.loadVectorData(i,(l,c)=>{const u=!this.loading[n];if(delete this.loading[n],u||l||!c)return a.status="done",u||(this.loaded[n]=a),r(l);const h=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),a.vectorTile=c.vectorTile||new aW.VectorTile(new lA(h));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,(i,n)=>{if(i||!n)return r(i);const a={};if(s){const l=ut(o);l.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(l)))}r(null,et({rawTileData:h.slice(0)},n,d,a))})};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()}),this.loaded=this.loaded||{},this.loaded[n]=a})}reloadTile(i,r){const n=this.loaded,o=i.uid,s=this;if(n&&n[o]){const a=n[o];a.showCollisionBoxes=i.showCollisionBoxes,a.enableTerrain=!!i.enableTerrain,a.projection=i.projection;const l=(i,n)=>{const o=a.reloadCallback;o&&(delete a.reloadCallback,a.parse(a.vectorTile,s.layerIndex,this.availableImages,s.actor,o)),r(i,n)};"parsing"===a.status?a.reloadCallback=l:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,l):l())}}abortTile(i,r){const n=i.uid,o=this.loading[n];o&&(o.abort&&o.abort(),delete this.loading[n]),r()}removeTile(i,r){const n=this.loaded,o=i.uid;n&&n[o]&&delete n[o],r()}},i.WritingMode=lq,i.ZoomHistory=nc,i.add=T,i.addDynamicAttributes=c2,i.adjoint=function(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=r[4],c=r[5],u=r[6],h=r[7],d=r[8];return i[0]=l*d-c*h,i[1]=s*h-o*d,i[2]=o*c-s*l,i[3]=c*u-a*d,i[4]=n*d-s*u,i[5]=s*a-n*c,i[6]=a*h-l*u,i[7]=o*u-n*h,i[8]=n*l-o*a,i},i.asyncAll=Q,i.bezier=W,i.bindAll=ea,i.boundsAttributes=uU,i.bufferConvexPolygon=function(i,r){const n=[];for(let o=0;oe7&&(i.getActor().send("enforceCacheSizeLimit",e9),eX=0)},i.calculateGlobeMatrix=uQ,i.calculateGlobeMercatorMatrix=function(i){const r=i.worldSize,n=K(i.center.lat,-85.051129,85.051129),o=new l(s_(i.center.lng)*r,sb(n)*r),s=1/sv(i.center.lat)*r,a=i.pixelsPerMeter,c=r/(s/i.pixelsPerMeter),u=p(new Float64Array(16));return m(u,u,[o.x,o.y,0]),g(u,u,[c,c,a]),u},i.clamp=K,i.clearTileCache=function(i){const r=u.caches.delete(eN);i&&r.catch(i).then(()=>i())},i.clipLine=cf,i.clone=function(i){var r=new h(16);return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],r},i.clone$1=eh,i.collisionCircleLayout=lv,i.config=eT,i.conjugate=function(i,r){return i[0]=-r[0],i[1]=-r[1],i[2]=-r[2],i[3]=r[3],i},i.create=function(){var i=new h(16);return h!=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},i.create$1=d,i.createExpression=rd,i.createLayout=oh,i.createStyleLayer=function(i){return"custom"===i.type?new c9(i):new c5[i.type](i)},i.cross=P,i.degToRad=G,i.div=function(i,r,n){return i[0]=r[0]/n[0],i[1]=r[1]/n[1],i[2]=r[2]/n[2],i},i.dot=k,i.ease=H,i.easeCubicInOut=X,i.emitValidationErrors=rY,i.endsWith=el,i.enforceCacheSizeLimit=function(i){eq(),eG&&eG.then(r=>{r.keys().then(n=>{for(let o=0;oa&&(o+=(i[s]-a)*(i[s]-a)),r[s]Math.abs(r.parallels[0]+r.parallels[1])){let n=function(i){const r=Math.max(.01,Math.cos(i*j)),n=1/(2*Math.max(Math.PI*r,1/r));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom",],project(i,o){const s=Math.sin(o*j)/r;return{x:i*j*r*n+.5,y:-s*n+.5,z:0}},unproject(i,o){const s=K((i-.5)/n*N/r,-180,180),a=Math.asin(K(-(o-.5)/n*r,-1,1)),l=K(a*N,-85.051129,85.051129);return new sx(s,l)}}}(r.parallels[0]);if("lambertConformalConic"===r.name){const{project:o,unproject:s}=hf.mercator;n={wrap:!0,supportsWorldCopies:!0,project:o,unproject:s}}return et({},i,r,n)}return et({},i,r)}(r,i):r},i.getRTLTextPluginStatus=n7,i.getReferrer=eK,i.getTilePoint=function(i,{x:r,y:n},o=0){return new l(((r-o)*i.scale-i.x)*8192,(n*i.scale-i.y)*8192)},i.getTileVec3=function(i,r,n=0){return w(((r.x-n)*i.scale-i.x)*8192,(r.y*i.scale-i.y)*8192,sE(r.z,r.y))},i.getVideo=function(i,r){const n=u.document.createElement("video");n.muted=!0,n.onloadstart=function(){r(null,n)};for(let o=0;o{}}},i.globeBuffersForTileMesh=function(i,r,n,o){const s=i.context,a=i.transform;let l=r.globeGridBuffer,c=r.globePoleBuffer;if(!l){const u=he.createGridVertices(n.canonical);l=r.globeGridBuffer=s.createVertexBuffer(u,uG,!1)}if(!c){const h=he.createPoleTriangleVertices(o,a.tileSize*o,0===n.canonical.y);c=r.globePoleBuffer=s.createVertexBuffer(h,uG,!1)}return[l,c]},i.globeDenormalizeECEF=uJ,i.globeMatrixForTile=function(i,r){var n,o;const s=uJ(uX(i)),a=((n=new Float64Array(16))[0]=(o=r)[0],n[1]=o[1],n[2]=o[2],n[3]=o[3],n[4]=o[4],n[5]=o[5],n[6]=o[6],n[7]=o[7],n[8]=o[8],n[9]=o[9],n[10]=o[10],n[11]=o[11],n[12]=o[12],n[13]=o[13],n[14]=o[14],n[15]=o[15],n);return $(a,a,s),a},i.globePoleMatrixForTile=function(i,r,n){const o=p(new Float64Array(16)),s=Math.pow(2,i.z),a=(i.x-s/2)/s*Math.PI*2,l=n.point,c=n.worldSize/(n.tileSize*s);return m(o,o,[l.x,l.y,-n.worldSize/Math.PI/2,]),g(o,o,[c,c,c]),y(o,o,-n._center.lat*j),x(o,o,-n._center.lng*j),x(o,o,a),r&&g(o,o,[1,-1,1]),o},i.globeTileBounds=uX,i.globeToMercatorTransition=function(i){return Y(5,6,i)},i.identity=p,i.identity$1=O,i.invert=function(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=r[4],c=r[5],u=r[6],h=r[7],d=r[8],p=r[9],f=r[10],m=r[11],g=r[12],y=r[13],x=r[14],$=r[15],v=n*c-o*l,_=n*u-s*l,b=n*h-a*l,w=o*u-s*c,T=o*h-a*c,E=s*h-a*u,S=d*y-p*g,I=d*x-f*g,C=d*$-m*g,z=p*x-f*y,A=p*$-m*y,k=f*$-m*x,P=v*k-_*A+b*z+w*C-T*I+E*S;return P?(i[0]=(c*k-u*A+h*z)*(P=1/P),i[1]=(s*A-o*k-a*z)*P,i[2]=(y*E-x*T+$*w)*P,i[3]=(f*T-p*E-m*w)*P,i[4]=(u*C-l*k-h*I)*P,i[5]=(n*k-s*C+a*I)*P,i[6]=(x*b-g*E-$*_)*P,i[7]=(d*E-f*b+m*_)*P,i[8]=(l*A-c*C+h*S)*P,i[9]=(o*C-n*A-a*S)*P,i[10]=(g*T-y*b+$*v)*P,i[11]=(p*b-d*T-m*v)*P,i[12]=(c*I-l*z-u*S)*P,i[13]=(n*z-o*I+s*S)*P,i[14]=(y*_-g*w-x*v)*P,i[15]=(d*w-p*_+f*v)*P,i):null},i.isMapAuthenticated=function(i){return ej.has(i)},i.isMapboxURL=eL,i.latFromMercatorY=sT,i.len=b,i.length=b,i.length$1=function(i){return Math.hypot(i[0],i[1],i[2],i[3])},i.loadVectorTile=hs,i.makeRequest=eY,i.mercatorXfromLng=s_,i.mercatorYfromLat=sb,i.mercatorZfromAltitude=sw,i.mul=$,i.mul$1=S,i.multiply=function(i,r,n){var o=r[0],s=r[1],a=r[2],l=r[3],c=r[4],u=r[5],h=r[6],d=r[7],p=r[8],f=n[0],m=n[1],g=n[2],y=n[3],x=n[4],$=n[5],v=n[6],_=n[7],b=n[8];return i[0]=f*o+m*l+g*h,i[1]=f*s+m*c+g*d,i[2]=f*a+m*u+g*p,i[3]=y*o+x*l+$*h,i[4]=y*s+x*c+$*d,i[5]=y*a+x*u+$*p,i[6]=v*o+_*l+b*h,i[7]=v*s+_*c+b*d,i[8]=v*a+_*u+b*p,i},i.multiply$1=f,i.multiply$2=S,i.nextPowerOfTwo=eo,i.normalize=A,i.normalize$1=function(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=n*n+o*o+s*s+a*a;return l>0&&(l=1/Math.sqrt(l)),i[0]=n*l,i[1]=o*l,i[2]=s*l,i[3]=a*l,i},i.number=i$,i.ortho=function(i,r,n,o,s,a,l){var c=1/(r-n),u=1/(o-s),h=1/(a-l);return i[0]=-2*c,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*u,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*h,i[11]=0,i[12]=(r+n)*c,i[13]=(s+o)*u,i[14]=(l+a)*h,i[15]=1,i},i.pbf=lA,i.perspective=function(i,r,n,o,s){var a,l=1/Math.tan(r/2);return i[0]=l/n,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=l,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,null!=s&&s!==1/0?(i[10]=(s+o)*(a=1/(o-s)),i[14]=2*s*o*a):(i[10]=-1,i[14]=-2*o),i},i.pick=function(i,r){const n={};for(let o=0;othis._layers[i.id]),h=u[0];if("none"===h.visibility)continue;const d=h.source||"";let p=this.familiesBySource[d];p||(p=this.familiesBySource[d]={});const f=h.sourceLayer||"_geojsonTileLayer";let m=p[f];m||(m=p[f]=[]),m.push(u)}}}const{ImageBitmap:s}=i.window;class a{loadTile(r,n){const{uid:o,encoding:a,rawImageData:l,padding:c,buildQuadTree:u}=r,h=s&&l instanceof s?this.getImageData(l,c):l;n(null,new i.DEMData(o,h,a,c<1,u))}getImageData(r,n){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(r.width,r.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=r.width,this.offscreenCanvas.height=r.height,this.offscreenCanvasContext.drawImage(r,0,0,r.width,r.height);const o=this.offscreenCanvasContext.getImageData(-n,-n,r.width+2*n,r.height+2*n);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new i.RGBAImage({width:o.width,height:o.height},o.data)}}var l,c=function i(r,n){var o,s=r&&r.type;if("FeatureCollection"===s)for(o=0;o=Math.abs(c)?n-u+c:c-u+n,n=u}n+o>=0!=!!r&&i.reverse()}const d=i.vectorTile.VectorTileFeature.prototype.toGeoJSON;class p{constructor(r){this._feature=r,this.extent=i.EXTENT,this.type=r.type,this.properties=r.tags,"id"in r&&!isNaN(r.id)&&(this.id=parseInt(r.id,10))}loadGeometry(){if(1===this._feature.type){const r=[];for(const n of this._feature.geometry)r.push([new i.pointGeometry(n[0],n[1]),]);return r}{const o=[];for(const s of this._feature.geometry){const a=[];for(const l of s)a.push(new i.pointGeometry(l[0],l[1]));o.push(a)}return o}}toGeoJSON(i,r,n){return d.call(this,i,r,n)}}class f{constructor(r){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=r.length,this._features=r}feature(i){return new p(this._features[i])}}var m=i.vectorTile.VectorTileFeature,g=y;function y(i,r){this.options=r||{},this.features=i,this.length=i.length}function x(i,r){this.id="number"==typeof i.id?i.id:void 0,this.type=i.type,this.rawGeometry=1===i.type?[i.geometry]:i.geometry,this.properties=i.tags,this.extent=r||4096}y.prototype.feature=function(i){return new x(this.features[i],this.options.extent)},x.prototype.loadGeometry=function(){var r=this.rawGeometry;this.geometry=[];for(var n=0;n>31}function S(i,r){for(var n=i.loadGeometry(),o=i.type,s=0,a=0,l=n.length,c=0;ci[0],P=i=>i[1];class D{constructor(i,r=k,n=P,o=64,s=Float64Array){this.nodeSize=o,this.points=i;const a=i.length<65536?Uint16Array:Uint32Array,l=this.ids=new a(i.length),c=this.coords=new s(2*i.length);for(let u=0;u>1;(function i(r,n,o,s,a,l){for(;a>s;){if(a-s>600){const c=a-s+1,u=o-s+1,h=Math.log(c),d=.5*Math.exp(2*h/3),p=.5*Math.sqrt(h*d*(c-d)/c)*(u-c/2<0?-1:1);i(r,n,o,Math.max(s,Math.floor(o-u*d/c+p)),Math.min(a,Math.floor(o+(c-u)*d/c+p)),l)}const f=n[2*o+l];let m=s,g=a;for(C(r,n,s,o),n[2*a+l]>f&&C(r,n,s,a);mf;)g--}n[2*s+l]===f?C(r,n,s,g):C(r,n,++g,a),g<=o&&(s=g+1),o<=g&&(a=g-1)}})(r,n,c,s,a,l%2),i(r,n,o,s,c-1,l+1),i(r,n,o,c+1,a,l+1)}(l,c,o,0,l.length-1,0)}range(i,r,n,o){return function(i,r,n,o,s,a,l){const c=[0,i.length-1,0],u=[];let h,d;for(;c.length;){const p=c.pop(),f=c.pop(),m=c.pop();if(f-m<=l){for(let g=m;g<=f;g++)h=r[2*g],d=r[2*g+1],h>=n&&h<=s&&d>=o&&d<=a&&u.push(i[g]);continue}const y=Math.floor((m+f)/2);h=r[2*y],d=r[2*y+1],h>=n&&h<=s&&d>=o&&d<=a&&u.push(i[y]);const x=(p+1)%2;(0===p?n<=h:o<=d)&&(c.push(m),c.push(y-1),c.push(x)),(0===p?s>=h:a>=d)&&(c.push(y+1),c.push(f),c.push(x))}return u}(this.ids,this.coords,i,r,n,o,this.nodeSize)}within(i,r,n){return function(i,r,n,o,s,a){const l=[0,i.length-1,0],c=[],u=s*s;for(;l.length;){const h=l.pop(),d=l.pop(),p=l.pop();if(d-p<=a){for(let f=p;f<=d;f++)A(r[2*f],r[2*f+1],n,o)<=u&&c.push(i[f]);continue}const m=Math.floor((p+d)/2),g=r[2*m],y=r[2*m+1];A(g,y,n,o)<=u&&c.push(i[m]);const x=(h+1)%2;(0===h?n-s<=g:o-s<=y)&&(l.push(p),l.push(m-1),l.push(x)),(0===h?n+s>=g:o+s>=y)&&(l.push(m+1),l.push(d),l.push(x))}return c}(this.ids,this.coords,i,r,n,this.nodeSize)}}const L=Math.fround||(l=new Float32Array(1),i=>(l[0]=+i,l[0]));class B{constructor(i){this.options=N(Object.create({minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:i=>i}),i),this.trees=Array(this.options.maxZoom+1)}load(i){const{log:r,minZoom:n,maxZoom:o,nodeSize:s}=this.options;r&&console.time("total time");const a=`prepare ${i.length} points`;r&&console.time(a),this.points=i;let l=[];for(let c=0;c=n;u--){const h=+Date.now();l=this._cluster(l,u),this.trees[u]=new D(l,G,Z,s,Float32Array),r&&console.log("z%d: %d clusters in %dms",u,l.length,+Date.now()-h)}return r&&console.timeEnd("total time"),this}getClusters(i,r){let n=((i[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,i[1]));let s=180===i[2]?180:((i[2]+180)%360+360)%360-180;const a=Math.max(-90,Math.min(90,i[3]));if(i[2]-i[0]>=360)n=-180,s=180;else if(n>s){const l=this.getClusters([n,o,180,a],r),c=this.getClusters([-180,o,s,a],r);return l.concat(c)}const u=this.trees[this._limitZoom(r)],h=u.range(U(n),V(a),U(s),V(o)),d=[];for(const p of h){const f=u.points[p];d.push(f.numPoints?F(f):this.points[f.index])}return d}getChildren(i){const r=this._getOriginId(i),n=this._getOriginZoom(i),o="No cluster with the specified id.",s=this.trees[n];if(!s)throw Error(o);const a=s.points[r];if(!a)throw Error(o);const l=this.options.radius/(this.options.extent*Math.pow(2,n-1)),c=s.within(a.x,a.y,l),u=[];for(const h of c){const d=s.points[h];d.parentId===i&&u.push(d.numPoints?F(d):this.points[d.index])}if(0===u.length)throw Error(o);return u}getLeaves(i,r,n){const o=[];return this._appendLeaves(o,i,r=r||10,n=n||0,0),o}getTile(i,r,n){const o=this.trees[this._limitZoom(i)],s=Math.pow(2,i),{extent:a,radius:l}=this.options,c=l/a,u=(n-c)/s,h=(n+1+c)/s,d={features:[]};return this._addTileFeatures(o.range((r-c)/s,u,(r+1+c)/s,h),o.points,r,n,s,d),0===r&&this._addTileFeatures(o.range(1-c/s,u,1,h),o.points,s,n,s,d),r===s-1&&this._addTileFeatures(o.range(0,u,c/s,h),o.points,-1,n,s,d),d.features.length?d:null}getClusterExpansionZoom(i){let r=this._getOriginZoom(i)-1;for(;r<=this.options.maxZoom;){const n=this.getChildren(i);if(r++,1!==n.length)break;i=n[0].properties.cluster_id}return r}_appendLeaves(i,r,n,o,s){const a=this.getChildren(r);for(const l of a){const c=l.properties;if(c&&c.cluster?s+c.point_count<=o?s+=c.point_count:s=this._appendLeaves(i,c.cluster_id,n,o,s):sr&&(m+=y.numPoints||1)}if(m>f&&m>=l){let x=h.x*f,$=h.y*f,v=a&&f>1?this._map(h,!0):null;const _=(u<<5)+(r+1)+this.points.length;for(const b of p){const w=d.points[b];if(w.zoom<=r)continue;w.zoom=r;const T=w.numPoints||1;x+=w.x*T,$+=w.y*T,w.parentId=_,a&&(v||(v=this._map(h,!0)),a(v,this._map(w)))}h.parentId=_,n.push(R(x/m,$/m,_,m,v))}else if(n.push(h),m>1)for(const E of p){const S=d.points[E];S.zoom<=r||(S.zoom=r,n.push(S))}}return n}_getOriginId(i){return i-this.points.length>>5}_getOriginZoom(i){return(i-this.points.length)%32}_map(i,r){if(i.numPoints)return r?N({},i.properties):i.properties;const n=this.points[i.index].properties,o=this.options.map(n);return r&&o===n?N({},o):o}}function R(i,r,n,o,s){return{x:L(i),y:L(r),zoom:1/0,id:n,parentId:-1,numPoints:o,properties:s}}function M(i,r){const[n,o]=i.geometry.coordinates;return{x:L(U(n)),y:L(V(o)),zoom:1/0,index:r,parentId:-1}}function F(i){return{type:"Feature",id:i.id,properties:O(i),geometry:{type:"Point",coordinates:[360*(i.x-.5),j(i.y),]}}}function O(i){const r=i.numPoints,n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r;return N(N({},i.properties),{cluster:!0,cluster_id:i.id,point_count:r,point_count_abbreviated:n})}function U(i){return i/360+.5}function V(i){const r=Math.sin(i*Math.PI/180),n=.5-.25*Math.log((1+r)/(1-r))/Math.PI;return n<0?0:n>1?1:n}function j(i){const r=(180-360*i)*Math.PI/180;return 360*Math.atan(Math.exp(r))/Math.PI-90}function N(i,r){for(const n in r)i[n]=r[n];return i}function G(i){return i.x}function Z(i){return i.y}function q(i,r,n,o,s,a){var l=s-n,c=a-o;if(0!==l||0!==c){var u=((i-n)*l+(r-o)*c)/(l*l+c*c);u>1?(n=s,o=a):u>0&&(n+=l*u,o+=c*u)}return(l=i-n)*l+(c=r-o)*c}function X(i,r,n,o){var s={id:void 0===i?null:i,type:r,geometry:n,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(i){var r=i.geometry,n=i.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)W(i,r);else if("Polygon"===n||"MultiLineString"===n)for(var o=0;o0&&(l+=o?(s*h-u*a)/2:Math.sqrt(Math.pow(u-s,2)+Math.pow(h-a,2))),s=u,a=h}var d=r.length-3;r[2]=1,function i(r,n,o,s){for(var a,l=s,c=o-n>>1,u=o-n,h=r[n],d=r[n+1],p=r[o],f=r[o+1],m=n+3;ml)a=m,l=g;else if(g===l){var y=Math.abs(m-c);ys&&(a-n>3&&i(r,n,a,s),r[a+2]=l,o-a>3&&i(r,a,o,s))}(r,0,d,n),r[d+2]=1,r.size=Math.abs(l),r.start=0,r.end=r.size}function J(i,r,n,o){for(var s=0;s1?1:n}function et(i,r,n,o,s,a,l,c){if(o/=r,a>=(n/=r)&&l=o)return null;for(var u=[],h=0;h=n&&g=o)){var y=[];if("Point"===f||"MultiPoint"===f)ei(p,y,n,o,s);else if("LineString"===f)er(p,y,n,o,s,!1,c.lineMetrics);else if("MultiLineString"===f)eo(p,y,n,o,s,!1);else if("Polygon"===f)eo(p,y,n,o,s,!0);else if("MultiPolygon"===f)for(var x=0;x=n&&l<=o&&(r.push(i[a]),r.push(i[a+1]),r.push(i[a+2]))}}function er(i,r,n,o,s,a,l){for(var c,u,h=en(i),d=0===s?ea:el,p=i.start,f=0;fn&&(u=d(h,m,g,x,$,n),l&&(h.start=p+c*u)):v>o?_=n&&(u=d(h,m,g,x,$,n),b=!0),_>o&&v<=o&&(u=d(h,m,g,x,$,o),b=!0),!a&&b&&(l&&(h.end=p+c*u),r.push(h),h=en(i)),l&&(p+=c)}var w=i.length-3;m=i[w],g=i[w+1],y=i[w+2],(v=0===s?m:g)>=n&&v<=o&&es(h,m,g,y),w=h.length-3,a&&w>=3&&(h[w]!==h[0]||h[w+1]!==h[1])&&es(h,h[0],h[1],h[2]),h.length&&r.push(h)}function en(i){var r=[];return r.size=i.size,r.start=i.start,r.end=i.end,r}function eo(i,r,n,o,s,a){for(var l=0;ll.maxX&&(l.maxX=d),p>l.maxY&&(l.maxY=p)}return l}function ef(i,r,n,o){var s=r.geometry,a=r.type,l=[];if("Point"===a||"MultiPoint"===a)for(var c=0;c0&&r.size<(s?l:o))n.numPoints+=r.length/3;else{for(var c=[],u=0;ul)&&(n.numSimplified++,c.push(r[u]),c.push(r[u+1])),n.numPoints++;s&&function(i,r){for(var n=0,o=0,s=i.length,a=s-2;o0===r)for(o=0,s=i.length;o24)throw Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw Error("promoteId and generateId cannot be used together.");var o,s,a,l,c,u,h=function(i,r){var n=[];if("FeatureCollection"===i.type)for(var o=0;o1&&console.time("creation"),f=this.tiles[p]=ep(i,r,n,o,u),this.tileCoords.push({z:r,x:n,y:o}),h)){h>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",r,n,o,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var m="z"+r;this.stats[m]=(this.stats[m]||0)+1,this.total++}if(f.source=i,s){if(r===u.maxZoom||r===s)continue;var g=1<1&&console.time("clipping");var y,x,$,v,_,b,w=.5*u.buffer/u.extent,T=.5-w,E=.5+w,S=1+w;y=x=$=v=null,_=et(i,d,n-w,n+E,0,f.minX,f.maxX,u),b=et(i,d,n+T,n+S,0,f.minX,f.maxX,u),i=null,_&&(y=et(_,d,o-w,o+E,1,f.minY,f.maxY,u),x=et(_,d,o+T,o+S,1,f.minY,f.maxY,u),_=null),b&&($=et(b,d,o-w,o+E,1,f.minY,f.maxY,u),v=et(b,d,o+T,o+S,1,f.minY,f.maxY,u),b=null),h>1&&console.timeEnd("clipping"),c.push(y||[],r+1,2*n,2*o),c.push(x||[],r+1,2*n,2*o+1),c.push($||[],r+1,2*n+1,2*o),c.push(v||[],r+1,2*n+1,2*o+1)}}},e8.prototype.getTile=function(i,r,n){var o=this.options,s=o.extent,a=o.debug;if(i<0||i>24)return null;var l=1<1&&console.log("drilling down to z%d-%d-%d",i,r,n);for(var u,h=i,d=r,p=n;!u&&h>0;)h--,d=Math.floor(d/2),p=Math.floor(p/2),u=this.tiles[eg(h,d,p)];return u&&u.source?(a>1&&console.log("found parent tile z%d-%d-%d",h,d,p),a>1&&console.time("drilling down"),this.splitTile(u.source,h,d,p,i,r,n),a>1&&console.timeEnd("drilling down"),this.tiles[c]?eh(this.tiles[c],s):null):null};class ey extends i.VectorTileWorkerSource{constructor(i,r,n,o,s){super(i,r,n,o,function(i,r){const n=i.tileID.canonical;if(!this._geoJSONIndex)return r(null,null);const o=this._geoJSONIndex.getTile(n.z,n.x,n.y);if(!o)return r(null,null);const s=new f(o.features);let a=$(s);0===a.byteOffset&&a.byteLength===a.buffer.byteLength||(a=new Uint8Array(a)),r(null,{vectorTile:s,rawData:a.buffer})}),s&&(this.loadGeoJSON=s)}loadData(r,n){const o=r&&r.request,s=o&&o.collectResourceTiming;this.loadGeoJSON(r,(a,l)=>{if(a||!l)return n(a);if("object"!=typeof l)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{c(l,!0);try{var u,h;if(r.filter){const d=i.createExpression(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));const p=l.features.filter(i=>d.value.evaluate({zoom:0},i));l={type:"FeatureCollection",features:p}}this._geoJSONIndex=r.cluster?new B(function({superclusterOptions:r,clusterProperties:n}){if(!n||!r)return r;const o={},s={},a={accumulated:null,zoom:0},l={properties:null},c=Object.keys(n);for(const u of c){const[h,d]=n[u],p=i.createExpression(d),f=i.createExpression("string"==typeof h?[h,["accumulated",],["get",u,],]:h);o[u]=p.value,s[u]=f.value}return r.map=i=>{l.properties=i;const r={};for(const n of c)r[n]=o[n].evaluate(a,l);return r},r.reduce=(i,r)=>{for(const n of(l.properties=r,c))a.accumulated=i[n],i[n]=s[n].evaluate(a,l)},r}(r)).load(l.features):(u=l,h=r.geojsonVtOptions,new e8(u,h))}catch(f){return n(f)}this.loaded={};const m={};if(s){const g=i.getPerformanceMeasurement(o);g&&(m.resourceTiming={},m.resourceTiming[r.source]=JSON.parse(JSON.stringify(g)))}n(null,m)}})}reloadTile(i,r){const n=this.loaded;return n&&n[i.uid]?super.reloadTile(i,r):this.loadTile(i,r)}loadGeoJSON(r,n){if(r.request)i.getJSON(r.request,n);else{if("string"!=typeof r.data)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(r.data))}catch(o){return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(i,r){try{r(null,this._geoJSONIndex.getClusterExpansionZoom(i.clusterId))}catch(n){r(n)}}getClusterChildren(i,r){try{r(null,this._geoJSONIndex.getChildren(i.clusterId))}catch(n){r(n)}}getClusterLeaves(i,r){try{r(null,this._geoJSONIndex.getLeaves(i.clusterId,i.limit,i.offset))}catch(n){r(n)}}}class ex{constructor(r){this.self=r,this.actor=new i.Actor(r,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:ey},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(i,r)=>{if(this.workerSourceTypes[i])throw Error(`Worker source with name "${i}" already registered.`);this.workerSourceTypes[i]=r},this.self.registerRTLTextPlugin=r=>{if(i.plugin.isParsed())throw Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=r.applyArabicShaping,i.plugin.processBidirectionalText=r.processBidirectionalText,i.plugin.processStyledBidirectionalText=r.processStyledBidirectionalText}}clearCaches(i,r,n){delete this.layerIndexes[i],delete this.availableImages[i],delete this.workerSources[i],delete this.demWorkerSources[i],n()}checkIfReady(i,r,n){n()}setReferrer(i,r){this.referrer=r}spriteLoaded(r,n){for(const o in this.isSpriteLoaded[r]=n,this.workerSources[r]){const s=this.workerSources[r][o];for(const a in s)s[a]instanceof i.VectorTileWorkerSource&&(s[a].isSpriteLoaded=n,s[a].fire(new i.Event("isSpriteLoaded")))}}setImages(i,r,n){for(const o in this.availableImages[i]=r,this.workerSources[i]){const s=this.workerSources[i][o];for(const a in s)s[a].availableImages=r}n()}enableTerrain(i,r,n){this.terrain=r,n()}setProjection(r,n){this.projections[r]=i.getProjection(n)}setLayers(i,r,n){this.getLayerIndex(i).replace(r),n()}updateLayers(i,r,n){this.getLayerIndex(i).update(r.layers,r.removedIds),n()}loadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).loadTile(s,o)}loadDEMTile(r,n,o){const s=this.enableTerrain?i.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(r,n.source).loadTile(s,o)}reloadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).reloadTile(s,o)}abortTile(i,r,n){this.getWorkerSource(i,r.type,r.source).abortTile(r,n)}removeTile(i,r,n){this.getWorkerSource(i,r.type,r.source).removeTile(r,n)}removeSource(i,r,n){if(!this.workerSources[i]||!this.workerSources[i][r.type]||!this.workerSources[i][r.type][r.source])return;const o=this.workerSources[i][r.type][r.source];delete this.workerSources[i][r.type][r.source],void 0!==o.removeSource?o.removeSource(r,n):n()}loadWorkerSource(i,r,n){try{this.self.importScripts(r.url),n()}catch(o){n(o.toString())}}syncRTLPluginState(r,n,o){try{i.plugin.setState(n);const s=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&null!=s){this.self.importScripts(s);const a=i.plugin.isParsed();o(a?void 0:Error(`RTL Text Plugin failed to import scripts from ${s}`),a)}}catch(l){o(l.toString())}}getAvailableImages(i){let r=this.availableImages[i];return r||(r=[]),r}getLayerIndex(i){let r=this.layerIndexes[i];return r||(r=this.layerIndexes[i]=new o),r}getWorkerSource(i,r,n){return this.workerSources[i]||(this.workerSources[i]={}),this.workerSources[i][r]||(this.workerSources[i][r]={}),this.workerSources[i][r][n]||(this.workerSources[i][r][n]=new this.workerSourceTypes[r]({send:(r,n,o,s,a,l)=>{this.actor.send(r,n,o,i,a,l)},scheduler:this.actor.scheduler},this.getLayerIndex(i),this.getAvailableImages(i),this.isSpriteLoaded[i])),this.workerSources[i][r][n]}getDEMWorkerSource(i,r){return this.demWorkerSources[i]||(this.demWorkerSources[i]={}),this.demWorkerSources[i][r]||(this.demWorkerSources[i][r]=new a),this.demWorkerSources[i][r]}enforceCacheSizeLimit(r,n){i.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(i,r,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new ex(self)),ex}),s(["./shared"],function(i){var r=n;function n(i){var r,s;return r=i,"undefined"!=typeof window&&"undefined"!=typeof document&&!!Array.prototype&&!!Array.prototype.every&&!!Array.prototype.filter&&!!Array.prototype.forEach&&!!Array.prototype.indexOf&&!!Array.prototype.lastIndexOf&&!!Array.prototype.map&&!!Array.prototype.some&&!!Array.prototype.reduce&&!!Array.prototype.reduceRight&&!!Array.isArray&&!!Function.prototype&&!!Function.prototype.bind&&!!Object.keys&&!!Object.create&&!!Object.getPrototypeOf&&!!Object.getOwnPropertyNames&&!!Object.isSealed&&!!Object.isFrozen&&!!Object.isExtensible&&!!Object.getOwnPropertyDescriptor&&!!Object.defineProperty&&!!Object.defineProperties&&!!Object.seal&&!!Object.freeze&&!!Object.preventExtensions&&!!("JSON"in window&&"parse"in JSON&&"stringify"in JSON)&&!!function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var i,r,n=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(n);try{r=new Worker(o),i=!0}catch(s){i=!1}return r&&r.terminate(),URL.revokeObjectURL(o),i}()&&"Uint8ClampedArray"in window&&!!ArrayBuffer.isView&&!!function(){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");if(!r)return!1;var n=r.getImageData(0,0,1,1);return n&&n.width===i.width}()&&(void 0===o[s=r&&r.failIfMajorPerformanceCaveat]&&(o[s]=function(i){var r,o,s,a,l=(r=i,o=document.createElement("canvas"),(s=Object.create(n.webGLContextAttributes)).failIfMajorPerformanceCaveat=r,o.getContext("webgl",s)||o.getContext("experimental-webgl",s));if(!l)return!1;try{a=l.createShader(l.VERTEX_SHADER)}catch(c){return!1}return!(!a||l.isContextLost())&&(l.shaderSource(a,"void main() {}"),l.compileShader(a),!0===l.getShaderParameter(a,l.COMPILE_STATUS))}(s)),!!o[s]&&!document.documentMode)}var o={};function s(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=n*a-s*o;return l?(i[0]=a*(l=1/l),i[1]=-o*l,i[2]=-s*l,i[3]=n*l,i):null}function a(i,r){if(Array.isArray(i)){if(!Array.isArray(r)||i.length!==r.length)return!1;for(let n=0;n{i.window.removeEventListener("click",d,!0)},0)},l.mousePos=function(i,r){const n=i.getBoundingClientRect();return p(i,n,r)},l.touchPos=function(i,r){const n=i.getBoundingClientRect(),o=[];for(let s=0;s=0?0:r.button};class m extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(i){if(this.loaded!==i&&(this.loaded=i,i)){for(const{ids:r,callback:n}of this.requestors)this._notify(r,n);this.requestors=[]}}getImage(i){return this.images[i]}addImage(i,r){this._validate(i,r)&&(this.images[i]=r)}_validate(r,n){let o=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "content" value`))),o=!1),o}_validateStretch(i,r){if(!i)return!0;let n=0;for(const o of i){if(o[0]{this.ready=!0})}broadcast(r,n,o){i.asyncAll(this.actors,(i,o)=>{i.send(r,n,o)},o=o||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(i=>{i.remove()}),this.actors=[],this.workerPool.release(this.id)}}function C(r,n,o){return n*(i.EXTENT/(r.tileSize*Math.pow(2,o-r.tileID.overscaledZ)))}I.Actor=i.Actor;class z{constructor(i,r,n){this.context=i;const o=i.gl;this.buffer=o.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const A={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class k{constructor(i,r,n,o){this.length=r.length,this.attributes=n,this.itemSize=r.bytesPerElement,this.dynamicDraw=o,this.context=i;const s=i.gl;this.buffer=s.createBuffer(),i.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,r){for(let n=0;no.pointCoordinate3D(i)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(r,n){let o,s;if(r instanceof i.pointGeometry||"number"==typeof r[0]){const a=i.pointGeometry.convert(r);o=[i.pointGeometry.convert(r)],s=n.isPointAboveHorizon(a)}else{const l=i.pointGeometry.convert(r[0]),c=i.pointGeometry.convert(r[1]);o=[l,c],s=i.polygonizeBounds(l,c).every(i=>n.isPointAboveHorizon(i))}return new M(o,n.getCameraPoint(),s,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(r){return i.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const n=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],s=i.polygonizeBounds(n,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=o.x?s[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(s[3]=this.cameraPoint)),i.bufferConvexPolygon(s,r)}containsTile(r,n,o){var s;const a=r.queryPadding+1,l=r.tileID.wrap,c=o?this._bufferedCameraMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)):this._bufferedScreenMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)),u=this.screenGeometryMercator.map(n=>i.getTileVec3(r.tileTransform,n,l)),h=u.map(r=>new i.pointGeometry(r[0],r[1])),d=n.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),p=i.getTileVec3(r.tileTransform,d,l),f=u.map(r=>{const n=i.sub(r,r,p);return i.normalize(n,n),new i.Ray(p,n)}),m=C(r,1,n.zoom);if(i.polygonIntersectsBox(c,0,0,i.EXTENT,i.EXTENT))return{queryGeometry:this,tilespaceGeometry:h,tilespaceRays:f,bufferedTilespaceGeometry:c,bufferedTilespaceBounds:((s=i.getBounds(c)).min.x=i.clamp(s.min.x,0,i.EXTENT),s.min.y=i.clamp(s.min.y,0,i.EXTENT),s.max.x=i.clamp(s.max.x,0,i.EXTENT),s.max.y=i.clamp(s.max.y,0,i.EXTENT),s),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(i,r){const n=F(i);if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{const o=this.bufferedScreenGeometry(i).map(i=>r.pointCoordinate3D(i));return this._screenRaycastCache[n]=o,o}}_bufferedCameraMercator(i,r){const n=F(i);if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{const o=this.bufferedCameraGeometry(i).map(i=>r.pointCoordinate3D(i));return this._cameraRaycastCache[n]=o,o}}}function F(i){return 100*i|0}function O(r,n,o){const s=function(s,a){if(s)return o(s);if(a){const l=i.pick(i.extend(a,r),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding",]);a.vector_layers&&(l.vectorLayers=a.vector_layers,l.vectorLayerIds=l.vectorLayers.map(i=>i.id)),l.tiles=n.canonicalizeTileset(l,r.url),o(null,l)}};return r.url?i.getJSON(n.transformRequest(n.normalizeSourceURL(r.url),i.ResourceType.Source),s):i.exported.frame(()=>s(null,r))}class U{constructor(r,n,o){this.bounds=i.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(i){return Array.isArray(i)&&4===i.length?[Math.max(-180,i[0]),Math.max(-90,i[1]),Math.min(180,i[2]),Math.min(90,i[3]),]:[-180,-90,180,90]}contains(r){const n=Math.pow(2,r.z),o=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*n),s=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*n),a=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*n),l=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*n);return r.x>=o&&r.x=s&&r.y{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new U(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(i){this.map=i,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loadTile(r,n){const o=i.exported.devicePixelRatio>=2,s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(o,s,a,l)=>{if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(s){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:a,expires:l});const c=this.map.painter.context,u=c.gl;r.texture=this.map.painter.getTileTexture(s.width),r.texture?r.texture.update(s,{useMipmap:!0}):(r.texture=new i.Texture(c,s,u.RGBA,{useMipmap:!0}),r.texture.bind(u.LINEAR,u.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&u.texParameterf(u.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),r.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),n(null)}})}abortTile(i,r){i.request&&(i.request.cancel(),delete i.request),r()}unloadTile(i,r){i.texture&&this.map.painter.saveTileTexture(i.texture),r()}hasTransition(){return!1}}let j;function N(r,n,o,s,a,l,c,u){const h=[r,o,a,n,s,l,1,1,1],d=[c,u,1],p=i.adjoint([],h),[f,m,g]=i.transformMat3(d,d,i.transpose(p,p));return i.multiply(h,[f,0,0,0,m,0,0,0,g],h)}class G extends i.Evented{constructor(i,r,n,o){super(),this.id=i,this.dispatcher=n,this.coordinates=r.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=r}load(r,n){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(o,s)=>{this._loaded=!0,o?this.fire(new i.ErrorEvent(o)):s&&(this.image=i.exported.getImageData(s),this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),n&&n(),this._finishLoading())})}loaded(){return this._loaded}updateImage(i){return this.image&&i.url&&(this.options.url=i.url,this.load(i.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(i){this.map=i,this.load()}setCoordinates(r){this.coordinates=r,delete this._boundsArray;const n=r.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(r){let n=1/0,o=1/0,s=-1/0,a=-1/0;for(const l of r)n=Math.min(n,l.x),o=Math.min(o,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y);const c=Math.max(s-n,a-o),u=Math.max(0,Math.floor(-Math.log(c)/Math.LN2)),h=Math.pow(2,u);return new i.CanonicalTileID(u,Math.floor((n+s)/2*h),Math.floor((o+a)/2*h))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const r=i.tileTransform(this.tileID,this.map.transform.projection),[n,o,s,a]=this.coordinates.map(n=>{const o=r.projection.project(n[0],n[1]);return i.getTilePoint(r,o)._round()});return this.perspectiveTransform=function(r,n,o,s,a,l,c,u,h,d){const p=N(0,0,r,0,0,n,r,n),f=N(o,s,a,l,c,u,h,d);return i.multiply(f,i.adjoint(p,p),f),[f[6]/f[8]*r/i.EXTENT,f[7]/f[8]*n/i.EXTENT,]}(this.width,this.height,n.x,n.y,o.x,o.y,a.x,a.y,s.x,s.y),this._boundsArray=new i.StructArrayLayout4i8,this._boundsArray.emplaceBack(n.x,n.y,0,0),this._boundsArray.emplaceBack(o.x,o.y,i.EXTENT,0),this._boundsArray.emplaceBack(a.x,a.y,0,i.EXTENT),this._boundsArray.emplaceBack(s.x,s.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const r=this.map.painter.context,n=r.gl;for(const o in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new i.Texture(r,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}loadTile(i,r){this.tileID&&this.tileID.equals(i.tileID.canonical)?(this.tiles[String(i.tileID.wrap)]=i,i.buckets={},r(null)):(i.state="errored",r(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const Z={vector:class extends i.Evented{constructor(r,n,o,s){if(super(),this.id=r,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,i.extend(this,i.pick(n,["url","scheme","tileSize","promoteId",])),this._options=i.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(s),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=O(this._options,this.map._requestManager,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new U(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}onAdd(i){this.map=i,this.load()}setSourceProperty(i){this._tileJSONRequest&&this._tileJSONRequest.cancel(),i();const r=this.map.style._getSourceCaches(this.id);for(const n of r)n.clearTiles();this.load()}setTiles(i){return this.setSourceProperty(()=>{this._options.tiles=i}),this}setUrl(i){return this.setSourceProperty(()=>{this.url=i,this._options.url=i}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),s={request:this.map._requestManager.transformRequest(o,i.ResourceType.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile};if(s.request.collectResourceTiming=this._collectResourceTiming,r.actor&&"expired"!==r.state)"loading"===r.state?r.reloadCallback=n:r.request=r.actor.send("reloadTile",s,l.bind(this));else if(r.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",s,l.bind(this),void 0,!0);else{const a=i.loadVectorTile.call({deduped:this._deduped},s,(i,n)=>{i||!n?l.call(this,i):(s.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},r.actor&&r.actor.send("loadTile",s,l.bind(this),void 0,!0))},!0);r.request={cancel:a}}function l(o,s){return delete r.request,r.aborted?n(null):o&&404!==o.status?n(o):(s&&s.resourceTiming&&(r.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&r.setExpiryData(s),r.loadVectorData(s,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.actor&&i.actor.send("abortTile",{uid:i.uid,type:this.type,source:this.id})}unloadTile(i){i.unloadVectorData(),i.actor&&i.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:V,"raster-dem":class extends V{constructor(r,n,o,s){super(r,n,o,s),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function s(i,o){i&&(r.state="errored",n(i)),o&&(r.dem=o,r.dem.onDeserialize(),r.needsHillshadePrepare=!0,r.needsDEMTextureUpload=!0,r.state="loaded",n(null))}r.request=i.getImage(this.map._requestManager.transformRequest(o,i.ResourceType.Tile),(function(o,a,l,c){if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(a){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:l,expires:c});const u=i.window.ImageBitmap&&a instanceof i.window.ImageBitmap&&(null==j&&(j=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof i.window.createImageBitmap),j),h=1-(a.width-i.prevPowerOfTwo(a.width))/2;h<1||r.neighboringTiles||(r.neighboringTiles=this._getNeighboringTiles(r.tileID));const d=u?a:i.exported.getImageData(a,h),p={uid:r.uid,coord:r.tileID,source:this.id,rawImageData:d,encoding:this.encoding,padding:h};r.actor&&"expired"!==r.state||(r.actor=this.dispatcher.getActor(),r.actor.send("loadDEMTile",p,s.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(r){const n=r.canonical,o=Math.pow(2,n.z),s=(n.x-1+o)%o,a=0===n.x?r.wrap-1:r.wrap,l=(n.x+1+o)%o,c=n.x+1===o?r.wrap+1:r.wrap,u={};return u[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y).key]={backfilled:!1},u[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y).key]={backfilled:!1},n.y>0&&(u[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y-1).key]={backfilled:!1},u[new i.OverscaledTileID(r.overscaledZ,r.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},u[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new i.ErrorEvent(r));else{const o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(o.resourceTiming=n.resourceTiming[this.id]),this.fire(new i.Event("data",o)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(r,n){const o=r.actor?"reloadTile":"loadTile";r.actor=this.actor,r.request=this.actor.send(o,{type:this.type,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(i,s)=>(delete r.request,r.unloadVectorData(),r.aborted?n(null):i?n(i):(r.loadVectorData(s,this.map.painter,"reloadTile"===o),n(null))),void 0,"loadTile"===o)}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.aborted=!0}unloadTile(i){i.unloadVectorData(),this.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends G{constructor(i,r,n,o){super(i,r,n,o),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const r=this.options;for(const n of(this.urls=[],r.urls))this.urls.push(this.map._requestManager.transformRequest(n,i.ResourceType.Source).url);i.getVideo(this.urls,(r,n)=>{this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(this.video=n,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(r){if(this.video){const n=this.video.seekable;rn.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=r}}getVideo(){return this.video}onAdd(i){this.map||(this.map=i,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const r=this.map.painter.context,n=r.gl;for(const o in 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 i.Texture(r,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:G,canvas:class extends G{constructor(r,n,o,s){super(r,n,o,s),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(i=>!Array.isArray(i)||2!==i.length||i.some(i=>"number"!=typeof i))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,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 i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.ErrorEvent(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(i){this.map=i,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let r=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,r=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,r=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const n=this.map.painter.context,o=n.gl;for(const s in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(r||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(n,this.canvas,o.RGBA,{premultiply:!0}),this.tiles){const a=this.tiles[s];"loaded"!==a.state&&(a.state="loaded",a.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const i of[this.canvas.width,this.canvas.height,])if(isNaN(i)||i<=0)return!0;return!1}}},q=function(r,n,o,s){const a=new Z[n.type](r,n,o,s);if(a.id!==r)throw Error(`Expected Source id to be ${r} instead of ${a.id}`);return i.bindAll(["load","abort","unload","serialize","prepare",],a),a};function X(r,n){const o=i.identity([]);return i.scale(o,o,[.5*r.width,-(.5*r.height),1,]),i.translate(o,o,[1,-1,0]),i.multiply$1(o,o,r.calculateProjMatrix(n.toUnwrapped()))}function W(i,r,n,o,s,a,l,c=!1){const u=i.tilesIn(o,l,c);u.sort(K);const h=[];for(const d of u)h.push({wrappedTileID:d.tile.tileID.wrapped().key,queryResults:d.tile.queryRenderedFeatures(r,n,i._state,d,s,a,X(i.transform,d.tile.tileID),c)});const p=function(i){const r={},n={};for(const o of i){const s=o.queryResults,a=o.wrappedTileID,l=n[a]=n[a]||{};for(const c in s){const u=s[c],h=l[c]=l[c]||{},d=r[c]=r[c]||[];for(const p of u)h[p.featureIndex]||(h[p.featureIndex]=!0,d.push(p))}}return r}(h);for(const f in p)p[f].forEach(r=>{const n=r.feature,o=i.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});return p}function H(i,r){const n=i.getRenderableIds().map(r=>i.getTileByID(r)),o=[],s={};for(let a=0;a{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[J]}numActive(){return Object.keys(this.active).length}}let ee;function et(){return ee||(ee=new Q),ee}function ei(r,n){const o={};for(const s in r)"ref"!==s&&(o[s]=r[s]);return i.refProperties.forEach(i=>{i in n&&(o[i]=n[i])}),o}function er(i){i=i.slice();const r=Object.create(null);for(let n=0;n0?(s-l)/c:0;return this.points[a].mult(1-u).add(this.points[n].mult(u))}}class ep{constructor(i,r,n){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(i/n),this.yCellCount=Math.ceil(r/n);for(let a=0;athis.width||o<0||r>this.height)return!s&&[];const l=[];if(i<=0&&r<=0&&this.width<=n&&this.height<=o){if(s)return!0;for(let c=0;c0:l}_queryCircle(i,r,n,o,s){const a=i-n,l=i+n,c=r-n,u=r+n;if(l<0||a>this.width||u<0||c>this.height)return!o&&[];const h=[];return this._forEachCell(a,c,l,u,this._queryCellCircle,h,{hitTest:o,circle:{x:i,y:r,radius:n},seenUids:{box:{},circle:{}}},s),o?h.length>0:h}query(i,r,n,o,s){return this._query(i,r,n,o,!1,s)}hitTest(i,r,n,o,s){return this._query(i,r,n,o,!0,s)}hitTestCircle(i,r,n,o){return this._queryCircle(i,r,n,!0,o)}_queryCell(i,r,n,o,s,a,l,c){const u=l.seenUids,h=this.boxCells[s];if(null!==h){const d=this.bboxes;for(const p of h)if(!u.box[p]){u.box[p]=!0;const f=4*p;if(i<=d[f+2]&&r<=d[f+3]&&n>=d[f+0]&&o>=d[f+1]&&(!c||c(this.boxKeys[p]))){if(l.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[p],x1:d[f],y1:d[f+1],x2:d[f+2],y2:d[f+3]})}}}const m=this.circleCells[s];if(null!==m){const g=this.circles;for(const y of m)if(!u.circle[y]){u.circle[y]=!0;const x=3*y;if(this._circleAndRectCollide(g[x],g[x+1],g[x+2],i,r,n,o)&&(!c||c(this.circleKeys[y]))){if(l.hitTest)return a.push(!0),!0;{const $=g[x],v=g[x+1],_=g[x+2];a.push({key:this.circleKeys[y],x1:$-_,y1:v-_,x2:$+_,y2:v+_})}}}}}_queryCellCircle(i,r,n,o,s,a,l,c){const u=l.circle,h=l.seenUids,d=this.boxCells[s];if(null!==d){const p=this.bboxes;for(const f of d)if(!h.box[f]){h.box[f]=!0;const m=4*f;if(this._circleAndRectCollide(u.x,u.y,u.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!c||c(this.boxKeys[f])))return a.push(!0),!0}}const g=this.circleCells[s];if(null!==g){const y=this.circles;for(const x of g)if(!h.circle[x]){h.circle[x]=!0;const $=3*x;if(this._circlesCollide(y[$],y[$+1],y[$+2],u.x,u.y,u.radius)&&(!c||c(this.circleKeys[x])))return a.push(!0),!0}}}_forEachCell(i,r,n,o,s,a,l,c){const u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(r),d=this._convertToXCellCoord(n),p=this._convertToYCellCoord(o);for(let f=u;f<=d;f++)for(let m=h;m<=p;m++)if(s.call(this,i,r,n,o,this.xCellCount*m+f,a,l,c))return}_convertToXCellCoord(i){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(i*this.xScale)))}_convertToYCellCoord(i){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(i*this.yScale)))}_circlesCollide(i,r,n,o,s,a){const l=o-i,c=s-r,u=n+a;return u*u>l*l+c*c}_circleAndRectCollide(i,r,n,o,s,a,l){const c=(a-o)/2,u=Math.abs(i-(o+c));if(u>c+n)return!1;const h=(l-s)/2,d=Math.abs(r-(s+h));if(d>h+n)return!1;if(u<=c||d<=h)return!0;const p=u-c,f=d-h;return p*p+f*f<=n*n}}const ef=Math.tan(85*Math.PI/180);function em(r,n,o,a,l,c){let u=i.create();if(o){if("globe"===l.projection.name)u=i.calculateGlobeMatrix(l,l.worldSize/l._projectionScaler,[0,0]),i.multiply$1(u,u,i.globeDenormalizeECEF(i.globeTileBounds(n)));else{const h=s([],c);u[0]=h[0],u[1]=h[1],u[4]=h[2],u[5]=h[3]}a||i.rotateZ(u,u,l.angle)}else i.multiply$1(u,l.labelPlaneMatrix,r);return u}function e8(r,n,o,s,a,l){if(o){if("globe"===a.projection.name){const c=em(r,n,o,s,a,l);return i.invert(c,c),i.multiply$1(c,r,c),c}{const u=i.clone(r),h=i.identity([]);return h[0]=l[0],h[1]=l[1],h[4]=l[2],h[5]=l[3],i.multiply$1(u,u,h),s||i.rotateZ(u,u,-a.angle),u}}return a.glCoordMatrix}function eg(r,n,o=0){const s=[r.x,r.y,o,1];o?i.transformMat4$1(s,s,n):eI(s,s,n);const a=s[3];return{point:new i.pointGeometry(s[0]/a,s[1]/a),signedDistanceFromCamera:a}}function ey(i,r){return Math.min(.5+i/r*.5,1.5)}function ex(i,r){const n=i[0]/i[3],o=i[1]/i[3];return n>=-r[0]&&n<=r[0]&&o>=-r[1]&&o<=r[1]}function e$(r,n,o,s,a,l,c,u,h,d){const p=o.transform,f=s?r.textSizeData:r.iconSizeData,m=i.evaluateSizeForZoom(f,o.transform.zoom),g=[256/o.width*2+1,256/o.height*2+1,],y=s?r.text.dynamicLayoutVertexArray:r.icon.dynamicLayoutVertexArray;y.clear();const x=r.lineVertexArray,$=s?r.text.placedSymbolArray:r.icon.placedSymbolArray,v=o.transform.width/o.transform.height;let _=!1;for(let b=0;b<$.length;b++){const w=$.get(b);if(w.writingMode!==i.WritingMode.vertical||_||0!==b&&$.get(b-1).writingMode===i.WritingMode.horizontal||(_=!0),w.hidden||w.writingMode===i.WritingMode.vertical&&!_){eS(w.numGlyphs,y);continue}_=!1;const T=new i.pointGeometry(w.tileAnchorX,w.tileAnchorY),E=h?h(T):[0,0,0],S=p.projection.projectTilePoint(T.x,T.y,d.canonical),I=[S.x+E[0],S.y+E[1],S.z+E[2]],C=[...I,1];if(i.transformMat4$1(C,C,n),!ex(C,g)){eS(w.numGlyphs,y);continue}const z=ey(o.transform.cameraToCenterDistance,C[3]),A=i.evaluateSizeForFeature(f,m,w),k=c?A/z:A*z,P=eg(new i.pointGeometry(I[0],I[1]),a,I[2]);if(P.signedDistanceFromCamera<=0){eS(w.numGlyphs,y);continue}let D={};const L=c?null:h,B=eb(w,k,!1,u,n,a,l,r.glyphOffsetArray,x,y,P.point,T,D,v,L,p.projection,d);_=B.useVertical,L&&B.needsFlipping&&(D={}),(B.notEnoughRoom||_||B.needsFlipping&&eb(w,k,!0,u,n,a,l,r.glyphOffsetArray,x,y,P.point,T,D,v,L,p.projection,d).notEnoughRoom)&&eS(w.numGlyphs,y)}s?r.text.dynamicLayoutVertexBuffer.updateData(y):r.icon.dynamicLayoutVertexBuffer.updateData(y)}function ev(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g){const y=c.glyphStartIndex+c.numGlyphs,x=c.lineStartIndex,$=c.lineStartIndex+c.lineLength,v=r.getoffsetX(c.glyphStartIndex),_=r.getoffsetX(y-1),b=eT(i*v,n,o,s,a,l,c.segment,x,$,u,h,d,p,f,!0,m,g);if(!b)return null;const w=eT(i*_,n,o,s,a,l,c.segment,x,$,u,h,d,p,f,!0,m,g);return w?{first:b,last:w}:null}function e_(r,n,o,s){return r.writingMode===i.WritingMode.horizontal&&Math.abs(o.y-n.y)>Math.abs(o.x-n.x)*s?{useVertical:!0}:r.writingMode===i.WritingMode.vertical?n.yef}(n,o,s)?1===r.flipState?{needsFlipping:!0}:null:n.x>o.x?{needsFlipping:!0}:null}function eb(r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$){const v=n/24,_=r.lineOffsetX*v,b=r.lineOffsetY*v;let w;if(r.numGlyphs>1){const T=r.glyphStartIndex+r.numGlyphs,E=r.lineStartIndex,S=r.lineStartIndex+r.lineLength,I=ev(v,u,_,b,o,p,f,r,h,l,m,y,!1,x,$);if(!I)return{notEnoughRoom:!0};const C=eg(I.first.point,c).point,z=eg(I.last.point,c).point;if(s&&!o){const A=e_(r,C,z,g);if(r.flipState=A&&A.needsFlipping?1:2,A)return A}w=[I.first];for(let k=r.glyphStartIndex+1;k0?B.point:e0(f,L,P,1,a,void 0,x,$.canonical),g);if(r.flipState=R&&R.needsFlipping?1:2,R)return R}const M=eT(v*u.getoffsetX(r.glyphStartIndex),_,b,o,p,f,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,h,l,m,y,!1,!1,x,$);if(!M)return{notEnoughRoom:!0};w=[M]}for(const F of w)i.addDynamicAttributes(d,F.point,F.angle);return{}}function ew(r,n,o,s,a){const l=s.projectTilePoint(r.x,r.y,n);if(!a)return eg(l,o,l.z);const c=a(r);return eg(new i.pointGeometry(l.x+c[0],l.y+c[1]),o,l.z+c[2])}function e0(i,r,n,o,s,a,l,c){const u=ew(i.add(i.sub(r)._unit()),c,s,l,a).point,h=n.sub(u);return n.add(h._mult(o/h.mag()))}function eT(r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$){const v=s?r-n:r+n;let _=v>0?1:-1,b=0;s&&(_*=-1,b=Math.PI),_<0&&(b+=Math.PI);let w=_>0?u+c:u+c+1,T=a,E=a,S=0,I=0;const C=Math.abs(v),z=[],A=[];let k=l;const P=()=>{const r=w-_;return 0===S?l:new i.pointGeometry(d.getx(r),d.gety(r))},D=()=>e0(P(),k,E,C-S+1,p,m,x,$.canonical);for(;S+I<=C;){if((w+=_)=h)return null;if(E=T,z.push(T),g&&A.push(k||P()),void 0===(T=f[w])){k=new i.pointGeometry(d.getx(w),d.gety(w));const L=ew(k,$.canonical,p,x,m);T=L.signedDistanceFromCamera>0?f[w]=L.point:D()}else k=null;S+=I,I=E.dist(T)}y&&m&&(k=k||new i.pointGeometry(d.getx(w),d.gety(w)),f[w]=T=void 0===f[w]?T:D(),I=E.dist(T));const B=(C-S)/I,R=T.sub(E),M=R.mult(B)._add(E);o&&M._add(R._unit()._perp()._mult(o*_));const F=b+Math.atan2(T.y-E.y,T.x-E.x);return z.push(M),g&&(k=k||new i.pointGeometry(d.getx(w),d.gety(w)),A.push(function(r,n,o){const s=1-o;return new i.pointGeometry(r.x*s+n.x*o,r.y*s+n.y*o)}(A.length>0?A[A.length-1]:k,k,B))),{point:M,angle:F,path:z,tilePath:A}}const eE=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,]);function eS(i,r){for(let n=0;ni.sortKey-r.sortKey));this._currentPartIndex[0,0,0],_=new i.pointGeometry(n.tileAnchorX,n.tileAnchorY),b=this.transform.projection.projectTilePoint(n.tileAnchorX,n.tileAnchorY,g.canonical),w=v(_),T=[b.x+w[0],b.y+w[1],b.z+w[2]],E=this.projectAndGetPerspectiveRatio(l,T[0],T[1],T[2],g),{perspectiveRatio:S}=E,I=(d?a/S:a*S)/i.ONE_EM,C=eg(new i.pointGeometry(T[0],T[1]),c,T[2]).point,z=E.signedDistanceFromCamera>0?ev(I,s,n.lineOffsetX*I,n.lineOffsetY*I,!1,C,_,n,o,c,{},x&&!d?v:null,d&&!!x,this.transform.projection,g):null;let A=!1,k=!1,P=!0;if(z&&!E.aboveHorizon){const D=.5*f*S+m,L=new i.pointGeometry(-100,-100),B=new i.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),R=new ed,M=z.first,F=z.last;let O=[];for(let U=M.path.length-1;U>=1;U--)O.push(M.path[U]);for(let V=1;V{const n=v(reg(i,u));O=N.some(i=>i.signedDistanceFromCamera<=0)?[]:N.map(i=>i.point)}let G=[];if(O.length>0){const Z=O[0].clone(),q=O[0].clone();for(let X=1;X=L.x&&q.x<=B.x&&Z.y>=L.y&&q.y<=B.y?[O]:q.xB.x||q.yB.y?[]:i.clipLine([O],L.x,L.y,B.x,B.y)}for(const W of G){R.reset(W,.25*D);let H=0;H=R.length<=.5*D?1:Math.ceil(R.paddedLength/j)+1;for(let K=0;K0){i.transformMat4$1(l,l,r);let u=!1;this.fogState&&a&&(u=function(r,n,o,s,a,l){const c=l.calculateFogTileMatrix(a),u=[n,o,s];return i.transformMat4(u,u,c),b(r,u,l.pitch,l._fov)}(this.fogState,n,o,s||0,a.toUnwrapped(),this.transform)>.9),c=l[2]>l[3]||u}else eI(l,l,r);return{point:new i.pointGeometry((l[0]/l[3]+1)/2*this.transform.width+100,(-l[1]/l[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/l[3]*.5,1.5),signedDistanceFromCamera:l[3],aboveHorizon:c}}isOffscreen(i,r,n,o){return n<100||i>=this.screenRightBoundary||o<100||r>this.screenBottomBoundary}isInsideGrid(i,r,n,o){return n>=0&&i=0&&ri.collisionGroupID===r}}return this.collisionGroups[i]}}(o),this.collisionCircleArrays={},this.prevPlacement=s,s&&(s.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,n,o,s){const a=o.getBucket(n),l=o.latestFeatureIndex;if(!a||!l||n.id!==a.layerIds[0])return;const c=a.layers[0].layout,u=o.collisionBoxArray,h=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),d=o.tileSize/i.EXTENT,p=o.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(p),m="map"===c.get("text-pitch-alignment"),g="map"===c.get("text-rotation-alignment");n.compileFilter();const y=n.dynamicFilter(),x=n.dynamicFilterNeedsFeature(),$=this.transform.calculatePixelsToTileUnitsMatrix(o),v=em(f,o.tileID.canonical,m,g,this.transform,$);let _=null;if(m){const b=e8(f,o.tileID.canonical,m,g,this.transform,$);_=i.multiply$1([],this.transform.labelPlaneMatrix,b)}let w=null;y&&o.latestFeatureIndex&&(w={unwrappedTileID:p,dynamicFilter:y,dynamicFilterNeedsFeature:x,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[a.bucketInstanceId]=new eP(a.bucketInstanceId,l,a.sourceLayerIndex,a.index,o.tileID);const T={bucket:a,layout:c,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:_,clippingData:w,scale:h,textPixelRatio:d,holdingForFade:o.holdingForFade(),collisionBoxArray:u,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(a.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(a.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(s)for(const E of a.sortKeyRanges){const{sortKey:S,symbolInstanceStart:I,symbolInstanceEnd:C}=E;r.push({sortKey:S,symbolInstanceStart:I,symbolInstanceEnd:C,parameters:T})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:T})}attemptAnchorPlacement(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$){const v=[p.textOffset0,p.textOffset1],_=eD(i,n,o,v,s),b=this.collisionIndex.placeCollisionBox(s,r,eL(_.x,_.y,a,l,this.transform.angle),d,c,u,h.predicate);if((!y||0!==this.collisionIndex.placeCollisionBox(m.getSymbolInstanceIconSize($,this.transform.zoom,f),y,eL(_.x,_.y,a,l,this.transform.angle),d,c,u,h.predicate).box.length)&&b.box.length>0){let w;return this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(w=this.prevPlacement.variableOffsets[p.crossTileID].anchor),this.variableOffsets[p.crossTileID]={textOffset:v,width:n,height:o,anchor:i,textScale:s,prevAnchor:w},this.markUsedJustification(m,i,p,g),m.allowVerticalPlacement&&(this.markUsedOrientation(m,g,p),this.placedOrientations[p.crossTileID]=g),{shift:_,placedGlyphBoxes:b}}}placeLayerBucketPart(r,n,o,s){const{bucket:a,layout:l,posMatrix:c,textLabelPlaneMatrix:u,labelToScreenMatrix:h,clippingData:d,textPixelRatio:p,holdingForFade:f,collisionBoxArray:m,partiallyEvaluatedTextSize:g,partiallyEvaluatedIconSize:y,collisionGroup:x}=r.parameters,$=l.get("text-optional"),v=l.get("icon-optional"),_=l.get("text-allow-overlap"),b=l.get("icon-allow-overlap"),w="map"===l.get("text-rotation-alignment"),T="map"===l.get("text-pitch-alignment"),E="none"!==l.get("icon-text-fit"),S="viewport-y"===l.get("symbol-z-order"),I=_&&(b||!a.hasIconData()||v),C=b&&(_||!a.hasTextData()||$);!a.collisionArrays&&m&&a.deserializeCollisionBoxes(m),o&&s&&a.updateCollisionDebugBuffers(this.transform.zoom,m);const z=(r,s,m)=>{if(d){const S={zoom:this.transform.zoom,pitch:this.transform.pitch};let z=null;if(d.dynamicFilterNeedsFeature){const A=this.retainedQueryData[a.bucketInstanceId];z=d.featureIndex.loadFeature({featureIndex:r.featureIndex,bucketIndex:A.bucketIndex,sourceLayerIndex:A.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,d.dynamicFilter)(S,z,this.retainedQueryData[a.bucketInstanceId].tileID.canonical,new i.pointGeometry(r.tileAnchorX,r.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[r.crossTileID]=new eA(!1,!1,!1,!0),void(n[r.crossTileID]=!0)}if(n[r.crossTileID])return;if(f)return void(this.placements[r.crossTileID]=new eA(!1,!1,!1));let k=!1,P=!1,D=!0,L=null,B={box:null,offscreen:null},R={box:null,offscreen:null},M=null,F=null,O=null,U=0,V=0,j=0;m.textFeatureIndex?U=m.textFeatureIndex:r.useRuntimeCollisionCircles&&(U=r.featureIndex),m.verticalTextFeatureIndex&&(V=m.verticalTextFeatureIndex);const N=i=>{i.tileID=this.retainedQueryData[a.bucketInstanceId].tileID,(this.transform.elevation||i.elevation)&&(i.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[a.bucketInstanceId].tileID,i.tileAnchorX,i.tileAnchorY):0)},G=m.textBox;if(G){N(G);const Z=n=>{let o=i.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[r.crossTileID];s&&(this.placedOrientations[r.crossTileID]=s,o=s,this.markUsedOrientation(a,o,r))}return o},q=(n,o)=>{if(a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&m.verticalTextBox){for(const s of a.writingModes)if(s===i.WritingMode.vertical?R=B=o():B=n(),B&&B.box&&B.box.length)break}else B=n()};if(l.get("text-variable-anchor")){let X=l.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[r.crossTileID]){const W=this.prevPlacement.variableOffsets[r.crossTileID];X.indexOf(W.anchor)>0&&(X=X.filter(i=>i!==W.anchor)).unshift(W.anchor)}const H=(i,n,o)=>{const l=a.getSymbolInstanceTextSize(g,r,this.transform.zoom,s),u=(i.x2-i.x1)*l+2*i.padding,h=(i.y2-i.y1)*l+2*i.padding,d=E&&!b?n:null;d&&N(d);let f={box:[],offscreen:!1};const m=_?2*X.length:X.length;for(let $=0;$=X.length,r,s,a,o,d,g,y);if(v&&(f=v.placedGlyphBoxes)&&f.box&&f.box.length){k=!0,L=v.shift;break}}return f};q(()=>H(G,m.iconBox,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return n&&N(n),a.allowVerticalPlacement&&!(B&&B.box&&B.box.length)&&r.numVerticalGlyphVertices>0&&n?H(n,m.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null}}),B&&(k=B.box,D=B.offscreen);const K=Z(B&&B.box);if(!k&&this.prevPlacement){const Y=this.prevPlacement.variableOffsets[r.crossTileID];Y&&(this.variableOffsets[r.crossTileID]=Y,this.markUsedJustification(a,Y.anchor,r,K))}}else{const J=(n,o)=>{const l=a.getSymbolInstanceTextSize(g,r,this.transform.zoom,s),u=this.collisionIndex.placeCollisionBox(l,n,new i.pointGeometry(0,0),_,p,c,x.predicate);return u&&u.box&&u.box.length&&(this.markUsedOrientation(a,o,r),this.placedOrientations[r.crossTileID]=o),u};q(()=>J(G,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&n?(N(n),J(n,i.WritingMode.vertical)):{box:null,offscreen:null}}),Z(B&&B.box&&B.box.length)}}if(k=(M=B)&&M.box&&M.box.length>0,D=M&&M.offscreen,r.useRuntimeCollisionCircles){const Q=a.text.placedSymbolArray.get(r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex),ee=i.evaluateSizeForFeature(a.textSizeData,g,Q),et=l.get("text-padding");F=this.collisionIndex.placeCollisionCircles(_,Q,a.lineVertexArray,a.glyphOffsetArray,ee,c,u,h,o,T,x.predicate,r.collisionCircleDiameter*ee/i.ONE_EM,et,this.retainedQueryData[a.bucketInstanceId].tileID),k=_||F.circles.length>0&&!F.collisionDetected,D=D&&F.offscreen}if(m.iconFeatureIndex&&(j=m.iconFeatureIndex),m.iconBox){const ei=r=>{N(r);const n=E&&L?eL(L.x,L.y,w,T,this.transform.angle):new i.pointGeometry(0,0),o=a.getSymbolInstanceIconSize(y,this.transform.zoom,s);return this.collisionIndex.placeCollisionBox(o,r,n,b,p,c,x.predicate)};P=R&&R.box&&R.box.length&&m.verticalIconBox?(O=ei(m.verticalIconBox)).box.length>0:(O=ei(m.iconBox)).box.length>0,D=D&&O.offscreen}const er=$||0===r.numHorizontalGlyphVertices&&0===r.numVerticalGlyphVertices,en=v||0===r.numIconVertices;if(er||en?en?er||(P=P&&k):k=P&&k:P=k=P&&k,k&&M&&M.box&&this.collisionIndex.insertCollisionBox(M.box,l.get("text-ignore-placement"),a.bucketInstanceId,R&&R.box&&V?V:U,x.ID),P&&O&&this.collisionIndex.insertCollisionBox(O.box,l.get("icon-ignore-placement"),a.bucketInstanceId,j,x.ID),F&&(k&&this.collisionIndex.insertCollisionCircles(F.circles,l.get("text-ignore-placement"),a.bucketInstanceId,U,x.ID),o)){const eo=a.bucketInstanceId;let es=this.collisionCircleArrays[eo];void 0===es&&(es=this.collisionCircleArrays[eo]=new ek);for(let ea=0;ea=0;--k){const P=A[k];z(a.symbolInstances.get(P),P,a.collisionArrays[P])}}else for(let D=r.symbolInstanceStart;D=0&&(r.text.placedSymbolArray.get(c).crossTileID=a>=0&&c!==a?0:o.crossTileID)}markUsedOrientation(r,n,o){const s=n===i.WritingMode.horizontal||n===i.WritingMode.horizontalOnly?n:0,a=n===i.WritingMode.vertical?n:0,l=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex,];for(const c of l)r.text.placedSymbolArray.get(c).placedOrientation=s;o.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(i){this.commitTime=i,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let n=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const o=r?r.symbolFadeChange(i):1,s=r?r.opacities:{},a=r?r.variableOffsets:{},l=r?r.placedOrientations:{};for(const c in this.placements){const u=this.placements[c],h=s[c];h?(this.opacities[c]=new ez(h,o,u.text,u.icon,null,u.clipped),n=n||u.text!==h.text.placed||u.icon!==h.icon.placed):(this.opacities[c]=new ez(null,o,u.text,u.icon,u.skipFade,u.clipped),n=n||u.text||u.icon)}for(const d in s){const p=s[d];if(!this.opacities[d]){const f=new ez(p,o,!1,!1);f.isHidden()||(this.opacities[d]=f,n=n||p.text.placed||p.icon.placed)}}for(const m in a)this.variableOffsets[m]||!this.opacities[m]||this.opacities[m].isHidden()||(this.variableOffsets[m]=a[m]);for(const g in l)this.placedOrientations[g]||!this.opacities[g]||this.opacities[g].isHidden()||(this.placedOrientations[g]=l[g]);n?this.lastPlacementChangeTime=i:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:i)}updateLayerOpacities(i,r){const n={};for(const o of r){const s=o.getBucket(i);s&&o.latestFeatureIndex&&i.id===s.layerIds[0]&&this.updateBucketOpacities(s,n,o.collisionBoxArray)}}updateBucketOpacities(r,n,o){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const s=r.layers[0].layout,a=!!r.layers[0].dynamicFilter(),l=new ez(null,0,!1,!1,!0),c=s.get("text-allow-overlap"),u=s.get("icon-allow-overlap"),h=s.get("text-variable-anchor"),d="map"===s.get("text-rotation-alignment"),p="map"===s.get("text-pitch-alignment"),f="none"!==s.get("icon-text-fit"),m=new ez(null,0,c&&(u||!r.hasIconData()||s.get("icon-optional")),u&&(c||!r.hasTextData()||s.get("text-optional")),!0);!r.collisionArrays&&o&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(o);const g=(i,r,n)=>{for(let o=0;o0||_>0,E=$.numIconVertices>0,S=this.placedOrientations[$.crossTileID],I=S===i.WritingMode.vertical,C=S===i.WritingMode.horizontal||S===i.WritingMode.horizontalOnly;if(!T&&!E||w.isHidden()||y++,T){const z=eB(w.text);g(r.text,v,I?0:z),g(r.text,_,C?0:z);const A=w.text.isHidden();[$.rightJustifiedTextSymbolIndex,$.centerJustifiedTextSymbolIndex,$.leftJustifiedTextSymbolIndex,].forEach(i=>{i>=0&&(r.text.placedSymbolArray.get(i).hidden=A||I?1:0)}),$.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get($.verticalPlacedTextSymbolIndex).hidden=A||C?1:0);const k=this.variableOffsets[$.crossTileID];k&&this.markUsedJustification(r,k.anchor,$,S);const P=this.placedOrientations[$.crossTileID];P&&(this.markUsedJustification(r,"left",$,P),this.markUsedOrientation(r,P,$))}if(E){const D=eB(w.icon);$.placedIconSymbolIndex>=0&&(g(r.icon,$.numIconVertices,I?0:D),r.icon.placedSymbolArray.get($.placedIconSymbolIndex).hidden=w.icon.isHidden()),$.verticalPlacedIconSymbolIndex>=0&&(g(r.icon,$.numVerticalIconVertices,C?0:D),r.icon.placedSymbolArray.get($.verticalPlacedIconSymbolIndex).hidden=w.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const L=r.collisionArrays[x];if(L){let B=new i.pointGeometry(0,0),R=!0;if(L.textBox||L.verticalTextBox){if(h){const M=this.variableOffsets[b];M?(B=eD(M.anchor,M.width,M.height,M.textOffset,M.textScale),d&&B._rotate(p?this.transform.angle:-this.transform.angle)):R=!1}a&&(R=!w.clipped),L.textBox&&e1(r.textCollisionBox.collisionVertexArray,w.text.placed,!R||I,B.x,B.y),L.verticalTextBox&&e1(r.textCollisionBox.collisionVertexArray,w.text.placed,!R||C,B.x,B.y)}const F=R&&Boolean(!C&&L.verticalIconBox);L.iconBox&&e1(r.iconCollisionBox.collisionVertexArray,w.icon.placed,F,f?B.x:0,f?B.y:0),L.verticalIconBox&&e1(r.iconCollisionBox.collisionVertexArray,w.icon.placed,!F,f?B.x:0,f?B.y:0)}}}if(r.fullyClipped=0===y,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const O=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=O.invProjMatrix,r.placementViewportMatrix=O.viewportMatrix,r.collisionCircleArray=O.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(i){return 0===this.fadeDuration?1:(i-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(i){return Math.max(0,(this.transform.zoom-i)/1.5)}hasTransitions(i){return this.stale||i-this.lastPlacementChangeTimei}setStale(){this.stale=!0}}(r,a,l,c,u),this._currentPlacementIndex=n.length-1,this._forceFullPlacement=o,this._showCollisionBoxes=s,this._done=!1}isDone(){return this._done}continuePlacement(r,n,o){const s=i.exported.now(),a=()=>{const r=i.exported.now()-s;return!this._forceFullPlacement&&r>2};for(;this._currentPlacementIndex>=0;){const l=n[r[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=c)&&(!l.maxzoom||l.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new eR(l)),this._inProgressLayer.continuePlacement(o[l.source],this.placement,this._showCollisionBoxes,l,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(i){return this.placement.commit(i),this.placement}}const eM=512/i.EXTENT/2;class e2{constructor(i,r,n){this.tileID=i,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(let o=0;oi.overscaledZ)for(const c in l){const u=l[c];u.tileID.isChildOf(i)&&u.findMatches(r.symbolInstances,i,s)}else{const h=l[i.scaledTo(Number(a)).key];h&&h.findMatches(r.symbolInstances,i,s)}}for(let d=0;d{r[i]=!0}),this.layerIndexes)r[n]||delete this.layerIndexes[n]}}const e4=(r,n)=>i.emitValidationErrors(r,n&&n.filter(i=>"source.canvas"!==i.identifier)),eU=i.pick(en,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection",]),eV=i.pick(en,["setCenter","setZoom","setBearing","setPitch",]),e6=function(){const r={},n=i.spec.$version;for(const o in i.spec.$root){const s=i.spec.$root[o];if(s.required){let a=null;null!=(a="version"===o?n:"array"===s.type?[]:{})&&(r[o]=a)}}return r}(),ej={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class eN extends i.Evented{constructor(r,n={}){super(),this.map=r,this.dispatcher=new I(et(),this),this.imageManager=new m,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(r._requestManager,n.localFontFamily?i.LocalGlyphMode.all:n.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.lineAtlas=new i.LineAtlas(256,512),this.crossTileSymbolIndex=new eO,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new i.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const o=this;this._rtlTextPluginCallback=eN.registerForPluginStateChange(r=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:r.pluginStatus,pluginURL:r.pluginURL},(r,n)=>{if(i.triggerPluginCompletionEvent(r),n&&n.every(i=>i))for(const s in o._sourceCaches){const a=o._sourceCaches[s],l=a.getSource().type;"vector"!==l&&"geojson"!==l||a.reload()}})}),this.on("data",i=>{if("source"!==i.dataType||"metadata"!==i.sourceDataType)return;const r=this.getSource(i.sourceId);if(r&&r.vectorLayerIds)for(const n in this._layers){const o=this._layers[n];o.source===r.id&&this._validateLayer(o)}})}loadURL(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const o="boolean"==typeof n.validate?n.validate:!i.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,n.accessToken);const s=this.map._requestManager.transformRequest(r,i.ResourceType.Style);this._request=i.getJSON(s,(r,n)=>{this._request=null,r?this.fire(new i.ErrorEvent(r)):n&&this._load(n,o)})}loadJSON(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(r,!1!==n.validate)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(e6,!1)}_updateLayerCount(i,r){const n=r?1:-1;i.is3D()&&(this._num3DLayers+=n),"circle"===i.type&&(this._numCircleLayers+=n),"symbol"===i.type&&(this._numSymbolLayers+=n)}_load(r,n){if(n&&e4(this,i.validateStyle(r)))return;for(const o in this._loaded=!0,this.stylesheet=r,this.updateProjection(),r.sources)this.addSource(o,r.sources[o],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const s=er(this.stylesheet.layers);for(let a of(this._order=s.map(i=>i.id),this._layers={},this._serializedLayers={},s))(a=i.createStyleLayer(a)).setEventedParent(this,{layer:{id:a.id}}),this._layers[a.id]=a,this._serializedLayers[a.id]=a.serialize(),this._updateLayerCount(a,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new x(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(i){i?this.stylesheet.projection=i:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const i=this.map.transform.projection,r=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),n=this.map.transform.projection;if(this._loaded&&(n.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),r){if(n.isReprojectedInTileSpace||i.isReprojectedInTileSpace)for(const o in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[o].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(r){this._spriteRequest=function(r,n,o){let s,a,l;const c=i.exported.devicePixelRatio>1?"@2x":"";let u=i.getJSON(n.transformRequest(n.normalizeSpriteURL(r,c,".json"),i.ResourceType.SpriteJSON),(i,r)=>{u=null,l||(l=i,s=r,d())}),h=i.getImage(n.transformRequest(n.normalizeSpriteURL(r,c,".png"),i.ResourceType.SpriteImage),(i,r)=>{h=null,l||(l=i,a=r,d())});function d(){if(l)o(l);else if(s&&a){const r=i.exported.getImageData(a),n={};for(const c in s){const{width:u,height:h,x:d,y:p,sdf:f,pixelRatio:m,stretchX:g,stretchY:y,content:x}=s[c],$=new i.RGBAImage({width:u,height:h});i.RGBAImage.copy(r,$,{x:d,y:p},{x:0,y:0},{width:u,height:h}),n[c]={data:$,pixelRatio:m,sdf:f,stretchX:g,stretchY:y,content:x}}o(null,n)}}return{cancel(){u&&(u.cancel(),u=null),h&&(h.cancel(),h=null)}}}(r,this.map._requestManager,(r,n)=>{if(this._spriteRequest=null,r)this.fire(new i.ErrorEvent(r));else if(n)for(const o in n)this.imageManager.addImage(o,n[o]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(r){const n=this.getSource(r.source);if(!n)return;const o=r.sourceLayer;o&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(o))&&this.fire(new i.ErrorEvent(Error(`Source layer "${o}" does not exist on source "${n.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const i in this._sourceCaches)if(!this._sourceCaches[i].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(i){const r=[];for(const n of i){const o=this._layers[n];"custom"!==o.type&&r.push(o.serialize())}return r}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const i in this._sourceCaches)if(this._sourceCaches[i].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(i){return!!this.terrain&&ej[i.type]}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}update(r){if(!this._loaded)return;const n=this._changed;if(this._changed){const o=Object.keys(this._updatedLayers),s=Object.keys(this._removedLayers);for(const a in(o.length||s.length)&&this._updateWorkerLayers(o,s),this._updatedSources){const l=this._updatedSources[a];"reload"===l?this._reloadSource(a):"clear"===l&&this._clearSource(a)}for(const c in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[c].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const u={};for(const h in this._sourceCaches){const d=this._sourceCaches[h];u[h]=d.used,d.used=!1}for(const p of this._order){const f=this._layers[p];if(f.recalculate(r,this._availableImages),!f.isHidden(r.zoom)){const m=this._getLayerSourceCache(f);m&&(m.used=!0)}const g=this.map.painter;if(g){const y=f.getProgramIds();if(!y)continue;const x=f.getProgramConfiguration(r.zoom);for(const $ of y)g.useProgram($,x)}}for(const v in u){const _=this._sourceCaches[v];u[v]!==_.used&&_.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:_.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const i=Object.keys(this._changedImages);if(i.length){for(const r in this._sourceCaches)this._sourceCaches[r].reloadTilesForDependencies(["icons","patterns"],i);this._changedImages={}}}_updateWorkerLayers(i,r){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(i),removedIds:r})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),e4(this,i.validateStyle(r)))return!1;(r=i.clone$1(r)).layers=er(r.layers);const n=(function(i,r){if(!i)return[{command:en.setStyle,args:[r]},];let n=[];try{if(!a(i.version,r.version))return[{command:en.setStyle,args:[r]},];a(i.center,r.center)||n.push({command:en.setCenter,args:[r.center]}),a(i.zoom,r.zoom)||n.push({command:en.setZoom,args:[r.zoom]}),a(i.bearing,r.bearing)||n.push({command:en.setBearing,args:[r.bearing]}),a(i.pitch,r.pitch)||n.push({command:en.setPitch,args:[r.pitch]}),a(i.sprite,r.sprite)||n.push({command:en.setSprite,args:[r.sprite]}),a(i.glyphs,r.glyphs)||n.push({command:en.setGlyphs,args:[r.glyphs]}),a(i.transition,r.transition)||n.push({command:en.setTransition,args:[r.transition]}),a(i.light,r.light)||n.push({command:en.setLight,args:[r.light]}),a(i.fog,r.fog)||n.push({command:en.setFog,args:[r.fog]}),a(i.projection,r.projection)||n.push({command:en.setProjection,args:[r.projection]});const o={},s=[];!function(i,r,n,o){let s;for(s in r=r||{},i=i||{})i.hasOwnProperty(s)&&(r.hasOwnProperty(s)||es(s,n,o));for(s in r)r.hasOwnProperty(s)&&(i.hasOwnProperty(s)?a(i[s],r[s])||("geojson"===i[s].type&&"geojson"===r[s].type&&el(i,r,s)?n.push({command:en.setGeoJSONSourceData,args:[s,r[s].data,]}):ea(s,r,n,o)):eo(s,r,n))}(i.sources,r.sources,s,o);const l=[];i.layers&&i.layers.forEach(i=>{o[i.source]?n.push({command:en.removeLayer,args:[i.id]}):l.push(i)});let c=i.terrain;c&&o[c.source]&&(n.push({command:en.setTerrain,args:[void 0]}),c=void 0),n=n.concat(s),a(c,r.terrain)||n.push({command:en.setTerrain,args:[r.terrain]}),function(i,r,n){r=r||[];const o=(i=i||[]).map(eu),s=r.map(eu),l=i.reduce(eh,{}),c=r.reduce(eh,{}),u=o.slice(),h=Object.create(null);let d,p,f,m,g,y,x;for(d=0,p=0;d!(i.command in eV));if(0===n.length)return!1;const o=n.filter(i=>!(i.command in eU));if(o.length>0)throw Error(`Unimplemented: ${o.map(i=>i.command).join(", ")}.`);return n.forEach(i=>{"setTransition"!==i.command&&this[i.command].apply(this,i.args)}),this.stylesheet=r,this.updateProjection(),!0}addImage(r,n){if(this.getImage(r))return this.fire(new i.ErrorEvent(Error("An image with this name already exists.")));this.imageManager.addImage(r,n),this._afterImageUpdated(r)}updateImage(i,r){this.imageManager.updateImage(i,r)}getImage(i){return this.imageManager.getImage(i)}removeImage(r){if(!this.getImage(r))return this.fire(new i.ErrorEvent(Error("No image with this name exists.")));this.imageManager.removeImage(r),this._afterImageUpdated(r)}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,n,o={}){if(this._checkLoaded(),void 0!==this.getSource(r))throw Error("There is already a source with this ID");if(!n.type)throw 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(i.validateStyle.source,`sources.${r}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const s=q(r,n,this.dispatcher,this);s.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:s.serialize(),sourceId:r}));const a=n=>{const o=(n?"symbol:":"other:")+r,a=this._sourceCaches[o]=new i.SourceCache(o,s,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[r]=a,a.style=this,a.onAdd(this.map)};a(!1),"vector"!==n.type&&"geojson"!==n.type||a(!0),s.onAdd&&s.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const n=this.getSource(r);if(void 0===n)throw Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while layer "${o}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while terrain is using it.`)));const s=this._getSourceCaches(r);for(const a of s)delete this._sourceCaches[a.id],delete this._updatedSources[a.id],a.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:a.getSource().id})),a.setEventedParent(null),a.clearTiles();delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(i,r){this._checkLoaded(),this.getSource(i).setData(r),this._changed=!0}getSource(i){const r=this._getSourceCache(i);return r&&r.getSource()}addLayer(r,n,o={}){this._checkLoaded();const s=r.id;if(this.getLayer(s))return void this.fire(new i.ErrorEvent(Error(`Layer with id "${s}" already exists on this map`)));let a;if("custom"===r.type){if(e4(this,i.validateCustomStyleLayer(r)))return;a=i.createStyleLayer(r)}else{if("object"==typeof r.source&&(this.addSource(s,r.source),r=i.clone$1(r),r=i.extend(r,{source:s})),this._validate(i.validateStyle.layer,`layers.${s}`,r,{arrayIndex:-1},o))return;a=i.createStyleLayer(r),this._validateLayer(a),a.setEventedParent(this,{layer:{id:s}}),this._serializedLayers[a.id]=a.serialize(),this._updateLayerCount(a,!0)}const l=n?this._order.indexOf(n):this._order.length;if(n&&-1===l)return void this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(l,0,s),this._layerOrderChanged=!0,this._layers[s]=a;const c=this._getLayerSourceCache(a);if(this._removedLayers[s]&&a.source&&c&&"custom"!==a.type){const u=this._removedLayers[s];delete this._removedLayers[s],u.type!==a.type?this._updatedSources[a.source]="clear":(this._updatedSources[a.source]="reload",c.pause())}this._updateLayer(a),a.onAdd&&a.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,n){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===n)return;const o=this._order.indexOf(r);this._order.splice(o,1);const s=n?this._order.indexOf(n):this._order.length;n&&-1===s?this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const n=this._layers[r];if(!n)return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const o=this._order.indexOf(r);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=n,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(i){return this._layers[i]}hasLayer(i){return i in this._layers}hasLayerType(i){for(const r in this._layers)if(this._layers[r].type===i)return!0;return!1}setLayerZoomRange(r,n,o){this._checkLoaded();const s=this.getLayer(r);s?s.minzoom===n&&s.maxzoom===o||(null!=n&&(s.minzoom=n),null!=o&&(s.maxzoom=o),this._updateLayer(s)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,n,o={}){this._checkLoaded();const s=this.getLayer(r);if(s){if(!a(s.filter,n))return null==n?(s.filter=void 0,void this._updateLayer(s)):void(this._validate(i.validateStyle.filter,`layers.${s.id}.filter`,n,{layerType:s.type},o)||(s.filter=i.clone$1(n),this._updateLayer(s)))}else this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){return i.clone$1(this.getLayer(r).filter)}setLayoutProperty(r,n,o,s={}){this._checkLoaded();const l=this.getLayer(r);l?a(l.getLayoutProperty(n),o)||(l.setLayoutProperty(n,o,s),this._updateLayer(l)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,n){const o=this.getLayer(r);if(o)return o.getLayoutProperty(n);this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,n,o,s={}){this._checkLoaded();const l=this.getLayer(r);l?a(l.getPaintProperty(n),o)||(l.setPaintProperty(n,o,s)&&this._updateLayer(l),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(i,r){return this.getLayer(i).getPaintProperty(r)}setFeatureState(r,n){this._checkLoaded();const o=r.source,s=r.sourceLayer,a=this.getSource(o);if(void 0===a)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const l=a.type;if("geojson"===l&&s)return void this.fire(new i.ErrorEvent(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===l&&!s)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided.")));const c=this._getSourceCaches(o);for(const u of c)u.setFeatureState(s,r.id,n)}removeFeatureState(r,n){this._checkLoaded();const o=r.source,s=this.getSource(o);if(void 0===s)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const a=s.type,l="vector"===a?r.sourceLayer:void 0;if("vector"===a&&!l)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof r.id&&"number"!=typeof r.id)return void this.fire(new i.ErrorEvent(Error("A feature id is required to remove its specific state property.")));const c=this._getSourceCaches(o);for(const u of c)u.removeFeatureState(l,r.id,n)}getFeatureState(r){this._checkLoaded();const n=r.source,o=r.sourceLayer,s=this.getSource(n);if(void 0!==s){if("vector"!==s.type||o)return void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(o,r.id);this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const n in this._sourceCaches){const o=this._sourceCaches[n].getSource();r[o.id]||(r[o.id]=o.serialize())}return i.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:r,layers:this._serializeLayers(this._order)},i=>void 0!==i)}_updateLayer(i){this._updatedLayers[i.id]=!0;const r=this._getLayerSourceCache(i);i.source&&!this._updatedSources[i.source]&&r&&"raster"!==r.getSource().type&&(this._updatedSources[i.source]="reload",r.pause()),this._changed=!0,i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){var r,n;const o={},s=[];for(let a=this._order.length-1;a>=0;a--){const l=this._order[a];if(r=l,"fill-extrusion"===this._layers[r].type)for(const c of(o[l]=a,i)){const u=c[l];if(u)for(const h of u)s.push(h)}}s.sort((i,r)=>r.intersectionZ-i.intersectionZ);const d=[];for(let p=this._order.length-1;p>=0;p--){const f=this._order[p];if(n=f,"fill-extrusion"===this._layers[n].type)for(let m=s.length-1;m>=0;m--){const g=s[m].feature;if(o[g.layer.id]{const r=this.getLayer(i);return r&&r.is3D()}):this.has3DLayers(),h=M.createFromScreenPoints(r,o);for(const d in this._sourceCaches){const p=this._sourceCaches[d].getSource().id;n.layers&&!s[p]||c.push(W(this._sourceCaches[d],this._layers,this._serializedLayers,h,n,o,u,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,r,n,o,s,a,l){const c={},u=a.queryRenderedSymbols(o),h=[];for(const d of Object.keys(u).map(Number))h.push(l[d]);for(const p of(h.sort(K),h)){const f=p.featureIndex.lookupSymbolFeatures(u[p.bucketInstanceId],r,p.bucketIndex,p.sourceLayerIndex,s.filter,s.layers,s.availableImages,i);for(const m in f){const g=c[m]=c[m]||[],y=f[m];for(const x of(y.sort((i,r)=>{const n=p.featureSortOrder;if(n){const o=n.indexOf(i.featureIndex);return n.indexOf(r.featureIndex)-o}return r.featureIndex-i.featureIndex}),y))g.push(x)}}for(const $ in c)c[$].forEach(r=>{const o=r.feature,s=n(i[$]).getFeatureState(o.layer["source-layer"],o.id);o.source=o.layer.source,o.layer["source-layer"]&&(o.sourceLayer=o.layer["source-layer"]),o.state=s});return c}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),h.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(r,n){n&&n.filter&&this._validate(i.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this._getSourceCaches(r);let s=[];for(const a of o)s=s.concat(H(a,n));return s}addSourceType(i,r,n){return eN.getSourceType(i)?n(Error(`A source type called "${i}" already exists.`)):(eN.setSourceType(i,r),r.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:i,url:r.workerSourceURL},n):n(null,null))}getLight(){return this.light.getLight()}setLight(r,n={}){this._checkLoaded();const o=this.light.getLight();let s=!1;for(const l in r)if(!a(r[l],o[l])){s=!0;break}if(!s)return;const c={now:i.exported.now(),transition:i.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(r,n),this.light.updateTransitions(c)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(r,n=1){if(this._checkLoaded(),!r)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===n){if("object"==typeof r.source){const o="terrain-dem-src";this.addSource(o,r.source),r=i.clone$1(r),r=i.extend(r,{source:o})}if(this._validate(i.validateStyle.terrain,"terrain",r))return}if(!this.terrain||this.terrain&&n!==this.terrain.drapeRenderMode)this._createTerrain(r,n);else{const s=this.terrain,l=s.get();for(const c in r)if(!a(r[c],l[c])){s.set(r),this.stylesheet.terrain=r;const u={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};s.updateTransitions(u);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(r){const n=this.fog=new S(r,this.map.transform);this.stylesheet.fog=r;const o={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};n.updateTransitions(o)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const i of this.map._markers)i._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,o=n.get();for(const s in r)if(!a(r[s],o[s])){n.set(r),this.stylesheet.fog=r;const l={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};n.updateTransitions(l);break}}else this._createFog(r);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const i=this._order.filter(i=>this.isLayerDraped(this._layers[i])),r=this._order.filter(i=>!this.isLayerDraped(this._layers[i]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...i),this._drapedFirstOrder.push(...r)}_createTerrain(r,n){const o=this.terrain=new _(r,n);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const s={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(s)}_force3DLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"fill-extrusion"===r.type&&this._updateLayer(r)}}_forceSymbolLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"symbol"===r.type&&this._updateLayer(r)}}_validate(r,n,o,s,a={}){return(!a||!1!==a.validate)&&e4(this,r.call(i.validateStyle,i.extend({key:n,style:this.serialize(),value:o,styleSpec:i.spec},s)))}_remove(){for(const r in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[r].setEventedParent(null);for(const n in this._sourceCaches)this._sourceCaches[n].clearTiles(),this._sourceCaches[n].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(i){const r=this._getSourceCaches(i);for(const n of r)n.clearTiles()}_reloadSource(i){const r=this._getSourceCaches(i);for(const n of r)n.resume(),n.reload()}_updateSources(i){for(const r in this._sourceCaches)this._sourceCaches[r].update(i)}_generateCollisionBoxes(){for(const i in this._sourceCaches){const r=this._sourceCaches[i];r.resume(),r.reload()}}_updatePlacement(r,n,o,s,a=!1){let l=!1,c=!1;const u={};for(const h of this._order){const d=this._layers[h];if("symbol"!==d.type)continue;if(!u[d.source]){const p=this._getLayerSourceCache(d);if(!p)continue;u[d.source]=p.getRenderableIds(!0).map(i=>p.getTileByID(i)).sort((i,r)=>r.tileID.overscaledZ-i.tileID.overscaledZ||(i.tileID.isLessThan(r.tileID)?-1:1))}const f=this.crossTileSymbolIndex.addLayer(d,u[d.source],r.center.lng,r.projection);l=l||f}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a=a||this._layerOrderChanged||0===o,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),r.zoom))&&(this.pauseablePlacement=new e3(r,this._order,a,n,o,s,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,u),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l)for(const m of this._order){const g=this._layers[m];"symbol"===g.type&&this.placement.updateLayerOpacities(g,u[g.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const i in this._sourceCaches)this._sourceCaches[i].releaseSymbolFadeTiles()}getImages(i,r,n){this.imageManager.getImages(r.icons,n),this._updateTilesForChangedImages();const o=i=>{i&&i.setDependencies(r.tileID.key,r.type,r.icons)};o(this._otherSourceCaches[r.source]),o(this._symbolSourceCaches[r.source])}getGlyphs(i,r,n){this.glyphManager.getGlyphs(r.stacks,n)}getResource(r,n,o){return i.makeRequest(n,o)}_getSourceCache(i){return this._otherSourceCaches[i]}_getLayerSourceCache(i){return"symbol"===i.type?this._symbolSourceCaches[i.source]:this._otherSourceCaches[i.source]}_getSourceCaches(i){const r=[];return this._otherSourceCaches[i]&&r.push(this._otherSourceCaches[i]),this._symbolSourceCaches[i]&&r.push(this._symbolSourceCaches[i]),r}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}eN.getSourceType=function(i){return Z[i]},eN.setSourceType=function(i,r){Z[i]=r},eN.registerForPluginStateChange=i.registerForPluginStateChange;var eG="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}\n#endif",eZ="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}";let e9={},e7={};e9=eW("","\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",!0),e7=eW("#ifdef FOG\nuniform float u_fog_temporal_offset;float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif","#ifdef FOG\nuniform mat4 u_fog_matrix;vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",!0);const eq=eW("\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef TERRAIN\nhighp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#endif","\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#if defined(PROJECTION_GLOBE_VIEW) && !defined(PROJECTED_POS_ON_VIEWPORT)\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {\n#if defined(PROJECTION_GLOBE_VIEW) && !defined(PROJECTED_POS_ON_VIEWPORT)\nreturn mix(globe,mercator,t);\n#else\nreturn globe;\n#endif\n}\n#ifdef PROJECTION_GLOBE_VIEW\nmat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),e5=eG;var eX={background:eW("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:eW("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:eW("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 scaled_extrude=extrude*a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=scaled_extrude.x*surface_vectors[0]+scaled_extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);vec4 world_center=vec4(pos,1);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\n#if defined(SCALE_WITH_MAP) && defined(PROJECTION_GLOBE_VIEW)\nview_scale*=a_scale;\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:eW("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:eW("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\ngl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nextrude*=a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\nvec3 pos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:eW("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:eW("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}","attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:eW("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:eW("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}"),fill:eW("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:eW("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:eW("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:eW("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:eW("varying vec4 v_color;void main() {vec4 color=v_color;\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(pos.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:eW("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:eW("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture2D(u_image,coord).a/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:eW("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:eW("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nvec4 out_color=texture2D(u_gradient_image,v_uv);\n#else\nvec4 out_color=color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#ifdef RENDER_LINE_GRADIENT\nattribute vec3 a_packed;\n#else\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];float a_linesofar=a_packed[2];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);\n#endif\n#ifdef RENDER_LINE_DASH\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:eW("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),raster:eW("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:eW("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:eW("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;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 vec3 u_tile_id;uniform float u_zoom_transition;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[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;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:eW("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[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;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:eW("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:eW("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:eW("\nvarying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",eZ),skyboxGradient:eW("varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",eZ),skyboxCapture:eW("\nvarying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}","attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:eW("uniform sampler2D u_image0;varying vec2 v_pos0;void main() {gl_FragColor=texture2D(u_image0,v_pos0);\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_proj_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;attribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;varying vec2 v_pos0;const float wireframeOffset=1e3;void main() {v_pos0=a_uv;vec2 uv=a_uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nvec4 globe=u_globe_matrix*vec4(a_globe_pos+up_vector.xyz*height,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(a_merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);}"),globeAtmosphere:eW("uniform vec2 u_center;uniform float u_radius;uniform vec2 u_screen_size;uniform float u_opacity;uniform highp float u_fadeout_range;uniform vec3 u_start_color;uniform vec3 u_end_color;uniform float u_pixel_ratio;void main() {highp vec2 fragCoord=gl_FragCoord.xy/u_pixel_ratio;fragCoord.y=u_screen_size.y-fragCoord.y;float distFromCenter=length(fragCoord-u_center);float normDistFromCenter=length(fragCoord-u_center)/u_radius;if (normDistFromCenter < 1.0)\ndiscard;float t=clamp(1.0-sqrt(normDistFromCenter-1.0)/u_fadeout_range,0.0,1.0);vec3 color=mix(u_start_color,u_end_color,1.0-t);gl_FragColor=vec4(color*t*u_opacity,u_opacity);}","attribute vec3 a_pos;void main() {gl_Position=vec4(a_pos,1.0);}")};function eW(i,r,n){const o=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,a=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),l=i.match(s),c=r.match(s),u=eG.match(s);let h=c?c.concat(l):l;n||(e9.staticUniforms&&(h=e9.staticUniforms.concat(h)),e7.staticUniforms&&(h=e7.staticUniforms.concat(h))),h&&(h=h.concat(u));const d={};return{fragmentSource:i=i.replace(o,(i,r,n,o,s)=>(d[s]=!0,"define"===r?` +Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(d[1])} }\`.`),];const p=[];return"symbol"===i.layerType&&("text-field"===l&&o&&!o.glyphs&&p.push(new td(n,a,'use of "text-field" requires a style "glyphs" property')),"text-font"===l&&rr(t8(a))&&"identity"===tm(a.type)&&p.push(new td(n,a,'"text-font" does not support identity functions'))),p.concat(rG({key:i.key,value:a,valueSpec:h,style:o,styleSpec:s,expressionContext:"property",propertyType:r,propertyKey:l}))}function rM(i){return r3(i,"paint")}function r2(i){return r3(i,"layout")}function rF(i){let r=[];const n=i.value,o=i.key,s=i.style,a=i.styleSpec;n.type||n.ref||r.push(new td(o,n,'either "type" or "ref" is required'));let l=tm(n.type);const c=tm(n.ref);if(n.id){const u=tm(n.id);for(let h=0;h{i in n&&r.push(new td(o,n[i],`"${i}" is prohibited for ref layers`))}),s.layers.forEach(i=>{tm(i.id)===c&&(p=i)}),p?p.ref?r.push(new td(o,n.ref,"ref cannot reference another ref layer")):l=tm(p.type):r.push(new td(o,n.ref,`ref layer "${c}" not found`))}else if("background"!==l&&"sky"!==l){if(n.source){const f=s.sources&&s.sources[n.source],m=f&&tm(f.type);f?"vector"===m&&"raster"===l?r.push(new td(o,n.source,`layer "${n.id}" requires a raster source`)):"raster"===m&&"raster"!==l?r.push(new td(o,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==m||n["source-layer"]?"raster-dem"===m&&"hillshade"!==l?r.push(new td(o,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===l&&n.paint&&n.paint["line-gradient"]&&("geojson"!==m||!f.lineMetrics)&&r.push(new td(o,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new td(o,n,`layer "${n.id}" must specify a "source-layer"`)):r.push(new td(o,n.source,`source "${n.source}" not found`))}else r.push(new td(o,n,'missing required property "source"'))}return r=r.concat(ry({key:o,value:n,valueSpec:a.layer,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":()=>[],type:()=>rG({key:`${o}.type`,value:n.type,valueSpec:a.layer.type,style:i.style,styleSpec:i.styleSpec,object:n,objectKey:"type"}),filter:i=>rB(tf({layerType:l},i)),layout:i=>ry({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>r2(tf({layerType:l},i))}}),paint:i=>ry({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rM(tf({layerType:l},i))}})}}))}function rO(i){const r=i.value,n=i.key,o=ri(r);return"string"!==o?[new td(n,r,`string expected, ${o} found`)]:[]}const r4={promoteId:function({key:i,value:r}){if("string"===ri(r))return rO({key:i,value:r});{const n=[];for(const o in r)n.push(...rO({key:`${i}.${o}`,value:r[o]}));return n}}};function rU(i){const r=i.value,n=i.key,o=i.styleSpec,s=i.style;if(!r.type)return[new td(n,r,'"type" is required')];const a=tm(r.type);let l;switch(a){case"vector":case"raster":case"raster-dem":return ry({key:n,value:r,valueSpec:o[`source_${a.replace("-","_")}`],style:i.style,styleSpec:o,objectElementValidators:r4});case"geojson":if(l=ry({key:n,value:r,valueSpec:o.source_geojson,style:s,styleSpec:o,objectElementValidators:r4}),r.cluster)for(const c in r.clusterProperties){const[u,h]=r.clusterProperties[c],d="string"==typeof u?[u,["accumulated"],["get",c],]:u;l.push(...r_({key:`${n}.${c}.map`,value:h,expressionContext:"cluster-map"})),l.push(...r_({key:`${n}.${c}.reduce`,value:d,expressionContext:"cluster-reduce"}))}return l;case"video":return ry({key:n,value:r,valueSpec:o.source_video,style:s,styleSpec:o});case"image":return ry({key:n,value:r,valueSpec:o.source_image,style:s,styleSpec:o});case"canvas":return[new td(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas"),];default:return rw({key:`${n}.type`,value:r.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image",]},style:s,styleSpec:o})}}function rV(i){const r=i.value,n=i.styleSpec,o=n.light,s=i.style;let a=[];const l=ri(r);if(void 0===r)return a;if("object"!==l)return a.concat([new td("light",r,`object expected, ${l} found`),]);for(const c in r){const u=c.match(/^(.*)-transition$/);a=a.concat(u&&o[u[1]]&&o[u[1]].transition?rG({key:c,value:r[c],valueSpec:n.transition,style:s,styleSpec:n}):o[c]?rG({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}):[new td(c,r[c],`unknown property "${c}"`),])}return a}function r6(i){const r=i.value,n=i.key,o=i.style,s=i.styleSpec,a=s.terrain;let l=[];const c=ri(r);if(void 0===r)return l;if("object"!==c)return l.concat([new td("terrain",r,`object expected, ${c} found`),]);for(const u in r){const h=u.match(/^(.*)-transition$/);l=l.concat(h&&a[h[1]]&&a[h[1]].transition?rG({key:u,value:r[u],valueSpec:s.transition,style:o,styleSpec:s}):a[u]?rG({key:u,value:r[u],valueSpec:a[u],style:o,styleSpec:s}):[new td(u,r[u],`unknown property "${u}"`),])}if(r.source){const d=o.sources&&o.sources[r.source],p=d&&tm(d.type);d?"raster-dem"!==p&&l.push(new td(n,r.source,`terrain cannot be used with a source of type ${p}, it only be used with a "raster-dem" source type`)):l.push(new td(n,r.source,`source "${r.source}" not found`))}else l.push(new td(n,r,'terrain is missing required property "source"'));return l}function rj(i){const r=i.value,n=i.style,o=i.styleSpec,s=o.fog;let a=[];const l=ri(r);if(void 0===r)return a;if("object"!==l)return a.concat([new td("fog",r,`object expected, ${l} found`),]);for(const c in r){const u=c.match(/^(.*)-transition$/);a=a.concat(u&&s[u[1]]&&s[u[1]].transition?rG({key:c,value:r[c],valueSpec:o.transition,style:n,styleSpec:o}):s[c]?rG({key:c,value:r[c],valueSpec:s[c],style:n,styleSpec:o}):[new td(c,r[c],`unknown property "${c}"`),])}return a}const rN={"*":()=>[],array:rx,boolean:function(i){const r=i.value,n=i.key,o=ri(r);return"boolean"!==o?[new td(n,r,`boolean expected, ${o} found`),]:[]},number:r$,color:function(i){const r=i.key,n=i.value,o=ri(n);return"string"!==o?[new td(r,n,`color expected, ${o} found`),]:null===tL.parseCSSColor(n)?[new td(r,n,`color expected, "${n}" found`),]:[]},constants:tp,enum:rw,filter:rB,function:rv,layer:rF,object:ry,source:rU,light:rV,terrain:r6,fog:rj,string:rO,formatted:function(i){return 0===rO(i).length?[]:r_(i)},resolvedImage:function(i){return 0===rO(i).length?[]:r_(i)},projection:function(i){const r=i.value,n=i.styleSpec,o=n.projection,s=i.style;let a=[];const l=ri(r);if("object"===l)for(const c in r)a=a.concat(rG({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}));else"string"!==l&&(a=a.concat([new td("projection",r,`object or string expected, ${l} found`),]));return a}};function rG(i){const r=i.value,n=i.valueSpec,o=i.styleSpec;return n.expression&&rr(tm(r))?rv(i):n.expression&&rh(t8(r))?r_(i):n.type&&rN[n.type]?rN[n.type](i):ry(tf({},i,{valueSpec:n.type?o[n.type]:n}))}function rZ(i){const r=i.value,n=i.key,o=rO(i);return o.length||(-1===r.indexOf("{fontstack}")&&o.push(new td(n,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&o.push(new td(n,r,'"glyphs" url must include a "{range}" token'))),o}function r9(i,r=th){let n=[];return n=n.concat(rG({key:"",value:i,valueSpec:r.$root,styleSpec:r,style:i,objectElementValidators:{glyphs:rZ,"*":()=>[]}})),i.constants&&(n=n.concat(tp({key:"constants",value:i.constants,style:i,styleSpec:r}))),r7(n)}function r7(i){return[].concat(i).sort((i,r)=>i.line-r.line)}function rq(i){return function(...r){return r7(i.apply(this,r))}}r9.source=rq(rU),r9.light=rq(rV),r9.terrain=rq(r6),r9.fog=rq(rj),r9.layer=rq(rF),r9.filter=rq(rB),r9.paintProperty=rq(rM),r9.layoutProperty=rq(r2);const r5=r9,rX=r5.light,rW=r5.fog,rH=r5.paintProperty,rK=r5.layoutProperty;function rY(i,r){let n=!1;if(r&&r.length)for(const o of r)i.fire(new tc(Error(o.message))),n=!0;return n}var rJ=rQ;function rQ(i,r,n){var o=this.cells=[];if(i instanceof ArrayBuffer){this.arrayBuffer=i;var s=new Int32Array(this.arrayBuffer);i=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a=d[m+0]&&o>=d[m+1])?(l[f]=!0,a.push(h[f])):l[f]=!1}}},rQ.prototype._forEachCell=function(i,r,n,o,s,a,l,c){for(var u=this._convertToCellCoord(i),h=this._convertToCellCoord(r),d=this._convertToCellCoord(n),p=this._convertToCellCoord(o),f=u;f<=d;f++)for(var m=h;m<=p;m++){var g=this.d*m+f;if((!c||c(this._convertFromCellCoord(f),this._convertFromCellCoord(m),this._convertFromCellCoord(f+1),this._convertFromCellCoord(m+1)))&&s.call(this,i,r,n,o,g,a,l,c))return}},rQ.prototype._convertFromCellCoord=function(i){return(i-this.padding)/this.scale},rQ.prototype._convertToCellCoord=function(i){return Math.max(0,Math.min(this.d-1,Math.floor(i*this.scale)+this.padding))},rQ.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var i=this.cells,r=3+this.cells.length+1+1,n=0,o=0;o=0)continue;const h=i[u];c[u]=ni[l].shallow.indexOf(u)>=0?h:na(h,r)}i instanceof Error&&(c.message=i.message)}if(c.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==l&&(c.$name=l),c}throw Error("can't serialize object of type "+typeof i)}function nl(i){if(null==i||"boolean"==typeof i||"number"==typeof i||"string"==typeof i||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||no(i)||ns(i)||ArrayBuffer.isView(i)||i instanceof ne)return i;if(Array.isArray(i))return i.map(nl);if("object"==typeof i){const r=i.$name||"Object",{klass:n}=ni[r];if(!n)throw Error(`can't deserialize unregistered class ${r}`);if(n.deserialize)return n.deserialize(i);const o=Object.create(n.prototype);for(const s of Object.keys(i)){if("$name"===s)continue;const a=i[s];o[s]=ni[r].shallow.indexOf(s)>=0?a:nl(a)}return o}throw Error("can't deserialize object of type "+typeof i)}class nc{constructor(){this.first=!0}update(i,r){const n=Math.floor(i);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=i,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=1536&&i<=1791,nh=i=>i>=1872&&i<=1919,nd=i=>i>=2208&&i<=2303,np=i=>i>=11904&&i<=12031,nf=i=>i>=12032&&i<=12255,nm=i=>i>=12272&&i<=12287,n8=i=>i>=12288&&i<=12351,ng=i=>i>=12352&&i<=12447,ny=i=>i>=12448&&i<=12543,nx=i=>i>=12544&&i<=12591,n$=i=>i>=12704&&i<=12735,nv=i=>i>=12736&&i<=12783,n_=i=>i>=12784&&i<=12799,nb=i=>i>=12800&&i<=13055,nw=i=>i>=13056&&i<=13311,n0=i=>i>=13312&&i<=19903,nT=i=>i>=19968&&i<=40959,nE=i=>i>=40960&&i<=42127,nS=i=>i>=42128&&i<=42191,nI=i=>i>=44032&&i<=55215,nC=i=>i>=63744&&i<=64255,nz=i=>i>=64336&&i<=65023,nA=i=>i>=65040&&i<=65055,nk=i=>i>=65072&&i<=65103,nP=i=>i>=65104&&i<=65135,nD=i=>i>=65136&&i<=65279,nL=i=>i>=65280&&i<=65519;function n1(i){for(const r of i)if(n3(r.charCodeAt(0)))return!0;return!1}function nB(i){for(const r of i)if(!nR(r.charCodeAt(0)))return!1;return!0}function nR(i){return!(nu(i)||nh(i)||nd(i)||nz(i)||nD(i))}function n3(i){var r,n,o,s,a,l,c,u;return!(746!==i&&747!==i&&(i<4352||!(n$(i)||nx(i)||nk(i)&&!(i>=65097&&i<=65103)||nC(i)||nw(i)||np(i)||nv(i)||!(!n8(i)||i>=12296&&i<=12305||i>=12308&&i<=12319||12336===i)||n0(i)||nT(i)||nb(i)||(r=i)>=12592&&r<=12687||(n=i)>=43360&&n<=43391||(o=i)>=55216&&o<=55295||(s=i)>=4352&&s<=4607||nI(i)||ng(i)||nm(i)||(a=i)>=12688&&a<=12703||nf(i)||n_(i)||ny(i)&&12540!==i||!(!nL(i)||65288===i||65289===i||65293===i||i>=65306&&i<=65310||65339===i||65341===i||65343===i||i>=65371&&i<=65503||65507===i||i>=65512&&i<=65519)||!(!nP(i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||(l=i)>=5120&&l<=5759||(c=i)>=6320&&c<=6399||nA(i)||(u=i)>=19904&&u<=19967||nE(i)||nS(i))))}function nM(i){var r,n,o,s,a,l,c,u,h,d,p,f,m;return!(n3(i)||(n=r=i)>=128&&n<=255&&(167===r||169===r||174===r||177===r||188===r||189===r||190===r||215===r||247===r)||(o=r)>=8192&&o<=8303&&(8214===r||8224===r||8225===r||8240===r||8241===r||8251===r||8252===r||8258===r||8263===r||8264===r||8265===r||8273===r)||(s=r)>=8448&&s<=8527||(a=r)>=8528&&a<=8591||(l=r)>=8960&&l<=9215&&(r>=8960&&r<=8967||r>=8972&&r<=8991||r>=8996&&r<=9e3||9003===r||r>=9085&&r<=9114||r>=9150&&r<=9165||9167===r||r>=9169&&r<=9179||r>=9186&&r<=9215)||(c=r)>=9216&&c<=9279&&9251!==r||(u=r)>=9280&&u<=9311||(h=r)>=9312&&h<=9471||(d=r)>=9632&&d<=9727||(p=r)>=9728&&p<=9983&&!(r>=9754&&r<=9759)||(f=r)>=11008&&f<=11263&&(r>=11026&&r<=11055||r>=11088&&r<=11097||r>=11192&&r<=11243)||n8(r)||ny(r)||(m=r)>=57344&&m<=63743||nk(r)||nP(r)||nL(r)||8734===r||8756===r||8757===r||r>=9984&&r<=10087||r>=10102&&r<=10131||65532===r||65533===r)}function n2(i){return i>=1424&&i<=2303||nz(i)||nD(i)}function nF(i,r){var n;return!(!r&&n2(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||(n=i)>=6016&&n<=6143)}function nO(i){for(const r of i)if(n2(r.charCodeAt(0)))return!0;return!1}const n4="deferred",nU="loading",nV="loaded";let n6=null,nj="unavailable",nN=null;const nG=function(i){i&&"string"==typeof i&&i.indexOf("NetworkError")>-1&&(nj="error"),n6&&n6(i)};function nZ(){n9.fire(new tl("pluginStateChange",{pluginStatus:nj,pluginURL:nN}))}const n9=new tu,n7=function(){return nj},nq=function(){if(nj!==n4||!nN)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");nj=nU,nZ(),nN&&eJ({url:nN},i=>{i?nG(i):(nj=nV,nZ())})},n5={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>nj===nV||null!=n5.applyArabicShaping,isLoading:()=>nj===nU,setState(i){nj=i.pluginStatus,nN=i.pluginURL},isParsed:()=>null!=n5.applyArabicShaping&&null!=n5.processBidirectionalText&&null!=n5.processStyledBidirectionalText,getPluginURL:()=>nN};class nX{constructor(i,r){this.zoom=i,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new nc,this.transition={},this.pitch=0)}isSupportedScript(i){return function(i,r){for(const n of i)if(!nF(n.charCodeAt(0),r))return!1;return!0}(i,n5.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const i=this.zoom,r=i-Math.floor(i),n=this.crossFadingFactor();return i>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*r}}}class nW{constructor(i,r){this.property=i,this.value=r,this.expression=function(i,r){if(rr(i))return new r8(i,r);if(rh(i)){const n=rm(i,r);if("error"===n.result)throw Error(n.value.map(i=>`${i.key}: ${i.message}`).join(", "));return n.value}{let o=i;return"string"==typeof i&&"color"===r.type&&(o=t1.parse(i)),{kind:"constant",evaluate:()=>o}}}(void 0===r?i.specification.default:r,i.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(i,r,n){return this.property.possiblyEvaluate(this,i,r,n)}}class nH{constructor(i){this.property=i,this.value=new nW(i,void 0)}transitioned(i,r){return new nY(this.property,this.value,r,et({},i.transition,this.transition),i.now)}untransitioned(){return new nY(this.property,this.value,null,{},0)}}class nK{constructor(i){this._properties=i,this._values=Object.create(i.defaultTransitionablePropertyValues)}getValue(i){return eh(this._values[i].value.value)}setValue(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nH(this._values[i].property)),this._values[i].value=new nW(this._values[i].property,null===r?void 0:eh(r))}getTransition(i){return eh(this._values[i].transition)}setTransition(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nH(this._values[i].property)),this._values[i].transition=eh(r)||void 0}serialize(){const i={};for(const r of Object.keys(this._values)){const n=this.getValue(r);void 0!==n&&(i[r]=n);const o=this.getTransition(r);void 0!==o&&(i[`${r}-transition`]=o)}return i}transitioned(i,r){const n=new nJ(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].transitioned(i,r._values[o]);return n}untransitioned(){const i=new nJ(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].untransitioned();return i}}class nY{constructor(i,r,n,o,s){const a=o.delay||0,l=o.duration||0;s=s||0,this.property=i,this.value=r,this.begin=s+a,this.end=this.begin+l,i.specification.transition&&(o.delay||o.duration)&&(this.prior=n)}possiblyEvaluate(i,r,n){const o=i.now||0,s=this.value.possiblyEvaluate(i,r,n),a=this.prior;if(a){if(o>this.end||this.value.isDataDriven())return this.prior=null,s;if(oo.zoomHistory.lastIntegerZoom?{from:i,to:r,other:n}:{from:n,to:r,other:i}}interpolate(i){return i}}class on{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){if(void 0!==i.value){if("constant"===i.expression.kind){const s=i.expression.evaluate(r,null,{},n,o);return this._calculate(s,s,s,r)}return this._calculate(i.expression.evaluate(new nX(Math.floor(r.zoom-1),r)),i.expression.evaluate(new nX(Math.floor(r.zoom),r)),i.expression.evaluate(new nX(Math.floor(r.zoom+1),r)),r)}}_calculate(i,r,n,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:i,to:r}:{from:n,to:r}}interpolate(i){return i}}class oo{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){return!!i.expression.evaluate(r,null,{},n,o)}interpolate(){return!1}}class os{constructor(i){for(const r in this.properties=i,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],i){const n=i[r];n.specification.overridable&&this.overridableProperties.push(r);const o=this.defaultPropertyValues[r]=new nW(n,void 0),s=this.defaultTransitionablePropertyValues[r]=new nH(n);this.defaultTransitioningPropertyValues[r]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate({})}}}function oa(i,r){return 256*(i=K(Math.floor(i),0,255))+K(Math.floor(r),0,255)}nr("DataDrivenProperty",oi),nr("DataConstantProperty",ot),nr("CrossFadedDataDrivenProperty",or),nr("CrossFadedProperty",on),nr("ColorRampProperty",oo);const ol={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class oc{constructor(i,r){this._structArray=i,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class ou{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(i,r){return i._trim(),r&&(i.isTransferred=!0,r.push(i.arrayBuffer)),{length:i.length,arrayBuffer:i.arrayBuffer}}static deserialize(i){const r=Object.create(this.prototype);return r.arrayBuffer=i.arrayBuffer,r.length=i.length,r.capacity=i.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(i){this.reserve(i),this.length=i}reserve(i){if(i>this.capacity){this.capacity=Math.max(i,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 Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function oh(i,r=1){let n=0,o=0;return{members:i.map(i=>{const s=ol[i.type].BYTES_PER_ELEMENT,a=n=od(n,Math.max(r,s)),l=i.components||1;return o=Math.max(o,s),n+=s*l,{name:i.name,type:i.type,components:l,offset:a}}),size:od(n,Math.max(o,r)),alignment:r}}function od(i,r){return Math.ceil(i/r)*r}class op extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.int16[o+0]=r,this.int16[o+1]=n,i}}op.prototype.bytesPerElement=4,nr("StructArrayLayout2i4",op);class of extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.int16[a+0]=r,this.int16[a+1]=n,this.int16[a+2]=o,this.int16[a+3]=s,i}}of.prototype.bytesPerElement=8,nr("StructArrayLayout4i8",of);class om extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const u=6*i,h=12*i,d=3*i;return this.int16[u+0]=r,this.int16[u+1]=n,this.uint8[h+4]=o,this.uint8[h+5]=s,this.uint8[h+6]=a,this.uint8[h+7]=l,this.float32[d+2]=c,i}}om.prototype.bytesPerElement=12,nr("StructArrayLayout2i4ub1f12",om);class o8 extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.float32[s+0]=r,this.float32[s+1]=n,this.float32[s+2]=o,i}}o8.prototype.bytesPerElement=12,nr("StructArrayLayout3f12",o8);class og extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,u,h){const d=this.length;return this.resize(d+1),this.emplace(d,i,r,n,o,s,a,l,c,u,h)}emplace(i,r,n,o,s,a,l,c,u,h,d){const p=10*i;return this.uint16[p+0]=r,this.uint16[p+1]=n,this.uint16[p+2]=o,this.uint16[p+3]=s,this.uint16[p+4]=a,this.uint16[p+5]=l,this.uint16[p+6]=c,this.uint16[p+7]=u,this.uint16[p+8]=h,this.uint16[p+9]=d,i}}og.prototype.bytesPerElement=20,nr("StructArrayLayout10ui20",og);class oy extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,i,r,n,o,s,a,l,c)}emplace(i,r,n,o,s,a,l,c,u){const h=8*i;return this.uint16[h+0]=r,this.uint16[h+1]=n,this.uint16[h+2]=o,this.uint16[h+3]=s,this.uint16[h+4]=a,this.uint16[h+5]=l,this.uint16[h+6]=c,this.uint16[h+7]=u,i}}oy.prototype.bytesPerElement=16,nr("StructArrayLayout8ui16",oy);class ox extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y){const x=this.length;return this.resize(x+1),this.emplace(x,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y)}emplace(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x){const $=16*i;return this.int16[$+0]=r,this.int16[$+1]=n,this.int16[$+2]=o,this.int16[$+3]=s,this.uint16[$+4]=a,this.uint16[$+5]=l,this.uint16[$+6]=c,this.uint16[$+7]=u,this.int16[$+8]=h,this.int16[$+9]=d,this.int16[$+10]=p,this.int16[$+11]=f,this.int16[$+12]=m,this.int16[$+13]=g,this.int16[$+14]=y,this.int16[$+15]=x,i}}ox.prototype.bytesPerElement=32,nr("StructArrayLayout4i4ui4i4i32",ox);class o$ extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint32[1*i+0]=r,i}}o$.prototype.bytesPerElement=4,nr("StructArrayLayout1ul4",o$);class ov extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,u,h,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,i,r,n,o,s,a,l,c,u,h,d,p,f)}emplace(i,r,n,o,s,a,l,c,u,h,d,p,f,m){const g=20*i,y=10*i;return this.int16[g+0]=r,this.int16[g+1]=n,this.int16[g+2]=o,this.int16[g+3]=s,this.int16[g+4]=a,this.float32[y+3]=l,this.float32[y+4]=c,this.float32[y+5]=u,this.float32[y+6]=h,this.int16[g+14]=d,this.uint32[y+8]=p,this.uint16[g+18]=f,this.uint16[g+19]=m,i}}ov.prototype.bytesPerElement=40,nr("StructArrayLayout5i4f1i1ul2ui40",ov);class o_ extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const u=8*i;return this.int16[u+0]=r,this.int16[u+1]=n,this.int16[u+2]=o,this.int16[u+4]=s,this.int16[u+5]=a,this.int16[u+6]=l,this.int16[u+7]=c,i}}o_.prototype.bytesPerElement=16,nr("StructArrayLayout3i2i2i16",o_);class ob extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,i,r,n,o,s)}emplace(i,r,n,o,s,a){const l=4*i,c=8*i;return this.float32[l+0]=r,this.float32[l+1]=n,this.float32[l+2]=o,this.int16[c+6]=s,this.int16[c+7]=a,i}}ob.prototype.bytesPerElement=16,nr("StructArrayLayout2f1f2i16",ob);class ow extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=12*i,l=3*i;return this.uint8[a+0]=r,this.uint8[a+1]=n,this.float32[l+1]=o,this.float32[l+2]=s,i}}ow.prototype.bytesPerElement=12,nr("StructArrayLayout2ub2f12",ow);class o0 extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.uint16[s+0]=r,this.uint16[s+1]=n,this.uint16[s+2]=o,i}}o0.prototype.bytesPerElement=6,nr("StructArrayLayout3ui6",o0);class oT extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$,v,_,b){const w=this.length;return this.resize(w+1),this.emplace(w,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$,v,_,b)}emplace(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$,v,_,b,w){const T=30*i,E=15*i,S=60*i;return this.int16[T+0]=r,this.int16[T+1]=n,this.int16[T+2]=o,this.float32[E+2]=s,this.float32[E+3]=a,this.uint16[T+8]=l,this.uint16[T+9]=c,this.uint32[E+5]=u,this.uint32[E+6]=h,this.uint32[E+7]=d,this.uint16[T+16]=p,this.uint16[T+17]=f,this.uint16[T+18]=m,this.float32[E+10]=g,this.float32[E+11]=y,this.uint8[S+48]=x,this.uint8[S+49]=$,this.uint8[S+50]=v,this.uint32[E+13]=_,this.int16[T+28]=b,this.uint8[S+58]=w,i}}oT.prototype.bytesPerElement=60,nr("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",oT);class oE extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$,v,_,b,w,T,E,S,I,C,z,A,k){const P=this.length;return this.resize(P+1),this.emplace(P,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$,v,_,b,w,T,E,S,I,C,z,A,k)}emplace(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$,v,_,b,w,T,E,S,I,C,z,A,k,P){const D=38*i,L=19*i;return this.int16[D+0]=r,this.int16[D+1]=n,this.int16[D+2]=o,this.float32[L+2]=s,this.float32[L+3]=a,this.int16[D+8]=l,this.int16[D+9]=c,this.int16[D+10]=u,this.int16[D+11]=h,this.int16[D+12]=d,this.int16[D+13]=p,this.uint16[D+14]=f,this.uint16[D+15]=m,this.uint16[D+16]=g,this.uint16[D+17]=y,this.uint16[D+18]=x,this.uint16[D+19]=$,this.uint16[D+20]=v,this.uint16[D+21]=_,this.uint16[D+22]=b,this.uint16[D+23]=w,this.uint16[D+24]=T,this.uint16[D+25]=E,this.uint16[D+26]=S,this.uint16[D+27]=I,this.uint16[D+28]=C,this.uint32[L+15]=z,this.float32[L+16]=A,this.float32[L+17]=k,this.float32[L+18]=P,i}}oE.prototype.bytesPerElement=76,nr("StructArrayLayout3i2f6i15ui1ul3f76",oE);class oS extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.float32[1*i+0]=r,i}}oS.prototype.bytesPerElement=4,nr("StructArrayLayout1f4",oS);class oI extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.int16[s+0]=r,this.int16[s+1]=n,this.int16[s+2]=o,i}}oI.prototype.bytesPerElement=6,nr("StructArrayLayout3i6",oI);class oC extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const u=7*i;return this.float32[u+0]=r,this.float32[u+1]=n,this.float32[u+2]=o,this.float32[u+3]=s,this.float32[u+4]=a,this.float32[u+5]=l,this.float32[u+6]=c,i}}oC.prototype.bytesPerElement=28,nr("StructArrayLayout7f28",oC);class oz extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=6*i;return this.uint32[3*i+0]=r,this.uint16[a+2]=n,this.uint16[a+3]=o,this.uint16[a+4]=s,i}}oz.prototype.bytesPerElement=12,nr("StructArrayLayout1ul3ui12",oz);class oA extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.uint16[o+0]=r,this.uint16[o+1]=n,i}}oA.prototype.bytesPerElement=4,nr("StructArrayLayout2ui4",oA);class ok extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint16[1*i+0]=r,i}}ok.prototype.bytesPerElement=2,nr("StructArrayLayout1ui2",ok);class oP extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.float32[o+0]=r,this.float32[o+1]=n,i}}oP.prototype.bytesPerElement=8,nr("StructArrayLayout2f8",oP);class oD extends ou{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.float32[a+0]=r,this.float32[a+1]=n,this.float32[a+2]=o,this.float32[a+3]=s,i}}oD.prototype.bytesPerElement=16,nr("StructArrayLayout4f16",oD);class oL extends oc{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}oL.prototype.size=40;class o1 extends ov{get(i){return new oL(this,i)}}nr("CollisionBoxArray",o1);class oB extends oc{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(i){this._structArray.uint8[this._pos1+49]=i}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(i){this._structArray.uint8[this._pos1+50]=i}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(i){this._structArray.uint32[this._pos4+13]=i}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(i){this._structArray.uint8[this._pos1+58]=i}}oB.prototype.size=60;class oR extends oT{get(i){return new oB(this,i)}}nr("PlacedSymbolArray",oR);class o3 extends oc{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(i){this._structArray.uint32[this._pos4+15]=i}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}o3.prototype.size=76;class oM extends oE{get(i){return new o3(this,i)}}nr("SymbolInstanceArray",oM);class o2 extends oS{getoffsetX(i){return this.float32[1*i+0]}}nr("GlyphOffsetArray",o2);class oF extends oI{getx(i){return this.int16[3*i+0]}gety(i){return this.int16[3*i+1]}gettileUnitDistanceFromAnchor(i){return this.int16[3*i+2]}}nr("SymbolLineVertexArray",oF);class oO extends oc{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}oO.prototype.size=12;class o4 extends oz{get(i){return new oO(this,i)}}nr("FeatureIndexArray",o4);class oU extends oc{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}oU.prototype.size=4;class oV extends oA{get(i){return new oU(this,i)}}nr("FillExtrusionCentroidArray",oV);const o6=oh([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},]),oj=oh([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"},]);var oN=tD(function(i){i.exports=function(i,r){var n,o,s,a,l,c,u,h;for(o=i.length-(n=3&i.length),s=r,l=3432918353,c=461845907,h=0;h>>16)*l&65535)<<16)&4294967295)<<15|u>>>17))*c+(((u>>>16)*c&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(u=0,n){case 3:u^=(255&i.charCodeAt(h+2))<<16;case 2:u^=(255&i.charCodeAt(h+1))<<8;case 1:s^=u=(65535&(u=(u=(65535&(u^=255&i.charCodeAt(h)))*l+(((u>>>16)*l&65535)<<16)&4294967295)<<15|u>>>17))*c+(((u>>>16)*c&65535)<<16)&4294967295}return s^=i.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}),oG=tD(function(i){i.exports=function(i,r){for(var n,o=i.length,s=r^o,a=0;o>=4;)n=1540483477*(65535&(n=255&i.charCodeAt(a)|(255&i.charCodeAt(++a))<<8|(255&i.charCodeAt(++a))<<16|(255&i.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),o-=4,++a;switch(o){case 3:s^=(255&i.charCodeAt(a+2))<<16;case 2:s^=(255&i.charCodeAt(a+1))<<8;case 1:s=1540483477*(65535&(s^=255&i.charCodeAt(a)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}),oZ=oN;oZ.murmur3=oN,oZ.murmur2=oG;class o9{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(i,r,n,o){this.ids.push(o7(i)),this.positions.push(r,n,o)}getPositions(i){const r=o7(i);let n=0,o=this.ids.length-1;for(;n>1;this.ids[s]>=r?o=s:n=s+1}const a=[];for(;this.ids[n]===r;)a.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return a}static serialize(i,r){const n=new Float64Array(i.ids),o=new Uint32Array(i.positions);return oq(n,o,0,n.length-1),r&&r.push(n.buffer,o.buffer),{ids:n,positions:o}}static deserialize(i){const r=new o9;return r.ids=i.ids,r.positions=i.positions,r.indexed=!0,r}}function o7(i){const r=+i;return!isNaN(r)&&Number.MIN_SAFE_INTEGER<=r&&r<=Number.MAX_SAFE_INTEGER?r:oZ(String(i))}function oq(i,r,n,o){for(;n>1];let a=n-1,l=o+1;for(;;){do a++;while(i[a]s)if(a>=l)break;o5(i,a,l),o5(r,3*a,3*l),o5(r,3*a+1,3*l+1),o5(r,3*a+2,3*l+2)}l-n`u_${i}`),this.type=n}setUniform(i,r,n){i.set(n.constantOr(this.value))}getBinding(i,r,n){return"color"===this.type?new oK(i,r):new oW(i,r)}}class si{constructor(i,r){this.uniformNames=r.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(i,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=i.pixelRatio,this.patternFrom=r.tl.concat(r.br),this.patternTo=i.tl.concat(i.br)}setUniform(i,r,n,o){const s="u_pattern_to"===o||"u_dash_to"===o?this.patternTo:"u_pattern_from"===o||"u_dash_from"===o?this.patternFrom:"u_pixel_ratio_to"===o?this.pixelRatioTo:"u_pixel_ratio_from"===o?this.pixelRatioFrom:null;s&&i.set(s)}getBinding(i,r,n){return"u_pattern_from"===n||"u_pattern_to"===n||"u_dash_from"===n||"u_dash_to"===n?new oH(i,r):new oW(i,r)}}class sr{constructor(i,r,n,o){this.expression=i,this.type=n,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(i,r,n,o,s,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new nX(0),r,{},s,o,a);this.paintVertexArray.resize(i),this._setPaintValue(l,i,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:0},n,o,void 0,s);this._setPaintValue(i,r,a)}_setPaintValue(i,r,n){if("color"===this.type){const o=se(n);for(let s=i;s`u_${i}_t`),this.type=n,this.useIntegerZoom=o,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(i,r,n,o,s,a){const l=this.expression.evaluate(new nX(this.zoom),r,{},s,o,a),c=this.expression.evaluate(new nX(this.zoom+1),r,{},s,o,a),u=this.paintVertexArray.length;this.paintVertexArray.resize(i),this._setPaintValue(u,i,l,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom},n,o,void 0,s),l=this.expression.evaluate({zoom:this.zoom+1},n,o,void 0,s);this._setPaintValue(i,r,a,l)}_setPaintValue(i,r,n,o){if("color"===this.type){const s=se(n),a=se(o);for(let l=i;l!0){this.binders={},this._buffers=[];const o=[];for(const s in i.paint._values){if(!n(s))continue;const a=i.paint.get(s);if(!(a instanceof nQ&&iQ(a.property.specification)))continue;const l=sc(s,i.type),c=a.value,u=a.property.specification.type,h=a.property.useIntegerZoom,d=a.property.specification["property-type"],p="cross-faded"===d||"cross-faded-data-driven"===d,f="line-dasharray"===String(s)&&"constant"!==i.layout.get("line-cap").value.kind;if("constant"!==c.kind||f){if("source"===c.kind||f||p){const m=sd(s,u,"source");this.binders[s]=p?new so(c,l,u,h,r,m,i.id):new sr(c,l,u,m),o.push(`/a_${s}`)}else{const g=sd(s,u,"composite");this.binders[s]=new sn(c,l,u,h,r,g),o.push(`/z_${s}`)}}else this.binders[s]=p?new si(c.value,l):new st(c.value,l,u),o.push(`/u_${s}`)}this.cacheKey=o.sort().join("")}getMaxValue(i){const r=this.binders[i];return r instanceof sr||r instanceof sn?r.maxValue:0}populatePaintArrays(i,r,n,o,s,a){for(const l in this.binders){const c=this.binders[l];(c instanceof sr||c instanceof sn||c instanceof so)&&c.populatePaintArray(i,r,n,o,s,a)}}setConstantPatternPositions(i,r){for(const n in this.binders){const o=this.binders[n];o instanceof si&&o.setConstantPatternPositions(i,r)}}updatePaintArrays(i,r,n,o,s,a){let l=!1;for(const c in i){const u=r.getPositions(c);for(const h of u){const d=n.feature(h.index);for(const p in this.binders){const f=this.binders[p];if((f instanceof sr||f instanceof sn||f instanceof so)&&!0===f.expression.isStateDependent){const m=o.paint.get(p);f.expression=m.value,f.updatePaintArray(h.start,h.end,d,i[c],s,a),l=!0}}}}return l}defines(){const i=[];for(const r in this.binders){const n=this.binders[r];(n instanceof st||n instanceof si)&&i.push(...n.uniformNames.map(i=>`#define HAS_UNIFORM_${i}`))}return i}getBinderAttributes(){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof sr||n instanceof sn||n instanceof so)for(let o=0;o!0){for(const o of(this.programConfigurations={},i))this.programConfigurations[o.id]=new ss(o,r,n);this.needsUpload=!1,this._featureMap=new o9,this._bufferOffset=0}populatePaintArrays(i,r,n,o,s,a,l){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(i,r,o,s,a,l);void 0!==r.id&&this._featureMap.add(r.id,n,this._bufferOffset,i),this._bufferOffset=i,this.needsUpload=!0}updatePaintArrays(i,r,n,o,s){for(const a of n)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(i,this._featureMap,r,a,o,s)||this.needsUpload}get(i){return this.programConfigurations[i]}upload(i){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(i);this.needsUpload=!1}}destroy(){for(const i in this.programConfigurations)this.programConfigurations[i].destroy()}}const sl={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from",],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from",],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from",],"line-dasharray":["dash_to","dash_from"]};function sc(i,r){return sl[i]||[i.replace(`${r}-`,"").replace(/-/g,"_"),]}const su={"line-pattern":{source:og,composite:og},"fill-pattern":{source:og,composite:og},"fill-extrusion-pattern":{source:og,composite:og},"line-dasharray":{source:oy,composite:oy}},sh={color:{source:oP,composite:oD},number:{source:oS,composite:oP}};function sd(i,r,n){const o=su[i];return o&&o[n]||sh[r][n]}nr("ConstantBinder",st),nr("CrossFadedConstantBinder",si),nr("SourceExpressionBinder",sr),nr("CrossFadedCompositeBinder",so),nr("CompositeExpressionBinder",sn),nr("ProgramConfiguration",ss,{omit:["_buffers"]}),nr("ProgramConfigurationSet",sa);const sp="-transition";class sf extends tu{constructor(i,r){if(super(),this.id=i.id,this.type=i.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==i.type&&(this.metadata=i.metadata,this.minzoom=i.minzoom,this.maxzoom=i.maxzoom,"background"!==i.type&&"sky"!==i.type&&(this.source=i.source,this.sourceLayer=i["source-layer"],this.filter=i.filter),r.layout&&(this._unevaluatedLayout=new class{constructor(i){this._properties=i,this._values=Object.create(i.defaultPropertyValues)}getValue(i){return eh(this._values[i].value)}setValue(i,r){this._values[i]=new nW(this._values[i].property,null===r?void 0:eh(r))}serialize(){const i={};for(const r of Object.keys(this._values)){const n=this.getValue(r);void 0!==n&&(i[r]=n)}return i}possiblyEvaluate(i,r,n){const o=new oe(this._properties);for(const s of Object.keys(this._values))o._values[s]=this._values[s].possiblyEvaluate(i,r,n);return o}}(r.layout)),r.paint)){for(const n in this._transitionablePaint=new nK(r.paint),i.paint)this.setPaintProperty(n,i.paint[n],{validate:!1});for(const o in i.layout)this.setLayoutProperty(o,i.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new oe(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(i){return"visibility"===i?this.visibility:this._unevaluatedLayout.getValue(i)}setLayoutProperty(i,r,n={}){null!=r&&this._validate(rK,`layers.${this.id}.layout.${i}`,i,r,n)||("visibility"!==i?this._unevaluatedLayout.setValue(i,r):this.visibility=r)}getPaintProperty(i){return el(i,sp)?this._transitionablePaint.getTransition(i.slice(0,-sp.length)):this._transitionablePaint.getValue(i)}setPaintProperty(i,r,n={}){if(null!=r&&this._validate(rH,`layers.${this.id}.paint.${i}`,i,r,n))return!1;if(el(i,sp))return this._transitionablePaint.setTransition(i.slice(0,-sp.length),r||void 0),!1;{const o=this._transitionablePaint._values[i],s="cross-faded-data-driven"===o.property.specification["property-type"],a=o.value.isDataDriven(),l=o.value;this._transitionablePaint.setValue(i,r),this._handleSpecialPaintPropertyUpdate(i);const c=this._transitionablePaint._values[i].value;return c.isDataDriven()||a||s||this._handleOverridablePaintPropertyUpdate(i,l,c)}}_handleSpecialPaintPropertyUpdate(i){}getProgramIds(){return null}getProgramConfiguration(i){return null}_handleOverridablePaintPropertyUpdate(i,r,n){return!1}isHidden(i){return!!(this.minzoom&&i=this.maxzoom)||"none"===this.visibility}updateTransitions(i){this._transitioningPaint=this._transitionablePaint.transitioned(i,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(i,r){i.getCrossfadeParameters&&(this._crossfadeParameters=i.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(i,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(i,void 0,r)}serialize(){const i={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&&(i.layout=i.layout||{},i.layout.visibility=this.visibility),eu(i,(i,r)=>!(void 0===i||"layout"===r&&!Object.keys(i).length||"paint"===r&&!Object.keys(i).length))}_validate(i,r,n,o,s={}){return(!s||!1!==s.validate)&&rY(this,i.call(r5,{key:r,layerType:this.type,objectKey:n,value:o,styleSpec:th,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const i in this.paint._values){const r=this.paint.get(i);if(r instanceof nQ&&iQ(r.property.specification)&&("source"===r.value.kind||"composite"===r.value.kind)&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=rT(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const sm=oh([{name:"a_pos",components:2,type:"Int16"},],4),{members:s8}=sm;class sg{constructor(i=[]){this.segments=i}prepareSegment(i,r,n,o){let s=this.segments[this.segments.length-1];return i>sg.MAX_VERTEX_ARRAY_LENGTH&&ep(`Max vertices per segment is ${sg.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${i}`),(!s||s.vertexLength+i>sg.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==o)&&(s={vertexOffset:r.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==o&&(s.sortKey=o),this.segments.push(s)),s}get(){return this.segments}destroy(){for(const i of this.segments)for(const r in i.vaos)i.vaos[r].destroy()}static simpleSegment(i,r,n,o){return new sg([{vertexOffset:i,primitiveOffset:r,vertexLength:n,primitiveLength:o,vaos:{},sortKey:0},])}}sg.MAX_VERTEX_ARRAY_LENGTH=65535,nr("SegmentVector",sg);class sy{constructor(i,r){i&&(r?this.setSouthWest(i).setNorthEast(r):4===i.length?this.setSouthWest([i[0],i[1],]).setNorthEast([i[2],i[3]]):this.setSouthWest(i[0]).setNorthEast(i[1]))}setNorthEast(i){return this._ne=i instanceof sx?new sx(i.lng,i.lat):sx.convert(i),this}setSouthWest(i){return this._sw=i instanceof sx?new sx(i.lng,i.lat):sx.convert(i),this}extend(i){const r=this._sw,n=this._ne;let o,s;if(i instanceof sx)o=i,s=i;else{if(!(i instanceof sy))return Array.isArray(i)?4===i.length||i.every(Array.isArray)?this.extend(sy.convert(i)):this.extend(sx.convert(i)):this;if(o=i._sw,s=i._ne,!o||!s)return this}return r||n?(r.lng=Math.min(o.lng,r.lng),r.lat=Math.min(o.lat,r.lat),n.lng=Math.max(s.lng,n.lng),n.lat=Math.max(s.lat,n.lat)):(this._sw=new sx(o.lng,o.lat),this._ne=new sx(s.lng,s.lat)),this}getCenter(){return new sx((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 sx(this.getWest(),this.getNorth())}getSouthEast(){return new sx(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(i){const{lng:r,lat:n}=sx.convert(i);let o=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&o}static convert(i){return!i||i instanceof sy?i:new sy(i)}}class sx{constructor(i,r){if(isNaN(i)||isNaN(r))throw Error(`Invalid LngLat object: (${i}, ${r})`);if(this.lng=+i,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new sx(J(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(i){const r=Math.PI/180,n=this.lat*r,o=i.lat*r,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos((i.lng-this.lng)*r);return 6371008.8*Math.acos(Math.min(s,1))}toBounds(i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*this.lat);return new sy(new sx(this.lng-n,this.lat-r),new sx(this.lng+n,this.lat+r))}static convert(i){if(i instanceof sx)return i;if(Array.isArray(i)&&(2===i.length||3===i.length))return new sx(Number(i[0]),Number(i[1]));if(!Array.isArray(i)&&"object"==typeof i&&null!==i)return new sx(Number("lng"in i?i.lng:i.lon),Number(i.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const s$=2*Math.PI*6371008.8;function sv(i){return s$*Math.cos(i*Math.PI/180)}function s_(i){return(180+i)/360}function sb(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function sw(i,r){return i/sv(r)}function s0(i){return 360*i-180}function sT(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}function sE(i,r){return i*sv(sT(r))}class sS{constructor(i,r,n=0){this.x=+i,this.y=+r,this.z=+n}static fromLngLat(i,r=0){const n=sx.convert(i);return new sS(s_(n.lng),sb(n.lat),r/sv(n.lat))}toLngLat(){return new sx(s0(this.x),sT(this.y))}toAltitude(){return sE(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/s$*(1/Math.cos(sT(this.y)*Math.PI/180))}}function sI(i,r,n,o,s,a,c,u,h){const d=(r+o)/2,p=(n+s)/2,f=new l(d,p);u(f),function(i,r,n,o,s,a){const l=n-s,c=o-a;return Math.abs((o-r)*l-(n-i)*c)/Math.hypot(l,c)}(f.x,f.y,a.x,a.y,c.x,c.y)>=h?(sI(i,r,n,d,p,a,f,u,h),sI(i,d,p,o,s,f,c,u,h)):i.push(c)}function sC(i,r,n){const o=[];let s,a,l;for(const c of i){const{x:u,y:h}=c;r(c),l?sI(o,s,a,u,h,l,c,r,n):o.push(c),s=u,a=h,l=c}return o}const sz=-16383-1;function sA(i,r){const n=Math.round(i.x*r),o=Math.round(i.y*r);return i.x=K(n,sz,16383),i.y=K(o,sz,16383),(ni.x+1||oi.y+1)&&ep("Geometry exceeds allowed extent, reduce your vector tile buffer size"),i}function sk(i,r,n){const o=i.loadGeometry(),s=i.extent,a=8192/s;if(r&&n&&n.projection.isReprojectedInTileSpace){const l=1<{const n=s0((r.x+i.x/s)/l),o=sT((r.y+i.y/s)/l),a=d.project(n,o);i.x=(a.x*c-u)*s,i.y=(a.y*c-h)*s};for(let f=0;f=s||g.y<0||g.y>=s||(p(g),m.push(g));o[f]=m}}for(const y of o)for(const x of y)sA(x,a);return o}function sP(i,r){return{type:i.type,id:i.id,properties:i.properties,geometry:r?sk(i):[]}}function sD(i,r,n,o,s){i.emplaceBack(2*r+(o+1)/2,2*n+(s+1)/2)}class sL{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new op,this.indexArray=new o0,this.segments=new sg,this.programConfigurations=new sa(i.layers,i.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){const s=this.layers[0],a=[];let l=null;for(const{feature:c,id:u,index:h,sourceLayerIndex:d}of("circle"===s.type&&(l=s.layout.get("circle-sort-key")),i)){const p=this.layers[0]._featureFilter.needGeometry,f=sP(c,p);if(!this.layers[0]._featureFilter.filter(new nX(this.zoom),f,n))continue;const m=l?l.evaluate(f,{},n):void 0,g={id:u,properties:c.properties,type:c.type,sourceLayerIndex:d,index:h,geometry:p?f.geometry:sk(c,n,o),patterns:{},sortKey:m};a.push(g)}for(const y of(l&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:x,index:$,sourceLayerIndex:v}=y,_=i[$].feature;this.addFeature(y,x,$,r.availableImages,n),r.featureIndex.insert(_,x,$,v,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,s8),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(i,r,n,o,s){for(const a of r)for(const l of a){const c=l.x,u=l.y;if(c<0||c>=8192||u<0||u>=8192)continue;const h=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,i.sortKey),d=h.vertexLength;sD(this.layoutVertexArray,c,u,-1,-1),sD(this.layoutVertexArray,c,u,1,-1),sD(this.layoutVertexArray,c,u,1,1),sD(this.layoutVertexArray,c,u,-1,1),this.indexArray.emplaceBack(d,d+1,d+2),this.indexArray.emplaceBack(d,d+3,d+2),h.vertexLength+=4,h.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,{},o,s)}}function s1(i,r){for(let n=0;n1){if(sM(i,r))return!0;for(let o=0;o1?n:n.sub(r)._mult(s)._add(r))}function s4(i,r){let n,o,s,a=!1;for(let l=0;lr.y!=s.y>r.y&&r.x<(s.x-o.x)*(r.y-o.y)/(s.y-o.y)+o.x&&(a=!a)}return a}function sU(i,r){let n=!1;for(let o=0,s=i.length-1;or.y!=l.y>r.y&&r.x<(l.x-a.x)*(r.y-a.y)/(l.y-a.y)+a.x&&(n=!n)}return n}function sV(i,r,n,o,s){for(const a of i)if(r<=a.x&&n<=a.y&&o>=a.x&&s>=a.y)return!0;const c=[new l(r,n),new l(r,s),new l(o,s),new l(o,n),];if(i.length>2){for(const u of c)if(sU(i,u))return!0}for(let h=0;hs.x&&r.x>s.x||i.ys.y&&r.y>s.y)return!1;const a=ef(i,r,n[0]);return a!==ef(i,r,n[1])||a!==ef(i,r,n[2])||a!==ef(i,r,n[3])}function sj(i,r,n){const o=r.paint.get(i).value;return"constant"===o.kind?o.value:n.programConfigurations.get(r.id).getMaxValue(i)}function sN(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function sG(i,r,n,o,s){if(!r[0]&&!r[1])return i;const a=l.convert(r)._mult(s);"viewport"===n&&a._rotate(-o);const c=[];for(let u=0;u{var a,l,c;const u=M([],n,i),h=1/u[3]/r*s;return a=u,l=u,c=[h,h,o?1/u[3]:h,h],a[0]=l[0]*c[0],a[1]=l[1]*c[1],a[2]=l[2]*c[2],a[3]=l[3]*c[3],a}),l=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5],].map(i=>{const r=A([],P([],R([],a[i[0]],a[i[1]]),R([],a[i[2]],a[i[1]]))),n=-k(r,a[i[1]]);return r.concat(n)});return new sq(a,l)}}class s5{constructor(i,r){this.min=i,this.max=r,this.center=C([],T([],this.min,this.max),.5)}quadrant(i){const r=[i%2==0,i<2],n=_(this.min),o=_(this.max);for(let s=0;s=0;if(0===a)return 0;a!==r.length&&(n=!1)}if(n)return 2;for(let c=0;c<3;c++){let u=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(let d=0;dthis.max[c]-this.min[c])return 0}return 1}}function sX(i,r,n,o,s,a,l,c,u){if(a&&i.queryGeometry.isAboveHorizon)return!1;for(const h of(a&&(u*=i.pixelToTileUnitsFactor),r))for(const d of h){const p=d.add(c),f=s&&n.elevation?n.elevation.exaggeration()*s.getElevationAt(p.x,p.y,!0):0,m=a?p:sW(p,f,o),g=a?i.tilespaceRays.map(i=>sY(i,f)):i.queryGeometry.screenGeometry,y=M([],[d.x,d.y,f,1],o);if(!l&&a?u*=y[3]/n.cameraToCenterDistance:l&&!a&&(u*=n.cameraToCenterDistance/y[3]),sB(g,m,u))return!0}return!1}function sW(i,r,n){const o=M([],[i.x,i.y,r,1],n);return new l(o[0]/o[3],o[1]/o[3])}const sH=w(0,0,0),sK=w(0,0,1);function sY(i,r){const n=v();return sH[2]=r,i.intersectsPlane(sH,sK,n),new l(n[0],n[1])}class sJ extends sL{}function sQ(i,{width:r,height:n},o,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==r*n*o)throw RangeError("mismatched image size")}else s=new Uint8Array(r*n*o);return i.width=r,i.height=n,i.data=s,i}function ae(i,{width:r,height:n},o){if(r===i.width&&n===i.height)return;const s=sQ({},{width:r,height:n},o);at(i,s,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,r),height:Math.min(i.height,n)},o),i.width=r,i.height=n,i.data=s.data}function at(i,r,n,o,s,a){if(0===s.width||0===s.height)return r;if(s.width>i.width||s.height>i.height||n.x>i.width-s.width||n.y>i.height-s.height)throw RangeError("out of range source coordinates for image copy");if(s.width>r.width||s.height>r.height||o.x>r.width-s.width||o.y>r.height-s.height)throw RangeError("out of range destination coordinates for image copy");const l=i.data,c=r.data;for(let u=0;u{r[i.evaluationKey]=a;const l=i.expression.evaluate(r);s.data[n+o+0]=Math.floor(255*l.r/l.a),s.data[n+o+1]=Math.floor(255*l.g/l.a),s.data[n+o+2]=Math.floor(255*l.b/l.a),s.data[n+o+3]=Math.floor(255*l.a)};if(i.clips)for(let l=0,c=0;l80*n){o=a=i[0],s=l=i[1];for(var g=n;ga&&(a=c),u>l&&(l=u);h=0!==(h=Math.max(a-o,l-s))?1/h:0}return ap(f,m,n,o,s,h),m}function ah(i,r,n,o,s){var a,l;if(s===aD(i,r,n,o)>0)for(a=r;a=r;a-=o)l=aA(a,i[a],i[a+1],l);return l&&aT(l,l.next)&&(ak(l),l=l.next),l}function ad(i,r){if(!i)return i;r||(r=i);var n,o=i;do if(n=!1,o.steiner||!aT(o,o.next)&&0!==a0(o.prev,o,o.next))o=o.next;else{if(ak(o),(o=r=o.prev)===o.next)break;n=!0}while(n||o!==r)return r}function ap(i,r,n,o,s,a,l){if(i){!l&&a&&function(i,r,n,o){var s=i;do null===s.z&&(s.z=av(s.x,s.y,r,n,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i)s.prevZ.nextZ=null,s.prevZ=null,function(i){var r,n,o,s,a,l,c,u,h=1;do{for(n=i,i=null,a=null,l=0;n;){for(l++,o=n,c=0,r=0;r0||u>0&&o;)0!==c&&(0===u||!o||n.z<=o.z)?(s=n,n=n.nextZ,c--):(s=o,o=o.nextZ,u--),a?a.nextZ=s:i=s,s.prevZ=a,a=s;n=o}a.nextZ=null,h*=2}while(l>1)}(s)}(i,o,s,a);for(var c,u,h=i;i.prev!==i.next;)if(c=i.prev,u=i.next,a?am(i,o,s,a):af(i))r.push(c.i/n),r.push(i.i/n),r.push(u.i/n),ak(i),i=u.next,h=u.next;else if((i=u)===h){l?1===l?ap(i=a8(ad(i),r,n),r,n,o,s,a,2):2===l&&ag(i,r,n,o,s,a):ap(ad(i),r,n,o,s,a,1);break}}}function af(i){var r=i.prev,n=i,o=i.next;if(a0(r,n,o)>=0)return!1;for(var s=i.next.next;s!==i.prev;){if(ab(r.x,r.y,n.x,n.y,o.x,o.y,s.x,s.y)&&a0(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function am(i,r,n,o){var s=i.prev,a=i,l=i.next;if(a0(s,a,l)>=0)return!1;for(var c=s.x>a.x?s.x>l.x?s.x:l.x:a.x>l.x?a.x:l.x,u=s.y>a.y?s.y>l.y?s.y:l.y:a.y>l.y?a.y:l.y,h=av(s.x=h&&f&&f.z<=d;){if(p!==i.prev&&p!==i.next&&ab(s.x,s.y,a.x,a.y,l.x,l.y,p.x,p.y)&&a0(p.prev,p,p.next)>=0||(p=p.prevZ,f!==i.prev&&f!==i.next&&ab(s.x,s.y,a.x,a.y,l.x,l.y,f.x,f.y)&&a0(f.prev,f,f.next)>=0))return!1;f=f.nextZ}for(;p&&p.z>=h;){if(p!==i.prev&&p!==i.next&&ab(s.x,s.y,a.x,a.y,l.x,l.y,p.x,p.y)&&a0(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==i.prev&&f!==i.next&&ab(s.x,s.y,a.x,a.y,l.x,l.y,f.x,f.y)&&a0(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function a8(i,r,n){var o=i;do{var s=o.prev,a=o.next.next;!aT(s,a)&&aE(s,o,o.next,a)&&aC(s,a)&&aC(a,s)&&(r.push(s.i/n),r.push(o.i/n),r.push(a.i/n),ak(o),ak(o.next),o=i=a),o=o.next}while(o!==i)return ad(o)}function ag(i,r,n,o,s,a){var l=i;do{for(var c=l.next.next;c!==l.prev;){if(l.i!==c.i&&aw(l,c)){var u=az(l,c);return l=ad(l,l.next),u=ad(u,u.next),ap(l,r,n,o,s,a),void ap(u,r,n,o,s,a)}c=c.next}l=l.next}while(l!==i)}function ay(i,r){return i.x-r.x}function ax(i,r){var n=function(i,r){var n,o=r,s=i.x,a=i.y,l=-1/0;do{if(a<=o.y&&a>=o.next.y&&o.next.y!==o.y){var c=o.x+(a-o.y)*(o.next.x-o.x)/(o.next.y-o.y);if(c<=s&&c>l){if(l=c,c===s){if(a===o.y)return o;if(a===o.next.y)return o.next}n=o.x=o.x&&o.x>=d&&s!==o.x&&ab(an.x||o.x===n.x&&a$(n,o)))&&(n=o,f=u)),o=o.next;while(o!==h)return n}(i,r);if(!n)return r;var o=az(n,i),s=ad(n,n.next);return ad(o,o.next),r===n?s:r}function a$(i,r){return 0>a0(i.prev,i,r.prev)&&0>a0(r.next,i,i.next)}function av(i,r,n,o,s){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=32767*(i-n)*s)|i<<8))|i<<4))|i<<2))|i<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=32767*(r-o)*s)|r<<8))|r<<4))|r<<2))|r<<1))<<1}function a_(i){var r=i,n=i;do(r.x=0&&(i-l)*(o-c)-(n-l)*(r-c)>=0&&(n-l)*(a-c)-(s-l)*(o-c)>=0}function aw(i,r){return i.next.i!==r.i&&i.prev.i!==r.i&&!function(i,r){var n=i;do{if(n.i!==i.i&&n.next.i!==i.i&&n.i!==r.i&&n.next.i!==r.i&&aE(n,n.next,i,r))return!0;n=n.next}while(n!==i)return!1}(i,r)&&(aC(i,r)&&aC(r,i)&&function(i,r){var n=i,o=!1,s=(i.x+r.x)/2,a=(i.y+r.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&s<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==i)return o}(i,r)&&(a0(i.prev,i,r.prev)||a0(i,r.prev,r))||aT(i,r)&&a0(i.prev,i,i.next)>0&&a0(r.prev,r,r.next)>0)}function a0(i,r,n){return(r.y-i.y)*(n.x-r.x)-(r.x-i.x)*(n.y-r.y)}function aT(i,r){return i.x===r.x&&i.y===r.y}function aE(i,r,n,o){var s=aI(a0(i,r,n)),a=aI(a0(i,r,o)),l=aI(a0(n,o,i)),c=aI(a0(n,o,r));return s!==a&&l!==c||!(0!==s||!aS(i,n,r))||!(0!==a||!aS(i,o,r))||!(0!==l||!aS(n,i,o))||!(0!==c||!aS(n,r,o))}function aS(i,r,n){return r.x<=Math.max(i.x,n.x)&&r.x>=Math.min(i.x,n.x)&&r.y<=Math.max(i.y,n.y)&&r.y>=Math.min(i.y,n.y)}function aI(i){return i>0?1:i<0?-1:0}function aC(i,r){return 0>a0(i.prev,i,i.next)?a0(i,r,i.next)>=0&&a0(i,i.prev,r)>=0:0>a0(i,r,i.prev)||0>a0(i,i.next,r)}function az(i,r){var n=new aP(i.i,i.x,i.y),o=new aP(r.i,r.x,r.y),s=i.next,a=r.prev;return i.next=r,r.prev=i,n.next=s,s.prev=n,o.next=n,n.prev=o,a.next=o,o.prev=a,o}function aA(i,r,n,o){var s=new aP(i,r,n);return o?(s.next=o.next,s.prev=o,o.next.prev=s,o.next=s):(s.prev=s,s.next=s),s}function ak(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 aP(i,r,n){this.i=i,this.x=r,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function aD(i,r,n,o){for(var s=0,a=r,l=n-o;an;){if(o-n>600){var a=o-n+1,l=r-n+1,c=Math.log(a),u=.5*Math.exp(2*c/3),h=.5*Math.sqrt(c*u*(a-u)/a)*(l-a/2<0?-1:1);a1(i,r,Math.max(n,Math.floor(r-l*u/a+h)),Math.min(o,Math.floor(r+(a-l)*u/a+h)),s)}var d=i[r],p=n,f=o;for(aB(i,n,r),s(i[o],d)>0&&aB(i,n,o);ps(i[p],d);)p++;for(;s(i[f],d)>0;)f--}0===s(i[n],d)?aB(i,n,f):aB(i,++f,o),f<=r&&(n=f+1),r<=f&&(o=f-1)}}function aB(i,r,n){var o=i[r];i[r]=i[n],i[n]=o}function aR(i,r){return ir?1:0}function a3(i,r){const n=i.length;if(n<=1)return[i];const o=[];let s,a;for(let l=0;l1)for(let u=0;u0&&n.holes.push(o+=i[s-1].length)}return n},ac.default=au;class aO{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new op,this.indexArray=new o0,this.indexArray2=new oA,this.programConfigurations=new sa(i.layers,i.zoom),this.segments=new sg,this.segments2=new sg,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=a2("fill",this.layers,r);const s=this.layers[0].layout.get("fill-sort-key"),a=[];for(const{feature:l,id:c,index:u,sourceLayerIndex:h}of i){const d=this.layers[0]._featureFilter.needGeometry,p=sP(l,d);if(!this.layers[0]._featureFilter.filter(new nX(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n,r.availableImages):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:h,index:u,geometry:d?p.geometry:sk(l,n,o),patterns:{},sortKey:f};a.push(m)}for(const g of(s&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:y,index:x,sourceLayerIndex:$}=g;if(this.hasPattern){const v=aF("fill",this.layers,g,this.zoom,r);this.patternFeatures.push(v)}else this.addFeature(g,y,x,n,{},r.availableImages);r.featureIndex.insert(i[x].feature,y,x,$,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,al),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.indexBuffer2=i.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(i),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(i,r,n,o,s,a=[]){for(const l of a3(r,500)){let c=0;for(const u of l)c+=u.length;const h=this.segments.prepareSegment(c,this.layoutVertexArray,this.indexArray),d=h.vertexLength,p=[],f=[];for(const m of l){if(0===m.length)continue;m!==l[0]&&f.push(p.length/2);const g=this.segments2.prepareSegment(m.length,this.layoutVertexArray,this.indexArray2),y=g.vertexLength;this.layoutVertexArray.emplaceBack(m[0].x,m[0].y),this.indexArray2.emplaceBack(y+m.length-1,y),p.push(m[0].x),p.push(m[0].y);for(let x=1;x>3}if(s--,1===o||2===o)a+=i.readSVarint(),c+=i.readSVarint(),1===o&&(r&&u.push(r),r=[]),r.push(new l(a,c));else{if(7!==o)throw Error("unknown command "+o);r&&r.push(r[0].clone())}}return r&&u.push(r),u},aG.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var r=i.readVarint()+i.pos,n=1,o=0,s=0,a=0,l=1/0,c=-1/0,u=1/0,h=-1/0;i.pos>3}if(o--,1===n||2===n)(s+=i.readSVarint())c&&(c=s),(a+=i.readSVarint())h&&(h=a);else if(7!==n)throw Error("unknown command "+n)}return[l,u,c,h]},aG.prototype.toGeoJSON=function(i,r,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*i,c=this.extent*r,u=this.loadGeometry(),h=aG.types[this.type];function d(i){for(var r=0;r>3;r=1===o?i.readString():2===o?i.readFloat():3===o?i.readDouble():4===o?i.readVarint64():5===o?i.readVarint():6===o?i.readSVarint():7===o?i.readBoolean():null}return r}(n))}function aX(i,r,n){if(3===i){var o=new a7(n,n.readVarint()+n.pos);o.length&&(r[o.name]=o)}}aq.prototype.feature=function(i){if(i<0||i>=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[i];var r=this._pbf.readVarint()+this._pbf.pos;return new aN(this._pbf,r,this.extent,this._keys,this._values)};var aW={VectorTile:function(i,r){this.layers=i.readFields(aX,{},r)},VectorTileFeature:aN,VectorTileLayer:a7};const aH=aW.VectorTileFeature.types;function aK(i,r,n,o,s,a,l,c){i.emplaceBack((r<<1)+l,(n<<1)+a,(Math.floor(8192*o)<<1)+s,Math.round(c))}class aY{constructor(){this.acc=new l(0,0),this.polyCount=[]}startRing(i){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new l(i.x,i.y),this.max=new l(i.x,i.y))}append(i,r){this.currentPolyCount.edges++,this.acc._add(i);let n=!!this.borders;const o=this.min,s=this.max;i.xs.x&&(s.x=i.x,n=!0),i.ys.y&&(s.y=i.y,n=!0),((0===i.x||8192===i.x)&&i.x===r.x)!=((0===i.y||8192===i.y)&&i.y===r.y)&&this.processBorderOverlap(i,r),n&&this.checkBorderIntersection(i,r)}checkBorderIntersection(i,r){r.x<0!=i.x<0&&this.addBorderIntersection(0,i$(r.y,i.y,(0-r.x)/(i.x-r.x))),r.x>8192!=i.x>8192&&this.addBorderIntersection(1,i$(r.y,i.y,(8192-r.x)/(i.x-r.x))),r.y<0!=i.y<0&&this.addBorderIntersection(2,i$(r.x,i.x,(0-r.y)/(i.y-r.y))),r.y>8192!=i.y>8192&&this.addBorderIntersection(3,i$(r.x,i.x,(8192-r.y)/(i.y-r.y)))}addBorderIntersection(i,r){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],]);const n=this.borders[i];rn[1]&&(n[1]=r)}processBorderOverlap(i,r){if(i.x===r.x){if(i.y===r.y)return;const n=0===i.x?0:1;this.addBorderIntersection(n,r.y),this.addBorderIntersection(n,i.y)}else{const o=0===i.y?2:3;this.addBorderIntersection(o,r.x),this.addBorderIntersection(o,i.x)}}centroid(){const i=this.polyCount.reduce((i,r)=>i+r.edges,0);return 0!==i?this.acc.div(i)._round():new l(0,0)}span(){return new l(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((i,r)=>i+ +(r[0]!==Number.MAX_VALUE),0)}}class aJ{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new of,this.centroidVertexArray=new oV,this.indexArray=new o0,this.programConfigurations=new sa(i.layers,i.zoom),this.segments=new sg,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=i.enableTerrain}populate(i,r,n,o){for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of(this.features=[],this.hasPattern=a2("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(i){const r=Math.exp(Math.PI*(1-i.y/(1<i.x<=0)||l.every(i=>i.x>=8192)||l.every(i=>i.y<=0)||l.every(i=>i.y>=8192))continue;for(let p=0;p=1){const x=f[g-1];if(!aQ(y,x)){c&&c.append(y,x),d.vertexLength+4>sg.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const $=y.sub(x)._perp(),v=$.x/(Math.abs($.x)+Math.abs($.y)),_=$.y>0?1:0,b=x.dist(y);m+b>32768&&(m=0),aK(this.layoutVertexArray,y.x,y.y,v,_,0,0,m),aK(this.layoutVertexArray,y.x,y.y,v,_,0,1,m),m+=b,aK(this.layoutVertexArray,x.x,x.y,v,_,0,0,m),aK(this.layoutVertexArray,x.x,x.y,v,_,0,1,m);const w=d.vertexLength;this.indexArray.emplaceBack(w,w+2,w+1),this.indexArray.emplaceBack(w+1,w+2,w+3),d.vertexLength+=4,d.primitiveLength+=2}}}}if(d.vertexLength+h>sg.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(h,this.layoutVertexArray,this.indexArray)),"Polygon"!==aH[i.type])continue;const T=[],E=[],S=d.vertexLength;for(let I=0;I0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const D=c.borders,L=this.featuresOnBorder.push(c)-1;for(let B=0;B<4;B++)D[B][0]!==Number.MAX_VALUE&&this.borders[B].push(L)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}sortBorders(){for(let i=0;i<4;i++)this.borders[i].sort((r,n)=>this.featuresOnBorder[r].borders[i][0]-this.featuresOnBorder[n].borders[i][0])}encodeCentroid(i,r,n=!0){let o,s;if(i){if(0!==i.y){const a=r.span()._mult(this.tileToMeter);o=(Math.max(i.x,1)<<3)+Math.min(7,Math.round(a.x/10)),s=(Math.max(i.y,1)<<3)+Math.min(7,Math.round(a.y/10))}else o=Math.ceil(7*(i.x+450)),s=0}else o=0,s=+n;let l=n?this.centroidVertexArray.length:r.vertexArrayOffset;for(const c of r.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*c.edges+c.top);for(let u=0;u<2*c.edges;u++)this.centroidVertexArray.emplace(l++,0,s),this.centroidVertexArray.emplace(l++,o,s);for(let h=0;h8192)||i.y===r.y&&(i.y<0||i.y>8192)}nr("FillExtrusionBucket",aJ,{omit:["layers","features"]}),nr("PartMetadata",aY);var le={paint:new os({"fill-extrusion-opacity":new ot(th["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new oi(th["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new ot(th["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new ot(th["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new or(th["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new oi(th["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new oi(th["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new ot(th["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function lt(i,r){return i.x*r.x+i.y*r.y}function li(i,r){if(1===i.length){let n=0;const o=r[n++];let s;for(;!s||o.equals(s);)if(!(s=r[n++]))return 1/0;for(;ni.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new om,this.layoutVertexArray2=new o8,this.indexArray=new o0,this.programConfigurations=new sa(i.layers,i.zoom),this.segments=new sg,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=a2("line",this.layers,r);const s=this.layers[0].layout.get("line-sort-key"),a=[];for(const{feature:l,id:c,index:u,sourceLayerIndex:h}of i){const d=this.layers[0]._featureFilter.needGeometry,p=sP(l,d);if(!this.layers[0]._featureFilter.filter(new nX(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:h,index:u,geometry:d?p.geometry:sk(l,n,o),patterns:{},sortKey:f};a.push(m)}s&&a.sort((i,r)=>i.sortKey-r.sortKey);const{lineAtlas:g,featureIndex:y}=r,x=this.addConstantDashes(g);for(const $ of a){const{geometry:v,index:_,sourceLayerIndex:b}=$;if(x&&this.addFeatureDashes($,g),this.hasPattern){const w=aF("line",this.layers,$,this.zoom,r);this.patternFeatures.push(w)}else this.addFeature($,v,_,n,g.positions,r.availableImages);y.insert(i[_].feature,v,_,b,this.index)}}addConstantDashes(i){let r=!1;for(const n of this.layers){const o=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"!==o.kind||"constant"!==s.kind)r=!0;else{const a=s.value,l=o.value;if(!l)continue;i.addDash(l.from,a),i.addDash(l.to,a),l.other&&i.addDash(l.other,a)}}return r}addFeatureDashes(i,r){const n=this.zoom;for(const o of this.layers){const s=o.paint.get("line-dasharray").value,a=o.layout.get("line-cap").value;if("constant"===s.kind&&"constant"===a.kind)continue;let l,c,u,h,d,p;if("constant"===s.kind){const f=s.value;if(!f)continue;l=f.other||f.to,c=f.to,u=f.from}else l=s.evaluate({zoom:n-1},i),c=s.evaluate({zoom:n},i),u=s.evaluate({zoom:n+1},i);"constant"===a.kind?h=d=p=a.value:(h=a.evaluate({zoom:n-1},i),d=a.evaluate({zoom:n},i),p=a.evaluate({zoom:n+1},i)),r.addDash(l,h),r.addDash(c,d),r.addDash(u,p);const m=r.getKey(l,h),g=r.getKey(c,d),y=r.getKey(u,p);i.patterns[o.id]={min:m,mid:g,max:y}}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=i.createVertexBuffer(this.layoutVertexArray2,ll)),this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,ls),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(i){if(i.properties&&i.properties.hasOwnProperty("mapbox_clip_start")&&i.properties.hasOwnProperty("mapbox_clip_end"))return{start:+i.properties.mapbox_clip_start,end:+i.properties.mapbox_clip_end}}addFeature(i,r,n,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(i,{}),u=l.get("line-cap").evaluate(i,{}),h=l.get("line-miter-limit"),d=l.get("line-round-limit");for(const p of(this.lineClips=this.lineFeatureClips(i),r))this.addLine(p,i,c,u,h,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}addLine(i,r,n,o,s,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let l=0;l=2&&i[u-1].equals(i[u-2]);)u--;let h=0;for(;h0;if(E&&$>h){const I=f.dist(m);if(I>2*d){const C=f.sub(f.sub(m)._mult(d/I)._round());this.updateDistance(m,C),this.addCurrentVertex(C,y,0,0,p),m=C}}const z=m&&g;let A=z?n:c?"butt":o;if(z&&"round"===A&&(ws&&(A="bevel"),"bevel"===A&&(w>2&&(A="flipbevel"),w100)v=x.mult(-1);else{const k=w*y.add(x).mag()/y.sub(x).mag();v._perp()._mult(k*(S?-1:1))}this.addCurrentVertex(f,v,0,0,p),this.addCurrentVertex(f,v.mult(-1),0,0,p)}else if("bevel"===A||"fakeround"===A){const P=-Math.sqrt(w*w-1),D=S?P:0,L=S?0:P;if(m&&this.addCurrentVertex(f,y,D,L,p),"fakeround"===A){const B=Math.round(180*T/Math.PI/20);for(let R=1;R2*d){const j=f.add(g.sub(f)._mult(d/V)._round());this.updateDistance(f,j),this.addCurrentVertex(j,x,0,0,p),f=j}}}}addCurrentVertex(i,r,n,o,s,a=!1){const l=r.y*o-r.x,c=-r.y-r.x*o;this.addHalfVertex(i,r.x+r.y*n,r.y-r.x*n,a,!1,n,s),this.addHalfVertex(i,l,c,a,!0,-o,s)}addHalfVertex({x:i,y:r},n,o,s,a,l,c){this.layoutVertexArray.emplaceBack((i<<1)+(s?1:0),(r<<1)+(a?1:0),Math.round(63*n)+128,Math.round(63*o)+128,1+(0===l?0:l<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const u=c.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),c.primitiveLength++),a?this.e2=u:this.e1=u}updateScaledDistance(){if(this.lineClips){const i=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=i*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(i,r){this.distance+=i.dist(r),this.updateScaledDistance()}}nr("LineBucket",lh,{omit:["layers","patternFeatures"]});const ld=new os({"line-cap":new oi(th.layout_line["line-cap"]),"line-join":new oi(th.layout_line["line-join"]),"line-miter-limit":new ot(th.layout_line["line-miter-limit"]),"line-round-limit":new ot(th.layout_line["line-round-limit"]),"line-sort-key":new oi(th.layout_line["line-sort-key"])});var lp={paint:new os({"line-opacity":new oi(th.paint_line["line-opacity"]),"line-color":new oi(th.paint_line["line-color"]),"line-translate":new ot(th.paint_line["line-translate"]),"line-translate-anchor":new ot(th.paint_line["line-translate-anchor"]),"line-width":new oi(th.paint_line["line-width"]),"line-gap-width":new oi(th.paint_line["line-gap-width"]),"line-offset":new oi(th.paint_line["line-offset"]),"line-blur":new oi(th.paint_line["line-blur"]),"line-dasharray":new or(th.paint_line["line-dasharray"]),"line-pattern":new or(th.paint_line["line-pattern"]),"line-gradient":new oo(th.paint_line["line-gradient"])}),layout:ld};const lf=new class extends oi{possiblyEvaluate(i,r){return r=new nX(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(i,r)}evaluate(i,r,n,o){return r=et({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(i,r,n,o)}}(lp.paint.properties["line-width"].specification);function lm(i,r){return r>0?r+2*i:i}lf.useIntegerZoom=!0;const l8=oh([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_z_tile_anchor",components:4,type:"Int16"},],4),lg=oh([{name:"a_projected_pos",components:3,type:"Float32"},],4);oh([{name:"a_fade_opacity",components:1,type:"Uint32"},],4);const ly=oh([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},]),lx=oh([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},]);oh([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"},]);const l$=oh([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"},],4),lv=oh([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"},],4);function l_(i,r){const{expression:n}=r;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new nX(i+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:o,interpolationType:s}=n;let a=0;for(;a{i.text=function(i,r,n){const o=r.layout.get("text-transform").evaluate(n,{});return"uppercase"===o?i=i.toLocaleUpperCase():"lowercase"===o&&(i=i.toLocaleLowerCase()),n5.applyArabicShaping&&(i=n5.applyArabicShaping(i)),i}(i.text,r,n)}),i}const lE={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","\xa2":"¢","\xa3":"£","\xa5":"¥","\xa6":"¦","\xac":"¬","\xaf":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function lS(i){return"︶"===i||"﹈"===i||"︸"===i||"﹄"===i||"﹂"===i||"︾"===i||"︼"===i||"︺"===i||"︘"===i||"﹀"===i||"︐"===i||"︓"===i||"︔"===i||"`"===i||" ̄"===i||"︑"===i||"︒"===i}function lI(i){return"︵"===i||"﹇"===i||"︷"===i||"﹃"===i||"﹁"===i||"︽"===i||"︻"===i||"︹"===i||"︗"===i||"︿"===i}var lC=function(i,r,n,o,s){var a,l,c=8*s-o-1,u=(1<>1,d=-7,p=n?s-1:0,f=n?-1:1,m=i[r+p];for(p+=f,a=m&(1<<-d)-1,m>>=-d,d+=c;d>0;a=256*a+i[r+p],p+=f,d-=8);for(l=a&(1<<-d)-1,a>>=-d,d+=o;d>0;l=256*l+i[r+p],p+=f,d-=8);if(0===a)a=1-h;else{if(a===u)return l?NaN:1/0*(m?-1:1);l+=Math.pow(2,o),a-=h}return(m?-1:1)*l*Math.pow(2,a-o)},lz=function(i,r,n,o,s,a){var l,c,u,h=8*a-s-1,d=(1<>1,f=23===s?5960464477539062e-23:0,m=o?0:a-1,g=o?1:-1,y=r<0||0===r&&1/r<0?1:0;for(isNaN(r=Math.abs(r))||r===1/0?(c=isNaN(r)?1:0,l=d):(l=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-l))<1&&(l--,u*=2),(r+=l+p>=1?f/u:f*Math.pow(2,1-p))*u>=2&&(l++,u/=2),l+p>=d?(c=0,l=d):l+p>=1?(c=(r*u-1)*Math.pow(2,s),l+=p):(c=r*Math.pow(2,p-1)*Math.pow(2,s),l=0));s>=8;i[n+m]=255&c,m+=g,c/=256,s-=8);for(l=l<0;i[n+m]=255&l,m+=g,l/=256,h-=8);i[n+m-g]|=128*y},lA=lk;function lk(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}lk.Varint=0,lk.Fixed64=1,lk.Bytes=2,lk.Fixed32=5;var lP="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function lD(i){return i.type===lk.Bytes?i.readVarint()+i.pos:i.pos+1}function lL(i,r,n){var o=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));n.realloc(o);for(var s=n.pos-1;s>=i;s--)n.buf[s+o]=n.buf[s]}function l1(i,r){for(var n=0;n>>8,i[n+2]=r>>>16,i[n+3]=r>>>24}function l6(i,r){return(i[r]|i[r+1]<<8|i[r+2]<<16)+(i[r+3]<<24)}function lj(i,r,n){r.glyphs=[],1===i&&n.readMessage(lN,r)}function lN(i,r,n){if(3===i){const{id:o,bitmap:s,width:a,height:l,left:c,top:u,advance:h}=n.readMessage(lG,{});r.glyphs.push({id:o,bitmap:new ai({width:a+6,height:l+6},s),metrics:{width:a,height:l,left:c,top:u,advance:h}})}else 4===i?r.ascender=n.readSVarint():5===i&&(r.descender=n.readSVarint())}function lG(i,r,n){1===i?r.id=n.readVarint():2===i?r.bitmap=n.readBytes():3===i?r.width=n.readVarint():4===i?r.height=n.readVarint():5===i?r.left=n.readSVarint():6===i?r.top=n.readSVarint():7===i&&(r.advance=n.readVarint())}function lZ(i){let r=0,n=0;for(const o of i)r+=o.w*o.h,n=Math.max(n,o.w);i.sort((i,r)=>r.h-i.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0},];let a=0,l=0;for(const c of i)for(let u=s.length-1;u>=0;u--){const h=s[u];if(!(c.w>h.w||c.h>h.h)){if(c.x=h.x,c.y=h.y,l=Math.max(l,c.y+c.h),a=Math.max(a,c.x+c.w),c.w===h.w&&c.h===h.h){const d=s.pop();u>3,a=this.pos;this.type=7&o,i(s,r,this),this.pos===a&&this.skip(o)}return r},readMessage:function(i,r){return this.readFields(i,r,this.readVarint()+this.pos)},readFixed32:function(){var i=lU(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=l6(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=lU(this.buf,this.pos)+4294967296*lU(this.buf,this.pos+4);return this.pos+=8,i},readSFixed64:function(){var i=lU(this.buf,this.pos)+4294967296*l6(this.buf,this.pos+4);return this.pos+=8,i},readFloat:function(){var i=lC(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=lC(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var r,n,o=this.buf;return r=127&(n=o[this.pos++]),n<128?r:(r|=(127&(n=o[this.pos++]))<<7,n<128?r:(r|=(127&(n=o[this.pos++]))<<14,n<128?r:(r|=(127&(n=o[this.pos++]))<<21,n<128?r:function(i,r,n){var o,s,a,l,c=n.buf;if(a=(112&(l=c[n.pos++]))>>4,l<128||(a|=(127&(l=c[n.pos++]))<<3,l<128)||(a|=(127&(l=c[n.pos++]))<<10,l<128)||(a|=(127&(l=c[n.pos++]))<<17,l<128)||(a|=(127&(l=c[n.pos++]))<<24,l<128)||(a|=(1&(l=c[n.pos++]))<<31,l<128))return o=i,s=a,r?4294967296*s+(o>>>0):4294967296*(s>>>0)+(o>>>0);throw Error("Expected varint not more than 10 bytes")}(r|=(15&(n=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?-((i+1)/2):i/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var i,r,n,o=this.readVarint()+this.pos,s=this.pos;return this.pos=o,o-s>=12&&lP?(i=this.buf,r=s,n=o,lP.decode(i.subarray(r,n))):function(i,r,n){for(var o="",s=r;s239?4:u>223?3:u>191?2:1;if(s+d>n)break;1===d?u<128&&(h=u):2===d?128==(192&(a=i[s+1]))&&(h=(31&u)<<6|63&a)<=127&&(h=null):3===d?(l=i[s+2],128==(192&(a=i[s+1]))&&128==(192&l)&&((h=(15&u)<<12|(63&a)<<6|63&l)<=2047||h>=55296&&h<=57343)&&(h=null)):4===d&&(l=i[s+2],c=i[s+3],128==(192&(a=i[s+1]))&&128==(192&l)&&128==(192&c)&&((h=(15&u)<<18|(63&a)<<12|(63&l)<<6|63&c)<=65535||h>=1114112)&&(h=null)),null===h?(h=65533,d=1):h>65535&&(h-=65536,o+=String.fromCharCode(h>>>10&1023|55296),h=56320|1023&h),o+=String.fromCharCode(h),s+=d}return o}(this.buf,s,o)},readBytes:function(){var i=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,i);return this.pos=i,r},readPackedVarint:function(i,r){if(this.type!==lk.Bytes)return i.push(this.readVarint(r));var n=lD(this);for(i=i||[];this.pos127;);else if(r===lk.Bytes)this.pos=this.readVarint()+this.pos;else if(r===lk.Fixed32)this.pos+=4;else{if(r!==lk.Fixed64)throw Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(i,r){this.writeVarint(i<<3|r)},realloc:function(i){for(var r=this.length||16;r268435455||i<0?function(i,r){var n,o,s,a,l,c,u;if(i>=0?(n=i%4294967296|0,o=i/4294967296|0):(o=~(-i/4294967296),4294967295^(n=~(-i%4294967296))?n=n+1|0:(n=0,o=o+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");r.realloc(10),s=n,(a=r).buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,a.buf[a.pos]=127&(s>>>=7),l=o,c=r,u=(7&l)<<4,c.buf[c.pos++]|=u|((l>>>=3)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l)))))}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?-(2*i)-1:2*i)},writeBoolean:function(i){this.writeVarint(Boolean(i))},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var r=this.pos;this.pos=function(i,r,n){for(var o,s,a=0;a55295&&o<57344){if(!s){o>56319||a+1===r.length?(i[n++]=239,i[n++]=191,i[n++]=189):s=o;continue}if(o<56320){i[n++]=239,i[n++]=191,i[n++]=189,s=o;continue}o=s-55296<<10|o-56320|65536,s=null}else s&&(i[n++]=239,i[n++]=191,i[n++]=189,s=null);o<128?i[n++]=o:(o<2048?i[n++]=o>>6|192:(o<65536?i[n++]=o>>12|224:(i[n++]=o>>18|240,i[n++]=o>>12&63|128),i[n++]=o>>6&63|128),i[n++]=63&o|128)}return n}(this.buf,i,this.pos);var n=this.pos-r;n>=128&&lL(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeFloat:function(i){this.realloc(4),lz(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),lz(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var r=i.length;this.writeVarint(r),this.realloc(r);for(var n=0;n=128&&lL(n,o,this),this.pos=n-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,r,n){this.writeTag(i,lk.Bytes),this.writeRawMessage(r,n)},writePackedVarint:function(i,r){r.length&&this.writeMessage(i,l1,r)},writePackedSVarint:function(i,r){r.length&&this.writeMessage(i,lB,r)},writePackedBoolean:function(i,r){r.length&&this.writeMessage(i,lM,r)},writePackedFloat:function(i,r){r.length&&this.writeMessage(i,lR,r)},writePackedDouble:function(i,r){r.length&&this.writeMessage(i,l3,r)},writePackedFixed32:function(i,r){r.length&&this.writeMessage(i,l2,r)},writePackedSFixed32:function(i,r){r.length&&this.writeMessage(i,lF,r)},writePackedFixed64:function(i,r){r.length&&this.writeMessage(i,lO,r)},writePackedSFixed64:function(i,r){r.length&&this.writeMessage(i,l4,r)},writeBytesField:function(i,r){this.writeTag(i,lk.Bytes),this.writeBytes(r)},writeFixed32Field:function(i,r){this.writeTag(i,lk.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(i,r){this.writeTag(i,lk.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(i,r){this.writeTag(i,lk.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(i,r){this.writeTag(i,lk.Fixed64),this.writeSFixed64(r)},writeVarintField:function(i,r){this.writeTag(i,lk.Varint),this.writeVarint(r)},writeSVarintField:function(i,r){this.writeTag(i,lk.Varint),this.writeSVarint(r)},writeStringField:function(i,r){this.writeTag(i,lk.Bytes),this.writeString(r)},writeFloatField:function(i,r){this.writeTag(i,lk.Fixed32),this.writeFloat(r)},writeDoubleField:function(i,r){this.writeTag(i,lk.Fixed64),this.writeDouble(r)},writeBooleanField:function(i,r){this.writeVarintField(i,Boolean(r))}};class l9{constructor(i,{pixelRatio:r,version:n,stretchX:o,stretchY:s,content:a}){this.paddedRect=i,this.pixelRatio=r,this.stretchX=o,this.stretchY=s,this.content=a,this.version=n}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1,]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1,]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio,]}}class l7{constructor(i,r){const n={},o={};this.haveRenderCallbacks=[];const s=[];this.addImages(i,n,s),this.addImages(r,o,s);const{w:a,h:l}=lZ(s),c=new ar({width:a||1,height:l||1});for(const u in i){const h=i[u],d=n[u].paddedRect;ar.copy(h.data,c,{x:0,y:0},{x:d.x+1,y:d.y+1},h.data)}for(const p in r){const f=r[p],m=o[p].paddedRect,g=m.x+1,y=m.y+1,x=f.data.width,$=f.data.height;ar.copy(f.data,c,{x:0,y:0},{x:g,y:y},f.data),ar.copy(f.data,c,{x:0,y:$-1},{x:g,y:y-1},{width:x,height:1}),ar.copy(f.data,c,{x:0,y:0},{x:g,y:y+$},{width:x,height:1}),ar.copy(f.data,c,{x:x-1,y:0},{x:g-1,y:y},{width:1,height:$}),ar.copy(f.data,c,{x:0,y:0},{x:g+x,y:y},{width:1,height:$})}this.image=c,this.iconPositions=n,this.patternPositions=o}addImages(i,r,n){for(const o in i){const s=i[o],a={x:0,y:0,w:s.data.width+2,h:s.data.height+2};n.push(a),r[o]=new l9(a,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(i,r){for(const n in i.dispatchRenderCallbacks(this.haveRenderCallbacks),i.updatedImages)this.patchUpdatedImage(this.iconPositions[n],i.getImage(n),r),this.patchUpdatedImage(this.patternPositions[n],i.getImage(n),r)}patchUpdatedImage(i,r,n){if(!i||!r||i.version===r.version)return;i.version=r.version;const[o,s]=i.tl;n.update(r.data,void 0,{x:o,y:s})}}nr("ImagePosition",l9),nr("ImageAtlas",l7);const lq={horizontal:1,vertical:2,horizontalOnly:3};class l5{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(i,r){const n=new l5;return n.scale=i||1,n.fontStack=r,n}static forImage(i){const r=new l5;return r.imageName=i,r}}class lX{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(i,r){const n=new lX;for(let o=0;o=0&&o>=i&&lH[this.text.charCodeAt(o)];o--)n--;this.text=this.text.substring(i,n),this.sectionIndex=this.sectionIndex.slice(i,n)}substring(i,r){const n=new lX;return n.text=this.text.substring(i,r),n.sectionIndex=this.sectionIndex.slice(i,r),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((i,r)=>Math.max(i,this.sections[r].scale),0)}addTextSection(i,r){this.text+=i.text,this.sections.push(l5.forText(i.scale,i.fontStack||r));const n=this.sections.length-1;for(let o=0;o=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function lW(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y){const x=lX.fromFeature(i,s);let $;p===lq.vertical&&x.verticalizePunctuation(f);const{processBidirectionalText:v,processStyledBidirectionalText:_}=n5;if(v&&1===x.sections.length){$=[];const b=v(x.toString(),ct(x,h,a,r,o,m,g));for(const w of b){const T=new lX;T.text=w,T.sections=x.sections;for(let E=0;E0&&q>A&&(A=q)}else{const X=n[L.fontStack];if(!X)continue;X[R]&&(O=X[R]);const W=r[L.fontStack];if(!W)continue;const H=W.glyphs[R];if(!H)continue;if(F=H.metrics,V=8203!==R?24:0,$){const K=void 0!==W.ascender?Math.abs(W.ascender):0,Y=void 0!==W.descender?Math.abs(W.descender):0,J=(K+Y)*M;k=0;let p=0;for(let f=0;f-n/2;){if(--l<0)return!1;c-=i[l].dist(a),a=i[l]}c+=i[l].dist(i[l+1]),l++;const u=[];let h=0;for(;co;)h-=u.shift().angleDelta;if(h>s)return!1;l++,c+=d.dist(p)}return!0}function cl(i){let r=0;for(let n=0;nh){const g=(h-u)/m,y=i$(p.x,f.x,g),x=i$(p.y,f.y,g),$=new cs(y,x,0,f.angleTo(p),d);return!l||ca(i,$,c,l,r)?$:void 0}u+=m}}function cd(i,r,n,o,s,a,l,c,u){const h=cc(o,a,l),d=cu(o,s),p=d*l,f=0===i[0].x||i[0].x===u||0===i[0].y||i[0].y===u;return r-p=0&&b=0&&w=0&&f+h<=d){const T=new cs(b,w,0,v,g);T._round(),o&&!ca(i,T,a,o,s)||m.push(T)}}p+=$}return c||m.length||l||(m=cp(i,p/2,n,o,s,a,l,!0,u)),m}function cf(i,r,n,o,s){const a=[];for(let c=0;c=o&&f.x>=o||(p.x>=o?p=new l(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round():f.x>=o&&(f=new l(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round()),p.y>=s&&f.y>=s||(p.y>=s?p=new l(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round():f.y>=s&&(f=new l(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round()),h&&p.equals(h[h.length-1])||(h=[p],a.push(h)),h.push(f)))))}}return a}function cm(i,r,n,o,s,a,l,c,u){for(let h=r;h-1)a[++u]=c,l[u]=h,l[u+1]=1e20}for(let f=0,m=0;f{let o=this.entries[i];o||(o=this.entries[i]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=o.glyphs[r];if(void 0!==s)return void n(null,{stack:i,id:r,glyph:s});if(s=this._tinySDF(o,i,r))return o.glyphs[r]=s,void n(null,{stack:i,id:r,glyph:s});const a=Math.floor(r/256);if(256*a>65535)return void n(Error("glyphs > 65535 not supported"));if(o.ranges[a])return void n(null,{stack:i,id:r,glyph:s});let l=o.requests[a];l||(l=o.requests[a]=[],cy.loadGlyphRange(i,a,this.url,this.requestManager,(i,r)=>{if(r){for(const n in o.ascender=r.ascender,o.descender=r.descender,r.glyphs)this._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=r.glyphs[+n]);o.ranges[a]=!0}for(const s of l)s(i,r);delete o.requests[a]})),l.push((o,s)=>{o?n(o):s&&n(null,{stack:i,id:r,glyph:s.glyphs[r]||null})})},(i,n)=>{if(i)r(i);else if(n){const o={};for(const{stack:s,id:a,glyph:l}of n)void 0===o[s]&&(o[s]={}),void 0===o[s].glyphs&&(o[s].glyphs={}),o[s].glyphs[a]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics},o[s].ascender=this.entries[s].ascender,o[s].descender=this.entries[s].descender;r(null,o)}})}_doesCharSupportLocalGlyph(i){return this.localGlyphMode!==cg.none&&(this.localGlyphMode===cg.all?!!this.localFontFamily:!!this.localFontFamily&&(nT(i)||nI(i)||ng(i)||ny(i))||n8(i))}_tinySDF(i,r,n){const o=this.localFontFamily;if(!o||!this._doesCharSupportLocalGlyph(n))return;let s=i.tinySDF;if(!s){let a="400";/bold/i.test(r)?a="900":/medium/i.test(r)?a="500":/light/i.test(r)&&(a="200"),(s=i.tinySDF=new cy.TinySDF({fontFamily:o,fontWeight:a,fontSize:48,buffer:6,radius:16})).fontWeight=a}if(this.localGlyphs[s.fontWeight][n])return this.localGlyphs[s.fontWeight][n];const l=String.fromCharCode(n),{data:c,width:u,height:h,glyphWidth:d,glyphHeight:p,glyphLeft:f,glyphTop:m,glyphAdvance:g}=s.draw(l);return this.localGlyphs[s.fontWeight][n]={id:n,bitmap:new ai({width:u,height:h},c),metrics:{width:d/2,height:p/2,left:f/2,top:m/2-27,advance:g/2,localGlyph:!0}}}}function cx(i,r,n,o){const s=[],a=i.image,c=a.pixelRatio,u=a.paddedRect.w-2,h=a.paddedRect.h-2,d=i.right-i.left,p=i.bottom-i.top,f=a.stretchX||[[0,u]],m=a.stretchY||[[0,h]],g=(i,r)=>i+r[1]-r[0],y=f.reduce(g,0),x=m.reduce(g,0),$=u-y,v=h-x;let _=0,b=y,w=0,T=x,E=0,S=$,I=0,C=v;if(a.content&&o){const z=a.content;_=c$(f,0,z[0]),w=c$(m,0,z[1]),b=c$(f,z[0],z[2]),T=c$(m,z[1],z[3]),E=z[0]-_,I=z[1]-w,S=z[2]-z[0]-b,C=z[3]-z[1]-T}const A=(o,s,u,h)=>{var f,m,g,$,v,z,A,k,P,D,L,B,R,M,F,O,U,V,j,N,G,Z,q,X,W,H,K,Y;const J=(f=o.stretch-_,m=b,g=d,f/m*g+i.left),Q=($=o.fixed-E,v=S,z=o.stretch,A=y,$-v*z/A),ee=(k=s.stretch-w,P=T,D=p,k/P*D+i.top),et=(L=s.fixed-I,B=C,R=s.stretch,M=x,L-B*R/M),ei=(F=u.stretch-_,O=b,U=d,F/O*U+i.left),er=(V=u.fixed-E,j=S,N=u.stretch,G=y,V-j*N/G),en=(Z=h.stretch-w,q=T,X=p,Z/q*X+i.top),eo=(W=h.fixed-I,H=C,K=h.stretch,Y=x,W-H*K/Y),es=new l(J,ee),ea=new l(ei,ee),el=new l(ei,en),ec=new l(J,en),eu=new l(Q/c,et/c),eh=new l(er/c,eo/c),ed=r*Math.PI/180;if(ed){const ep=Math.sin(ed),ef=Math.cos(ed),em=[ef,-ep,ep,ef];es._matMult(em),ea._matMult(em),ec._matMult(em),el._matMult(em)}const e8=o.stretch+o.fixed,eg=s.stretch+s.fixed;return{tl:es,tr:ea,bl:ec,br:el,tex:{x:a.paddedRect.x+1+e8,y:a.paddedRect.y+1+eg,w:u.stretch+u.fixed-e8,h:h.stretch+h.fixed-eg},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:eu,pixelOffsetBR:eh,minFontScaleX:S/c/d,minFontScaleY:C/c/p,isSDF:n}};if(o&&(a.stretchX||a.stretchY)){const k=cv(f,$,y),P=cv(m,v,x);for(let D=0;D{if(i)s(i);else if(r){var n;const o={},a=(n=r,new lA(n).readFields(lj,{}));for(const l of a.glyphs)o[l.id]=l;s(null,{glyphs:o,ascender:a.ascender,descender:a.descender})}})},cy.TinySDF=class{constructor({fontSize:i=24,buffer:r=3,radius:n=8,cutoff:o=.25,fontFamily:s="sans-serif",fontWeight:a="normal",fontStyle:l="normal"}){this.buffer=r,this.cutoff=o,this.radius=n;const c=this.size=i+4*r,u=this._createCanvas(c),h=this.ctx=u.getContext("2d",{willReadFrequently:!0});h.font=`${l} ${a} ${i}px ${s}`,h.textBaseline="alphabetic",h.textAlign="left",h.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(i){const r=document.createElement("canvas");return r.width=r.height=i,r}draw(i){const{width:r,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:s,actualBoundingBoxRight:a}=this.ctx.measureText(i),l=Math.floor(n),c=Math.min(this.size-this.buffer,Math.ceil(a-s)),u=Math.min(this.size-this.buffer,Math.ceil(n)+Math.ceil(o)),h=c+2*this.buffer,d=u+2*this.buffer,p=h*d,f=new Uint8ClampedArray(p),m={data:f,width:h,height:d,glyphWidth:c,glyphHeight:u,glyphTop:l,glyphLeft:0,glyphAdvance:r};if(0===c||0===u)return m;const{ctx:g,buffer:y,gridInner:x,gridOuter:$}=this;g.clearRect(y,y,c,u),g.fillText(i,y,y+l+1);const v=g.getImageData(y,y,c,u);$.fill(1e20,0,p),x.fill(0,0,p);for(let _=0;_0?E*E:0,x[T]=E<0?E*E:0}}cm($,0,0,h,d,h,this.f,this.v,this.z),cm(x,y,y,c,u,h,this.f,this.v,this.z);for(let S=0;Sr?1:0}){if(this.data=i,this.length=this.data.length,this.compare=r,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const i=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:r,compare:n}=this,o=r[i];for(;i>0;){const s=i-1>>1,a=r[s];if(n(o,a)>=0)break;r[i]=a,i=s}r[i]=o}_down(i){const{data:r,compare:n}=this,o=this.length>>1,s=r[i];for(;in(r[c],l)&&(a=c,l=r[c]),n(l,s)>=0)break;r[i]=l,i=a}r[i]=s}}function cw(i,r=1,n=!1){let o=1/0,s=1/0,a=-1/0,c=-1/0;const u=i[0];for(let h=0;ha)&&(a=d.x),(!h||d.y>c)&&(c=d.y)}const p=Math.min(a-o,c-s);let f=p/2;const m=new cb([],c0);if(0===p)return new l(o,s);for(let g=o;gx.d||!x.d)&&(x=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,$)),v.max-x.d<=r||(f=v.h/2,m.push(new cT(v.p.x-f,v.p.y-f,f,i)),m.push(new cT(v.p.x+f,v.p.y-f,f,i)),m.push(new cT(v.p.x-f,v.p.y+f,f,i)),m.push(new cT(v.p.x+f,v.p.y+f,f,i)),$+=4)}return n&&(console.log(`num probes: ${$}`),console.log(`best distance: ${x.d}`)),x.p}function c0(i,r){return r.max-i.max}function cT(i,r,n,o){this.p=new l(i,r),this.h=n,this.d=function(i,r){let n=!1,o=1/0;for(let s=0;si.y!=d.y>i.y&&i.x<(d.x-h.x)*(i.y-h.y)/(d.y-h.y)+h.x&&(n=!n),o=Math.min(o,sO(i,h,d))}}return(n?1:-1)*Math.sqrt(o)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}const cE=Number.POSITIVE_INFINITY,cS=Math.sqrt(2);function cI(i,r){return r[1]!==cE?function(i,r,n){let o=0,s=0;switch(r=Math.abs(r),n=Math.abs(n),i){case"top-right":case"top-left":case"top":s=n-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-n}switch(i){case"top-right":case"bottom-right":case"right":o=-r;break;case"top-left":case"bottom-left":case"left":o=r}return[o,s]}(i,r[0],r[1]):function(i,r){let n=0,o=0;r<0&&(r=0);const s=r/cS;switch(i){case"top-right":case"top-left":o=s-7;break;case"bottom-right":case"bottom-left":o=7-s;break;case"bottom":o=7-r;break;case"top":o=r-7}switch(i){case"top-right":case"bottom-right":n=-s;break;case"top-left":case"bottom-left":n=s;break;case"left":n=r;break;case"right":n=-r}return[n,o]}(i,r[0])}function cC(i,r,n,o,s,a,l,c,u,h){i.createArrays(),i.tilePixelRatio=8192/(512*i.overscaling),i.compareText={},i.iconsNeedLinear=!1;const d=i.layers[0].layout,p=i.layers[0]._unevaluatedLayout._values,f={};if("composite"===i.textSizeData.kind){const{minZoom:m,maxZoom:g}=i.textSizeData;f.compositeTextSizes=[p["text-size"].possiblyEvaluate(new nX(m),c),p["text-size"].possiblyEvaluate(new nX(g),c),]}if("composite"===i.iconSizeData.kind){const{minZoom:y,maxZoom:x}=i.iconSizeData;f.compositeIconSizes=[p["icon-size"].possiblyEvaluate(new nX(y),c),p["icon-size"].possiblyEvaluate(new nX(x),c),]}f.layoutTextSize=p["text-size"].possiblyEvaluate(new nX(u+1),c),f.layoutIconSize=p["icon-size"].possiblyEvaluate(new nX(u+1),c),f.textMaxSize=p["text-size"].possiblyEvaluate(new nX(18),c);const $="map"===d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),v=d.get("text-size");for(const _ of i.features){const b=d.get("text-font").evaluate(_,{},c).join(","),w=v.evaluate(_,{},c),T=f.layoutTextSize.evaluate(_,{},c),E=(f.layoutIconSize.evaluate(_,{},c),{horizontal:{},vertical:void 0}),S=_.text;let I,C=[0,0];if(S){const z=S.toString(),A=24*d.get("text-letter-spacing").evaluate(_,{},c),k=24*d.get("text-line-height").evaluate(_,{},c),P=nB(z)?A:0,D=d.get("text-anchor").evaluate(_,{},c),L=d.get("text-variable-anchor");if(!L){const B=d.get("text-radial-offset").evaluate(_,{},c);C=B?cI(D,[24*B,cE]):d.get("text-offset").evaluate(_,{},c).map(i=>24*i)}let R=$?"center":d.get("text-justify").evaluate(_,{},c);const M=d.get("symbol-placement"),F="point"===M,O="point"===M?24*d.get("text-max-width").evaluate(_,{},c):0,U=o=>{i.allowVerticalPlacement&&n1(z)&&(E.vertical=lW(S,r,n,s,b,O,k,D,o,P,C,lq.vertical,!0,M,T,w))};if(!$&&L){const V="auto"===R?L.map(i=>cz(i)):[R];let j=!1;for(let N=0;N=0||!n1(z)){const q=lW(S,r,n,s,b,O,k,D,R,P,C,lq.horizontal,!1,M,T,w);q&&(E.horizontal[R]=q)}U("point"===M?"left":R)}}let X=!1;if(_.icon&&_.icon.name){const W=o[_.icon.name];W&&(I=cn(s[_.icon.name],d.get("icon-offset").evaluate(_,{},c),d.get("icon-anchor").evaluate(_,{},c)),X=W.sdf,void 0===i.sdfIcons?i.sdfIcons=W.sdf:i.sdfIcons!==W.sdf&&ep("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(W.pixelRatio!==i.pixelRatio||0!==d.get("icon-rotate").constantOr(1))&&(i.iconsNeedLinear=!0))}const H=cD(E.horizontal)||E.vertical;i.iconsInText||(i.iconsInText=!!H&&H.iconsInText),(H||I)&&cA(i,_,E,I,o,f,T,0,C,X,l,c,h)}a&&i.generateCollisionDebugBuffers(u,i.collisionBoxArray)}function cz(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 cA(i,r,n,o,s,a,l,c,u,h,d,p,f){let m=a.textMaxSize.evaluate(r,{},p);void 0===m&&(m=l);const g=i.layers[0].layout,y=g.get("icon-offset").evaluate(r,{},p),x=cD(n.horizontal)||n.vertical,$=l/24,v=i.tilePixelRatio*m/24,_=i.tilePixelRatio*g.get("symbol-spacing"),b=g.get("text-padding")*i.tilePixelRatio,w=g.get("icon-padding")*i.tilePixelRatio,T=g.get("text-max-angle")*j,E="map"===g.get("text-rotation-alignment")&&"point"!==g.get("symbol-placement"),S="map"===g.get("icon-rotation-alignment")&&"point"!==g.get("symbol-placement"),I=g.get("symbol-placement"),C=_/2,z=g.get("icon-text-fit");let A;o&&"none"!==z&&(i.allowVerticalPlacement&&n.vertical&&(A=co(o,n.vertical,z,g.get("icon-text-fit-padding"),y,$)),x&&(o=co(o,x,z,g.get("icon-text-fit-padding"),y,$)));const k=(l,c,m)=>{if(c.x<0||c.x>=8192||c.y<0||c.y>=8192)return;const{x:g,y:x,z:$}=f.projectTilePoint(c.x,c.y,m),v=new cs(g,x,$,0,void 0);!function(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$,v,_,b,w,T,E,S){const I=i.addToLineVertexArray(r,o);let C,z,A,k,P,D,L,B=0,R=0,M=0,F=0,O=-1,U=-1;const V={};let j=oZ(""),N=0,G=0;if(void 0===u._unevaluatedLayout.getValue("text-radial-offset")?[N,G]=u.layout.get("text-offset").evaluate(b,{},S).map(i=>24*i):(N=24*u.layout.get("text-radial-offset").evaluate(b,{},S),G=cE),i.allowVerticalPlacement&&s.vertical){const Z=s.vertical;if(g)D=c1(Z),c&&(L=c1(c));else{const q=u.layout.get("text-rotate").evaluate(b,{},S)+90;A=cL(h,n,r,d,p,f,Z,m,q,y),c&&(k=cL(h,n,r,d,p,f,c,$,q))}}if(a){const X=u.layout.get("icon-rotate").evaluate(b,{},S),W="none"!==u.layout.get("icon-text-fit"),H=cx(a,X,T,W),K=c?cx(c,X,T,W):void 0;z=cL(h,n,r,d,p,f,a,$,X),B=4*H.length;const Y=i.iconSizeData;let J=null;"source"===Y.kind?(J=[128*u.layout.get("icon-size").evaluate(b,{},S),])[0]>ck&&ep(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Y.kind&&((J=[128*w.compositeIconSizes[0].evaluate(b,{},S),128*w.compositeIconSizes[1].evaluate(b,{},S),])[0]>ck||J[1]>ck)&&ep(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),i.addSymbols(i.icon,H,J,_,v,b,!1,n,r,I.lineStartIndex,I.lineLength,-1,E,S),O=i.icon.placedSymbolArray.length-1,K&&(R=4*K.length,i.addSymbols(i.icon,K,J,_,v,b,lq.vertical,n,r,I.lineStartIndex,I.lineLength,-1,E,S),U=i.icon.placedSymbolArray.length-1)}for(const Q in s.horizontal){const ee=s.horizontal[Q];C||(j=oZ(ee.text),g?P=c1(ee):C=cL(h,n,r,d,p,f,ee,m,u.layout.get("text-rotate").evaluate(b,{},S),y));const et=1===ee.positionedLines.length;if(M+=cP(i,n,r,ee,l,u,g,b,y,I,s.vertical?lq.horizontal:lq.horizontalOnly,et?Object.keys(s.horizontal):[Q],V,O,w,E,S),et)break}s.vertical&&(F+=cP(i,n,r,s.vertical,l,u,g,b,y,I,lq.vertical,["vertical"],V,U,w,E,S));let ei=-1;const er=(i,r)=>i?Math.max(i,r):r;ei=er(P,ei),ei=er(D,ei),ei=er(L,ei);const en=ei>-1?1:0;i.glyphOffsetArray.length>=cU.MAX_GLYPHS&&ep("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&i.addToSortKeyRanges(i.symbolInstances.length,b.sortKey),i.symbolInstances.emplaceBack(n.x,n.y,n.z,r.x,r.y,V.right>=0?V.right:-1,V.center>=0?V.center:-1,V.left>=0?V.left:-1,V.vertical>=0?V.vertical:-1,O,U,j,void 0!==C?C:i.collisionBoxArray.length,void 0!==C?C+1:i.collisionBoxArray.length,void 0!==A?A:i.collisionBoxArray.length,void 0!==A?A+1:i.collisionBoxArray.length,void 0!==z?z:i.collisionBoxArray.length,void 0!==z?z+1:i.collisionBoxArray.length,k||i.collisionBoxArray.length,k?k+1:i.collisionBoxArray.length,d,M,F,B,R,en,0,N,G,ei)}(i,c,v,l,n,o,s,A,i.layers[0],i.collisionBoxArray,r.index,r.sourceLayerIndex,i.index,b,E,u,0,w,S,y,r,a,h,d,p)};if("line"===I)for(const P of cf(r.geometry,0,0,8192,8192)){const D=cd(P,_,T,n.vertical||x,o,24,v,i.overscaling,8192);for(const L of D){const B=x;B&&cB(i,B.text,C,L)||k(P,L,p)}}else if("line-center"===I){for(const R of r.geometry)if(R.length>1){const M=ch(R,T,n.vertical||x,o,24,v);M&&k(R,M,p)}}else if("Polygon"===r.type)for(const F of a3(r.geometry,0)){const O=cw(F,16);k(F[0],new cs(O.x,O.y,0,0,void 0),p)}else if("LineString"===r.type)for(const U of r.geometry)k(U,new cs(U[0].x,U[0].y,0,0,void 0),p);else if("Point"===r.type)for(const V of r.geometry)for(const N of V)k([N],new cs(N.x,N.y,0,0,void 0),p)}const ck=32640;function cP(i,r,n,o,s,a,c,u,h,d,p,f,m,g,y,x,$){const v=function(i,r,n,o,s,a,c,u){const h=[];if(0===r.positionedLines.length)return h;const d=o.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,p=function(i){const r=i[0],n=i[1],o=r*n;return o>0?[r,-n]:o<0?[-r,n]:0===r?[n,r]:[n,-r]}(n);let f=Math.abs(r.top-r.bottom);for(const m of r.positionedLines)f-=m.lineOffset;const g=r.positionedLines.length,y=f/g;let x=r.top-n[1];for(let $=0;$ck&&ep(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===_.kind&&((b=[128*y.compositeTextSizes[0].evaluate(u,{},$),128*y.compositeTextSizes[1].evaluate(u,{},$),])[0]>ck||b[1]>ck)&&ep(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),i.addSymbols(i.text,v,b,h,c,u,p,r,n,d.lineStartIndex,d.lineLength,g,x,$),f))m[w]=i.text.placedSymbolArray.length-1;return 4*v.length}function cD(i){for(const r in i)return i[r];return null}function cL(i,r,n,o,s,a,c,u,h,d){let p=c.top,f=c.bottom,m=c.left,g=c.right;const y=c.collisionPadding;if(y&&(m-=y[0],p-=y[1],g+=y[2],f+=y[3]),h){const x=new l(m,p),$=new l(g,p),v=new l(m,f),_=new l(g,f),b=h*j;let w=new l(0,0);d&&(w=new l(d[0],d[1])),x._rotateAround(b,w),$._rotateAround(b,w),v._rotateAround(b,w),_._rotateAround(b,w),m=Math.min(x.x,$.x,v.x,_.x),g=Math.max(x.x,$.x,v.x,_.x),p=Math.min(x.y,$.y,v.y,_.y),f=Math.max(x.y,$.y,v.y,_.y)}return i.emplaceBack(r.x,r.y,r.z,n.x,n.y,m,p,g,f,u,o,s,a),i.length-1}function c1(i){i.collisionPadding&&(i.top-=i.collisionPadding[1],i.bottom+=i.collisionPadding[3]);const r=i.bottom-i.top;return r>0?Math.max(10,r):null}function cB(i,r,n,o){const s=i.compareText;if(r in s){const a=s[r];for(let l=a.length-1;l>=0;l--)if(o.dist(a[l])i.id),this.index=i.index,this.pixelRatio=i.pixelRatio,this.sourceLayerIndex=i.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=p([]),this.placementViewportMatrix=p([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=l_(this.zoom,r["text-size"]),this.iconSizeData=l_(this.zoom,r["icon-size"]);const n=this.layers[0].layout,o=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&void 0!==o.constantOr(1),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(i=>lq[i]),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.sourceID=i.sourceID}createArrays(){this.text=new cO(new sa(this.layers,this.zoom,i=>/^text/.test(i))),this.icon=new cO(new sa(this.layers,this.zoom,i=>/^icon/.test(i))),this.glyphOffsetArray=new o2,this.lineVertexArray=new oF,this.symbolInstances=new oM}calculateGlyphDependencies(i,r,n,o,s){for(let a=0;a0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,p=a.get("symbol-sort-key");if(this.features=[],!h&&!d)return;const f=r.iconDependencies,m=r.glyphDependencies,g=r.availableImages,y=new nX(this.zoom);for(const{feature:x,id:$,index:v,sourceLayerIndex:_}of i){const b=s._featureFilter.needGeometry,w=sP(x,b);if(!s._featureFilter.filter(y,w,n))continue;let T,E;if(b||(w.geometry=sk(x,n,o)),h){const S=s.getValueAndResolveTokens("text-field",w,n,g),I=t3.factory(S);cF(I)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===n7()||this.hasRTLText&&n5.isParsed())&&(T=lT(I,s,w))}if(d){const C=s.getValueAndResolveTokens("icon-image",w,n,g);E=C instanceof tM?C:tM.fromString(C)}if(!T&&!E)continue;const z=this.sortFeaturesByKey?p.evaluate(w,{},n):void 0;if(this.features.push({id:$,text:T,icon:E,index:v,sourceLayerIndex:_,geometry:w.geometry,properties:x.properties,type:cR[x.type],sortKey:z}),E&&(f[E.name]=!0),T){const A=l.evaluate(w,{},n).join(","),k="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");for(const P of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(lq.vertical)>=0,T.sections))if(P.image)f[P.image.name]=!0;else{const D=n1(T.toString()),L=P.fontStack||A,B=m[L]=m[L]||{};this.calculateGlyphDependencies(P.text,B,k,this.allowVerticalPlacement,D)}}}"line"===a.get("symbol-placement")&&(this.features=function(i){const r={},n={},o=[];let s=0;function a(r){o.push(i[r]),s++}function l(i,r,s){const a=n[i];return delete n[i],n[r]=a,o[a].geometry[0].pop(),o[a].geometry[0]=o[a].geometry[0].concat(s[0]),a}function c(i,n,s){const a=r[n];return delete r[n],r[i]=a,o[a].geometry[0].shift(),o[a].geometry[0]=s[0].concat(o[a].geometry[0]),a}function u(i,r,n){const o=n?r[0][r[0].length-1]:r[0][0];return`${i}:${o.x}:${o.y}`}for(let h=0;hi.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((i,r)=>i.sortKey-r.sortKey)}update(i,r,n,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(i,r,this.layers,n,o),this.icon.programConfigurations.updatePaintArrays(i,r,this.layers,n,o))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(i),this.iconCollisionBox.upload(i)),this.text.upload(i,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(i,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(i,r){const n=this.lineVertexArray.length;if(void 0!==i.segment){let o=i.dist(r[i.segment+1]),s=i.dist(r[i.segment]);const a={};for(let l=i.segment+1;l=0;c--)a[c]={x:r[c].x,y:r[c].y,tileUnitDistanceFromAnchor:s},c>0&&(s+=r[c-1].dist(r[c]));for(let u=0;u=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:o),a=lb(this.textSizeData,i,s)/24;return this.tilePixelRatio*a}getSymbolInstanceIconSize(i,r,n){const o=this.icon.placedSymbolArray.get(n),s=lb(this.iconSizeData,i,o);return this.tilePixelRatio*s}_commitDebugCollisionVertexUpdate(i,r,n){i.emplaceBack(r,-n,-n),i.emplaceBack(r,n,-n),i.emplaceBack(r,n,n),i.emplaceBack(r,-n,n)}_updateTextDebugCollisionBoxes(i,r,n,o,s,a){for(let l=o;l0}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(i,r){const n=i.placedSymbolArray.get(r),o=n.vertexStartIndex+4*n.numGlyphs;for(let s=n.vertexStartIndex;so[i]-o[r]||s[r]-s[i]),a}addToSortKeyRanges(i,r){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===r?n.symbolInstanceEnd=i+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:i+1})}sortFeatures(i){if(this.sortFeaturesByY&&this.sortedAngle!==i&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const r of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(i),this.sortedAngle=i,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const n=this.symbolInstances.get(r);this.featureSortOrder.push(n.featureIndex),[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex,].forEach((i,r,n)=>{i>=0&&n.indexOf(i)===r&&this.addIndicesForPlacedSymbol(this.text,i)}),n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}nr("SymbolBucket",cU,{omit:["layers","collisionBoxArray","features","compareText",]}),cU.MAX_GLYPHS=65535,cU.addDynamicAttributes=c2;const cV=new os({"symbol-placement":new ot(th.layout_symbol["symbol-placement"]),"symbol-spacing":new ot(th.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new ot(th.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new oi(th.layout_symbol["symbol-sort-key"]),"symbol-z-order":new ot(th.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new ot(th.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new ot(th.layout_symbol["icon-ignore-placement"]),"icon-optional":new ot(th.layout_symbol["icon-optional"]),"icon-rotation-alignment":new ot(th.layout_symbol["icon-rotation-alignment"]),"icon-size":new oi(th.layout_symbol["icon-size"]),"icon-text-fit":new ot(th.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ot(th.layout_symbol["icon-text-fit-padding"]),"icon-image":new oi(th.layout_symbol["icon-image"]),"icon-rotate":new oi(th.layout_symbol["icon-rotate"]),"icon-padding":new ot(th.layout_symbol["icon-padding"]),"icon-keep-upright":new ot(th.layout_symbol["icon-keep-upright"]),"icon-offset":new oi(th.layout_symbol["icon-offset"]),"icon-anchor":new oi(th.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new ot(th.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new ot(th.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new ot(th.layout_symbol["text-rotation-alignment"]),"text-field":new oi(th.layout_symbol["text-field"]),"text-font":new oi(th.layout_symbol["text-font"]),"text-size":new oi(th.layout_symbol["text-size"]),"text-max-width":new oi(th.layout_symbol["text-max-width"]),"text-line-height":new oi(th.layout_symbol["text-line-height"]),"text-letter-spacing":new oi(th.layout_symbol["text-letter-spacing"]),"text-justify":new oi(th.layout_symbol["text-justify"]),"text-radial-offset":new oi(th.layout_symbol["text-radial-offset"]),"text-variable-anchor":new ot(th.layout_symbol["text-variable-anchor"]),"text-anchor":new oi(th.layout_symbol["text-anchor"]),"text-max-angle":new ot(th.layout_symbol["text-max-angle"]),"text-writing-mode":new ot(th.layout_symbol["text-writing-mode"]),"text-rotate":new oi(th.layout_symbol["text-rotate"]),"text-padding":new ot(th.layout_symbol["text-padding"]),"text-keep-upright":new ot(th.layout_symbol["text-keep-upright"]),"text-transform":new oi(th.layout_symbol["text-transform"]),"text-offset":new oi(th.layout_symbol["text-offset"]),"text-allow-overlap":new ot(th.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new ot(th.layout_symbol["text-ignore-placement"]),"text-optional":new ot(th.layout_symbol["text-optional"])});var c6={paint:new os({"icon-opacity":new oi(th.paint_symbol["icon-opacity"]),"icon-color":new oi(th.paint_symbol["icon-color"]),"icon-halo-color":new oi(th.paint_symbol["icon-halo-color"]),"icon-halo-width":new oi(th.paint_symbol["icon-halo-width"]),"icon-halo-blur":new oi(th.paint_symbol["icon-halo-blur"]),"icon-translate":new ot(th.paint_symbol["icon-translate"]),"icon-translate-anchor":new ot(th.paint_symbol["icon-translate-anchor"]),"text-opacity":new oi(th.paint_symbol["text-opacity"]),"text-color":new oi(th.paint_symbol["text-color"],{runtimeType:tb,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new oi(th.paint_symbol["text-halo-color"]),"text-halo-width":new oi(th.paint_symbol["text-halo-width"]),"text-halo-blur":new oi(th.paint_symbol["text-halo-blur"]),"text-translate":new ot(th.paint_symbol["text-translate"]),"text-translate-anchor":new ot(th.paint_symbol["text-translate-anchor"])}),layout:cV};class cj{constructor(i){this.type=i.property.overrides?i.property.overrides.runtimeType:tx,this.defaultValue=i}evaluate(i){if(i.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(i.formattedSection))return r.getOverride(i.formattedSection)}return i.feature&&i.featureState?this.defaultValue.evaluate(i.feature,i.featureState):this.defaultValue.property.specification.default}eachChild(i){this.defaultValue.isConstant()||i(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}nr("FormatSectionOverride",cj,{omit:["defaultValue"]});class cN extends sf{constructor(i){super(i,c6)}recalculate(i,r){super.recalculate(i,r),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const n=this.layout.get("text-writing-mode");if(n){const o=[];for(const s of n)0>o.indexOf(s)&&o.push(s);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(i,r,n,o){var s;const a=this.layout.get(i).evaluate(r,{},n,o),l=this._unevaluatedLayout._values[i];return l.isDataDriven()||rh(l.value)||!a?a:(s=r.properties,a.replace(/{([^{}]+)}/g,(i,r)=>r in s?String(s[r]):""))}createBucket(i){return new cU(i)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const i of c6.paint.overridableProperties){if(!cN.hasPaintOverride(this.layout,i))continue;const r=this.paint.get(i),n=new cj(r),o=new ru(n,r.property.specification);let s=null;s="constant"===r.value.kind||"source"===r.value.kind?new rp("source",o):new rf("composite",o,r.value.zoomStops,r.value._interpolationType),this.paint._values[i]=new nQ(r.property,s,r.parameters)}}_handleOverridablePaintPropertyUpdate(i,r,n){return!(!this.layout||r.isDataDriven()||n.isDataDriven())&&cN.hasPaintOverride(this.layout,i)}static hasPaintOverride(i,r){const n=i.get("text-field"),o=c6.paint.properties[r];let s=!1;const a=i=>{for(const r of i)if(o.overrides&&o.overrides.hasOverride(r))return void(s=!0)};if("constant"===n.value.kind&&n.value.value instanceof t3)a(n.value.value.sections);else if("source"===n.value.kind){const l=i=>{s||(i instanceof tU&&tO(i.value)===tE?a(i.value.sections):i instanceof tN?a(i.sections):i.eachChild(l))},c=n.value;c._styleExpression&&l(c._styleExpression.expression)}return s}getProgramConfiguration(i){return new ss(this,i)}}var cG={paint:new os({"background-color":new ot(th.paint_background["background-color"]),"background-pattern":new on(th.paint_background["background-pattern"]),"background-opacity":new ot(th.paint_background["background-opacity"])})},cZ={paint:new os({"raster-opacity":new ot(th.paint_raster["raster-opacity"]),"raster-hue-rotate":new ot(th.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new ot(th.paint_raster["raster-brightness-min"]),"raster-brightness-max":new ot(th.paint_raster["raster-brightness-max"]),"raster-saturation":new ot(th.paint_raster["raster-saturation"]),"raster-contrast":new ot(th.paint_raster["raster-contrast"]),"raster-resampling":new ot(th.paint_raster["raster-resampling"]),"raster-fade-duration":new ot(th.paint_raster["raster-fade-duration"])})};class c9 extends sf{constructor(i){super(i,{}),this.implementation=i}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(i){this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)}onRemove(i){this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)}}var c7={paint:new os({"sky-type":new ot(th.paint_sky["sky-type"]),"sky-atmosphere-sun":new ot(th.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new ot(th.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new ot(th.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new ot(th.paint_sky["sky-gradient-radius"]),"sky-gradient":new oo(th.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new ot(th.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new ot(th.paint_sky["sky-atmosphere-color"]),"sky-opacity":new ot(th.paint_sky["sky-opacity"])})};function cq(i,r,n){var o,s,a,l,c,u,h,d,p;const f=w(0,0,1),m=O(F());return o=m,s=m,a=n?-(i*j)+Math.PI:i*j,a*=.5,l=s[0],c=s[1],u=s[2],h=s[3],d=Math.sin(a),p=Math.cos(a),o[0]=l*p-u*d,o[1]=c*p+h*d,o[2]=u*p+l*d,o[3]=h*p-c*d,U(m,m,-(r*j)),L(f,f,m),A(f,f)}const c5={circle:class extends sf{constructor(i){super(i,s7)}createBucket(i){return new sL(i)}queryRadius(i){const r=i;return sj("circle-radius",this,r)+sj("circle-stroke-width",this,r)+sN(this.paint.get("circle-translate"))}queryIntersectsFeature(i,r,n,o,s,a,l,c){const u=sZ(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),h=this.paint.get("circle-radius").evaluate(r,n)+this.paint.get("circle-stroke-width").evaluate(r,n);return sX(i,o,a,l,c,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),u,h)}getProgramIds(){return["circle"]}getProgramConfiguration(i){return new ss(this,i)}},heatmap:class extends sf{createBucket(i){return new sJ(i)}constructor(i){super(i,an),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){"heatmap-color"===i&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=ao({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(i){return sj("heatmap-radius",this,i)}queryIntersectsFeature(i,r,n,o,s,a,c,u){const h=this.paint.get("heatmap-radius").evaluate(r,n);return sX(i,o,a,c,u,!0,!0,new l(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(i){return new ss(this,i)}},hillshade:class extends sf{constructor(i){super(i,as)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare",]}getProgramConfiguration(i){return new ss(this,i)}},fill:class extends sf{constructor(i){super(i,aU)}getProgramIds(){const i=this.paint.get("fill-pattern"),r=i&&i.constantOr(1),n=[r?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(r&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(i){return new ss(this,i)}recalculate(i,r){super.recalculate(i,r);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new aO(i)}queryRadius(){return sN(this.paint.get("fill-translate"))}queryIntersectsFeature(i,r,n,o,s,a){return!i.queryGeometry.isAboveHorizon&&sR(sG(i.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),o)}isTileClipped(){return!0}},"fill-extrusion":class extends sf{constructor(i){super(i,le)}createBucket(i){return new aJ(i)}queryRadius(){return sN(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion",]}getProgramConfiguration(i){return new ss(this,i)}queryIntersectsFeature(i,r,n,o,s,a,c,u,h){var d,p,f,m,g,y,x,$,v;const _=sZ(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),b=this.paint.get("fill-extrusion-height").evaluate(r,n),w=this.paint.get("fill-extrusion-base").evaluate(r,n),T=[0,0],E=u&&a.elevation,S=a.elevation?a.elevation.exaggeration():1;if(E){const I=i.tile.getBucket(this).centroidVertexArray,C=h+1;if(C=3){for(let a=0;a1&&(c=i[++l]);const h=Math.abs(u-c.left),d=Math.abs(u-c.right),p=Math.min(h,d);let f;const m=s/n*(o+1);if(c.isDash){const g=o-Math.abs(m);f=Math.sqrt(p*p+g*g)}else f=o-Math.sqrt(p*p+m*m);this.image.data[a+u]=Math.max(0,Math.min(255,f+128))}}}addRegularDash(i,r){for(let n=i.length-1;n>=0;--n){const o=i[n],s=i[n+1];o.zeroLength?i.splice(n,1):s&&s.isDash===o.isDash&&(s.left=o.left,i.splice(n,1))}const a=i[0],l=i[i.length-1];a.isDash===l.isDash&&(a.left=l.left-this.width,l.right=a.right+this.width);const c=this.width*this.nextRow;let u=0,h=i[u];for(let d=0;d1&&(h=i[++u]);const p=Math.abs(d-h.left),f=Math.abs(d-h.right),m=Math.min(p,f);this.image.data[c+d]=Math.max(0,Math.min(255,(h.isDash?m:-m)+r+128))}}addDash(i,r){const n=this.getKey(i,r);if(this.positions[n])return this.positions[n];const o="round"===r,s=o?7:0,a=2*s+1;if(this.nextRow+a>this.height)return ep("LineAtlas out of space"),null;0===i.length&&i.push(1);let l=0;for(let c=0;c0;a--)s+=(r&(o=1<this.canonical.z?new uo(i,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new uo(i,this.wrap,i,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(i,r=!0){if(this.overscaledZ===i&&r)return this.key;if(i>this.canonical.z)return us(this.wrap*+r,i,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-i;return us(this.wrap*+r,i,i,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(i){if(i.wrap!==this.wrap)return!1;const r=this.canonical.z-i.canonical.z;return 0===i.overscaledZ||i.overscaledZ>r&&i.canonical.y===this.canonical.y>>r}children(i){if(this.overscaledZ>=i)return[new uo(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y),];const r=this.canonical.z+1,n=2*this.canonical.x,o=2*this.canonical.y;return[new uo(r,this.wrap,r,n,o),new uo(r,this.wrap,r,n+1,o),new uo(r,this.wrap,r,n,o+1),new uo(r,this.wrap,r,n+1,o+1),]}isLessThan(i){return this.wrapi.wrap)&&(this.overscaledZi.overscaledZ)&&(this.canonical.xi.canonical.x)&&this.canonical.yMath.abs(o[l])){if(n[l]r[l])return null}else{const c=1/o[l];let u=(i[l]-n[l])*c,h=(r[l]-n[l])*c;if(u>h){const d=u;u=h,h=d}if(u>s&&(s=u),ha)return null}return s}function um(i,r,n,o,s,a,l,c,u,h,d){const p=o-i,f=s-r,m=a-n,g=l-i,y=c-r,x=u-n,$=d[1]*x-d[2]*y,v=d[2]*g-d[0]*x,_=d[0]*y-d[1]*g,b=p*$+f*v+m*_;if(1e-15>Math.abs(b))return null;const w=1/b,T=h[0]-i,E=h[1]-r,S=h[2]-n,I=(T*$+E*v+S*_)*w;if(I<0||I>1)return null;const C=E*m-S*f,z=S*p-T*m,A=T*f-E*p,k=(d[0]*C+d[1]*z+d[2]*A)*w;return k<0||I+k>1?null:(g*C+y*z+x*A)*w}function u8(i,r,n,o,s,a,l,c,u){const h=1<{const a=o?1:0;s[0]=i*n,s[1]=r*n,s[2]=(i+1)*n-a,s[3]=(r+1)*n-a};let l=new up(o);const c=[];for(let u=0;u=1;o/=2){const m=n[n.length-1];l=new up(o);for(let g=0;g0;){const{idx:m,t:g,nodex:y,nodey:x,depth:$}=f.pop();if(this.leaves[m]){u8(y,x,$,i,r,n,o,d,p);const v=1<<$,_=(y+0)/v,b=(y+1)/v,w=(x+0)/v,T=(x+1)/v,E=ux(_,w,this.dem)*l,S=ux(b,w,this.dem)*l,I=ux(b,T,this.dem)*l,C=ux(_,T,this.dem)*l,A=um(d[0],d[1],E,p[0],d[1],S,p[0],p[1],I,s,a),k=um(p[0],p[1],I,d[0],p[1],C,d[0],d[1],E,s,a),P=Math.min(null!==A?A:Number.MAX_VALUE,null!==k?k:Number.MAX_VALUE);if(P!==Number.MAX_VALUE)return P;{var D,L;const B=z([],s,a,g);if(uy(E,S,C,I,(B[0]-(D=d[0]))/(p[0]-D),(B[1]-(L=d[1]))/(p[1]-L))>=B[2])return g}continue}let R=0;for(let M=0;M=u[h[V]]&&(h.splice(V,0,M),U=!0);U||(h[R]=M),R++}}for(let j=0;j=this.dim+1||r<-1||r>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(i+1)}_unpackMapbox(i,r,n){return(256*i*256+256*r+n)/10-1e4}_unpackTerrarium(i,r,n){return 256*i+r+n/256-32768}static pack(i,r){const n=[0,0,0,0],o=uv.getUnpackVector(r);let s=Math.floor((i+o[3])/o[2]);return n[2]=s%256,s=Math.floor(s/256),n[1]=s%256,s=Math.floor(s/256),n[0]=s,n}getPixels(){return new ar({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,r,n){if(this.dim!==i.dim)throw Error("dem dimension mismatch");let o=r*this.dim,s=r*this.dim+this.dim,a=n*this.dim,l=n*this.dim+this.dim;switch(r){case -1:o=s-1;break;case 1:s=o+1}switch(n){case -1:a=l-1;break;case 1:l=a+1}const c=-r*this.dim,u=-n*this.dim;for(let h=a;h{"source"===i.dataType&&"metadata"===i.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===i.dataType&&"content"===i.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new class{constructor(i,r){this.max=i,this.onRemove=r,this.reset()}reset(){for(const i in this.data)for(const r of this.data[i])r.timeout&&clearTimeout(r.timeout),this.onRemove(r.value);return this.data={},this.order=[],this}add(i,r,n){const o=i.wrapped().key;void 0===this.data[o]&&(this.data[o]=[]);const s={value:r,timeout:void 0};if(void 0!==n&&(s.timeout=setTimeout(()=>{this.remove(i,s)},n)),this.data[o].push(s),this.order.push(o),this.order.length>this.max){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}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 r=this.data[i].shift();return r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),r.value}getByKey(i){const r=this.data[i];return r?r[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,r){if(!this.has(i))return this;const n=i.wrapped().key,o=void 0===r?0:this.data[n].indexOf(r),s=this.data[n][o];return this.data[n].splice(o,1),s.timeout&&clearTimeout(s.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(s.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(i){const r=[];for(const n in this.data)for(const o of this.data[n])i(o.value)||r.push(o);for(const s of r)this.remove(s.value.tileID,s)}}(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new class{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(i,r,n){const o=String(r);if(this.stateChanges[i]=this.stateChanges[i]||{},this.stateChanges[i][o]=this.stateChanges[i][o]||{},et(this.stateChanges[i][o],n),null===this.deletedStates[i])for(const s in this.deletedStates[i]={},this.state[i])s!==o&&(this.deletedStates[i][s]=null);else if(this.deletedStates[i]&&null===this.deletedStates[i][o])for(const a in this.deletedStates[i][o]={},this.state[i][o])n[a]||(this.deletedStates[i][o][a]=null);else for(const l in n)this.deletedStates[i]&&this.deletedStates[i][o]&&null===this.deletedStates[i][o][l]&&delete this.deletedStates[i][o][l]}removeFeatureState(i,r,n){if(null===this.deletedStates[i])return;const o=String(r);if(this.deletedStates[i]=this.deletedStates[i]||{},n&&void 0!==r)null!==this.deletedStates[i][o]&&(this.deletedStates[i][o]=this.deletedStates[i][o]||{},this.deletedStates[i][o][n]=null);else if(void 0!==r){if(this.stateChanges[i]&&this.stateChanges[i][o])for(n in this.deletedStates[i][o]={},this.stateChanges[i][o])this.deletedStates[i][o][n]=null;else this.deletedStates[i][o]=null}else this.deletedStates[i]=null}getState(i,r){const n=String(r),o=et({},(this.state[i]||{})[n],(this.stateChanges[i]||{})[n]);if(null===this.deletedStates[i])return{};if(this.deletedStates[i]){const s=this.deletedStates[i][r];if(null===s)return{};for(const a in s)delete o[a]}return o}initializeTileState(i,r){i.setFeatureState(this.state,r)}coalesceChanges(i,r){const n={};for(const o in this.stateChanges){this.state[o]=this.state[o]||{};const s={};for(const a in this.stateChanges[o])this.state[o][a]||(this.state[o][a]={}),et(this.state[o][a],this.stateChanges[o][a]),s[a]=this.state[o][a];n[o]=s}for(const l in this.deletedStates){this.state[l]=this.state[l]||{};const c={};if(null===this.deletedStates[l])for(const u in this.state[l])c[u]={},this.state[l][u]={};else for(const h in this.deletedStates[l]){if(null===this.deletedStates[l][h])this.state[l][h]={};else for(const d of Object.keys(this.deletedStates[l][h]))delete this.state[l][h][d];c[h]=this.state[l][h]}n[l]=n[l]||{},et(n[l],c)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(n).length)for(const p in i)i[p].setFeatureState(n,r)}}}onAdd(i){this.map=i,this._minTileCacheSize=i?i._minTileCacheSize:null,this._maxTileCacheSize=i?i._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const i in this._tiles){const r=this._tiles[i];if("loaded"!==r.state&&"errored"!==r.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const i=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,i&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(i,r){return i.isSymbolTile=this._onlySymbols,this._source.loadTile(i,r)}_unloadTile(i){if(this._source.unloadTile)return this._source.unloadTile(i,()=>{})}_abortTile(i){if(this._source.abortTile)return this._source.abortTile(i,()=>{})}serialize(){return this._source.serialize()}prepare(i){for(const r in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const n=this._tiles[r];n.upload(i),n.prepare(this.map.style.imageManager)}}getIds(){return ee(this._tiles).map(i=>i.tileID).sort(ub).map(i=>i.key)}getRenderableIds(i){const r=[];for(const n in this._tiles)this._isIdRenderable(+n,i)&&r.push(this._tiles[n]);return i?r.sort((i,r)=>{const n=i.tileID,o=r.tileID,s=new l(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),a=new l(o.canonical.x,o.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x}).map(i=>i.tileID.key):r.map(i=>i.tileID).sort(ub).map(i=>i.key)}hasRenderableParent(i){const r=this.findLoadedParent(i,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(i,r){return this._tiles[i]&&this._tiles[i].hasData()&&!this._coveredTiles[i]&&(r||!this._tiles[i].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const i in this._cache.reset(),this._tiles)"errored"!==this._tiles[i].state&&this._reloadTile(+i,"reloading")}_reloadTile(i,r){const n=this._tiles[i];n&&("loading"!==n.state&&(n.state=r),this._loadTile(n,this._tileLoaded.bind(this,n,i,r)))}_tileLoaded(i,r,n,o){if(o){if(i.state="errored",404!==o.status)this._source.fire(new tc(o,{tile:i}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const s=this.map.painter.terrain;this.update(this.transform,s.getScaledDemTileSize(),!0),s.resetTileLookupCache(this.id)}else this.update(this.transform)}else i.timeAdded=ew.now(),"expired"===n&&(i.refreshedUponExpiration=!0),this._setTileReloadTimer(r,i),"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),this._state.initializeTileState(i,this.map?this.map.painter:null),this._source.fire(new tl("data",{dataType:"source",tile:i,coord:i.tileID,sourceCacheId:this.id}))}_backfillDEM(i){const r=this.getRenderableIds();for(let n=0;n1||(Math.abs(n)>1&&(1===Math.abs(n+s)?n+=s:1===Math.abs(n-s)&&(n-=s)),r.dem&&i.dem&&(i.dem.backfillBorder(r.dem,n,o),i.neighboringTiles&&i.neighboringTiles[a]&&(i.neighboringTiles[a].backfilled=!0)))}}getTile(i){return this.getTileByID(i.key)}getTileByID(i){return this._tiles[i]}_retainLoadedChildren(i,r,n,o){for(const s in this._tiles){let a=this._tiles[s];if(o[s]||!a.hasData()||a.tileID.overscaledZ<=r||a.tileID.overscaledZ>n)continue;let l=a.tileID;for(;a&&a.tileID.overscaledZ>r+1;){const c=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[c.key])&&a.hasData()&&(l=c)}let u=l;for(;u.overscaledZ>r;)if(i[(u=u.scaledTo(u.overscaledZ-1)).key]){o[l.key]=l;break}}}findLoadedParent(i,r){if(i.key in this._loadedParentTiles){const n=this._loadedParentTiles[i.key];return n&&n.tileID.overscaledZ>=r?n:null}for(let o=i.overscaledZ-1;o>=r;o--){const s=i.scaledTo(o),a=this._getLoadedTile(s);if(a)return a}}_getLoadedTile(i){const r=this._tiles[i.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?i.wrapped().key:i.canonical.key)}updateCacheSize(i,r){r=r||this._source.tileSize;const n=Math.ceil(i.width/r)+1,o=Math.ceil(i.height/r)+1,s=Math.floor(n*o*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,s):s,l="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(l)}handleWrapJump(i){const r=Math.round((i-(void 0===this._prevLng?i:this._prevLng))/360);if(this._prevLng=i,r){const n={};for(const o in this._tiles){const s=this._tiles[o];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+r),n[s.tileID.key]=s}for(const a in this._tiles=n,this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(const l in this._tiles)this._setTileReloadTimer(+l,this._tiles[l])}}update(i,r,n){if(this.transform=i,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;let o;this.updateCacheSize(i,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=i.getVisibleUnwrappedCoordinates(this._source.tileID).map(i=>new uo(i.canonical.z,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y)):(o=i.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter(i=>this._source.hasTile(i)))):o=[];const s=this._updateRetainedTiles(o);if(uw(this._source.type)&&0!==o.length){const a={},l={},c=Object.keys(s);for(const u of c){const h=s[u],d=this._tiles[u];if(!d||d.fadeEndTime&&d.fadeEndTime<=ew.now())continue;const p=this.findLoadedParent(h,Math.max(h.overscaledZ-u_.maxOverzooming,this._source.minzoom));p&&(this._addTile(p.tileID),a[p.tileID.key]=p.tileID),l[u]=h}const f=o[o.length-1].overscaledZ;for(const m in this._tiles){const g=this._tiles[m];if(s[m]||!g.hasData())continue;let y=g.tileID;for(;y.overscaledZ>f;){y=y.scaledTo(y.overscaledZ-1);const x=this._tiles[y.key];if(x&&x.hasData()&&l[y.key]){s[m]=g.tileID;break}}}for(const $ in a)s[$]||(this._coveredTiles[$]=!0,s[$]=a[$])}for(const v in s)this._tiles[v].clearFadeHold();const _=function(i,r){const n=[];for(const o in i)o in r||n.push(o);return n}(this._tiles,s);for(const b of _){const w=this._tiles[b];w.hasSymbolBuckets&&!w.holdingForFade()?w.setHoldDuration(this.map._fadeDuration):w.hasSymbolBuckets&&!w.symbolFadeFinished()||this._removeTile(+b)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const i in this._tiles)this._tiles[i].holdingForFade()&&this._removeTile(+i)}_updateRetainedTiles(i){const r={};if(0===i.length)return r;const n={},o=i.reduce((i,r)=>Math.min(i,r.overscaledZ),1/0),s=i[0].overscaledZ,a=Math.max(s-u_.maxOverzooming,this._source.minzoom),l=Math.max(s+u_.maxUnderzooming,this._source.minzoom),c={};for(const u of i){const h=this._addTile(u);r[u.key]=u,h.hasData()||o=this._source.maxzoom){const f=d.children(this._source.maxzoom)[0],m=this.getTile(f);if(m&&m.hasData()){r[f.key]=f;continue}}else{const g=d.children(this._source.maxzoom);if(r[g[0].key]&&r[g[1].key]&&r[g[2].key]&&r[g[3].key])continue}let y=p.wasRequested();for(let x=d.overscaledZ-1;x>=a;--x){const $=d.scaledTo(x);if(n[$.key]||(n[$.key]=!0,(p=this.getTile($))||!y||(p=this._addTile($)),p&&(r[$.key]=$,y=p.wasRequested(),p.hasData())))break}}return r}_updateLoadedParentTileCache(){for(const i in this._loadedParentTiles={},this._tiles){const r=[];let n,o=this._tiles[i].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){n=this._loadedParentTiles[o.key];break}r.push(o.key);const s=o.scaledTo(o.overscaledZ-1);if(n=this._getLoadedTile(s))break;o=s}for(const a of r)this._loadedParentTiles[a]=n}}_addTile(i){let r=this._tiles[i.key];if(r)return r;(r=this._cache.getAndRemove(i))&&(this._setTileReloadTimer(i.key,r),r.tileID=i,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[i.key]&&(clearTimeout(this._cacheTimers[i.key]),delete this._cacheTimers[i.key],this._setTileReloadTimer(i.key,r)));const n=Boolean(r);if(!n){const o=this.map?this.map.painter:null,s="raster"===this._source.type||"raster-dem"===this._source.type;r=new u6(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,o,s),this._loadTile(r,this._tileLoaded.bind(this,r,i.key,r.state))}return r?(r.uses++,this._tiles[i.key]=r,n||this._source.fire(new tl("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(i,r){i in this._timers&&(clearTimeout(this._timers[i]),delete this._timers[i]);const n=r.getExpiryTimeout();n&&(this._timers[i]=setTimeout(()=>{this._reloadTile(i,"expired"),delete this._timers[i]},n))}_removeTile(i){const r=this._tiles[i];r&&(r.uses--,delete this._tiles[i],this._timers[i]&&(clearTimeout(this._timers[i]),delete this._timers[i]),r.uses>0||(r.hasData()&&"reloading"!==r.state?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){for(const i in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+i);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(i,r,n){const o=[],s=this.transform;if(!s)return o;for(const a in this._tiles){const l=this._tiles[a];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;const c=i.containsTile(l,s,r);c&&o.push(c)}return o}getVisibleCoordinates(i){const r=this.getRenderableIds(i).map(i=>this._tiles[i].tileID);for(const n of r)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(uw(this._source.type))for(const i in this._tiles){const r=this._tiles[i];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=ew.now())return!0}return!1}setFeatureState(i,r,n){this._state.updateState(i=i||"_geojsonTileLayer",r,n)}removeFeatureState(i,r,n){this._state.removeFeatureState(i=i||"_geojsonTileLayer",r,n)}getFeatureState(i,r){return this._state.getState(i=i||"_geojsonTileLayer",r)}setDependencies(i,r,n){const o=this._tiles[i];o&&o.setDependencies(r,n)}reloadTilesForDependencies(i,r){for(const n in this._tiles)this._tiles[n].hasDependency(i,r)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(i,r))}_preloadTiles(i,r){const n=new Map,o=Array.isArray(i)?i:[i],s=this.map.painter.terrain,a=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const l of o){const c=l.coveringTiles({tileSize:a,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const u of c)n.set(u.key,u);this.usedForTerrain&&l.updateElevation(!1)}const h=Array.from(n.values()),d="raster"===this._source.type||"raster-dem"===this._source.type;Q(h,(i,r)=>{const n=new u6(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,this.map.painter,d);this._loadTile(n,i=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),r(i,n)})},r)}}function ub(i,r){const n=Math.abs(2*i.wrap)-+(i.wrap<0),o=Math.abs(2*r.wrap)-+(r.wrap<0);return i.overscaledZ-r.overscaledZ||o-n||r.canonical.y-i.canonical.y||r.canonical.x-i.canonical.x}function uw(i){return"raster"===i||"image"===i||"video"===i}u_.maxOverzooming=10,u_.maxUnderzooming=3;class u0{constructor(i,r,n){this._demTile=i,this._dem=this._demTile.dem,this._scale=r,this._offset=n}static create(i,r,n){const o=n||i.findDEMTileFor(r);if(!o||!o.dem)return;const s=o.dem,a=o.tileID,l=1<=0&&d[3]>=0&&c.insert(l,d[0],d[1],d[2],d[3])}}loadVTLayers(){if(!this.vtLayers)for(const i in this.vtLayers=new aW.VectorTile(new lA(this.rawTileData)).layers,this.sourceLayerCoder=new uh(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[i]=[];return this.vtLayers}query(i,r,n,o){this.loadVTLayers();const s=i.params||{},a=rT(s.filter),l=i.tileResult,c=i.transform,u=l.bufferedTilespaceBounds,h=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(i,r,n,o)=>sV(l.bufferedTilespaceGeometry,i,r,n,o));h.sort(uS);let d=null;c.elevation&&h.length>0&&(d=u0.create(c.elevation,this.tileID));const p={};let f;for(let m=0;m(x||(x=sk(r,this.tileID.canonical,i.tileTransform)),n.queryIntersectsFeature(l,r,o,x,this.z,i.transform,i.pixelPosMatrix,d,s)))}return p}loadMatchingFeature(i,r,n,o,s,a,l,c,u){const{featureIndex:h,bucketIndex:d,sourceLayerIndex:p,layoutVertexArrayOffset:f}=r,m=this.bucketLayerIDs[d];if(o&&!function(i,r){for(let n=0;n=0)return!0;return!1}(o,m))return;const g=this.sourceLayerCoder.decode(p),y=this.vtLayers[g].feature(h);if(n.needGeometry){const x=sP(y,!0);if(!n.filter(new nX(this.tileID.overscaledZ),x,this.tileID.canonical))return}else if(!n.filter(new nX(this.tileID.overscaledZ),y))return;const $=this.getId(y,g);for(let v=0;vo.indexOf(_))continue;const b=a[_];if(!b)continue;let w={};void 0!==$&&c&&(w=c.getState(b.sourceLayer||"_geojsonTileLayer",$));const T=et({},l[_]);T.paint=uE(T.paint,b.paint,y,w,s),T.layout=uE(T.layout,b.layout,y,w,s);const E=!u||u(y,b,w,f);if(!E)continue;const S=new ud(y,this.z,this.x,this.y,$);S.layer=T;let I=i[_];void 0===I&&(I=i[_]=[]),I.push({featureIndex:h,feature:S,intersectionZ:E})}}lookupSymbolFeatures(i,r,n,o,s,a,l,c){const u={};this.loadVTLayers();const h=rT(s);for(const d of i)this.loadMatchingFeature(u,{bucketIndex:n,sourceLayerIndex:o,featureIndex:d,layoutVertexArrayOffset:0},h,a,l,c,r);return u}loadFeature(i){const{featureIndex:r,sourceLayerIndex:n}=i;this.loadVTLayers();const o=this.sourceLayerCoder.decode(n),s=this.vtFeatures[o];if(s[r])return s[r];const a=this.vtLayers[o].feature(r);return s[r]=a,a}hasLayer(i){for(const r of this.bucketLayerIDs)for(const n of r)if(i===n)return!0;return!1}getId(i,r){let n=i.id;return this.promoteId&&"boolean"==typeof(n=i.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[r]])&&(n=Number(n)),n}}function uE(i,r,n,o,s){return ec(i,(i,a)=>{const l=r instanceof oe?r.get(a):null;return l&&l.evaluate?l.evaluate(n,o,s):l})}function uS(i,r){return r-i}nr("FeatureIndex",uT,{omit:["rawTileData","sourceLayerCoder"]});var uI=oh([{name:"a_pos",type:"Int16",components:2},]);const uC=new Uint16Array(8184);for(let uz=0;uz<2046;uz++){let uA=uz+2,uk=0,uP=0,uD=0,uL=0,u1=0,uB=0;for(1&uA?uD=uL=u1=32:uk=uP=uB=32;(uA>>=1)>1;){const uR=uk+uD>>1,u3=uP+uL>>1;1&uA?(uD=uk,uL=uP,uk=u1,uP=uB):(uk=uD,uP=uL,uD=u1,uL=uB),u1=uR,uB=u3}const uM=4*uz;uC[uM+0]=uk,uC[uM+1]=uP,uC[uM+2]=uD,uC[uM+3]=uL}const u2=new Uint16Array(2178),uF=new Uint8Array(1089),uO=new Uint16Array(1089);function u4(i){return 0===i?-.03125:32===i?.03125:0}var uU=oh([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2},]);const uV={type:2,extent:8192,loadGeometry:()=>[[new l(0,0),new l(8193,0),new l(8193,8193),new l(0,8193),new l(0,0),],]};class u6{constructor(i,r,n,o,s){this.tileID=i,this.uid=er(),this.uses=0,this.tileSize=r,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,this.expiredRequestCount=0,this.state="loading",o&&o.transform&&(this.projection=o.transform.projection)}registerFadeDuration(i){const r=i+this.timeAdded;rr.getLayer(i)).filter(Boolean);if(0!==s.length)for(const a of(o.layers=s,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map(i=>s.filter(r=>r.id===i)[0])),s))n[a.id]=o}return n}(i.buckets,r.style),this.hasSymbolBuckets=!1,this.buckets){const s=this.buckets[o];if(s instanceof cU){if(this.hasSymbolBuckets=!0,!n)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const a in this.buckets){const l=this.buckets[a];if(l instanceof cU&&l.hasRTLText){this.hasRTLText=!0,n5.isLoading()||n5.isLoaded()||"deferred"!==n7()||nq();break}}for(const c in this.queryPadding=0,this.buckets){const u=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(c).queryRadius(u))}i.imageAtlas&&(this.imageAtlas=i.imageAtlas),i.glyphAtlasImage&&(this.glyphAtlasImage=i.glyphAtlasImage),i.lineAtlas&&(this.lineAtlas=i.lineAtlas)}else this.collisionBoxArray=new o1}unloadVectorData(){if(this.hasData()){for(const i in this.buckets)this.buckets[i].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this.globeGridBuffer&&(this.globeGridBuffer.destroy(),this.globeGridBuffer=null),this.globePoleBuffer&&(this.globePoleBuffer.destroy(),this.globePoleBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(i){return this.buckets[i.id]}upload(i){for(const r in this.buckets){const n=this.buckets[r];n.uploadPending()&&n.upload(i)}const o=i.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new cJ(i,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new cJ(i,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new cJ(i,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(i){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(i,this.imageAtlasTexture)}queryRenderedFeatures(i,r,n,o,s,a,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:l,transform:a,params:s,tileTransform:this.tileTransform},i,r,n):{}}querySourceFeatures(i,r){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const o=n.loadVTLayers(),s=r?r.sourceLayer:"",a=o._geojsonTileLayer||o[s];if(!a)return;const l=rT(r&&r.filter),{z:c,x:u,y:h}=this.tileID.canonical,d={z:c,x:u,y:h};for(let p=0;po)s=!1;else if(r){if(this.expirationTime=0;d--){const p=4*d,f=uC[p+0],m=uC[p+1],g=uC[p+2],y=uC[p+3],x=f+g>>1,$=m+y>>1,v=x+$-m,_=$+f-x,b=33*m+f,w=33*y+g,T=33*$+x,E=Math.hypot((u2[2*b+0]+u2[2*w+0])/2-u2[2*T+0],(u2[2*b+1]+u2[2*w+1])/2-u2[2*T+1])>=16;if(uF[T]=uF[T]||(E?1:0),d<1022){const S=(m+_>>1)*33+(f+v>>1),I=(y+_>>1)*33+(g+v>>1);uF[T]=uF[T]||uF[S]||uF[I]}}const C=new of,z=new o0;let A=0;function k(i,r){const n=33*r+i;return 0===uO[n]&&(C.emplaceBack(u2[2*n+0],u2[2*n+1],8192*i/32,8192*r/32),uO[n]=++A),uO[n]-1}function P(i,r,n,o,s,a){const l=i+n>>1,c=r+o>>1;if(Math.abs(i-s)+Math.abs(r-a)>1&&uF[33*c+l])P(s,a,i,r,l,c),P(n,o,s,a,l,c);else{const u=k(i,r),h=k(n,o),d=k(s,a);z.emplaceBack(u,h,d)}}return P(0,0,32,32,32,0),P(32,32,0,0,0,32),{vertices:C,indices:z}}(this.tileID.canonical,r);o=a.vertices,s=a.indices}else{for(const{x:l,y:c}of(o=new of,s=new o0,n))o.emplaceBack(l,c,0,0);const u=ac(o.int16,void 0,4);for(let h=0;h{const o=65*n+r;i.emplaceBack(o+1,o,o+65),i.emplaceBack(o+65,o+65+1,o+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}getWirefameBuffer(i){if(!this.wireframeSegments){const r=this._createWireframeGrid();this.wireframeIndexBuffer=i.createIndexBuffer(r),this.wireframeSegments=sg.simpleSegment(0,0,4096,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments,]}_createWireframeGrid(){const i=new oA,r=(r,n)=>{const o=65*n+r;i.emplaceBack(o,o+1),i.emplaceBack(o,o+65),i.emplaceBack(o,o+65+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}}function ht(i,r){if(!r.isReprojectedInTileSpace)return{scale:1<_&&(b(i,h,o,s,c,u),b(h,n,c,u,a,l))}b(p,f,o,a,s,a),b(f,m,s,a,s,l),b(m,g,s,l,o,l),b(g,p,o,l,o,a),y-=_,x-=_,$+=_,v+=_;const w=1/Math.max($-y,v-x);return{scale:w,x:y*w,y:x*w,x2:$*w,y2:v*w,projection:r}}class hi{constructor(i){const r={},n=[];for(const o in i){const s=i[o],a=r[o]={};for(const l in s.glyphs){const c=s.glyphs[+l];if(!c||0===c.bitmap.width||0===c.bitmap.height)continue;const u=c.metrics.localGlyph?2:1,h={x:0,y:0,w:c.bitmap.width+2*u,h:c.bitmap.height+2*u};n.push(h),a[l]=h}}const{w:d,h:p}=lZ(n),f=new ai({width:d||1,height:p||1});for(const m in i){const g=i[m];for(const y in g.glyphs){const x=g.glyphs[+y];if(!x||0===x.bitmap.width||0===x.bitmap.height)continue;const $=r[m][y],v=x.metrics.localGlyph?2:1;ai.copy(x.bitmap,f,{x:0,y:0},{x:$.x+v,y:$.y+v},x.bitmap)}}this.image=f,this.positions=r}}nr("GlyphAtlas",hi);class hr{constructor(i){this.tileID=new uo(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),this.tileZoom=i.tileZoom,this.uid=i.uid,this.zoom=i.zoom,this.canonical=i.tileID.canonical,this.pixelRatio=i.pixelRatio,this.tileSize=i.tileSize,this.source=i.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=i.showCollisionBoxes,this.collectResourceTiming=!!i.collectResourceTiming,this.returnDependencies=!!i.returnDependencies,this.promoteId=i.promoteId,this.enableTerrain=!!i.enableTerrain,this.isSymbolTile=i.isSymbolTile,this.tileTransform=ht(i.tileID.canonical,i.projection),this.projection=i.projection}parse(i,r,n,o,s){this.status="parsing",this.data=i,this.collisionBoxArray=new o1;const a=new uh(Object.keys(i.layers).sort()),l=new uT(this.tileID,this.promoteId);l.bucketLayerIDs=[];const c={},u=new cQ(256,256),h={featureIndex:l,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n},d=r.familiesBySource[this.source];for(const p in d){const f=i.layers[p];if(!f)continue;let m=!1,g=!1;for(const y of d[p])"symbol"===y[0].type?m=!0:g=!0;if(!0===this.isSymbolTile&&!m||!1===this.isSymbolTile&&!g)continue;1===f.version&&ep(`Vector tile source "${this.source}" layer "${p}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const x=a.encode(p),$=[];for(let v=0;v=T.maxzoom||"none"!==T.visibility&&(hn(w,this.zoom,n),(c[T.id]=T.createBucket({index:l.bucketLayerIDs.length,layers:w,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:x,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:n})).populate($,h,this.tileID.canonical,this.tileTransform),l.bucketLayerIDs.push(w.map(i=>i.id)))}}let E,S,I,C;u.trim();const z={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},A=ec(h.glyphDependencies,i=>Object.keys(i).map(Number));Object.keys(A).length?o.send("getGlyphs",{uid:this.uid,stacks:A},(i,r)=>{E||(E=i,S=r,D.call(this))},void 0,!1,z):S={};const k=Object.keys(h.iconDependencies);k.length?o.send("getImages",{icons:k,source:this.source,tileID:this.tileID,type:"icons"},(i,r)=>{E||(E=i,I=r,D.call(this))},void 0,!1,z):I={};const P=Object.keys(h.patternDependencies);function D(){if(E)return s(E);if(S&&I&&C){const i=new hi(S),r=new l7(I,C);for(const o in c){const a=c[o];a instanceof cU?(hn(a.layers,this.zoom,n),cC(a,S,i.positions,I,r.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection),a.projection=this.projection.name):a.hasPattern&&(a instanceof lh||a instanceof aO||a instanceof aJ)&&(hn(a.layers,this.zoom,n),a.addFeatures(h,this.tileID.canonical,r.patternPositions,n))}this.status="done",s(null,{buckets:ee(c).filter(i=>!i.isEmpty()),featureIndex:l,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:u,imageAtlas:r,glyphMap:this.returnDependencies?S:null,iconMap:this.returnDependencies?I:null,glyphPositions:this.returnDependencies?i.positions:null})}}P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"patterns"},(i,r)=>{E||(E=i,C=r,D.call(this))},void 0,!1,z):C={},D.call(this)}}function hn(i,r,n){const o=new nX(r);for(const s of i)s.recalculate(o,n)}class ho{constructor(i){this.entries={},this.scheduler=i}request(i,r,n,o){const s=this.entries[i]=this.entries[i]||{callbacks:[]};if(s.result){const[a,l]=s.result;return this.scheduler?this.scheduler.add(()=>{o(a,l)},r):o(a,l),()=>{}}return s.callbacks.push(o),s.cancel||(s.cancel=n((n,o)=>{for(const a of(s.result=[n,o],s.callbacks))this.scheduler?this.scheduler.add(()=>{a(n,o)},r):a(n,o);setTimeout(()=>delete this.entries[i],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(i=>i!==o),s.callbacks.length||(s.cancel(),delete this.entries[i]))}}}function hs(i,r,n){const o=JSON.stringify(i.request);return i.data&&(this.deduped.entries[o]={result:[null,i.data]}),this.deduped.request(o,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom},r=>{const o=eJ(i.request,(i,o,s,a)=>{i?r(i):o&&r(null,{vectorTile:n?void 0:new aW.VectorTile(new lA(o)),rawData:o,cacheControl:s,expires:a})});return()=>{o.cancel(),r()}},r)}const ha=p(new Float64Array(16));class hl{constructor(i,r){this._tr=i,this._worldSize=r}createInversionMatrix(){return ha}createTileMatrix(i){let r,n,o;const s=i.canonical,a=p(new Float64Array(16)),l=this._tr.projection;if(l.isReprojectedInTileSpace){const c=ht(s,l);r=1,n=c.x+i.wrap*c.scale,o=c.y,g(a,a,[r/c.scale,r/c.scale,this._tr.pixelsPerMeter/this._worldSize,])}else r=this._worldSize/this._tr.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return m(a,a,[n,o,0]),g(a,a,[r/8192,r/8192,1]),a}pointCoordinate(i,r,n){const o=this._tr.horizonLineFromTop(!1),s=new l(i,Math.max(o,r));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(s,n))}upVector(){return[0,0,1]}upVectorScale(){return 1}}const hc=Math.sqrt(3)/2,hu=Math.PI/2;function hh(i){return Math.tan((hu+i)/2)}const hd=85.051129*j,hp=85.051129*j,hf={albers:{name:"albers",range:[4,7],center:[-96,37.5],parallels:[29.5,45.5],zAxisUnit:"meters",conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&V(this.parallels,this.constants.parallels))return;const i=Math.sin(this.parallels[0]*j),r=(i+Math.sin(this.parallels[1]*j))/2,n=1+i*(2*r-i),o=Math.sqrt(n)/r;this.constants={n:r,c:n,r0:o,parallels:this.parallels}},project(i,r){this.initializeConstants();const n=(i-this.center[0])*j,{n:o,c:s,r0:a}=this.constants,l=Math.sqrt(s-2*o*Math.sin(r*j))/o;return{x:l*Math.sin(n*o),y:l*Math.cos(n*o)-a,z:0}},unproject(i,r){this.initializeConstants();const{n:n,c:o,r0:s}=this.constants,a=s+r;let l=Math.atan2(i,Math.abs(a))*Math.sign(a);a*n<0&&(l-=Math.PI*Math.sign(i)*Math.sign(a));const c=this.center[0]*j*n;l=J(l,-Math.PI-c,Math.PI-c);const u=l/n*N+this.center[0],h=Math.asin(K((o-(i*i+a*a)*n*n)/(2*n),-1,1)),d=K(h*N,-85.051129,85.051129);return new sx(u,d)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/sv(i)*r,farthestPixelDistance(i){return uZ(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hl(i,r)},equalEarth:{name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r=r/180*Math.PI,i=i/180*Math.PI;const n=Math.asin(hc*Math.sin(r)),o=n*n,s=o*o*o;return{x:.5*(i*Math.cos(n)/(hc*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o)))/Math.PI+.5),y:1-.5*(n*(1.340264+-.081106*o+s*(893e-6+.003796*o))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=n*n,s=o*o*o;for(let a,l,c=0;c<12&&(l=n*(1.340264+-.081106*o+s*(893e-6+.003796*o))-r,s=(o=(n=K(n-(a=l/(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))),-Math.PI/3,Math.PI/3))*n)*o*o,!(1e-12>Math.abs(a)));++c);const u=hc*i*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))/Math.cos(n),h=Math.asin(Math.sin(n)/hc),d=K(180*u/Math.PI,-180,180),p=K(180*h/Math.PI,-85.051129,85.051129);return new sx(d,p)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/sv(i)*r,farthestPixelDistance(i){return uZ(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hl(i,r)},equirectangular:{name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(i,r)=>({x:.5+i/360,y:.5-r/360,z:0}),unproject(i,r){const n=K(360*(.5-r),-85.051129,85.051129);return new sx(360*(i-.5),n)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/sv(i)*r,farthestPixelDistance(i){return uZ(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hl(i,r)},lambertConformalConic:{name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&V(this.parallels,this.constants.parallels))return;const i=this.parallels[0]*j,r=this.parallels[1]*j,n=Math.cos(i),o=i===r?Math.sin(i):Math.log(n/Math.cos(r))/Math.log(hh(r)/hh(i)),s=n*Math.pow(hh(i),o)/o;this.constants={n:o,f:s,parallels:this.parallels}},project(i,r){this.initializeConstants(),r*=j,i=(i-this.center[0])*j;const{n:n,f:o}=this.constants;o>0?r<-hu+1e-6&&(r=-hu+1e-6):r>hu-1e-6&&(r=hu-1e-6);const s=o/Math.pow(hh(r),n),a=s*Math.sin(n*i),l=o-s*Math.cos(n*i);return{x:.5*(a/Math.PI+.5),y:1-.5*(l/Math.PI+.5),z:0}},unproject(i,r){this.initializeConstants(),i=(2*i-.5)*Math.PI,r=(2*(1-r)-.5)*Math.PI;const{n:n,f:o}=this.constants,s=o-r,a=Math.sign(s),l=Math.sign(n)*Math.sqrt(i*i+s*s);let c=Math.atan2(i,Math.abs(s))*a;s*n<0&&(c-=Math.PI*Math.sign(i)*a);const u=K(c/n*N+this.center[0],-180,180),h=K((2*Math.atan(Math.pow(o/l,1/n))-hu)*N,-85.051129,85.051129);return new sx(u,h)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/sv(i)*r,farthestPixelDistance(i){return uZ(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hl(i,r)},mercator:{name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(i,r)=>({x:s_(i),y:sb(r),z:0}),unproject(i,r){const n=s0(i),o=sT(r);return new sx(n,o)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/sv(i)*r,farthestPixelDistance(i){return uZ(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hl(i,r)},naturalEarth:{name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(i,r){const n=(r*=j)*r,o=n*n;return{x:.5*((i*=j)*(.8707-.131979*n+o*(o*(.003971*n-.001529*o)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+n*(.015085+o*(.028874*n-.044475-.005916*o)))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=25,s=0,a=n*n;do{a=n*n;const l=a*a;s=(n*(1.007226+a*(.015085+l*(.028874*a-.044475-.005916*l)))-r)/(1.007226+a*(.045255+l*(.259866*a-.311325-.005916*11*l))),n=K(n-s,-hd,hd)}while(Math.abs(s)>1e-6&&--o>0)a=n*n;const c=K(i/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*N,-180,180),u=n*N;return new sx(c,u)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/sv(i)*r,farthestPixelDistance(i){return uZ(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hl(i,r)},winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r*=j,i*=j;const n=Math.cos(r),o=2/Math.PI,s=Math.acos(n*Math.cos(i/2)),a=Math.sin(s)/s,l=.5*(i*o+2*n*Math.sin(i/2)/a)||0,c=.5*(r+Math.sin(r)/a)||0;return{x:.5*(l/Math.PI+.5),y:1-.5*(c/Math.PI+1),z:0}},unproject(i,r){let n=i=(2*i-.5)*Math.PI,o=r=(2*(1-r)-1)*Math.PI,s=25,a=0,l=0;do{const c=Math.cos(o),u=Math.sin(o),h=2*u*c,d=u*u,p=c*c,f=Math.cos(n/2),m=Math.sin(n/2),g=2*f*m,y=m*m,x=1-p*f*f,$=x?1/x:0,v=x?Math.acos(c*f)*Math.sqrt(1/x):0,_=.5*(2*v*c*m+2*n/Math.PI)-i,b=.5*(v*u+o)-r,w=.5*$*(p*y+v*c*f*d)+1/Math.PI,T=$*(g*h/4-v*u*m),E=.125*$*(h*m-v*u*p*g),S=.5*$*(d*f+v*y*c)+.5,I=T*E-S*w;a=(b*T-_*S)/I,l=(_*E-b*w)/I,n=K(n-a,-Math.PI,Math.PI),o=K(o-l,-hp,hp)}while((Math.abs(a)>1e-6||Math.abs(l)>1e-6)&&--s>0)return new sx(n*N,o*N)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/sv(i)*r,farthestPixelDistance(i){return uZ(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hl(i,r)}};i.ARRAY_TYPE=h,i.AUTH_ERR_MSG=eD,i.Aabb=s5,i.Actor=class{constructor(i,r,n){this.target=i,this.parent=r,this.mapId=n,this.callbacks={},this.cancelCallbacks={},ea(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=e8()?i:u,this.scheduler=new class{constructor(){this.tasks={},this.taskQueue=[],ea(["process"],this),this.invoker=new class{constructor(i){this._callback=i,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){delete this._channel,this._callback=()=>{}}}(this.process),this.nextId=0}add(i,r){const n=this.nextId++,o=function({type:i,isSymbolTile:r,zoom:n}){return n=n||0,"message"===i?0:"maybePrepare"!==i||r?"parseTile"!==i||r?"parseTile"===i&&r?300-n:"maybePrepare"===i&&r?400-n:500:200-n:100-n}(r);return 0===o?(e8(),i(),{cancel(){}}):(this.tasks[n]={fn:i,metadata:r,priority:o,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}})}process(){e8();{if(this.taskQueue=this.taskQueue.filter(i=>!!this.tasks[i]),!this.taskQueue.length)return;const i=this.pick();if(null===i)return;const r=this.tasks[i];if(delete this.tasks[i],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}}pick(){let i=null,r=1/0;for(let n=0;n{n&&delete this.callbacks[l],this.target.postMessage({id:l,type:"",targetMapId:o,sourceMapId:this.mapId})}}}receive(i){const r=i.data,n=r.id;if(n&&(!r.targetMapId||this.mapId===r.targetMapId)){if(""===r.type){const o=this.cancelCallbacks[n];delete this.cancelCallbacks[n],o&&o.cancel()}else if(r.mustQueue||e8()){const s=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,r),s&&s.metadata||{type:"message"})}else this.processTask(n,r)}}processTask(i,r){if(""===r.type){const n=this.callbacks[i];delete this.callbacks[i],n&&(r.error?n(nl(r.error)):n(null,nl(r.data)))}else{const o=e_(this.globalScope)?void 0:[],s=r.hasCallback?(r,n)=>{delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"",sourceMapId:this.mapId,error:r?na(r):null,data:na(n,o)},o)}:i=>{},a=nl(r.data);if(this.parent[r.type])this.parent[r.type](r.sourceMapId,a,s);else if(this.parent.getWorkerSource){const l=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,l[0],a.source)[l[1]](a,s)}else s(Error(`Could not find function ${r.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=ur,i.Color=t1,i.ColorMode=uc,i.CullFaceMode=uu,i.DEMData=uv,i.DataConstantProperty=ot,i.DedupedRequest=ho,i.DepthMode=ua,i.EXTENT=8192,i.Elevation=class{getAtPointOrZero(i,r=0){return this.getAtPoint(i,r)||0}getAtPoint(i,r,n=!0){null==r&&(r=null);const o=this._source();if(!o||i.y<0||i.y>1)return r;const s=o.getSource().maxzoom,a=1<{const o=this.getAtTileOffset(i,n.x,n.y),s=r.upVector(i.canonical,n.x,n.y);return C(s,s,o*r.upVectorScale(i.canonical)),s}}getForTilePoints(i,r,n,o){const s=u0.create(this,i,o);return!!s&&(r.forEach(i=>{i[2]=this.exaggeration()*s.getElevationAt(i[0],i[1],n)}),!0)}getMinMaxForTile(i){const r=this.findDEMTileFor(i);if(!r||!r.dem)return null;const n=r.dem.tree,o=r.tileID,s=1<Math.abs(o))return!1;const s=((i[0]-this.pos[0])*r[0]+(i[1]-this.pos[1])*r[1]+(i[2]-this.pos[2])*r[2])/o;return n[0]=this.pos[0]+this.dir[0]*s,n[1]=this.pos[1]+this.dir[1]*s,n[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(i,r,n){var o,s,a,l,c,u,h,d;if(o=this.pos,s=i,a=o[0],l=o[1],c=o[2],u=s[0],h=s[1],d=s[2],Math.abs(a-u)<=1e-6*Math.max(1,Math.abs(a),Math.abs(u))&&Math.abs(l-h)<=1e-6*Math.max(1,Math.abs(l),Math.abs(h))&&Math.abs(c-d)<=1e-6*Math.max(1,Math.abs(c),Math.abs(d))||0===r)return n[0]=n[1]=n[2]=0,!1;const[p,f,m]=this.dir,g=this.pos[0]-i[0],y=this.pos[1]-i[1],x=this.pos[2]-i[2],$=p*p+f*f+m*m,v=2*(g*p+y*f+x*m),_=v*v-4*$*(g*g+y*y+x*x-r*r);if(_<0){const b=Math.max(-v/2,0),w=g+p*b,T=y+f*b,E=x+m*b,S=Math.hypot(w,T,E);return n[0]=w*r/S,n[1]=T*r/S,n[2]=E*r/S,!1}{const I=(-v-Math.sqrt(_))/(2*$);if(I<0){const C=Math.hypot(g,y,x);return n[0]=g*r/C,n[1]=y*r/C,n[2]=x*r/C,!1}return n[0]=g+p*I,n[1]=y+f*I,n[2]=x+m*I,!0}}},i.RequestManager=class{constructor(i,r,n){this._transformRequestFn=i,this._customAccessToken=r,this._silenceAuthErrors=!!n,this._createSkuToken()}_createSkuToken(){const i=function(){let i="";for(let r=0;r<10;r++)i+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",i].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(i,r){return this._transformRequestFn&&this._transformRequestFn(i,r)||{url:i}}normalizeStyleURL(i,r){if(!eL(i))return i;const n=eR(i);return n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(i,r){if(!eL(i))return i;const n=eR(i);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeSourceURL(i,r){if(!eL(i))return i;const n=eR(i);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||r)}normalizeSpriteURL(i,r,n,o){const s=eR(i);return eL(i)?(s.path=`/styles/v1${s.path}/sprite${r}${n}`,this._makeAPIURL(s,this._customAccessToken||o)):(s.path+=`${r}${n}`,e3(s))}normalizeTileURL(i,r,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!eL(i))return i;const o=eR(i);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||n&&"raster"!==o.authority&&512===n?"@2x":""}${eI.supported?".webp":"$1"}`),"raster"===o.authority?o.path=`/${eT.RASTER_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${eT.TILE_URL_VERSION}${o.path}`);const s=this._customAccessToken||function(i){for(const r of i){const n=r.match(/^access_token=(.*)$/);if(n)return n[1]}return null}(o.params)||eT.ACCESS_TOKEN;return eT.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,s)}canonicalizeTileURL(i,r){const n=eR(i);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return i;let o="mapbox://";n.path.match(/^\/raster\/v1\//)?o+=`raster/${n.path.replace(`/${eT.RASTER_URL_PREFIX}/`,"")}`:o+=`tiles/${n.path.replace(`/${eT.TILE_URL_VERSION}/`,"")}`;let s=n.params;return r&&(s=s.filter(i=>!i.match(/^access_token=/))),s.length&&(o+=`?${s.join("&")}`),o}canonicalizeTileset(i,r){const n=!!r&&eL(r),o=[];for(const s of i.tiles||[])e1(s)?o.push(this.canonicalizeTileURL(s,n)):o.push(s);return o}_makeAPIURL(i,r){const n="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",o=eR(eT.API_URL);if(i.protocol=o.protocol,i.authority=o.authority,"http"===i.protocol){const s=i.params.indexOf("secure");s>=0&&i.params.splice(s,1)}if("/"!==o.path&&(i.path=`${o.path}${i.path}`),!eT.REQUIRE_ACCESS_TOKEN)return e3(i);if(r=r||eT.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===r[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return i.params=i.params.filter(i=>-1===i.indexOf("access_token")),i.params.push(`access_token=${r||""}`),e3(i)}},i.ResourceType=eW,i.SegmentVector=sg,i.SourceCache=u_,i.StencilMode=ul,i.StructArrayLayout1ui2=ok,i.StructArrayLayout2f1f2i16=ob,i.StructArrayLayout2i4=op,i.StructArrayLayout2ui4=oA,i.StructArrayLayout3f12=o8,i.StructArrayLayout3ui6=o0,i.StructArrayLayout4i8=of,i.Texture=cJ,i.Tile=u6,i.Transitionable=nK,i.Uniform1f=oW,i.Uniform1i=class extends oX{constructor(i,r){super(i,r),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},i.Uniform2f=class extends oX{constructor(i,r){super(i,r),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]))}},i.Uniform3f=class extends oX{constructor(i,r){super(i,r),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]))}},i.Uniform4f=oH,i.UniformColor=oK,i.UniformMatrix2f=class extends oX{constructor(i,r){super(i,r),this.current=oQ}set(i){for(let r=0;r<4;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}},i.UniformMatrix3f=class extends oX{constructor(i,r){super(i,r),this.current=oJ}set(i){for(let r=0;r<9;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},i.UniformMatrix4f=class extends oX{constructor(i,r){super(i,r),this.current=oY}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 r=1;r<16;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},i.UnwrappedTileID=un,i.ValidationError=td,i.VectorTileWorkerSource=class extends tu{constructor(i,r,n,o,s){super(),this.actor=i,this.layerIndex=r,this.availableImages=n,this.loadVectorData=s||hs,this.loading={},this.loaded={},this.deduped=new ho(i.scheduler),this.isSpriteLoaded=o,this.scheduler=i.scheduler}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[n]=new hr(i);a.abort=this.loadVectorData(i,(l,c)=>{const u=!this.loading[n];if(delete this.loading[n],u||l||!c)return a.status="done",u||(this.loaded[n]=a),r(l);const h=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),a.vectorTile=c.vectorTile||new aW.VectorTile(new lA(h));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,(i,n)=>{if(i||!n)return r(i);const a={};if(s){const l=ut(o);l.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(l)))}r(null,et({rawTileData:h.slice(0)},n,d,a))})};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()}),this.loaded=this.loaded||{},this.loaded[n]=a})}reloadTile(i,r){const n=this.loaded,o=i.uid,s=this;if(n&&n[o]){const a=n[o];a.showCollisionBoxes=i.showCollisionBoxes,a.enableTerrain=!!i.enableTerrain,a.projection=i.projection;const l=(i,n)=>{const o=a.reloadCallback;o&&(delete a.reloadCallback,a.parse(a.vectorTile,s.layerIndex,this.availableImages,s.actor,o)),r(i,n)};"parsing"===a.status?a.reloadCallback=l:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,l):l())}}abortTile(i,r){const n=i.uid,o=this.loading[n];o&&(o.abort&&o.abort(),delete this.loading[n]),r()}removeTile(i,r){const n=this.loaded,o=i.uid;n&&n[o]&&delete n[o],r()}},i.WritingMode=lq,i.ZoomHistory=nc,i.add=T,i.addDynamicAttributes=c2,i.adjoint=function(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=r[4],c=r[5],u=r[6],h=r[7],d=r[8];return i[0]=l*d-c*h,i[1]=s*h-o*d,i[2]=o*c-s*l,i[3]=c*u-a*d,i[4]=n*d-s*u,i[5]=s*a-n*c,i[6]=a*h-l*u,i[7]=o*u-n*h,i[8]=n*l-o*a,i},i.asyncAll=Q,i.bezier=W,i.bindAll=ea,i.boundsAttributes=uU,i.bufferConvexPolygon=function(i,r){const n=[];for(let o=0;oe7&&(i.getActor().send("enforceCacheSizeLimit",e9),eX=0)},i.calculateGlobeMatrix=uQ,i.calculateGlobeMercatorMatrix=function(i){const r=i.worldSize,n=K(i.center.lat,-85.051129,85.051129),o=new l(s_(i.center.lng)*r,sb(n)*r),s=1/sv(i.center.lat)*r,a=i.pixelsPerMeter,c=r/(s/i.pixelsPerMeter),u=p(new Float64Array(16));return m(u,u,[o.x,o.y,0]),g(u,u,[c,c,a]),u},i.clamp=K,i.clearTileCache=function(i){const r=u.caches.delete(eN);i&&r.catch(i).then(()=>i())},i.clipLine=cf,i.clone=function(i){var r=new h(16);return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],r},i.clone$1=eh,i.collisionCircleLayout=lv,i.config=eT,i.conjugate=function(i,r){return i[0]=-r[0],i[1]=-r[1],i[2]=-r[2],i[3]=r[3],i},i.create=function(){var i=new h(16);return h!=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},i.create$1=d,i.createExpression=rd,i.createLayout=oh,i.createStyleLayer=function(i){return"custom"===i.type?new c9(i):new c5[i.type](i)},i.cross=P,i.degToRad=G,i.div=function(i,r,n){return i[0]=r[0]/n[0],i[1]=r[1]/n[1],i[2]=r[2]/n[2],i},i.dot=k,i.ease=H,i.easeCubicInOut=X,i.emitValidationErrors=rY,i.endsWith=el,i.enforceCacheSizeLimit=function(i){eq(),eG&&eG.then(r=>{r.keys().then(n=>{for(let o=0;oa&&(o+=(i[s]-a)*(i[s]-a)),r[s]Math.abs(r.parallels[0]+r.parallels[1])){let n=function(i){const r=Math.max(.01,Math.cos(i*j)),n=1/(2*Math.max(Math.PI*r,1/r));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom",],project(i,o){const s=Math.sin(o*j)/r;return{x:i*j*r*n+.5,y:-s*n+.5,z:0}},unproject(i,o){const s=K((i-.5)/n*N/r,-180,180),a=Math.asin(K(-(o-.5)/n*r,-1,1)),l=K(a*N,-85.051129,85.051129);return new sx(s,l)}}}(r.parallels[0]);if("lambertConformalConic"===r.name){const{project:o,unproject:s}=hf.mercator;n={wrap:!0,supportsWorldCopies:!0,project:o,unproject:s}}return et({},i,r,n)}return et({},i,r)}(r,i):r},i.getRTLTextPluginStatus=n7,i.getReferrer=eK,i.getTilePoint=function(i,{x:r,y:n},o=0){return new l(((r-o)*i.scale-i.x)*8192,(n*i.scale-i.y)*8192)},i.getTileVec3=function(i,r,n=0){return w(((r.x-n)*i.scale-i.x)*8192,(r.y*i.scale-i.y)*8192,sE(r.z,r.y))},i.getVideo=function(i,r){const n=u.document.createElement("video");n.muted=!0,n.onloadstart=function(){r(null,n)};for(let o=0;o0&&(l=1/Math.sqrt(l)),i[0]=n*l,i[1]=o*l,i[2]=s*l,i[3]=a*l,i},i.number=i$,i.ortho=function(i,r,n,o,s,a,l){var c=1/(r-n),u=1/(o-s),h=1/(a-l);return i[0]=-2*c,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*u,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*h,i[11]=0,i[12]=(r+n)*c,i[13]=(s+o)*u,i[14]=(l+a)*h,i[15]=1,i},i.pbf=lA,i.perspective=function(i,r,n,o,s){var a,l=1/Math.tan(r/2);return i[0]=l/n,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=l,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,null!=s&&s!==1/0?(i[10]=(s+o)*(a=1/(o-s)),i[14]=2*s*o*a):(i[10]=-1,i[14]=-2*o),i},i.pick=function(i,r){const n={};for(let o=0;othis._layers[i.id]),h=u[0];if("none"===h.visibility)continue;const d=h.source||"";let p=this.familiesBySource[d];p||(p=this.familiesBySource[d]={});const f=h.sourceLayer||"_geojsonTileLayer";let m=p[f];m||(m=p[f]=[]),m.push(u)}}}const{ImageBitmap:s}=i.window;class a{loadTile(r,n){const{uid:o,encoding:a,rawImageData:l,padding:c,buildQuadTree:u}=r,h=s&&l instanceof s?this.getImageData(l,c):l;n(null,new i.DEMData(o,h,a,c<1,u))}getImageData(r,n){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(r.width,r.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=r.width,this.offscreenCanvas.height=r.height,this.offscreenCanvasContext.drawImage(r,0,0,r.width,r.height);const o=this.offscreenCanvasContext.getImageData(-n,-n,r.width+2*n,r.height+2*n);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new i.RGBAImage({width:o.width,height:o.height},o.data)}}var l,c=function i(r,n){var o,s=r&&r.type;if("FeatureCollection"===s)for(o=0;o=Math.abs(c)?n-u+c:c-u+n,n=u}n+o>=0!=!!r&&i.reverse()}const d=i.vectorTile.VectorTileFeature.prototype.toGeoJSON;class p{constructor(r){this._feature=r,this.extent=i.EXTENT,this.type=r.type,this.properties=r.tags,"id"in r&&!isNaN(r.id)&&(this.id=parseInt(r.id,10))}loadGeometry(){if(1===this._feature.type){const r=[];for(const n of this._feature.geometry)r.push([new i.pointGeometry(n[0],n[1]),]);return r}{const o=[];for(const s of this._feature.geometry){const a=[];for(const l of s)a.push(new i.pointGeometry(l[0],l[1]));o.push(a)}return o}}toGeoJSON(i,r,n){return d.call(this,i,r,n)}}class f{constructor(r){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=r.length,this._features=r}feature(i){return new p(this._features[i])}}var m=i.vectorTile.VectorTileFeature,g=y;function y(i,r){this.options=r||{},this.features=i,this.length=i.length}function x(i,r){this.id="number"==typeof i.id?i.id:void 0,this.type=i.type,this.rawGeometry=1===i.type?[i.geometry]:i.geometry,this.properties=i.tags,this.extent=r||4096}y.prototype.feature=function(i){return new x(this.features[i],this.options.extent)},x.prototype.loadGeometry=function(){var r=this.rawGeometry;this.geometry=[];for(var n=0;n>31}function S(i,r){for(var n=i.loadGeometry(),o=i.type,s=0,a=0,l=n.length,c=0;ci[0],P=i=>i[1];class D{constructor(i,r=k,n=P,o=64,s=Float64Array){this.nodeSize=o,this.points=i;const a=i.length<65536?Uint16Array:Uint32Array,l=this.ids=new a(i.length),c=this.coords=new s(2*i.length);for(let u=0;u>1;(function i(r,n,o,s,a,l){for(;a>s;){if(a-s>600){const c=a-s+1,u=o-s+1,h=Math.log(c),d=.5*Math.exp(2*h/3),p=.5*Math.sqrt(h*d*(c-d)/c)*(u-c/2<0?-1:1);i(r,n,o,Math.max(s,Math.floor(o-u*d/c+p)),Math.min(a,Math.floor(o+(c-u)*d/c+p)),l)}const f=n[2*o+l];let m=s,g=a;for(C(r,n,s,o),n[2*a+l]>f&&C(r,n,s,a);mf;)g--}n[2*s+l]===f?C(r,n,s,g):C(r,n,++g,a),g<=o&&(s=g+1),o<=g&&(a=g-1)}})(r,n,c,s,a,l%2),i(r,n,o,s,c-1,l+1),i(r,n,o,c+1,a,l+1)}(l,c,o,0,l.length-1,0)}range(i,r,n,o){return function(i,r,n,o,s,a,l){const c=[0,i.length-1,0],u=[];let h,d;for(;c.length;){const p=c.pop(),f=c.pop(),m=c.pop();if(f-m<=l){for(let g=m;g<=f;g++)h=r[2*g],d=r[2*g+1],h>=n&&h<=s&&d>=o&&d<=a&&u.push(i[g]);continue}const y=Math.floor((m+f)/2);h=r[2*y],d=r[2*y+1],h>=n&&h<=s&&d>=o&&d<=a&&u.push(i[y]);const x=(p+1)%2;(0===p?n<=h:o<=d)&&(c.push(m),c.push(y-1),c.push(x)),(0===p?s>=h:a>=d)&&(c.push(y+1),c.push(f),c.push(x))}return u}(this.ids,this.coords,i,r,n,o,this.nodeSize)}within(i,r,n){return function(i,r,n,o,s,a){const l=[0,i.length-1,0],c=[],u=s*s;for(;l.length;){const h=l.pop(),d=l.pop(),p=l.pop();if(d-p<=a){for(let f=p;f<=d;f++)A(r[2*f],r[2*f+1],n,o)<=u&&c.push(i[f]);continue}const m=Math.floor((p+d)/2),g=r[2*m],y=r[2*m+1];A(g,y,n,o)<=u&&c.push(i[m]);const x=(h+1)%2;(0===h?n-s<=g:o-s<=y)&&(l.push(p),l.push(m-1),l.push(x)),(0===h?n+s>=g:o+s>=y)&&(l.push(m+1),l.push(d),l.push(x))}return c}(this.ids,this.coords,i,r,n,this.nodeSize)}}const L=Math.fround||(l=new Float32Array(1),i=>(l[0]=+i,l[0]));class B{constructor(i){this.options=N(Object.create({minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:i=>i}),i),this.trees=Array(this.options.maxZoom+1)}load(i){const{log:r,minZoom:n,maxZoom:o,nodeSize:s}=this.options;r&&console.time("total time");const a=`prepare ${i.length} points`;r&&console.time(a),this.points=i;let l=[];for(let c=0;c=n;u--){const h=+Date.now();l=this._cluster(l,u),this.trees[u]=new D(l,G,Z,s,Float32Array),r&&console.log("z%d: %d clusters in %dms",u,l.length,+Date.now()-h)}return r&&console.timeEnd("total time"),this}getClusters(i,r){let n=((i[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,i[1]));let s=180===i[2]?180:((i[2]+180)%360+360)%360-180;const a=Math.max(-90,Math.min(90,i[3]));if(i[2]-i[0]>=360)n=-180,s=180;else if(n>s){const l=this.getClusters([n,o,180,a],r),c=this.getClusters([-180,o,s,a],r);return l.concat(c)}const u=this.trees[this._limitZoom(r)],h=u.range(U(n),V(a),U(s),V(o)),d=[];for(const p of h){const f=u.points[p];d.push(f.numPoints?F(f):this.points[f.index])}return d}getChildren(i){const r=this._getOriginId(i),n=this._getOriginZoom(i),o="No cluster with the specified id.",s=this.trees[n];if(!s)throw Error(o);const a=s.points[r];if(!a)throw Error(o);const l=this.options.radius/(this.options.extent*Math.pow(2,n-1)),c=s.within(a.x,a.y,l),u=[];for(const h of c){const d=s.points[h];d.parentId===i&&u.push(d.numPoints?F(d):this.points[d.index])}if(0===u.length)throw Error(o);return u}getLeaves(i,r,n){const o=[];return this._appendLeaves(o,i,r=r||10,n=n||0,0),o}getTile(i,r,n){const o=this.trees[this._limitZoom(i)],s=Math.pow(2,i),{extent:a,radius:l}=this.options,c=l/a,u=(n-c)/s,h=(n+1+c)/s,d={features:[]};return this._addTileFeatures(o.range((r-c)/s,u,(r+1+c)/s,h),o.points,r,n,s,d),0===r&&this._addTileFeatures(o.range(1-c/s,u,1,h),o.points,s,n,s,d),r===s-1&&this._addTileFeatures(o.range(0,u,c/s,h),o.points,-1,n,s,d),d.features.length?d:null}getClusterExpansionZoom(i){let r=this._getOriginZoom(i)-1;for(;r<=this.options.maxZoom;){const n=this.getChildren(i);if(r++,1!==n.length)break;i=n[0].properties.cluster_id}return r}_appendLeaves(i,r,n,o,s){const a=this.getChildren(r);for(const l of a){const c=l.properties;if(c&&c.cluster?s+c.point_count<=o?s+=c.point_count:s=this._appendLeaves(i,c.cluster_id,n,o,s):sr&&(m+=y.numPoints||1)}if(m>f&&m>=l){let x=h.x*f,$=h.y*f,v=a&&f>1?this._map(h,!0):null;const _=(u<<5)+(r+1)+this.points.length;for(const b of p){const w=d.points[b];if(w.zoom<=r)continue;w.zoom=r;const T=w.numPoints||1;x+=w.x*T,$+=w.y*T,w.parentId=_,a&&(v||(v=this._map(h,!0)),a(v,this._map(w)))}h.parentId=_,n.push(R(x/m,$/m,_,m,v))}else if(n.push(h),m>1)for(const E of p){const S=d.points[E];S.zoom<=r||(S.zoom=r,n.push(S))}}return n}_getOriginId(i){return i-this.points.length>>5}_getOriginZoom(i){return(i-this.points.length)%32}_map(i,r){if(i.numPoints)return r?N({},i.properties):i.properties;const n=this.points[i.index].properties,o=this.options.map(n);return r&&o===n?N({},o):o}}function R(i,r,n,o,s){return{x:L(i),y:L(r),zoom:1/0,id:n,parentId:-1,numPoints:o,properties:s}}function M(i,r){const[n,o]=i.geometry.coordinates;return{x:L(U(n)),y:L(V(o)),zoom:1/0,index:r,parentId:-1}}function F(i){return{type:"Feature",id:i.id,properties:O(i),geometry:{type:"Point",coordinates:[360*(i.x-.5),j(i.y),]}}}function O(i){const r=i.numPoints,n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r;return N(N({},i.properties),{cluster:!0,cluster_id:i.id,point_count:r,point_count_abbreviated:n})}function U(i){return i/360+.5}function V(i){const r=Math.sin(i*Math.PI/180),n=.5-.25*Math.log((1+r)/(1-r))/Math.PI;return n<0?0:n>1?1:n}function j(i){const r=(180-360*i)*Math.PI/180;return 360*Math.atan(Math.exp(r))/Math.PI-90}function N(i,r){for(const n in r)i[n]=r[n];return i}function G(i){return i.x}function Z(i){return i.y}function q(i,r,n,o,s,a){var l=s-n,c=a-o;if(0!==l||0!==c){var u=((i-n)*l+(r-o)*c)/(l*l+c*c);u>1?(n=s,o=a):u>0&&(n+=l*u,o+=c*u)}return(l=i-n)*l+(c=r-o)*c}function X(i,r,n,o){var s={id:void 0===i?null:i,type:r,geometry:n,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(i){var r=i.geometry,n=i.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)W(i,r);else if("Polygon"===n||"MultiLineString"===n)for(var o=0;o0&&(l+=o?(s*h-u*a)/2:Math.sqrt(Math.pow(u-s,2)+Math.pow(h-a,2))),s=u,a=h}var d=r.length-3;r[2]=1,function i(r,n,o,s){for(var a,l=s,c=o-n>>1,u=o-n,h=r[n],d=r[n+1],p=r[o],f=r[o+1],m=n+3;ml)a=m,l=g;else if(g===l){var y=Math.abs(m-c);ys&&(a-n>3&&i(r,n,a,s),r[a+2]=l,o-a>3&&i(r,a,o,s))}(r,0,d,n),r[d+2]=1,r.size=Math.abs(l),r.start=0,r.end=r.size}function J(i,r,n,o){for(var s=0;s1?1:n}function et(i,r,n,o,s,a,l,c){if(o/=r,a>=(n/=r)&&l=o)return null;for(var u=[],h=0;h=n&&g=o)){var y=[];if("Point"===f||"MultiPoint"===f)ei(p,y,n,o,s);else if("LineString"===f)er(p,y,n,o,s,!1,c.lineMetrics);else if("MultiLineString"===f)eo(p,y,n,o,s,!1);else if("Polygon"===f)eo(p,y,n,o,s,!0);else if("MultiPolygon"===f)for(var x=0;x=n&&l<=o&&(r.push(i[a]),r.push(i[a+1]),r.push(i[a+2]))}}function er(i,r,n,o,s,a,l){for(var c,u,h=en(i),d=0===s?ea:el,p=i.start,f=0;fn&&(u=d(h,m,g,x,$,n),l&&(h.start=p+c*u)):v>o?_=n&&(u=d(h,m,g,x,$,n),b=!0),_>o&&v<=o&&(u=d(h,m,g,x,$,o),b=!0),!a&&b&&(l&&(h.end=p+c*u),r.push(h),h=en(i)),l&&(p+=c)}var w=i.length-3;m=i[w],g=i[w+1],y=i[w+2],(v=0===s?m:g)>=n&&v<=o&&es(h,m,g,y),w=h.length-3,a&&w>=3&&(h[w]!==h[0]||h[w+1]!==h[1])&&es(h,h[0],h[1],h[2]),h.length&&r.push(h)}function en(i){var r=[];return r.size=i.size,r.start=i.start,r.end=i.end,r}function eo(i,r,n,o,s,a){for(var l=0;ll.maxX&&(l.maxX=d),p>l.maxY&&(l.maxY=p)}return l}function ef(i,r,n,o){var s=r.geometry,a=r.type,l=[];if("Point"===a||"MultiPoint"===a)for(var c=0;c0&&r.size<(s?l:o))n.numPoints+=r.length/3;else{for(var c=[],u=0;ul)&&(n.numSimplified++,c.push(r[u]),c.push(r[u+1])),n.numPoints++;s&&function(i,r){for(var n=0,o=0,s=i.length,a=s-2;o0===r)for(o=0,s=i.length;o24)throw Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw Error("promoteId and generateId cannot be used together.");var o,s,a,l,c,u,h=function(i,r){var n=[];if("FeatureCollection"===i.type)for(var o=0;o1&&console.time("creation"),f=this.tiles[p]=ep(i,r,n,o,u),this.tileCoords.push({z:r,x:n,y:o}),h)){h>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",r,n,o,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var m="z"+r;this.stats[m]=(this.stats[m]||0)+1,this.total++}if(f.source=i,s){if(r===u.maxZoom||r===s)continue;var g=1<1&&console.time("clipping");var y,x,$,v,_,b,w=.5*u.buffer/u.extent,T=.5-w,E=.5+w,S=1+w;y=x=$=v=null,_=et(i,d,n-w,n+E,0,f.minX,f.maxX,u),b=et(i,d,n+T,n+S,0,f.minX,f.maxX,u),i=null,_&&(y=et(_,d,o-w,o+E,1,f.minY,f.maxY,u),x=et(_,d,o+T,o+S,1,f.minY,f.maxY,u),_=null),b&&($=et(b,d,o-w,o+E,1,f.minY,f.maxY,u),v=et(b,d,o+T,o+S,1,f.minY,f.maxY,u),b=null),h>1&&console.timeEnd("clipping"),c.push(y||[],r+1,2*n,2*o),c.push(x||[],r+1,2*n,2*o+1),c.push($||[],r+1,2*n+1,2*o),c.push(v||[],r+1,2*n+1,2*o+1)}}},e8.prototype.getTile=function(i,r,n){var o=this.options,s=o.extent,a=o.debug;if(i<0||i>24)return null;var l=1<1&&console.log("drilling down to z%d-%d-%d",i,r,n);for(var u,h=i,d=r,p=n;!u&&h>0;)h--,d=Math.floor(d/2),p=Math.floor(p/2),u=this.tiles[eg(h,d,p)];return u&&u.source?(a>1&&console.log("found parent tile z%d-%d-%d",h,d,p),a>1&&console.time("drilling down"),this.splitTile(u.source,h,d,p,i,r,n),a>1&&console.timeEnd("drilling down"),this.tiles[c]?eh(this.tiles[c],s):null):null};class ey extends i.VectorTileWorkerSource{constructor(i,r,n,o,s){super(i,r,n,o,function(i,r){const n=i.tileID.canonical;if(!this._geoJSONIndex)return r(null,null);const o=this._geoJSONIndex.getTile(n.z,n.x,n.y);if(!o)return r(null,null);const s=new f(o.features);let a=$(s);0===a.byteOffset&&a.byteLength===a.buffer.byteLength||(a=new Uint8Array(a)),r(null,{vectorTile:s,rawData:a.buffer})}),s&&(this.loadGeoJSON=s)}loadData(r,n){const o=r&&r.request,s=o&&o.collectResourceTiming;this.loadGeoJSON(r,(a,l)=>{if(a||!l)return n(a);if("object"!=typeof l)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{c(l,!0);try{var u,h;if(r.filter){const d=i.createExpression(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));const p=l.features.filter(i=>d.value.evaluate({zoom:0},i));l={type:"FeatureCollection",features:p}}this._geoJSONIndex=r.cluster?new B(function({superclusterOptions:r,clusterProperties:n}){if(!n||!r)return r;const o={},s={},a={accumulated:null,zoom:0},l={properties:null},c=Object.keys(n);for(const u of c){const[h,d]=n[u],p=i.createExpression(d),f=i.createExpression("string"==typeof h?[h,["accumulated",],["get",u,],]:h);o[u]=p.value,s[u]=f.value}return r.map=i=>{l.properties=i;const r={};for(const n of c)r[n]=o[n].evaluate(a,l);return r},r.reduce=(i,r)=>{for(const n of(l.properties=r,c))a.accumulated=i[n],i[n]=s[n].evaluate(a,l)},r}(r)).load(l.features):(u=l,h=r.geojsonVtOptions,new e8(u,h))}catch(f){return n(f)}this.loaded={};const m={};if(s){const g=i.getPerformanceMeasurement(o);g&&(m.resourceTiming={},m.resourceTiming[r.source]=JSON.parse(JSON.stringify(g)))}n(null,m)}})}reloadTile(i,r){const n=this.loaded;return n&&n[i.uid]?super.reloadTile(i,r):this.loadTile(i,r)}loadGeoJSON(r,n){if(r.request)i.getJSON(r.request,n);else{if("string"!=typeof r.data)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(r.data))}catch(o){return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(i,r){try{r(null,this._geoJSONIndex.getClusterExpansionZoom(i.clusterId))}catch(n){r(n)}}getClusterChildren(i,r){try{r(null,this._geoJSONIndex.getChildren(i.clusterId))}catch(n){r(n)}}getClusterLeaves(i,r){try{r(null,this._geoJSONIndex.getLeaves(i.clusterId,i.limit,i.offset))}catch(n){r(n)}}}class ex{constructor(r){this.self=r,this.actor=new i.Actor(r,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:ey},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(i,r)=>{if(this.workerSourceTypes[i])throw Error(`Worker source with name "${i}" already registered.`);this.workerSourceTypes[i]=r},this.self.registerRTLTextPlugin=r=>{if(i.plugin.isParsed())throw Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=r.applyArabicShaping,i.plugin.processBidirectionalText=r.processBidirectionalText,i.plugin.processStyledBidirectionalText=r.processStyledBidirectionalText}}clearCaches(i,r,n){delete this.layerIndexes[i],delete this.availableImages[i],delete this.workerSources[i],delete this.demWorkerSources[i],n()}checkIfReady(i,r,n){n()}setReferrer(i,r){this.referrer=r}spriteLoaded(r,n){for(const o in this.isSpriteLoaded[r]=n,this.workerSources[r]){const s=this.workerSources[r][o];for(const a in s)s[a]instanceof i.VectorTileWorkerSource&&(s[a].isSpriteLoaded=n,s[a].fire(new i.Event("isSpriteLoaded")))}}setImages(i,r,n){for(const o in this.availableImages[i]=r,this.workerSources[i]){const s=this.workerSources[i][o];for(const a in s)s[a].availableImages=r}n()}enableTerrain(i,r,n){this.terrain=r,n()}setProjection(r,n){this.projections[r]=i.getProjection(n)}setLayers(i,r,n){this.getLayerIndex(i).replace(r),n()}updateLayers(i,r,n){this.getLayerIndex(i).update(r.layers,r.removedIds),n()}loadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).loadTile(s,o)}loadDEMTile(r,n,o){const s=this.enableTerrain?i.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(r,n.source).loadTile(s,o)}reloadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).reloadTile(s,o)}abortTile(i,r,n){this.getWorkerSource(i,r.type,r.source).abortTile(r,n)}removeTile(i,r,n){this.getWorkerSource(i,r.type,r.source).removeTile(r,n)}removeSource(i,r,n){if(!this.workerSources[i]||!this.workerSources[i][r.type]||!this.workerSources[i][r.type][r.source])return;const o=this.workerSources[i][r.type][r.source];delete this.workerSources[i][r.type][r.source],void 0!==o.removeSource?o.removeSource(r,n):n()}loadWorkerSource(i,r,n){try{this.self.importScripts(r.url),n()}catch(o){n(o.toString())}}syncRTLPluginState(r,n,o){try{i.plugin.setState(n);const s=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&null!=s){this.self.importScripts(s);const a=i.plugin.isParsed();o(a?void 0:Error(`RTL Text Plugin failed to import scripts from ${s}`),a)}}catch(l){o(l.toString())}}getAvailableImages(i){let r=this.availableImages[i];return r||(r=[]),r}getLayerIndex(i){let r=this.layerIndexes[i];return r||(r=this.layerIndexes[i]=new o),r}getWorkerSource(i,r,n){return this.workerSources[i]||(this.workerSources[i]={}),this.workerSources[i][r]||(this.workerSources[i][r]={}),this.workerSources[i][r][n]||(this.workerSources[i][r][n]=new this.workerSourceTypes[r]({send:(r,n,o,s,a,l)=>{this.actor.send(r,n,o,i,a,l)},scheduler:this.actor.scheduler},this.getLayerIndex(i),this.getAvailableImages(i),this.isSpriteLoaded[i])),this.workerSources[i][r][n]}getDEMWorkerSource(i,r){return this.demWorkerSources[i]||(this.demWorkerSources[i]={}),this.demWorkerSources[i][r]||(this.demWorkerSources[i][r]=new a),this.demWorkerSources[i][r]}enforceCacheSizeLimit(r,n){i.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(i,r,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new ex(self)),ex}),s(["./shared"],function(i){var r=n;function n(i){var r,s;return r=i,"undefined"!=typeof window&&"undefined"!=typeof document&&!!Array.prototype&&!!Array.prototype.every&&!!Array.prototype.filter&&!!Array.prototype.forEach&&!!Array.prototype.indexOf&&!!Array.prototype.lastIndexOf&&!!Array.prototype.map&&!!Array.prototype.some&&!!Array.prototype.reduce&&!!Array.prototype.reduceRight&&!!Array.isArray&&!!Function.prototype&&!!Function.prototype.bind&&!!Object.keys&&!!Object.create&&!!Object.getPrototypeOf&&!!Object.getOwnPropertyNames&&!!Object.isSealed&&!!Object.isFrozen&&!!Object.isExtensible&&!!Object.getOwnPropertyDescriptor&&!!Object.defineProperty&&!!Object.defineProperties&&!!Object.seal&&!!Object.freeze&&!!Object.preventExtensions&&!!("JSON"in window&&"parse"in JSON&&"stringify"in JSON)&&!!function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var i,r,n=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(n);try{r=new Worker(o),i=!0}catch(s){i=!1}return r&&r.terminate(),URL.revokeObjectURL(o),i}()&&"Uint8ClampedArray"in window&&!!ArrayBuffer.isView&&!!function(){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");if(!r)return!1;var n=r.getImageData(0,0,1,1);return n&&n.width===i.width}()&&(void 0===o[s=r&&r.failIfMajorPerformanceCaveat]&&(o[s]=function(i){var r,o,s,a,l=(r=i,o=document.createElement("canvas"),(s=Object.create(n.webGLContextAttributes)).failIfMajorPerformanceCaveat=r,o.getContext("webgl",s)||o.getContext("experimental-webgl",s));if(!l)return!1;try{a=l.createShader(l.VERTEX_SHADER)}catch(c){return!1}return!(!a||l.isContextLost())&&(l.shaderSource(a,"void main() {}"),l.compileShader(a),!0===l.getShaderParameter(a,l.COMPILE_STATUS))}(s)),!!o[s]&&!document.documentMode)}var o={};function s(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=n*a-s*o;return l?(i[0]=a*(l=1/l),i[1]=-o*l,i[2]=-s*l,i[3]=n*l,i):null}function a(i,r){if(Array.isArray(i)){if(!Array.isArray(r)||i.length!==r.length)return!1;for(let n=0;n{i.window.removeEventListener("click",d,!0)},0)},l.mousePos=function(i,r){const n=i.getBoundingClientRect();return p(i,n,r)},l.touchPos=function(i,r){const n=i.getBoundingClientRect(),o=[];for(let s=0;s=0?0:r.button};class m extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(i){if(this.loaded!==i&&(this.loaded=i,i)){for(const{ids:r,callback:n}of this.requestors)this._notify(r,n);this.requestors=[]}}getImage(i){return this.images[i]}addImage(i,r){this._validate(i,r)&&(this.images[i]=r)}_validate(r,n){let o=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "content" value`))),o=!1),o}_validateStretch(i,r){if(!i)return!0;let n=0;for(const o of i){if(o[0]{this.ready=!0})}broadcast(r,n,o){i.asyncAll(this.actors,(i,o)=>{i.send(r,n,o)},o=o||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(i=>{i.remove()}),this.actors=[],this.workerPool.release(this.id)}}function C(r,n,o){return n*(i.EXTENT/(r.tileSize*Math.pow(2,o-r.tileID.overscaledZ)))}I.Actor=i.Actor;class z{constructor(i,r,n){this.context=i;const o=i.gl;this.buffer=o.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const A={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class k{constructor(i,r,n,o){this.length=r.length,this.attributes=n,this.itemSize=r.bytesPerElement,this.dynamicDraw=o,this.context=i;const s=i.gl;this.buffer=s.createBuffer(),i.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,r){for(let n=0;no.pointCoordinate3D(i)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(r,n){let o,s;if(r instanceof i.pointGeometry||"number"==typeof r[0]){const a=i.pointGeometry.convert(r);o=[i.pointGeometry.convert(r)],s=n.isPointAboveHorizon(a)}else{const l=i.pointGeometry.convert(r[0]),c=i.pointGeometry.convert(r[1]);o=[l,c],s=i.polygonizeBounds(l,c).every(i=>n.isPointAboveHorizon(i))}return new M(o,n.getCameraPoint(),s,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(r){return i.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const n=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],s=i.polygonizeBounds(n,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=o.x?s[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(s[3]=this.cameraPoint)),i.bufferConvexPolygon(s,r)}containsTile(r,n,o){var s;const a=r.queryPadding+1,l=r.tileID.wrap,c=o?this._bufferedCameraMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)):this._bufferedScreenMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)),u=this.screenGeometryMercator.map(n=>i.getTileVec3(r.tileTransform,n,l)),h=u.map(r=>new i.pointGeometry(r[0],r[1])),d=n.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),p=i.getTileVec3(r.tileTransform,d,l),f=u.map(r=>{const n=i.sub(r,r,p);return i.normalize(n,n),new i.Ray(p,n)}),m=C(r,1,n.zoom);if(i.polygonIntersectsBox(c,0,0,i.EXTENT,i.EXTENT))return{queryGeometry:this,tilespaceGeometry:h,tilespaceRays:f,bufferedTilespaceGeometry:c,bufferedTilespaceBounds:((s=i.getBounds(c)).min.x=i.clamp(s.min.x,0,i.EXTENT),s.min.y=i.clamp(s.min.y,0,i.EXTENT),s.max.x=i.clamp(s.max.x,0,i.EXTENT),s.max.y=i.clamp(s.max.y,0,i.EXTENT),s),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(i,r){const n=F(i);if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{const o=this.bufferedScreenGeometry(i).map(i=>r.pointCoordinate3D(i));return this._screenRaycastCache[n]=o,o}}_bufferedCameraMercator(i,r){const n=F(i);if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{const o=this.bufferedCameraGeometry(i).map(i=>r.pointCoordinate3D(i));return this._cameraRaycastCache[n]=o,o}}}function F(i){return 100*i|0}function O(r,n,o){const s=function(s,a){if(s)return o(s);if(a){const l=i.pick(i.extend(a,r),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding",]);a.vector_layers&&(l.vectorLayers=a.vector_layers,l.vectorLayerIds=l.vectorLayers.map(i=>i.id)),l.tiles=n.canonicalizeTileset(l,r.url),o(null,l)}};return r.url?i.getJSON(n.transformRequest(n.normalizeSourceURL(r.url),i.ResourceType.Source),s):i.exported.frame(()=>s(null,r))}class U{constructor(r,n,o){this.bounds=i.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(i){return Array.isArray(i)&&4===i.length?[Math.max(-180,i[0]),Math.max(-90,i[1]),Math.min(180,i[2]),Math.min(90,i[3]),]:[-180,-90,180,90]}contains(r){const n=Math.pow(2,r.z),o=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*n),s=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*n),a=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*n),l=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*n);return r.x>=o&&r.x=s&&r.y{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new U(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(i){this.map=i,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loadTile(r,n){const o=i.exported.devicePixelRatio>=2,s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(o,s,a,l)=>{if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(s){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:a,expires:l});const c=this.map.painter.context,u=c.gl;r.texture=this.map.painter.getTileTexture(s.width),r.texture?r.texture.update(s,{useMipmap:!0}):(r.texture=new i.Texture(c,s,u.RGBA,{useMipmap:!0}),r.texture.bind(u.LINEAR,u.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&u.texParameterf(u.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),r.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),n(null)}})}abortTile(i,r){i.request&&(i.request.cancel(),delete i.request),r()}unloadTile(i,r){i.texture&&this.map.painter.saveTileTexture(i.texture),r()}hasTransition(){return!1}}let j;function N(r,n,o,s,a,l,c,u){const h=[r,o,a,n,s,l,1,1,1],d=[c,u,1],p=i.adjoint([],h),[f,m,g]=i.transformMat3(d,d,i.transpose(p,p));return i.multiply(h,[f,0,0,0,m,0,0,0,g],h)}class G extends i.Evented{constructor(i,r,n,o){super(),this.id=i,this.dispatcher=n,this.coordinates=r.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=r}load(r,n){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(o,s)=>{this._loaded=!0,o?this.fire(new i.ErrorEvent(o)):s&&(this.image=i.exported.getImageData(s),this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),n&&n(),this._finishLoading())})}loaded(){return this._loaded}updateImage(i){return this.image&&i.url&&(this.options.url=i.url,this.load(i.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(i){this.map=i,this.load()}setCoordinates(r){this.coordinates=r,delete this._boundsArray;const n=r.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(r){let n=1/0,o=1/0,s=-1/0,a=-1/0;for(const l of r)n=Math.min(n,l.x),o=Math.min(o,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y);const c=Math.max(s-n,a-o),u=Math.max(0,Math.floor(-Math.log(c)/Math.LN2)),h=Math.pow(2,u);return new i.CanonicalTileID(u,Math.floor((n+s)/2*h),Math.floor((o+a)/2*h))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const r=i.tileTransform(this.tileID,this.map.transform.projection),[n,o,s,a]=this.coordinates.map(n=>{const o=r.projection.project(n[0],n[1]);return i.getTilePoint(r,o)._round()});return this.perspectiveTransform=function(r,n,o,s,a,l,c,u,h,d){const p=N(0,0,r,0,0,n,r,n),f=N(o,s,a,l,c,u,h,d);return i.multiply(f,i.adjoint(p,p),f),[f[6]/f[8]*r/i.EXTENT,f[7]/f[8]*n/i.EXTENT,]}(this.width,this.height,n.x,n.y,o.x,o.y,a.x,a.y,s.x,s.y),this._boundsArray=new i.StructArrayLayout4i8,this._boundsArray.emplaceBack(n.x,n.y,0,0),this._boundsArray.emplaceBack(o.x,o.y,i.EXTENT,0),this._boundsArray.emplaceBack(a.x,a.y,0,i.EXTENT),this._boundsArray.emplaceBack(s.x,s.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const r=this.map.painter.context,n=r.gl;for(const o in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new i.Texture(r,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}loadTile(i,r){this.tileID&&this.tileID.equals(i.tileID.canonical)?(this.tiles[String(i.tileID.wrap)]=i,i.buckets={},r(null)):(i.state="errored",r(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const Z={vector:class extends i.Evented{constructor(r,n,o,s){if(super(),this.id=r,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,i.extend(this,i.pick(n,["url","scheme","tileSize","promoteId",])),this._options=i.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(s),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=O(this._options,this.map._requestManager,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new U(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}onAdd(i){this.map=i,this.load()}setSourceProperty(i){this._tileJSONRequest&&this._tileJSONRequest.cancel(),i();const r=this.map.style._getSourceCaches(this.id);for(const n of r)n.clearTiles();this.load()}setTiles(i){return this.setSourceProperty(()=>{this._options.tiles=i}),this}setUrl(i){return this.setSourceProperty(()=>{this.url=i,this._options.url=i}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),s={request:this.map._requestManager.transformRequest(o,i.ResourceType.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile};if(s.request.collectResourceTiming=this._collectResourceTiming,r.actor&&"expired"!==r.state)"loading"===r.state?r.reloadCallback=n:r.request=r.actor.send("reloadTile",s,l.bind(this));else if(r.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",s,l.bind(this),void 0,!0);else{const a=i.loadVectorTile.call({deduped:this._deduped},s,(i,n)=>{i||!n?l.call(this,i):(s.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},r.actor&&r.actor.send("loadTile",s,l.bind(this),void 0,!0))},!0);r.request={cancel:a}}function l(o,s){return delete r.request,r.aborted?n(null):o&&404!==o.status?n(o):(s&&s.resourceTiming&&(r.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&r.setExpiryData(s),r.loadVectorData(s,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.actor&&i.actor.send("abortTile",{uid:i.uid,type:this.type,source:this.id})}unloadTile(i){i.unloadVectorData(),i.actor&&i.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:V,"raster-dem":class extends V{constructor(r,n,o,s){super(r,n,o,s),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function s(i,o){i&&(r.state="errored",n(i)),o&&(r.dem=o,r.dem.onDeserialize(),r.needsHillshadePrepare=!0,r.needsDEMTextureUpload=!0,r.state="loaded",n(null))}r.request=i.getImage(this.map._requestManager.transformRequest(o,i.ResourceType.Tile),(function(o,a,l,c){if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(a){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:l,expires:c});const u=i.window.ImageBitmap&&a instanceof i.window.ImageBitmap&&(null==j&&(j=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof i.window.createImageBitmap),j),h=1-(a.width-i.prevPowerOfTwo(a.width))/2;h<1||r.neighboringTiles||(r.neighboringTiles=this._getNeighboringTiles(r.tileID));const d=u?a:i.exported.getImageData(a,h),p={uid:r.uid,coord:r.tileID,source:this.id,rawImageData:d,encoding:this.encoding,padding:h};r.actor&&"expired"!==r.state||(r.actor=this.dispatcher.getActor(),r.actor.send("loadDEMTile",p,s.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(r){const n=r.canonical,o=Math.pow(2,n.z),s=(n.x-1+o)%o,a=0===n.x?r.wrap-1:r.wrap,l=(n.x+1+o)%o,c=n.x+1===o?r.wrap+1:r.wrap,u={};return u[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y).key]={backfilled:!1},u[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y).key]={backfilled:!1},n.y>0&&(u[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y-1).key]={backfilled:!1},u[new i.OverscaledTileID(r.overscaledZ,r.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},u[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new i.ErrorEvent(r));else{const o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(o.resourceTiming=n.resourceTiming[this.id]),this.fire(new i.Event("data",o)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(r,n){const o=r.actor?"reloadTile":"loadTile";r.actor=this.actor,r.request=this.actor.send(o,{type:this.type,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(i,s)=>(delete r.request,r.unloadVectorData(),r.aborted?n(null):i?n(i):(r.loadVectorData(s,this.map.painter,"reloadTile"===o),n(null))),void 0,"loadTile"===o)}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.aborted=!0}unloadTile(i){i.unloadVectorData(),this.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends G{constructor(i,r,n,o){super(i,r,n,o),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const r=this.options;for(const n of(this.urls=[],r.urls))this.urls.push(this.map._requestManager.transformRequest(n,i.ResourceType.Source).url);i.getVideo(this.urls,(r,n)=>{this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(this.video=n,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(r){if(this.video){const n=this.video.seekable;rn.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=r}}getVideo(){return this.video}onAdd(i){this.map||(this.map=i,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const r=this.map.painter.context,n=r.gl;for(const o in 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 i.Texture(r,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:G,canvas:class extends G{constructor(r,n,o,s){super(r,n,o,s),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(i=>!Array.isArray(i)||2!==i.length||i.some(i=>"number"!=typeof i))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,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 i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.ErrorEvent(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(i){this.map=i,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let r=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,r=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,r=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const n=this.map.painter.context,o=n.gl;for(const s in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(r||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(n,this.canvas,o.RGBA,{premultiply:!0}),this.tiles){const a=this.tiles[s];"loaded"!==a.state&&(a.state="loaded",a.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const i of[this.canvas.width,this.canvas.height,])if(isNaN(i)||i<=0)return!0;return!1}}},q=function(r,n,o,s){const a=new Z[n.type](r,n,o,s);if(a.id!==r)throw Error(`Expected Source id to be ${r} instead of ${a.id}`);return i.bindAll(["load","abort","unload","serialize","prepare",],a),a};function X(r,n){const o=i.identity([]);return i.scale(o,o,[.5*r.width,-(.5*r.height),1,]),i.translate(o,o,[1,-1,0]),i.multiply$1(o,o,r.calculateProjMatrix(n.toUnwrapped()))}function W(i,r,n,o,s,a,l,c=!1){const u=i.tilesIn(o,l,c);u.sort(K);const h=[];for(const d of u)h.push({wrappedTileID:d.tile.tileID.wrapped().key,queryResults:d.tile.queryRenderedFeatures(r,n,i._state,d,s,a,X(i.transform,d.tile.tileID),c)});const p=function(i){const r={},n={};for(const o of i){const s=o.queryResults,a=o.wrappedTileID,l=n[a]=n[a]||{};for(const c in s){const u=s[c],h=l[c]=l[c]||{},d=r[c]=r[c]||[];for(const p of u)h[p.featureIndex]||(h[p.featureIndex]=!0,d.push(p))}}return r}(h);for(const f in p)p[f].forEach(r=>{const n=r.feature,o=i.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});return p}function H(i,r){const n=i.getRenderableIds().map(r=>i.getTileByID(r)),o=[],s={};for(let a=0;a{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[J]}numActive(){return Object.keys(this.active).length}}let ee;function et(){return ee||(ee=new Q),ee}function ei(r,n){const o={};for(const s in r)"ref"!==s&&(o[s]=r[s]);return i.refProperties.forEach(i=>{i in n&&(o[i]=n[i])}),o}function er(i){i=i.slice();const r=Object.create(null);for(let n=0;n0?(s-l)/c:0;return this.points[a].mult(1-u).add(this.points[n].mult(u))}}class ep{constructor(i,r,n){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(i/n),this.yCellCount=Math.ceil(r/n);for(let a=0;athis.width||o<0||r>this.height)return!s&&[];const l=[];if(i<=0&&r<=0&&this.width<=n&&this.height<=o){if(s)return!0;for(let c=0;c0:l}_queryCircle(i,r,n,o,s){const a=i-n,l=i+n,c=r-n,u=r+n;if(l<0||a>this.width||u<0||c>this.height)return!o&&[];const h=[];return this._forEachCell(a,c,l,u,this._queryCellCircle,h,{hitTest:o,circle:{x:i,y:r,radius:n},seenUids:{box:{},circle:{}}},s),o?h.length>0:h}query(i,r,n,o,s){return this._query(i,r,n,o,!1,s)}hitTest(i,r,n,o,s){return this._query(i,r,n,o,!0,s)}hitTestCircle(i,r,n,o){return this._queryCircle(i,r,n,!0,o)}_queryCell(i,r,n,o,s,a,l,c){const u=l.seenUids,h=this.boxCells[s];if(null!==h){const d=this.bboxes;for(const p of h)if(!u.box[p]){u.box[p]=!0;const f=4*p;if(i<=d[f+2]&&r<=d[f+3]&&n>=d[f+0]&&o>=d[f+1]&&(!c||c(this.boxKeys[p]))){if(l.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[p],x1:d[f],y1:d[f+1],x2:d[f+2],y2:d[f+3]})}}}const m=this.circleCells[s];if(null!==m){const g=this.circles;for(const y of m)if(!u.circle[y]){u.circle[y]=!0;const x=3*y;if(this._circleAndRectCollide(g[x],g[x+1],g[x+2],i,r,n,o)&&(!c||c(this.circleKeys[y]))){if(l.hitTest)return a.push(!0),!0;{const $=g[x],v=g[x+1],_=g[x+2];a.push({key:this.circleKeys[y],x1:$-_,y1:v-_,x2:$+_,y2:v+_})}}}}}_queryCellCircle(i,r,n,o,s,a,l,c){const u=l.circle,h=l.seenUids,d=this.boxCells[s];if(null!==d){const p=this.bboxes;for(const f of d)if(!h.box[f]){h.box[f]=!0;const m=4*f;if(this._circleAndRectCollide(u.x,u.y,u.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!c||c(this.boxKeys[f])))return a.push(!0),!0}}const g=this.circleCells[s];if(null!==g){const y=this.circles;for(const x of g)if(!h.circle[x]){h.circle[x]=!0;const $=3*x;if(this._circlesCollide(y[$],y[$+1],y[$+2],u.x,u.y,u.radius)&&(!c||c(this.circleKeys[x])))return a.push(!0),!0}}}_forEachCell(i,r,n,o,s,a,l,c){const u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(r),d=this._convertToXCellCoord(n),p=this._convertToYCellCoord(o);for(let f=u;f<=d;f++)for(let m=h;m<=p;m++)if(s.call(this,i,r,n,o,this.xCellCount*m+f,a,l,c))return}_convertToXCellCoord(i){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(i*this.xScale)))}_convertToYCellCoord(i){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(i*this.yScale)))}_circlesCollide(i,r,n,o,s,a){const l=o-i,c=s-r,u=n+a;return u*u>l*l+c*c}_circleAndRectCollide(i,r,n,o,s,a,l){const c=(a-o)/2,u=Math.abs(i-(o+c));if(u>c+n)return!1;const h=(l-s)/2,d=Math.abs(r-(s+h));if(d>h+n)return!1;if(u<=c||d<=h)return!0;const p=u-c,f=d-h;return p*p+f*f<=n*n}}const ef=Math.tan(85*Math.PI/180);function em(r,n,o,a,l,c){let u=i.create();if(o){if("globe"===l.projection.name)u=i.calculateGlobeMatrix(l,l.worldSize/l._projectionScaler,[0,0]),i.multiply$1(u,u,i.globeDenormalizeECEF(i.globeTileBounds(n)));else{const h=s([],c);u[0]=h[0],u[1]=h[1],u[4]=h[2],u[5]=h[3]}a||i.rotateZ(u,u,l.angle)}else i.multiply$1(u,l.labelPlaneMatrix,r);return u}function e8(r,n,o,s,a,l){if(o){if("globe"===a.projection.name){const c=em(r,n,o,s,a,l);return i.invert(c,c),i.multiply$1(c,r,c),c}{const u=i.clone(r),h=i.identity([]);return h[0]=l[0],h[1]=l[1],h[4]=l[2],h[5]=l[3],i.multiply$1(u,u,h),s||i.rotateZ(u,u,-a.angle),u}}return a.glCoordMatrix}function eg(r,n,o=0){const s=[r.x,r.y,o,1];o?i.transformMat4$1(s,s,n):eI(s,s,n);const a=s[3];return{point:new i.pointGeometry(s[0]/a,s[1]/a),signedDistanceFromCamera:a}}function ey(i,r){return Math.min(.5+i/r*.5,1.5)}function ex(i,r){const n=i[0]/i[3],o=i[1]/i[3];return n>=-r[0]&&n<=r[0]&&o>=-r[1]&&o<=r[1]}function e$(r,n,o,s,a,l,c,u,h,d){const p=o.transform,f=s?r.textSizeData:r.iconSizeData,m=i.evaluateSizeForZoom(f,o.transform.zoom),g=[256/o.width*2+1,256/o.height*2+1,],y=s?r.text.dynamicLayoutVertexArray:r.icon.dynamicLayoutVertexArray;y.clear();const x=r.lineVertexArray,$=s?r.text.placedSymbolArray:r.icon.placedSymbolArray,v=o.transform.width/o.transform.height;let _=!1;for(let b=0;b<$.length;b++){const w=$.get(b);if(w.writingMode!==i.WritingMode.vertical||_||0!==b&&$.get(b-1).writingMode===i.WritingMode.horizontal||(_=!0),w.hidden||w.writingMode===i.WritingMode.vertical&&!_){eS(w.numGlyphs,y);continue}_=!1;const T=new i.pointGeometry(w.tileAnchorX,w.tileAnchorY),E=h?h(T):[0,0,0],S=p.projection.projectTilePoint(T.x,T.y,d.canonical),I=[S.x+E[0],S.y+E[1],S.z+E[2]],C=[...I,1];if(i.transformMat4$1(C,C,n),!ex(C,g)){eS(w.numGlyphs,y);continue}const z=ey(o.transform.cameraToCenterDistance,C[3]),A=i.evaluateSizeForFeature(f,m,w),k=c?A/z:A*z,P=eg(new i.pointGeometry(I[0],I[1]),a,I[2]);if(P.signedDistanceFromCamera<=0){eS(w.numGlyphs,y);continue}let D={};const L=c?null:h,B=eb(w,k,!1,u,n,a,l,r.glyphOffsetArray,x,y,P.point,T,D,v,L,p.projection,d);_=B.useVertical,L&&B.needsFlipping&&(D={}),(B.notEnoughRoom||_||B.needsFlipping&&eb(w,k,!0,u,n,a,l,r.glyphOffsetArray,x,y,P.point,T,D,v,L,p.projection,d).notEnoughRoom)&&eS(w.numGlyphs,y)}s?r.text.dynamicLayoutVertexBuffer.updateData(y):r.icon.dynamicLayoutVertexBuffer.updateData(y)}function ev(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g){const y=c.glyphStartIndex+c.numGlyphs,x=c.lineStartIndex,$=c.lineStartIndex+c.lineLength,v=r.getoffsetX(c.glyphStartIndex),_=r.getoffsetX(y-1),b=eT(i*v,n,o,s,a,l,c.segment,x,$,u,h,d,p,f,!0,m,g);if(!b)return null;const w=eT(i*_,n,o,s,a,l,c.segment,x,$,u,h,d,p,f,!0,m,g);return w?{first:b,last:w}:null}function e_(r,n,o,s){return r.writingMode===i.WritingMode.horizontal&&Math.abs(o.y-n.y)>Math.abs(o.x-n.x)*s?{useVertical:!0}:r.writingMode===i.WritingMode.vertical?n.yef}(n,o,s)?1===r.flipState?{needsFlipping:!0}:null:n.x>o.x?{needsFlipping:!0}:null}function eb(r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$){const v=n/24,_=r.lineOffsetX*v,b=r.lineOffsetY*v;let w;if(r.numGlyphs>1){const T=r.glyphStartIndex+r.numGlyphs,E=r.lineStartIndex,S=r.lineStartIndex+r.lineLength,I=ev(v,u,_,b,o,p,f,r,h,l,m,y,!1,x,$);if(!I)return{notEnoughRoom:!0};const C=eg(I.first.point,c).point,z=eg(I.last.point,c).point;if(s&&!o){const A=e_(r,C,z,g);if(r.flipState=A&&A.needsFlipping?1:2,A)return A}w=[I.first];for(let k=r.glyphStartIndex+1;k0?B.point:e0(f,L,P,1,a,void 0,x,$.canonical),g);if(r.flipState=R&&R.needsFlipping?1:2,R)return R}const M=eT(v*u.getoffsetX(r.glyphStartIndex),_,b,o,p,f,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,h,l,m,y,!1,!1,x,$);if(!M)return{notEnoughRoom:!0};w=[M]}for(const F of w)i.addDynamicAttributes(d,F.point,F.angle);return{}}function ew(r,n,o,s,a){const l=s.projectTilePoint(r.x,r.y,n);if(!a)return eg(l,o,l.z);const c=a(r);return eg(new i.pointGeometry(l.x+c[0],l.y+c[1]),o,l.z+c[2])}function e0(i,r,n,o,s,a,l,c){const u=ew(i.add(i.sub(r)._unit()),c,s,l,a).point,h=n.sub(u);return n.add(h._mult(o/h.mag()))}function eT(r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$){const v=s?r-n:r+n;let _=v>0?1:-1,b=0;s&&(_*=-1,b=Math.PI),_<0&&(b+=Math.PI);let w=_>0?u+c:u+c+1,T=a,E=a,S=0,I=0;const C=Math.abs(v),z=[],A=[];let k=l;const P=()=>{const r=w-_;return 0===S?l:new i.pointGeometry(d.getx(r),d.gety(r))},D=()=>e0(P(),k,E,C-S+1,p,m,x,$.canonical);for(;S+I<=C;){if((w+=_)=h)return null;if(E=T,z.push(T),g&&A.push(k||P()),void 0===(T=f[w])){k=new i.pointGeometry(d.getx(w),d.gety(w));const L=ew(k,$.canonical,p,x,m);T=L.signedDistanceFromCamera>0?f[w]=L.point:D()}else k=null;S+=I,I=E.dist(T)}y&&m&&(k=k||new i.pointGeometry(d.getx(w),d.gety(w)),f[w]=T=void 0===f[w]?T:D(),I=E.dist(T));const B=(C-S)/I,R=T.sub(E),M=R.mult(B)._add(E);o&&M._add(R._unit()._perp()._mult(o*_));const F=b+Math.atan2(T.y-E.y,T.x-E.x);return z.push(M),g&&(k=k||new i.pointGeometry(d.getx(w),d.gety(w)),A.push(function(r,n,o){const s=1-o;return new i.pointGeometry(r.x*s+n.x*o,r.y*s+n.y*o)}(A.length>0?A[A.length-1]:k,k,B))),{point:M,angle:F,path:z,tilePath:A}}const eE=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,]);function eS(i,r){for(let n=0;ni.sortKey-r.sortKey));this._currentPartIndex[0,0,0],_=new i.pointGeometry(n.tileAnchorX,n.tileAnchorY),b=this.transform.projection.projectTilePoint(n.tileAnchorX,n.tileAnchorY,g.canonical),w=v(_),T=[b.x+w[0],b.y+w[1],b.z+w[2]],E=this.projectAndGetPerspectiveRatio(l,T[0],T[1],T[2],g),{perspectiveRatio:S}=E,I=(d?a/S:a*S)/i.ONE_EM,C=eg(new i.pointGeometry(T[0],T[1]),c,T[2]).point,z=E.signedDistanceFromCamera>0?ev(I,s,n.lineOffsetX*I,n.lineOffsetY*I,!1,C,_,n,o,c,{},x&&!d?v:null,d&&!!x,this.transform.projection,g):null;let A=!1,k=!1,P=!0;if(z&&!E.aboveHorizon){const D=.5*f*S+m,L=new i.pointGeometry(-100,-100),B=new i.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),R=new ed,M=z.first,F=z.last;let O=[];for(let U=M.path.length-1;U>=1;U--)O.push(M.path[U]);for(let V=1;V{const n=v(reg(i,u));O=N.some(i=>i.signedDistanceFromCamera<=0)?[]:N.map(i=>i.point)}let G=[];if(O.length>0){const Z=O[0].clone(),q=O[0].clone();for(let X=1;X=L.x&&q.x<=B.x&&Z.y>=L.y&&q.y<=B.y?[O]:q.xB.x||q.yB.y?[]:i.clipLine([O],L.x,L.y,B.x,B.y)}for(const W of G){R.reset(W,.25*D);let H=0;H=R.length<=.5*D?1:Math.ceil(R.paddedLength/j)+1;for(let K=0;K0){i.transformMat4$1(l,l,r);let u=!1;this.fogState&&a&&(u=function(r,n,o,s,a,l){const c=l.calculateFogTileMatrix(a),u=[n,o,s];return i.transformMat4(u,u,c),b(r,u,l.pitch,l._fov)}(this.fogState,n,o,s||0,a.toUnwrapped(),this.transform)>.9),c=l[2]>l[3]||u}else eI(l,l,r);return{point:new i.pointGeometry((l[0]/l[3]+1)/2*this.transform.width+100,(-l[1]/l[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/l[3]*.5,1.5),signedDistanceFromCamera:l[3],aboveHorizon:c}}isOffscreen(i,r,n,o){return n<100||i>=this.screenRightBoundary||o<100||r>this.screenBottomBoundary}isInsideGrid(i,r,n,o){return n>=0&&i=0&&ri.collisionGroupID===r}}return this.collisionGroups[i]}}(o),this.collisionCircleArrays={},this.prevPlacement=s,s&&(s.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,n,o,s){const a=o.getBucket(n),l=o.latestFeatureIndex;if(!a||!l||n.id!==a.layerIds[0])return;const c=a.layers[0].layout,u=o.collisionBoxArray,h=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),d=o.tileSize/i.EXTENT,p=o.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(p),m="map"===c.get("text-pitch-alignment"),g="map"===c.get("text-rotation-alignment");n.compileFilter();const y=n.dynamicFilter(),x=n.dynamicFilterNeedsFeature(),$=this.transform.calculatePixelsToTileUnitsMatrix(o),v=em(f,o.tileID.canonical,m,g,this.transform,$);let _=null;if(m){const b=e8(f,o.tileID.canonical,m,g,this.transform,$);_=i.multiply$1([],this.transform.labelPlaneMatrix,b)}let w=null;y&&o.latestFeatureIndex&&(w={unwrappedTileID:p,dynamicFilter:y,dynamicFilterNeedsFeature:x,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[a.bucketInstanceId]=new eP(a.bucketInstanceId,l,a.sourceLayerIndex,a.index,o.tileID);const T={bucket:a,layout:c,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:_,clippingData:w,scale:h,textPixelRatio:d,holdingForFade:o.holdingForFade(),collisionBoxArray:u,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(a.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(a.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(s)for(const E of a.sortKeyRanges){const{sortKey:S,symbolInstanceStart:I,symbolInstanceEnd:C}=E;r.push({sortKey:S,symbolInstanceStart:I,symbolInstanceEnd:C,parameters:T})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:T})}attemptAnchorPlacement(i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,y,x,$){const v=[p.textOffset0,p.textOffset1],_=eD(i,n,o,v,s),b=this.collisionIndex.placeCollisionBox(s,r,eL(_.x,_.y,a,l,this.transform.angle),d,c,u,h.predicate);if((!y||0!==this.collisionIndex.placeCollisionBox(m.getSymbolInstanceIconSize($,this.transform.zoom,f),y,eL(_.x,_.y,a,l,this.transform.angle),d,c,u,h.predicate).box.length)&&b.box.length>0){let w;return this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(w=this.prevPlacement.variableOffsets[p.crossTileID].anchor),this.variableOffsets[p.crossTileID]={textOffset:v,width:n,height:o,anchor:i,textScale:s,prevAnchor:w},this.markUsedJustification(m,i,p,g),m.allowVerticalPlacement&&(this.markUsedOrientation(m,g,p),this.placedOrientations[p.crossTileID]=g),{shift:_,placedGlyphBoxes:b}}}placeLayerBucketPart(r,n,o,s){const{bucket:a,layout:l,posMatrix:c,textLabelPlaneMatrix:u,labelToScreenMatrix:h,clippingData:d,textPixelRatio:p,holdingForFade:f,collisionBoxArray:m,partiallyEvaluatedTextSize:g,partiallyEvaluatedIconSize:y,collisionGroup:x}=r.parameters,$=l.get("text-optional"),v=l.get("icon-optional"),_=l.get("text-allow-overlap"),b=l.get("icon-allow-overlap"),w="map"===l.get("text-rotation-alignment"),T="map"===l.get("text-pitch-alignment"),E="none"!==l.get("icon-text-fit"),S="viewport-y"===l.get("symbol-z-order"),I=_&&(b||!a.hasIconData()||v),C=b&&(_||!a.hasTextData()||$);!a.collisionArrays&&m&&a.deserializeCollisionBoxes(m),o&&s&&a.updateCollisionDebugBuffers(this.transform.zoom,m);const z=(r,s,m)=>{if(d){const S={zoom:this.transform.zoom,pitch:this.transform.pitch};let z=null;if(d.dynamicFilterNeedsFeature){const A=this.retainedQueryData[a.bucketInstanceId];z=d.featureIndex.loadFeature({featureIndex:r.featureIndex,bucketIndex:A.bucketIndex,sourceLayerIndex:A.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,d.dynamicFilter)(S,z,this.retainedQueryData[a.bucketInstanceId].tileID.canonical,new i.pointGeometry(r.tileAnchorX,r.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[r.crossTileID]=new eA(!1,!1,!1,!0),void(n[r.crossTileID]=!0)}if(n[r.crossTileID])return;if(f)return void(this.placements[r.crossTileID]=new eA(!1,!1,!1));let k=!1,P=!1,D=!0,L=null,B={box:null,offscreen:null},R={box:null,offscreen:null},M=null,F=null,O=null,U=0,V=0,j=0;m.textFeatureIndex?U=m.textFeatureIndex:r.useRuntimeCollisionCircles&&(U=r.featureIndex),m.verticalTextFeatureIndex&&(V=m.verticalTextFeatureIndex);const N=i=>{i.tileID=this.retainedQueryData[a.bucketInstanceId].tileID,(this.transform.elevation||i.elevation)&&(i.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[a.bucketInstanceId].tileID,i.tileAnchorX,i.tileAnchorY):0)},G=m.textBox;if(G){N(G);const Z=n=>{let o=i.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[r.crossTileID];s&&(this.placedOrientations[r.crossTileID]=s,o=s,this.markUsedOrientation(a,o,r))}return o},q=(n,o)=>{if(a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&m.verticalTextBox){for(const s of a.writingModes)if(s===i.WritingMode.vertical?R=B=o():B=n(),B&&B.box&&B.box.length)break}else B=n()};if(l.get("text-variable-anchor")){let X=l.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[r.crossTileID]){const W=this.prevPlacement.variableOffsets[r.crossTileID];X.indexOf(W.anchor)>0&&(X=X.filter(i=>i!==W.anchor)).unshift(W.anchor)}const H=(i,n,o)=>{const l=a.getSymbolInstanceTextSize(g,r,this.transform.zoom,s),u=(i.x2-i.x1)*l+2*i.padding,h=(i.y2-i.y1)*l+2*i.padding,d=E&&!b?n:null;d&&N(d);let f={box:[],offscreen:!1};const m=_?2*X.length:X.length;for(let $=0;$=X.length,r,s,a,o,d,g,y);if(v&&(f=v.placedGlyphBoxes)&&f.box&&f.box.length){k=!0,L=v.shift;break}}return f};q(()=>H(G,m.iconBox,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return n&&N(n),a.allowVerticalPlacement&&!(B&&B.box&&B.box.length)&&r.numVerticalGlyphVertices>0&&n?H(n,m.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null}}),B&&(k=B.box,D=B.offscreen);const K=Z(B&&B.box);if(!k&&this.prevPlacement){const Y=this.prevPlacement.variableOffsets[r.crossTileID];Y&&(this.variableOffsets[r.crossTileID]=Y,this.markUsedJustification(a,Y.anchor,r,K))}}else{const J=(n,o)=>{const l=a.getSymbolInstanceTextSize(g,r,this.transform.zoom,s),u=this.collisionIndex.placeCollisionBox(l,n,new i.pointGeometry(0,0),_,p,c,x.predicate);return u&&u.box&&u.box.length&&(this.markUsedOrientation(a,o,r),this.placedOrientations[r.crossTileID]=o),u};q(()=>J(G,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&n?(N(n),J(n,i.WritingMode.vertical)):{box:null,offscreen:null}}),Z(B&&B.box&&B.box.length)}}if(k=(M=B)&&M.box&&M.box.length>0,D=M&&M.offscreen,r.useRuntimeCollisionCircles){const Q=a.text.placedSymbolArray.get(r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex),ee=i.evaluateSizeForFeature(a.textSizeData,g,Q),et=l.get("text-padding");F=this.collisionIndex.placeCollisionCircles(_,Q,a.lineVertexArray,a.glyphOffsetArray,ee,c,u,h,o,T,x.predicate,r.collisionCircleDiameter*ee/i.ONE_EM,et,this.retainedQueryData[a.bucketInstanceId].tileID),k=_||F.circles.length>0&&!F.collisionDetected,D=D&&F.offscreen}if(m.iconFeatureIndex&&(j=m.iconFeatureIndex),m.iconBox){const ei=r=>{N(r);const n=E&&L?eL(L.x,L.y,w,T,this.transform.angle):new i.pointGeometry(0,0),o=a.getSymbolInstanceIconSize(y,this.transform.zoom,s);return this.collisionIndex.placeCollisionBox(o,r,n,b,p,c,x.predicate)};P=R&&R.box&&R.box.length&&m.verticalIconBox?(O=ei(m.verticalIconBox)).box.length>0:(O=ei(m.iconBox)).box.length>0,D=D&&O.offscreen}const er=$||0===r.numHorizontalGlyphVertices&&0===r.numVerticalGlyphVertices,en=v||0===r.numIconVertices;if(er||en?en?er||(P=P&&k):k=P&&k:P=k=P&&k,k&&M&&M.box&&this.collisionIndex.insertCollisionBox(M.box,l.get("text-ignore-placement"),a.bucketInstanceId,R&&R.box&&V?V:U,x.ID),P&&O&&this.collisionIndex.insertCollisionBox(O.box,l.get("icon-ignore-placement"),a.bucketInstanceId,j,x.ID),F&&(k&&this.collisionIndex.insertCollisionCircles(F.circles,l.get("text-ignore-placement"),a.bucketInstanceId,U,x.ID),o)){const eo=a.bucketInstanceId;let es=this.collisionCircleArrays[eo];void 0===es&&(es=this.collisionCircleArrays[eo]=new ek);for(let ea=0;ea=0;--k){const P=A[k];z(a.symbolInstances.get(P),P,a.collisionArrays[P])}}else for(let D=r.symbolInstanceStart;D=0&&(r.text.placedSymbolArray.get(c).crossTileID=a>=0&&c!==a?0:o.crossTileID)}markUsedOrientation(r,n,o){const s=n===i.WritingMode.horizontal||n===i.WritingMode.horizontalOnly?n:0,a=n===i.WritingMode.vertical?n:0,l=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex,];for(const c of l)r.text.placedSymbolArray.get(c).placedOrientation=s;o.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(i){this.commitTime=i,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let n=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const o=r?r.symbolFadeChange(i):1,s=r?r.opacities:{},a=r?r.variableOffsets:{},l=r?r.placedOrientations:{};for(const c in this.placements){const u=this.placements[c],h=s[c];h?(this.opacities[c]=new ez(h,o,u.text,u.icon,null,u.clipped),n=n||u.text!==h.text.placed||u.icon!==h.icon.placed):(this.opacities[c]=new ez(null,o,u.text,u.icon,u.skipFade,u.clipped),n=n||u.text||u.icon)}for(const d in s){const p=s[d];if(!this.opacities[d]){const f=new ez(p,o,!1,!1);f.isHidden()||(this.opacities[d]=f,n=n||p.text.placed||p.icon.placed)}}for(const m in a)this.variableOffsets[m]||!this.opacities[m]||this.opacities[m].isHidden()||(this.variableOffsets[m]=a[m]);for(const g in l)this.placedOrientations[g]||!this.opacities[g]||this.opacities[g].isHidden()||(this.placedOrientations[g]=l[g]);n?this.lastPlacementChangeTime=i:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:i)}updateLayerOpacities(i,r){const n={};for(const o of r){const s=o.getBucket(i);s&&o.latestFeatureIndex&&i.id===s.layerIds[0]&&this.updateBucketOpacities(s,n,o.collisionBoxArray)}}updateBucketOpacities(r,n,o){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const s=r.layers[0].layout,a=!!r.layers[0].dynamicFilter(),l=new ez(null,0,!1,!1,!0),c=s.get("text-allow-overlap"),u=s.get("icon-allow-overlap"),h=s.get("text-variable-anchor"),d="map"===s.get("text-rotation-alignment"),p="map"===s.get("text-pitch-alignment"),f="none"!==s.get("icon-text-fit"),m=new ez(null,0,c&&(u||!r.hasIconData()||s.get("icon-optional")),u&&(c||!r.hasTextData()||s.get("text-optional")),!0);!r.collisionArrays&&o&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(o);const g=(i,r,n)=>{for(let o=0;o0||_>0,E=$.numIconVertices>0,S=this.placedOrientations[$.crossTileID],I=S===i.WritingMode.vertical,C=S===i.WritingMode.horizontal||S===i.WritingMode.horizontalOnly;if(!T&&!E||w.isHidden()||y++,T){const z=eB(w.text);g(r.text,v,I?0:z),g(r.text,_,C?0:z);const A=w.text.isHidden();[$.rightJustifiedTextSymbolIndex,$.centerJustifiedTextSymbolIndex,$.leftJustifiedTextSymbolIndex,].forEach(i=>{i>=0&&(r.text.placedSymbolArray.get(i).hidden=A||I?1:0)}),$.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get($.verticalPlacedTextSymbolIndex).hidden=A||C?1:0);const k=this.variableOffsets[$.crossTileID];k&&this.markUsedJustification(r,k.anchor,$,S);const P=this.placedOrientations[$.crossTileID];P&&(this.markUsedJustification(r,"left",$,P),this.markUsedOrientation(r,P,$))}if(E){const D=eB(w.icon);$.placedIconSymbolIndex>=0&&(g(r.icon,$.numIconVertices,I?0:D),r.icon.placedSymbolArray.get($.placedIconSymbolIndex).hidden=w.icon.isHidden()),$.verticalPlacedIconSymbolIndex>=0&&(g(r.icon,$.numVerticalIconVertices,C?0:D),r.icon.placedSymbolArray.get($.verticalPlacedIconSymbolIndex).hidden=w.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const L=r.collisionArrays[x];if(L){let B=new i.pointGeometry(0,0),R=!0;if(L.textBox||L.verticalTextBox){if(h){const M=this.variableOffsets[b];M?(B=eD(M.anchor,M.width,M.height,M.textOffset,M.textScale),d&&B._rotate(p?this.transform.angle:-this.transform.angle)):R=!1}a&&(R=!w.clipped),L.textBox&&e1(r.textCollisionBox.collisionVertexArray,w.text.placed,!R||I,B.x,B.y),L.verticalTextBox&&e1(r.textCollisionBox.collisionVertexArray,w.text.placed,!R||C,B.x,B.y)}const F=R&&Boolean(!C&&L.verticalIconBox);L.iconBox&&e1(r.iconCollisionBox.collisionVertexArray,w.icon.placed,F,f?B.x:0,f?B.y:0),L.verticalIconBox&&e1(r.iconCollisionBox.collisionVertexArray,w.icon.placed,!F,f?B.x:0,f?B.y:0)}}}if(r.fullyClipped=0===y,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const O=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=O.invProjMatrix,r.placementViewportMatrix=O.viewportMatrix,r.collisionCircleArray=O.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(i){return 0===this.fadeDuration?1:(i-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(i){return Math.max(0,(this.transform.zoom-i)/1.5)}hasTransitions(i){return this.stale||i-this.lastPlacementChangeTimei}setStale(){this.stale=!0}}(r,a,l,c,u),this._currentPlacementIndex=n.length-1,this._forceFullPlacement=o,this._showCollisionBoxes=s,this._done=!1}isDone(){return this._done}continuePlacement(r,n,o){const s=i.exported.now(),a=()=>{const r=i.exported.now()-s;return!this._forceFullPlacement&&r>2};for(;this._currentPlacementIndex>=0;){const l=n[r[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=c)&&(!l.maxzoom||l.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new eR(l)),this._inProgressLayer.continuePlacement(o[l.source],this.placement,this._showCollisionBoxes,l,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(i){return this.placement.commit(i),this.placement}}const eM=512/i.EXTENT/2;class e2{constructor(i,r,n){this.tileID=i,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(let o=0;oi.overscaledZ)for(const c in l){const u=l[c];u.tileID.isChildOf(i)&&u.findMatches(r.symbolInstances,i,s)}else{const h=l[i.scaledTo(Number(a)).key];h&&h.findMatches(r.symbolInstances,i,s)}}for(let d=0;d{r[i]=!0}),this.layerIndexes)r[n]||delete this.layerIndexes[n]}}const e4=(r,n)=>i.emitValidationErrors(r,n&&n.filter(i=>"source.canvas"!==i.identifier)),eU=i.pick(en,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection",]),eV=i.pick(en,["setCenter","setZoom","setBearing","setPitch",]),e6=function(){const r={},n=i.spec.$version;for(const o in i.spec.$root){const s=i.spec.$root[o];if(s.required){let a=null;null!=(a="version"===o?n:"array"===s.type?[]:{})&&(r[o]=a)}}return r}(),ej={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class eN extends i.Evented{constructor(r,n={}){super(),this.map=r,this.dispatcher=new I(et(),this),this.imageManager=new m,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(r._requestManager,n.localFontFamily?i.LocalGlyphMode.all:n.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.lineAtlas=new i.LineAtlas(256,512),this.crossTileSymbolIndex=new eO,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new i.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const o=this;this._rtlTextPluginCallback=eN.registerForPluginStateChange(r=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:r.pluginStatus,pluginURL:r.pluginURL},(r,n)=>{if(i.triggerPluginCompletionEvent(r),n&&n.every(i=>i))for(const s in o._sourceCaches){const a=o._sourceCaches[s],l=a.getSource().type;"vector"!==l&&"geojson"!==l||a.reload()}})}),this.on("data",i=>{if("source"!==i.dataType||"metadata"!==i.sourceDataType)return;const r=this.getSource(i.sourceId);if(r&&r.vectorLayerIds)for(const n in this._layers){const o=this._layers[n];o.source===r.id&&this._validateLayer(o)}})}loadURL(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const o="boolean"==typeof n.validate?n.validate:!i.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,n.accessToken);const s=this.map._requestManager.transformRequest(r,i.ResourceType.Style);this._request=i.getJSON(s,(r,n)=>{this._request=null,r?this.fire(new i.ErrorEvent(r)):n&&this._load(n,o)})}loadJSON(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(r,!1!==n.validate)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(e6,!1)}_updateLayerCount(i,r){const n=r?1:-1;i.is3D()&&(this._num3DLayers+=n),"circle"===i.type&&(this._numCircleLayers+=n),"symbol"===i.type&&(this._numSymbolLayers+=n)}_load(r,n){if(n&&e4(this,i.validateStyle(r)))return;for(const o in this._loaded=!0,this.stylesheet=r,this.updateProjection(),r.sources)this.addSource(o,r.sources[o],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const s=er(this.stylesheet.layers);for(let a of(this._order=s.map(i=>i.id),this._layers={},this._serializedLayers={},s))(a=i.createStyleLayer(a)).setEventedParent(this,{layer:{id:a.id}}),this._layers[a.id]=a,this._serializedLayers[a.id]=a.serialize(),this._updateLayerCount(a,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new x(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(i){i?this.stylesheet.projection=i:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const i=this.map.transform.projection,r=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),n=this.map.transform.projection;if(this._loaded&&(n.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),r){if(n.isReprojectedInTileSpace||i.isReprojectedInTileSpace)for(const o in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[o].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(r){this._spriteRequest=function(r,n,o){let s,a,l;const c=i.exported.devicePixelRatio>1?"@2x":"";let u=i.getJSON(n.transformRequest(n.normalizeSpriteURL(r,c,".json"),i.ResourceType.SpriteJSON),(i,r)=>{u=null,l||(l=i,s=r,d())}),h=i.getImage(n.transformRequest(n.normalizeSpriteURL(r,c,".png"),i.ResourceType.SpriteImage),(i,r)=>{h=null,l||(l=i,a=r,d())});function d(){if(l)o(l);else if(s&&a){const r=i.exported.getImageData(a),n={};for(const c in s){const{width:u,height:h,x:d,y:p,sdf:f,pixelRatio:m,stretchX:g,stretchY:y,content:x}=s[c],$=new i.RGBAImage({width:u,height:h});i.RGBAImage.copy(r,$,{x:d,y:p},{x:0,y:0},{width:u,height:h}),n[c]={data:$,pixelRatio:m,sdf:f,stretchX:g,stretchY:y,content:x}}o(null,n)}}return{cancel(){u&&(u.cancel(),u=null),h&&(h.cancel(),h=null)}}}(r,this.map._requestManager,(r,n)=>{if(this._spriteRequest=null,r)this.fire(new i.ErrorEvent(r));else if(n)for(const o in n)this.imageManager.addImage(o,n[o]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(r){const n=this.getSource(r.source);if(!n)return;const o=r.sourceLayer;o&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(o))&&this.fire(new i.ErrorEvent(Error(`Source layer "${o}" does not exist on source "${n.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const i in this._sourceCaches)if(!this._sourceCaches[i].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(i){const r=[];for(const n of i){const o=this._layers[n];"custom"!==o.type&&r.push(o.serialize())}return r}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const i in this._sourceCaches)if(this._sourceCaches[i].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(i){return!!this.terrain&&ej[i.type]}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}update(r){if(!this._loaded)return;const n=this._changed;if(this._changed){const o=Object.keys(this._updatedLayers),s=Object.keys(this._removedLayers);for(const a in(o.length||s.length)&&this._updateWorkerLayers(o,s),this._updatedSources){const l=this._updatedSources[a];"reload"===l?this._reloadSource(a):"clear"===l&&this._clearSource(a)}for(const c in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[c].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const u={};for(const h in this._sourceCaches){const d=this._sourceCaches[h];u[h]=d.used,d.used=!1}for(const p of this._order){const f=this._layers[p];if(f.recalculate(r,this._availableImages),!f.isHidden(r.zoom)){const m=this._getLayerSourceCache(f);m&&(m.used=!0)}const g=this.map.painter;if(g){const y=f.getProgramIds();if(!y)continue;const x=f.getProgramConfiguration(r.zoom);for(const $ of y)g.useProgram($,x)}}for(const v in u){const _=this._sourceCaches[v];u[v]!==_.used&&_.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:_.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const i=Object.keys(this._changedImages);if(i.length){for(const r in this._sourceCaches)this._sourceCaches[r].reloadTilesForDependencies(["icons","patterns"],i);this._changedImages={}}}_updateWorkerLayers(i,r){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(i),removedIds:r})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),e4(this,i.validateStyle(r)))return!1;(r=i.clone$1(r)).layers=er(r.layers);const n=(function(i,r){if(!i)return[{command:en.setStyle,args:[r]},];let n=[];try{if(!a(i.version,r.version))return[{command:en.setStyle,args:[r]},];a(i.center,r.center)||n.push({command:en.setCenter,args:[r.center]}),a(i.zoom,r.zoom)||n.push({command:en.setZoom,args:[r.zoom]}),a(i.bearing,r.bearing)||n.push({command:en.setBearing,args:[r.bearing]}),a(i.pitch,r.pitch)||n.push({command:en.setPitch,args:[r.pitch]}),a(i.sprite,r.sprite)||n.push({command:en.setSprite,args:[r.sprite]}),a(i.glyphs,r.glyphs)||n.push({command:en.setGlyphs,args:[r.glyphs]}),a(i.transition,r.transition)||n.push({command:en.setTransition,args:[r.transition]}),a(i.light,r.light)||n.push({command:en.setLight,args:[r.light]}),a(i.fog,r.fog)||n.push({command:en.setFog,args:[r.fog]}),a(i.projection,r.projection)||n.push({command:en.setProjection,args:[r.projection]});const o={},s=[];!function(i,r,n,o){let s;for(s in r=r||{},i=i||{})i.hasOwnProperty(s)&&(r.hasOwnProperty(s)||es(s,n,o));for(s in r)r.hasOwnProperty(s)&&(i.hasOwnProperty(s)?a(i[s],r[s])||("geojson"===i[s].type&&"geojson"===r[s].type&&el(i,r,s)?n.push({command:en.setGeoJSONSourceData,args:[s,r[s].data,]}):ea(s,r,n,o)):eo(s,r,n))}(i.sources,r.sources,s,o);const l=[];i.layers&&i.layers.forEach(i=>{o[i.source]?n.push({command:en.removeLayer,args:[i.id]}):l.push(i)});let c=i.terrain;c&&o[c.source]&&(n.push({command:en.setTerrain,args:[void 0]}),c=void 0),n=n.concat(s),a(c,r.terrain)||n.push({command:en.setTerrain,args:[r.terrain]}),function(i,r,n){r=r||[];const o=(i=i||[]).map(eu),s=r.map(eu),l=i.reduce(eh,{}),c=r.reduce(eh,{}),u=o.slice(),h=Object.create(null);let d,p,f,m,g,y,x;for(d=0,p=0;d!(i.command in eV));if(0===n.length)return!1;const o=n.filter(i=>!(i.command in eU));if(o.length>0)throw Error(`Unimplemented: ${o.map(i=>i.command).join(", ")}.`);return n.forEach(i=>{"setTransition"!==i.command&&this[i.command].apply(this,i.args)}),this.stylesheet=r,this.updateProjection(),!0}addImage(r,n){if(this.getImage(r))return this.fire(new i.ErrorEvent(Error("An image with this name already exists.")));this.imageManager.addImage(r,n),this._afterImageUpdated(r)}updateImage(i,r){this.imageManager.updateImage(i,r)}getImage(i){return this.imageManager.getImage(i)}removeImage(r){if(!this.getImage(r))return this.fire(new i.ErrorEvent(Error("No image with this name exists.")));this.imageManager.removeImage(r),this._afterImageUpdated(r)}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,n,o={}){if(this._checkLoaded(),void 0!==this.getSource(r))throw Error("There is already a source with this ID");if(!n.type)throw 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(i.validateStyle.source,`sources.${r}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const s=q(r,n,this.dispatcher,this);s.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:s.serialize(),sourceId:r}));const a=n=>{const o=(n?"symbol:":"other:")+r,a=this._sourceCaches[o]=new i.SourceCache(o,s,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[r]=a,a.style=this,a.onAdd(this.map)};a(!1),"vector"!==n.type&&"geojson"!==n.type||a(!0),s.onAdd&&s.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const n=this.getSource(r);if(void 0===n)throw Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while layer "${o}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while terrain is using it.`)));const s=this._getSourceCaches(r);for(const a of s)delete this._sourceCaches[a.id],delete this._updatedSources[a.id],a.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:a.getSource().id})),a.setEventedParent(null),a.clearTiles();delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(i,r){this._checkLoaded(),this.getSource(i).setData(r),this._changed=!0}getSource(i){const r=this._getSourceCache(i);return r&&r.getSource()}addLayer(r,n,o={}){this._checkLoaded();const s=r.id;if(this.getLayer(s))return void this.fire(new i.ErrorEvent(Error(`Layer with id "${s}" already exists on this map`)));let a;if("custom"===r.type){if(e4(this,i.validateCustomStyleLayer(r)))return;a=i.createStyleLayer(r)}else{if("object"==typeof r.source&&(this.addSource(s,r.source),r=i.clone$1(r),r=i.extend(r,{source:s})),this._validate(i.validateStyle.layer,`layers.${s}`,r,{arrayIndex:-1},o))return;a=i.createStyleLayer(r),this._validateLayer(a),a.setEventedParent(this,{layer:{id:s}}),this._serializedLayers[a.id]=a.serialize(),this._updateLayerCount(a,!0)}const l=n?this._order.indexOf(n):this._order.length;if(n&&-1===l)return void this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(l,0,s),this._layerOrderChanged=!0,this._layers[s]=a;const c=this._getLayerSourceCache(a);if(this._removedLayers[s]&&a.source&&c&&"custom"!==a.type){const u=this._removedLayers[s];delete this._removedLayers[s],u.type!==a.type?this._updatedSources[a.source]="clear":(this._updatedSources[a.source]="reload",c.pause())}this._updateLayer(a),a.onAdd&&a.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,n){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===n)return;const o=this._order.indexOf(r);this._order.splice(o,1);const s=n?this._order.indexOf(n):this._order.length;n&&-1===s?this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const n=this._layers[r];if(!n)return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const o=this._order.indexOf(r);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=n,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(i){return this._layers[i]}hasLayer(i){return i in this._layers}hasLayerType(i){for(const r in this._layers)if(this._layers[r].type===i)return!0;return!1}setLayerZoomRange(r,n,o){this._checkLoaded();const s=this.getLayer(r);s?s.minzoom===n&&s.maxzoom===o||(null!=n&&(s.minzoom=n),null!=o&&(s.maxzoom=o),this._updateLayer(s)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,n,o={}){this._checkLoaded();const s=this.getLayer(r);if(s){if(!a(s.filter,n))return null==n?(s.filter=void 0,void this._updateLayer(s)):void(this._validate(i.validateStyle.filter,`layers.${s.id}.filter`,n,{layerType:s.type},o)||(s.filter=i.clone$1(n),this._updateLayer(s)))}else this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){return i.clone$1(this.getLayer(r).filter)}setLayoutProperty(r,n,o,s={}){this._checkLoaded();const l=this.getLayer(r);l?a(l.getLayoutProperty(n),o)||(l.setLayoutProperty(n,o,s),this._updateLayer(l)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,n){const o=this.getLayer(r);if(o)return o.getLayoutProperty(n);this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,n,o,s={}){this._checkLoaded();const l=this.getLayer(r);l?a(l.getPaintProperty(n),o)||(l.setPaintProperty(n,o,s)&&this._updateLayer(l),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(i,r){return this.getLayer(i).getPaintProperty(r)}setFeatureState(r,n){this._checkLoaded();const o=r.source,s=r.sourceLayer,a=this.getSource(o);if(void 0===a)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const l=a.type;if("geojson"===l&&s)return void this.fire(new i.ErrorEvent(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===l&&!s)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided.")));const c=this._getSourceCaches(o);for(const u of c)u.setFeatureState(s,r.id,n)}removeFeatureState(r,n){this._checkLoaded();const o=r.source,s=this.getSource(o);if(void 0===s)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const a=s.type,l="vector"===a?r.sourceLayer:void 0;if("vector"===a&&!l)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof r.id&&"number"!=typeof r.id)return void this.fire(new i.ErrorEvent(Error("A feature id is required to remove its specific state property.")));const c=this._getSourceCaches(o);for(const u of c)u.removeFeatureState(l,r.id,n)}getFeatureState(r){this._checkLoaded();const n=r.source,o=r.sourceLayer,s=this.getSource(n);if(void 0!==s){if("vector"!==s.type||o)return void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(o,r.id);this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const n in this._sourceCaches){const o=this._sourceCaches[n].getSource();r[o.id]||(r[o.id]=o.serialize())}return i.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:r,layers:this._serializeLayers(this._order)},i=>void 0!==i)}_updateLayer(i){this._updatedLayers[i.id]=!0;const r=this._getLayerSourceCache(i);i.source&&!this._updatedSources[i.source]&&r&&"raster"!==r.getSource().type&&(this._updatedSources[i.source]="reload",r.pause()),this._changed=!0,i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){var r,n;const o={},s=[];for(let a=this._order.length-1;a>=0;a--){const l=this._order[a];if(r=l,"fill-extrusion"===this._layers[r].type)for(const c of(o[l]=a,i)){const u=c[l];if(u)for(const h of u)s.push(h)}}s.sort((i,r)=>r.intersectionZ-i.intersectionZ);const d=[];for(let p=this._order.length-1;p>=0;p--){const f=this._order[p];if(n=f,"fill-extrusion"===this._layers[n].type)for(let m=s.length-1;m>=0;m--){const g=s[m].feature;if(o[g.layer.id]{const r=this.getLayer(i);return r&&r.is3D()}):this.has3DLayers(),h=M.createFromScreenPoints(r,o);for(const d in this._sourceCaches){const p=this._sourceCaches[d].getSource().id;n.layers&&!s[p]||c.push(W(this._sourceCaches[d],this._layers,this._serializedLayers,h,n,o,u,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,r,n,o,s,a,l){const c={},u=a.queryRenderedSymbols(o),h=[];for(const d of Object.keys(u).map(Number))h.push(l[d]);for(const p of(h.sort(K),h)){const f=p.featureIndex.lookupSymbolFeatures(u[p.bucketInstanceId],r,p.bucketIndex,p.sourceLayerIndex,s.filter,s.layers,s.availableImages,i);for(const m in f){const g=c[m]=c[m]||[],y=f[m];for(const x of(y.sort((i,r)=>{const n=p.featureSortOrder;if(n){const o=n.indexOf(i.featureIndex);return n.indexOf(r.featureIndex)-o}return r.featureIndex-i.featureIndex}),y))g.push(x)}}for(const $ in c)c[$].forEach(r=>{const o=r.feature,s=n(i[$]).getFeatureState(o.layer["source-layer"],o.id);o.source=o.layer.source,o.layer["source-layer"]&&(o.sourceLayer=o.layer["source-layer"]),o.state=s});return c}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),h.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(r,n){n&&n.filter&&this._validate(i.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this._getSourceCaches(r);let s=[];for(const a of o)s=s.concat(H(a,n));return s}addSourceType(i,r,n){return eN.getSourceType(i)?n(Error(`A source type called "${i}" already exists.`)):(eN.setSourceType(i,r),r.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:i,url:r.workerSourceURL},n):n(null,null))}getLight(){return this.light.getLight()}setLight(r,n={}){this._checkLoaded();const o=this.light.getLight();let s=!1;for(const l in r)if(!a(r[l],o[l])){s=!0;break}if(!s)return;const c={now:i.exported.now(),transition:i.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(r,n),this.light.updateTransitions(c)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(r,n=1){if(this._checkLoaded(),!r)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===n){if("object"==typeof r.source){const o="terrain-dem-src";this.addSource(o,r.source),r=i.clone$1(r),r=i.extend(r,{source:o})}if(this._validate(i.validateStyle.terrain,"terrain",r))return}if(!this.terrain||this.terrain&&n!==this.terrain.drapeRenderMode)this._createTerrain(r,n);else{const s=this.terrain,l=s.get();for(const c in r)if(!a(r[c],l[c])){s.set(r),this.stylesheet.terrain=r;const u={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};s.updateTransitions(u);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(r){const n=this.fog=new S(r,this.map.transform);this.stylesheet.fog=r;const o={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};n.updateTransitions(o)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const i of this.map._markers)i._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,o=n.get();for(const s in r)if(!a(r[s],o[s])){n.set(r),this.stylesheet.fog=r;const l={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};n.updateTransitions(l);break}}else this._createFog(r);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const i=this._order.filter(i=>this.isLayerDraped(this._layers[i])),r=this._order.filter(i=>!this.isLayerDraped(this._layers[i]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...i),this._drapedFirstOrder.push(...r)}_createTerrain(r,n){const o=this.terrain=new _(r,n);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const s={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(s)}_force3DLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"fill-extrusion"===r.type&&this._updateLayer(r)}}_forceSymbolLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"symbol"===r.type&&this._updateLayer(r)}}_validate(r,n,o,s,a={}){return(!a||!1!==a.validate)&&e4(this,r.call(i.validateStyle,i.extend({key:n,style:this.serialize(),value:o,styleSpec:i.spec},s)))}_remove(){for(const r in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[r].setEventedParent(null);for(const n in this._sourceCaches)this._sourceCaches[n].clearTiles(),this._sourceCaches[n].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(i){const r=this._getSourceCaches(i);for(const n of r)n.clearTiles()}_reloadSource(i){const r=this._getSourceCaches(i);for(const n of r)n.resume(),n.reload()}_updateSources(i){for(const r in this._sourceCaches)this._sourceCaches[r].update(i)}_generateCollisionBoxes(){for(const i in this._sourceCaches){const r=this._sourceCaches[i];r.resume(),r.reload()}}_updatePlacement(r,n,o,s,a=!1){let l=!1,c=!1;const u={};for(const h of this._order){const d=this._layers[h];if("symbol"!==d.type)continue;if(!u[d.source]){const p=this._getLayerSourceCache(d);if(!p)continue;u[d.source]=p.getRenderableIds(!0).map(i=>p.getTileByID(i)).sort((i,r)=>r.tileID.overscaledZ-i.tileID.overscaledZ||(i.tileID.isLessThan(r.tileID)?-1:1))}const f=this.crossTileSymbolIndex.addLayer(d,u[d.source],r.center.lng,r.projection);l=l||f}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a=a||this._layerOrderChanged||0===o,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),r.zoom))&&(this.pauseablePlacement=new e3(r,this._order,a,n,o,s,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,u),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l)for(const m of this._order){const g=this._layers[m];"symbol"===g.type&&this.placement.updateLayerOpacities(g,u[g.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const i in this._sourceCaches)this._sourceCaches[i].releaseSymbolFadeTiles()}getImages(i,r,n){this.imageManager.getImages(r.icons,n),this._updateTilesForChangedImages();const o=i=>{i&&i.setDependencies(r.tileID.key,r.type,r.icons)};o(this._otherSourceCaches[r.source]),o(this._symbolSourceCaches[r.source])}getGlyphs(i,r,n){this.glyphManager.getGlyphs(r.stacks,n)}getResource(r,n,o){return i.makeRequest(n,o)}_getSourceCache(i){return this._otherSourceCaches[i]}_getLayerSourceCache(i){return"symbol"===i.type?this._symbolSourceCaches[i.source]:this._otherSourceCaches[i.source]}_getSourceCaches(i){const r=[];return this._otherSourceCaches[i]&&r.push(this._otherSourceCaches[i]),this._symbolSourceCaches[i]&&r.push(this._symbolSourceCaches[i]),r}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}eN.getSourceType=function(i){return Z[i]},eN.setSourceType=function(i,r){Z[i]=r},eN.registerForPluginStateChange=i.registerForPluginStateChange;var eG="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}\n#endif",eZ="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}";let e9={},e7={};e9=eW("","\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",!0),e7=eW("#ifdef FOG\nuniform float u_fog_temporal_offset;float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif","#ifdef FOG\nuniform mat4 u_fog_matrix;vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",!0);const eq=eW("\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef TERRAIN\nhighp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#endif","\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#if defined(PROJECTION_GLOBE_VIEW) && !defined(PROJECTED_POS_ON_VIEWPORT)\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {\n#if defined(PROJECTION_GLOBE_VIEW) && !defined(PROJECTED_POS_ON_VIEWPORT)\nreturn mix(globe,mercator,t);\n#else\nreturn globe;\n#endif\n}\n#ifdef PROJECTION_GLOBE_VIEW\nmat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),e5=eG;var eX={background:eW("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:eW("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:eW("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 scaled_extrude=extrude*a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=scaled_extrude.x*surface_vectors[0]+scaled_extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);vec4 world_center=vec4(pos,1);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\n#if defined(SCALE_WITH_MAP) && defined(PROJECTION_GLOBE_VIEW)\nview_scale*=a_scale;\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:eW("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:eW("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\ngl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nextrude*=a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\nvec3 pos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:eW("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:eW("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}","attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:eW("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:eW("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}"),fill:eW("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:eW("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:eW("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:eW("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:eW("varying vec4 v_color;void main() {vec4 color=v_color;\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(pos.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:eW("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:eW("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture2D(u_image,coord).a/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:eW("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:eW("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nvec4 out_color=texture2D(u_gradient_image,v_uv);\n#else\nvec4 out_color=color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#ifdef RENDER_LINE_GRADIENT\nattribute vec3 a_packed;\n#else\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];float a_linesofar=a_packed[2];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);\n#endif\n#ifdef RENDER_LINE_DASH\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:eW("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),raster:eW("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:eW("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:eW("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;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 vec3 u_tile_id;uniform float u_zoom_transition;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[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;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:eW("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[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;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:eW("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:eW("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:eW("\nvarying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",eZ),skyboxGradient:eW("varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",eZ),skyboxCapture:eW("\nvarying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}","attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:eW("uniform sampler2D u_image0;varying vec2 v_pos0;void main() {gl_FragColor=texture2D(u_image0,v_pos0);\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_proj_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;attribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;varying vec2 v_pos0;const float wireframeOffset=1e3;void main() {v_pos0=a_uv;vec2 uv=a_uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nvec4 globe=u_globe_matrix*vec4(a_globe_pos+up_vector.xyz*height,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(a_merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);}"),globeAtmosphere:eW("uniform vec2 u_center;uniform float u_radius;uniform vec2 u_screen_size;uniform float u_opacity;uniform highp float u_fadeout_range;uniform vec3 u_start_color;uniform vec3 u_end_color;uniform float u_pixel_ratio;void main() {highp vec2 fragCoord=gl_FragCoord.xy/u_pixel_ratio;fragCoord.y=u_screen_size.y-fragCoord.y;float distFromCenter=length(fragCoord-u_center);float normDistFromCenter=length(fragCoord-u_center)/u_radius;if (normDistFromCenter < 1.0)\ndiscard;float t=clamp(1.0-sqrt(normDistFromCenter-1.0)/u_fadeout_range,0.0,1.0);vec3 color=mix(u_start_color,u_end_color,1.0-t);gl_FragColor=vec4(color*t*u_opacity,u_opacity);}","attribute vec3 a_pos;void main() {gl_Position=vec4(a_pos,1.0);}")};function eW(i,r,n){const o=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,a=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),l=i.match(s),c=r.match(s),u=eG.match(s);let h=c?c.concat(l):l;n||(e9.staticUniforms&&(h=e9.staticUniforms.concat(h)),e7.staticUniforms&&(h=e7.staticUniforms.concat(h))),h&&(h=h.concat(u));const d={};return{fragmentSource:i=i.replace(o,(i,r,n,o,s)=>(d[s]=!0,"define"===r?` #ifndef HAS_UNIFORM_u_${s} varying ${n} ${o} ${s}; #else @@ -57,4 +57,4 @@ uniform ${n} ${o} u_${s}; `}),staticAttributes:a,staticUniforms:h}}class eH{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(i,r,n,o,s,a,l,c){this.context=i;let u=this.boundPaintVertexBuffers.length!==o.length;for(let h=0;!u&&h{const a=o.paint.get("hillshade-shadow-color"),l=o.paint.get("hillshade-highlight-color"),c=o.paint.get("hillshade-accent-color");let u=o.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===o.paint.get("hillshade-illumination-anchor")&&(u-=r.transform.angle);const h=!r.options.moving;return{u_matrix:s||r.transform.calculateProjMatrix(n.tileID.toUnwrapped(),h),u_image:0,u_latrange:function(r,n){const o=Math.pow(2,n.canonical.z),s=n.canonical.y;return[new i.MercatorCoordinate(0,s/o).toLngLat().lat,new i.MercatorCoordinate(0,(s+1)/o).toLngLat().lat,]}(0,n.tileID),u_light:[o.paint.get("hillshade-exaggeration"),u,],u_shadow:a,u_highlight:l,u_accent:c}})(r,o,s,r.terrain?n.projMatrix:null);r.prepareDrawProgram(u,p,n.toUnwrapped());const{tileBoundsBuffer:m,tileBoundsIndexBuffer:g,tileBoundsSegments:y}=r.getTileBoundsBuffers(o);p.draw(u,h.TRIANGLES,a,l,c,i.CullFaceMode.disabled,f,s.id,m,g,y)}function eY(r,n,o){if(!n.needsDEMTextureUpload)return;const s=r.context,a=s.gl;s.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||r.getTileTexture(o.stride);const l=o.getPixels();n.demTexture?n.demTexture.update(l,{premultiply:!1}):n.demTexture=new i.Texture(s,l,a.RGBA,{premultiply:!1}),n.needsDEMTextureUpload=!1}function eJ(r,n,o,s,a,l){const c=r.context,u=c.gl;if(!n.dem)return;const h=n.dem;if(c.activeTexture.set(u.TEXTURE1),eY(r,n,h),!n.demTexture)return;n.demTexture.bind(u.NEAREST,u.CLAMP_TO_EDGE);const d=h.dim;c.activeTexture.set(u.TEXTURE0);let p=n.fbo;if(!p){const f=new i.Texture(c,{width:d,height:d,data:null},u.RGBA);f.bind(u.LINEAR,u.CLAMP_TO_EDGE),(p=n.fbo=c.createFramebuffer(d,d,!0)).colorAttachment.set(f.texture)}c.bindFramebuffer.set(p.framebuffer),c.viewport.set([0,0,d,d]);const{tileBoundsBuffer:m,tileBoundsIndexBuffer:g,tileBoundsSegments:y}=r.getMercatorTileBoundsBuffers();r.useProgram("hillshadePrepare").draw(c,u.TRIANGLES,s,a,l,i.CullFaceMode.disabled,((r,n)=>{const o=n.stride,s=i.create();return i.ortho(s,0,i.EXTENT,-i.EXTENT,0,0,1),i.translate(s,s,[0,-i.EXTENT,0]),{u_matrix:s,u_image:1,u_dimension:[o,o],u_zoom:r.overscaledZ,u_unpack:n.unpackVector}})(n.tileID,h),o.id,m,g,y),n.needsHillshadePrepare=!1}const eQ=(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_image0:new i.Uniform1i(r,n.u_image0),u_skirt_height:new i.Uniform1f(r,n.u_skirt_height)}),te=(i,r)=>({u_matrix:i,u_image0:0,u_skirt_height:r}),tt=(i,r,n,o,s)=>({u_proj_matrix:Float32Array.from(i),u_globe_matrix:r,u_merc_matrix:n,u_zoom_transition:o,u_merc_center:s,u_image0:0});function ti(i,r){return null!=i&&null!=r&&!(!i.hasData()||!r.hasData())&&null!=i.demTexture&&null!=r.demTexture&&i.tileID.key!==r.tileID.key}const tr=new class{constructor(){this.operations={}}newMorphing(i,r,n,o,s){if(i in this.operations){const a=this.operations[i];a.to.tileID.key!==n.tileID.key&&(a.queued=n)}else this.operations[i]={startTime:o,phase:0,duration:s,from:r,to:n,queued:null}}getMorphValuesForProxy(i){if(!(i in this.operations))return null;const r=this.operations[i];return{from:r.from,to:r.to,phase:r.phase}}update(i){for(const r in this.operations){const n=this.operations[r];for(n.phase=(i-n.startTime)/n.duration;n.phase>=1||!this._validOp(n);)if(!this._nextOp(n,i)){delete this.operations[r];break}}}_nextOp(i,r){return!!i.queued&&(i.from=i.to,i.to=i.queued,i.queued=null,i.phase=0,i.startTime=r,!0)}_validOp(i){return i.from.hasData()&&i.to.hasData()}},tn={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function to(i,r){const n=1<({u_matrix:i});function ta(r,n,o,s,a){if(a>0){const l=i.exported.now(),c=(l-r.timeAdded)/a,u=n?(l-n.timeAdded)/a:-1,h=o.getSource(),d=s.coveringZoomLevel({tileSize:h.tileSize,roundZoom:h.roundZoom}),p=!n||Math.abs(n.tileID.overscaledZ-d)>Math.abs(r.tileID.overscaledZ-d),f=p&&r.refreshedUponExpiration?1:i.clamp(p?c:1-u,0,1);return r.refreshedUponExpiration&&c>=1&&(r.refreshedUponExpiration=!1),n?{opacity:1,mix:1-f}:{opacity:f,mix:0}}return{opacity:1,mix:0}}class tl extends i.SourceCache{constructor(i){const r={type:"raster-dem",maxzoom:i.transform.maxZoom},n=new I(et(),null),o=q("mock-dem",r,n,i.style);super("mock-dem",o,!1),o.setEventedParent(this),this._sourceLoaded=!0}_loadTile(i,r){i.state="loaded",r(null)}}class tc extends i.SourceCache{constructor(i){const r=q("proxy",{type:"geojson",maxzoom:i.transform.maxZoom},new I(et(),null),i.style);super("proxy",r,!1),r.setEventedParent(this),this.map=this.getSource().map=i,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(r,n,o){if(r.freezeTileCoverage)return;this.transform=r;const s=r.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((n,o)=>{if(n[o.key]="",!this._tiles[o.key]){const s=new i.Tile(o,this._source.tileSize*o.overscaleFactor(),r.tileZoom);s.state="loaded",this._tiles[o.key]=s}return n},{});for(const a in this._tiles)a in s||(this.freeFBO(a),this._tiles[a].unloadVectorData(),delete this._tiles[a])}freeFBO(i){const r=this.proxyCachedFBO[i];if(void 0!==r){const n=Object.values(r);this.renderCachePool.push(...n),delete this.proxyCachedFBO[i]}}deallocRenderCache(){this.renderCache.forEach(i=>i.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class tu extends i.OverscaledTileID{constructor(i,r,n){super(i.overscaledZ,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y),this.proxyTileKey=r,this.projMatrix=n}}class th extends i.Elevation{constructor(r,n){super(),this.painter=r,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[o,s,a]=function(r){const n=new i.StructArrayLayout4i8,o=new i.StructArrayLayout3ui6;n.reserve(17161),o.reserve(33800);const s=i.EXTENT/128,a=i.EXTENT+s/2,l=a+s;for(let c=-s;ca||c<0||c>a?24575:0,d=i.clamp(Math.round(u),0,i.EXTENT),p=i.clamp(Math.round(c),0,i.EXTENT);n.emplaceBack(d+h,p,d,p)}const f=(i,r)=>{const n=131*r+i;o.emplaceBack(n+1,n,n+131),o.emplaceBack(n+131,n+131+1,n+1)};for(let m=1;m<129;m++)for(let g=1;g<129;g++)f(g,m);return[0,129].forEach(i=>{for(let r=0;r<130;r++)f(r,i),f(i,r)}),[n,o,32768]}(),l=r.context;this.gridBuffer=l.createVertexBuffer(o,i.boundsAttributes.members),this.gridIndexBuffer=l.createIndexBuffer(s),this.gridSegments=i.SegmentVector.simpleSegment(0,0,o.length,s.length),this.gridNoSkirtSegments=i.SegmentVector.simpleSegment(0,0,o.length,a),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new tc(n.map),this.orthoMatrix=i.create(),i.ortho(this.orthoMatrix,0,i.EXTENT,0,i.EXTENT,0,1);const c=l.gl;this._overlapStencilMode=new i.StencilMode({func:c.GEQUAL,mask:255},0,255,c.KEEP,c.KEEP,c.REPLACE),this._previousZoom=r.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=n,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new tl(n.map)}set style(i){i.on("data",this._onStyleDataEvent.bind(this)),i.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=i,this._checkRenderCacheEfficiency()}update(r,n,o){if(r&&r.terrain){this._style!==r&&(this.style=r),this.enabled=!0;const s=r.terrain.properties;this.sourceCache=0===r.terrain.drapeRenderMode?this._mockSourceCache:r._getSourceCache(s.get("source")),this._exaggeration=s.get("exaggeration");const a=()=>{this.sourceCache.used&&i.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source. This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const r=this.getScaledDemTileSize();this.sourceCache.update(n,r,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,a(),this._initializing=!0),a(),n.updateElevation(!o),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(n),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(i){this._findCoveringTileCache[i]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const r=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==r.efficiency&&i.warnOnce(`Terrain render cache efficiency is not optimal (${r.efficiency}%) and performance may be affected negatively, consider placing all background, fill and line layers before layer - with id '${r.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(i){i.coord&&"source"===i.dataType?this._clearRenderCacheForTile(i.sourceCacheId,i.coord):"style"===i.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const i in this._style._sourceCaches)this._style._sourceCaches[i].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(i=>i.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const i=2*this.proxySourceCache.getSource().tileSize;return[i,i]}set useVertexMorphing(i){this._useVertexMorphing=i}updateTileBinding(r){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const n=this.proxySourceCache,o=this.painter.transform;this._initializing&&(this._initializing=0===o._centerAltitude&&-1===this.getAtPointOrZero(i.MercatorCoordinate.fromLngLat(o.center),-1),this._emptyDEMTextureDirty=!this._initializing);const s=this.proxyCoords=n.getIds().map(i=>{const r=n.getTileByID(i).tileID;return r.projMatrix=o.calculateProjMatrix(r.toUnwrapped()),r});(function(r,n){const o=n.transform.pointCoordinate(n.transform.getCameraPoint()),s=new i.pointGeometry(o.x,o.y);r.sort((r,n)=>{if(n.overscaledZ-r.overscaledZ)return n.overscaledZ-r.overscaledZ;const o=new i.pointGeometry(r.canonical.x+(1<{this.proxyToSource[i.key]={}}),this.terrainTileForTile={};const l=this._style._sourceCaches;for(const c in l){const u=l[c];if(!u.used||(u!==this.sourceCache&&this.resetTileLookupCache(u.id),this._setupProxiedCoordsForOrtho(u,r[c],a),u.usedForTerrain))continue;const h=r[c];u.getSource().reparseOverscaled&&this._assignTerrainTiles(h)}this.proxiedCoords[n.id]=s.map(i=>new tu(i,i.key,this.orthoMatrix)),this._assignTerrainTiles(s),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(a),this.renderingToTexture=!1,this._updateTimestamp=i.exported.now();const d={};for(const p of(this._visibleDemTiles=[],this.proxyCoords)){const f=this.terrainTileForTile[p.key];if(!f)continue;const m=f.tileID.key;m in d||(this._visibleDemTiles.push(f),d[m]=m)}}_assignTerrainTiles(i){this._initializing||i.forEach(i=>{if(this.terrainTileForTile[i.key])return;const r=this._findTileCoveringTileID(i,this.sourceCache);r&&(this.terrainTileForTile[i.key]=r)})}_prepareDEMTextures(){const i=this.painter.context,r=i.gl;for(const n in this.terrainTileForTile){const o=this.terrainTileForTile[n],s=o.dem;s&&(!o.demTexture||o.needsDEMTextureUpload)&&(i.activeTexture.set(r.TEXTURE1),eY(this.painter,o,s))}}_prepareDemTileUniforms(i,r,n,o){if(!r||null==r.demTexture)return!1;const s=i.tileID.canonical,a=Math.pow(2,r.tileID.canonical.z-s.z),l=o||"";return n[`u_dem_tl${l}`]=[s.x*a%1,s.y*a%1,],n[`u_dem_scale${l}`]=a,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const r=this.painter.context,n=r.gl;if(!this._emptyDepthBufferTexture){const o={width:1,height:1,data:new Uint8Array([255,255,255,255,])};this._emptyDepthBufferTexture=new i.Texture(r,o,n.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let i=0;const r=this._visibleDemTiles.reduce((r,n)=>{if(!n.dem)return r;const o=n.dem.tree.minimums[0];return o>0&&i++,r+o},0);return i?r/i:0}_updateEmptyDEMTexture(){const r=this.painter.context,n=r.gl;r.activeTexture.set(n.TEXTURE2);const o=this._getLoadedAreaMinimum(),s={width:1,height:1,data:new Uint8Array(i.DEMData.pack(o,this.sourceCache.getSource().encoding))};this._emptyDEMTextureDirty=!1;let a=this._emptyDEMTexture;return a?a.update(s,{premultiply:!1}):a=this._emptyDEMTexture=new i.Texture(r,s,n.RGBA,{premultiply:!1}),a}setupElevationDraw(r,n,o){var s;const a=this.painter.context,l=a.gl,c=(s=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:i.DEMData.getUnpackVector(s),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});c.u_dem_size=this.sourceCache.getSource().tileSize,c.u_exaggeration=this.exaggeration();const u=this.painter.transform,h=u.projection.createTileTransform(u,u.worldSize),d=r.tileID.canonical;c.u_tile_tl_up=h.upVector(d,0,0),c.u_tile_tr_up=h.upVector(d,i.EXTENT,0),c.u_tile_br_up=h.upVector(d,i.EXTENT,i.EXTENT),c.u_tile_bl_up=h.upVector(d,0,i.EXTENT),c.u_tile_up_scale=h.upVectorScale(d);let p=null,f=null,m=1;if(o&&o.morphing&&this._useVertexMorphing){const g=o.morphing.srcDemTile,y=o.morphing.dstDemTile;m=o.morphing.phase,g&&y&&(this._prepareDemTileUniforms(r,g,c,"_prev")&&(f=g),this._prepareDemTileUniforms(r,y,c)&&(p=y))}if(f&&p?(a.activeTexture.set(l.TEXTURE2),p.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE,l.NEAREST),a.activeTexture.set(l.TEXTURE4),f.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE,l.NEAREST),c.u_dem_lerp=m):(p=this.terrainTileForTile[r.tileID.key],a.activeTexture.set(l.TEXTURE2),(this._prepareDemTileUniforms(r,p,c)?p.demTexture:this.emptyDEMTexture).bind(l.NEAREST,l.CLAMP_TO_EDGE)),a.activeTexture.set(l.TEXTURE3),o&&o.useDepthForOcclusion?(this._depthTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE),c.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height,]):(this.emptyDepthBufferTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE),c.u_depth_size_inv=[1,1]),o&&o.useMeterToDem&&p){const x=(1<{if(h===i)return;const o=[];n&&o.push(tn[d]),o.push(tn[i]),o.push("PROJECTION_GLOBE_VIEW"),u=r.useProgram("globeRaster",null,o),h=i},f=r.colorModeForRenderPass(),m=new i.DepthMode(c.LEQUAL,i.DepthMode.ReadWrite,r.depthRangeFor3D);tr.update(a);const g=r.transform,y=i.calculateGlobeMatrix(g,g.worldSize),x=i.calculateGlobeMercatorMatrix(g),$=[i.mercatorXfromLng(g.center.lng),i.mercatorYfromLat(g.center.lat),],v=r.globeSharedBuffers;(d?[!1,!0]:[!1]).forEach(d=>{h=-1;const _=d?c.LINES:c.TRIANGLES;for(const b of s){const w=o.getTile(b),T=Math.pow(2,b.canonical.z),[E,S]=i.globeBuffersForTileMesh(r,w,b,T),I=i.StencilMode.disabled,C=n.prevTerrainTileForTile[b.key],z=n.terrainTileForTile[b.key];ti(C,z)&&tr.newMorphing(b.key,C,z,a,250),l.activeTexture.set(c.TEXTURE0),w.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE);const A=tr.getMorphValuesForProxy(b.key),k=A?1:0,P={};A&&i.extend$1(P,{morphing:{srcDemTile:A.from,dstDemTile:A.to,phase:i.easeCubicInOut(A.phase)}});const D=i.globeMatrixForTile(b.canonical,y),L=tt(g.projMatrix,D,x,i.globeToMercatorTransition(g.zoom),$);if(p(k,d),n.setupElevationDraw(w,u,P),r.prepareDrawProgram(l,u,b.toUnwrapped()),v){const[B,R]=d?v.getWirefameBuffer(r.context):[v.gridIndexBuffer,v.gridSegments,];u.draw(l,_,m,I,f,i.CullFaceMode.backCCW,L,"globe_raster",E,B,R)}if(!d){const M=[0===b.canonical.y?i.globePoleMatrixForTile(b.canonical,!1,g):null,b.canonical.y===T-1?i.globePoleMatrixForTile(b.canonical,!0,g):null,];for(const F of M){if(!F)continue;const O=tt(g.projMatrix,F,F,0,$);v&&u.draw(l,_,m,I,f,i.CullFaceMode.disabled,O,"globe_pole_raster",S,v.poleIndexBuffer,v.poleSegments)}}}})}(r,n,o,s,a);else{const l=r.context,c=l.gl;let u,h;const d=r.options.showTerrainWireframe?2:0,p=(i,n)=>{if(h===i)return;const o=[tn[i]];n&&o.push(tn[d]),u=r.useProgram("terrainRaster",null,o),h=i},f=r.colorModeForRenderPass(),m=new i.DepthMode(c.LEQUAL,i.DepthMode.ReadWrite,r.depthRangeFor3D);tr.update(a);const g=r.transform,y=6*Math.pow(1.5,22-g.zoom)*n.exaggeration();(d?[!1,!0]:[!1]).forEach(d=>{h=-1;const x=d?c.LINES:c.TRIANGLES,[$,v]=d?n.getWirefameBuffer():[n.gridIndexBuffer,n.gridSegments,];for(const _ of s){const b=o.getTile(_),w=i.StencilMode.disabled,T=n.prevTerrainTileForTile[_.key],E=n.terrainTileForTile[_.key];ti(T,E)&&tr.newMorphing(_.key,T,E,a,250),l.activeTexture.set(c.TEXTURE0),b.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE,c.LINEAR_MIPMAP_NEAREST);const S=tr.getMorphValuesForProxy(_.key),I=S?1:0;let C;S&&(C={morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:i.easeCubicInOut(S.phase)}});const z=te(_.projMatrix,to(_.canonical,g.renderWorldCopies)?y/10:y);p(I,d),n.setupElevationDraw(b,u,C),r.prepareDrawProgram(l,u,_.toUnwrapped()),u.draw(l,x,m,w,f,i.CullFaceMode.backCCW,z,"terrain_raster",n.gridBuffer,$,v)}})}}(n,this,this.proxySourceCache,r,this._updateTimestamp),this.renderingToTexture=!0,r.splice(0,r.length))}renderBatch(r){if(0===this._drapedRenderBatches.length)return r+1;this.renderingToTexture=!0;const n=this.painter,o=this.painter.context,s=this.proxySourceCache,a=this.proxiedCoords[s.id],l=this._drapedRenderBatches.shift(),c=[],u=n.style.order;let h=0;for(const d of a){const p=s.getTileByID(d.proxyTileKey),f=s.proxyCachedFBO[d.key]?s.proxyCachedFBO[d.key][r]:void 0,m=void 0!==f?s.renderCache[f]:this.pool[h++],g=void 0!==f;if(p.texture=m.tex,g&&!m.dirty){c.push(p.tileID);continue}let y;o.bindFramebuffer.set(m.fb.framebuffer),this.renderedToTile=!1,m.dirty&&(o.clear({color:i.Color.transparent,stencil:0}),m.dirty=!1);for(let x=l.start;x<=l.end;++x){const $=n.style._layers[u[x]];if($.isHidden(n.transform.zoom))continue;const v=n.style._getLayerSourceCache($),_=v?this.proxyToSource[d.key][v.id]:[d];if(!_)continue;const b=_;o.viewport.set([0,0,m.fb.width,m.fb.height,]),y!==(v?v.id:null)&&(this._setupStencil(m,_,$,v),y=v?v.id:null),n.renderLayer(n,v,$,b)}this.renderedToTile?(m.dirty=!0,c.push(p.tileID)):g||--h,5===h&&(h=0,this.renderToBackBuffer(c))}return this.renderToBackBuffer(c),this.renderingToTexture=!1,o.bindFramebuffer.set(null),o.viewport.set([0,0,n.width,n.height]),l.end+1}postRender(){}renderCacheEfficiency(i){const r=i.order.length;if(0===r)return{efficiency:100};let n,o=0,s=0,a=!1;for(let l=0;li.dem).forEach(r=>{i=Math.min(i,r.dem.tree.minimums[0])}),0===i?i:(i-30)*this._exaggeration}raycast(i,r,n){if(!this._visibleDemTiles)return null;const o=this._visibleDemTiles.filter(i=>i.dem).map(o=>{const s=o.tileID,a=Math.pow(2,s.overscaledZ),{x:l,y:c}=s.canonical,u=l/a,h=(l+1)/a,d=c/a,p=(c+1)/a;return{minx:u,miny:d,maxx:h,maxy:p,t:o.dem.tree.raycastRoot(u,d,h,p,i,r,n),tile:o}});for(const s of(o.sort((i,r)=>(null!==i.t?i.t:Number.MAX_VALUE)-(null!==r.t?r.t:Number.MAX_VALUE)),o)){if(null==s.t)break;const a=s.tile.dem.tree.raycast(s.minx,s.miny,s.maxx,s.maxy,i,r,n);if(null!=a)return a}return null}_createFBO(){const r=this.painter.context,n=r.gl,o=this.drapeBufferSize;r.activeTexture.set(n.TEXTURE0);const s=new i.Texture(r,{width:o[0],height:o[1],data:null},n.RGBA);s.bind(n.LINEAR,n.CLAMP_TO_EDGE);const a=r.createFramebuffer(o[0],o[1],!1);return a.colorAttachment.set(s.texture),a.depthAttachment=new B(r,a.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=r.createRenderbuffer(r.gl.DEPTH_STENCIL,o[0],o[1]),this._stencilRef=0,a.depthAttachment.set(this._sharedDepthStencil),r.clear({stencil:0})):a.depthAttachment.set(this._sharedDepthStencil),r.extTextureFilterAnisotropic&&!r.extTextureFilterAnisotropicForceOff&&n.texParameterf(n.TEXTURE_2D,r.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,r.extTextureFilterAnisotropicMax),{fb:a,tex:s,dirty:!1}}_initFBOPool(){for(;this.pool.length{const r=this._style._layers[i],n=r.isHidden(this.painter.transform.zoom),o=r.getCrossfadeParameters(),s=!!o&&1!==o.t,a=r.hasTransition();return"custom"!==r.type&&!n&&(s||a)})}_clearRasterFadeFromRenderCache(){let i=!1;for(const r in this._style._sourceCaches)if(this._style._sourceCaches[r]._source instanceof V){i=!0;break}if(i)for(let n=0;nr.renderCachePool.length){const n=Object.values(r.proxyCachedFBO);r.proxyCachedFBO={};for(let o=0;o=0;c--){const u=a[c];if(r.getTileByID(u.key),void 0!==r.proxyCachedFBO[u.key]){const h=i[u.key],d=this.proxyToSource[u.key];let p=0;for(const f in d){const m=d[f],g=h[f];if(!g||g.length!==m.length||m.some((i,r)=>i!==g[r]||l[f]&&l[f].hasOwnProperty(i.key))){p=-1;break}++p}for(const y in r.proxyCachedFBO[u.key])r.renderCache[r.proxyCachedFBO[u.key][y]].dirty=p<0||p!==Object.values(h).length}}const x=[...this._drapedRenderBatches];for(const $ of(x.sort((i,r)=>r.end-r.start-(i.end-i.start)),x))for(const v of a){if(r.proxyCachedFBO[v.key])continue;let _=r.renderCachePool.pop();void 0===_&&r.renderCache.length<50&&(_=r.renderCache.length,r.renderCache.push(this._createFBO())),void 0!==_&&(r.proxyCachedFBO[v.key]={},r.proxyCachedFBO[v.key][$.start]=_,r.renderCache[_].dirty=!0)}this._tilesDirty={}}_setupStencil(i,r,n,o){if(!o||!this._sourceTilesOverlap[o.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const s=this.painter.context,a=s.gl;if(r.length<=1)return void(this._overlapStencilType=!1);let l;if(n.isTileClipped())l=r.length,this._overlapStencilMode.test={func:a.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(r[0].overscaledZ>r[r.length-1].overscaledZ))return void(this._overlapStencilType=!1);l=1,this._overlapStencilMode.test={func:a.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+l>255&&(s.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=l,this._overlapStencilMode.ref=this._stencilRef,n.isTileClipped()&&this._renderTileClippingMasks(r,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(r){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[r.key]),this._overlapStencilMode):i.StencilMode.disabled}_renderTileClippingMasks(r,n){const o=this.painter,s=this.painter.context,a=s.gl;o._tileClippingMaskIDs={},s.setColorMode(i.ColorMode.disabled),s.setDepthMode(i.DepthMode.disabled);const l=o.useProgram("clippingMask");for(const c of r){const u=o._tileClippingMaskIDs[c.key]=--n;l.draw(s,a.TRIANGLES,i.DepthMode.disabled,new i.StencilMode({func:a.ALWAYS,mask:0},u,255,a.KEEP,a.KEEP,a.REPLACE),i.ColorMode.disabled,i.CullFaceMode.disabled,ts(c.projMatrix),"$clipping",o.tileExtentBuffer,o.quadTriangleIndexBuffer,o.tileExtentSegments)}}pointCoordinate(r){const n=this.painter.transform;if(r.x<0||r.x>n.width||r.y<0||r.y>n.height)return null;const o=[r.x,r.y,1,1];i.transformMat4$1(o,o,n.pixelMatrixInverse),i.scale$1(o,o,1/o[3]),o[0]/=n.worldSize,o[1]/=n.worldSize;const s=n._camera.position,a=i.mercatorZfromAltitude(1,n.center.lat),l=[s[0],s[1],s[2]/a,0],c=i.subtract([],o.slice(0,3),l);i.normalize(c,c);const u=this.raycast(l,c,this._exaggeration);return null!==u&&u?(i.scaleAndAdd(l,l,c,u),l[3]=l[2],l[2]*=a,l):null}drawDepth(){const r=this.painter,n=r.context,o=this.proxySourceCache,s=Math.ceil(r.width),a=Math.ceil(r.height);if(this._depthFBO&&(this._depthFBO.width!==s||this._depthFBO.height!==a)&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture),!this._depthFBO){const l=n.gl,c=n.createFramebuffer(s,a,!0);n.activeTexture.set(l.TEXTURE0);const u=new i.Texture(n,{width:s,height:a,data:null},l.RGBA);u.bind(l.NEAREST,l.CLAMP_TO_EDGE),c.colorAttachment.set(u.texture);const h=n.createRenderbuffer(n.gl.DEPTH_COMPONENT16,s,a);c.depthAttachment.set(h),this._depthFBO=c,this._depthTexture=u}n.bindFramebuffer.set(this._depthFBO.framebuffer),n.viewport.set([0,0,s,a]),function(r,n,o,s){if("globe"===r.transform.projection.name)return;const a=r.context,l=a.gl;a.clear({depth:1});const c=r.useProgram("terrainDepth"),u=new i.DepthMode(l.LESS,i.DepthMode.ReadWrite,r.depthRangeFor3D);for(const h of s){const d=o.getTile(h),p=te(h.projMatrix,0);n.setupElevationDraw(d,c),c.draw(a,l.TRIANGLES,u,i.StencilMode.disabled,i.ColorMode.unblended,i.CullFaceMode.backCCW,p,"terrain_depth",n.gridBuffer,n.gridIndexBuffer,n.gridNoSkirtSegments)}}(r,this,o,this.proxyCoords)}_setupProxiedCoordsForOrtho(i,r,n){if(i.getSource() instanceof G)return this._setupProxiedCoordsForImageSource(i,r,n);this._findCoveringTileCache[i.id]=this._findCoveringTileCache[i.id]||{};const o=this.proxiedCoords[i.id]=[],s=this.proxyCoords;for(let a=0;a(i.min.x=Math.min(i.min.x,r.x-c.x),i.min.y=Math.min(i.min.y,r.y-c.y),i.max.x=Math.max(i.max.x,r.x-c.x),i.max.y=Math.max(i.max.y,r.y-c.y),i),{min:new i.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),h=(r,n)=>{const o=r.wrap+r.canonical.x/(1<l+u.max.x||s+ac+u.max.y};for(let d=0;di.key===n.tileID.key);if(a)return a}if(n.tileID.key!==r.key){const l=r.canonical.z-n.tileID.canonical.z;let c,u,h;s=i.create();const d=n.tileID.wrap-r.wrap<0?(u=(c=i.EXTENT>>l)*((n.tileID.canonical.x<=d){const p=r.canonical.z-d;n.getSource().reparseOverscaled?(c=Math.max(r.canonical.z+2,n.transform.tileZoom),l=new i.OverscaledTileID(c,r.wrap,d,r.canonical.x>>p,r.canonical.y>>p)):0!==p&&(c=d,l=new i.OverscaledTileID(c,r.wrap,d,r.canonical.x>>p,r.canonical.y>>p))}l.key!==r.key&&(h.push(l.key),o=n.getTile(l))}const f=i=>{h.forEach(r=>{s[r]=i}),h.length=0};for(c-=1;c>=u&&(!o||!o.hasData());c--){o&&f(o.tileID.key);const m=l.calculateScaledKey(c);if((o=n.getTileByID(m))&&o.hasData())break;const g=s[m];if(null===g)break;void 0===g?h.push(m):o=n.getTileByID(g)}return f(o?o.tileID.key:null),o&&o.hasData()?o:null}findDEMTileFor(i){return this.enabled?this._findTileCoveringTileID(i,this.sourceCache):null}prepareDrawTile(i){this.renderedToTile=!0}_clearRenderCacheForTile(i,r){let n=this._tilesDirty[i];n||(n=this._tilesDirty[i]={}),n[r.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const r=function(r){let n,o,s;const a=new i.StructArrayLayout2ui4;for(o=1;o<129;o++){for(n=1;n<129;n++)s=131*o+n,a.emplaceBack(s,s+1),a.emplaceBack(s,s+131),a.emplaceBack(s+1,s+131),128===o&&a.emplaceBack(s+131,s+131+1);a.emplaceBack(s+1,s+1+131)}return a}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(r),this.wireframeSegments=i.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments,]}}function td(i){const r=[];for(let n=0;nv.indexOf(_)&&v.push(_);let b=s?s.defines():[];b=b.concat(l.map(i=>`#define ${i}`));const w=b.concat("\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",e5,eq.fragmentSource,e7.fragmentSource,o.fragmentSource).join("\n"),T=b.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",e5,eq.vertexSource,e7.vertexSource,e9.vertexSource,o.vertexSource).join("\n"),E=p.createShader(p.FRAGMENT_SHADER);if(p.isContextLost())return void(this.failedToCreate=!0);p.shaderSource(E,w),p.compileShader(E),p.attachShader(this.program,E);const S=p.createShader(p.VERTEX_SHADER);if(p.isContextLost())return void(this.failedToCreate=!0);p.shaderSource(S,T),p.compileShader(S),p.attachShader(this.program,S),this.attributes={};const I={};this.numAttributes=g.length;for(let C=0;C>16,c>>16],u_pixel_coord_lower:[65535&l,65535&c]}}const tm=(r,n,o,s)=>{const a=n.style.light,l=a.properties.get("position"),c=[l.x,l.y,l.z],u=i.create$1();"viewport"===a.properties.get("anchor")&&(i.fromRotation(u,-n.transform.angle),i.transformMat3(c,c,u));const h=a.properties.get("color");return{u_matrix:r,u_lightpos:c,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+o,u_opacity:s}},t8=(r,n,o,s,a,l,c)=>i.extend(tm(r,n,o,s),tf(l,n,c),{u_height_factor:-Math.pow(2,a.overscaledZ)/c.tileSize/8}),tg=i=>({u_matrix:i}),ty=(r,n,o,s)=>i.extend(tg(r),tf(o,n,s)),tx=(i,r)=>({u_matrix:i,u_world:r}),t$=(r,n,o,s,a)=>i.extend(ty(r,n,o,s),{u_world:a}),tv=(r,n,o,s)=>{const a=r.transform;let l;return l="map"===s.paint.get("circle-pitch-alignment")?a.calculatePixelsToTileUnitsMatrix(o):new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1],]),{u_camera_to_center_distance:a.cameraToCenterDistance,u_matrix:r.translatePosMatrix(n.projMatrix,o,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:i.exported.devicePixelRatio,u_extrude_scale:l}},t_=i=>{const r=[];return"map"===i.paint.get("circle-pitch-alignment")&&r.push("PITCH_WITH_MAP"),"map"===i.paint.get("circle-pitch-scale")&&r.push("SCALE_WITH_MAP"),r},tb=(r,n,o)=>{const s=i.EXTENT/o.tileSize;return{u_matrix:r,u_camera_to_center_distance:n.cameraToCenterDistance,u_extrude_scale:[n.pixelsToGLUnits[0]/s,n.pixelsToGLUnits[1]/s,]}},tw=(i,r,n=1)=>({u_matrix:i,u_color:r,u_overlay:0,u_overlay_scale:n}),t0=(i,r,n,o)=>({u_matrix:i,u_extrude_scale:C(r,1,n),u_intensity:o}),tT=(r,n,o,s,a,l)=>{const c=r.transform,u=c.calculatePixelsToTileUnitsMatrix(n),h={u_matrix:tI(r,n,o,a),u_pixels_to_tile_units:u,u_device_pixel_ratio:i.exported.devicePixelRatio,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1],],u_dash_image:0,u_gradient_image:1,u_image_height:l,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if(tC(o)){const d=tS(n,r.transform);h.u_texsize=n.lineAtlasTexture.size,h.u_scale=[d,s.fromScale,s.toScale,],h.u_mix=s.t}return h},tE=(r,n,o,s,a)=>{const l=r.transform,c=tS(n,l);return{u_matrix:tI(r,n,o,a),u_texsize:n.imageAtlasTexture.size,u_pixels_to_tile_units:l.calculatePixelsToTileUnitsMatrix(n),u_device_pixel_ratio:i.exported.devicePixelRatio,u_image:0,u_scale:[c,s.fromScale,s.toScale],u_fade:s.t,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1],],u_alpha_discard_threshold:0}};function tS(i,r){return 1/C(i,1,r.tileZoom)}function tI(i,r,n,o){return i.translatePosMatrix(o||r.tileID.projMatrix,r,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}function tC(i){const r=i.paint.get("line-dasharray").value;return r.value||"constant"!==r.kind}const tz=(i,r,n,o,s,a)=>{var l,c;return{u_matrix:i,u_tl_parent:r,u_scale_parent:n,u_fade_t:o.mix,u_opacity:o.opacity*s.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:s.paint.get("raster-brightness-min"),u_brightness_high:s.paint.get("raster-brightness-max"),u_saturation_factor:(c=s.paint.get("raster-saturation"))>0?1-1/(1.001-c):-c,u_contrast_factor:(l=s.paint.get("raster-contrast"))>0?1/(1-l):1+l,u_spin_weights:tA(s.paint.get("raster-hue-rotate")),u_perspective_transform:a}};function tA(i){i*=Math.PI/180;const r=Math.sin(i),n=Math.cos(i);return[(2*n+1)/3,(-Math.sqrt(3)*r-n+1)/3,(Math.sqrt(3)*r-n+1)/3,]}const tk=(i,r,n,o,s,a,l,c,u,h,d,p,f,m)=>{const g=s.transform;return{u_is_size_zoom_constant:+("constant"===i||"source"===i),u_is_size_feature_constant:+("constant"===i||"camera"===i),u_size_t:r?r.uSizeT:0,u_size:r?r.uSize:0,u_camera_to_center_distance:g.cameraToCenterDistance,u_pitch:g.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:g.width/g.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_matrix:a,u_label_plane_matrix:l,u_coord_matrix:c,u_is_text:+u,u_pitch_with_map:+o,u_texsize:h,u_tile_id:d,u_zoom_transition:p,u_inv_rot_matrix:f,u_merc_center:m,u_texture:0}},tP=(r,n,o,s,a,l,c,u,h,d,p,f,m,g,y)=>{const{cameraToCenterDistance:x,_pitch:$}=a.transform;return i.extend(tk(r,n,o,s,a,l,c,u,h,d,f,m,g,y),{u_gamma_scale:s?x*Math.cos(a.terrain?0:$):1,u_device_pixel_ratio:i.exported.devicePixelRatio,u_is_halo:+p})},tD=(r,n,o,s,a,l,c,u,h,d,p,f,m,g)=>i.extend(tP(r,n,o,s,a,l,c,u,!0,h,!0,p,f,m,g),{u_texsize_icon:d,u_texture_icon:1}),tL=(i,r,n)=>({u_matrix:i,u_opacity:r,u_color:n}),t1=(r,n,o,s,a,l)=>i.extend(function(i,r,n,o){const s=n.imageManager.getPattern(i.from.toString()),a=n.imageManager.getPattern(i.to.toString()),{width:l,height:c}=n.imageManager.getPixelSize(),u=Math.pow(2,o.tileID.overscaledZ),h=o.tileSize*Math.pow(2,n.transform.tileZoom)/u,d=h*(o.tileID.canonical.x+o.tileID.wrap*u),p=h*o.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:s.tl,u_pattern_br_a:s.br,u_pattern_tl_b:a.tl,u_pattern_br_b:a.br,u_texsize:[l,c],u_mix:r.t,u_pattern_size_a:s.displaySize,u_pattern_size_b:a.displaySize,u_scale_a:r.fromScale,u_scale_b:r.toScale,u_tile_units_to_pixels:1/C(o,1,n.transform.tileZoom),u_pixel_coord_upper:[d>>16,p>>16,],u_pixel_coord_lower:[65535&d,65535&p,]}}(s,l,o,a),{u_matrix:r,u_opacity:n}),tB={fillExtrusion:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_lightpos:new i.Uniform3f(r,n.u_lightpos),u_lightintensity:new i.Uniform1f(r,n.u_lightintensity),u_lightcolor:new i.Uniform3f(r,n.u_lightcolor),u_vertical_gradient:new i.Uniform1f(r,n.u_vertical_gradient),u_opacity:new i.Uniform1f(r,n.u_opacity)}),fillExtrusionPattern:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_lightpos:new i.Uniform3f(r,n.u_lightpos),u_lightintensity:new i.Uniform1f(r,n.u_lightintensity),u_lightcolor:new i.Uniform3f(r,n.u_lightcolor),u_vertical_gradient:new i.Uniform1f(r,n.u_vertical_gradient),u_height_factor:new i.Uniform1f(r,n.u_height_factor),u_image:new i.Uniform1i(r,n.u_image),u_texsize:new i.Uniform2f(r,n.u_texsize),u_pixel_coord_upper:new i.Uniform2f(r,n.u_pixel_coord_upper),u_pixel_coord_lower:new i.Uniform2f(r,n.u_pixel_coord_lower),u_scale:new i.Uniform3f(r,n.u_scale),u_fade:new i.Uniform1f(r,n.u_fade),u_opacity:new i.Uniform1f(r,n.u_opacity)}),fill:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix)}),fillPattern:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_image:new i.Uniform1i(r,n.u_image),u_texsize:new i.Uniform2f(r,n.u_texsize),u_pixel_coord_upper:new i.Uniform2f(r,n.u_pixel_coord_upper),u_pixel_coord_lower:new i.Uniform2f(r,n.u_pixel_coord_lower),u_scale:new i.Uniform3f(r,n.u_scale),u_fade:new i.Uniform1f(r,n.u_fade)}),fillOutline:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_world:new i.Uniform2f(r,n.u_world)}),fillOutlinePattern:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_world:new i.Uniform2f(r,n.u_world),u_image:new i.Uniform1i(r,n.u_image),u_texsize:new i.Uniform2f(r,n.u_texsize),u_pixel_coord_upper:new i.Uniform2f(r,n.u_pixel_coord_upper),u_pixel_coord_lower:new i.Uniform2f(r,n.u_pixel_coord_lower),u_scale:new i.Uniform3f(r,n.u_scale),u_fade:new i.Uniform1f(r,n.u_fade)}),circle:(r,n)=>({u_camera_to_center_distance:new i.Uniform1f(r,n.u_camera_to_center_distance),u_extrude_scale:new i.UniformMatrix2f(r,n.u_extrude_scale),u_device_pixel_ratio:new i.Uniform1f(r,n.u_device_pixel_ratio),u_matrix:new i.UniformMatrix4f(r,n.u_matrix)}),collisionBox:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_camera_to_center_distance:new i.Uniform1f(r,n.u_camera_to_center_distance),u_extrude_scale:new i.Uniform2f(r,n.u_extrude_scale)}),collisionCircle:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_inv_matrix:new i.UniformMatrix4f(r,n.u_inv_matrix),u_camera_to_center_distance:new i.Uniform1f(r,n.u_camera_to_center_distance),u_viewport_size:new i.Uniform2f(r,n.u_viewport_size)}),debug:(r,n)=>({u_color:new i.UniformColor(r,n.u_color),u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_overlay:new i.Uniform1i(r,n.u_overlay),u_overlay_scale:new i.Uniform1f(r,n.u_overlay_scale)}),clippingMask:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix)}),heatmap:(r,n)=>({u_extrude_scale:new i.Uniform1f(r,n.u_extrude_scale),u_intensity:new i.Uniform1f(r,n.u_intensity),u_matrix:new i.UniformMatrix4f(r,n.u_matrix)}),heatmapTexture:(r,n)=>({u_image:new i.Uniform1i(r,n.u_image),u_color_ramp:new i.Uniform1i(r,n.u_color_ramp),u_opacity:new i.Uniform1f(r,n.u_opacity)}),hillshade:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_image:new i.Uniform1i(r,n.u_image),u_latrange:new i.Uniform2f(r,n.u_latrange),u_light:new i.Uniform2f(r,n.u_light),u_shadow:new i.UniformColor(r,n.u_shadow),u_highlight:new i.UniformColor(r,n.u_highlight),u_accent:new i.UniformColor(r,n.u_accent)}),hillshadePrepare:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_image:new i.Uniform1i(r,n.u_image),u_dimension:new i.Uniform2f(r,n.u_dimension),u_zoom:new i.Uniform1f(r,n.u_zoom),u_unpack:new i.Uniform4f(r,n.u_unpack)}),line:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_pixels_to_tile_units:new i.UniformMatrix2f(r,n.u_pixels_to_tile_units),u_device_pixel_ratio:new i.Uniform1f(r,n.u_device_pixel_ratio),u_units_to_pixels:new i.Uniform2f(r,n.u_units_to_pixels),u_dash_image:new i.Uniform1i(r,n.u_dash_image),u_gradient_image:new i.Uniform1i(r,n.u_gradient_image),u_image_height:new i.Uniform1f(r,n.u_image_height),u_texsize:new i.Uniform2f(r,n.u_texsize),u_scale:new i.Uniform3f(r,n.u_scale),u_mix:new i.Uniform1f(r,n.u_mix),u_alpha_discard_threshold:new i.Uniform1f(r,n.u_alpha_discard_threshold)}),linePattern:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_texsize:new i.Uniform2f(r,n.u_texsize),u_pixels_to_tile_units:new i.UniformMatrix2f(r,n.u_pixels_to_tile_units),u_device_pixel_ratio:new i.Uniform1f(r,n.u_device_pixel_ratio),u_image:new i.Uniform1i(r,n.u_image),u_units_to_pixels:new i.Uniform2f(r,n.u_units_to_pixels),u_scale:new i.Uniform3f(r,n.u_scale),u_fade:new i.Uniform1f(r,n.u_fade),u_alpha_discard_threshold:new i.Uniform1f(r,n.u_alpha_discard_threshold)}),raster:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_tl_parent:new i.Uniform2f(r,n.u_tl_parent),u_scale_parent:new i.Uniform1f(r,n.u_scale_parent),u_fade_t:new i.Uniform1f(r,n.u_fade_t),u_opacity:new i.Uniform1f(r,n.u_opacity),u_image0:new i.Uniform1i(r,n.u_image0),u_image1:new i.Uniform1i(r,n.u_image1),u_brightness_low:new i.Uniform1f(r,n.u_brightness_low),u_brightness_high:new i.Uniform1f(r,n.u_brightness_high),u_saturation_factor:new i.Uniform1f(r,n.u_saturation_factor),u_contrast_factor:new i.Uniform1f(r,n.u_contrast_factor),u_spin_weights:new i.Uniform3f(r,n.u_spin_weights),u_perspective_transform:new i.Uniform2f(r,n.u_perspective_transform)}),symbolIcon:(r,n)=>({u_is_size_zoom_constant:new i.Uniform1i(r,n.u_is_size_zoom_constant),u_is_size_feature_constant:new i.Uniform1i(r,n.u_is_size_feature_constant),u_size_t:new i.Uniform1f(r,n.u_size_t),u_size:new i.Uniform1f(r,n.u_size),u_camera_to_center_distance:new i.Uniform1f(r,n.u_camera_to_center_distance),u_pitch:new i.Uniform1f(r,n.u_pitch),u_rotate_symbol:new i.Uniform1i(r,n.u_rotate_symbol),u_aspect_ratio:new i.Uniform1f(r,n.u_aspect_ratio),u_fade_change:new i.Uniform1f(r,n.u_fade_change),u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_label_plane_matrix:new i.UniformMatrix4f(r,n.u_label_plane_matrix),u_coord_matrix:new i.UniformMatrix4f(r,n.u_coord_matrix),u_is_text:new i.Uniform1i(r,n.u_is_text),u_pitch_with_map:new i.Uniform1i(r,n.u_pitch_with_map),u_texsize:new i.Uniform2f(r,n.u_texsize),u_tile_id:new i.Uniform3f(r,n.u_tile_id),u_zoom_transition:new i.Uniform1f(r,n.u_zoom_transition),u_inv_rot_matrix:new i.UniformMatrix4f(r,n.u_inv_rot_matrix),u_merc_center:new i.Uniform2f(r,n.u_merc_center),u_texture:new i.Uniform1i(r,n.u_texture)}),symbolSDF:(r,n)=>({u_is_size_zoom_constant:new i.Uniform1i(r,n.u_is_size_zoom_constant),u_is_size_feature_constant:new i.Uniform1i(r,n.u_is_size_feature_constant),u_size_t:new i.Uniform1f(r,n.u_size_t),u_size:new i.Uniform1f(r,n.u_size),u_camera_to_center_distance:new i.Uniform1f(r,n.u_camera_to_center_distance),u_pitch:new i.Uniform1f(r,n.u_pitch),u_rotate_symbol:new i.Uniform1i(r,n.u_rotate_symbol),u_aspect_ratio:new i.Uniform1f(r,n.u_aspect_ratio),u_fade_change:new i.Uniform1f(r,n.u_fade_change),u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_label_plane_matrix:new i.UniformMatrix4f(r,n.u_label_plane_matrix),u_coord_matrix:new i.UniformMatrix4f(r,n.u_coord_matrix),u_is_text:new i.Uniform1i(r,n.u_is_text),u_pitch_with_map:new i.Uniform1i(r,n.u_pitch_with_map),u_texsize:new i.Uniform2f(r,n.u_texsize),u_texture:new i.Uniform1i(r,n.u_texture),u_gamma_scale:new i.Uniform1f(r,n.u_gamma_scale),u_device_pixel_ratio:new i.Uniform1f(r,n.u_device_pixel_ratio),u_tile_id:new i.Uniform3f(r,n.u_tile_id),u_zoom_transition:new i.Uniform1f(r,n.u_zoom_transition),u_inv_rot_matrix:new i.UniformMatrix4f(r,n.u_inv_rot_matrix),u_merc_center:new i.Uniform2f(r,n.u_merc_center),u_is_halo:new i.Uniform1i(r,n.u_is_halo)}),symbolTextAndIcon:(r,n)=>({u_is_size_zoom_constant:new i.Uniform1i(r,n.u_is_size_zoom_constant),u_is_size_feature_constant:new i.Uniform1i(r,n.u_is_size_feature_constant),u_size_t:new i.Uniform1f(r,n.u_size_t),u_size:new i.Uniform1f(r,n.u_size),u_camera_to_center_distance:new i.Uniform1f(r,n.u_camera_to_center_distance),u_pitch:new i.Uniform1f(r,n.u_pitch),u_rotate_symbol:new i.Uniform1i(r,n.u_rotate_symbol),u_aspect_ratio:new i.Uniform1f(r,n.u_aspect_ratio),u_fade_change:new i.Uniform1f(r,n.u_fade_change),u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_label_plane_matrix:new i.UniformMatrix4f(r,n.u_label_plane_matrix),u_coord_matrix:new i.UniformMatrix4f(r,n.u_coord_matrix),u_is_text:new i.Uniform1i(r,n.u_is_text),u_pitch_with_map:new i.Uniform1i(r,n.u_pitch_with_map),u_texsize:new i.Uniform2f(r,n.u_texsize),u_texsize_icon:new i.Uniform2f(r,n.u_texsize_icon),u_texture:new i.Uniform1i(r,n.u_texture),u_texture_icon:new i.Uniform1i(r,n.u_texture_icon),u_gamma_scale:new i.Uniform1f(r,n.u_gamma_scale),u_device_pixel_ratio:new i.Uniform1f(r,n.u_device_pixel_ratio),u_is_halo:new i.Uniform1i(r,n.u_is_halo)}),background:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_opacity:new i.Uniform1f(r,n.u_opacity),u_color:new i.UniformColor(r,n.u_color)}),backgroundPattern:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_opacity:new i.Uniform1f(r,n.u_opacity),u_image:new i.Uniform1i(r,n.u_image),u_pattern_tl_a:new i.Uniform2f(r,n.u_pattern_tl_a),u_pattern_br_a:new i.Uniform2f(r,n.u_pattern_br_a),u_pattern_tl_b:new i.Uniform2f(r,n.u_pattern_tl_b),u_pattern_br_b:new i.Uniform2f(r,n.u_pattern_br_b),u_texsize:new i.Uniform2f(r,n.u_texsize),u_mix:new i.Uniform1f(r,n.u_mix),u_pattern_size_a:new i.Uniform2f(r,n.u_pattern_size_a),u_pattern_size_b:new i.Uniform2f(r,n.u_pattern_size_b),u_scale_a:new i.Uniform1f(r,n.u_scale_a),u_scale_b:new i.Uniform1f(r,n.u_scale_b),u_pixel_coord_upper:new i.Uniform2f(r,n.u_pixel_coord_upper),u_pixel_coord_lower:new i.Uniform2f(r,n.u_pixel_coord_lower),u_tile_units_to_pixels:new i.Uniform1f(r,n.u_tile_units_to_pixels)}),terrainRaster:eQ,terrainDepth:eQ,skybox:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_sun_direction:new i.Uniform3f(r,n.u_sun_direction),u_cubemap:new i.Uniform1i(r,n.u_cubemap),u_opacity:new i.Uniform1f(r,n.u_opacity),u_temporal_offset:new i.Uniform1f(r,n.u_temporal_offset)}),skyboxGradient:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_color_ramp:new i.Uniform1i(r,n.u_color_ramp),u_center_direction:new i.Uniform3f(r,n.u_center_direction),u_radius:new i.Uniform1f(r,n.u_radius),u_opacity:new i.Uniform1f(r,n.u_opacity),u_temporal_offset:new i.Uniform1f(r,n.u_temporal_offset)}),skyboxCapture:(r,n)=>({u_matrix_3f:new i.UniformMatrix3f(r,n.u_matrix_3f),u_sun_direction:new i.Uniform3f(r,n.u_sun_direction),u_sun_intensity:new i.Uniform1f(r,n.u_sun_intensity),u_color_tint_r:new i.Uniform4f(r,n.u_color_tint_r),u_color_tint_m:new i.Uniform4f(r,n.u_color_tint_m),u_luminance:new i.Uniform1f(r,n.u_luminance)}),globeRaster:(r,n)=>({u_proj_matrix:new i.UniformMatrix4f(r,n.u_proj_matrix),u_globe_matrix:new i.UniformMatrix4f(r,n.u_globe_matrix),u_merc_matrix:new i.UniformMatrix4f(r,n.u_merc_matrix),u_zoom_transition:new i.Uniform1f(r,n.u_zoom_transition),u_merc_center:new i.Uniform2f(r,n.u_merc_center),u_image0:new i.Uniform1i(r,n.u_image0)}),globeAtmosphere:(r,n)=>({u_center:new i.Uniform2f(r,n.u_center),u_radius:new i.Uniform1f(r,n.u_radius),u_screen_size:new i.Uniform2f(r,n.u_screen_size),u_pixel_ratio:new i.Uniform1f(r,n.u_pixel_ratio),u_opacity:new i.Uniform1f(r,n.u_opacity),u_fadeout_range:new i.Uniform1f(r,n.u_fadeout_range),u_start_color:new i.Uniform3f(r,n.u_start_color),u_end_color:new i.Uniform3f(r,n.u_end_color)})};let tR;function t3(r,n,o,s,a,l,c){var u;const h=r.context,d=h.gl,p=r.useProgram("collisionBox"),f=[];let m=0,g=0;for(let y=0;y0){const T=i.create(),E=_;i.mul(T,v.placementInvProjMatrix,r.transform.glCoordMatrix),i.mul(T,T,v.placementViewportMatrix),f.push({circleArray:w,circleOffset:g,transform:E,invTransform:T}),m+=w.length/4,g=m}b&&(r.terrain&&r.terrain.setupElevationDraw($,p),p.draw(h,d.LINES,i.DepthMode.disabled,i.StencilMode.disabled,r.colorModeForRenderPass(),i.CullFaceMode.disabled,tb(_,r.transform,$),o.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,null,r.transform.zoom,null,b.collisionVertexBuffer,b.collisionVertexBufferExt))}if(!c||!f.length)return;const S=r.useProgram("collisionCircle"),I=new i.StructArrayLayout2f1f2i16;I.resize(4*m),I._trim();let C=0;for(const z of f)for(let A=0;A[0,0,0];g.clear();for(let b=0;b=0&&(x[w.associatedIconIndex]={shiftedAnchor:M,angle:F})}else eS(w.numGlyphs,g)}if(p){y.clear();const U=r.icon.placedSymbolArray;for(let V=0;V[0,0,0];e$(L,P.projMatrix,r,a,J,ee,v,d,en,P)}const eo=r.translatePosMatrix(P.projMatrix,D,l,c),es=_||a&&I||ei?tM:J,ea=r.translatePosMatrix(ee,D,l,c,!0),el=M&&0!==o.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1);let ec;const eu=x.createInversionMatrix(P.toUnwrapped());ec=M?L.iconsInText?tD(F.kind,V,b,v,r,eo,es,ea,N,X,j,z,eu,S):tP(F.kind,V,b,v,r,eo,es,ea,a,N,!0,j,z,eu,S):tk(F.kind,V,b,v,r,eo,es,ea,a,N,j,z,eu,S);const eh={program:U,buffers:B,uniformValues:ec,atlasTexture:G,atlasTextureIcon:W,atlasInterpolation:Z,atlasInterpolationIcon:q,isSDF:M,hasHalo:el,tile:D,labelPlaneMatrixInv:Q};if(w&&L.canOverlap){T=!0;const ed=B.segments.get();for(const ep of ed)A.push({segments:new i.SegmentVector([ep]),sortKey:ep.sortKey,state:eh})}else A.push({segments:B.segments,sortKey:0,state:eh})}for(const ef of(T&&A.sort((i,r)=>i.sortKey-r.sortKey),A)){const eg=ef.state;if(r.terrain&&r.terrain.setupElevationDraw(eg.tile,eg.program,{useDepthForOcclusion:!C,labelPlaneMatrixInv:eg.labelPlaneMatrixInv}),m.activeTexture.set(g.TEXTURE0),eg.atlasTexture.bind(eg.atlasInterpolation,g.CLAMP_TO_EDGE),eg.atlasTextureIcon&&(m.activeTexture.set(g.TEXTURE1),eg.atlasTextureIcon&&eg.atlasTextureIcon.bind(eg.atlasInterpolationIcon,g.CLAMP_TO_EDGE)),eg.isSDF){const ey=eg.uniformValues;eg.hasHalo&&(ey.u_is_halo=1,tU(eg.buffers,ef.segments,o,r,eg.program,E,p,f,ey)),ey.u_is_halo=0}tU(eg.buffers,ef.segments,o,r,eg.program,E,p,f,eg.uniformValues)}}function tU(r,n,o,s,a,l,c,u,h){const d=s.context;a.draw(d,d.gl.TRIANGLES,l,c,u,i.CullFaceMode.disabled,h,o.id,r.layoutVertexBuffer,r.indexBuffer,n,o.paint,s.transform.zoom,r.programConfigurations.get(o.id),r.dynamicLayoutVertexBuffer,r.opacityVertexBuffer)}function tV(r,n,o,s,a,l,c){const u=r.context.gl,h=o.paint.get("fill-pattern"),d=h&&h.constantOr(1),p=o.getCrossfadeParameters();let f,m,g,y,x;for(const $ of(c?(m=d&&!o.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",f=u.LINES):(m=d?"fillPattern":"fill",f=u.TRIANGLES),s)){const v=n.getTile($);if(d&&!v.patternsLoaded())continue;const _=v.getBucket(o);if(!_)continue;r.prepareDrawTile($);const b=_.programConfigurations.get(o.id),w=r.useProgram(m,b);d&&(r.context.activeTexture.set(u.TEXTURE0),v.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),b.updatePaintBuffers(p));const T=h.constantOr(null);if(T&&v.imageAtlas){const E=v.imageAtlas,S=E.patternPositions[T.to.toString()],I=E.patternPositions[T.from.toString()];S&&I&&b.setConstantPatternPositions(S,I)}const C=r.translatePosMatrix($.projMatrix,v,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor"));if(c){y=_.indexBuffer2,x=_.segments2;const z=r.terrain&&r.terrain.renderingToTexture?r.terrain.drapeBufferSize:[u.drawingBufferWidth,u.drawingBufferHeight,];g="fillOutlinePattern"===m&&d?t$(C,r,p,v,z):tx(C,z)}else y=_.indexBuffer,x=_.segments,g=d?ty(C,r,p,v):tg(C);r.prepareDrawProgram(r.context,w,$.toUnwrapped()),w.draw(r.context,f,a,r.stencilModeForClipping($),l,i.CullFaceMode.disabled,g,o.id,_.layoutVertexBuffer,y,x,o.paint,r.transform.zoom,b)}}function t6(r,n,o,s,a,l,c){const u=r.context,h=u.gl,d=o.paint.get("fill-extrusion-pattern"),p=d.constantOr(1),f=o.getCrossfadeParameters(),m=o.paint.get("fill-extrusion-opacity");for(const g of s){const y=n.getTile(g),x=y.getBucket(o);if(!x)continue;const $=x.programConfigurations.get(o.id),v=r.useProgram(p?"fillExtrusionPattern":"fillExtrusion",$);if(r.terrain){const _=r.terrain;if(!x.enableTerrain)continue;if(_.setupElevationDraw(y,v,{useMeterToDem:!0}),tj(u,n,g,x,o,_),!x.centroidVertexBuffer){const b=v.attributes.a_centroid_pos;void 0!==b&&h.vertexAttrib2f(b,0,0)}}p&&(r.context.activeTexture.set(h.TEXTURE0),y.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),$.updatePaintBuffers(f));const w=d.constantOr(null);if(w&&y.imageAtlas){const T=y.imageAtlas,E=T.patternPositions[w.to.toString()],S=T.patternPositions[w.from.toString()];E&&S&&$.setConstantPatternPositions(E,S)}const I=r.translatePosMatrix(g.projMatrix,y,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),C=o.paint.get("fill-extrusion-vertical-gradient"),z=p?t8(I,r,C,m,g,f,y):tm(I,r,C,m);r.prepareDrawProgram(u,v,g.toUnwrapped()),v.draw(u,u.gl.TRIANGLES,a,l,c,i.CullFaceMode.backCCW,z,o.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,o.paint,r.transform.zoom,$,r.terrain?x.centroidVertexBuffer:null)}}function tj(r,n,o,s,a,l){const c=[r=>{let n=r.canonical.x-1,o=r.wrap;return n<0&&(n=(1<{let n=r.canonical.x+1,o=r.wrap;return n===1<new i.OverscaledTileID(r.overscaledZ,r.wrap,r.canonical.z,r.canonical.x,(0===r.canonical.y?1<new i.OverscaledTileID(r.overscaledZ,r.wrap,r.canonical.z,r.canonical.x,r.canonical.y===(1<{const r=n.getSource().maxzoom,o=i=>{const r=n.getTileByID(i);if(r&&r.hasData())return r.getBucket(a)};let s,l,c;return(i.overscaledZ===i.canonical.z||i.overscaledZ>=r)&&(s=o(i.key)),i.overscaledZ>=r&&(l=o(i.calculateScaledKey(i.overscaledZ+1))),i.overscaledZ>r&&(c=o(i.calculateScaledKey(i.overscaledZ-1))),s||l||c},h=[0,0,0],d=(r,n)=>(h[0]=Math.min(r.min.y,n.min.y),h[1]=Math.max(r.max.y,n.max.y),h[2]=i.EXTENT-n.min.x>r.max.x?n.min.x-i.EXTENT:r.max.x,h),p=(r,n)=>(h[0]=Math.min(r.min.x,n.min.x),h[1]=Math.max(r.max.x,n.max.x),h[2]=i.EXTENT-n.min.y>r.max.y?n.min.y-i.EXTENT:r.max.y,h),f=[(i,r)=>d(i,r),(i,r)=>d(r,i),(i,r)=>p(i,r),(i,r)=>p(r,i),],m=new i.pointGeometry(0,0);let g,y,x;const $=(r,n,s,a,c)=>{const u=[[a?s:r,a?r:s,0],[a?s:n,a?n:s,0],],h=c<0?i.EXTENT+c:c,d=[a?h:(r+n)/2,a?(r+n)/2:h,0,];return 0===s&&c<0||0!==s&&c>0?l.getForTilePoints(x,[d],!0,y):u.push(d),l.getForTilePoints(o,u,!0,g),Math.max(u[0][2],u[1][2],d[2])/l.exaggeration()};for(let v=0;v<4;v++){const _=s.borders[v];if(0===_.length&&(s.borderDone[v]=!0),s.borderDone[v])continue;const b=x=c[v](o),w=u(b);if(!w||!w.enableTerrain||!(y=l.findDEMTileFor(b))||!y.dem)continue;if(!g){const T=l.findDEMTileFor(o);if(!T||!T.dem)return;g=T}const E=(v<2?1:5)-v,S=w.borders[E];let I=0;for(let C=0;C<_.length;C++){const z=s.featuresOnBorder[_[C]],A=z.borders[v];let k;for(;IA[0]+3);)w.borderDone[E]||w.encodeCentroid(void 0,k,!1),I++;if(k&&IA[1]-3)&&(D++,++I!==S.length);)k=w.featuresOnBorder[S[I]];if(k=w.featuresOnBorder[S[P]],z.intersectsCount()>1||k.intersectsCount()>1||1!==D){1!==D&&(I=P),s.encodeCentroid(void 0,z,!1),w.borderDone[E]||w.encodeCentroid(void 0,k,!1);continue}const L=f[v](z,k),B=v%2?i.EXTENT-1:0;m.x=$(L[0],Math.min(i.EXTENT-1,L[1]),B,v<2,L[2]),m.y=0,s.encodeCentroid(m,z,!1),w.borderDone[E]||w.encodeCentroid(m,k,!1)}else s.encodeCentroid(void 0,z,!1)}s.borderDone[v]=s.needsCentroidUpdate=!0,w.borderDone[E]||(w.borderDone[E]=w.needsCentroidUpdate=!0)}(s.needsCentroidUpdate||!s.centroidVertexBuffer&&0!==s.centroidVertexArray.length)&&s.uploadCentroid(r)}const tN=new i.Color(1,0,0,1),tG=new i.Color(0,1,0,1),tZ=new i.Color(0,0,1,1),t9=new i.Color(1,0,1,1),t7=new i.Color(0,1,1,1);function tq(i,r,n,o){tX(i,0,r+n/2,i.transform.width,n,o)}function t5(i,r,n,o){tX(i,r-n/2,0,n,i.transform.height,o)}function tX(r,n,o,s,a,l){const c=r.context,u=c.gl;u.enable(u.SCISSOR_TEST),u.scissor(n*i.exported.devicePixelRatio,o*i.exported.devicePixelRatio,s*i.exported.devicePixelRatio,a*i.exported.devicePixelRatio),c.clear({color:l}),u.disable(u.SCISSOR_TEST)}function tW(r,n,o){const s=r.context,a=s.gl,l=o.projMatrix,c=r.useProgram("debug"),u=n.getTileByID(o.key);r.terrain&&r.terrain.setupElevationDraw(u,c);const h=i.DepthMode.disabled,d=i.StencilMode.disabled,p=r.colorModeForRenderPass(),f="$debug";s.activeTexture.set(a.TEXTURE0),r.emptyTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),u._makeDebugTileBoundsBuffers(r.context,r.transform.projection);const m=u._tileDebugBuffer||r.debugBuffer,g=u._tileDebugIndexBuffer||r.debugIndexBuffer,y=u._tileDebugSegments||r.debugSegments;c.draw(s,a.LINE_STRIP,h,d,p,i.CullFaceMode.disabled,tw(l,i.Color.red),f,m,g,y);const x=u.latestRawTileData,$=Math.floor((x&&x.byteLength||0)/1024),v=n.getTile(o).tileSize,_=512/Math.min(v,512)*(o.overscaledZ/r.transform.zoom)*.5;let b=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(b+=` => ${o.overscaledZ}`),function(i,r){i.initDebugOverlayCanvas();const n=i.debugOverlayCanvas,o=i.context.gl,s=i.debugOverlayCanvas.getContext("2d");s.clearRect(0,0,n.width,n.height),s.shadowColor="white",s.shadowBlur=2,s.lineWidth=1.5,s.strokeStyle="white",s.textBaseline="top",s.font="bold 36px Open Sans, sans-serif",s.fillText(r,5,5),s.strokeText(r,5,5),i.debugOverlayTexture.update(n),i.debugOverlayTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE)}(r,`${b} ${$}kb`),c.draw(s,a.TRIANGLES,h,d,i.ColorMode.alphaBlended,i.CullFaceMode.disabled,tw(l,i.Color.transparent,_),f,r.debugBuffer,r.quadTriangleIndexBuffer,r.debugSegments)}const tH=i.createLayout([{name:"a_pos_3f",components:3,type:"Float32"},]),{members:tK}=tH;function tY(i,r,n,o){i.emplaceBack(r,n,o)}class tJ{constructor(r){this.vertexArray=new i.StructArrayLayout3f12,this.indices=new i.StructArrayLayout3ui6,tY(this.vertexArray,-1,-1,1),tY(this.vertexArray,1,-1,1),tY(this.vertexArray,-1,1,1),tY(this.vertexArray,1,1,1),tY(this.vertexArray,-1,-1,-1),tY(this.vertexArray,1,-1,-1),tY(this.vertexArray,-1,1,-1),tY(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=r.createVertexBuffer(this.vertexArray,tK),this.indexBuffer=r.createIndexBuffer(this.indices),this.segment=i.SegmentVector.simpleSegment(0,0,36,12)}}function tQ(r,n,o,s,a,l){var c,u,h,d,p;const f=r.gl,m=n.paint.get("sky-atmosphere-color"),g=n.paint.get("sky-atmosphere-halo-color"),y=n.paint.get("sky-atmosphere-sun-intensity"),x=(c=i.fromMat4([],s),u=a,h=y,d=m,p=g,{u_matrix_3f:c,u_sun_direction:u,u_sun_intensity:h,u_color_tint_r:[d.r,d.g,d.b,d.a],u_color_tint_m:[p.r,p.g,p.b,p.a],u_luminance:5e-5});f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_CUBE_MAP_POSITIVE_X+l,n.skyboxTexture,0),o.draw(r,f.TRIANGLES,i.DepthMode.disabled,i.StencilMode.disabled,i.ColorMode.unblended,i.CullFaceMode.frontCW,x,"skyboxCapture",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}const ie={symbol:function(r,n,o,s,a){if("translucent"!==r.renderPass)return;const l=i.StencilMode.disabled,c=r.colorModeForRenderPass();o.layout.get("text-variable-anchor")&&function(r,n,o,s,a,l,c){const u=n.transform,h="map"===a,d="map"===l,p=u.projection.createTileTransform(u,u.worldSize);for(const f of r){const m=s.getTile(f),g=m.getBucket(o);if(!g||g.projection!==u.projection.name||!g.text||!g.text.segments.get().length)continue;const y=i.evaluateSizeForZoom(g.textSizeData,u.zoom),x=n.transform.calculatePixelsToTileUnitsMatrix(m),$=em(f.projMatrix,m.tileID.canonical,d,h,n.transform,x),v="none"!==o.layout.get("icon-text-fit")&&g.hasIconData();if(y){const _=Math.pow(2,u.zoom-m.tileID.overscaledZ);tF(g,h,d,c,i.symbolSize,u,$,f,_,y,v,p)}}}(s,r,o,n,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),a),0!==o.paint.get("icon-opacity").constantOr(1)&&t4(r,n,o,s,!1,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),o.layout.get("icon-rotation-alignment"),o.layout.get("icon-pitch-alignment"),o.layout.get("icon-keep-upright"),l,c),0!==o.paint.get("text-opacity").constantOr(1)&&t4(r,n,o,s,!0,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),o.layout.get("text-keep-upright"),l,c),n.map.showCollisionBoxes&&(t3(r,n,o,s,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),t3(r,n,o,s,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1))},circle:function(r,n,o,s){if("translucent"!==r.renderPass)return;const a=o.paint.get("circle-opacity"),l=o.paint.get("circle-stroke-width"),c=o.paint.get("circle-stroke-opacity"),u=void 0!==o.layout.get("circle-sort-key").constantOr(1);if(0===a.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const h=r.context,d=h.gl,p=r.depthModeForSublayer(0,i.DepthMode.ReadOnly),f=i.StencilMode.disabled,m=r.colorModeForRenderPass(),g=[];for(let y=0;yi.sortKey-r.sortKey);const S={useDepthForOcclusion:"globe"!==r.transform.projection.name};for(const I of g){const{programConfiguration:C,program:z,layoutVertexBuffer:A,indexBuffer:k,uniformValues:P,tile:D}=I.state,L=I.segments;r.terrain&&r.terrain.setupElevationDraw(D,z,S),r.prepareDrawProgram(h,z,D.tileID.toUnwrapped()),z.draw(h,d.TRIANGLES,p,f,m,i.CullFaceMode.disabled,P,o.id,A,k,L,o.paint,r.transform.zoom,C)}},heatmap:function(r,n,o,s){if(0!==o.paint.get("heatmap-opacity")){if("offscreen"===r.renderPass){const a=r.context,l=a.gl,c=i.StencilMode.disabled,u=new i.ColorMode([l.ONE,l.ONE],i.Color.transparent,[!0,!0,!0,!0]);(function(i,r,n){const o=i.gl;i.activeTexture.set(o.TEXTURE1),i.viewport.set([0,0,r.width/4,r.height/4,]);let s=n.heatmapFbo;if(s)o.bindTexture(o.TEXTURE_2D,s.colorAttachment.get()),i.bindFramebuffer.set(s.framebuffer);else{const a=o.createTexture();o.bindTexture(o.TEXTURE_2D,a),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.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR),s=n.heatmapFbo=i.createFramebuffer(r.width/4,r.height/4,!1),function(i,r,n,o){const s=i.gl;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,r.width/4,r.height/4,0,s.RGBA,i.extRenderToTextureHalfFloat?i.extTextureHalfFloat.HALF_FLOAT_OES:s.UNSIGNED_BYTE,null),o.colorAttachment.set(n)}(i,r,a,s)}})(a,r,o),a.clear({color:i.Color.transparent});for(let h=0;h{const r=[];tC(i)&&r.push("RENDER_LINE_DASH"),i.paint.get("line-gradient")&&r.push("RENDER_LINE_GRADIENT");const n=i.paint.get("line-pattern").constantOr(1),o=1!==i.paint.get("line-opacity").constantOr(1);return!n&&o&&r.push("RENDER_LINE_ALPHA_DISCARD"),r})(o);let b=_.includes("RENDER_LINE_ALPHA_DISCARD");for(const w of(r.terrain&&r.terrain.clipOrMaskOverlapStencilType()&&(b=!1),s)){const T=n.getTile(w);if(m&&!T.patternsLoaded())continue;const E=T.getBucket(o);if(!E)continue;r.prepareDrawTile(w);const S=E.programConfigurations.get(o.id),I=r.useProgram(x,S,_),C=f.constantOr(null);if(C&&T.imageAtlas){const z=T.imageAtlas,A=z.patternPositions[C.to.toString()],k=z.patternPositions[C.from.toString()];A&&k&&S.setConstantPatternPositions(A,k)}const P=h.constantOr(null),D=p.constantOr(null);if(!m&&P&&D&&T.lineAtlas){const L=T.lineAtlas,B=L.getDash(P.to,D),R=L.getDash(P.from,D);B&&R&&S.setConstantPatternPositions(B,R)}const M=r.terrain?w.projMatrix:null,F=m?tE(r,T,o,y,M):tT(r,T,o,y,M,E.lineClipsArray.length);if(g){const O=E.gradients[o.id];let U=O.texture;if(o.gradientVersion!==O.version){let V=256;if(o.stepInterpolant){const j=n.getSource().maxzoom,N=w.canonical.z===j?Math.ceil(1<{I.draw($,v.TRIANGLES,c,n,u,i.CullFaceMode.disabled,F,o.id,E.layoutVertexBuffer,E.indexBuffer,E.segments,o.paint,r.transform.zoom,S,E.layoutVertexBuffer2)};if(b){const Z=r.stencilModeForClipping(w).ref;0===Z&&r.terrain&&$.clear({stencil:0});const q={func:v.EQUAL,mask:255};F.u_alpha_discard_threshold=.8,G(new i.StencilMode(q,Z,255,v.KEEP,v.KEEP,v.INVERT)),F.u_alpha_discard_threshold=0,G(new i.StencilMode(q,Z,255,v.KEEP,v.KEEP,v.KEEP))}else G(r.stencilModeForClipping(w))}b&&(r.resetStencilClippingMasks(),r.terrain&&$.clear({stencil:0}))},fill:function(r,n,o,s){const a=o.paint.get("fill-color"),l=o.paint.get("fill-opacity");if(0===l.constantOr(1))return;const c=r.colorModeForRenderPass(),u=o.paint.get("fill-pattern"),h=r.opaquePassEnabledForLayer()&&!u.constantOr(1)&&1===a.constantOr(i.Color.transparent).a&&1===l.constantOr(0)?"opaque":"translucent";if(r.renderPass===h){const d=r.depthModeForSublayer(1,"opaque"===r.renderPass?i.DepthMode.ReadWrite:i.DepthMode.ReadOnly);tV(r,n,o,s,d,c,!1)}if("translucent"===r.renderPass&&o.paint.get("fill-antialias")){const p=r.depthModeForSublayer(o.getPaintProperty("fill-outline-color")?2:0,i.DepthMode.ReadOnly);tV(r,n,o,s,p,c,!0)}},"fill-extrusion":function(r,n,o,s){const a=o.paint.get("fill-extrusion-opacity");if(0!==a&&"translucent"===r.renderPass){const l=new i.DepthMode(r.context.gl.LEQUAL,i.DepthMode.ReadWrite,r.depthRangeFor3D);if(1!==a||o.paint.get("fill-extrusion-pattern").constantOr(1))t6(r,n,o,s,l,i.StencilMode.disabled,i.ColorMode.disabled),t6(r,n,o,s,l,r.stencilModeFor3D(),r.colorModeForRenderPass()),r.resetStencilClippingMasks();else{const c=r.colorModeForRenderPass();t6(r,n,o,s,l,i.StencilMode.disabled,c)}}},hillshade:function(r,n,o,s){if("offscreen"!==r.renderPass&&"translucent"!==r.renderPass)return;const a=r.context,l=r.depthModeForSublayer(0,i.DepthMode.ReadOnly),c=r.colorModeForRenderPass(),u=r.terrain&&r.terrain.renderingToTexture,[h,d]="translucent"!==r.renderPass||u?[{},s]:r.stencilConfigForOverlap(s);for(const p of d){const f=n.getTile(p);if(f.needsHillshadePrepare&&"offscreen"===r.renderPass)eJ(r,f,o,l,i.StencilMode.disabled,c);else if("translucent"===r.renderPass){const m=u&&r.terrain?r.terrain.stencilModeForRTTOverlap(p):h[p.overscaledZ];eK(r,p,f,o,l,m,c)}}a.viewport.set([0,0,r.width,r.height]),r.resetStencilClippingMasks()},raster:function(r,n,o,s,a,l){if("translucent"!==r.renderPass||0===o.paint.get("raster-opacity")||!s.length)return;const c=r.context,u=c.gl,h=n.getSource(),d=r.useProgram("raster"),p=r.colorModeForRenderPass(),f=r.terrain&&r.terrain.renderingToTexture,[m,g]=h instanceof G||f?[{},s]:r.stencilConfigForOverlap(s),y=g[g.length-1].overscaledZ,x=!r.options.moving;for(const $ of g){const v=f?i.DepthMode.disabled:r.depthModeForSublayer($.overscaledZ-y,1===o.paint.get("raster-opacity")?i.DepthMode.ReadWrite:i.DepthMode.ReadOnly,u.LESS),_=$.toUnwrapped(),b=n.getTile($);if(f&&(!b||!b.hasData()))continue;const w=f?$.projMatrix:r.transform.calculateProjMatrix(_,x),T=r.terrain&&f?r.terrain.stencilModeForRTTOverlap($):m[$.overscaledZ],E=l?0:o.paint.get("raster-fade-duration");b.registerFadeDuration(E);const S=n.findLoadedParent($,0),I=ta(b,S,n,r.transform,E);let C,z;r.terrain&&r.terrain.prepareDrawTile($);const A="nearest"===o.paint.get("raster-resampling")?u.NEAREST:u.LINEAR;c.activeTexture.set(u.TEXTURE0),b.texture.bind(A,u.CLAMP_TO_EDGE),c.activeTexture.set(u.TEXTURE1),S?(S.texture.bind(A,u.CLAMP_TO_EDGE),C=Math.pow(2,S.tileID.overscaledZ-b.tileID.overscaledZ),z=[b.tileID.canonical.x*C%1,b.tileID.canonical.y*C%1,]):b.texture.bind(A,u.CLAMP_TO_EDGE);const k=tz(w,z||[0,0],C||1,I,o,h instanceof G?h.perspectiveTransform:[0,0]);if(r.prepareDrawProgram(c,d,_),h instanceof G)d.draw(c,u.TRIANGLES,v,i.StencilMode.disabled,p,i.CullFaceMode.disabled,k,o.id,h.boundsBuffer,r.quadTriangleIndexBuffer,h.boundsSegments);else{const{tileBoundsBuffer:P,tileBoundsIndexBuffer:D,tileBoundsSegments:L}=r.getTileBoundsBuffers(b);d.draw(c,u.TRIANGLES,v,T,p,i.CullFaceMode.disabled,k,o.id,P,D,L)}}r.resetStencilClippingMasks()},background:function(r,n,o,s){const a=o.paint.get("background-color"),l=o.paint.get("background-opacity");if(0===l)return;const c=r.context,u=c.gl,h=r.transform,d=h.tileSize,p=o.paint.get("background-pattern");if(r.isPatternMissing(p))return;const f=!p&&1===a.a&&1===l&&r.opaquePassEnabledForLayer()?"opaque":"translucent";if(r.renderPass!==f)return;const m=i.StencilMode.disabled,g=r.depthModeForSublayer(0,"opaque"===f?i.DepthMode.ReadWrite:i.DepthMode.ReadOnly),y=r.colorModeForRenderPass(),x=r.useProgram(p?"backgroundPattern":"background");let $,v=s;v||(v=Object.values($=r.getBackgroundTiles()).map(i=>i.tileID)),p&&(c.activeTexture.set(u.TEXTURE0),r.imageManager.bind(r.context));const _=o.getCrossfadeParameters();for(const b of v){const w=b.toUnwrapped(),T=s?b.projMatrix:r.transform.calculateProjMatrix(w);r.prepareDrawTile(b);const E=n?n.getTile(b):$?$[b.key]:new i.Tile(b,d,h.zoom,r),S=p?t1(T,l,r,p,{tileID:b,tileSize:d},_):tL(T,l,a);r.prepareDrawProgram(c,x,w);const{tileBoundsBuffer:I,tileBoundsIndexBuffer:C,tileBoundsSegments:z}=r.getTileBoundsBuffers(E);x.draw(c,u.TRIANGLES,g,m,y,i.CullFaceMode.disabled,S,o.id,I,C,z)}},sky:function(r,n,o){const s=r.transform,a="mercator"===s.projection.name||"globe"===s.projection.name?1:i.smoothstep(7,8,s.zoom),l=o.paint.get("sky-opacity")*a;if(0===l)return;const c=r.context,u=o.paint.get("sky-type"),h=new i.DepthMode(c.gl.LEQUAL,i.DepthMode.ReadOnly,[0,1]),d=r.frameCounter/1e3%1;"atmosphere"===u?"offscreen"===r.renderPass?o.needsSkyboxCapture(r)&&(function(r,n,o,s){const a=r.context,l=a.gl;let c=n.skyboxFbo;if(!c){c=n.skyboxFbo=a.createFramebuffer(32,32,!1),n.skyboxGeometry=new tJ(a),n.skyboxTexture=a.gl.createTexture(),l.bindTexture(l.TEXTURE_CUBE_MAP,n.skyboxTexture),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MAG_FILTER,l.LINEAR);for(let u=0;u<6;++u)l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,l.RGBA,32,32,0,l.RGBA,l.UNSIGNED_BYTE,null)}a.bindFramebuffer.set(c.framebuffer),a.viewport.set([0,0,32,32,]);const h=n.getCenter(r,!0),d=r.useProgram("skyboxCapture"),p=new Float64Array(16);i.identity(p),i.rotateY(p,p,-(.5*Math.PI)),tQ(a,n,d,p,h,0),i.identity(p),i.rotateY(p,p,.5*Math.PI),tQ(a,n,d,p,h,1),i.identity(p),i.rotateX(p,p,-(.5*Math.PI)),tQ(a,n,d,p,h,2),i.identity(p),i.rotateX(p,p,.5*Math.PI),tQ(a,n,d,p,h,3),i.identity(p),tQ(a,n,d,p,h,4),i.identity(p),i.rotateY(p,p,Math.PI),tQ(a,n,d,p,h,5),a.viewport.set([0,0,r.width,r.height,])}(r,o),o.markSkyboxValid(r)):"sky"===r.renderPass&&function(r,n,o,s,a){var l,c,u;const h=r.context,d=h.gl,p=r.transform,f=r.useProgram("skybox");h.activeTexture.set(d.TEXTURE0),d.bindTexture(d.TEXTURE_CUBE_MAP,n.skyboxTexture);const m=(l=p.skyboxMatrix,c=n.getCenter(r,!1),u=s,{u_matrix:l,u_sun_direction:c,u_cubemap:0,u_opacity:u,u_temporal_offset:a});r.prepareDrawProgram(h,f),f.draw(h,d.TRIANGLES,o,i.StencilMode.disabled,r.colorModeForRenderPass(),i.CullFaceMode.backCW,m,"skybox",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(r,o,h,l,d):"gradient"===u&&"sky"===r.renderPass&&function(r,n,o,s,a){var l,c,u,h,d;const p=r.context,f=p.gl,m=r.transform,g=r.useProgram("skyboxGradient");n.skyboxGeometry||(n.skyboxGeometry=new tJ(p)),p.activeTexture.set(f.TEXTURE0);let y=n.colorRampTexture;y||(y=n.colorRampTexture=new i.Texture(p,n.colorRamp,f.RGBA)),y.bind(f.LINEAR,f.CLAMP_TO_EDGE);const x=(l=m.skyboxMatrix,c=n.getCenter(r,!1),u=n.paint.get("sky-gradient-radius"),h=s,d=a,{u_matrix:l,u_color_ramp:0,u_center_direction:c,u_radius:i.degToRad(u),u_opacity:h,u_temporal_offset:d});r.prepareDrawProgram(p,g),g.draw(p,f.TRIANGLES,o,i.StencilMode.disabled,r.colorModeForRenderPass(),i.CullFaceMode.backCW,x,"skyboxGradient",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(r,o,h,l,d)},debug:function(i,r,n){for(let o=0;or.getOpacity(this.transform.pitch)||.03>r.properties.get("horizon-blend"))return void(this.transform.fogCullDistSq=null);const[n,o]=r.getFovAdjustedRange(this.transform._fov);if(n>o)return void(this.transform.fogCullDistSq=null);const s=n+.78*(o-n);this.transform.fogCullDistSq=s*s}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(r,n){if(this.width=r*i.exported.devicePixelRatio,this.height=n*i.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height,]),this.style)for(const o of this.style.order)this.style._layers[o].resize()}setup(){const r=this.context,n=new i.StructArrayLayout2i4;n.emplaceBack(0,0),n.emplaceBack(i.EXTENT,0),n.emplaceBack(0,i.EXTENT),n.emplaceBack(i.EXTENT,i.EXTENT),this.tileExtentBuffer=r.createVertexBuffer(n,i.posAttributes.members),this.tileExtentSegments=i.SegmentVector.simpleSegment(0,0,4,2);const o=new i.StructArrayLayout2i4;o.emplaceBack(0,0),o.emplaceBack(i.EXTENT,0),o.emplaceBack(0,i.EXTENT),o.emplaceBack(i.EXTENT,i.EXTENT),this.debugBuffer=r.createVertexBuffer(o,i.posAttributes.members),this.debugSegments=i.SegmentVector.simpleSegment(0,0,4,5);const s=new i.StructArrayLayout2i4;s.emplaceBack(-1,-1),s.emplaceBack(1,-1),s.emplaceBack(-1,1),s.emplaceBack(1,1),this.viewportBuffer=r.createVertexBuffer(s,i.posAttributes.members),this.viewportSegments=i.SegmentVector.simpleSegment(0,0,4,2);const a=new i.StructArrayLayout4i8;a.emplaceBack(0,0,0,0),a.emplaceBack(i.EXTENT,0,i.EXTENT,0),a.emplaceBack(0,i.EXTENT,0,i.EXTENT),a.emplaceBack(i.EXTENT,i.EXTENT,i.EXTENT,i.EXTENT),this.mercatorBoundsBuffer=r.createVertexBuffer(a,i.boundsAttributes.members),this.mercatorBoundsSegments=i.SegmentVector.simpleSegment(0,0,4,2);const l=new i.StructArrayLayout3ui6;l.emplaceBack(0,1,2),l.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=r.createIndexBuffer(l);const c=new i.StructArrayLayout1ui2;for(const u of[0,1,3,2,0])c.emplaceBack(u);this.debugIndexBuffer=r.createIndexBuffer(c),this.emptyTexture=new i.Texture(r,{width:1,height:1,data:new Uint8Array([0,0,0,0])},r.gl.RGBA),this.identityMat=i.create();const h=this.context.gl;this.stencilClearMode=new i.StencilMode({func:h.ALWAYS,mask:0},0,255,h.ZERO,h.ZERO,h.ZERO),this.loadTimeStamps.push(i.window.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(i){return i._makeTileBoundsBuffers(this.context,this.transform.projection),i._tileBoundsBuffer?{tileBoundsBuffer:i._tileBoundsBuffer,tileBoundsIndexBuffer:i._tileBoundsIndexBuffer,tileBoundsSegments:i._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const r=this.context,n=r.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(r,n.TRIANGLES,i.DepthMode.disabled,this.stencilClearMode,i.ColorMode.disabled,i.CullFaceMode.disabled,ts(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(r,n,o){if(!n||this.currentStencilSource===n.id||!r.isTileClipped()||!o||0===o.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let s=!1;for(const a of o)if(void 0===this._tileClippingMaskIDs[a.key]){s=!0;break}if(!s)return}this.currentStencilSource=n.id;const l=this.context,c=l.gl;this.nextStencilID+o.length>256&&this.clearStencil(),l.setColorMode(i.ColorMode.disabled),l.setDepthMode(i.DepthMode.disabled);const u=this.useProgram("clippingMask");for(const h of(this._tileClippingMaskIDs={},o)){const d=n.getTile(h),p=this._tileClippingMaskIDs[h.key]=this.nextStencilID++,{tileBoundsBuffer:f,tileBoundsIndexBuffer:m,tileBoundsSegments:g}=this.getTileBoundsBuffers(d);u.draw(l,c.TRIANGLES,i.DepthMode.disabled,new i.StencilMode({func:c.ALWAYS,mask:0},p,255,c.KEEP,c.KEEP,c.REPLACE),i.ColorMode.disabled,i.CullFaceMode.disabled,ts(h.projMatrix),"$clipping",f,m,g)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const r=this.nextStencilID++,n=this.context.gl;return new i.StencilMode({func:n.NOTEQUAL,mask:255},r,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(r){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(r);const n=this.context.gl;return new i.StencilMode({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[r.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(r){const n=this.context.gl,o=r.sort((i,r)=>r.overscaledZ-i.overscaledZ),s=o[o.length-1].overscaledZ,a=o[0].overscaledZ-s+1;if(a>1){this.currentStencilSource=void 0,this.nextStencilID+a>256&&this.clearStencil();const l={};for(let c=0;c=0;this.currentLayer--){const v=this.style._layers[o[this.currentLayer]],_=r._getLayerSourceCache(v);if(v.isSky())continue;const b=_?u[_.id]:void 0;this._renderTileClippingMasks(v,_,b),this.renderLayer(this,_,v,b)}if(this.renderPass="sky",(i.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const n=r._getLayerSourceCache(i);n&&!i.isHidden(this.transform.zoom)&&(!C||C.getSource().maxzoom0?r.pop():null}isPatternMissing(i){if(!i)return!1;if(!i.from||!i.to)return!0;const r=this.imageManager.getPattern(i.from.toString()),n=this.imageManager.getPattern(i.to.toString());return!r||!n}currentGlobalDefines(){const i=this.terrain&&this.terrain.renderingToTexture,r=this.style&&this.style.fog,n=[];return this.terrain&&!this.terrain.renderingToTexture&&n.push("TERRAIN"),r&&!i&&0!==r.getOpacity(this.transform.pitch)&&n.push("FOG"),i&&n.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&n.push("OVERDRAW_INSPECTOR"),n}useProgram(i,r,n){this.cache=this.cache||{};const o=this.currentGlobalDefines().concat(n||[]),s=tp.cacheKey(i,o,r);return this.cache[s]||(this.cache[s]=new tp(this.context,i,eX[i],r,tB[i],o)),this.cache[s]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const i=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height,]),this.context.blendEquation.set(i.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=i.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new i.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}prepareDrawTile(i){this.terrain&&this.terrain.prepareDrawTile(i)}prepareDrawProgram(i,r,n){if(this.terrain&&this.terrain.renderingToTexture)return;const o=this.style.fog;if(o){const s=o.getOpacity(this.transform.pitch);0!==s&&r.setFogUniformValues(i,((i,r,n,o)=>{const s=r.properties.get("color"),a=i.frameCounter/1e3%1,l=[s.r/s.a,s.g/s.a,s.b/s.a,o,];return{u_fog_matrix:n?i.transform.calculateFogTileMatrix(n):i.identityMat,u_fog_range:r.getFovAdjustedRange(i.transform._fov),u_fog_color:l,u_fog_horizon_blend:r.properties.get("horizon-blend"),u_fog_temporal_offset:a}})(this,o,n,s))}}setTileLoadedFlag(i){this.tileLoaded=i}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const i=this.context.gl,r=i.createTexture();return i.bindTexture(i.TEXTURE_2D,r),i.copyTexImage2D(i.TEXTURE_2D,0,i.RGBA,0,0,i.drawingBufferWidth,i.drawingBufferHeight,0),r}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const i=this.style&&this.style.fog;return!!i&&0!==i.getOpacity(this.transform.pitch)}getBackgroundTiles(){const r=this._backgroundTiles,n=this._backgroundTiles={},o=this.transform.coveringTiles({tileSize:512});for(const s of o)n[s.key]=r[s.key]||new i.Tile(s,512,this.transform.tileZoom,this);return n}clearBackgroundTiles(){this._backgroundTiles={}}}class ii{constructor(i=0,r=0,n=0,o=0){if(isNaN(i)||i<0||isNaN(r)||r<0||isNaN(n)||n<0||isNaN(o)||o<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=i,this.bottom=r,this.left=n,this.right=o}interpolate(r,n,o){return null!=n.top&&null!=r.top&&(this.top=i.number(r.top,n.top,o)),null!=n.bottom&&null!=r.bottom&&(this.bottom=i.number(r.bottom,n.bottom,o)),null!=n.left&&null!=r.left&&(this.left=i.number(r.left,n.left,o)),null!=n.right&&null!=r.right&&(this.right=i.number(r.right,n.right,o)),this}getCenter(r,n){const o=i.clamp((this.left+r-this.right)/2,0,r),s=i.clamp((this.top+n-this.bottom)/2,0,n);return new i.pointGeometry(o,s)}equals(i){return this.top===i.top&&this.bottom===i.bottom&&this.left===i.left&&this.right===i.right}clone(){return new ii(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function ir(r,n){const o=i.getColumn(r,3);i.fromQuat(r,n),i.setColumn(r,3,o)}function io(r,n){i.setColumn(r,3,[n[0],n[1],n[2],1])}function is(r,n){const o=i.identity$1([]);return i.rotateZ$1(o,o,-n),i.rotateX$1(o,o,-r),o}function ia(r,n){const o=[r[0],r[1],0],s=[n[0],n[1],0];if(i.length(o)>=1e-15){const a=i.normalize([],o);i.scale$2(s,a,i.dot(s,a)),n[0]=s[0],n[1]=s[1]}const l=i.cross([],n,r);if(1e-15>i.len(l))return null;const c=Math.atan2(-l[1],l[0]);return is(Math.atan2(Math.sqrt(r[0]*r[0]+r[1]*r[1]),-r[2]),c)}class il{constructor(i,r){this.position=i,this.orientation=r}get position(){return this._position}set position(r){this._position=this._renderWorldCopies?function(r){if(!r)return;const n=Array.isArray(r)?new i.MercatorCoordinate(r[0],r[1],r[2]):r;return n.x=i.wrap(n.x,0,1),n}(r):r}lookAtPoint(r,n){if(this.orientation=null,!this.position)return;const o=this._elevation?this._elevation.getAtPointOrZero(i.MercatorCoordinate.fromLngLat(r)):0,s=this.position,a=i.MercatorCoordinate.fromLngLat(r,o),l=[a.x-s.x,a.y-s.y,a.z-s.z];n||(n=[0,0,1]),n[2]=Math.abs(n[2]),this.orientation=ia(l,n)}setPitchBearing(r,n){this.orientation=is(i.degToRad(r),i.degToRad(-n))}}class ic{constructor(r,n){this._transform=i.identity([]),this._orientation=i.identity$1([]),n&&(this._orientation=n,ir(this._transform,this._orientation)),r&&io(this._transform,r)}get mercatorPosition(){const r=this.position;return new i.MercatorCoordinate(r[0],r[1],r[2])}get position(){const r=i.getColumn(this._transform,3);return[r[0],r[1],r[2]]}set position(i){io(this._transform,i)}get orientation(){return this._orientation}set orientation(i){this._orientation=i,ir(this._transform,this._orientation)}getPitchBearing(){const i=this.forward(),r=this.right();return{bearing:Math.atan2(-r[1],r[0]),pitch:Math.atan2(Math.sqrt(i[0]*i[0]+i[1]*i[1]),-i[2])}}setPitchBearing(i,r){this._orientation=is(i,r),ir(this._transform,this._orientation)}forward(){const r=i.getColumn(this._transform,2);return[-r[0],-r[1],-r[2]]}up(){const r=i.getColumn(this._transform,1);return[-r[0],-r[1],-r[2]]}right(){const r=i.getColumn(this._transform,0);return[r[0],r[1],r[2]]}getCameraToWorld(r,n){const o=new Float64Array(16);return i.invert(o,this.getWorldToCamera(r,n)),o}getWorldToCameraPosition(r,n,o){const s=this.position;i.scale$2(s,s,-r);const a=new Float64Array(16);return i.fromScaling(a,[o,o,o]),i.translate(a,a,s),a[10]*=n,a}getWorldToCamera(r,n){const o=new Float64Array(16),s=new Float64Array(4),a=this.position;return i.conjugate(s,this._orientation),i.scale$2(a,a,-r),i.fromQuat(o,s),i.translate(o,o,a),o[1]*=-1,o[5]*=-1,o[9]*=-1,o[13]*=-1,o[8]*=n,o[9]*=n,o[10]*=n,o[11]*=n,o}getCameraToClipPerspective(r,n,o,s){const a=new Float64Array(16);return i.perspective(a,r,n,o,s),a}getDistanceToElevation(r){const n=0===r?0:i.mercatorZfromAltitude(r,this.position[1]),o=this.forward();return(n-this.position[2])/o[2]}clone(){return new ic([...this.position],[...this.orientation])}}function iu(r,n){const o=id(r),s=function(r,n,o,s,a){const l=new i.LngLat(o.lng-180*ip,o.lat),c=new i.LngLat(o.lng+180*ip,o.lat),u=r.project(l.lng,l.lat),h=r.project(c.lng,c.lat),d=-Math.atan2(h.y-u.y,h.x-u.x),p=i.MercatorCoordinate.fromLngLat(o);p.y=i.clamp(p.y,-.999975,.999975);const f=p.toLngLat(),m=r.project(f.lng,f.lat),g=i.MercatorCoordinate.fromLngLat(f);g.x+=ip;const y=g.toLngLat(),x=r.project(y.lng,y.lat),$=i8(x.x-m.x,x.y-m.y,d),v=i.MercatorCoordinate.fromLngLat(f);v.y+=ip;const _=v.toLngLat(),b=r.project(_.lng,_.lat),w=i8(b.x-m.x,b.y-m.y,d),T=Math.abs($.x)/Math.abs(w.y),E=i.identity([]);i.rotateZ(E,E,-d*(1-(a?0:s)));const S=i.identity([]);return i.scale(S,S,[1,1-(1-T)*s,1]),S[4]=-w.x/w.y*s,i.rotateZ(S,S,d),i.multiply$1(S,E,S),S}(r.projection,0,r.center,o,n),a=ih(r);return i.scale(s,s,[a,a,1]),s}function ih(r){const n=r.projection,o=id(r),s=im(n,r.center),a=im(n,i.LngLat.convert(n.center));return Math.pow(2,s*o+(1-o)*a)}function id(r){const n=r.projection.range;if(!n)return 0;const o=Math.max(r.width,r.height),s=Math.log(o/1024)/Math.LN2;return i.smoothstep(n[0]+s,n[1]+s,r.zoom)}const ip=1/4e4;function im(r,n){const o=i.clamp(n.lat,-i.MAX_MERCATOR_LATITUDE,i.MAX_MERCATOR_LATITUDE),s=new i.LngLat(n.lng-180*ip,o),a=new i.LngLat(n.lng+180*ip,o),l=r.project(s.lng,o),c=r.project(a.lng,o),u=i.MercatorCoordinate.fromLngLat(s),h=i.MercatorCoordinate.fromLngLat(a),d=c.x-l.x,p=c.y-l.y,f=h.x-u.x,m=h.y-u.y,g=Math.sqrt((f*f+m*m)/(d*d+p*p));return Math.log(g)/Math.LN2}function i8(i,r,n){const o=Math.cos(n),s=Math.sin(n);return{x:i*o-r*s,y:i*s+r*o}}class ig{constructor(r,n,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===a||a,this._minZoom=r||0,this._maxZoom=n||22,this._minPitch=null==o?0:o,this._maxPitch=null==s?60:s,this.setProjection(),this.setMaxBounds(),this.width=0,this.height=0,this._center=new i.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new ii,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new ic,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){const i=new ig(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return i.setProjection(this.getProjection()),i._elevation=this._elevation,i._centerAltitude=this._centerAltitude,i.tileSize=this.tileSize,i.setMaxBounds(this.getMaxBounds()),i.width=this.width,i.height=this.height,i.cameraElevationReference=this.cameraElevationReference,i._center=this._center,i._setZoom(this.zoom),i._cameraZoom=this._cameraZoom,i.angle=this.angle,i._fov=this._fov,i._pitch=this._pitch,i._nearZ=this._nearZ,i._farZ=this._farZ,i._averageElevation=this._averageElevation,i._unmodified=this._unmodified,i._edgeInsets=this._edgeInsets.clone(),i._camera=this._camera.clone(),i._calcMatrices(),i.freezeTileCoverage=this.freezeTileCoverage,i}get elevation(){return this._elevation}set elevation(i){this._elevation!==i&&(this._elevation=i,i?this._updateCenterElevation()&&this._updateCameraOnTerrain():(this._cameraZoom=null,this._centerAltitude=0),this._calcMatrices())}updateElevation(i){this._terrainEnabled()&&null==this._cameraZoom&&this._updateCenterElevation()&&this._updateCameraOnTerrain(),i&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return i.pick(this.projection,["name","center","parallels",])}setProjection(r){null==r&&(r={name:"mercator"}),this.projectionOptions=r;const n=this.projection?this.getProjection():void 0;return this.projection=i.getProjection(r),!a(n,this.getProjection())&&(this._calcMatrices(),!0)}get minZoom(){return this._minZoom}set minZoom(i){this._minZoom!==i&&(this._minZoom=i,this.zoom=Math.max(this.zoom,i))}get maxZoom(){return this._maxZoom}set maxZoom(i){this._maxZoom!==i&&(this._maxZoom=i,this.zoom=Math.min(this.zoom,i))}get minPitch(){return this._minPitch}set minPitch(i){this._minPitch!==i&&(this._minPitch=i,this.pitch=Math.max(this.pitch,i))}get maxPitch(){return this._maxPitch}set maxPitch(i){this._maxPitch!==i&&(this._maxPitch=i,this.pitch=Math.min(this.pitch,i))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(i){void 0===i?i=!0:null===i&&(i=!1),this._renderWorldCopies=i}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const i=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(i))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new i.pointGeometry(this.width,this.height)}get bearing(){return i.wrap(this.rotation,-180,180)}set bearing(i){this.rotation=i}get rotation(){return-this.angle/Math.PI*180}set rotation(r){var n,o,s,a,l,c,u,h,d,p;const f=-r*Math.PI/180;this.angle!==f&&(this._unmodified=!1,this.angle=f,this._calcMatrices(),this.rotationMatrix=(n=new i.ARRAY_TYPE(4),i.ARRAY_TYPE!=Float32Array&&(n[1]=0,n[2]=0),n[0]=1,n[3]=1,n),o=this.rotationMatrix,s=this.rotationMatrix,a=this.angle,l=s[0],c=s[1],u=s[2],h=s[3],d=Math.sin(a),p=Math.cos(a),o[0]=l*p+u*d,o[1]=c*p+h*d,o[2]=-(l*d)+u*p,o[3]=-(c*d)+h*p)}get pitch(){return this._pitch/Math.PI*180}set pitch(r){const n=i.clamp(r,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(i){i=Math.max(.01,Math.min(60,i)),this._fov!==i&&(this._unmodified=!1,this._fov=i/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(i){this._averageElevation=i,this._calcFogMatrices()}get zoom(){return this._zoom}set zoom(i){const r=Math.min(Math.max(i,this.minZoom),this.maxZoom);this._zoom!==r&&(this._unmodified=!1,this._setZoom(r),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._constrain(),this._calcMatrices())}_setZoom(i){this._zoom=i,this.scale=this.zoomScale(i),this.tileZoom=Math.floor(i),this.zoomFraction=i-this.tileZoom}_updateCenterElevation(){if(!this._elevation)return!1;const i=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center),-1);return -1===i?(this._cameraZoom=null,!1):(this._centerAltitude=i,!0)}_updateCameraOnTerrain(){this._cameraZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize)}sampleAverageElevation(){if(!this._elevation)return 0;const r=this._elevation,n=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8],],o=this.horizonLineFromTop();let s=0,a=0;for(let l=0;lr.maxzoom&&(n=r.maxzoom);const l=this.locationCoordinate(this.center),c=1<{const n=1/4e4,o=new i.MercatorCoordinate(r.x+n,r.y,r.z),s=new i.MercatorCoordinate(r.x,r.y+n,r.z),a=r.toLngLat(),l=o.toLngLat(),c=s.toLngLat(),u=this.locationCoordinate(a),h=this.locationCoordinate(l),d=this.locationCoordinate(c),p=Math.hypot(h.x-u.x,h.y-u.y),f=Math.hypot(d.x-u.x,d.y-u.y);return Math.sqrt(p*f)*v/n},b=r=>{const n=x,o=$;return{aabb:i.tileAABB(this,c,0,0,0,r,o,n,this.projection),zoom:0,x:0,y:0,minZ:o,maxZ:n,wrap:r,fullyVisible:!1}},w=[];let T=[];const E=n,S=r.reparseOverscaled?o:n,I=i=>i*i,C=I((f-this._centerAltitude)*p),z=i=>{if(!this._elevation||!i.tileID||!a)return;const r=this._elevation.getMinMaxForTile(i.tileID),n=i.aabb;r?(n.min[2]=r.min,n.max[2]=r.max,n.center[2]=(n.min[2]+n.max[2])/2):(i.shouldSplit=A(i),i.shouldSplit||(n.min[2]=n.max[2]=n.center[2]=this._centerAltitude))},A=r=>{if(r.zoom.85?1:h}const d=n*n+a*a+l;return d{if(r*I(.707)0;){const P=w.pop(),D=P.x,L=P.y;let B=P.fullyVisible;if(!B){const R=P.aabb.intersects(h);if(0===R)continue;B=2===R}if(P.zoom!==E&&A(P))for(let M=0;M<4;M++){const F=(D<<1)+M%2,O=(L<<1)+(M>>1),U={aabb:a?P.aabb.quadrant(M):i.tileAABB(this,c,P.zoom+1,F,O,P.wrap,P.minZ,P.maxZ,this.projection),zoom:P.zoom+1,x:F,y:O,wrap:P.wrap,fullyVisible:B,tileID:void 0,shouldSplit:void 0,minZ:P.minZ,maxZ:P.maxZ};s&&(U.tileID=new i.OverscaledTileID(P.zoom+1===E?S:P.zoom+1,P.wrap,P.zoom+1,F,O),z(U)),w.push(U)}else{const V=P.zoom===E?S:P.zoom;if(r.minzoom&&r.minzoom>V)continue;const j=u[0]-(.5+D+(P.wrap<{const o=[0,0,0,1],s=[i.EXTENT,i.EXTENT,0,1],a=this.calculateFogTileMatrix(n.tileID.toUnwrapped());i.transformMat4$1(o,o,a),i.transformMat4$1(s,s,a);const l=i.getAABBPointSquareDist(o,s);if(0===l)return!0;let c=!1;const u=this._elevation;if(u&&l>Z&&0!==q){const h=this.calculateProjMatrix(n.tileID.toUnwrapped());let d;r.isTerrainDEM||(d=u.getMinMaxForTile(n.tileID)),d||(d={min:$,max:x});const p=i.furthestTileCorner(this.rotation),f=[p[0]*i.EXTENT,p[1]*i.EXTENT,d.max,];i.transformMat4(f,f,h),c=(1-f[1])*this.height*.5i.distanceSq-r.distanceSq).map(i=>i.tileID)}resize(i,r){this.width=i,this.height=r,this.pixelsToGLUnits=[2/i,-2/r],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(i){return Math.pow(2,i)}scaleZoom(i){return Math.log(i)/Math.LN2}project(r){const n=i.clamp(r.lat,-i.MAX_MERCATOR_LATITUDE,i.MAX_MERCATOR_LATITUDE),o=this.projection.project(r.lng,n);return new i.pointGeometry(o.x*this.worldSize,o.y*this.worldSize)}unproject(i){return this.projection.unproject(i.x/this.worldSize,i.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(r,n){const o=this.pointCoordinate(n),s=this.pointCoordinate(this.centerPoint),a=this.locationCoordinate(r);this.setLocation(new i.MercatorCoordinate(a.x-(o.x-s.x),a.y-(o.y-s.y)))}setLocation(i){this.center=this.coordinateLocation(i),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(i){return this.projection.locationPoint(this,i)}locationPoint3D(i){return this._coordinatePoint(this.locationCoordinate(i),!0)}pointLocation(i){return this.coordinateLocation(this.pointCoordinate(i))}pointLocation3D(i){return this.coordinateLocation(this.pointCoordinate3D(i))}locationCoordinate(r,n){const o=n?i.mercatorZfromAltitude(n,r.lat):void 0,s=this.projection.project(r.lng,r.lat);return new i.MercatorCoordinate(s.x,s.y,o)}coordinateLocation(i){return this.projection.unproject(i.x,i.y)}pointRayIntersection(r,n){const o=null!=n?n:this._centerAltitude,s=[r.x,r.y,0,1],a=[r.x,r.y,1,1];i.transformMat4$1(s,s,this.pixelMatrixInverse),i.transformMat4$1(a,a,this.pixelMatrixInverse);const l=a[3];i.scale$1(s,s,1/s[3]),i.scale$1(a,a,1/l);const c=s[2],u=a[2];return{p0:s,p1:a,t:c===u?0:(o-c)/(u-c)}}screenPointToMercatorRay(r){const n=[r.x,r.y,0,1],o=[r.x,r.y,1,1];return i.transformMat4$1(n,n,this.pixelMatrixInverse),i.transformMat4$1(o,o,this.pixelMatrixInverse),i.scale$1(n,n,1/n[3]),i.scale$1(o,o,1/o[3]),n[2]=i.mercatorZfromAltitude(n[2],this._center.lat)*this.worldSize,o[2]=i.mercatorZfromAltitude(o[2],this._center.lat)*this.worldSize,i.scale$1(n,n,1/this.worldSize),i.scale$1(o,o,1/this.worldSize),new i.Ray([n[0],n[1],n[2]],i.normalize([],i.sub([],o,n)))}rayIntersectionCoordinate(r){const{p0:n,p1:o,t:s}=r,a=i.mercatorZfromAltitude(n[2],this._center.lat),l=i.mercatorZfromAltitude(o[2],this._center.lat);return new i.MercatorCoordinate(i.number(n[0],o[0],s)/this.worldSize,i.number(n[1],o[1],s)/this.worldSize,i.number(a,l,s))}pointCoordinate(i,r=this._centerAltitude){return this.projection.createTileTransform(this,this.worldSize).pointCoordinate(i.x,i.y,r)}pointCoordinate3D(r){if(!this.elevation)return this.pointCoordinate(r);const n=this.elevation;let o=this.elevation.pointCoordinate(r);if(o)return new i.MercatorCoordinate(o[0],o[1],o[2]);let s=0,a=this.horizonLineFromTop();if(r.y>a)return this.pointCoordinate(r);const l=.02*a,c=r.clone();for(let u=0;u<10&&a-s>l;u++){c.y=i.number(s,a,.66);const h=n.pointCoordinate(c);h?(a=c.y,o=h):s=c.y}return o?new i.MercatorCoordinate(o[0],o[1],o[2]):this.pointCoordinate(r)}isPointAboveHorizon(i){if(this.elevation)return!this.elevation.pointCoordinate(i);{const r=this.horizonLineFromTop();return i.y0?new i.pointGeometry(s[0]/s[3],s[1]/s[3]):new i.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(r,n){var o,s,a,l,c,u,h,d;const p=new i.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),f=new i.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),m=new i.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),g=new i.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let y=this.pointCoordinate(p,r),x=this.pointCoordinate(f,r);const $=this.pointCoordinate(m,n),v=this.pointCoordinate(g,n);return y.y>1&&x.y>=0?y=new i.MercatorCoordinate((1-v.y)/(o=v,((s=y).y-o.y)/(s.x-o.x))+v.x,1):y.y<0&&x.y<=1&&(y=new i.MercatorCoordinate(-v.y/(a=v,((l=y).y-a.y)/(l.x-a.x))+v.x,0)),x.y>1&&y.y>=0?x=new i.MercatorCoordinate((1-$.y)/(c=$,((u=x).y-c.y)/(u.x-c.x))+$.x,1):x.y<0&&y.y<=1&&(x=new i.MercatorCoordinate(-$.y/(h=$,((d=x).y-h.y)/(d.x-h.x))+$.x,0)),new i.LngLatBounds().extend(this.coordinateLocation(y)).extend(this.coordinateLocation(x)).extend(this.coordinateLocation(v)).extend(this.coordinateLocation($))}_getBounds3D(){const i=this.elevation;if(!i.visibleDemTiles.length)return this._getBounds(0,0);const r=i.visibleDemTiles.reduce((i,r)=>{if(r.dem){const n=r.dem.tree;i.min=Math.min(i.min,n.minimums[0]),i.max=Math.max(i.max,n.maximums[0])}return i},{min:Number.MAX_VALUE,max:0});return this._getBounds(r.min*i.exaggeration(),r.max*i.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(i=!0){const r=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,n=this.height/2-r*(1-this._horizonShift);return i?Math.max(0,n):n}getMaxBounds(){return this.maxBounds}setMaxBounds(r){this.maxBounds=r,this.minLat=-i.MAX_MERCATOR_LATITUDE,this.maxLat=i.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,r&&(this.minLat=r.getSouth(),this.maxLat=r.getNorth(),this.minLng=r.getWest(),this.maxLng=r.getEast(),this.maxLngp&&(c=p-h),p-dm&&(l=m-u),m-f.5?b-1:b,w>.5?w-1:w,0,]),this.alignedProjMatrix=T,c=i.create(),i.scale(c,c,[this.width/2,-this.height/2,1,]),i.translate(c,c,[1,-1,0]),this.labelPlaneMatrix=c,c=i.create(),i.scale(c,c,[1,-1,1]),i.translate(c,c,[-1,-1,0]),i.scale(c,c,[2/this.width,2/this.height,1,]),this.glCoordMatrix=c,this.pixelMatrix=i.multiply$1(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},!(c=i.invert(new Float64Array(16),this.pixelMatrix)))throw Error("failed to invert matrix");this.pixelMatrixInverse=c,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const r=this.cameraWorldSize,n=this.cameraPixelsPerMeter,o=this._camera.position,s=1/this.height,a=[r,r,n];i.scale$2(a,a,s),i.scale$2(o,o,-1),i.multiply$2(o,o,a);const l=i.create();i.translate(l,l,o),i.scale(l,l,a),this.mercatorFogMatrix=l,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(r,n,s)}_computeCameraPosition(i){const r=(i=i||this.pixelsPerMeter)/this.pixelsPerMeter,n=this._camera.forward(),o=this.point,s=this._mercatorZfromZoom(this._cameraZoom?this._cameraZoom:this._zoom)*r-i/this.worldSize*this._centerAltitude;return[o.x/this.worldSize-n[0]*s,o.y/this.worldSize-n[1]*s,i/this.worldSize*this._centerAltitude-n[2]*s,]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(r){const n=this._maxCameraBoundsDistance()*Math.cos(this._pitch),o=r[2];let s=1;o>0&&(s=Math.min((n-this._camera.position[2])/o,1)),this._camera.position=i.scaleAndAdd([],this._camera.position,r,s),this._updateStateFromCamera()}_updateStateFromCamera(){const r=this._camera.position,n=this._camera.forward(),{pitch:o,bearing:s}=this._camera.getPitchBearing(),a=i.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,l=this._mercatorZfromZoom(this._maxZoom)*Math.cos(i.degToRad(this._maxPitch)),c=Math.max((r[2]-a)/Math.cos(o),l),u=this._zoomFromMercatorZ(c);i.scaleAndAdd(r,r,n,c),this._pitch=i.clamp(o,i.degToRad(this.minPitch),i.degToRad(this.maxPitch)),this.angle=i.wrap(s,-Math.PI,Math.PI),this._setZoom(i.clamp(u,this._minZoom,this._maxZoom)),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._center=this.coordinateLocation(new i.MercatorCoordinate(r[0],r[1],r[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(i){return Math.pow(2,i)*this.tileSize}_mercatorZfromZoom(i){return this.cameraToCenterDistance/this._worldSizeFromZoom(i)}_minimumHeightOverTerrain(){const i=Math.min((null!=this._cameraZoom?this._cameraZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(i)}_zoomFromMercatorZ(i){return this.scaleZoom(this.cameraToCenterDistance/(i*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(i.warnOnce("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."),1))}anyCornerOffEdge(r,n){const o=Math.min(r.x,n.x),s=Math.max(r.x,n.x),a=Math.min(r.y,n.y),l=Math.max(r.y,n.y);if(ah||f.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+i.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new i.pointGeometry(0,0),new i.pointGeometry(this.width,this.height))}zoomDeltaToMovement(r,n){const o=i.length(i.sub([],this._camera.position,r)),s=this._zoomFromMercatorZ(o)+n;return o-this._mercatorZfromZoom(s)}getCameraPoint(){const r=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i.pointGeometry(0,r))}}function iy(i,r){let n=!1,o=null;const s=()=>{o=null,n&&(i(),o=setTimeout(s,r),n=!1)};return()=>(n=!0,o||s(),o)}const ix={linearity:.3,easing:i.bezier(0,0,.3,1)},i$=i.extend({deceleration:2500,maxSpeed:1400},ix),iv=i.extend({deceleration:20,maxSpeed:1400},ix),i_=i.extend({deceleration:1e3,maxSpeed:360},ix),ib=i.extend({deceleration:1e3,maxSpeed:90},ix);function iw(i,r){(!i.duration||i.durationn.unproject(i)),u=a.reduce((i,r,n,o)=>i.add(r.div(o.length)),new i.pointGeometry(0,0));super(r,{points:a,point:u,lngLats:c,lngLat:n.unproject(u),originalEvent:o}),this._defaultPrevented=!1}}class iS extends i.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(i,r,n){super(i,{originalEvent:n}),this._defaultPrevented=!1}}class iI{constructor(i,r){this._map=i,this._clickTolerance=r.clickTolerance}reset(){delete this._mousedownPos}wheel(i){return this._firePreventable(new iS(i.type,this._map,i))}mousedown(i,r){return this._mousedownPos=r,this._firePreventable(new iT(i.type,this._map,i))}mouseup(i){this._map.fire(new iT(i.type,this._map,i))}preclick(r){const n=i.extend({},r);n.type="preclick",this._map.fire(new iT(n.type,this._map,n))}click(i,r){this._mousedownPos&&this._mousedownPos.dist(r)>=this._clickTolerance||(this.preclick(i),this._map.fire(new iT(i.type,this._map,i)))}dblclick(i){return this._firePreventable(new iT(i.type,this._map,i))}mouseover(i){this._map.fire(new iT(i.type,this._map,i))}mouseout(i){this._map.fire(new iT(i.type,this._map,i))}touchstart(i){return this._firePreventable(new iE(i.type,this._map,i))}touchmove(i){this._map.fire(new iE(i.type,this._map,i))}touchend(i){this._map.fire(new iE(i.type,this._map,i))}touchcancel(i){this._map.fire(new iE(i.type,this._map,i))}_firePreventable(i){if(this._map.fire(i),i.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class iC{constructor(i){this._map=i}reset(){this._delayContextMenu=!1,delete this._contextMenuEvent}mousemove(i){this._map.fire(new iT(i.type,this._map,i))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new iT("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(i){this._delayContextMenu?this._contextMenuEvent=i:this._map.fire(new iT(i.type,this._map,i)),this._map.listens("contextmenu")&&i.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class iz{constructor(i,r){this._map=i,this._el=i.getCanvasContainer(),this._container=i.getContainer(),this._clickTolerance=r.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(i,r){this.isEnabled()&&i.shiftKey&&0===i.button&&(l.disableDrag(),this._startPos=this._lastPos=r,this._active=!0)}mousemoveWindow(i,r){if(!this._active)return;const n=r;if(this._lastPos.equals(n)||!this._box&&n.dist(this._startPos){this._box&&(this._box.style.transform=`translate(${s}px,${c}px)`,this._box.style.width=a-s+"px",this._box.style.height=u-c+"px")})}mouseupWindow(r,n){if(!this._active||0!==r.button)return;const o=this._startPos,s=n;if(this.reset(),l.suppressClick(),o.x!==s.x||o.y!==s.y)return this._map.fire(new i.Event("boxzoomend",{originalEvent:r})),{cameraAnimation:i=>i.fitScreenCoordinates(o,s,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",r)}keydown(i){this._active&&27===i.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",i))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),l.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(r,n){return this._map.fire(new i.Event(r,{originalEvent:n}))}}function iA(i,r){const n={};for(let o=0;othis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=r.timeStamp),o.length===this.numTouches&&(this.centroid=function(r){const n=new i.pointGeometry(0,0);for(const o of r)n._add(o);return n.div(r.length)}(n),this.touches=iA(o,n)))}touchmove(i,r,n){if(this.aborted||!this.centroid)return;const o=iA(n,r);for(const s in this.touches){const a=this.touches[s],l=o[s];(!l||l.dist(a)>30)&&(this.aborted=!0)}}touchend(i,r,n){if((!this.centroid||i.timeStamp-this.startTime>500)&&(this.aborted=!0),0===n.length){const o=!this.aborted&&this.centroid;if(this.reset(),o)return o}}}(r),this.numTaps=r.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(i,r,n){this.singleTap.touchstart(i,r,n)}touchmove(i,r,n){this.singleTap.touchmove(i,r,n)}touchend(i,r,n){const o=this.singleTap.touchend(i,r,n);if(o){const s=i.timeStamp-this.lastTime<500,a=!this.lastTap||30>this.lastTap.dist(o);if(s&&a||this.reset(),this.count++,this.lastTime=i.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class iP{constructor(){this._zoomIn=new ik({numTouches:1,numTaps:2}),this._zoomOut=new ik({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(i,r,n){this._zoomIn.touchstart(i,r,n),this._zoomOut.touchstart(i,r,n)}touchmove(i,r,n){this._zoomIn.touchmove(i,r,n),this._zoomOut.touchmove(i,r,n)}touchend(i,r,n){const o=this._zoomIn.touchend(i,r,n),s=this._zoomOut.touchend(i,r,n);return o?(this._active=!0,i.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:r=>r.easeTo({duration:300,zoom:r.getZoom()+1,around:r.unproject(o)},{originalEvent:i})}):s?(this._active=!0,i.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:r=>r.easeTo({duration:300,zoom:r.getZoom()-1,around:r.unproject(s)},{originalEvent:i})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const iD={0:1,2:2};class iL{constructor(i){this.reset(),this._clickTolerance=i.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(i,r){return!1}_move(i,r){return{}}mousedown(i,r){if(this._lastPoint)return;const n=l.mouseButton(i);this._correctButton(i,n)&&(this._lastPoint=r,this._eventButton=n)}mousemoveWindow(i,r){const n=this._lastPoint;if(n){if(i.preventDefault(),function(i,r){const n=iD[r];return void 0===i.buttons||(i.buttons&n)!==n}(i,this._eventButton))this.reset();else if(this._moved||!(r.dist(n)0&&(this._active=!0);const s=iA(o,n),a=new i.pointGeometry(0,0),l=new i.pointGeometry(0,0);let c=0;for(const u in s){const h=s[u],d=this._touches[u];d&&(a._add(h),l._add(h.sub(d)),c++,s[u]=h)}if(this._touches=s,c{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")},500)}}class iM{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}_start(i){}_move(i,r,n){return{}}touchstart(i,r,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier,],this._start([r[0],r[1]]))}touchmove(i,r,n){if(!this._firstTwoTouches)return;i.preventDefault();const[o,s]=this._firstTwoTouches,a=i2(n,r,o),l=i2(n,r,s);if(!a||!l)return;const c=this._aroundCenter?null:a.add(l).div(2);return this._move([a,l],c,i)}touchend(i,r,n){if(!this._firstTwoTouches)return;const[o,s]=this._firstTwoTouches,a=i2(n,r,o),c=i2(n,r,s);a&&c||(this._active&&l.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(i){this._enabled=!0,this._aroundCenter=!!i&&"center"===i.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function i2(i,r,n){for(let o=0;oMath.abs(iF(this._distance,this._startDistance))))return this._active=!0,{zoomDelta:iF(this._distance,n),pinchAround:r}}}function i4(i,r){return 180*i.angleWith(r)/Math.PI}class iU extends iM{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(i){this._startVector=this._vector=i[0].sub(i[1]),this._minDiameter=i[0].dist(i[1])}_move(i,r){const n=this._vector;if(this._vector=i[0].sub(i[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:i4(this._vector,n),pinchAround:r}}_isBelowThreshold(i){this._minDiameter=Math.min(this._minDiameter,i.mag());const r=25/(Math.PI*this._minDiameter)*360,n=i4(i,this._startVector);return Math.abs(n)Math.abs(i.x)}class i6 extends iM{constructor(i){super(),this._map=i}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}_start(i){this._lastPoints=i,iV(i[0].sub(i[1]))&&(this._valid=!1)}_move(i,r,n){const o=i[0].sub(this._lastPoints[0]),s=i[1].sub(this._lastPoints[1]);if(!(this._map._cooperativeGestures&&n.touches.length<3)&&(this._valid=this.gestureBeginsVertically(o,s,n.timeStamp),this._valid))return this._lastPoints=i,this._active=!0,{pitchDelta:-((o.y+s.y)/2*.5)}}gestureBeginsVertically(i,r,n){if(void 0!==this._valid)return this._valid;const o=i.mag()>=2,s=r.mag()>=2;if(!o&&!s)return;if(!o||!s)return void 0===this._firstMove&&(this._firstMove=n),n-this._firstMove<100&&void 0;const a=i.y>0==r.y>0;return iV(i)&&iV(r)&&a}}class ij{constructor(){const i={panStep:100,bearingStep:15,pitchStep:10};this._panStep=i.panStep,this._bearingStep=i.bearingStep,this._pitchStep=i.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(i){if(i.altKey||i.ctrlKey||i.metaKey)return;let r=0,n=0,o=0,s=0,a=0;switch(i.keyCode){case 61:case 107:case 171:case 187:r=1;break;case 189:case 109:case 173:r=-1;break;case 37:i.shiftKey?n=-1:(i.preventDefault(),s=-1);break;case 39:i.shiftKey?n=1:(i.preventDefault(),s=1);break;case 38:i.shiftKey?o=1:(i.preventDefault(),a=-1);break;case 40:i.shiftKey?o=-1:(i.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(n=0,o=0),{cameraAnimation:l=>{const c=l.getZoom();l.easeTo({duration:300,easeId:"keyboardHandler",easing:iN,zoom:r?Math.round(c)+r*(i.shiftKey?2:1):c,bearing:l.getBearing()+n*this._bearingStep,pitch:l.getPitch()+o*this._pitchStep,offset:[-s*this._panStep,-a*this._panStep,],center:l.getCenter()},{originalEvent:i})}}}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 iN(i){return i*(2-i)}class iG{constructor(r,n){this._map=r,this._el=r.getCanvasContainer(),this._handler=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,i.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen",],this)}setZoomRate(i){this._defaultZoomRate=i}setWheelZoomRate(i){this._wheelZoomRate=i}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(i){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!i&&"center"===i.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(r){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(r.ctrlKey||r.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let n=r.deltaMode===i.window.WheelEvent.DOM_DELTA_LINE?40*r.deltaY:r.deltaY;const o=i.exported.now(),s=o-(this._lastWheelEventTime||0);this._lastWheelEventTime=o,0!==n&&n%4.000244140625==0?this._type="wheel":0!==n&&4>Math.abs(n)?this._type="trackpad":s>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,r)):this._type||(this._type=200>Math.abs(s*n)?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),r.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=r,this._delta-=n,this._active||this._start(r)),r.preventDefault()}_onTimeout(i){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(i)}_start(i){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 r=l.mousePos(this._el,i);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:r,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const r=this._map.transform,n=()=>r._terrainEnabled()&&this._aroundCoord?r.computeZoomRelativeTo(this._aroundCoord):r.zoom;if(0!==this._delta){const o="wheel"===this._type&&Math.abs(this._delta)>4.000244140625?this._wheelZoomRate:this._defaultZoomRate;let s=2/(1+Math.exp(-Math.abs(this._delta*o)));this._delta<0&&0!==s&&(s=1/s);const a=n(),l=Math.pow(2,a),c="number"==typeof this._targetZoom?r.zoomScale(this._targetZoom):l;this._targetZoom=Math.min(r.maxZoom,Math.max(r.minZoom,r.scaleZoom(c*s))),"wheel"===this._type&&(this._startZoom=n(),this._easing=this._smoothOutEasing(200)),this._delta=0}const u="number"==typeof this._targetZoom?this._targetZoom:n(),h=this._startZoom,d=this._easing;let p,f=!1;if("wheel"===this._type&&h&&d){const m=Math.min((i.exported.now()-this._lastWheelEventTime)/200,1),g=d(m);p=i.number(h,u,g),m<1?this._frameId||(this._frameId=!0):f=!0}else p=u,f=!0;return this._active=!0,f&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!f,zoomDelta:p-n(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(r){let n=i.ease;if(this._prevEase){const o=this._prevEase,s=(i.exported.now()-o.start)/o.duration,a=o.easing(s+.01)-o.easing(s),l=.27/Math.sqrt(a*a+1e-4)*.01,c=Math.sqrt(.0729-l*l);n=i.bezier(l,c,.25,1)}return this._prevEase={start:i.exported.now(),duration:r,easing:n},n}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=l.create("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(i.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_isFullscreen(){return!!i.window.document.fullscreenElement}_showBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")},200)}}class iZ{constructor(i,r){this._clickZoom=i,this._tapZoom=r}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 i9{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(i,r){return i.preventDefault(),{cameraAnimation:n=>{n.easeTo({duration:300,zoom:n.getZoom()+(i.shiftKey?-1:1),around:n.unproject(r)},{originalEvent:i})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class i7{constructor(){this._tap=new ik({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(i,r,n){this._swipePoint||(this._tapTime&&i.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?n.length>0&&(this._swipePoint=r[0],this._swipeTouch=n[0].identifier):this._tap.touchstart(i,r,n))}touchmove(i,r,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;const o=r[0],s=o.y-this._swipePoint.y;return this._swipePoint=o,i.preventDefault(),this._active=!0,{zoomDelta:s/128}}}else this._tap.touchmove(i,r,n)}touchend(i,r,n){this._tapTime?this._swipePoint&&0===n.length&&this.reset():this._tap.touchend(i,r,n)&&(this._tapTime=i.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class iq{constructor(i,r,n){this._el=i,this._mousePan=r,this._touchPan=n}enable(i){this._inertiaOptions=i||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class i5{constructor(i,r,n){this._pitchWithRotate=i.pitchWithRotate,this._mouseRotate=r,this._mousePitch=n}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class iX{constructor(i,r,n,o){this._el=i,this._touchZoom=r,this._touchRotate=n,this._tapDragZoom=o,this._rotationDisabled=!1,this._enabled=!0}enable(i){this._touchZoom.enable(i),this._rotationDisabled||this._touchRotate.enable(i),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const iW=i=>i.zoom||i.drag||i.pitch||i.rotate;class iH extends i.Event{}function iK(i){return i.panDelta&&i.panDelta.mag()||i.zoomDelta||i.bearingDelta||i.pitchDelta}const iY="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class iJ extends i.Evented{constructor(r,n){super(),this._moving=!1,this._zooming=!1,this.transform=r,this._bearingSnap=n.bearingSnap,i.bindAll(["_renderFrameCallback"],this)}getCenter(){return new i.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(i,r){return this.jumpTo({center:i},r)}panBy(r,n,o){return r=i.pointGeometry.convert(r).mult(-1),this.panTo(this.transform.center,i.extend({offset:r},n),o)}panTo(r,n,o){return this.easeTo(i.extend({center:r},n),o)}getZoom(){return this.transform.zoom}setZoom(i,r){return this.jumpTo({zoom:i},r),this}zoomTo(r,n,o){return this.easeTo(i.extend({zoom:r},n),o)}zoomIn(i,r){return this.zoomTo(this.getZoom()+1,i,r),this}zoomOut(i,r){return this.zoomTo(this.getZoom()-1,i,r),this}getBearing(){return this.transform.bearing}setBearing(i,r){return this.jumpTo({bearing:i},r),this}getPadding(){return this.transform.padding}setPadding(i,r){return this.jumpTo({padding:i},r),this}rotateTo(r,n,o){return this.easeTo(i.extend({bearing:r},n),o)}resetNorth(r,n){return this.rotateTo(0,i.extend({duration:1e3},r),n),this}resetNorthPitch(r,n){return this.easeTo(i.extend({bearing:0,pitch:0,duration:1e3},r),n),this}snapToNorth(i,r){return Math.abs(this.getBearing())g=>{if(w&&(o.zoom=i.number(s,u,g)),T&&(o.bearing=i.number(a,h,g)),E&&(o.pitch=i.number(l,d,g)),S&&(o.interpolatePadding(c,p,g),m=o.centerPoint.add(f)),_)o.setLocationAtPoint(_,b);else{const y=o.zoomScale(o.zoom-s),I=u>s?Math.min(2,v):Math.max(.5,v),C=Math.pow(I,1-g),z=o.unproject(x.add($.mult(g*C)).mult(y));o.setLocationAtPoint(o.renderWorldCopies?z.wrap():z,m)}return r.preloadOnly||this._fireMoveEvents(n),o};if(r.preloadOnly){const C=this._emulate(I,r.duration,o);return this._preloadTiles(C),this}const z={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=w,this._rotating=T,this._pitching=E,this._padding=S,this._easeId=r.easeId,this._prepareEase(n,r.noMoveStart,z),this._ease(I(o),i=>{o.recenterOnTerrain(),this._afterEase(n,i)},r),this}_prepareEase(r,n,o={}){this._moving=!0,this.transform.cameraElevationReference="sea",n||o.moving||this.fire(new i.Event("movestart",r)),this._zooming&&!o.zooming&&this.fire(new i.Event("zoomstart",r)),this._rotating&&!o.rotating&&this.fire(new i.Event("rotatestart",r)),this._pitching&&!o.pitching&&this.fire(new i.Event("pitchstart",r))}_fireMoveEvents(r){this.fire(new i.Event("move",r)),this._zooming&&this.fire(new i.Event("zoom",r)),this._rotating&&this.fire(new i.Event("rotate",r)),this._pitching&&this.fire(new i.Event("pitch",r))}_afterEase(r,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId,this.transform.cameraElevationReference="ground";const o=this._zooming,s=this._rotating,a=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,o&&this.fire(new i.Event("zoomend",r)),s&&this.fire(new i.Event("rotateend",r)),a&&this.fire(new i.Event("pitchend",r)),this.fire(new i.Event("moveend",r))}flyTo(r,n){if(!r.essential&&i.exported.prefersReducedMotion){const o=i.pick(r,["center","zoom","bearing","pitch","around",]);return this.jumpTo(o,n)}this.stop(),r=i.extend({offset:[0,0],speed:1.2,curve:1.42,easing:i.ease},r);const s=this.transform,a=this.getZoom(),l=this.getBearing(),c=this.getPitch(),u=this.getPadding(),h="zoom"in r?i.clamp(+r.zoom,s.minZoom,s.maxZoom):a,d="bearing"in r?this._normalizeBearing(r.bearing,l):l,p="pitch"in r?+r.pitch:c,f="padding"in r?r.padding:s.padding,m=s.zoomScale(h-a),g=i.pointGeometry.convert(r.offset);let y=s.centerPoint.add(g);const x=s.pointLocation(y),$=i.LngLat.convert(r.center||x);this._normalizeCenter($);const v=s.project(x),_=s.project($).sub(v);let b=r.curve;const w=Math.max(s.width,s.height),T=w/m,E=_.mag();if("minZoom"in r){const S=i.clamp(Math.min(r.minZoom,a,h),s.minZoom,s.maxZoom),I=w/s.zoomScale(S-a);b=Math.sqrt(I/E*2)}const C=b*b;function z(i){const r=(T*T-w*w+(i?-1:1)*C*C*E*E)/(2*(i?T:w)*C*E);return Math.log(Math.sqrt(r*r+1)-r)}function A(i){return(Math.exp(i)-Math.exp(-i))/2}function k(i){return(Math.exp(i)+Math.exp(-i))/2}const P=z(0);let D=function(i){return k(P)/k(P+b*i)},L=function(i){var r;return w*((k(P)*(A(r=P+b*i)/k(r))-A(P))/C)/E},B=(z(1)-P)/b;if(1e-6>Math.abs(E)||!isFinite(B)){if(1e-6>Math.abs(w-T))return this.easeTo(r,n);const R=Tr.maxDuration&&(r.duration=0);const M=l!==d,F=p!==c,O=!s.isPaddingEqual(f),U=o=>s=>{const m=s*B,x=1/D(m);o.zoom=1===s?h:a+o.scaleZoom(x),M&&(o.bearing=i.number(l,d,s)),F&&(o.pitch=i.number(c,p,s)),O&&(o.interpolatePadding(u,f,s),y=o.centerPoint.add(g));const b=1===s?$:o.unproject(v.add(_.mult(L(m))).mult(x));return o.setLocationAtPoint(o.renderWorldCopies?b.wrap():b,y),o._updateCenterElevation(),r.preloadOnly||this._fireMoveEvents(n),o};if(r.preloadOnly){const V=this._emulate(U,r.duration,s);return this._preloadTiles(V),this}return this._zooming=!0,this._rotating=M,this._pitching=F,this._padding=O,this._prepareEase(n,!1),this._ease(U(s),()=>this._afterEase(n),r),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(i,r){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const n=this._onEaseEnd;delete this._onEaseEnd,n.call(this,r)}if(!i){const o=this.handlers;o&&o.stop(!1)}return this}_ease(r,n,o){!1===o.animate||0===o.duration?(r(1),n()):(this._easeStart=i.exported.now(),this._easeOptions=o,this._onEaseFrame=r,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const r=Math.min((i.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(r)),r<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(r,n){r=i.wrap(r,-180,180);const o=Math.abs(r-n);return Math.abs(r-360-n)180?-360:n<-180?360:0}_emulate(i,r,n){const o=Math.ceil(15*r/1e3),s=[],a=i(n.clone());for(let l=0;l<=o;l++){const c=a(l/o);s.push(c.clone())}return s}}class iQ{constructor(r={}){this.options=r,i.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact",],this)}getDefaultPosition(){return"bottom-right"}onAdd(i){const r=this.options&&this.options.compact;return this._map=i,this._container=l.create("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=l.create("button","mapboxgl-ctrl-attrib-button",this._container),l.create("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden",!0),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=l.create("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),r&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===r&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(i,r){const n=this._map._getUIString(`AttributionControl.${r}`);i.setAttribute("aria-label",n),i.removeAttribute("title"),i.firstElementChild&&i.firstElementChild.setAttribute("title",n)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let r=this._editLink;r||(r=this._editLink=this._container.querySelector(".mapbox-improve-map"));const n=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||i.config.ACCESS_TOKEN},];if(r){const o=n.reduce((i,r,o)=>(r.value&&(i+=`${r.key}=${r.value}${oi.indexOf(a.attribution)&&i.push(a.attribution)}}i.sort((i,r)=>i.length-r.length),i=i.filter((r,n)=>{for(let o=n+1;o=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?i=[...this.options.customAttribution,...i,]:i.unshift(this.options.customAttribution));const l=i.join(" | ");l!==this._attribHTML&&(this._attribHTML=l,i.length?(this._innerContainer.innerHTML=l,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class re{constructor(){i.bindAll(["_updateLogo"],this),i.bindAll(["_updateCompact"],this)}onAdd(i){this._map=i,this._container=l.create("div","mapboxgl-ctrl");const r=l.create("a","mapboxgl-ctrl-logo");return r.target="_blank",r.rel="noopener nofollow",r.href="https://www.mapbox.com/",r.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),r.setAttribute("rel","noopener nofollow"),this._container.appendChild(r),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(i){i&&"metadata"!==i.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const i=this._map.style._sourceCaches;if(0===Object.entries(i).length)return!0;for(const r in i){const n=i[r].getSource();if(n.hasOwnProperty("mapbox_logo")&&!n.mapbox_logo)return!1}return!0}_updateCompact(){const i=this._container.children;if(i.length){const r=i[0];this._map.getCanvasContainer().offsetWidth<250?r.classList.add("mapboxgl-compact"):r.classList.remove("mapboxgl-compact")}}}class rt{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(i){const r=++this._id;return this._queue.push({callback:i,id:r,cancelled:!1}),r}remove(i){const r=this._currentlyRunning,n=r?this._queue.concat(r):this._queue;for(const o of n)if(o.id===i)return void(o.cancelled=!0)}run(i=0){const r=this._currentlyRunning=this._queue;for(const n of(this._queue=[],r))if(!n.cancelled&&(n.callback(i),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function ri(r,n,o){if(r=new i.LngLat(r.lng,r.lat),n){const s=new i.LngLat(r.lng-360,r.lat),a=new i.LngLat(r.lng+360,r.lat),l=360*Math.ceil(Math.abs(r.lng-o.center.lng)/360),c=o.locationPoint(r).distSqr(n),u=n.x<0||n.y<0||n.x>o.width||n.y>o.height;o.locationPoint(s).distSqr(n)180;){const h=o.locationPoint(r);if(h.x>=0&&h.y>=0&&h.x<=o.width&&h.y<=o.height)break;r.lng>o.center.lng?r.lng-=360:r.lng+=360}return r}const rr={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class rn extends i.Evented{constructor(r,n){if(super(),(r instanceof i.window.HTMLElement||n)&&(r=i.extend({element:r},n)),i.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer",],this),this._anchor=r&&r.anchor||"center",this._color=r&&r.color||"#3FB1CE",this._scale=r&&r.scale||1,this._draggable=r&&r.draggable||!1,this._clickTolerance=r&&r.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=r&&r.rotation||0,this._rotationAlignment=r&&r.rotationAlignment||"auto",this._pitchAlignment=r&&r.pitchAlignment&&"auto"!==r.pitchAlignment?r.pitchAlignment:this._rotationAlignment,this._updateMoving=()=>this._update(!0),r&&r.element)this._element=r.element,this._offset=i.pointGeometry.convert(r&&r.offset||[0,0]);else{this._defaultMarker=!0,this._element=l.create("div");const o=l.createSVG("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},this._element),s=l.createSVG("radialGradient",{id:"shadowGradient"},l.createSVG("defs",{},o));l.createSVG("stop",{offset:"10%","stop-opacity":.4},s),l.createSVG("stop",{offset:"100%","stop-opacity":.05},s),l.createSVG("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},o),l.createSVG("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},o),l.createSVG("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},o),l.createSVG("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},o),this._offset=i.pointGeometry.convert(r&&r.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",i=>{i.preventDefault()}),this._element.addEventListener("mousedown",i=>{i.preventDefault()});const a=this._element.classList;for(const c in rr)a.remove(`mapboxgl-marker-anchor-${c}`);a.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(i){return i===this._map||(this.remove(),this._map=i,i.getCanvasContainer().appendChild(this._element),i.on("move",this._updateMoving),i.on("moveend",this._update),i.on("remove",this._clearFadeTimer),i._addMarker(this),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick)),this}remove(){return this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._updateMoving),this._map.off("moveend",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),this._map.off("remove",this._clearFadeTimer),this._map._removeMarker(this),delete this._map),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(r){return this._lngLat=i.LngLat.convert(r),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(i){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),i){if(!("offset"in i.options)){const r=Math.sqrt(91.125);i.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[r,-1*(24.6+r),],"bottom-right":[-r,-1*(24.6+r),],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=i,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(i){const r=i.code,n=i.charCode||i.keyCode;"Space"!==r&&"Enter"!==r&&32!==n&&13!==n||this.togglePopup()}_onMapClick(i){const r=i.originalEvent.target,n=this._element;this._popup&&(r===n||n.contains(r))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const i=this._popup;return i&&(i.isOpen()?(i.remove(),this._element.setAttribute("aria-expanded","false")):(i.addTo(this._map),this._element.setAttribute("aria-expanded","true"))),this}_evaluateOpacity(){const i=this._pos?this._pos.sub(this._transformedOffset()):null;if(!this._withinScreenBounds(i))return void this._clearFadeTimer();const r=this._map.unproject(i);let n=!1;if(this._map.transform._terrainEnabled()&&this._map.getTerrain()){const o=this._map.getFreeCameraOptions();if(o.position){const s=o.position.toLngLat();n=s.distanceTo(r)<.9*s.distanceTo(this._lngLat)}}const a=(1-this._map._queryFogOpacity(r))*(n?.2:1);this._element.style.opacity=`${a}`,this._popup&&this._popup._setOpacity(`${a}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_withinScreenBounds(i){const r=this._map.transform;return!!i&&i.x>=0&&i.x=0&&i.y{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),this._map._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(this._map.getTerrain()||this._map.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}_transformedOffset(){if(!this._defaultMarker)return this._offset;const i=this._map.transform,r=this._offset.mult(this._scale);return"map"===this._rotationAlignment&&r._rotate(i.angle),"map"===this._pitchAlignment&&(r.y*=Math.cos(i._pitch)),r}getOffset(){return this._offset}setOffset(r){return this._offset=i.pointGeometry.convert(r),this._update(),this}_onMove(r){if(!this._isDragging){const n=this._clickTolerance||this._map._clickTolerance;this._isDragging=r.point.dist(this._pointerdownPos)>=n}this._isDragging&&(this._pos=r.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new i.Event("dragstart"))),this.fire(new i.Event("drag")))}_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),"active"===this._state&&this.fire(new i.Event("dragend")),this._state="inactive"}_addDragHandler(i){this._element.contains(i.originalEvent.target)&&(i.preventDefault(),this._positionDelta=i.point.sub(this._pos).add(this._transformedOffset()),this._pointerdownPos=i.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))}setDraggable(i){return this._draggable=!!i,this._map&&(i?(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(i){return this._rotation=i||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(i){return this._rotationAlignment=i||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(i){return this._pitchAlignment=i&&"auto"!==i?i:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const{HTMLImageElement:ro,HTMLElement:rs,ImageBitmap:ra}=i.window;function rl(i){i.parentNode&&i.parentNode.removeChild(i)}class rc{constructor(r,n,o=!1){this._clickTolerance=10,this.element=n,this.mouseRotate=new iB({clickTolerance:r.dragRotate._mouseRotate._clickTolerance}),this.map=r,o&&(this.mousePitch=new iR({clickTolerance:r.dragRotate._mousePitch._clickTolerance})),i.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset",],this),n.addEventListener("mousedown",this.mousedown),n.addEventListener("touchstart",this.touchstart,{passive:!1}),n.addEventListener("touchmove",this.touchmove),n.addEventListener("touchend",this.touchend),n.addEventListener("touchcancel",this.reset)}down(i,r){this.mouseRotate.mousedown(i,r),this.mousePitch&&this.mousePitch.mousedown(i,r),l.disableDrag()}move(i,r){const n=this.map,o=this.mouseRotate.mousemoveWindow(i,r);if(o&&o.bearingDelta&&n.setBearing(n.getBearing()+o.bearingDelta),this.mousePitch){const s=this.mousePitch.mousemoveWindow(i,r);s&&s.pitchDelta&&n.setPitch(n.getPitch()+s.pitchDelta)}}off(){const i=this.element;i.removeEventListener("mousedown",this.mousedown),i.removeEventListener("touchstart",this.touchstart,{passive:!1}),i.removeEventListener("touchmove",this.touchmove),i.removeEventListener("touchend",this.touchend),i.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){l.enableDrag(),i.window.removeEventListener("mousemove",this.mousemove),i.window.removeEventListener("mouseup",this.mouseup)}mousedown(r){this.down(i.extend({},r,{ctrlKey:!0,preventDefault:()=>r.preventDefault()}),l.mousePos(this.element,r)),i.window.addEventListener("mousemove",this.mousemove),i.window.addEventListener("mouseup",this.mouseup)}mousemove(i){this.move(i,l.mousePos(this.element,i))}mouseup(i){this.mouseRotate.mouseupWindow(i),this.mousePitch&&this.mousePitch.mouseupWindow(i),this.offTemp()}touchstart(i){1!==i.targetTouches.length?this.reset():(this._startPos=this._lastPos=l.touchPos(this.element,i.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>i.preventDefault()},this._startPos))}touchmove(i){1!==i.targetTouches.length?this.reset():(this._lastPos=l.touchPos(this.element,i.targetTouches)[0],this.move({preventDefault:()=>i.preventDefault()},this._lastPos))}touchend(i){0===i.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)5280?rf(r,o,u/5280,i._getUIString("ScaleControl.Miles"),i):rf(r,o,u,i._getUIString("ScaleControl.Feet"),i)}else n&&"nautical"===n.unit?rf(r,o,c/1852,i._getUIString("ScaleControl.NauticalMiles"),i):c>=1e3?rf(r,o,c/1e3,i._getUIString("ScaleControl.Kilometers"),i):rf(r,o,c,i._getUIString("ScaleControl.Meters"),i)}function rf(i,r,n,o,s){const a=function(i){const r=Math.pow(10,`${Math.floor(i)}`.length-1);let n=i/r;return r*(n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:n>=1?1:function(i){const r=Math.pow(10,Math.ceil(-Math.log(i)/Math.LN10));return Math.round(i*r)/r}(n))}(n),l=a/n;s._requestDomTask(()=>{i.style.width=r*l+"px",i.innerHTML=`${a} ${o}`})}const rm={version:i.version,supported:r,setRTLTextPlugin:i.setRTLTextPlugin,getRTLTextPluginStatus:i.getRTLTextPluginStatus,Map:class extends iJ{constructor(r){if(null!=(r=i.extend({},{center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0},r)).minZoom&&null!=r.maxZoom&&r.minZoom>r.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(null!=r.minPitch&&null!=r.maxPitch&&r.minPitch>r.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(null!=r.minPitch&&r.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(null!=r.maxPitch&&r.maxPitch>85)throw Error("maxPitch must be less than or equal to 85");if(super(new ig(r.minZoom,r.maxZoom,r.minPitch,r.maxPitch,r.renderWorldCopies),r),this._interactive=r.interactive,this._minTileCacheSize=r.minTileCacheSize,this._maxTileCacheSize=r.maxTileCacheSize,this._failIfMajorPerformanceCaveat=r.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=r.preserveDrawingBuffer,this._antialias=r.antialias,this._trackResize=r.trackResize,this._bearingSnap=r.bearingSnap,this._refreshExpiredTiles=r.refreshExpiredTiles,this._fadeDuration=r.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=r.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=r.collectResourceTiming,this._optimizeForTerrain=r.optimizeForTerrain,this._renderTaskQueue=new rt,this._domRenderTaskQueue=new rt,this._controls=[],this._markers=[],this._mapId=i.uniqueId(),this._locale=i.extend({},{"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},r.locale),this._clickTolerance=r.clickTolerance,this._cooperativeGestures=r.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevation=new class{constructor(i){this.jumpTo(i)}getValue(r){if(r<=this._startTime)return this._start;if(r>=this._endTime)return this._end;const n=i.easeCubicInOut((r-this._startTime)/(this._endTime-this._startTime));return this._start*(1-n)+this._end*n}isEasing(i){return i>=this._startTime&&i<=this._endTime}jumpTo(i){this._startTime=-1/0,this._endTime=-1/0,this._start=i,this._end=i}easeTo(i,r,n){this._start=this.getValue(r),this._end=i,this._startTime=r,this._endTime=r+n}}(0),this._requestManager=new i.RequestManager(r.transformRequest,r.accessToken,r.testMode),this._silenceAuthErrors=!!r.testMode,"string"==typeof r.container){if(this._container=i.window.document.getElementById(r.container),!this._container)throw Error(`Container '${r.container}' not found.`)}else{if(!(r.container instanceof rs))throw Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=r.container}if(this._container.childNodes.length>0&&i.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),r.maxBounds&&this.setMaxBounds(r.maxBounds),i.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored",],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),void 0!==i.window&&(i.window.addEventListener("online",this._onWindowOnline,!1),i.window.addEventListener("resize",this._onWindowResize,!1),i.window.addEventListener("orientationchange",this._onWindowResize,!1),i.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new class{constructor(r,n){this._map=r,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new class{constructor(i){this._map=i,this.clear()}clear(){this._inertiaBuffer=[]}record(r){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:i.exported.now(),settings:r})}_drainInertiaBuffer(){const r=this._inertiaBuffer,n=i.exported.now();for(;r.length>0&&n-r[0].time>160;)r.shift()}_onMoveEnd(r){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new i.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:o}of this._inertiaBuffer)n.zoom+=o.zoomDelta||0,n.bearing+=o.bearingDelta||0,n.pitch+=o.pitchDelta||0,o.panDelta&&n.pan._add(o.panDelta),o.around&&(n.around=o.around),o.pinchAround&&(n.pinchAround=o.pinchAround);const s=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,a={};if(n.pan.mag()){const l=i0(n.pan.mag(),s,i.extend({},i$,r||{}));a.offset=n.pan.mult(l.amount/n.pan.mag()),a.center=this._map.transform.center,iw(a,l)}if(n.zoom){const c=i0(n.zoom,s,iv);a.zoom=this._map.transform.zoom+c.amount,iw(a,c)}if(n.bearing){const u=i0(n.bearing,s,i_);a.bearing=this._map.transform.bearing+i.clamp(u.amount,-179,179),iw(a,u)}if(n.pitch){const h=i0(n.pitch,s,ib);a.pitch=this._map.transform.pitch+h.amount,iw(a,h)}if(a.zoom||a.bearing){const d=void 0===n.pinchAround?n.around:n.pinchAround;a.around=d?this._map.unproject(d):this._map.getCenter()}return this.clear(),i.extend(a,{noMoveStart:!0})}}(r),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new class{constructor(){this.constants=[1,1,.01],this.radius=0}setup(r,n){const o=i.sub([],n,r);this.radius=i.length(o[2]<0?i.div([],o,this.constants):[o[0],o[1],0])}projectRay(r){i.div(r,r,this.constants),i.normalize(r,r),i.mul$1(r,r,this.constants);const n=i.scale$2([],r,this.radius);if(n[2]>0){const o=i.scale$2([],[0,0,1],i.dot(n,[0,0,1])),s=i.scale$2([],i.normalize([],[n[0],n[1],0]),this.radius),a=i.add([],n,i.scale$2([],i.sub([],i.add([],s,o),n),2));n[0]=a[0],n[1]=a[1]}return n}},this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(n),i.bindAll(["handleEvent","handleWindowEvent"],this);const o=this._el;for(const[s,a,l]of(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],[i.window.document,"mousemove",{capture:!0},],[i.window.document,"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],[i.window,"blur",void 0],],this._listeners))s.addEventListener(a,s===i.window.document?this.handleWindowEvent:this.handleEvent,l)}destroy(){for(const[r,n,o]of this._listeners)r.removeEventListener(n,r===i.window.document?this.handleWindowEvent:this.handleEvent,o)}_addDefaultHandlers(i){const r=this._map,n=r.getCanvasContainer();this._add("mapEvent",new iI(r,i));const o=r.boxZoom=new iz(r,i);this._add("boxZoom",o);const s=new iP,a=new i9;r.doubleClickZoom=new iZ(a,s),this._add("tapZoom",s),this._add("clickZoom",a);const l=new i7;this._add("tapDragZoom",l);const c=r.touchPitch=new i6(r);this._add("touchPitch",c);const u=new iB(i),h=new iR(i);r.dragRotate=new i5(i,u,h),this._add("mouseRotate",u,["mousePitch"]),this._add("mousePitch",h,["mouseRotate"]);const d=new i1(i),p=new i3(r,i);r.dragPan=new iq(n,d,p),this._add("mousePan",d),this._add("touchPan",p,["touchZoom","touchRotate",]);const f=new iU,m=new iO;r.touchZoomRotate=new iX(n,m,f,l),this._add("touchRotate",f,["touchPan","touchZoom",]),this._add("touchZoom",m,["touchPan","touchRotate",]),this._add("blockableMapEvent",new iC(r));const g=r.scrollZoom=new iG(r,this);this._add("scrollZoom",g,["mousePan"]);const y=r.keyboard=new ij;for(const x of(this._add("keyboard",y),["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard",]))i.interactive&&i[x]&&r[x].enable(i[x])}_add(i,r,n){this._handlers.push({handlerName:i,handler:r,allowed:n}),this._handlersById[i]=r}stop(i){if(!this._updatingCamera){for(const{handler:r}of this._handlers)r.reset();this._inertia.clear(),this._fireEvents({},{},i),this._changes=[]}}isActive(){for(const{handler:i}of this._handlers)if(i.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(iW(this._eventsInProgress))||this.isZooming()}_blockedByActive(i,r,n){for(const o in i)if(o!==n&&(!r||0>r.indexOf(o)))return!0;return!1}handleWindowEvent(i){this.handleEvent(i,`${i.type}Window`)}_getMapTouches(i){const r=[];for(const n of i)this._el.contains(n.target)&&r.push(n);return r}handleEvent(i,r){this._updatingCamera=!0;const n="renderFrame"===i.type,o=n?void 0:i,s={needsRenderFrame:!1},a={},c={},u=i.touches?this._getMapTouches(i.touches):void 0,h=u?l.touchPos(this._el,u):n?void 0:l.mousePos(this._el,i);for(const{handlerName:d,handler:p,allowed:f}of this._handlers){if(!p.isEnabled())continue;let m;this._blockedByActive(c,f,d)?p.reset():p[r||i.type]&&(m=p[r||i.type](i,h,u),this.mergeHandlerResult(s,a,m,d,o),m&&m.needsRenderFrame&&this._triggerRenderFrame()),(m||p.isActive())&&(c[d]=p)}const g={};for(const y in this._previousActiveHandlers)c[y]||(g[y]=o);this._previousActiveHandlers=c,(Object.keys(g).length||iK(s))&&(this._changes.push([s,a,g]),this._triggerRenderFrame()),(Object.keys(c).length||iK(s))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:x}=s;x&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],x(this._map))}mergeHandlerResult(r,n,o,s,a){if(!o)return;i.extend(r,o);const l={handlerName:s,originalEvent:o.originalEvent||a};void 0!==o.zoomDelta&&(n.zoom=l),void 0!==o.panDelta&&(n.drag=l),void 0!==o.pitchDelta&&(n.pitch=l),void 0!==o.bearingDelta&&(n.rotate=l)}_applyChanges(){const r={},n={},o={};for(const[s,a,l]of this._changes)s.panDelta&&(r.panDelta=(r.panDelta||new i.pointGeometry(0,0))._add(s.panDelta)),s.zoomDelta&&(r.zoomDelta=(r.zoomDelta||0)+s.zoomDelta),s.bearingDelta&&(r.bearingDelta=(r.bearingDelta||0)+s.bearingDelta),s.pitchDelta&&(r.pitchDelta=(r.pitchDelta||0)+s.pitchDelta),void 0!==s.around&&(r.around=s.around),void 0!==s.aroundCoord&&(r.aroundCoord=s.aroundCoord),void 0!==s.pinchAround&&(r.pinchAround=s.pinchAround),s.noInertia&&(r.noInertia=s.noInertia),i.extend(n,a),i.extend(o,l);this._updateMapTransform(r,n,o),this._changes=[]}_updateMapTransform(r,n,o){const s=this._map,a=s.transform,l=i=>[i.x,i.y,i.z];if((i=>{const r=this._eventsInProgress.drag;return r&&!this._handlersById[r.handlerName].isActive()})()&&!iK(r)){const c=a.zoom;a.cameraElevationReference="sea",a.recenterOnTerrain(),a.cameraElevationReference="ground",c!==a.zoom&&this._map._update(!0)}if(!iK(r))return this._fireEvents(n,o,!0);let{panDelta:u,zoomDelta:h,bearingDelta:d,pitchDelta:p,around:f,aroundCoord:m,pinchAround:g}=r;void 0!==g&&(f=g),n.drag&&!this._eventsInProgress.drag&&f&&(this._dragOrigin=l(a.pointCoordinate3D(f)),this._trackingEllipsoid.setup(a._camera.position,this._dragOrigin)),a.cameraElevationReference="sea",s._stop(!0),f=f||s.transform.centerPoint,d&&(a.bearing+=d),p&&(a.pitch+=p),a._updateCameraState();const y=[0,0,0];if(u){const x=a.pointCoordinate(f),$=a.pointCoordinate(f.sub(u));x&&$&&(y[0]=$.x-x.x,y[1]=$.y-x.y)}const v=a.zoom,_=[0,0,0];if(h){const b=l(m||a.pointCoordinate3D(f)),w={dir:i.normalize([],i.sub([],b,a._camera.position))};if(w.dir[2]<0){const T=a.zoomDeltaToMovement(b,h);i.scale$2(_,w.dir,T)}}const E=i.add(y,y,_);a._translateCameraConstrained(E),h&&Math.abs(a.zoom-v)>1e-4&&a.recenterOnTerrain(),a.cameraElevationReference="ground",this._map._update(),r.noInertia||this._inertia.record(r),this._fireEvents(n,o,!0)}_fireEvents(r,n,o){const s=iW(this._eventsInProgress),a=iW(r),l={};for(const c in r){const{originalEvent:u}=r[c];this._eventsInProgress[c]||(l[`${c}start`]=u),this._eventsInProgress[c]=r[c]}for(const h in!s&&a&&this._fireEvent("movestart",a.originalEvent),l)this._fireEvent(h,l[h]);for(const d in a&&this._fireEvent("move",a.originalEvent),r){const{originalEvent:p}=r[d];this._fireEvent(d,p)}const f={};let m;for(const g in this._eventsInProgress){const{handlerName:y,originalEvent:x}=this._eventsInProgress[g];this._handlersById[y].isActive()||(delete this._eventsInProgress[g],m=n[y]||x,f[`${g}end`]=m)}for(const $ in f)this._fireEvent($,f[$]);const v=iW(this._eventsInProgress);if(o&&(s||a)&&!v){var _,b;this._updatingCamera=!0;const w=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions);w?(0!==(_=w.bearing||this._map.getBearing())&&-this._bearingSnap<_&&_{delete this._frameId,this.handleEvent(new iH("renderFrame",{timeStamp:i})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}(this,r),this._localFontFamily=r.localFontFamily,this._localIdeographFontFamily=r.localIdeographFontFamily,r.style&&this.setStyle(r.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),r.projection&&this.setProjection(r.projection),this._hash=r.hash&&new class{constructor(r){this._hashName=r&&encodeURIComponent(r),i.bindAll(["_getCurrentHash","_onHashChange","_updateHash",],this),this._updateHash=iy(this._updateHashUnthrottled.bind(this),300)}addTo(r){return this._map=r,i.window.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return i.window.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(r){const n=this._map.getCenter(),o=Math.round(100*this._map.getZoom())/100,s=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),a=Math.pow(10,s),l=Math.round(n.lng*a)/a,c=Math.round(n.lat*a)/a,u=this._map.getBearing(),h=this._map.getPitch();let d="";if(d+=r?`/${l}/${c}/${o}`:`${o}/${c}/${l}`,(u||h)&&(d+="/"+Math.round(10*u)/10),h&&(d+=`/${Math.round(h)}`),this._hashName){const p=this._hashName;let f=!1;const m=i.window.location.hash.slice(1).split("&").map(i=>{const r=i.split("=")[0];return r===p?(f=!0,`${r}=${d}`):i}).filter(i=>i);return f||m.push(`${p}=${d}`),`#${m.join("&")}`}return`#${d}`}_getCurrentHash(){const r=i.window.location.hash.replace("#","");if(this._hashName){let n;return r.split("&").map(i=>i.split("=")).forEach(i=>{i[0]===this._hashName&&(n=i)}),(n&&n[1]||"").split("/")}return r.split("/")}_onHashChange(){const i=this._getCurrentHash();if(i.length>=3&&!i.some(i=>isNaN(i))){const r=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(i[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+i[2],+i[1]],zoom:+i[0],bearing:r,pitch:+(i[4]||0)}),!0}return!1}_updateHashUnthrottled(){const r=i.window.location.href.replace(/(#.+)?$/,this.getHashString());i.window.history.replaceState(i.window.history.state,null,r)}}("string"==typeof r.hash&&r.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch}),r.bounds&&(this.resize(),this.fitBounds(r.bounds,i.extend({},r.fitBoundsOptions,{duration:0})))),this.resize(),r.attributionControl&&this.addControl(new iQ({customAttribution:r.customAttribution})),this._logoControl=new re,this.addControl(this._logoControl,r.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",r=>{this._update("style"===r.dataType),this.fire(new i.Event(`${r.dataType}data`,r))}),this.on("dataloading",r=>{this.fire(new i.Event(`${r.dataType}dataloading`,r))})}_getMapId(){return this._mapId}addControl(r,n){if(void 0===n&&(n=r.getDefaultPosition?r.getDefaultPosition():"top-right"),!r||!r.onAdd)return this.fire(new i.ErrorEvent(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const o=r.onAdd(this);this._controls.push(r);const s=this._controlPositions[n];return -1!==n.indexOf("bottom")?s.insertBefore(o,s.firstChild):s.appendChild(o),this}removeControl(r){if(!r||!r.onRemove)return this.fire(new i.ErrorEvent(Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const n=this._controls.indexOf(r);return n>-1&&this._controls.splice(n,1),r.onRemove(this),this}hasControl(i){return this._controls.indexOf(i)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(r){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const n=!this._moving;return n&&this.fire(new i.Event("movestart",r)).fire(new i.Event("move",r)),this.fire(new i.Event("resize",r)),n&&this.fire(new i.Event("moveend",r)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(r){return this.transform.setMaxBounds(i.LngLatBounds.convert(r)),this._update()}setMinZoom(r){if((r=null==r?-2:r)>=-2&&r<=this.transform.maxZoom)return this.transform.minZoom=r,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=r,this._update(),this.getZoom()>r?this.setZoom(r):this.fire(new i.Event("zoomstart")).fire(new i.Event("zoom")).fire(new i.Event("zoomend")),this;throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(r){if((r=null==r?0:r)<0)throw Error("minPitch must be greater than or equal to 0");if(r>=0&&r<=this.transform.maxPitch)return this.transform.minPitch=r,this._update(),this.getPitch()85)throw Error("maxPitch must be less than or equal to 85");if(r>=this.transform.minPitch)return this.transform.maxPitch=r,this._update(),this.getPitch()>r?this.setPitch(r):this.fire(new i.Event("pitchstart")).fire(new i.Event("pitch")).fire(new i.Event("pitchend")),this;throw Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(i){return this.transform.renderWorldCopies=i,this._update()}getProjection(){return this.transform.getProjection()}setProjection(i){return this._lazyInitEmptyStyle(),"string"==typeof i&&(i={name:i}),this._runtimeProjection=i,this.style.updateProjection(),this._transitionFromGlobe=!1,this}project(r){return this.transform.locationPoint3D(i.LngLat.convert(r))}unproject(r){return this.transform.pointLocation3D(i.pointGeometry.convert(r))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()}_createDelegatedListener(i,r,n){if("mouseenter"===i||"mouseover"===i){let o=!1;const s=s=>{const a=r.filter(i=>this.getLayer(i)),l=a.length?this.queryRenderedFeatures(s.point,{layers:a}):[];l.length?o||(o=!0,n.call(this,new iT(i,this,s.originalEvent,{features:l}))):o=!1},a=()=>{o=!1};return{layers:new Set(r),listener:n,delegates:{mousemove:s,mouseout:a}}}if("mouseleave"===i||"mouseout"===i){let l=!1;const c=o=>{const s=r.filter(i=>this.getLayer(i));(s.length?this.queryRenderedFeatures(o.point,{layers:s}):[]).length?l=!0:l&&(l=!1,n.call(this,new iT(i,this,o.originalEvent)))},u=r=>{l&&(l=!1,n.call(this,new iT(i,this,r.originalEvent)))};return{layers:new Set(r),listener:n,delegates:{mousemove:c,mouseout:u}}}{const h=i=>{const o=r.filter(i=>this.getLayer(i)),s=o.length?this.queryRenderedFeatures(i.point,{layers:o}):[];s.length&&(i.features=s,n.call(this,i),delete i.features)};return{layers:new Set(r),listener:n,delegates:{[i]:h}}}}on(i,r,n){if(void 0===n)return super.on(i,r);Array.isArray(r)||(r=[r]);const o=this._createDelegatedListener(i,r,n);for(const s in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[i]=this._delegatedListeners[i]||[],this._delegatedListeners[i].push(o),o.delegates)this.on(s,o.delegates[s]);return this}once(i,r,n){if(void 0===n)return super.once(i,r);Array.isArray(r)||(r=[r]);const o=this._createDelegatedListener(i,r,n);for(const s in o.delegates)this.once(s,o.delegates[s]);return this}off(i,r,n){if(void 0===n)return super.off(i,r);r=new Set(Array.isArray(r)?r:[r]);const o=(i,r)=>{if(i.size!==r.size)return!1;for(const n of i)if(!r.has(n))return!1;return!0},s=this._delegatedListeners?this._delegatedListeners[i]:void 0;return s&&(i=>{for(let s=0;s{r?this.fire(new i.ErrorEvent(r)):o&&this._updateDiff(o,n)})}else"object"==typeof r&&this._updateDiff(r,n)}_updateDiff(r,n){try{this.style.setState(r)&&this._update(!0)}catch(o){i.warnOnce(`Unable to perform style diff: ${o.message||o.error||o}. Rebuilding the style from scratch.`),this._updateStyle(r,n)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():i.warnOnce("There is no style added to the map.")}addSource(i,r){return this._lazyInitEmptyStyle(),this.style.addSource(i,r),this._update(!0)}isSourceLoaded(r){const n=this.style&&this.style._getSourceCaches(r);if(0!==n.length)return n.every(i=>i.loaded());this.fire(new i.ErrorEvent(Error(`There is no source with ID '${r}'`)))}areTilesLoaded(){const i=this.style&&this.style._sourceCaches;for(const r in i){const n=i[r]._tiles;for(const o in n){const s=n[o];if("loaded"!==s.state&&"errored"!==s.state)return!1}}return!0}addSourceType(i,r,n){return this._lazyInitEmptyStyle(),this.style.addSourceType(i,r,n)}removeSource(i){return this.style.removeSource(i),this._updateTerrain(),this._update(!0)}getSource(i){return this.style.getSource(i)}addImage(r,n,{pixelRatio:o=1,sdf:s=!1,stretchX:a,stretchY:l,content:c}={}){if(this._lazyInitEmptyStyle(),n instanceof ro||ra&&n instanceof ra){const{width:u,height:h,data:d}=i.exported.getImageData(n);this.style.addImage(r,{data:new i.RGBAImage({width:u,height:h},d),pixelRatio:o,stretchX:a,stretchY:l,content:c,sdf:s,version:0})}else{if(void 0===n.width||void 0===n.height)return this.fire(new i.ErrorEvent(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:p,height:f,data:m}=n,g=n;this.style.addImage(r,{data:new i.RGBAImage({width:p,height:f},new Uint8Array(m)),pixelRatio:o,stretchX:a,stretchY:l,content:c,sdf:s,version:0,userImage:g}),g.onAdd&&g.onAdd(this,r)}}}updateImage(r,n){const o=this.style.getImage(r);if(!o)return this.fire(new i.ErrorEvent(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const s=n instanceof ro||ra&&n instanceof ra?i.exported.getImageData(n):n,{width:a,height:l,data:c}=s;return void 0===a||void 0===l?this.fire(new i.ErrorEvent(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`"))):a!==o.data.width||l!==o.data.height?this.fire(new i.ErrorEvent(Error("The width and height of the updated image must be that same as the previous version of the image"))):(o.data.replace(c,!(n instanceof ro||ra&&n instanceof ra)),void this.style.updateImage(r,o))}hasImage(r){return r?!!this.style.getImage(r):(this.fire(new i.ErrorEvent(Error("Missing required image id"))),!1)}removeImage(i){this.style.removeImage(i)}loadImage(r,n){i.getImage(this._requestManager.transformRequest(r,i.ResourceType.Image),(r,o)=>{n(r,o instanceof ro?i.exported.getImageData(o):o)})}listImages(){return this.style.listImages()}addLayer(i,r){return this._lazyInitEmptyStyle(),this.style.addLayer(i,r),this._update(!0)}moveLayer(i,r){return this.style.moveLayer(i,r),this._update(!0)}removeLayer(i){return this.style.removeLayer(i),this._update(!0)}getLayer(i){return this.style.getLayer(i)}setLayerZoomRange(i,r,n){return this.style.setLayerZoomRange(i,r,n),this._update(!0)}setFilter(i,r,n={}){return this.style.setFilter(i,r,n),this._update(!0)}getFilter(i){return this.style.getFilter(i)}setPaintProperty(i,r,n,o={}){return this.style.setPaintProperty(i,r,n,o),this._update(!0)}getPaintProperty(i,r){return this.style.getPaintProperty(i,r)}setLayoutProperty(i,r,n,o={}){return this.style.setLayoutProperty(i,r,n,o),this._update(!0)}getLayoutProperty(i,r){return this.style.getLayoutProperty(i,r)}setLight(i,r={}){return this._lazyInitEmptyStyle(),this.style.setLight(i,r),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(i){return this._lazyInitEmptyStyle(),!i&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(i),this._averageElevationLastSampledAt=-1/0,this._update(!0)}_updateProjection(){"globe"===this.transform.projection.name&&this.transform.zoom>=i.GLOBE_ZOOM_THRESHOLD_MAX&&!this._transitionFromGlobe&&(this.setProjection({name:"mercator"}),this._transitionFromGlobe=!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(i){return this._lazyInitEmptyStyle(),this.style.setFog(i),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(r){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(i.LngLat.convert(r),this.transform):0}setFeatureState(i,r){return this.style.setFeatureState(i,r),this._update()}removeFeatureState(i,r){return this.style.removeFeatureState(i,r),this._update()}getFeatureState(i){return this.style.getFeatureState(i)}_updateContainerDimensions(){if(!this._container)return;const r=this._container.getBoundingClientRect().width||400,n=this._container.getBoundingClientRect().height||300;let o,s=this._container;for(;s&&!o;){const a=i.window.getComputedStyle(s).transform;a&&"none"!==a&&(o=a.match(/matrix.*\((.+)\)/)[1].split(", ")),s=s.parentElement}o?(this._containerWidth=o[0]&&"0"!==o[0]?Math.abs(r/o[0]):r,this._containerHeight=o[3]&&"0"!==o[3]?Math.abs(n/o[3]):n):(this._containerWidth=r,this._containerHeight=n)}_detectMissingCSS(){"rgb(250, 128, 114)"!==i.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&i.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const i=this._container;i.classList.add("mapboxgl-map"),(this._missingCSSCanary=l.create("div","mapboxgl-canary",i)).style.visibility="hidden",this._detectMissingCSS();const r=this._canvasContainer=l.create("div","mapboxgl-canvas-container",i);this._interactive&&r.classList.add("mapboxgl-interactive"),this._canvas=l.create("canvas","mapboxgl-canvas",r),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const n=this._controlContainer=l.create("div","mapboxgl-control-container",i),o=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right",].forEach(i=>{o[i]=l.create("div",`mapboxgl-ctrl-${i}`,n)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(r,n){const o=i.exported.devicePixelRatio||1;this._canvas.width=o*Math.ceil(r),this._canvas.height=o*Math.ceil(n),this._canvas.style.width=`${r}px`,this._canvas.style.height=`${n}px`}_addMarker(i){this._markers.push(i)}_removeMarker(i){const r=this._markers.indexOf(i);-1!==r&&this._markers.splice(r,1)}_setupPainter(){const n=i.extend({},r.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),o=this._canvas.getContext("webgl",n)||this._canvas.getContext("experimental-webgl",n);o?(i.storeAuthState(o,!0),this.painter=new it(o,this.transform),this.on("data",i=>{"source"===i.dataType&&this.painter.setTileLoadedFlag(!0)}),i.exported$1.testSupport(o)):this.fire(new i.ErrorEvent(Error("Failed to initialize WebGL")))}_contextLost(r){r.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.Event("webglcontextlost",{originalEvent:r}))}_contextRestored(r){this._setupPainter(),this.resize(),this._update(),this.fire(new i.Event("webglcontextrestored",{originalEvent:r}))}_onMapScroll(i){if(i.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(i){return this.style&&(this._styleDirty=this._styleDirty||i,this._sourcesDirty=!0,this.triggerRepaint()),this}_requestRenderFrame(i){return this._update(),this._renderTaskQueue.add(i)}_cancelRenderFrame(i){this._renderTaskQueue.remove(i)}_requestDomTask(i){!this.loaded()||this.loaded()&&!this.isMoving()?i():this._domRenderTaskQueue.add(i)}_render(r){let n;const o=this.painter.context.extTimerQuery,s=i.exported.now();this.listens("gpu-timing-frame")&&(n=o.createQueryEXT(),o.beginQueryEXT(o.TIME_ELAPSED_EXT,n));let a=this._updateAverageElevation(s);if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(r),this._domRenderTaskQueue.run(r),this._removed)return;this._updateProjection();let l=!1;const c=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const u=this.transform.zoom,h=this.transform.pitch,d=i.exported.now();this.style.zoomHistory.update(u,d);const p=new i.EvaluationParameters(u,{now:d,fadeDuration:c,pitch:h,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),f=p.crossFadingFactor();1===f&&f===this._crossFadingFactor||(l=!0,this._crossFadingFactor=f),this.style.update(p)}if(this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0),this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),this.style._updateSources(this.transform),this._forceMarkerUpdate()),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,c,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:c,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new i.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new i.Event("load"))),this.style&&(this.style.hasTransitions()||l)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const m=i.exported.now()-s;o.endQueryEXT(o.TIME_ELAPSED_EXT,n),setTimeout(()=>{const r=o.getQueryObjectEXT(n,o.QUERY_RESULT_EXT)/1e6;o.deleteQueryEXT(n),this.fire(new i.Event("gpu-timing-frame",{cpuTime:m,gpuTime:r}))},50)}if(this.listens("gpu-timing-layer")){const g=this.painter.collectGpuTimers();setTimeout(()=>{const r=this.painter.queryGpuTimers(g);this.fire(new i.Event("gpu-timing-layer",{layerTimes:r}))},50)}const y=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(y||this._repaint)this.triggerRepaint();else{const x=!this.isMoving()&&this.loaded();if(x&&(a=this._updateAverageElevation(s,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),x&&(this.fire(new i.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const $=this._calculateSpeedIndex();this.fire(new i.Event("speedindexcompleted",{speedIndex:$})),this.speedIndexTiming=!1}}return!this._loaded||this._fullyLoaded||y||(this._fullyLoaded=!0,this._authenticate()),this}_forceMarkerUpdate(){for(const i of this._markers)i._update()}_updateAverageElevation(i,r=!1){const n=i=>(this.transform.averageElevation=i,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&n(0);if((r||i-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(i)){const o=this.transform.averageElevation;let s=this.transform.sampleAverageElevation();isNaN(s)?s=0:this._averageElevationLastSampledAt=i;const a=Math.abs(o-s);if(a>1){if(this._isInitialLoad)return this._averageElevation.jumpTo(s),n(s);this._averageElevation.easeTo(s,i,300)}else if(a>1e-4)return this._averageElevation.jumpTo(s),n(s)}return!!this._averageElevation.isEasing(i)&&n(this._averageElevation.getValue(i))}_authenticate(){i.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,r=>{if(r&&(r.message===i.AUTH_ERR_MSG||401===r.status)){const n=this.painter.context.gl;i.storeAuthState(n,!1),this._logoControl instanceof re&&this._logoControl._updateLogo(),n&&n.clear(n.DEPTH_BUFFER_BIT|n.COLOR_BUFFER_BIT|n.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new i.ErrorEvent(Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),i.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const i=this.painter.canvasCopy(),r=this.painter.getCanvasCopiesAndTimestamps();r.timeStamps.push(performance.now());const n=this.painter.context.gl,o=n.createFramebuffer();function s(i){n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,i,0);const r=new Uint8Array(n.drawingBufferWidth*n.drawingBufferHeight*4);return n.readPixels(0,0,n.drawingBufferWidth,n.drawingBufferHeight,n.RGBA,n.UNSIGNED_BYTE,r),r}return n.bindFramebuffer(n.FRAMEBUFFER,o),this._canvasPixelComparison(s(i),r.canvasCopies.map(s),r.timeStamps)}_canvasPixelComparison(i,r,n){let o=n[1]-n[0];const s=i.length/4;for(let a=0;a{const r=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,r&&this._render(i)}))}_preloadTiles(r){const n=this.style&&Object.values(this.style._sourceCaches)||[];return i.asyncAll(n,(i,n)=>i._preloadTiles(r,n),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(i){this._trackResize&&this.resize({originalEvent:i})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(i){this._showTileBoundaries!==i&&(this._showTileBoundaries=i,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(i){this._showTerrainWireframe!==i&&(this._showTerrainWireframe=i,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(i){this._speedIndexTiming!==i&&(this._speedIndexTiming=i,this._update())}get showPadding(){return!!this._showPadding}set showPadding(i){this._showPadding!==i&&(this._showPadding=i,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(i){this._showCollisionBoxes!==i&&(this._showCollisionBoxes=i,i?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(i){this._showOverdrawInspector!==i&&(this._showOverdrawInspector=i,this._update())}get repaint(){return!!this._repaint}set repaint(i){this._repaint!==i&&(this._repaint=i,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(i){this._vertices=i,this._update()}_setCacheLimits(r,n){i.setCacheLimits(r,n)}get version(){return i.version}},NavigationControl:class{constructor(r){this.options=i.extend({},{showCompass:!0,showZoom:!0,visualizePitch:!1},r),this._container=l.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",i=>i.preventDefault()),this.options.showZoom&&(i.bindAll(["_setButtonTitle","_updateZoomButtons",],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",i=>this._map.zoomIn({},{originalEvent:i})),l.create("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden",!0),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",i=>this._map.zoomOut({},{originalEvent:i})),l.create("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden",!0)),this.options.showCompass&&(i.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",i=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:i}):this._map.resetNorth({},{originalEvent:i})}),this._compassIcon=l.create("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden",!0))}_updateZoomButtons(){const i=this._map.getZoom(),r=i===this._map.getMaxZoom(),n=i===this._map.getMinZoom();this._zoomInButton.disabled=r,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute("aria-disabled",r.toString()),this._zoomOutButton.setAttribute("aria-disabled",n.toString())}_rotateCompassArrow(){const i=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._map._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=i)})}onAdd(i){return this._map=i,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._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new rc(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(i,r){const n=l.create("button",i,this._container);return n.type="button",n.addEventListener("click",r),n}_setButtonTitle(i,r){const n=this._map._getUIString(`NavigationControl.${r}`);i.setAttribute("aria-label",n),i.firstElementChild&&i.firstElementChild.setAttribute("title",n)}},GeolocateControl:class extends i.Evented{constructor(r){super(),this.options=i.extend({},{positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},r),i.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation",],this),this._onDeviceOrientationListener=this._onDeviceOrientation.bind(this),this._updateMarkerRotationThrottled=iy(this._updateMarkerRotation,20)}onAdd(r){var n;return this._map=r,this._container=l.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),n=this._setupUI,void 0!==ru?n(ru):void 0!==i.window.navigator.permissions?i.window.navigator.permissions.query({name:"geolocation"}).then(i=>{n(ru="denied"!==i.state)}):n(ru=!!i.window.navigator.geolocation),this._container}onRemove(){void 0!==this._geolocationWatchID&&(i.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(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,rh=0,rd=!1}_isOutOfMapMaxBounds(i){const r=this._map.getMaxBounds(),n=i.coords;return r&&(n.longituder.getEast()||n.latituder.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(r){if(this._map){if(this._isOutOfMapMaxBounds(r))return this._setErrorState(),this.fire(new i.Event("outofmaxbounds",r)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=r,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(r),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(r),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new i.Event("geolocate",r)),this._finish()}}_updateCamera(r){const n=new i.LngLat(r.coords.longitude,r.coords.latitude),o=r.coords.accuracy,s=this._map.getBearing(),a=i.extend({bearing:s},this.options.fitBoundsOptions);this._map.fitBounds(n.toBounds(o),a,{geolocateSource:!0})}_updateMarker(r){if(r){const n=new i.LngLat(r.coords.longitude,r.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=r.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const i=this._map._containerHeight/2,r=this._map.unproject([0,i]),n=this._map.unproject([100,i]),o=r.distanceTo(n)/100,s=Math.ceil(2*this._accuracy/o);this._circleElement.style.width=`${s}px`,this._circleElement.style.height=`${s}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(r){if(this._map){if(this.options.trackUserLocation){if(1===r.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",n),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",n),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===r.code&&rd)return;this._setErrorState()}}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new i.Event("error",r)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(r){if(this._container.addEventListener("contextmenu",i=>i.preventDefault()),this._geolocateButton=l.create("button","mapboxgl-ctrl-geolocate",this._container),l.create("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden",!0),this._geolocateButton.type="button",!1===r){i.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",n),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",n)}else{const o=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",o),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",o)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=l.create("div","mapboxgl-user-location"),this._dotElement.appendChild(l.create("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(l.create("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new rn({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=l.create("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new rn({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",r=>{r.geolocateSource||"ACTIVE_LOCK"!==this._watchState||r.originalEvent&&"resize"===r.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new i.Event("trackuserlocationend")))})}_onDeviceOrientation(i){this._userLocationDotMarker&&(i.webkitCompassHeading?this._heading=i.webkitCompassHeading:!0===i.absolute&&(this._heading=-1*i.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return i.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new i.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":rh--,rd=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new i.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new i.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let r;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),++rh>1?(r={maximumAge:6e5,timeout:0},rd=!0):(r=this.options.positionOptions,rd=!1),this._geolocationWatchID=i.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,r),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else i.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const r=()=>{i.window.addEventListener("ondeviceorientationabsolute"in i.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientationListener)};void 0!==i.window.DeviceMotionEvent&&"function"==typeof i.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(i=>{"granted"===i&&r()}).catch(console.error):r()}_clearWatch(){i.window.navigator.geolocation.clearWatch(this._geolocationWatchID),i.window.removeEventListener("deviceorientation",this._onDeviceOrientationListener),i.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientationListener),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:iQ,ScaleControl:class{constructor(r){this.options=i.extend({},{maxWidth:100,unit:"metric"},r),i.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){rp(this._map,this._container,this.options)}onAdd(i){return this._map=i,this._container=l.create("div","mapboxgl-ctrl mapboxgl-ctrl-scale",i.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}setUnit(i){this.options.unit=i,rp(this._map,this._container,this.options)}},FullscreenControl:class{constructor(r){this._fullscreen=!1,r&&r.container&&(r.container instanceof i.window.HTMLElement?this._container=r.container:i.warnOnce("Full screen control 'container' must be a DOM element.")),i.bindAll(["_onClickFullscreen","_changeIcon",],this),"onfullscreenchange"in i.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in i.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(r){return this._map=r,this._container||(this._container=this._map.getContainer()),this._controlContainer=l.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,i.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!i.window.document.fullscreenEnabled&&!i.window.document.webkitFullscreenEnabled)}_setupUI(){const r=this._fullscreenButton=l.create("button","mapboxgl-ctrl-fullscreen",this._controlContainer);l.create("span","mapboxgl-ctrl-icon",r).setAttribute("aria-hidden",!0),r.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),i.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const i=this._getTitle();this._fullscreenButton.setAttribute("aria-label",i),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",i)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(i.window.document.fullscreenElement||i.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?i.window.document.exitFullscreen?i.window.document.exitFullscreen():i.window.document.webkitCancelFullScreen&&i.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends i.Evented{constructor(r){super(),this.options=i.extend(Object.create({closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"}),r),i.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag",],this),this._classList=new Set(r&&r.className?r.className.trim().split(/\s+/):[])}addTo(r){return this._map&&this.remove(),this._map=r,this.options.closeOnClick&&this._map.on("preclick",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._map._canvasContainer.classList.add("mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new i.Event("open")),this}isOpen(){return!!this._map}remove(){return this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new i.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(r){return this._lngLat=i.LngLat.convert(r),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._map._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(r){return this.setDOMContent(i.window.document.createTextNode(r))}setHTML(r){const n=i.window.document.createDocumentFragment(),o=i.window.document.createElement("body");let s;for(o.innerHTML=r;s=o.firstChild;)n.appendChild(s);return this.setDOMContent(n)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(i){return this.options.maxWidth=i,this._update(),this}setDOMContent(i){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=l.create("div","mapboxgl-popup-content",this._container);return this._content.appendChild(i),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(i){return this._classList.add(i),this._container&&this._updateClassList(),this}removeClassName(i){return this._classList.delete(i),this._container&&this._updateClassList(),this}setOffset(i){return this.options.offset=i,this._update(),this}toggleClassName(i){let r;return this._classList.delete(i)?r=!1:(this._classList.add(i),r=!0),this._container&&this._updateClassList(),r}_createCloseButton(){this.options.closeButton&&(this._closeButton=l.create("button","mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.setAttribute("aria-hidden","true"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(i){this._update(i.point)}_onMouseMove(i){this._update(i.point)}_onDrag(i){this._update(i.point)}_getAnchor(i){if(this.options.anchor)return this.options.anchor;const r=this._pos,n=this._container.offsetWidth,o=this._container.offsetHeight;let s;return s=r.y+i.bottom.ythis._map.transform.height-o?["bottom"]:[],r.xthis._map.transform.width-n/2&&s.push("right"),0===s.length?"bottom":s.join("-")}_updateClassList(){const i=[...this._classList];i.push("mapboxgl-popup"),this._anchor&&i.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&i.push("mapboxgl-popup-track-pointer"),this._container.className=i.join(" ")}_update(r){if(this._map&&(this._lngLat||this._trackPointer)&&this._content){if(this._container||(this._container=l.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=l.create("div","mapboxgl-popup-tip",this._container),this._container.appendChild(this._content)),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=ri(this._lngLat,this._pos,this._map.transform)),!this._trackPointer||r){const n=this._pos=this._trackPointer&&r?r:this._map.project(this._lngLat),o=function(r){if(r||(r=new i.pointGeometry(0,0)),"number"==typeof r){const n=Math.round(Math.sqrt(.5*Math.pow(r,2)));return{center:new i.pointGeometry(0,0),top:new i.pointGeometry(0,r),"top-left":new i.pointGeometry(n,n),"top-right":new i.pointGeometry(-n,n),bottom:new i.pointGeometry(0,-r),"bottom-left":new i.pointGeometry(n,-n),"bottom-right":new i.pointGeometry(-n,-n),left:new i.pointGeometry(r,0),right:new i.pointGeometry(-r,0)}}if(r instanceof i.pointGeometry||Array.isArray(r)){const o=i.pointGeometry.convert(r);return{center:o,top:o,"top-left":o,"top-right":o,bottom:o,"bottom-left":o,"bottom-right":o,left:o,right:o}}return{center:i.pointGeometry.convert(r.center||[0,0,]),top:i.pointGeometry.convert(r.top||[0,0]),"top-left":i.pointGeometry.convert(r["top-left"]||[0,0]),"top-right":i.pointGeometry.convert(r["top-right"]||[0,0]),bottom:i.pointGeometry.convert(r.bottom||[0,0,]),"bottom-left":i.pointGeometry.convert(r["bottom-left"]||[0,0]),"bottom-right":i.pointGeometry.convert(r["bottom-right"]||[0,0]),left:i.pointGeometry.convert(r.left||[0,0]),right:i.pointGeometry.convert(r.right||[0,0,])}}(this.options.offset),s=this._anchor=this._getAnchor(o),a=n.add(o[s]).round();this._map._requestDomTask(()=>{this._container&&s&&(this._container.style.transform=`${rr[s]} translate(${a.x}px,${a.y}px)`)})}this._updateClassList()}}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const i=this._container.querySelector("a[href], [tabindex]:not([tabindex='-1']), [contenteditable]:not([contenteditable='false']), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])");i&&i.focus()}_onClose(){this.remove()}_setOpacity(i){this._content&&(this._content.style.opacity=i),this._tip&&(this._tip.style.opacity=i)}},Marker:rn,Style:eN,LngLat:i.LngLat,LngLatBounds:i.LngLatBounds,Point:i.pointGeometry,MercatorCoordinate:i.MercatorCoordinate,FreeCameraOptions:il,Evented:i.Evented,config:i.config,prewarm:function(){et().acquire(J)},clearPrewarmedResources:function(){const i=ee;i&&(i.isPreloaded()&&1===i.numActive()?(i.release(J),ee=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return i.config.ACCESS_TOKEN},set accessToken(t){i.config.ACCESS_TOKEN=t},get baseApiUrl(){return i.config.API_URL},set baseApiUrl(t){i.config.API_URL=t},get workerCount(){return Q.workerCount},set workerCount(e){Q.workerCount=e},get maxParallelImageRequests(){return i.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){i.config.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(r){i.clearTileCache(r)},workerUrl:"",workerClass:null,setNow:i.exported.setNow,restoreNow:i.exported.restoreNow};return rm}),n})}},]); + with id '${r.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(i){i.coord&&"source"===i.dataType?this._clearRenderCacheForTile(i.sourceCacheId,i.coord):"style"===i.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const i in this._style._sourceCaches)this._style._sourceCaches[i].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(i=>i.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const i=2*this.proxySourceCache.getSource().tileSize;return[i,i]}set useVertexMorphing(i){this._useVertexMorphing=i}updateTileBinding(r){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const n=this.proxySourceCache,o=this.painter.transform;this._initializing&&(this._initializing=0===o._centerAltitude&&-1===this.getAtPointOrZero(i.MercatorCoordinate.fromLngLat(o.center),-1),this._emptyDEMTextureDirty=!this._initializing);const s=this.proxyCoords=n.getIds().map(i=>{const r=n.getTileByID(i).tileID;return r.projMatrix=o.calculateProjMatrix(r.toUnwrapped()),r});(function(r,n){const o=n.transform.pointCoordinate(n.transform.getCameraPoint()),s=new i.pointGeometry(o.x,o.y);r.sort((r,n)=>{if(n.overscaledZ-r.overscaledZ)return n.overscaledZ-r.overscaledZ;const o=new i.pointGeometry(r.canonical.x+(1<{this.proxyToSource[i.key]={}}),this.terrainTileForTile={};const l=this._style._sourceCaches;for(const c in l){const u=l[c];if(!u.used||(u!==this.sourceCache&&this.resetTileLookupCache(u.id),this._setupProxiedCoordsForOrtho(u,r[c],a),u.usedForTerrain))continue;const h=r[c];u.getSource().reparseOverscaled&&this._assignTerrainTiles(h)}this.proxiedCoords[n.id]=s.map(i=>new tu(i,i.key,this.orthoMatrix)),this._assignTerrainTiles(s),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(a),this.renderingToTexture=!1,this._updateTimestamp=i.exported.now();const d={};for(const p of(this._visibleDemTiles=[],this.proxyCoords)){const f=this.terrainTileForTile[p.key];if(!f)continue;const m=f.tileID.key;m in d||(this._visibleDemTiles.push(f),d[m]=m)}}_assignTerrainTiles(i){this._initializing||i.forEach(i=>{if(this.terrainTileForTile[i.key])return;const r=this._findTileCoveringTileID(i,this.sourceCache);r&&(this.terrainTileForTile[i.key]=r)})}_prepareDEMTextures(){const i=this.painter.context,r=i.gl;for(const n in this.terrainTileForTile){const o=this.terrainTileForTile[n],s=o.dem;s&&(!o.demTexture||o.needsDEMTextureUpload)&&(i.activeTexture.set(r.TEXTURE1),eY(this.painter,o,s))}}_prepareDemTileUniforms(i,r,n,o){if(!r||null==r.demTexture)return!1;const s=i.tileID.canonical,a=Math.pow(2,r.tileID.canonical.z-s.z),l=o||"";return n[`u_dem_tl${l}`]=[s.x*a%1,s.y*a%1,],n[`u_dem_scale${l}`]=a,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const r=this.painter.context,n=r.gl;if(!this._emptyDepthBufferTexture){const o={width:1,height:1,data:new Uint8Array([255,255,255,255,])};this._emptyDepthBufferTexture=new i.Texture(r,o,n.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let i=0;const r=this._visibleDemTiles.reduce((r,n)=>{if(!n.dem)return r;const o=n.dem.tree.minimums[0];return o>0&&i++,r+o},0);return i?r/i:0}_updateEmptyDEMTexture(){const r=this.painter.context,n=r.gl;r.activeTexture.set(n.TEXTURE2);const o=this._getLoadedAreaMinimum(),s={width:1,height:1,data:new Uint8Array(i.DEMData.pack(o,this.sourceCache.getSource().encoding))};this._emptyDEMTextureDirty=!1;let a=this._emptyDEMTexture;return a?a.update(s,{premultiply:!1}):a=this._emptyDEMTexture=new i.Texture(r,s,n.RGBA,{premultiply:!1}),a}setupElevationDraw(r,n,o){var s;const a=this.painter.context,l=a.gl,c=(s=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:i.DEMData.getUnpackVector(s),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});c.u_dem_size=this.sourceCache.getSource().tileSize,c.u_exaggeration=this.exaggeration();const u=this.painter.transform,h=u.projection.createTileTransform(u,u.worldSize),d=r.tileID.canonical;c.u_tile_tl_up=h.upVector(d,0,0),c.u_tile_tr_up=h.upVector(d,i.EXTENT,0),c.u_tile_br_up=h.upVector(d,i.EXTENT,i.EXTENT),c.u_tile_bl_up=h.upVector(d,0,i.EXTENT),c.u_tile_up_scale=h.upVectorScale(d);let p=null,f=null,m=1;if(o&&o.morphing&&this._useVertexMorphing){const g=o.morphing.srcDemTile,y=o.morphing.dstDemTile;m=o.morphing.phase,g&&y&&(this._prepareDemTileUniforms(r,g,c,"_prev")&&(f=g),this._prepareDemTileUniforms(r,y,c)&&(p=y))}if(f&&p?(a.activeTexture.set(l.TEXTURE2),p.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE,l.NEAREST),a.activeTexture.set(l.TEXTURE4),f.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE,l.NEAREST),c.u_dem_lerp=m):(p=this.terrainTileForTile[r.tileID.key],a.activeTexture.set(l.TEXTURE2),(this._prepareDemTileUniforms(r,p,c)?p.demTexture:this.emptyDEMTexture).bind(l.NEAREST,l.CLAMP_TO_EDGE)),a.activeTexture.set(l.TEXTURE3),o&&o.useDepthForOcclusion?(this._depthTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE),c.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height,]):(this.emptyDepthBufferTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE),c.u_depth_size_inv=[1,1]),o&&o.useMeterToDem&&p){const x=(1<{if(h===i)return;const o=[];n&&o.push(tn[d]),o.push(tn[i]),o.push("PROJECTION_GLOBE_VIEW"),u=r.useProgram("globeRaster",null,o),h=i},f=r.colorModeForRenderPass(),m=new i.DepthMode(c.LEQUAL,i.DepthMode.ReadWrite,r.depthRangeFor3D);tr.update(a);const g=r.transform,y=i.calculateGlobeMatrix(g,g.worldSize),x=i.calculateGlobeMercatorMatrix(g),$=[i.mercatorXfromLng(g.center.lng),i.mercatorYfromLat(g.center.lat),],v=r.globeSharedBuffers;(d?[!1,!0]:[!1]).forEach(d=>{h=-1;const _=d?c.LINES:c.TRIANGLES;for(const b of s){const w=o.getTile(b),T=Math.pow(2,b.canonical.z),[E,S]=i.globeBuffersForTileMesh(r,w,b,T),I=i.StencilMode.disabled,C=n.prevTerrainTileForTile[b.key],z=n.terrainTileForTile[b.key];ti(C,z)&&tr.newMorphing(b.key,C,z,a,250),l.activeTexture.set(c.TEXTURE0),w.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE);const A=tr.getMorphValuesForProxy(b.key),k=A?1:0,P={};A&&i.extend$1(P,{morphing:{srcDemTile:A.from,dstDemTile:A.to,phase:i.easeCubicInOut(A.phase)}});const D=i.globeMatrixForTile(b.canonical,y),L=tt(g.projMatrix,D,x,i.globeToMercatorTransition(g.zoom),$);if(p(k,d),n.setupElevationDraw(w,u,P),r.prepareDrawProgram(l,u,b.toUnwrapped()),v){const[B,R]=d?v.getWirefameBuffer(r.context):[v.gridIndexBuffer,v.gridSegments,];u.draw(l,_,m,I,f,i.CullFaceMode.backCCW,L,"globe_raster",E,B,R)}if(!d){const M=[0===b.canonical.y?i.globePoleMatrixForTile(b.canonical,!1,g):null,b.canonical.y===T-1?i.globePoleMatrixForTile(b.canonical,!0,g):null,];for(const F of M){if(!F)continue;const O=tt(g.projMatrix,F,F,0,$);v&&u.draw(l,_,m,I,f,i.CullFaceMode.disabled,O,"globe_pole_raster",S,v.poleIndexBuffer,v.poleSegments)}}}})}(r,n,o,s,a);else{const l=r.context,c=l.gl;let u,h;const d=r.options.showTerrainWireframe?2:0,p=(i,n)=>{if(h===i)return;const o=[tn[i]];n&&o.push(tn[d]),u=r.useProgram("terrainRaster",null,o),h=i},f=r.colorModeForRenderPass(),m=new i.DepthMode(c.LEQUAL,i.DepthMode.ReadWrite,r.depthRangeFor3D);tr.update(a);const g=r.transform,y=6*Math.pow(1.5,22-g.zoom)*n.exaggeration();(d?[!1,!0]:[!1]).forEach(d=>{h=-1;const x=d?c.LINES:c.TRIANGLES,[$,v]=d?n.getWirefameBuffer():[n.gridIndexBuffer,n.gridSegments,];for(const _ of s){const b=o.getTile(_),w=i.StencilMode.disabled,T=n.prevTerrainTileForTile[_.key],E=n.terrainTileForTile[_.key];ti(T,E)&&tr.newMorphing(_.key,T,E,a,250),l.activeTexture.set(c.TEXTURE0),b.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE,c.LINEAR_MIPMAP_NEAREST);const S=tr.getMorphValuesForProxy(_.key),I=S?1:0;let C;S&&(C={morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:i.easeCubicInOut(S.phase)}});const z=te(_.projMatrix,to(_.canonical,g.renderWorldCopies)?y/10:y);p(I,d),n.setupElevationDraw(b,u,C),r.prepareDrawProgram(l,u,_.toUnwrapped()),u.draw(l,x,m,w,f,i.CullFaceMode.backCCW,z,"terrain_raster",n.gridBuffer,$,v)}})}}(n,this,this.proxySourceCache,r,this._updateTimestamp),this.renderingToTexture=!0,r.splice(0,r.length))}renderBatch(r){if(0===this._drapedRenderBatches.length)return r+1;this.renderingToTexture=!0;const n=this.painter,o=this.painter.context,s=this.proxySourceCache,a=this.proxiedCoords[s.id],l=this._drapedRenderBatches.shift(),c=[],u=n.style.order;let h=0;for(const d of a){const p=s.getTileByID(d.proxyTileKey),f=s.proxyCachedFBO[d.key]?s.proxyCachedFBO[d.key][r]:void 0,m=void 0!==f?s.renderCache[f]:this.pool[h++],g=void 0!==f;if(p.texture=m.tex,g&&!m.dirty){c.push(p.tileID);continue}let y;o.bindFramebuffer.set(m.fb.framebuffer),this.renderedToTile=!1,m.dirty&&(o.clear({color:i.Color.transparent,stencil:0}),m.dirty=!1);for(let x=l.start;x<=l.end;++x){const $=n.style._layers[u[x]];if($.isHidden(n.transform.zoom))continue;const v=n.style._getLayerSourceCache($),_=v?this.proxyToSource[d.key][v.id]:[d];if(!_)continue;const b=_;o.viewport.set([0,0,m.fb.width,m.fb.height,]),y!==(v?v.id:null)&&(this._setupStencil(m,_,$,v),y=v?v.id:null),n.renderLayer(n,v,$,b)}this.renderedToTile?(m.dirty=!0,c.push(p.tileID)):g||--h,5===h&&(h=0,this.renderToBackBuffer(c))}return this.renderToBackBuffer(c),this.renderingToTexture=!1,o.bindFramebuffer.set(null),o.viewport.set([0,0,n.width,n.height]),l.end+1}postRender(){}renderCacheEfficiency(i){const r=i.order.length;if(0===r)return{efficiency:100};let n,o=0,s=0,a=!1;for(let l=0;li.dem).forEach(r=>{i=Math.min(i,r.dem.tree.minimums[0])}),0===i?i:(i-30)*this._exaggeration}raycast(i,r,n){if(!this._visibleDemTiles)return null;const o=this._visibleDemTiles.filter(i=>i.dem).map(o=>{const s=o.tileID,a=Math.pow(2,s.overscaledZ),{x:l,y:c}=s.canonical,u=l/a,h=(l+1)/a,d=c/a,p=(c+1)/a;return{minx:u,miny:d,maxx:h,maxy:p,t:o.dem.tree.raycastRoot(u,d,h,p,i,r,n),tile:o}});for(const s of(o.sort((i,r)=>(null!==i.t?i.t:Number.MAX_VALUE)-(null!==r.t?r.t:Number.MAX_VALUE)),o)){if(null==s.t)break;const a=s.tile.dem.tree.raycast(s.minx,s.miny,s.maxx,s.maxy,i,r,n);if(null!=a)return a}return null}_createFBO(){const r=this.painter.context,n=r.gl,o=this.drapeBufferSize;r.activeTexture.set(n.TEXTURE0);const s=new i.Texture(r,{width:o[0],height:o[1],data:null},n.RGBA);s.bind(n.LINEAR,n.CLAMP_TO_EDGE);const a=r.createFramebuffer(o[0],o[1],!1);return a.colorAttachment.set(s.texture),a.depthAttachment=new B(r,a.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=r.createRenderbuffer(r.gl.DEPTH_STENCIL,o[0],o[1]),this._stencilRef=0,a.depthAttachment.set(this._sharedDepthStencil),r.clear({stencil:0})):a.depthAttachment.set(this._sharedDepthStencil),r.extTextureFilterAnisotropic&&!r.extTextureFilterAnisotropicForceOff&&n.texParameterf(n.TEXTURE_2D,r.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,r.extTextureFilterAnisotropicMax),{fb:a,tex:s,dirty:!1}}_initFBOPool(){for(;this.pool.length{const r=this._style._layers[i],n=r.isHidden(this.painter.transform.zoom),o=r.getCrossfadeParameters(),s=!!o&&1!==o.t,a=r.hasTransition();return"custom"!==r.type&&!n&&(s||a)})}_clearRasterFadeFromRenderCache(){let i=!1;for(const r in this._style._sourceCaches)if(this._style._sourceCaches[r]._source instanceof V){i=!0;break}if(i)for(let n=0;nr.renderCachePool.length){const n=Object.values(r.proxyCachedFBO);r.proxyCachedFBO={};for(let o=0;o=0;c--){const u=a[c];if(r.getTileByID(u.key),void 0!==r.proxyCachedFBO[u.key]){const h=i[u.key],d=this.proxyToSource[u.key];let p=0;for(const f in d){const m=d[f],g=h[f];if(!g||g.length!==m.length||m.some((i,r)=>i!==g[r]||l[f]&&l[f].hasOwnProperty(i.key))){p=-1;break}++p}for(const y in r.proxyCachedFBO[u.key])r.renderCache[r.proxyCachedFBO[u.key][y]].dirty=p<0||p!==Object.values(h).length}}const x=[...this._drapedRenderBatches];for(const $ of(x.sort((i,r)=>r.end-r.start-(i.end-i.start)),x))for(const v of a){if(r.proxyCachedFBO[v.key])continue;let _=r.renderCachePool.pop();void 0===_&&r.renderCache.length<50&&(_=r.renderCache.length,r.renderCache.push(this._createFBO())),void 0!==_&&(r.proxyCachedFBO[v.key]={},r.proxyCachedFBO[v.key][$.start]=_,r.renderCache[_].dirty=!0)}this._tilesDirty={}}_setupStencil(i,r,n,o){if(!o||!this._sourceTilesOverlap[o.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const s=this.painter.context,a=s.gl;if(r.length<=1)return void(this._overlapStencilType=!1);let l;if(n.isTileClipped())l=r.length,this._overlapStencilMode.test={func:a.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(r[0].overscaledZ>r[r.length-1].overscaledZ))return void(this._overlapStencilType=!1);l=1,this._overlapStencilMode.test={func:a.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+l>255&&(s.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=l,this._overlapStencilMode.ref=this._stencilRef,n.isTileClipped()&&this._renderTileClippingMasks(r,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(r){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[r.key]),this._overlapStencilMode):i.StencilMode.disabled}_renderTileClippingMasks(r,n){const o=this.painter,s=this.painter.context,a=s.gl;o._tileClippingMaskIDs={},s.setColorMode(i.ColorMode.disabled),s.setDepthMode(i.DepthMode.disabled);const l=o.useProgram("clippingMask");for(const c of r){const u=o._tileClippingMaskIDs[c.key]=--n;l.draw(s,a.TRIANGLES,i.DepthMode.disabled,new i.StencilMode({func:a.ALWAYS,mask:0},u,255,a.KEEP,a.KEEP,a.REPLACE),i.ColorMode.disabled,i.CullFaceMode.disabled,ts(c.projMatrix),"$clipping",o.tileExtentBuffer,o.quadTriangleIndexBuffer,o.tileExtentSegments)}}pointCoordinate(r){const n=this.painter.transform;if(r.x<0||r.x>n.width||r.y<0||r.y>n.height)return null;const o=[r.x,r.y,1,1];i.transformMat4$1(o,o,n.pixelMatrixInverse),i.scale$1(o,o,1/o[3]),o[0]/=n.worldSize,o[1]/=n.worldSize;const s=n._camera.position,a=i.mercatorZfromAltitude(1,n.center.lat),l=[s[0],s[1],s[2]/a,0],c=i.subtract([],o.slice(0,3),l);i.normalize(c,c);const u=this.raycast(l,c,this._exaggeration);return null!==u&&u?(i.scaleAndAdd(l,l,c,u),l[3]=l[2],l[2]*=a,l):null}drawDepth(){const r=this.painter,n=r.context,o=this.proxySourceCache,s=Math.ceil(r.width),a=Math.ceil(r.height);if(this._depthFBO&&(this._depthFBO.width!==s||this._depthFBO.height!==a)&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture),!this._depthFBO){const l=n.gl,c=n.createFramebuffer(s,a,!0);n.activeTexture.set(l.TEXTURE0);const u=new i.Texture(n,{width:s,height:a,data:null},l.RGBA);u.bind(l.NEAREST,l.CLAMP_TO_EDGE),c.colorAttachment.set(u.texture);const h=n.createRenderbuffer(n.gl.DEPTH_COMPONENT16,s,a);c.depthAttachment.set(h),this._depthFBO=c,this._depthTexture=u}n.bindFramebuffer.set(this._depthFBO.framebuffer),n.viewport.set([0,0,s,a]),function(r,n,o,s){if("globe"===r.transform.projection.name)return;const a=r.context,l=a.gl;a.clear({depth:1});const c=r.useProgram("terrainDepth"),u=new i.DepthMode(l.LESS,i.DepthMode.ReadWrite,r.depthRangeFor3D);for(const h of s){const d=o.getTile(h),p=te(h.projMatrix,0);n.setupElevationDraw(d,c),c.draw(a,l.TRIANGLES,u,i.StencilMode.disabled,i.ColorMode.unblended,i.CullFaceMode.backCCW,p,"terrain_depth",n.gridBuffer,n.gridIndexBuffer,n.gridNoSkirtSegments)}}(r,this,o,this.proxyCoords)}_setupProxiedCoordsForOrtho(i,r,n){if(i.getSource() instanceof G)return this._setupProxiedCoordsForImageSource(i,r,n);this._findCoveringTileCache[i.id]=this._findCoveringTileCache[i.id]||{};const o=this.proxiedCoords[i.id]=[],s=this.proxyCoords;for(let a=0;a(i.min.x=Math.min(i.min.x,r.x-c.x),i.min.y=Math.min(i.min.y,r.y-c.y),i.max.x=Math.max(i.max.x,r.x-c.x),i.max.y=Math.max(i.max.y,r.y-c.y),i),{min:new i.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),h=(r,n)=>{const o=r.wrap+r.canonical.x/(1<l+u.max.x||s+ac+u.max.y};for(let d=0;di.key===n.tileID.key);if(a)return a}if(n.tileID.key!==r.key){const l=r.canonical.z-n.tileID.canonical.z;let c,u,h;s=i.create();const d=n.tileID.wrap-r.wrap<0?(u=(c=i.EXTENT>>l)*((n.tileID.canonical.x<=d){const p=r.canonical.z-d;n.getSource().reparseOverscaled?(c=Math.max(r.canonical.z+2,n.transform.tileZoom),l=new i.OverscaledTileID(c,r.wrap,d,r.canonical.x>>p,r.canonical.y>>p)):0!==p&&(c=d,l=new i.OverscaledTileID(c,r.wrap,d,r.canonical.x>>p,r.canonical.y>>p))}l.key!==r.key&&(h.push(l.key),o=n.getTile(l))}const f=i=>{h.forEach(r=>{s[r]=i}),h.length=0};for(c-=1;c>=u&&(!o||!o.hasData());c--){o&&f(o.tileID.key);const m=l.calculateScaledKey(c);if((o=n.getTileByID(m))&&o.hasData())break;const g=s[m];if(null===g)break;void 0===g?h.push(m):o=n.getTileByID(g)}return f(o?o.tileID.key:null),o&&o.hasData()?o:null}findDEMTileFor(i){return this.enabled?this._findTileCoveringTileID(i,this.sourceCache):null}prepareDrawTile(i){this.renderedToTile=!0}_clearRenderCacheForTile(i,r){let n=this._tilesDirty[i];n||(n=this._tilesDirty[i]={}),n[r.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const r=function(r){let n,o,s;const a=new i.StructArrayLayout2ui4;for(o=1;o<129;o++){for(n=1;n<129;n++)s=131*o+n,a.emplaceBack(s,s+1),a.emplaceBack(s,s+131),a.emplaceBack(s+1,s+131),128===o&&a.emplaceBack(s+131,s+131+1);a.emplaceBack(s+1,s+1+131)}return a}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(r),this.wireframeSegments=i.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments,]}}function td(i){const r=[];for(let n=0;nv.indexOf(_)&&v.push(_);let b=s?s.defines():[];b=b.concat(l.map(i=>`#define ${i}`));const w=b.concat("\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",e5,eq.fragmentSource,e7.fragmentSource,o.fragmentSource).join("\n"),T=b.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",e5,eq.vertexSource,e7.vertexSource,e9.vertexSource,o.vertexSource).join("\n"),E=p.createShader(p.FRAGMENT_SHADER);if(p.isContextLost())return void(this.failedToCreate=!0);p.shaderSource(E,w),p.compileShader(E),p.attachShader(this.program,E);const S=p.createShader(p.VERTEX_SHADER);if(p.isContextLost())return void(this.failedToCreate=!0);p.shaderSource(S,T),p.compileShader(S),p.attachShader(this.program,S),this.attributes={};const I={};this.numAttributes=g.length;for(let C=0;C>16,c>>16],u_pixel_coord_lower:[65535&l,65535&c]}}const tm=(r,n,o,s)=>{const a=n.style.light,l=a.properties.get("position"),c=[l.x,l.y,l.z],u=i.create$1();"viewport"===a.properties.get("anchor")&&(i.fromRotation(u,-n.transform.angle),i.transformMat3(c,c,u));const h=a.properties.get("color");return{u_matrix:r,u_lightpos:c,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+o,u_opacity:s}},t8=(r,n,o,s,a,l,c)=>i.extend(tm(r,n,o,s),tf(l,n,c),{u_height_factor:-Math.pow(2,a.overscaledZ)/c.tileSize/8}),tg=i=>({u_matrix:i}),ty=(r,n,o,s)=>i.extend(tg(r),tf(o,n,s)),tx=(i,r)=>({u_matrix:i,u_world:r}),t$=(r,n,o,s,a)=>i.extend(ty(r,n,o,s),{u_world:a}),tv=(r,n,o,s)=>{const a=r.transform;let l;return l="map"===s.paint.get("circle-pitch-alignment")?a.calculatePixelsToTileUnitsMatrix(o):new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1],]),{u_camera_to_center_distance:a.cameraToCenterDistance,u_matrix:r.translatePosMatrix(n.projMatrix,o,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:i.exported.devicePixelRatio,u_extrude_scale:l}},t_=i=>{const r=[];return"map"===i.paint.get("circle-pitch-alignment")&&r.push("PITCH_WITH_MAP"),"map"===i.paint.get("circle-pitch-scale")&&r.push("SCALE_WITH_MAP"),r},tb=(r,n,o)=>{const s=i.EXTENT/o.tileSize;return{u_matrix:r,u_camera_to_center_distance:n.cameraToCenterDistance,u_extrude_scale:[n.pixelsToGLUnits[0]/s,n.pixelsToGLUnits[1]/s,]}},tw=(i,r,n=1)=>({u_matrix:i,u_color:r,u_overlay:0,u_overlay_scale:n}),t0=(i,r,n,o)=>({u_matrix:i,u_extrude_scale:C(r,1,n),u_intensity:o}),tT=(r,n,o,s,a,l)=>{const c=r.transform,u=c.calculatePixelsToTileUnitsMatrix(n),h={u_matrix:tI(r,n,o,a),u_pixels_to_tile_units:u,u_device_pixel_ratio:i.exported.devicePixelRatio,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1],],u_dash_image:0,u_gradient_image:1,u_image_height:l,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if(tC(o)){const d=tS(n,r.transform);h.u_texsize=n.lineAtlasTexture.size,h.u_scale=[d,s.fromScale,s.toScale,],h.u_mix=s.t}return h},tE=(r,n,o,s,a)=>{const l=r.transform,c=tS(n,l);return{u_matrix:tI(r,n,o,a),u_texsize:n.imageAtlasTexture.size,u_pixels_to_tile_units:l.calculatePixelsToTileUnitsMatrix(n),u_device_pixel_ratio:i.exported.devicePixelRatio,u_image:0,u_scale:[c,s.fromScale,s.toScale],u_fade:s.t,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1],],u_alpha_discard_threshold:0}};function tS(i,r){return 1/C(i,1,r.tileZoom)}function tI(i,r,n,o){return i.translatePosMatrix(o||r.tileID.projMatrix,r,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}function tC(i){const r=i.paint.get("line-dasharray").value;return r.value||"constant"!==r.kind}const tz=(i,r,n,o,s,a)=>{var l,c;return{u_matrix:i,u_tl_parent:r,u_scale_parent:n,u_fade_t:o.mix,u_opacity:o.opacity*s.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:s.paint.get("raster-brightness-min"),u_brightness_high:s.paint.get("raster-brightness-max"),u_saturation_factor:(c=s.paint.get("raster-saturation"))>0?1-1/(1.001-c):-c,u_contrast_factor:(l=s.paint.get("raster-contrast"))>0?1/(1-l):1+l,u_spin_weights:tA(s.paint.get("raster-hue-rotate")),u_perspective_transform:a}};function tA(i){i*=Math.PI/180;const r=Math.sin(i),n=Math.cos(i);return[(2*n+1)/3,(-Math.sqrt(3)*r-n+1)/3,(Math.sqrt(3)*r-n+1)/3,]}const tk=(i,r,n,o,s,a,l,c,u,h,d,p,f,m)=>{const g=s.transform;return{u_is_size_zoom_constant:+("constant"===i||"source"===i),u_is_size_feature_constant:+("constant"===i||"camera"===i),u_size_t:r?r.uSizeT:0,u_size:r?r.uSize:0,u_camera_to_center_distance:g.cameraToCenterDistance,u_pitch:g.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:g.width/g.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_matrix:a,u_label_plane_matrix:l,u_coord_matrix:c,u_is_text:+u,u_pitch_with_map:+o,u_texsize:h,u_tile_id:d,u_zoom_transition:p,u_inv_rot_matrix:f,u_merc_center:m,u_texture:0}},tP=(r,n,o,s,a,l,c,u,h,d,p,f,m,g,y)=>{const{cameraToCenterDistance:x,_pitch:$}=a.transform;return i.extend(tk(r,n,o,s,a,l,c,u,h,d,f,m,g,y),{u_gamma_scale:s?x*Math.cos(a.terrain?0:$):1,u_device_pixel_ratio:i.exported.devicePixelRatio,u_is_halo:+p})},tD=(r,n,o,s,a,l,c,u,h,d,p,f,m,g)=>i.extend(tP(r,n,o,s,a,l,c,u,!0,h,!0,p,f,m,g),{u_texsize_icon:d,u_texture_icon:1}),tL=(i,r,n)=>({u_matrix:i,u_opacity:r,u_color:n}),t1=(r,n,o,s,a,l)=>i.extend(function(i,r,n,o){const s=n.imageManager.getPattern(i.from.toString()),a=n.imageManager.getPattern(i.to.toString()),{width:l,height:c}=n.imageManager.getPixelSize(),u=Math.pow(2,o.tileID.overscaledZ),h=o.tileSize*Math.pow(2,n.transform.tileZoom)/u,d=h*(o.tileID.canonical.x+o.tileID.wrap*u),p=h*o.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:s.tl,u_pattern_br_a:s.br,u_pattern_tl_b:a.tl,u_pattern_br_b:a.br,u_texsize:[l,c],u_mix:r.t,u_pattern_size_a:s.displaySize,u_pattern_size_b:a.displaySize,u_scale_a:r.fromScale,u_scale_b:r.toScale,u_tile_units_to_pixels:1/C(o,1,n.transform.tileZoom),u_pixel_coord_upper:[d>>16,p>>16,],u_pixel_coord_lower:[65535&d,65535&p,]}}(s,l,o,a),{u_matrix:r,u_opacity:n}),tB={fillExtrusion:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_lightpos:new i.Uniform3f(r,n.u_lightpos),u_lightintensity:new i.Uniform1f(r,n.u_lightintensity),u_lightcolor:new i.Uniform3f(r,n.u_lightcolor),u_vertical_gradient:new i.Uniform1f(r,n.u_vertical_gradient),u_opacity:new i.Uniform1f(r,n.u_opacity)}),fillExtrusionPattern:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_lightpos:new i.Uniform3f(r,n.u_lightpos),u_lightintensity:new i.Uniform1f(r,n.u_lightintensity),u_lightcolor:new i.Uniform3f(r,n.u_lightcolor),u_vertical_gradient:new i.Uniform1f(r,n.u_vertical_gradient),u_height_factor:new i.Uniform1f(r,n.u_height_factor),u_image:new i.Uniform1i(r,n.u_image),u_texsize:new i.Uniform2f(r,n.u_texsize),u_pixel_coord_upper:new i.Uniform2f(r,n.u_pixel_coord_upper),u_pixel_coord_lower:new i.Uniform2f(r,n.u_pixel_coord_lower),u_scale:new i.Uniform3f(r,n.u_scale),u_fade:new i.Uniform1f(r,n.u_fade),u_opacity:new i.Uniform1f(r,n.u_opacity)}),fill:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix)}),fillPattern:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_image:new i.Uniform1i(r,n.u_image),u_texsize:new i.Uniform2f(r,n.u_texsize),u_pixel_coord_upper:new i.Uniform2f(r,n.u_pixel_coord_upper),u_pixel_coord_lower:new i.Uniform2f(r,n.u_pixel_coord_lower),u_scale:new i.Uniform3f(r,n.u_scale),u_fade:new i.Uniform1f(r,n.u_fade)}),fillOutline:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_world:new i.Uniform2f(r,n.u_world)}),fillOutlinePattern:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_world:new i.Uniform2f(r,n.u_world),u_image:new i.Uniform1i(r,n.u_image),u_texsize:new i.Uniform2f(r,n.u_texsize),u_pixel_coord_upper:new i.Uniform2f(r,n.u_pixel_coord_upper),u_pixel_coord_lower:new i.Uniform2f(r,n.u_pixel_coord_lower),u_scale:new i.Uniform3f(r,n.u_scale),u_fade:new i.Uniform1f(r,n.u_fade)}),circle:(r,n)=>({u_camera_to_center_distance:new i.Uniform1f(r,n.u_camera_to_center_distance),u_extrude_scale:new i.UniformMatrix2f(r,n.u_extrude_scale),u_device_pixel_ratio:new i.Uniform1f(r,n.u_device_pixel_ratio),u_matrix:new i.UniformMatrix4f(r,n.u_matrix)}),collisionBox:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_camera_to_center_distance:new i.Uniform1f(r,n.u_camera_to_center_distance),u_extrude_scale:new i.Uniform2f(r,n.u_extrude_scale)}),collisionCircle:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_inv_matrix:new i.UniformMatrix4f(r,n.u_inv_matrix),u_camera_to_center_distance:new i.Uniform1f(r,n.u_camera_to_center_distance),u_viewport_size:new i.Uniform2f(r,n.u_viewport_size)}),debug:(r,n)=>({u_color:new i.UniformColor(r,n.u_color),u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_overlay:new i.Uniform1i(r,n.u_overlay),u_overlay_scale:new i.Uniform1f(r,n.u_overlay_scale)}),clippingMask:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix)}),heatmap:(r,n)=>({u_extrude_scale:new i.Uniform1f(r,n.u_extrude_scale),u_intensity:new i.Uniform1f(r,n.u_intensity),u_matrix:new i.UniformMatrix4f(r,n.u_matrix)}),heatmapTexture:(r,n)=>({u_image:new i.Uniform1i(r,n.u_image),u_color_ramp:new i.Uniform1i(r,n.u_color_ramp),u_opacity:new i.Uniform1f(r,n.u_opacity)}),hillshade:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_image:new i.Uniform1i(r,n.u_image),u_latrange:new i.Uniform2f(r,n.u_latrange),u_light:new i.Uniform2f(r,n.u_light),u_shadow:new i.UniformColor(r,n.u_shadow),u_highlight:new i.UniformColor(r,n.u_highlight),u_accent:new i.UniformColor(r,n.u_accent)}),hillshadePrepare:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_image:new i.Uniform1i(r,n.u_image),u_dimension:new i.Uniform2f(r,n.u_dimension),u_zoom:new i.Uniform1f(r,n.u_zoom),u_unpack:new i.Uniform4f(r,n.u_unpack)}),line:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_pixels_to_tile_units:new i.UniformMatrix2f(r,n.u_pixels_to_tile_units),u_device_pixel_ratio:new i.Uniform1f(r,n.u_device_pixel_ratio),u_units_to_pixels:new i.Uniform2f(r,n.u_units_to_pixels),u_dash_image:new i.Uniform1i(r,n.u_dash_image),u_gradient_image:new i.Uniform1i(r,n.u_gradient_image),u_image_height:new i.Uniform1f(r,n.u_image_height),u_texsize:new i.Uniform2f(r,n.u_texsize),u_scale:new i.Uniform3f(r,n.u_scale),u_mix:new i.Uniform1f(r,n.u_mix),u_alpha_discard_threshold:new i.Uniform1f(r,n.u_alpha_discard_threshold)}),linePattern:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_texsize:new i.Uniform2f(r,n.u_texsize),u_pixels_to_tile_units:new i.UniformMatrix2f(r,n.u_pixels_to_tile_units),u_device_pixel_ratio:new i.Uniform1f(r,n.u_device_pixel_ratio),u_image:new i.Uniform1i(r,n.u_image),u_units_to_pixels:new i.Uniform2f(r,n.u_units_to_pixels),u_scale:new i.Uniform3f(r,n.u_scale),u_fade:new i.Uniform1f(r,n.u_fade),u_alpha_discard_threshold:new i.Uniform1f(r,n.u_alpha_discard_threshold)}),raster:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_tl_parent:new i.Uniform2f(r,n.u_tl_parent),u_scale_parent:new i.Uniform1f(r,n.u_scale_parent),u_fade_t:new i.Uniform1f(r,n.u_fade_t),u_opacity:new i.Uniform1f(r,n.u_opacity),u_image0:new i.Uniform1i(r,n.u_image0),u_image1:new i.Uniform1i(r,n.u_image1),u_brightness_low:new i.Uniform1f(r,n.u_brightness_low),u_brightness_high:new i.Uniform1f(r,n.u_brightness_high),u_saturation_factor:new i.Uniform1f(r,n.u_saturation_factor),u_contrast_factor:new i.Uniform1f(r,n.u_contrast_factor),u_spin_weights:new i.Uniform3f(r,n.u_spin_weights),u_perspective_transform:new i.Uniform2f(r,n.u_perspective_transform)}),symbolIcon:(r,n)=>({u_is_size_zoom_constant:new i.Uniform1i(r,n.u_is_size_zoom_constant),u_is_size_feature_constant:new i.Uniform1i(r,n.u_is_size_feature_constant),u_size_t:new i.Uniform1f(r,n.u_size_t),u_size:new i.Uniform1f(r,n.u_size),u_camera_to_center_distance:new i.Uniform1f(r,n.u_camera_to_center_distance),u_pitch:new i.Uniform1f(r,n.u_pitch),u_rotate_symbol:new i.Uniform1i(r,n.u_rotate_symbol),u_aspect_ratio:new i.Uniform1f(r,n.u_aspect_ratio),u_fade_change:new i.Uniform1f(r,n.u_fade_change),u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_label_plane_matrix:new i.UniformMatrix4f(r,n.u_label_plane_matrix),u_coord_matrix:new i.UniformMatrix4f(r,n.u_coord_matrix),u_is_text:new i.Uniform1i(r,n.u_is_text),u_pitch_with_map:new i.Uniform1i(r,n.u_pitch_with_map),u_texsize:new i.Uniform2f(r,n.u_texsize),u_tile_id:new i.Uniform3f(r,n.u_tile_id),u_zoom_transition:new i.Uniform1f(r,n.u_zoom_transition),u_inv_rot_matrix:new i.UniformMatrix4f(r,n.u_inv_rot_matrix),u_merc_center:new i.Uniform2f(r,n.u_merc_center),u_texture:new i.Uniform1i(r,n.u_texture)}),symbolSDF:(r,n)=>({u_is_size_zoom_constant:new i.Uniform1i(r,n.u_is_size_zoom_constant),u_is_size_feature_constant:new i.Uniform1i(r,n.u_is_size_feature_constant),u_size_t:new i.Uniform1f(r,n.u_size_t),u_size:new i.Uniform1f(r,n.u_size),u_camera_to_center_distance:new i.Uniform1f(r,n.u_camera_to_center_distance),u_pitch:new i.Uniform1f(r,n.u_pitch),u_rotate_symbol:new i.Uniform1i(r,n.u_rotate_symbol),u_aspect_ratio:new i.Uniform1f(r,n.u_aspect_ratio),u_fade_change:new i.Uniform1f(r,n.u_fade_change),u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_label_plane_matrix:new i.UniformMatrix4f(r,n.u_label_plane_matrix),u_coord_matrix:new i.UniformMatrix4f(r,n.u_coord_matrix),u_is_text:new i.Uniform1i(r,n.u_is_text),u_pitch_with_map:new i.Uniform1i(r,n.u_pitch_with_map),u_texsize:new i.Uniform2f(r,n.u_texsize),u_texture:new i.Uniform1i(r,n.u_texture),u_gamma_scale:new i.Uniform1f(r,n.u_gamma_scale),u_device_pixel_ratio:new i.Uniform1f(r,n.u_device_pixel_ratio),u_tile_id:new i.Uniform3f(r,n.u_tile_id),u_zoom_transition:new i.Uniform1f(r,n.u_zoom_transition),u_inv_rot_matrix:new i.UniformMatrix4f(r,n.u_inv_rot_matrix),u_merc_center:new i.Uniform2f(r,n.u_merc_center),u_is_halo:new i.Uniform1i(r,n.u_is_halo)}),symbolTextAndIcon:(r,n)=>({u_is_size_zoom_constant:new i.Uniform1i(r,n.u_is_size_zoom_constant),u_is_size_feature_constant:new i.Uniform1i(r,n.u_is_size_feature_constant),u_size_t:new i.Uniform1f(r,n.u_size_t),u_size:new i.Uniform1f(r,n.u_size),u_camera_to_center_distance:new i.Uniform1f(r,n.u_camera_to_center_distance),u_pitch:new i.Uniform1f(r,n.u_pitch),u_rotate_symbol:new i.Uniform1i(r,n.u_rotate_symbol),u_aspect_ratio:new i.Uniform1f(r,n.u_aspect_ratio),u_fade_change:new i.Uniform1f(r,n.u_fade_change),u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_label_plane_matrix:new i.UniformMatrix4f(r,n.u_label_plane_matrix),u_coord_matrix:new i.UniformMatrix4f(r,n.u_coord_matrix),u_is_text:new i.Uniform1i(r,n.u_is_text),u_pitch_with_map:new i.Uniform1i(r,n.u_pitch_with_map),u_texsize:new i.Uniform2f(r,n.u_texsize),u_texsize_icon:new i.Uniform2f(r,n.u_texsize_icon),u_texture:new i.Uniform1i(r,n.u_texture),u_texture_icon:new i.Uniform1i(r,n.u_texture_icon),u_gamma_scale:new i.Uniform1f(r,n.u_gamma_scale),u_device_pixel_ratio:new i.Uniform1f(r,n.u_device_pixel_ratio),u_is_halo:new i.Uniform1i(r,n.u_is_halo)}),background:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_opacity:new i.Uniform1f(r,n.u_opacity),u_color:new i.UniformColor(r,n.u_color)}),backgroundPattern:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_opacity:new i.Uniform1f(r,n.u_opacity),u_image:new i.Uniform1i(r,n.u_image),u_pattern_tl_a:new i.Uniform2f(r,n.u_pattern_tl_a),u_pattern_br_a:new i.Uniform2f(r,n.u_pattern_br_a),u_pattern_tl_b:new i.Uniform2f(r,n.u_pattern_tl_b),u_pattern_br_b:new i.Uniform2f(r,n.u_pattern_br_b),u_texsize:new i.Uniform2f(r,n.u_texsize),u_mix:new i.Uniform1f(r,n.u_mix),u_pattern_size_a:new i.Uniform2f(r,n.u_pattern_size_a),u_pattern_size_b:new i.Uniform2f(r,n.u_pattern_size_b),u_scale_a:new i.Uniform1f(r,n.u_scale_a),u_scale_b:new i.Uniform1f(r,n.u_scale_b),u_pixel_coord_upper:new i.Uniform2f(r,n.u_pixel_coord_upper),u_pixel_coord_lower:new i.Uniform2f(r,n.u_pixel_coord_lower),u_tile_units_to_pixels:new i.Uniform1f(r,n.u_tile_units_to_pixels)}),terrainRaster:eQ,terrainDepth:eQ,skybox:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_sun_direction:new i.Uniform3f(r,n.u_sun_direction),u_cubemap:new i.Uniform1i(r,n.u_cubemap),u_opacity:new i.Uniform1f(r,n.u_opacity),u_temporal_offset:new i.Uniform1f(r,n.u_temporal_offset)}),skyboxGradient:(r,n)=>({u_matrix:new i.UniformMatrix4f(r,n.u_matrix),u_color_ramp:new i.Uniform1i(r,n.u_color_ramp),u_center_direction:new i.Uniform3f(r,n.u_center_direction),u_radius:new i.Uniform1f(r,n.u_radius),u_opacity:new i.Uniform1f(r,n.u_opacity),u_temporal_offset:new i.Uniform1f(r,n.u_temporal_offset)}),skyboxCapture:(r,n)=>({u_matrix_3f:new i.UniformMatrix3f(r,n.u_matrix_3f),u_sun_direction:new i.Uniform3f(r,n.u_sun_direction),u_sun_intensity:new i.Uniform1f(r,n.u_sun_intensity),u_color_tint_r:new i.Uniform4f(r,n.u_color_tint_r),u_color_tint_m:new i.Uniform4f(r,n.u_color_tint_m),u_luminance:new i.Uniform1f(r,n.u_luminance)}),globeRaster:(r,n)=>({u_proj_matrix:new i.UniformMatrix4f(r,n.u_proj_matrix),u_globe_matrix:new i.UniformMatrix4f(r,n.u_globe_matrix),u_merc_matrix:new i.UniformMatrix4f(r,n.u_merc_matrix),u_zoom_transition:new i.Uniform1f(r,n.u_zoom_transition),u_merc_center:new i.Uniform2f(r,n.u_merc_center),u_image0:new i.Uniform1i(r,n.u_image0)}),globeAtmosphere:(r,n)=>({u_center:new i.Uniform2f(r,n.u_center),u_radius:new i.Uniform1f(r,n.u_radius),u_screen_size:new i.Uniform2f(r,n.u_screen_size),u_pixel_ratio:new i.Uniform1f(r,n.u_pixel_ratio),u_opacity:new i.Uniform1f(r,n.u_opacity),u_fadeout_range:new i.Uniform1f(r,n.u_fadeout_range),u_start_color:new i.Uniform3f(r,n.u_start_color),u_end_color:new i.Uniform3f(r,n.u_end_color)})};let tR;function t3(r,n,o,s,a,l,c){var u;const h=r.context,d=h.gl,p=r.useProgram("collisionBox"),f=[];let m=0,g=0;for(let y=0;y0){const T=i.create(),E=_;i.mul(T,v.placementInvProjMatrix,r.transform.glCoordMatrix),i.mul(T,T,v.placementViewportMatrix),f.push({circleArray:w,circleOffset:g,transform:E,invTransform:T}),m+=w.length/4,g=m}b&&(r.terrain&&r.terrain.setupElevationDraw($,p),p.draw(h,d.LINES,i.DepthMode.disabled,i.StencilMode.disabled,r.colorModeForRenderPass(),i.CullFaceMode.disabled,tb(_,r.transform,$),o.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,null,r.transform.zoom,null,b.collisionVertexBuffer,b.collisionVertexBufferExt))}if(!c||!f.length)return;const S=r.useProgram("collisionCircle"),I=new i.StructArrayLayout2f1f2i16;I.resize(4*m),I._trim();let C=0;for(const z of f)for(let A=0;A[0,0,0];g.clear();for(let b=0;b=0&&(x[w.associatedIconIndex]={shiftedAnchor:M,angle:F})}else eS(w.numGlyphs,g)}if(p){y.clear();const U=r.icon.placedSymbolArray;for(let V=0;V[0,0,0];e$(L,P.projMatrix,r,a,J,ee,v,d,en,P)}const eo=r.translatePosMatrix(P.projMatrix,D,l,c),es=_||a&&I||ei?tM:J,ea=r.translatePosMatrix(ee,D,l,c,!0),el=M&&0!==o.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1);let ec;const eu=x.createInversionMatrix(P.toUnwrapped());ec=M?L.iconsInText?tD(F.kind,V,b,v,r,eo,es,ea,N,X,j,z,eu,S):tP(F.kind,V,b,v,r,eo,es,ea,a,N,!0,j,z,eu,S):tk(F.kind,V,b,v,r,eo,es,ea,a,N,j,z,eu,S);const eh={program:U,buffers:B,uniformValues:ec,atlasTexture:G,atlasTextureIcon:W,atlasInterpolation:Z,atlasInterpolationIcon:q,isSDF:M,hasHalo:el,tile:D,labelPlaneMatrixInv:Q};if(w&&L.canOverlap){T=!0;const ed=B.segments.get();for(const ep of ed)A.push({segments:new i.SegmentVector([ep]),sortKey:ep.sortKey,state:eh})}else A.push({segments:B.segments,sortKey:0,state:eh})}for(const ef of(T&&A.sort((i,r)=>i.sortKey-r.sortKey),A)){const eg=ef.state;if(r.terrain&&r.terrain.setupElevationDraw(eg.tile,eg.program,{useDepthForOcclusion:!C,labelPlaneMatrixInv:eg.labelPlaneMatrixInv}),m.activeTexture.set(g.TEXTURE0),eg.atlasTexture.bind(eg.atlasInterpolation,g.CLAMP_TO_EDGE),eg.atlasTextureIcon&&(m.activeTexture.set(g.TEXTURE1),eg.atlasTextureIcon&&eg.atlasTextureIcon.bind(eg.atlasInterpolationIcon,g.CLAMP_TO_EDGE)),eg.isSDF){const ey=eg.uniformValues;eg.hasHalo&&(ey.u_is_halo=1,tU(eg.buffers,ef.segments,o,r,eg.program,E,p,f,ey)),ey.u_is_halo=0}tU(eg.buffers,ef.segments,o,r,eg.program,E,p,f,eg.uniformValues)}}function tU(r,n,o,s,a,l,c,u,h){const d=s.context;a.draw(d,d.gl.TRIANGLES,l,c,u,i.CullFaceMode.disabled,h,o.id,r.layoutVertexBuffer,r.indexBuffer,n,o.paint,s.transform.zoom,r.programConfigurations.get(o.id),r.dynamicLayoutVertexBuffer,r.opacityVertexBuffer)}function tV(r,n,o,s,a,l,c){const u=r.context.gl,h=o.paint.get("fill-pattern"),d=h&&h.constantOr(1),p=o.getCrossfadeParameters();let f,m,g,y,x;for(const $ of(c?(m=d&&!o.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",f=u.LINES):(m=d?"fillPattern":"fill",f=u.TRIANGLES),s)){const v=n.getTile($);if(d&&!v.patternsLoaded())continue;const _=v.getBucket(o);if(!_)continue;r.prepareDrawTile($);const b=_.programConfigurations.get(o.id),w=r.useProgram(m,b);d&&(r.context.activeTexture.set(u.TEXTURE0),v.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),b.updatePaintBuffers(p));const T=h.constantOr(null);if(T&&v.imageAtlas){const E=v.imageAtlas,S=E.patternPositions[T.to.toString()],I=E.patternPositions[T.from.toString()];S&&I&&b.setConstantPatternPositions(S,I)}const C=r.translatePosMatrix($.projMatrix,v,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor"));if(c){y=_.indexBuffer2,x=_.segments2;const z=r.terrain&&r.terrain.renderingToTexture?r.terrain.drapeBufferSize:[u.drawingBufferWidth,u.drawingBufferHeight,];g="fillOutlinePattern"===m&&d?t$(C,r,p,v,z):tx(C,z)}else y=_.indexBuffer,x=_.segments,g=d?ty(C,r,p,v):tg(C);r.prepareDrawProgram(r.context,w,$.toUnwrapped()),w.draw(r.context,f,a,r.stencilModeForClipping($),l,i.CullFaceMode.disabled,g,o.id,_.layoutVertexBuffer,y,x,o.paint,r.transform.zoom,b)}}function t6(r,n,o,s,a,l,c){const u=r.context,h=u.gl,d=o.paint.get("fill-extrusion-pattern"),p=d.constantOr(1),f=o.getCrossfadeParameters(),m=o.paint.get("fill-extrusion-opacity");for(const g of s){const y=n.getTile(g),x=y.getBucket(o);if(!x)continue;const $=x.programConfigurations.get(o.id),v=r.useProgram(p?"fillExtrusionPattern":"fillExtrusion",$);if(r.terrain){const _=r.terrain;if(!x.enableTerrain)continue;if(_.setupElevationDraw(y,v,{useMeterToDem:!0}),tj(u,n,g,x,o,_),!x.centroidVertexBuffer){const b=v.attributes.a_centroid_pos;void 0!==b&&h.vertexAttrib2f(b,0,0)}}p&&(r.context.activeTexture.set(h.TEXTURE0),y.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),$.updatePaintBuffers(f));const w=d.constantOr(null);if(w&&y.imageAtlas){const T=y.imageAtlas,E=T.patternPositions[w.to.toString()],S=T.patternPositions[w.from.toString()];E&&S&&$.setConstantPatternPositions(E,S)}const I=r.translatePosMatrix(g.projMatrix,y,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),C=o.paint.get("fill-extrusion-vertical-gradient"),z=p?t8(I,r,C,m,g,f,y):tm(I,r,C,m);r.prepareDrawProgram(u,v,g.toUnwrapped()),v.draw(u,u.gl.TRIANGLES,a,l,c,i.CullFaceMode.backCCW,z,o.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,o.paint,r.transform.zoom,$,r.terrain?x.centroidVertexBuffer:null)}}function tj(r,n,o,s,a,l){const c=[r=>{let n=r.canonical.x-1,o=r.wrap;return n<0&&(n=(1<{let n=r.canonical.x+1,o=r.wrap;return n===1<new i.OverscaledTileID(r.overscaledZ,r.wrap,r.canonical.z,r.canonical.x,(0===r.canonical.y?1<new i.OverscaledTileID(r.overscaledZ,r.wrap,r.canonical.z,r.canonical.x,r.canonical.y===(1<{const r=n.getSource().maxzoom,o=i=>{const r=n.getTileByID(i);if(r&&r.hasData())return r.getBucket(a)};let s,l,c;return(i.overscaledZ===i.canonical.z||i.overscaledZ>=r)&&(s=o(i.key)),i.overscaledZ>=r&&(l=o(i.calculateScaledKey(i.overscaledZ+1))),i.overscaledZ>r&&(c=o(i.calculateScaledKey(i.overscaledZ-1))),s||l||c},h=[0,0,0],d=(r,n)=>(h[0]=Math.min(r.min.y,n.min.y),h[1]=Math.max(r.max.y,n.max.y),h[2]=i.EXTENT-n.min.x>r.max.x?n.min.x-i.EXTENT:r.max.x,h),p=(r,n)=>(h[0]=Math.min(r.min.x,n.min.x),h[1]=Math.max(r.max.x,n.max.x),h[2]=i.EXTENT-n.min.y>r.max.y?n.min.y-i.EXTENT:r.max.y,h),f=[(i,r)=>d(i,r),(i,r)=>d(r,i),(i,r)=>p(i,r),(i,r)=>p(r,i),],m=new i.pointGeometry(0,0);let g,y,x;const $=(r,n,s,a,c)=>{const u=[[a?s:r,a?r:s,0],[a?s:n,a?n:s,0],],h=c<0?i.EXTENT+c:c,d=[a?h:(r+n)/2,a?(r+n)/2:h,0,];return 0===s&&c<0||0!==s&&c>0?l.getForTilePoints(x,[d],!0,y):u.push(d),l.getForTilePoints(o,u,!0,g),Math.max(u[0][2],u[1][2],d[2])/l.exaggeration()};for(let v=0;v<4;v++){const _=s.borders[v];if(0===_.length&&(s.borderDone[v]=!0),s.borderDone[v])continue;const b=x=c[v](o),w=u(b);if(!w||!w.enableTerrain||!(y=l.findDEMTileFor(b))||!y.dem)continue;if(!g){const T=l.findDEMTileFor(o);if(!T||!T.dem)return;g=T}const E=(v<2?1:5)-v,S=w.borders[E];let I=0;for(let C=0;C<_.length;C++){const z=s.featuresOnBorder[_[C]],A=z.borders[v];let k;for(;IA[0]+3);)w.borderDone[E]||w.encodeCentroid(void 0,k,!1),I++;if(k&&IA[1]-3)&&(D++,++I!==S.length);)k=w.featuresOnBorder[S[I]];if(k=w.featuresOnBorder[S[P]],z.intersectsCount()>1||k.intersectsCount()>1||1!==D){1!==D&&(I=P),s.encodeCentroid(void 0,z,!1),w.borderDone[E]||w.encodeCentroid(void 0,k,!1);continue}const L=f[v](z,k),B=v%2?i.EXTENT-1:0;m.x=$(L[0],Math.min(i.EXTENT-1,L[1]),B,v<2,L[2]),m.y=0,s.encodeCentroid(m,z,!1),w.borderDone[E]||w.encodeCentroid(m,k,!1)}else s.encodeCentroid(void 0,z,!1)}s.borderDone[v]=s.needsCentroidUpdate=!0,w.borderDone[E]||(w.borderDone[E]=w.needsCentroidUpdate=!0)}(s.needsCentroidUpdate||!s.centroidVertexBuffer&&0!==s.centroidVertexArray.length)&&s.uploadCentroid(r)}const tN=new i.Color(1,0,0,1),tG=new i.Color(0,1,0,1),tZ=new i.Color(0,0,1,1),t9=new i.Color(1,0,1,1),t7=new i.Color(0,1,1,1);function tq(i,r,n,o){tX(i,0,r+n/2,i.transform.width,n,o)}function t5(i,r,n,o){tX(i,r-n/2,0,n,i.transform.height,o)}function tX(r,n,o,s,a,l){const c=r.context,u=c.gl;u.enable(u.SCISSOR_TEST),u.scissor(n*i.exported.devicePixelRatio,o*i.exported.devicePixelRatio,s*i.exported.devicePixelRatio,a*i.exported.devicePixelRatio),c.clear({color:l}),u.disable(u.SCISSOR_TEST)}function tW(r,n,o){const s=r.context,a=s.gl,l=o.projMatrix,c=r.useProgram("debug"),u=n.getTileByID(o.key);r.terrain&&r.terrain.setupElevationDraw(u,c);const h=i.DepthMode.disabled,d=i.StencilMode.disabled,p=r.colorModeForRenderPass(),f="$debug";s.activeTexture.set(a.TEXTURE0),r.emptyTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),u._makeDebugTileBoundsBuffers(r.context,r.transform.projection);const m=u._tileDebugBuffer||r.debugBuffer,g=u._tileDebugIndexBuffer||r.debugIndexBuffer,y=u._tileDebugSegments||r.debugSegments;c.draw(s,a.LINE_STRIP,h,d,p,i.CullFaceMode.disabled,tw(l,i.Color.red),f,m,g,y);const x=u.latestRawTileData,$=Math.floor((x&&x.byteLength||0)/1024),v=n.getTile(o).tileSize,_=512/Math.min(v,512)*(o.overscaledZ/r.transform.zoom)*.5;let b=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(b+=` => ${o.overscaledZ}`),function(i,r){i.initDebugOverlayCanvas();const n=i.debugOverlayCanvas,o=i.context.gl,s=i.debugOverlayCanvas.getContext("2d");s.clearRect(0,0,n.width,n.height),s.shadowColor="white",s.shadowBlur=2,s.lineWidth=1.5,s.strokeStyle="white",s.textBaseline="top",s.font="bold 36px Open Sans, sans-serif",s.fillText(r,5,5),s.strokeText(r,5,5),i.debugOverlayTexture.update(n),i.debugOverlayTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE)}(r,`${b} ${$}kb`),c.draw(s,a.TRIANGLES,h,d,i.ColorMode.alphaBlended,i.CullFaceMode.disabled,tw(l,i.Color.transparent,_),f,r.debugBuffer,r.quadTriangleIndexBuffer,r.debugSegments)}const tH=i.createLayout([{name:"a_pos_3f",components:3,type:"Float32"},]),{members:tK}=tH;function tY(i,r,n,o){i.emplaceBack(r,n,o)}class tJ{constructor(r){this.vertexArray=new i.StructArrayLayout3f12,this.indices=new i.StructArrayLayout3ui6,tY(this.vertexArray,-1,-1,1),tY(this.vertexArray,1,-1,1),tY(this.vertexArray,-1,1,1),tY(this.vertexArray,1,1,1),tY(this.vertexArray,-1,-1,-1),tY(this.vertexArray,1,-1,-1),tY(this.vertexArray,-1,1,-1),tY(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=r.createVertexBuffer(this.vertexArray,tK),this.indexBuffer=r.createIndexBuffer(this.indices),this.segment=i.SegmentVector.simpleSegment(0,0,36,12)}}function tQ(r,n,o,s,a,l){var c,u,h,d,p;const f=r.gl,m=n.paint.get("sky-atmosphere-color"),g=n.paint.get("sky-atmosphere-halo-color"),y=n.paint.get("sky-atmosphere-sun-intensity"),x=(c=i.fromMat4([],s),u=a,h=y,d=m,p=g,{u_matrix_3f:c,u_sun_direction:u,u_sun_intensity:h,u_color_tint_r:[d.r,d.g,d.b,d.a],u_color_tint_m:[p.r,p.g,p.b,p.a],u_luminance:5e-5});f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_CUBE_MAP_POSITIVE_X+l,n.skyboxTexture,0),o.draw(r,f.TRIANGLES,i.DepthMode.disabled,i.StencilMode.disabled,i.ColorMode.unblended,i.CullFaceMode.frontCW,x,"skyboxCapture",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}const ie={symbol:function(r,n,o,s,a){if("translucent"!==r.renderPass)return;const l=i.StencilMode.disabled,c=r.colorModeForRenderPass();o.layout.get("text-variable-anchor")&&function(r,n,o,s,a,l,c){const u=n.transform,h="map"===a,d="map"===l,p=u.projection.createTileTransform(u,u.worldSize);for(const f of r){const m=s.getTile(f),g=m.getBucket(o);if(!g||g.projection!==u.projection.name||!g.text||!g.text.segments.get().length)continue;const y=i.evaluateSizeForZoom(g.textSizeData,u.zoom),x=n.transform.calculatePixelsToTileUnitsMatrix(m),$=em(f.projMatrix,m.tileID.canonical,d,h,n.transform,x),v="none"!==o.layout.get("icon-text-fit")&&g.hasIconData();if(y){const _=Math.pow(2,u.zoom-m.tileID.overscaledZ);tF(g,h,d,c,i.symbolSize,u,$,f,_,y,v,p)}}}(s,r,o,n,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),a),0!==o.paint.get("icon-opacity").constantOr(1)&&t4(r,n,o,s,!1,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),o.layout.get("icon-rotation-alignment"),o.layout.get("icon-pitch-alignment"),o.layout.get("icon-keep-upright"),l,c),0!==o.paint.get("text-opacity").constantOr(1)&&t4(r,n,o,s,!0,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),o.layout.get("text-keep-upright"),l,c),n.map.showCollisionBoxes&&(t3(r,n,o,s,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),t3(r,n,o,s,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1))},circle:function(r,n,o,s){if("translucent"!==r.renderPass)return;const a=o.paint.get("circle-opacity"),l=o.paint.get("circle-stroke-width"),c=o.paint.get("circle-stroke-opacity"),u=void 0!==o.layout.get("circle-sort-key").constantOr(1);if(0===a.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const h=r.context,d=h.gl,p=r.depthModeForSublayer(0,i.DepthMode.ReadOnly),f=i.StencilMode.disabled,m=r.colorModeForRenderPass(),g=[];for(let y=0;yi.sortKey-r.sortKey);const S={useDepthForOcclusion:"globe"!==r.transform.projection.name};for(const I of g){const{programConfiguration:C,program:z,layoutVertexBuffer:A,indexBuffer:k,uniformValues:P,tile:D}=I.state,L=I.segments;r.terrain&&r.terrain.setupElevationDraw(D,z,S),r.prepareDrawProgram(h,z,D.tileID.toUnwrapped()),z.draw(h,d.TRIANGLES,p,f,m,i.CullFaceMode.disabled,P,o.id,A,k,L,o.paint,r.transform.zoom,C)}},heatmap:function(r,n,o,s){if(0!==o.paint.get("heatmap-opacity")){if("offscreen"===r.renderPass){const a=r.context,l=a.gl,c=i.StencilMode.disabled,u=new i.ColorMode([l.ONE,l.ONE],i.Color.transparent,[!0,!0,!0,!0]);(function(i,r,n){const o=i.gl;i.activeTexture.set(o.TEXTURE1),i.viewport.set([0,0,r.width/4,r.height/4,]);let s=n.heatmapFbo;if(s)o.bindTexture(o.TEXTURE_2D,s.colorAttachment.get()),i.bindFramebuffer.set(s.framebuffer);else{const a=o.createTexture();o.bindTexture(o.TEXTURE_2D,a),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.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR),s=n.heatmapFbo=i.createFramebuffer(r.width/4,r.height/4,!1),function(i,r,n,o){const s=i.gl;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,r.width/4,r.height/4,0,s.RGBA,i.extRenderToTextureHalfFloat?i.extTextureHalfFloat.HALF_FLOAT_OES:s.UNSIGNED_BYTE,null),o.colorAttachment.set(n)}(i,r,a,s)}})(a,r,o),a.clear({color:i.Color.transparent});for(let h=0;h{const r=[];tC(i)&&r.push("RENDER_LINE_DASH"),i.paint.get("line-gradient")&&r.push("RENDER_LINE_GRADIENT");const n=i.paint.get("line-pattern").constantOr(1),o=1!==i.paint.get("line-opacity").constantOr(1);return!n&&o&&r.push("RENDER_LINE_ALPHA_DISCARD"),r})(o);let b=_.includes("RENDER_LINE_ALPHA_DISCARD");for(const w of(r.terrain&&r.terrain.clipOrMaskOverlapStencilType()&&(b=!1),s)){const T=n.getTile(w);if(m&&!T.patternsLoaded())continue;const E=T.getBucket(o);if(!E)continue;r.prepareDrawTile(w);const S=E.programConfigurations.get(o.id),I=r.useProgram(x,S,_),C=f.constantOr(null);if(C&&T.imageAtlas){const z=T.imageAtlas,A=z.patternPositions[C.to.toString()],k=z.patternPositions[C.from.toString()];A&&k&&S.setConstantPatternPositions(A,k)}const P=h.constantOr(null),D=p.constantOr(null);if(!m&&P&&D&&T.lineAtlas){const L=T.lineAtlas,B=L.getDash(P.to,D),R=L.getDash(P.from,D);B&&R&&S.setConstantPatternPositions(B,R)}const M=r.terrain?w.projMatrix:null,F=m?tE(r,T,o,y,M):tT(r,T,o,y,M,E.lineClipsArray.length);if(g){const O=E.gradients[o.id];let U=O.texture;if(o.gradientVersion!==O.version){let V=256;if(o.stepInterpolant){const j=n.getSource().maxzoom,N=w.canonical.z===j?Math.ceil(1<{I.draw($,v.TRIANGLES,c,n,u,i.CullFaceMode.disabled,F,o.id,E.layoutVertexBuffer,E.indexBuffer,E.segments,o.paint,r.transform.zoom,S,E.layoutVertexBuffer2)};if(b){const Z=r.stencilModeForClipping(w).ref;0===Z&&r.terrain&&$.clear({stencil:0});const q={func:v.EQUAL,mask:255};F.u_alpha_discard_threshold=.8,G(new i.StencilMode(q,Z,255,v.KEEP,v.KEEP,v.INVERT)),F.u_alpha_discard_threshold=0,G(new i.StencilMode(q,Z,255,v.KEEP,v.KEEP,v.KEEP))}else G(r.stencilModeForClipping(w))}b&&(r.resetStencilClippingMasks(),r.terrain&&$.clear({stencil:0}))},fill:function(r,n,o,s){const a=o.paint.get("fill-color"),l=o.paint.get("fill-opacity");if(0===l.constantOr(1))return;const c=r.colorModeForRenderPass(),u=o.paint.get("fill-pattern"),h=r.opaquePassEnabledForLayer()&&!u.constantOr(1)&&1===a.constantOr(i.Color.transparent).a&&1===l.constantOr(0)?"opaque":"translucent";if(r.renderPass===h){const d=r.depthModeForSublayer(1,"opaque"===r.renderPass?i.DepthMode.ReadWrite:i.DepthMode.ReadOnly);tV(r,n,o,s,d,c,!1)}if("translucent"===r.renderPass&&o.paint.get("fill-antialias")){const p=r.depthModeForSublayer(o.getPaintProperty("fill-outline-color")?2:0,i.DepthMode.ReadOnly);tV(r,n,o,s,p,c,!0)}},"fill-extrusion":function(r,n,o,s){const a=o.paint.get("fill-extrusion-opacity");if(0!==a&&"translucent"===r.renderPass){const l=new i.DepthMode(r.context.gl.LEQUAL,i.DepthMode.ReadWrite,r.depthRangeFor3D);if(1!==a||o.paint.get("fill-extrusion-pattern").constantOr(1))t6(r,n,o,s,l,i.StencilMode.disabled,i.ColorMode.disabled),t6(r,n,o,s,l,r.stencilModeFor3D(),r.colorModeForRenderPass()),r.resetStencilClippingMasks();else{const c=r.colorModeForRenderPass();t6(r,n,o,s,l,i.StencilMode.disabled,c)}}},hillshade:function(r,n,o,s){if("offscreen"!==r.renderPass&&"translucent"!==r.renderPass)return;const a=r.context,l=r.depthModeForSublayer(0,i.DepthMode.ReadOnly),c=r.colorModeForRenderPass(),u=r.terrain&&r.terrain.renderingToTexture,[h,d]="translucent"!==r.renderPass||u?[{},s]:r.stencilConfigForOverlap(s);for(const p of d){const f=n.getTile(p);if(f.needsHillshadePrepare&&"offscreen"===r.renderPass)eJ(r,f,o,l,i.StencilMode.disabled,c);else if("translucent"===r.renderPass){const m=u&&r.terrain?r.terrain.stencilModeForRTTOverlap(p):h[p.overscaledZ];eK(r,p,f,o,l,m,c)}}a.viewport.set([0,0,r.width,r.height]),r.resetStencilClippingMasks()},raster:function(r,n,o,s,a,l){if("translucent"!==r.renderPass||0===o.paint.get("raster-opacity")||!s.length)return;const c=r.context,u=c.gl,h=n.getSource(),d=r.useProgram("raster"),p=r.colorModeForRenderPass(),f=r.terrain&&r.terrain.renderingToTexture,[m,g]=h instanceof G||f?[{},s]:r.stencilConfigForOverlap(s),y=g[g.length-1].overscaledZ,x=!r.options.moving;for(const $ of g){const v=f?i.DepthMode.disabled:r.depthModeForSublayer($.overscaledZ-y,1===o.paint.get("raster-opacity")?i.DepthMode.ReadWrite:i.DepthMode.ReadOnly,u.LESS),_=$.toUnwrapped(),b=n.getTile($);if(f&&(!b||!b.hasData()))continue;const w=f?$.projMatrix:r.transform.calculateProjMatrix(_,x),T=r.terrain&&f?r.terrain.stencilModeForRTTOverlap($):m[$.overscaledZ],E=l?0:o.paint.get("raster-fade-duration");b.registerFadeDuration(E);const S=n.findLoadedParent($,0),I=ta(b,S,n,r.transform,E);let C,z;r.terrain&&r.terrain.prepareDrawTile($);const A="nearest"===o.paint.get("raster-resampling")?u.NEAREST:u.LINEAR;c.activeTexture.set(u.TEXTURE0),b.texture.bind(A,u.CLAMP_TO_EDGE),c.activeTexture.set(u.TEXTURE1),S?(S.texture.bind(A,u.CLAMP_TO_EDGE),C=Math.pow(2,S.tileID.overscaledZ-b.tileID.overscaledZ),z=[b.tileID.canonical.x*C%1,b.tileID.canonical.y*C%1,]):b.texture.bind(A,u.CLAMP_TO_EDGE);const k=tz(w,z||[0,0],C||1,I,o,h instanceof G?h.perspectiveTransform:[0,0]);if(r.prepareDrawProgram(c,d,_),h instanceof G)d.draw(c,u.TRIANGLES,v,i.StencilMode.disabled,p,i.CullFaceMode.disabled,k,o.id,h.boundsBuffer,r.quadTriangleIndexBuffer,h.boundsSegments);else{const{tileBoundsBuffer:P,tileBoundsIndexBuffer:D,tileBoundsSegments:L}=r.getTileBoundsBuffers(b);d.draw(c,u.TRIANGLES,v,T,p,i.CullFaceMode.disabled,k,o.id,P,D,L)}}r.resetStencilClippingMasks()},background:function(r,n,o,s){const a=o.paint.get("background-color"),l=o.paint.get("background-opacity");if(0===l)return;const c=r.context,u=c.gl,h=r.transform,d=h.tileSize,p=o.paint.get("background-pattern");if(r.isPatternMissing(p))return;const f=!p&&1===a.a&&1===l&&r.opaquePassEnabledForLayer()?"opaque":"translucent";if(r.renderPass!==f)return;const m=i.StencilMode.disabled,g=r.depthModeForSublayer(0,"opaque"===f?i.DepthMode.ReadWrite:i.DepthMode.ReadOnly),y=r.colorModeForRenderPass(),x=r.useProgram(p?"backgroundPattern":"background");let $,v=s;v||(v=Object.values($=r.getBackgroundTiles()).map(i=>i.tileID)),p&&(c.activeTexture.set(u.TEXTURE0),r.imageManager.bind(r.context));const _=o.getCrossfadeParameters();for(const b of v){const w=b.toUnwrapped(),T=s?b.projMatrix:r.transform.calculateProjMatrix(w);r.prepareDrawTile(b);const E=n?n.getTile(b):$?$[b.key]:new i.Tile(b,d,h.zoom,r),S=p?t1(T,l,r,p,{tileID:b,tileSize:d},_):tL(T,l,a);r.prepareDrawProgram(c,x,w);const{tileBoundsBuffer:I,tileBoundsIndexBuffer:C,tileBoundsSegments:z}=r.getTileBoundsBuffers(E);x.draw(c,u.TRIANGLES,g,m,y,i.CullFaceMode.disabled,S,o.id,I,C,z)}},sky:function(r,n,o){const s=r.transform,a="mercator"===s.projection.name||"globe"===s.projection.name?1:i.smoothstep(7,8,s.zoom),l=o.paint.get("sky-opacity")*a;if(0===l)return;const c=r.context,u=o.paint.get("sky-type"),h=new i.DepthMode(c.gl.LEQUAL,i.DepthMode.ReadOnly,[0,1]),d=r.frameCounter/1e3%1;"atmosphere"===u?"offscreen"===r.renderPass?o.needsSkyboxCapture(r)&&(function(r,n,o,s){const a=r.context,l=a.gl;let c=n.skyboxFbo;if(!c){c=n.skyboxFbo=a.createFramebuffer(32,32,!1),n.skyboxGeometry=new tJ(a),n.skyboxTexture=a.gl.createTexture(),l.bindTexture(l.TEXTURE_CUBE_MAP,n.skyboxTexture),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MAG_FILTER,l.LINEAR);for(let u=0;u<6;++u)l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,l.RGBA,32,32,0,l.RGBA,l.UNSIGNED_BYTE,null)}a.bindFramebuffer.set(c.framebuffer),a.viewport.set([0,0,32,32,]);const h=n.getCenter(r,!0),d=r.useProgram("skyboxCapture"),p=new Float64Array(16);i.identity(p),i.rotateY(p,p,-(.5*Math.PI)),tQ(a,n,d,p,h,0),i.identity(p),i.rotateY(p,p,.5*Math.PI),tQ(a,n,d,p,h,1),i.identity(p),i.rotateX(p,p,-(.5*Math.PI)),tQ(a,n,d,p,h,2),i.identity(p),i.rotateX(p,p,.5*Math.PI),tQ(a,n,d,p,h,3),i.identity(p),tQ(a,n,d,p,h,4),i.identity(p),i.rotateY(p,p,Math.PI),tQ(a,n,d,p,h,5),a.viewport.set([0,0,r.width,r.height,])}(r,o),o.markSkyboxValid(r)):"sky"===r.renderPass&&function(r,n,o,s,a){var l,c,u;const h=r.context,d=h.gl,p=r.transform,f=r.useProgram("skybox");h.activeTexture.set(d.TEXTURE0),d.bindTexture(d.TEXTURE_CUBE_MAP,n.skyboxTexture);const m=(l=p.skyboxMatrix,c=n.getCenter(r,!1),u=s,{u_matrix:l,u_sun_direction:c,u_cubemap:0,u_opacity:u,u_temporal_offset:a});r.prepareDrawProgram(h,f),f.draw(h,d.TRIANGLES,o,i.StencilMode.disabled,r.colorModeForRenderPass(),i.CullFaceMode.backCW,m,"skybox",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(r,o,h,l,d):"gradient"===u&&"sky"===r.renderPass&&function(r,n,o,s,a){var l,c,u,h,d;const p=r.context,f=p.gl,m=r.transform,g=r.useProgram("skyboxGradient");n.skyboxGeometry||(n.skyboxGeometry=new tJ(p)),p.activeTexture.set(f.TEXTURE0);let y=n.colorRampTexture;y||(y=n.colorRampTexture=new i.Texture(p,n.colorRamp,f.RGBA)),y.bind(f.LINEAR,f.CLAMP_TO_EDGE);const x=(l=m.skyboxMatrix,c=n.getCenter(r,!1),u=n.paint.get("sky-gradient-radius"),h=s,d=a,{u_matrix:l,u_color_ramp:0,u_center_direction:c,u_radius:i.degToRad(u),u_opacity:h,u_temporal_offset:d});r.prepareDrawProgram(p,g),g.draw(p,f.TRIANGLES,o,i.StencilMode.disabled,r.colorModeForRenderPass(),i.CullFaceMode.backCW,x,"skyboxGradient",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(r,o,h,l,d)},debug:function(i,r,n){for(let o=0;or.getOpacity(this.transform.pitch)||.03>r.properties.get("horizon-blend"))return void(this.transform.fogCullDistSq=null);const[n,o]=r.getFovAdjustedRange(this.transform._fov);if(n>o)return void(this.transform.fogCullDistSq=null);const s=n+.78*(o-n);this.transform.fogCullDistSq=s*s}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(r,n){if(this.width=r*i.exported.devicePixelRatio,this.height=n*i.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height,]),this.style)for(const o of this.style.order)this.style._layers[o].resize()}setup(){const r=this.context,n=new i.StructArrayLayout2i4;n.emplaceBack(0,0),n.emplaceBack(i.EXTENT,0),n.emplaceBack(0,i.EXTENT),n.emplaceBack(i.EXTENT,i.EXTENT),this.tileExtentBuffer=r.createVertexBuffer(n,i.posAttributes.members),this.tileExtentSegments=i.SegmentVector.simpleSegment(0,0,4,2);const o=new i.StructArrayLayout2i4;o.emplaceBack(0,0),o.emplaceBack(i.EXTENT,0),o.emplaceBack(0,i.EXTENT),o.emplaceBack(i.EXTENT,i.EXTENT),this.debugBuffer=r.createVertexBuffer(o,i.posAttributes.members),this.debugSegments=i.SegmentVector.simpleSegment(0,0,4,5);const s=new i.StructArrayLayout2i4;s.emplaceBack(-1,-1),s.emplaceBack(1,-1),s.emplaceBack(-1,1),s.emplaceBack(1,1),this.viewportBuffer=r.createVertexBuffer(s,i.posAttributes.members),this.viewportSegments=i.SegmentVector.simpleSegment(0,0,4,2);const a=new i.StructArrayLayout4i8;a.emplaceBack(0,0,0,0),a.emplaceBack(i.EXTENT,0,i.EXTENT,0),a.emplaceBack(0,i.EXTENT,0,i.EXTENT),a.emplaceBack(i.EXTENT,i.EXTENT,i.EXTENT,i.EXTENT),this.mercatorBoundsBuffer=r.createVertexBuffer(a,i.boundsAttributes.members),this.mercatorBoundsSegments=i.SegmentVector.simpleSegment(0,0,4,2);const l=new i.StructArrayLayout3ui6;l.emplaceBack(0,1,2),l.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=r.createIndexBuffer(l);const c=new i.StructArrayLayout1ui2;for(const u of[0,1,3,2,0])c.emplaceBack(u);this.debugIndexBuffer=r.createIndexBuffer(c),this.emptyTexture=new i.Texture(r,{width:1,height:1,data:new Uint8Array([0,0,0,0])},r.gl.RGBA),this.identityMat=i.create();const h=this.context.gl;this.stencilClearMode=new i.StencilMode({func:h.ALWAYS,mask:0},0,255,h.ZERO,h.ZERO,h.ZERO),this.loadTimeStamps.push(i.window.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(i){return i._makeTileBoundsBuffers(this.context,this.transform.projection),i._tileBoundsBuffer?{tileBoundsBuffer:i._tileBoundsBuffer,tileBoundsIndexBuffer:i._tileBoundsIndexBuffer,tileBoundsSegments:i._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const r=this.context,n=r.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(r,n.TRIANGLES,i.DepthMode.disabled,this.stencilClearMode,i.ColorMode.disabled,i.CullFaceMode.disabled,ts(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(r,n,o){if(!n||this.currentStencilSource===n.id||!r.isTileClipped()||!o||0===o.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let s=!1;for(const a of o)if(void 0===this._tileClippingMaskIDs[a.key]){s=!0;break}if(!s)return}this.currentStencilSource=n.id;const l=this.context,c=l.gl;this.nextStencilID+o.length>256&&this.clearStencil(),l.setColorMode(i.ColorMode.disabled),l.setDepthMode(i.DepthMode.disabled);const u=this.useProgram("clippingMask");for(const h of(this._tileClippingMaskIDs={},o)){const d=n.getTile(h),p=this._tileClippingMaskIDs[h.key]=this.nextStencilID++,{tileBoundsBuffer:f,tileBoundsIndexBuffer:m,tileBoundsSegments:g}=this.getTileBoundsBuffers(d);u.draw(l,c.TRIANGLES,i.DepthMode.disabled,new i.StencilMode({func:c.ALWAYS,mask:0},p,255,c.KEEP,c.KEEP,c.REPLACE),i.ColorMode.disabled,i.CullFaceMode.disabled,ts(h.projMatrix),"$clipping",f,m,g)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const r=this.nextStencilID++,n=this.context.gl;return new i.StencilMode({func:n.NOTEQUAL,mask:255},r,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(r){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(r);const n=this.context.gl;return new i.StencilMode({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[r.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(r){const n=this.context.gl,o=r.sort((i,r)=>r.overscaledZ-i.overscaledZ),s=o[o.length-1].overscaledZ,a=o[0].overscaledZ-s+1;if(a>1){this.currentStencilSource=void 0,this.nextStencilID+a>256&&this.clearStencil();const l={};for(let c=0;c=0;this.currentLayer--){const v=this.style._layers[o[this.currentLayer]],_=r._getLayerSourceCache(v);if(v.isSky())continue;const b=_?u[_.id]:void 0;this._renderTileClippingMasks(v,_,b),this.renderLayer(this,_,v,b)}if(this.renderPass="sky",(i.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const n=r._getLayerSourceCache(i);n&&!i.isHidden(this.transform.zoom)&&(!C||C.getSource().maxzoom0?r.pop():null}isPatternMissing(i){if(!i)return!1;if(!i.from||!i.to)return!0;const r=this.imageManager.getPattern(i.from.toString()),n=this.imageManager.getPattern(i.to.toString());return!r||!n}currentGlobalDefines(){const i=this.terrain&&this.terrain.renderingToTexture,r=this.style&&this.style.fog,n=[];return this.terrain&&!this.terrain.renderingToTexture&&n.push("TERRAIN"),r&&!i&&0!==r.getOpacity(this.transform.pitch)&&n.push("FOG"),i&&n.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&n.push("OVERDRAW_INSPECTOR"),n}useProgram(i,r,n){this.cache=this.cache||{};const o=this.currentGlobalDefines().concat(n||[]),s=tp.cacheKey(i,o,r);return this.cache[s]||(this.cache[s]=new tp(this.context,i,eX[i],r,tB[i],o)),this.cache[s]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const i=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height,]),this.context.blendEquation.set(i.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=i.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new i.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}prepareDrawTile(i){this.terrain&&this.terrain.prepareDrawTile(i)}prepareDrawProgram(i,r,n){if(this.terrain&&this.terrain.renderingToTexture)return;const o=this.style.fog;if(o){const s=o.getOpacity(this.transform.pitch);0!==s&&r.setFogUniformValues(i,((i,r,n,o)=>{const s=r.properties.get("color"),a=i.frameCounter/1e3%1,l=[s.r/s.a,s.g/s.a,s.b/s.a,o,];return{u_fog_matrix:n?i.transform.calculateFogTileMatrix(n):i.identityMat,u_fog_range:r.getFovAdjustedRange(i.transform._fov),u_fog_color:l,u_fog_horizon_blend:r.properties.get("horizon-blend"),u_fog_temporal_offset:a}})(this,o,n,s))}}setTileLoadedFlag(i){this.tileLoaded=i}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const i=this.context.gl,r=i.createTexture();return i.bindTexture(i.TEXTURE_2D,r),i.copyTexImage2D(i.TEXTURE_2D,0,i.RGBA,0,0,i.drawingBufferWidth,i.drawingBufferHeight,0),r}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const i=this.style&&this.style.fog;return!!i&&0!==i.getOpacity(this.transform.pitch)}getBackgroundTiles(){const r=this._backgroundTiles,n=this._backgroundTiles={},o=this.transform.coveringTiles({tileSize:512});for(const s of o)n[s.key]=r[s.key]||new i.Tile(s,512,this.transform.tileZoom,this);return n}clearBackgroundTiles(){this._backgroundTiles={}}}class ii{constructor(i=0,r=0,n=0,o=0){if(isNaN(i)||i<0||isNaN(r)||r<0||isNaN(n)||n<0||isNaN(o)||o<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=i,this.bottom=r,this.left=n,this.right=o}interpolate(r,n,o){return null!=n.top&&null!=r.top&&(this.top=i.number(r.top,n.top,o)),null!=n.bottom&&null!=r.bottom&&(this.bottom=i.number(r.bottom,n.bottom,o)),null!=n.left&&null!=r.left&&(this.left=i.number(r.left,n.left,o)),null!=n.right&&null!=r.right&&(this.right=i.number(r.right,n.right,o)),this}getCenter(r,n){const o=i.clamp((this.left+r-this.right)/2,0,r),s=i.clamp((this.top+n-this.bottom)/2,0,n);return new i.pointGeometry(o,s)}equals(i){return this.top===i.top&&this.bottom===i.bottom&&this.left===i.left&&this.right===i.right}clone(){return new ii(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function ir(r,n){const o=i.getColumn(r,3);i.fromQuat(r,n),i.setColumn(r,3,o)}function io(r,n){i.setColumn(r,3,[n[0],n[1],n[2],1])}function is(r,n){const o=i.identity$1([]);return i.rotateZ$1(o,o,-n),i.rotateX$1(o,o,-r),o}function ia(r,n){const o=[r[0],r[1],0],s=[n[0],n[1],0];if(i.length(o)>=1e-15){const a=i.normalize([],o);i.scale$2(s,a,i.dot(s,a)),n[0]=s[0],n[1]=s[1]}const l=i.cross([],n,r);if(1e-15>i.len(l))return null;const c=Math.atan2(-l[1],l[0]);return is(Math.atan2(Math.sqrt(r[0]*r[0]+r[1]*r[1]),-r[2]),c)}class il{constructor(i,r){this.position=i,this.orientation=r}get position(){return this._position}set position(r){this._position=this._renderWorldCopies?function(r){if(!r)return;const n=Array.isArray(r)?new i.MercatorCoordinate(r[0],r[1],r[2]):r;return n.x=i.wrap(n.x,0,1),n}(r):r}lookAtPoint(r,n){if(this.orientation=null,!this.position)return;const o=this._elevation?this._elevation.getAtPointOrZero(i.MercatorCoordinate.fromLngLat(r)):0,s=this.position,a=i.MercatorCoordinate.fromLngLat(r,o),l=[a.x-s.x,a.y-s.y,a.z-s.z];n||(n=[0,0,1]),n[2]=Math.abs(n[2]),this.orientation=ia(l,n)}setPitchBearing(r,n){this.orientation=is(i.degToRad(r),i.degToRad(-n))}}class ic{constructor(r,n){this._transform=i.identity([]),this._orientation=i.identity$1([]),n&&(this._orientation=n,ir(this._transform,this._orientation)),r&&io(this._transform,r)}get mercatorPosition(){const r=this.position;return new i.MercatorCoordinate(r[0],r[1],r[2])}get position(){const r=i.getColumn(this._transform,3);return[r[0],r[1],r[2]]}set position(i){io(this._transform,i)}get orientation(){return this._orientation}set orientation(i){this._orientation=i,ir(this._transform,this._orientation)}getPitchBearing(){const i=this.forward(),r=this.right();return{bearing:Math.atan2(-r[1],r[0]),pitch:Math.atan2(Math.sqrt(i[0]*i[0]+i[1]*i[1]),-i[2])}}setPitchBearing(i,r){this._orientation=is(i,r),ir(this._transform,this._orientation)}forward(){const r=i.getColumn(this._transform,2);return[-r[0],-r[1],-r[2]]}up(){const r=i.getColumn(this._transform,1);return[-r[0],-r[1],-r[2]]}right(){const r=i.getColumn(this._transform,0);return[r[0],r[1],r[2]]}getCameraToWorld(r,n){const o=new Float64Array(16);return i.invert(o,this.getWorldToCamera(r,n)),o}getWorldToCameraPosition(r,n,o){const s=this.position;i.scale$2(s,s,-r);const a=new Float64Array(16);return i.fromScaling(a,[o,o,o]),i.translate(a,a,s),a[10]*=n,a}getWorldToCamera(r,n){const o=new Float64Array(16),s=new Float64Array(4),a=this.position;return i.conjugate(s,this._orientation),i.scale$2(a,a,-r),i.fromQuat(o,s),i.translate(o,o,a),o[1]*=-1,o[5]*=-1,o[9]*=-1,o[13]*=-1,o[8]*=n,o[9]*=n,o[10]*=n,o[11]*=n,o}getCameraToClipPerspective(r,n,o,s){const a=new Float64Array(16);return i.perspective(a,r,n,o,s),a}getDistanceToElevation(r){const n=0===r?0:i.mercatorZfromAltitude(r,this.position[1]),o=this.forward();return(n-this.position[2])/o[2]}clone(){return new ic([...this.position],[...this.orientation])}}function iu(r,n){const o=id(r),s=function(r,n,o,s,a){const l=new i.LngLat(o.lng-180*ip,o.lat),c=new i.LngLat(o.lng+180*ip,o.lat),u=r.project(l.lng,l.lat),h=r.project(c.lng,c.lat),d=-Math.atan2(h.y-u.y,h.x-u.x),p=i.MercatorCoordinate.fromLngLat(o);p.y=i.clamp(p.y,-.999975,.999975);const f=p.toLngLat(),m=r.project(f.lng,f.lat),g=i.MercatorCoordinate.fromLngLat(f);g.x+=ip;const y=g.toLngLat(),x=r.project(y.lng,y.lat),$=i8(x.x-m.x,x.y-m.y,d),v=i.MercatorCoordinate.fromLngLat(f);v.y+=ip;const _=v.toLngLat(),b=r.project(_.lng,_.lat),w=i8(b.x-m.x,b.y-m.y,d),T=Math.abs($.x)/Math.abs(w.y),E=i.identity([]);i.rotateZ(E,E,-d*(1-(a?0:s)));const S=i.identity([]);return i.scale(S,S,[1,1-(1-T)*s,1]),S[4]=-w.x/w.y*s,i.rotateZ(S,S,d),i.multiply$1(S,E,S),S}(r.projection,0,r.center,o,n),a=ih(r);return i.scale(s,s,[a,a,1]),s}function ih(r){const n=r.projection,o=id(r),s=im(n,r.center),a=im(n,i.LngLat.convert(n.center));return Math.pow(2,s*o+(1-o)*a)}function id(r){const n=r.projection.range;if(!n)return 0;const o=Math.max(r.width,r.height),s=Math.log(o/1024)/Math.LN2;return i.smoothstep(n[0]+s,n[1]+s,r.zoom)}const ip=1/4e4;function im(r,n){const o=i.clamp(n.lat,-i.MAX_MERCATOR_LATITUDE,i.MAX_MERCATOR_LATITUDE),s=new i.LngLat(n.lng-180*ip,o),a=new i.LngLat(n.lng+180*ip,o),l=r.project(s.lng,o),c=r.project(a.lng,o),u=i.MercatorCoordinate.fromLngLat(s),h=i.MercatorCoordinate.fromLngLat(a),d=c.x-l.x,p=c.y-l.y,f=h.x-u.x,m=h.y-u.y,g=Math.sqrt((f*f+m*m)/(d*d+p*p));return Math.log(g)/Math.LN2}function i8(i,r,n){const o=Math.cos(n),s=Math.sin(n);return{x:i*o-r*s,y:i*s+r*o}}class ig{constructor(r,n,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===a||a,this._minZoom=r||0,this._maxZoom=n||22,this._minPitch=null==o?0:o,this._maxPitch=null==s?60:s,this.setProjection(),this.setMaxBounds(),this.width=0,this.height=0,this._center=new i.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new ii,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new ic,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){const i=new ig(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return i.setProjection(this.getProjection()),i._elevation=this._elevation,i._centerAltitude=this._centerAltitude,i.tileSize=this.tileSize,i.setMaxBounds(this.getMaxBounds()),i.width=this.width,i.height=this.height,i.cameraElevationReference=this.cameraElevationReference,i._center=this._center,i._setZoom(this.zoom),i._cameraZoom=this._cameraZoom,i.angle=this.angle,i._fov=this._fov,i._pitch=this._pitch,i._nearZ=this._nearZ,i._farZ=this._farZ,i._averageElevation=this._averageElevation,i._unmodified=this._unmodified,i._edgeInsets=this._edgeInsets.clone(),i._camera=this._camera.clone(),i._calcMatrices(),i.freezeTileCoverage=this.freezeTileCoverage,i}get elevation(){return this._elevation}set elevation(i){this._elevation!==i&&(this._elevation=i,i?this._updateCenterElevation()&&this._updateCameraOnTerrain():(this._cameraZoom=null,this._centerAltitude=0),this._calcMatrices())}updateElevation(i){this._terrainEnabled()&&null==this._cameraZoom&&this._updateCenterElevation()&&this._updateCameraOnTerrain(),i&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return i.pick(this.projection,["name","center","parallels",])}setProjection(r){null==r&&(r={name:"mercator"}),this.projectionOptions=r;const n=this.projection?this.getProjection():void 0;return this.projection=i.getProjection(r),!a(n,this.getProjection())&&(this._calcMatrices(),!0)}get minZoom(){return this._minZoom}set minZoom(i){this._minZoom!==i&&(this._minZoom=i,this.zoom=Math.max(this.zoom,i))}get maxZoom(){return this._maxZoom}set maxZoom(i){this._maxZoom!==i&&(this._maxZoom=i,this.zoom=Math.min(this.zoom,i))}get minPitch(){return this._minPitch}set minPitch(i){this._minPitch!==i&&(this._minPitch=i,this.pitch=Math.max(this.pitch,i))}get maxPitch(){return this._maxPitch}set maxPitch(i){this._maxPitch!==i&&(this._maxPitch=i,this.pitch=Math.min(this.pitch,i))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(i){void 0===i?i=!0:null===i&&(i=!1),this._renderWorldCopies=i}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const i=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(i))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new i.pointGeometry(this.width,this.height)}get bearing(){return i.wrap(this.rotation,-180,180)}set bearing(i){this.rotation=i}get rotation(){return-this.angle/Math.PI*180}set rotation(r){var n,o,s,a,l,c,u,h,d,p;const f=-r*Math.PI/180;this.angle!==f&&(this._unmodified=!1,this.angle=f,this._calcMatrices(),this.rotationMatrix=(n=new i.ARRAY_TYPE(4),i.ARRAY_TYPE!=Float32Array&&(n[1]=0,n[2]=0),n[0]=1,n[3]=1,n),o=this.rotationMatrix,s=this.rotationMatrix,a=this.angle,l=s[0],c=s[1],u=s[2],h=s[3],d=Math.sin(a),p=Math.cos(a),o[0]=l*p+u*d,o[1]=c*p+h*d,o[2]=-(l*d)+u*p,o[3]=-(c*d)+h*p)}get pitch(){return this._pitch/Math.PI*180}set pitch(r){const n=i.clamp(r,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(i){i=Math.max(.01,Math.min(60,i)),this._fov!==i&&(this._unmodified=!1,this._fov=i/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(i){this._averageElevation=i,this._calcFogMatrices()}get zoom(){return this._zoom}set zoom(i){const r=Math.min(Math.max(i,this.minZoom),this.maxZoom);this._zoom!==r&&(this._unmodified=!1,this._setZoom(r),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._constrain(),this._calcMatrices())}_setZoom(i){this._zoom=i,this.scale=this.zoomScale(i),this.tileZoom=Math.floor(i),this.zoomFraction=i-this.tileZoom}_updateCenterElevation(){if(!this._elevation)return!1;const i=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center),-1);return -1===i?(this._cameraZoom=null,!1):(this._centerAltitude=i,!0)}_updateCameraOnTerrain(){this._cameraZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize)}sampleAverageElevation(){if(!this._elevation)return 0;const r=this._elevation,n=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8],],o=this.horizonLineFromTop();let s=0,a=0;for(let l=0;lr.maxzoom&&(n=r.maxzoom);const l=this.locationCoordinate(this.center),c=1<{const n=1/4e4,o=new i.MercatorCoordinate(r.x+n,r.y,r.z),s=new i.MercatorCoordinate(r.x,r.y+n,r.z),a=r.toLngLat(),l=o.toLngLat(),c=s.toLngLat(),u=this.locationCoordinate(a),h=this.locationCoordinate(l),d=this.locationCoordinate(c),p=Math.hypot(h.x-u.x,h.y-u.y),f=Math.hypot(d.x-u.x,d.y-u.y);return Math.sqrt(p*f)*v/n},b=r=>{const n=x,o=$;return{aabb:i.tileAABB(this,c,0,0,0,r,o,n,this.projection),zoom:0,x:0,y:0,minZ:o,maxZ:n,wrap:r,fullyVisible:!1}},w=[];let T=[];const E=n,S=r.reparseOverscaled?o:n,I=i=>i*i,C=I((f-this._centerAltitude)*p),z=i=>{if(!this._elevation||!i.tileID||!a)return;const r=this._elevation.getMinMaxForTile(i.tileID),n=i.aabb;r?(n.min[2]=r.min,n.max[2]=r.max,n.center[2]=(n.min[2]+n.max[2])/2):(i.shouldSplit=A(i),i.shouldSplit||(n.min[2]=n.max[2]=n.center[2]=this._centerAltitude))},A=r=>{if(r.zoom.85?1:h}const d=n*n+a*a+l;return d{if(r*I(.707)0;){const P=w.pop(),D=P.x,L=P.y;let B=P.fullyVisible;if(!B){const R=P.aabb.intersects(h);if(0===R)continue;B=2===R}if(P.zoom!==E&&A(P))for(let M=0;M<4;M++){const F=(D<<1)+M%2,O=(L<<1)+(M>>1),U={aabb:a?P.aabb.quadrant(M):i.tileAABB(this,c,P.zoom+1,F,O,P.wrap,P.minZ,P.maxZ,this.projection),zoom:P.zoom+1,x:F,y:O,wrap:P.wrap,fullyVisible:B,tileID:void 0,shouldSplit:void 0,minZ:P.minZ,maxZ:P.maxZ};s&&(U.tileID=new i.OverscaledTileID(P.zoom+1===E?S:P.zoom+1,P.wrap,P.zoom+1,F,O),z(U)),w.push(U)}else{const V=P.zoom===E?S:P.zoom;if(r.minzoom&&r.minzoom>V)continue;const j=u[0]-(.5+D+(P.wrap<{const o=[0,0,0,1],s=[i.EXTENT,i.EXTENT,0,1],a=this.calculateFogTileMatrix(n.tileID.toUnwrapped());i.transformMat4$1(o,o,a),i.transformMat4$1(s,s,a);const l=i.getAABBPointSquareDist(o,s);if(0===l)return!0;let c=!1;const u=this._elevation;if(u&&l>Z&&0!==q){const h=this.calculateProjMatrix(n.tileID.toUnwrapped());let d;r.isTerrainDEM||(d=u.getMinMaxForTile(n.tileID)),d||(d={min:$,max:x});const p=i.furthestTileCorner(this.rotation),f=[p[0]*i.EXTENT,p[1]*i.EXTENT,d.max,];i.transformMat4(f,f,h),c=(1-f[1])*this.height*.5i.distanceSq-r.distanceSq).map(i=>i.tileID)}resize(i,r){this.width=i,this.height=r,this.pixelsToGLUnits=[2/i,-2/r],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(i){return Math.pow(2,i)}scaleZoom(i){return Math.log(i)/Math.LN2}project(r){const n=i.clamp(r.lat,-i.MAX_MERCATOR_LATITUDE,i.MAX_MERCATOR_LATITUDE),o=this.projection.project(r.lng,n);return new i.pointGeometry(o.x*this.worldSize,o.y*this.worldSize)}unproject(i){return this.projection.unproject(i.x/this.worldSize,i.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(r,n){const o=this.pointCoordinate(n),s=this.pointCoordinate(this.centerPoint),a=this.locationCoordinate(r);this.setLocation(new i.MercatorCoordinate(a.x-(o.x-s.x),a.y-(o.y-s.y)))}setLocation(i){this.center=this.coordinateLocation(i),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(i){return this.projection.locationPoint(this,i)}locationPoint3D(i){return this._coordinatePoint(this.locationCoordinate(i),!0)}pointLocation(i){return this.coordinateLocation(this.pointCoordinate(i))}pointLocation3D(i){return this.coordinateLocation(this.pointCoordinate3D(i))}locationCoordinate(r,n){const o=n?i.mercatorZfromAltitude(n,r.lat):void 0,s=this.projection.project(r.lng,r.lat);return new i.MercatorCoordinate(s.x,s.y,o)}coordinateLocation(i){return this.projection.unproject(i.x,i.y)}pointRayIntersection(r,n){const o=null!=n?n:this._centerAltitude,s=[r.x,r.y,0,1],a=[r.x,r.y,1,1];i.transformMat4$1(s,s,this.pixelMatrixInverse),i.transformMat4$1(a,a,this.pixelMatrixInverse);const l=a[3];i.scale$1(s,s,1/s[3]),i.scale$1(a,a,1/l);const c=s[2],u=a[2];return{p0:s,p1:a,t:c===u?0:(o-c)/(u-c)}}screenPointToMercatorRay(r){const n=[r.x,r.y,0,1],o=[r.x,r.y,1,1];return i.transformMat4$1(n,n,this.pixelMatrixInverse),i.transformMat4$1(o,o,this.pixelMatrixInverse),i.scale$1(n,n,1/n[3]),i.scale$1(o,o,1/o[3]),n[2]=i.mercatorZfromAltitude(n[2],this._center.lat)*this.worldSize,o[2]=i.mercatorZfromAltitude(o[2],this._center.lat)*this.worldSize,i.scale$1(n,n,1/this.worldSize),i.scale$1(o,o,1/this.worldSize),new i.Ray([n[0],n[1],n[2]],i.normalize([],i.sub([],o,n)))}rayIntersectionCoordinate(r){const{p0:n,p1:o,t:s}=r,a=i.mercatorZfromAltitude(n[2],this._center.lat),l=i.mercatorZfromAltitude(o[2],this._center.lat);return new i.MercatorCoordinate(i.number(n[0],o[0],s)/this.worldSize,i.number(n[1],o[1],s)/this.worldSize,i.number(a,l,s))}pointCoordinate(i,r=this._centerAltitude){return this.projection.createTileTransform(this,this.worldSize).pointCoordinate(i.x,i.y,r)}pointCoordinate3D(r){if(!this.elevation)return this.pointCoordinate(r);const n=this.elevation;let o=this.elevation.pointCoordinate(r);if(o)return new i.MercatorCoordinate(o[0],o[1],o[2]);let s=0,a=this.horizonLineFromTop();if(r.y>a)return this.pointCoordinate(r);const l=.02*a,c=r.clone();for(let u=0;u<10&&a-s>l;u++){c.y=i.number(s,a,.66);const h=n.pointCoordinate(c);h?(a=c.y,o=h):s=c.y}return o?new i.MercatorCoordinate(o[0],o[1],o[2]):this.pointCoordinate(r)}isPointAboveHorizon(i){if(this.elevation)return!this.elevation.pointCoordinate(i);{const r=this.horizonLineFromTop();return i.y0?new i.pointGeometry(s[0]/s[3],s[1]/s[3]):new i.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(r,n){var o,s,a,l,c,u,h,d;const p=new i.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),f=new i.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),m=new i.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),g=new i.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let y=this.pointCoordinate(p,r),x=this.pointCoordinate(f,r);const $=this.pointCoordinate(m,n),v=this.pointCoordinate(g,n);return y.y>1&&x.y>=0?y=new i.MercatorCoordinate((1-v.y)/(o=v,((s=y).y-o.y)/(s.x-o.x))+v.x,1):y.y<0&&x.y<=1&&(y=new i.MercatorCoordinate(-v.y/(a=v,((l=y).y-a.y)/(l.x-a.x))+v.x,0)),x.y>1&&y.y>=0?x=new i.MercatorCoordinate((1-$.y)/(c=$,((u=x).y-c.y)/(u.x-c.x))+$.x,1):x.y<0&&y.y<=1&&(x=new i.MercatorCoordinate(-$.y/(h=$,((d=x).y-h.y)/(d.x-h.x))+$.x,0)),new i.LngLatBounds().extend(this.coordinateLocation(y)).extend(this.coordinateLocation(x)).extend(this.coordinateLocation(v)).extend(this.coordinateLocation($))}_getBounds3D(){const i=this.elevation;if(!i.visibleDemTiles.length)return this._getBounds(0,0);const r=i.visibleDemTiles.reduce((i,r)=>{if(r.dem){const n=r.dem.tree;i.min=Math.min(i.min,n.minimums[0]),i.max=Math.max(i.max,n.maximums[0])}return i},{min:Number.MAX_VALUE,max:0});return this._getBounds(r.min*i.exaggeration(),r.max*i.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(i=!0){const r=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,n=this.height/2-r*(1-this._horizonShift);return i?Math.max(0,n):n}getMaxBounds(){return this.maxBounds}setMaxBounds(r){this.maxBounds=r,this.minLat=-i.MAX_MERCATOR_LATITUDE,this.maxLat=i.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,r&&(this.minLat=r.getSouth(),this.maxLat=r.getNorth(),this.minLng=r.getWest(),this.maxLng=r.getEast(),this.maxLngp&&(c=p-h),p-dm&&(l=m-u),m-f.5?b-1:b,w>.5?w-1:w,0,]),this.alignedProjMatrix=T,c=i.create(),i.scale(c,c,[this.width/2,-this.height/2,1,]),i.translate(c,c,[1,-1,0]),this.labelPlaneMatrix=c,c=i.create(),i.scale(c,c,[1,-1,1]),i.translate(c,c,[-1,-1,0]),i.scale(c,c,[2/this.width,2/this.height,1,]),this.glCoordMatrix=c,this.pixelMatrix=i.multiply$1(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},!(c=i.invert(new Float64Array(16),this.pixelMatrix)))throw Error("failed to invert matrix");this.pixelMatrixInverse=c,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const r=this.cameraWorldSize,n=this.cameraPixelsPerMeter,o=this._camera.position,s=1/this.height,a=[r,r,n];i.scale$2(a,a,s),i.scale$2(o,o,-1),i.multiply$2(o,o,a);const l=i.create();i.translate(l,l,o),i.scale(l,l,a),this.mercatorFogMatrix=l,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(r,n,s)}_computeCameraPosition(i){const r=(i=i||this.pixelsPerMeter)/this.pixelsPerMeter,n=this._camera.forward(),o=this.point,s=this._mercatorZfromZoom(this._cameraZoom?this._cameraZoom:this._zoom)*r-i/this.worldSize*this._centerAltitude;return[o.x/this.worldSize-n[0]*s,o.y/this.worldSize-n[1]*s,i/this.worldSize*this._centerAltitude-n[2]*s,]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(r){const n=this._maxCameraBoundsDistance()*Math.cos(this._pitch),o=r[2];let s=1;o>0&&(s=Math.min((n-this._camera.position[2])/o,1)),this._camera.position=i.scaleAndAdd([],this._camera.position,r,s),this._updateStateFromCamera()}_updateStateFromCamera(){const r=this._camera.position,n=this._camera.forward(),{pitch:o,bearing:s}=this._camera.getPitchBearing(),a=i.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,l=this._mercatorZfromZoom(this._maxZoom)*Math.cos(i.degToRad(this._maxPitch)),c=Math.max((r[2]-a)/Math.cos(o),l),u=this._zoomFromMercatorZ(c);i.scaleAndAdd(r,r,n,c),this._pitch=i.clamp(o,i.degToRad(this.minPitch),i.degToRad(this.maxPitch)),this.angle=i.wrap(s,-Math.PI,Math.PI),this._setZoom(i.clamp(u,this._minZoom,this._maxZoom)),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._center=this.coordinateLocation(new i.MercatorCoordinate(r[0],r[1],r[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(i){return Math.pow(2,i)*this.tileSize}_mercatorZfromZoom(i){return this.cameraToCenterDistance/this._worldSizeFromZoom(i)}_minimumHeightOverTerrain(){const i=Math.min((null!=this._cameraZoom?this._cameraZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(i)}_zoomFromMercatorZ(i){return this.scaleZoom(this.cameraToCenterDistance/(i*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(i.warnOnce("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."),1))}anyCornerOffEdge(r,n){const o=Math.min(r.x,n.x),s=Math.max(r.x,n.x),a=Math.min(r.y,n.y),l=Math.max(r.y,n.y);if(ah||f.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+i.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new i.pointGeometry(0,0),new i.pointGeometry(this.width,this.height))}zoomDeltaToMovement(r,n){const o=i.length(i.sub([],this._camera.position,r)),s=this._zoomFromMercatorZ(o)+n;return o-this._mercatorZfromZoom(s)}getCameraPoint(){const r=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i.pointGeometry(0,r))}}function iy(i,r){let n=!1,o=null;const s=()=>{o=null,n&&(i(),o=setTimeout(s,r),n=!1)};return()=>(n=!0,o||s(),o)}const ix={linearity:.3,easing:i.bezier(0,0,.3,1)},i$=i.extend({deceleration:2500,maxSpeed:1400},ix),iv=i.extend({deceleration:20,maxSpeed:1400},ix),i_=i.extend({deceleration:1e3,maxSpeed:360},ix),ib=i.extend({deceleration:1e3,maxSpeed:90},ix);function iw(i,r){(!i.duration||i.durationn.unproject(i)),u=a.reduce((i,r,n,o)=>i.add(r.div(o.length)),new i.pointGeometry(0,0));super(r,{points:a,point:u,lngLats:c,lngLat:n.unproject(u),originalEvent:o}),this._defaultPrevented=!1}}class iS extends i.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(i,r,n){super(i,{originalEvent:n}),this._defaultPrevented=!1}}class iI{constructor(i,r){this._map=i,this._clickTolerance=r.clickTolerance}reset(){delete this._mousedownPos}wheel(i){return this._firePreventable(new iS(i.type,this._map,i))}mousedown(i,r){return this._mousedownPos=r,this._firePreventable(new iT(i.type,this._map,i))}mouseup(i){this._map.fire(new iT(i.type,this._map,i))}preclick(r){const n=i.extend({},r);n.type="preclick",this._map.fire(new iT(n.type,this._map,n))}click(i,r){this._mousedownPos&&this._mousedownPos.dist(r)>=this._clickTolerance||(this.preclick(i),this._map.fire(new iT(i.type,this._map,i)))}dblclick(i){return this._firePreventable(new iT(i.type,this._map,i))}mouseover(i){this._map.fire(new iT(i.type,this._map,i))}mouseout(i){this._map.fire(new iT(i.type,this._map,i))}touchstart(i){return this._firePreventable(new iE(i.type,this._map,i))}touchmove(i){this._map.fire(new iE(i.type,this._map,i))}touchend(i){this._map.fire(new iE(i.type,this._map,i))}touchcancel(i){this._map.fire(new iE(i.type,this._map,i))}_firePreventable(i){if(this._map.fire(i),i.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class iC{constructor(i){this._map=i}reset(){this._delayContextMenu=!1,delete this._contextMenuEvent}mousemove(i){this._map.fire(new iT(i.type,this._map,i))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new iT("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(i){this._delayContextMenu?this._contextMenuEvent=i:this._map.fire(new iT(i.type,this._map,i)),this._map.listens("contextmenu")&&i.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class iz{constructor(i,r){this._map=i,this._el=i.getCanvasContainer(),this._container=i.getContainer(),this._clickTolerance=r.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(i,r){this.isEnabled()&&i.shiftKey&&0===i.button&&(l.disableDrag(),this._startPos=this._lastPos=r,this._active=!0)}mousemoveWindow(i,r){if(!this._active)return;const n=r;if(this._lastPos.equals(n)||!this._box&&n.dist(this._startPos){this._box&&(this._box.style.transform=`translate(${s}px,${c}px)`,this._box.style.width=a-s+"px",this._box.style.height=u-c+"px")})}mouseupWindow(r,n){if(!this._active||0!==r.button)return;const o=this._startPos,s=n;if(this.reset(),l.suppressClick(),o.x!==s.x||o.y!==s.y)return this._map.fire(new i.Event("boxzoomend",{originalEvent:r})),{cameraAnimation:i=>i.fitScreenCoordinates(o,s,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",r)}keydown(i){this._active&&27===i.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",i))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),l.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(r,n){return this._map.fire(new i.Event(r,{originalEvent:n}))}}function iA(i,r){const n={};for(let o=0;othis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=r.timeStamp),o.length===this.numTouches&&(this.centroid=function(r){const n=new i.pointGeometry(0,0);for(const o of r)n._add(o);return n.div(r.length)}(n),this.touches=iA(o,n)))}touchmove(i,r,n){if(this.aborted||!this.centroid)return;const o=iA(n,r);for(const s in this.touches){const a=this.touches[s],l=o[s];(!l||l.dist(a)>30)&&(this.aborted=!0)}}touchend(i,r,n){if((!this.centroid||i.timeStamp-this.startTime>500)&&(this.aborted=!0),0===n.length){const o=!this.aborted&&this.centroid;if(this.reset(),o)return o}}}(r),this.numTaps=r.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(i,r,n){this.singleTap.touchstart(i,r,n)}touchmove(i,r,n){this.singleTap.touchmove(i,r,n)}touchend(i,r,n){const o=this.singleTap.touchend(i,r,n);if(o){const s=i.timeStamp-this.lastTime<500,a=!this.lastTap||30>this.lastTap.dist(o);if(s&&a||this.reset(),this.count++,this.lastTime=i.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class iP{constructor(){this._zoomIn=new ik({numTouches:1,numTaps:2}),this._zoomOut=new ik({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(i,r,n){this._zoomIn.touchstart(i,r,n),this._zoomOut.touchstart(i,r,n)}touchmove(i,r,n){this._zoomIn.touchmove(i,r,n),this._zoomOut.touchmove(i,r,n)}touchend(i,r,n){const o=this._zoomIn.touchend(i,r,n),s=this._zoomOut.touchend(i,r,n);return o?(this._active=!0,i.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:r=>r.easeTo({duration:300,zoom:r.getZoom()+1,around:r.unproject(o)},{originalEvent:i})}):s?(this._active=!0,i.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:r=>r.easeTo({duration:300,zoom:r.getZoom()-1,around:r.unproject(s)},{originalEvent:i})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const iD={0:1,2:2};class iL{constructor(i){this.reset(),this._clickTolerance=i.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(i,r){return!1}_move(i,r){return{}}mousedown(i,r){if(this._lastPoint)return;const n=l.mouseButton(i);this._correctButton(i,n)&&(this._lastPoint=r,this._eventButton=n)}mousemoveWindow(i,r){const n=this._lastPoint;if(n){if(i.preventDefault(),function(i,r){const n=iD[r];return void 0===i.buttons||(i.buttons&n)!==n}(i,this._eventButton))this.reset();else if(this._moved||!(r.dist(n)0&&(this._active=!0);const s=iA(o,n),a=new i.pointGeometry(0,0),l=new i.pointGeometry(0,0);let c=0;for(const u in s){const h=s[u],d=this._touches[u];d&&(a._add(h),l._add(h.sub(d)),c++,s[u]=h)}if(this._touches=s,c{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")},500)}}class iM{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}_start(i){}_move(i,r,n){return{}}touchstart(i,r,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier,],this._start([r[0],r[1]]))}touchmove(i,r,n){if(!this._firstTwoTouches)return;i.preventDefault();const[o,s]=this._firstTwoTouches,a=i2(n,r,o),l=i2(n,r,s);if(!a||!l)return;const c=this._aroundCenter?null:a.add(l).div(2);return this._move([a,l],c,i)}touchend(i,r,n){if(!this._firstTwoTouches)return;const[o,s]=this._firstTwoTouches,a=i2(n,r,o),c=i2(n,r,s);a&&c||(this._active&&l.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(i){this._enabled=!0,this._aroundCenter=!!i&&"center"===i.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function i2(i,r,n){for(let o=0;oMath.abs(iF(this._distance,this._startDistance))))return this._active=!0,{zoomDelta:iF(this._distance,n),pinchAround:r}}}function i4(i,r){return 180*i.angleWith(r)/Math.PI}class iU extends iM{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(i){this._startVector=this._vector=i[0].sub(i[1]),this._minDiameter=i[0].dist(i[1])}_move(i,r){const n=this._vector;if(this._vector=i[0].sub(i[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:i4(this._vector,n),pinchAround:r}}_isBelowThreshold(i){this._minDiameter=Math.min(this._minDiameter,i.mag());const r=25/(Math.PI*this._minDiameter)*360,n=i4(i,this._startVector);return Math.abs(n)Math.abs(i.x)}class i6 extends iM{constructor(i){super(),this._map=i}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}_start(i){this._lastPoints=i,iV(i[0].sub(i[1]))&&(this._valid=!1)}_move(i,r,n){const o=i[0].sub(this._lastPoints[0]),s=i[1].sub(this._lastPoints[1]);if(!(this._map._cooperativeGestures&&n.touches.length<3)&&(this._valid=this.gestureBeginsVertically(o,s,n.timeStamp),this._valid))return this._lastPoints=i,this._active=!0,{pitchDelta:-((o.y+s.y)/2*.5)}}gestureBeginsVertically(i,r,n){if(void 0!==this._valid)return this._valid;const o=i.mag()>=2,s=r.mag()>=2;if(!o&&!s)return;if(!o||!s)return void 0===this._firstMove&&(this._firstMove=n),n-this._firstMove<100&&void 0;const a=i.y>0==r.y>0;return iV(i)&&iV(r)&&a}}class ij{constructor(){const i={panStep:100,bearingStep:15,pitchStep:10};this._panStep=i.panStep,this._bearingStep=i.bearingStep,this._pitchStep=i.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(i){if(i.altKey||i.ctrlKey||i.metaKey)return;let r=0,n=0,o=0,s=0,a=0;switch(i.keyCode){case 61:case 107:case 171:case 187:r=1;break;case 189:case 109:case 173:r=-1;break;case 37:i.shiftKey?n=-1:(i.preventDefault(),s=-1);break;case 39:i.shiftKey?n=1:(i.preventDefault(),s=1);break;case 38:i.shiftKey?o=1:(i.preventDefault(),a=-1);break;case 40:i.shiftKey?o=-1:(i.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(n=0,o=0),{cameraAnimation:l=>{const c=l.getZoom();l.easeTo({duration:300,easeId:"keyboardHandler",easing:iN,zoom:r?Math.round(c)+r*(i.shiftKey?2:1):c,bearing:l.getBearing()+n*this._bearingStep,pitch:l.getPitch()+o*this._pitchStep,offset:[-s*this._panStep,-a*this._panStep,],center:l.getCenter()},{originalEvent:i})}}}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 iN(i){return i*(2-i)}class iG{constructor(r,n){this._map=r,this._el=r.getCanvasContainer(),this._handler=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,i.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen",],this)}setZoomRate(i){this._defaultZoomRate=i}setWheelZoomRate(i){this._wheelZoomRate=i}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(i){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!i&&"center"===i.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(r){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(r.ctrlKey||r.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let n=r.deltaMode===i.window.WheelEvent.DOM_DELTA_LINE?40*r.deltaY:r.deltaY;const o=i.exported.now(),s=o-(this._lastWheelEventTime||0);this._lastWheelEventTime=o,0!==n&&n%4.000244140625==0?this._type="wheel":0!==n&&4>Math.abs(n)?this._type="trackpad":s>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,r)):this._type||(this._type=200>Math.abs(s*n)?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),r.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=r,this._delta-=n,this._active||this._start(r)),r.preventDefault()}_onTimeout(i){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(i)}_start(i){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 r=l.mousePos(this._el,i);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:r,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const r=this._map.transform,n=()=>r._terrainEnabled()&&this._aroundCoord?r.computeZoomRelativeTo(this._aroundCoord):r.zoom;if(0!==this._delta){const o="wheel"===this._type&&Math.abs(this._delta)>4.000244140625?this._wheelZoomRate:this._defaultZoomRate;let s=2/(1+Math.exp(-Math.abs(this._delta*o)));this._delta<0&&0!==s&&(s=1/s);const a=n(),l=Math.pow(2,a),c="number"==typeof this._targetZoom?r.zoomScale(this._targetZoom):l;this._targetZoom=Math.min(r.maxZoom,Math.max(r.minZoom,r.scaleZoom(c*s))),"wheel"===this._type&&(this._startZoom=n(),this._easing=this._smoothOutEasing(200)),this._delta=0}const u="number"==typeof this._targetZoom?this._targetZoom:n(),h=this._startZoom,d=this._easing;let p,f=!1;if("wheel"===this._type&&h&&d){const m=Math.min((i.exported.now()-this._lastWheelEventTime)/200,1),g=d(m);p=i.number(h,u,g),m<1?this._frameId||(this._frameId=!0):f=!0}else p=u,f=!0;return this._active=!0,f&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!f,zoomDelta:p-n(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(r){let n=i.ease;if(this._prevEase){const o=this._prevEase,s=(i.exported.now()-o.start)/o.duration,a=o.easing(s+.01)-o.easing(s),l=.27/Math.sqrt(a*a+1e-4)*.01,c=Math.sqrt(.0729-l*l);n=i.bezier(l,c,.25,1)}return this._prevEase={start:i.exported.now(),duration:r,easing:n},n}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=l.create("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(i.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_isFullscreen(){return!!i.window.document.fullscreenElement}_showBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")},200)}}class iZ{constructor(i,r){this._clickZoom=i,this._tapZoom=r}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 i9{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(i,r){return i.preventDefault(),{cameraAnimation(n){n.easeTo({duration:300,zoom:n.getZoom()+(i.shiftKey?-1:1),around:n.unproject(r)},{originalEvent:i})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class i7{constructor(){this._tap=new ik({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(i,r,n){this._swipePoint||(this._tapTime&&i.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?n.length>0&&(this._swipePoint=r[0],this._swipeTouch=n[0].identifier):this._tap.touchstart(i,r,n))}touchmove(i,r,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;const o=r[0],s=o.y-this._swipePoint.y;return this._swipePoint=o,i.preventDefault(),this._active=!0,{zoomDelta:s/128}}}else this._tap.touchmove(i,r,n)}touchend(i,r,n){this._tapTime?this._swipePoint&&0===n.length&&this.reset():this._tap.touchend(i,r,n)&&(this._tapTime=i.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class iq{constructor(i,r,n){this._el=i,this._mousePan=r,this._touchPan=n}enable(i){this._inertiaOptions=i||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class i5{constructor(i,r,n){this._pitchWithRotate=i.pitchWithRotate,this._mouseRotate=r,this._mousePitch=n}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class iX{constructor(i,r,n,o){this._el=i,this._touchZoom=r,this._touchRotate=n,this._tapDragZoom=o,this._rotationDisabled=!1,this._enabled=!0}enable(i){this._touchZoom.enable(i),this._rotationDisabled||this._touchRotate.enable(i),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const iW=i=>i.zoom||i.drag||i.pitch||i.rotate;class iH extends i.Event{}function iK(i){return i.panDelta&&i.panDelta.mag()||i.zoomDelta||i.bearingDelta||i.pitchDelta}const iY="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class iJ extends i.Evented{constructor(r,n){super(),this._moving=!1,this._zooming=!1,this.transform=r,this._bearingSnap=n.bearingSnap,i.bindAll(["_renderFrameCallback"],this)}getCenter(){return new i.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(i,r){return this.jumpTo({center:i},r)}panBy(r,n,o){return r=i.pointGeometry.convert(r).mult(-1),this.panTo(this.transform.center,i.extend({offset:r},n),o)}panTo(r,n,o){return this.easeTo(i.extend({center:r},n),o)}getZoom(){return this.transform.zoom}setZoom(i,r){return this.jumpTo({zoom:i},r),this}zoomTo(r,n,o){return this.easeTo(i.extend({zoom:r},n),o)}zoomIn(i,r){return this.zoomTo(this.getZoom()+1,i,r),this}zoomOut(i,r){return this.zoomTo(this.getZoom()-1,i,r),this}getBearing(){return this.transform.bearing}setBearing(i,r){return this.jumpTo({bearing:i},r),this}getPadding(){return this.transform.padding}setPadding(i,r){return this.jumpTo({padding:i},r),this}rotateTo(r,n,o){return this.easeTo(i.extend({bearing:r},n),o)}resetNorth(r,n){return this.rotateTo(0,i.extend({duration:1e3},r),n),this}resetNorthPitch(r,n){return this.easeTo(i.extend({bearing:0,pitch:0,duration:1e3},r),n),this}snapToNorth(i,r){return Math.abs(this.getBearing())g=>{if(w&&(o.zoom=i.number(s,u,g)),T&&(o.bearing=i.number(a,h,g)),E&&(o.pitch=i.number(l,d,g)),S&&(o.interpolatePadding(c,p,g),m=o.centerPoint.add(f)),_)o.setLocationAtPoint(_,b);else{const y=o.zoomScale(o.zoom-s),I=u>s?Math.min(2,v):Math.max(.5,v),C=Math.pow(I,1-g),z=o.unproject(x.add($.mult(g*C)).mult(y));o.setLocationAtPoint(o.renderWorldCopies?z.wrap():z,m)}return r.preloadOnly||this._fireMoveEvents(n),o};if(r.preloadOnly){const C=this._emulate(I,r.duration,o);return this._preloadTiles(C),this}const z={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=w,this._rotating=T,this._pitching=E,this._padding=S,this._easeId=r.easeId,this._prepareEase(n,r.noMoveStart,z),this._ease(I(o),i=>{o.recenterOnTerrain(),this._afterEase(n,i)},r),this}_prepareEase(r,n,o={}){this._moving=!0,this.transform.cameraElevationReference="sea",n||o.moving||this.fire(new i.Event("movestart",r)),this._zooming&&!o.zooming&&this.fire(new i.Event("zoomstart",r)),this._rotating&&!o.rotating&&this.fire(new i.Event("rotatestart",r)),this._pitching&&!o.pitching&&this.fire(new i.Event("pitchstart",r))}_fireMoveEvents(r){this.fire(new i.Event("move",r)),this._zooming&&this.fire(new i.Event("zoom",r)),this._rotating&&this.fire(new i.Event("rotate",r)),this._pitching&&this.fire(new i.Event("pitch",r))}_afterEase(r,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId,this.transform.cameraElevationReference="ground";const o=this._zooming,s=this._rotating,a=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,o&&this.fire(new i.Event("zoomend",r)),s&&this.fire(new i.Event("rotateend",r)),a&&this.fire(new i.Event("pitchend",r)),this.fire(new i.Event("moveend",r))}flyTo(r,n){if(!r.essential&&i.exported.prefersReducedMotion){const o=i.pick(r,["center","zoom","bearing","pitch","around",]);return this.jumpTo(o,n)}this.stop(),r=i.extend({offset:[0,0],speed:1.2,curve:1.42,easing:i.ease},r);const s=this.transform,a=this.getZoom(),l=this.getBearing(),c=this.getPitch(),u=this.getPadding(),h="zoom"in r?i.clamp(+r.zoom,s.minZoom,s.maxZoom):a,d="bearing"in r?this._normalizeBearing(r.bearing,l):l,p="pitch"in r?+r.pitch:c,f="padding"in r?r.padding:s.padding,m=s.zoomScale(h-a),g=i.pointGeometry.convert(r.offset);let y=s.centerPoint.add(g);const x=s.pointLocation(y),$=i.LngLat.convert(r.center||x);this._normalizeCenter($);const v=s.project(x),_=s.project($).sub(v);let b=r.curve;const w=Math.max(s.width,s.height),T=w/m,E=_.mag();if("minZoom"in r){const S=i.clamp(Math.min(r.minZoom,a,h),s.minZoom,s.maxZoom),I=w/s.zoomScale(S-a);b=Math.sqrt(I/E*2)}const C=b*b;function z(i){const r=(T*T-w*w+(i?-1:1)*C*C*E*E)/(2*(i?T:w)*C*E);return Math.log(Math.sqrt(r*r+1)-r)}function A(i){return(Math.exp(i)-Math.exp(-i))/2}function k(i){return(Math.exp(i)+Math.exp(-i))/2}const P=z(0);let D=function(i){return k(P)/k(P+b*i)},L=function(i){var r;return w*((k(P)*(A(r=P+b*i)/k(r))-A(P))/C)/E},B=(z(1)-P)/b;if(1e-6>Math.abs(E)||!isFinite(B)){if(1e-6>Math.abs(w-T))return this.easeTo(r,n);const R=Tr.maxDuration&&(r.duration=0);const M=l!==d,F=p!==c,O=!s.isPaddingEqual(f),U=o=>s=>{const m=s*B,x=1/D(m);o.zoom=1===s?h:a+o.scaleZoom(x),M&&(o.bearing=i.number(l,d,s)),F&&(o.pitch=i.number(c,p,s)),O&&(o.interpolatePadding(u,f,s),y=o.centerPoint.add(g));const b=1===s?$:o.unproject(v.add(_.mult(L(m))).mult(x));return o.setLocationAtPoint(o.renderWorldCopies?b.wrap():b,y),o._updateCenterElevation(),r.preloadOnly||this._fireMoveEvents(n),o};if(r.preloadOnly){const V=this._emulate(U,r.duration,s);return this._preloadTiles(V),this}return this._zooming=!0,this._rotating=M,this._pitching=F,this._padding=O,this._prepareEase(n,!1),this._ease(U(s),()=>this._afterEase(n),r),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(i,r){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const n=this._onEaseEnd;delete this._onEaseEnd,n.call(this,r)}if(!i){const o=this.handlers;o&&o.stop(!1)}return this}_ease(r,n,o){!1===o.animate||0===o.duration?(r(1),n()):(this._easeStart=i.exported.now(),this._easeOptions=o,this._onEaseFrame=r,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const r=Math.min((i.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(r)),r<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(r,n){r=i.wrap(r,-180,180);const o=Math.abs(r-n);return Math.abs(r-360-n)180?-360:n<-180?360:0}_emulate(i,r,n){const o=Math.ceil(15*r/1e3),s=[],a=i(n.clone());for(let l=0;l<=o;l++){const c=a(l/o);s.push(c.clone())}return s}}class iQ{constructor(r={}){this.options=r,i.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact",],this)}getDefaultPosition(){return"bottom-right"}onAdd(i){const r=this.options&&this.options.compact;return this._map=i,this._container=l.create("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=l.create("button","mapboxgl-ctrl-attrib-button",this._container),l.create("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden",!0),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=l.create("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),r&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===r&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(i,r){const n=this._map._getUIString(`AttributionControl.${r}`);i.setAttribute("aria-label",n),i.removeAttribute("title"),i.firstElementChild&&i.firstElementChild.setAttribute("title",n)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let r=this._editLink;r||(r=this._editLink=this._container.querySelector(".mapbox-improve-map"));const n=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||i.config.ACCESS_TOKEN},];if(r){const o=n.reduce((i,r,o)=>(r.value&&(i+=`${r.key}=${r.value}${oi.indexOf(a.attribution)&&i.push(a.attribution)}}i.sort((i,r)=>i.length-r.length),i=i.filter((r,n)=>{for(let o=n+1;o=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?i=[...this.options.customAttribution,...i,]:i.unshift(this.options.customAttribution));const l=i.join(" | ");l!==this._attribHTML&&(this._attribHTML=l,i.length?(this._innerContainer.innerHTML=l,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class re{constructor(){i.bindAll(["_updateLogo"],this),i.bindAll(["_updateCompact"],this)}onAdd(i){this._map=i,this._container=l.create("div","mapboxgl-ctrl");const r=l.create("a","mapboxgl-ctrl-logo");return r.target="_blank",r.rel="noopener nofollow",r.href="https://www.mapbox.com/",r.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),r.setAttribute("rel","noopener nofollow"),this._container.appendChild(r),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(i){i&&"metadata"!==i.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const i=this._map.style._sourceCaches;if(0===Object.entries(i).length)return!0;for(const r in i){const n=i[r].getSource();if(n.hasOwnProperty("mapbox_logo")&&!n.mapbox_logo)return!1}return!0}_updateCompact(){const i=this._container.children;if(i.length){const r=i[0];this._map.getCanvasContainer().offsetWidth<250?r.classList.add("mapboxgl-compact"):r.classList.remove("mapboxgl-compact")}}}class rt{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(i){const r=++this._id;return this._queue.push({callback:i,id:r,cancelled:!1}),r}remove(i){const r=this._currentlyRunning,n=r?this._queue.concat(r):this._queue;for(const o of n)if(o.id===i)return void(o.cancelled=!0)}run(i=0){const r=this._currentlyRunning=this._queue;for(const n of(this._queue=[],r))if(!n.cancelled&&(n.callback(i),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function ri(r,n,o){if(r=new i.LngLat(r.lng,r.lat),n){const s=new i.LngLat(r.lng-360,r.lat),a=new i.LngLat(r.lng+360,r.lat),l=360*Math.ceil(Math.abs(r.lng-o.center.lng)/360),c=o.locationPoint(r).distSqr(n),u=n.x<0||n.y<0||n.x>o.width||n.y>o.height;o.locationPoint(s).distSqr(n)180;){const h=o.locationPoint(r);if(h.x>=0&&h.y>=0&&h.x<=o.width&&h.y<=o.height)break;r.lng>o.center.lng?r.lng-=360:r.lng+=360}return r}const rr={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class rn extends i.Evented{constructor(r,n){if(super(),(r instanceof i.window.HTMLElement||n)&&(r=i.extend({element:r},n)),i.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer",],this),this._anchor=r&&r.anchor||"center",this._color=r&&r.color||"#3FB1CE",this._scale=r&&r.scale||1,this._draggable=r&&r.draggable||!1,this._clickTolerance=r&&r.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=r&&r.rotation||0,this._rotationAlignment=r&&r.rotationAlignment||"auto",this._pitchAlignment=r&&r.pitchAlignment&&"auto"!==r.pitchAlignment?r.pitchAlignment:this._rotationAlignment,this._updateMoving=()=>this._update(!0),r&&r.element)this._element=r.element,this._offset=i.pointGeometry.convert(r&&r.offset||[0,0]);else{this._defaultMarker=!0,this._element=l.create("div");const o=l.createSVG("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},this._element),s=l.createSVG("radialGradient",{id:"shadowGradient"},l.createSVG("defs",{},o));l.createSVG("stop",{offset:"10%","stop-opacity":.4},s),l.createSVG("stop",{offset:"100%","stop-opacity":.05},s),l.createSVG("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},o),l.createSVG("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},o),l.createSVG("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},o),l.createSVG("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},o),this._offset=i.pointGeometry.convert(r&&r.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",i=>{i.preventDefault()}),this._element.addEventListener("mousedown",i=>{i.preventDefault()});const a=this._element.classList;for(const c in rr)a.remove(`mapboxgl-marker-anchor-${c}`);a.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(i){return i===this._map||(this.remove(),this._map=i,i.getCanvasContainer().appendChild(this._element),i.on("move",this._updateMoving),i.on("moveend",this._update),i.on("remove",this._clearFadeTimer),i._addMarker(this),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick)),this}remove(){return this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._updateMoving),this._map.off("moveend",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),this._map.off("remove",this._clearFadeTimer),this._map._removeMarker(this),delete this._map),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(r){return this._lngLat=i.LngLat.convert(r),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(i){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),i){if(!("offset"in i.options)){const r=Math.sqrt(91.125);i.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[r,-1*(24.6+r),],"bottom-right":[-r,-1*(24.6+r),],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=i,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(i){const r=i.code,n=i.charCode||i.keyCode;"Space"!==r&&"Enter"!==r&&32!==n&&13!==n||this.togglePopup()}_onMapClick(i){const r=i.originalEvent.target,n=this._element;this._popup&&(r===n||n.contains(r))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const i=this._popup;return i&&(i.isOpen()?(i.remove(),this._element.setAttribute("aria-expanded","false")):(i.addTo(this._map),this._element.setAttribute("aria-expanded","true"))),this}_evaluateOpacity(){const i=this._pos?this._pos.sub(this._transformedOffset()):null;if(!this._withinScreenBounds(i))return void this._clearFadeTimer();const r=this._map.unproject(i);let n=!1;if(this._map.transform._terrainEnabled()&&this._map.getTerrain()){const o=this._map.getFreeCameraOptions();if(o.position){const s=o.position.toLngLat();n=s.distanceTo(r)<.9*s.distanceTo(this._lngLat)}}const a=(1-this._map._queryFogOpacity(r))*(n?.2:1);this._element.style.opacity=`${a}`,this._popup&&this._popup._setOpacity(`${a}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_withinScreenBounds(i){const r=this._map.transform;return!!i&&i.x>=0&&i.x=0&&i.y{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),this._map._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(this._map.getTerrain()||this._map.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}_transformedOffset(){if(!this._defaultMarker)return this._offset;const i=this._map.transform,r=this._offset.mult(this._scale);return"map"===this._rotationAlignment&&r._rotate(i.angle),"map"===this._pitchAlignment&&(r.y*=Math.cos(i._pitch)),r}getOffset(){return this._offset}setOffset(r){return this._offset=i.pointGeometry.convert(r),this._update(),this}_onMove(r){if(!this._isDragging){const n=this._clickTolerance||this._map._clickTolerance;this._isDragging=r.point.dist(this._pointerdownPos)>=n}this._isDragging&&(this._pos=r.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new i.Event("dragstart"))),this.fire(new i.Event("drag")))}_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),"active"===this._state&&this.fire(new i.Event("dragend")),this._state="inactive"}_addDragHandler(i){this._element.contains(i.originalEvent.target)&&(i.preventDefault(),this._positionDelta=i.point.sub(this._pos).add(this._transformedOffset()),this._pointerdownPos=i.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))}setDraggable(i){return this._draggable=!!i,this._map&&(i?(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(i){return this._rotation=i||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(i){return this._rotationAlignment=i||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(i){return this._pitchAlignment=i&&"auto"!==i?i:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const{HTMLImageElement:ro,HTMLElement:rs,ImageBitmap:ra}=i.window;function rl(i){i.parentNode&&i.parentNode.removeChild(i)}class rc{constructor(r,n,o=!1){this._clickTolerance=10,this.element=n,this.mouseRotate=new iB({clickTolerance:r.dragRotate._mouseRotate._clickTolerance}),this.map=r,o&&(this.mousePitch=new iR({clickTolerance:r.dragRotate._mousePitch._clickTolerance})),i.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset",],this),n.addEventListener("mousedown",this.mousedown),n.addEventListener("touchstart",this.touchstart,{passive:!1}),n.addEventListener("touchmove",this.touchmove),n.addEventListener("touchend",this.touchend),n.addEventListener("touchcancel",this.reset)}down(i,r){this.mouseRotate.mousedown(i,r),this.mousePitch&&this.mousePitch.mousedown(i,r),l.disableDrag()}move(i,r){const n=this.map,o=this.mouseRotate.mousemoveWindow(i,r);if(o&&o.bearingDelta&&n.setBearing(n.getBearing()+o.bearingDelta),this.mousePitch){const s=this.mousePitch.mousemoveWindow(i,r);s&&s.pitchDelta&&n.setPitch(n.getPitch()+s.pitchDelta)}}off(){const i=this.element;i.removeEventListener("mousedown",this.mousedown),i.removeEventListener("touchstart",this.touchstart,{passive:!1}),i.removeEventListener("touchmove",this.touchmove),i.removeEventListener("touchend",this.touchend),i.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){l.enableDrag(),i.window.removeEventListener("mousemove",this.mousemove),i.window.removeEventListener("mouseup",this.mouseup)}mousedown(r){this.down(i.extend({},r,{ctrlKey:!0,preventDefault:()=>r.preventDefault()}),l.mousePos(this.element,r)),i.window.addEventListener("mousemove",this.mousemove),i.window.addEventListener("mouseup",this.mouseup)}mousemove(i){this.move(i,l.mousePos(this.element,i))}mouseup(i){this.mouseRotate.mouseupWindow(i),this.mousePitch&&this.mousePitch.mouseupWindow(i),this.offTemp()}touchstart(i){1!==i.targetTouches.length?this.reset():(this._startPos=this._lastPos=l.touchPos(this.element,i.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>i.preventDefault()},this._startPos))}touchmove(i){1!==i.targetTouches.length?this.reset():(this._lastPos=l.touchPos(this.element,i.targetTouches)[0],this.move({preventDefault:()=>i.preventDefault()},this._lastPos))}touchend(i){0===i.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)5280?rf(r,o,u/5280,i._getUIString("ScaleControl.Miles"),i):rf(r,o,u,i._getUIString("ScaleControl.Feet"),i)}else n&&"nautical"===n.unit?rf(r,o,c/1852,i._getUIString("ScaleControl.NauticalMiles"),i):c>=1e3?rf(r,o,c/1e3,i._getUIString("ScaleControl.Kilometers"),i):rf(r,o,c,i._getUIString("ScaleControl.Meters"),i)}function rf(i,r,n,o,s){const a=function(i){const r=Math.pow(10,`${Math.floor(i)}`.length-1);let n=i/r;return r*(n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:n>=1?1:function(i){const r=Math.pow(10,Math.ceil(-Math.log(i)/Math.LN10));return Math.round(i*r)/r}(n))}(n),l=a/n;s._requestDomTask(()=>{i.style.width=r*l+"px",i.innerHTML=`${a} ${o}`})}const rm={version:i.version,supported:r,setRTLTextPlugin:i.setRTLTextPlugin,getRTLTextPluginStatus:i.getRTLTextPluginStatus,Map:class extends iJ{constructor(r){if(null!=(r=i.extend({},{center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0},r)).minZoom&&null!=r.maxZoom&&r.minZoom>r.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(null!=r.minPitch&&null!=r.maxPitch&&r.minPitch>r.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(null!=r.minPitch&&r.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(null!=r.maxPitch&&r.maxPitch>85)throw Error("maxPitch must be less than or equal to 85");if(super(new ig(r.minZoom,r.maxZoom,r.minPitch,r.maxPitch,r.renderWorldCopies),r),this._interactive=r.interactive,this._minTileCacheSize=r.minTileCacheSize,this._maxTileCacheSize=r.maxTileCacheSize,this._failIfMajorPerformanceCaveat=r.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=r.preserveDrawingBuffer,this._antialias=r.antialias,this._trackResize=r.trackResize,this._bearingSnap=r.bearingSnap,this._refreshExpiredTiles=r.refreshExpiredTiles,this._fadeDuration=r.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=r.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=r.collectResourceTiming,this._optimizeForTerrain=r.optimizeForTerrain,this._renderTaskQueue=new rt,this._domRenderTaskQueue=new rt,this._controls=[],this._markers=[],this._mapId=i.uniqueId(),this._locale=i.extend({},{"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},r.locale),this._clickTolerance=r.clickTolerance,this._cooperativeGestures=r.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevation=new class{constructor(i){this.jumpTo(i)}getValue(r){if(r<=this._startTime)return this._start;if(r>=this._endTime)return this._end;const n=i.easeCubicInOut((r-this._startTime)/(this._endTime-this._startTime));return this._start*(1-n)+this._end*n}isEasing(i){return i>=this._startTime&&i<=this._endTime}jumpTo(i){this._startTime=-1/0,this._endTime=-1/0,this._start=i,this._end=i}easeTo(i,r,n){this._start=this.getValue(r),this._end=i,this._startTime=r,this._endTime=r+n}}(0),this._requestManager=new i.RequestManager(r.transformRequest,r.accessToken,r.testMode),this._silenceAuthErrors=!!r.testMode,"string"==typeof r.container){if(this._container=i.window.document.getElementById(r.container),!this._container)throw Error(`Container '${r.container}' not found.`)}else{if(!(r.container instanceof rs))throw Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=r.container}if(this._container.childNodes.length>0&&i.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),r.maxBounds&&this.setMaxBounds(r.maxBounds),i.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored",],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),void 0!==i.window&&(i.window.addEventListener("online",this._onWindowOnline,!1),i.window.addEventListener("resize",this._onWindowResize,!1),i.window.addEventListener("orientationchange",this._onWindowResize,!1),i.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new class{constructor(r,n){this._map=r,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new class{constructor(i){this._map=i,this.clear()}clear(){this._inertiaBuffer=[]}record(r){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:i.exported.now(),settings:r})}_drainInertiaBuffer(){const r=this._inertiaBuffer,n=i.exported.now();for(;r.length>0&&n-r[0].time>160;)r.shift()}_onMoveEnd(r){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new i.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:o}of this._inertiaBuffer)n.zoom+=o.zoomDelta||0,n.bearing+=o.bearingDelta||0,n.pitch+=o.pitchDelta||0,o.panDelta&&n.pan._add(o.panDelta),o.around&&(n.around=o.around),o.pinchAround&&(n.pinchAround=o.pinchAround);const s=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,a={};if(n.pan.mag()){const l=i0(n.pan.mag(),s,i.extend({},i$,r||{}));a.offset=n.pan.mult(l.amount/n.pan.mag()),a.center=this._map.transform.center,iw(a,l)}if(n.zoom){const c=i0(n.zoom,s,iv);a.zoom=this._map.transform.zoom+c.amount,iw(a,c)}if(n.bearing){const u=i0(n.bearing,s,i_);a.bearing=this._map.transform.bearing+i.clamp(u.amount,-179,179),iw(a,u)}if(n.pitch){const h=i0(n.pitch,s,ib);a.pitch=this._map.transform.pitch+h.amount,iw(a,h)}if(a.zoom||a.bearing){const d=void 0===n.pinchAround?n.around:n.pinchAround;a.around=d?this._map.unproject(d):this._map.getCenter()}return this.clear(),i.extend(a,{noMoveStart:!0})}}(r),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new class{constructor(){this.constants=[1,1,.01],this.radius=0}setup(r,n){const o=i.sub([],n,r);this.radius=i.length(o[2]<0?i.div([],o,this.constants):[o[0],o[1],0])}projectRay(r){i.div(r,r,this.constants),i.normalize(r,r),i.mul$1(r,r,this.constants);const n=i.scale$2([],r,this.radius);if(n[2]>0){const o=i.scale$2([],[0,0,1],i.dot(n,[0,0,1])),s=i.scale$2([],i.normalize([],[n[0],n[1],0]),this.radius),a=i.add([],n,i.scale$2([],i.sub([],i.add([],s,o),n),2));n[0]=a[0],n[1]=a[1]}return n}},this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(n),i.bindAll(["handleEvent","handleWindowEvent"],this);const o=this._el;for(const[s,a,l]of(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],[i.window.document,"mousemove",{capture:!0},],[i.window.document,"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],[i.window,"blur",void 0],],this._listeners))s.addEventListener(a,s===i.window.document?this.handleWindowEvent:this.handleEvent,l)}destroy(){for(const[r,n,o]of this._listeners)r.removeEventListener(n,r===i.window.document?this.handleWindowEvent:this.handleEvent,o)}_addDefaultHandlers(i){const r=this._map,n=r.getCanvasContainer();this._add("mapEvent",new iI(r,i));const o=r.boxZoom=new iz(r,i);this._add("boxZoom",o);const s=new iP,a=new i9;r.doubleClickZoom=new iZ(a,s),this._add("tapZoom",s),this._add("clickZoom",a);const l=new i7;this._add("tapDragZoom",l);const c=r.touchPitch=new i6(r);this._add("touchPitch",c);const u=new iB(i),h=new iR(i);r.dragRotate=new i5(i,u,h),this._add("mouseRotate",u,["mousePitch"]),this._add("mousePitch",h,["mouseRotate"]);const d=new i1(i),p=new i3(r,i);r.dragPan=new iq(n,d,p),this._add("mousePan",d),this._add("touchPan",p,["touchZoom","touchRotate",]);const f=new iU,m=new iO;r.touchZoomRotate=new iX(n,m,f,l),this._add("touchRotate",f,["touchPan","touchZoom",]),this._add("touchZoom",m,["touchPan","touchRotate",]),this._add("blockableMapEvent",new iC(r));const g=r.scrollZoom=new iG(r,this);this._add("scrollZoom",g,["mousePan"]);const y=r.keyboard=new ij;for(const x of(this._add("keyboard",y),["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard",]))i.interactive&&i[x]&&r[x].enable(i[x])}_add(i,r,n){this._handlers.push({handlerName:i,handler:r,allowed:n}),this._handlersById[i]=r}stop(i){if(!this._updatingCamera){for(const{handler:r}of this._handlers)r.reset();this._inertia.clear(),this._fireEvents({},{},i),this._changes=[]}}isActive(){for(const{handler:i}of this._handlers)if(i.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(iW(this._eventsInProgress))||this.isZooming()}_blockedByActive(i,r,n){for(const o in i)if(o!==n&&(!r||0>r.indexOf(o)))return!0;return!1}handleWindowEvent(i){this.handleEvent(i,`${i.type}Window`)}_getMapTouches(i){const r=[];for(const n of i)this._el.contains(n.target)&&r.push(n);return r}handleEvent(i,r){this._updatingCamera=!0;const n="renderFrame"===i.type,o=n?void 0:i,s={needsRenderFrame:!1},a={},c={},u=i.touches?this._getMapTouches(i.touches):void 0,h=u?l.touchPos(this._el,u):n?void 0:l.mousePos(this._el,i);for(const{handlerName:d,handler:p,allowed:f}of this._handlers){if(!p.isEnabled())continue;let m;this._blockedByActive(c,f,d)?p.reset():p[r||i.type]&&(m=p[r||i.type](i,h,u),this.mergeHandlerResult(s,a,m,d,o),m&&m.needsRenderFrame&&this._triggerRenderFrame()),(m||p.isActive())&&(c[d]=p)}const g={};for(const y in this._previousActiveHandlers)c[y]||(g[y]=o);this._previousActiveHandlers=c,(Object.keys(g).length||iK(s))&&(this._changes.push([s,a,g]),this._triggerRenderFrame()),(Object.keys(c).length||iK(s))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:x}=s;x&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],x(this._map))}mergeHandlerResult(r,n,o,s,a){if(!o)return;i.extend(r,o);const l={handlerName:s,originalEvent:o.originalEvent||a};void 0!==o.zoomDelta&&(n.zoom=l),void 0!==o.panDelta&&(n.drag=l),void 0!==o.pitchDelta&&(n.pitch=l),void 0!==o.bearingDelta&&(n.rotate=l)}_applyChanges(){const r={},n={},o={};for(const[s,a,l]of this._changes)s.panDelta&&(r.panDelta=(r.panDelta||new i.pointGeometry(0,0))._add(s.panDelta)),s.zoomDelta&&(r.zoomDelta=(r.zoomDelta||0)+s.zoomDelta),s.bearingDelta&&(r.bearingDelta=(r.bearingDelta||0)+s.bearingDelta),s.pitchDelta&&(r.pitchDelta=(r.pitchDelta||0)+s.pitchDelta),void 0!==s.around&&(r.around=s.around),void 0!==s.aroundCoord&&(r.aroundCoord=s.aroundCoord),void 0!==s.pinchAround&&(r.pinchAround=s.pinchAround),s.noInertia&&(r.noInertia=s.noInertia),i.extend(n,a),i.extend(o,l);this._updateMapTransform(r,n,o),this._changes=[]}_updateMapTransform(r,n,o){const s=this._map,a=s.transform,l=i=>[i.x,i.y,i.z];if((i=>{const r=this._eventsInProgress.drag;return r&&!this._handlersById[r.handlerName].isActive()})()&&!iK(r)){const c=a.zoom;a.cameraElevationReference="sea",a.recenterOnTerrain(),a.cameraElevationReference="ground",c!==a.zoom&&this._map._update(!0)}if(!iK(r))return this._fireEvents(n,o,!0);let{panDelta:u,zoomDelta:h,bearingDelta:d,pitchDelta:p,around:f,aroundCoord:m,pinchAround:g}=r;void 0!==g&&(f=g),n.drag&&!this._eventsInProgress.drag&&f&&(this._dragOrigin=l(a.pointCoordinate3D(f)),this._trackingEllipsoid.setup(a._camera.position,this._dragOrigin)),a.cameraElevationReference="sea",s._stop(!0),f=f||s.transform.centerPoint,d&&(a.bearing+=d),p&&(a.pitch+=p),a._updateCameraState();const y=[0,0,0];if(u){const x=a.pointCoordinate(f),$=a.pointCoordinate(f.sub(u));x&&$&&(y[0]=$.x-x.x,y[1]=$.y-x.y)}const v=a.zoom,_=[0,0,0];if(h){const b=l(m||a.pointCoordinate3D(f)),w={dir:i.normalize([],i.sub([],b,a._camera.position))};if(w.dir[2]<0){const T=a.zoomDeltaToMovement(b,h);i.scale$2(_,w.dir,T)}}const E=i.add(y,y,_);a._translateCameraConstrained(E),h&&Math.abs(a.zoom-v)>1e-4&&a.recenterOnTerrain(),a.cameraElevationReference="ground",this._map._update(),r.noInertia||this._inertia.record(r),this._fireEvents(n,o,!0)}_fireEvents(r,n,o){const s=iW(this._eventsInProgress),a=iW(r),l={};for(const c in r){const{originalEvent:u}=r[c];this._eventsInProgress[c]||(l[`${c}start`]=u),this._eventsInProgress[c]=r[c]}for(const h in!s&&a&&this._fireEvent("movestart",a.originalEvent),l)this._fireEvent(h,l[h]);for(const d in a&&this._fireEvent("move",a.originalEvent),r){const{originalEvent:p}=r[d];this._fireEvent(d,p)}const f={};let m;for(const g in this._eventsInProgress){const{handlerName:y,originalEvent:x}=this._eventsInProgress[g];this._handlersById[y].isActive()||(delete this._eventsInProgress[g],m=n[y]||x,f[`${g}end`]=m)}for(const $ in f)this._fireEvent($,f[$]);const v=iW(this._eventsInProgress);if(o&&(s||a)&&!v){var _,b;this._updatingCamera=!0;const w=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions);w?(0!==(_=w.bearing||this._map.getBearing())&&-this._bearingSnap<_&&_{delete this._frameId,this.handleEvent(new iH("renderFrame",{timeStamp:i})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}(this,r),this._localFontFamily=r.localFontFamily,this._localIdeographFontFamily=r.localIdeographFontFamily,r.style&&this.setStyle(r.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),r.projection&&this.setProjection(r.projection),this._hash=r.hash&&new class{constructor(r){this._hashName=r&&encodeURIComponent(r),i.bindAll(["_getCurrentHash","_onHashChange","_updateHash",],this),this._updateHash=iy(this._updateHashUnthrottled.bind(this),300)}addTo(r){return this._map=r,i.window.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return i.window.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(r){const n=this._map.getCenter(),o=Math.round(100*this._map.getZoom())/100,s=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),a=Math.pow(10,s),l=Math.round(n.lng*a)/a,c=Math.round(n.lat*a)/a,u=this._map.getBearing(),h=this._map.getPitch();let d="";if(d+=r?`/${l}/${c}/${o}`:`${o}/${c}/${l}`,(u||h)&&(d+="/"+Math.round(10*u)/10),h&&(d+=`/${Math.round(h)}`),this._hashName){const p=this._hashName;let f=!1;const m=i.window.location.hash.slice(1).split("&").map(i=>{const r=i.split("=")[0];return r===p?(f=!0,`${r}=${d}`):i}).filter(i=>i);return f||m.push(`${p}=${d}`),`#${m.join("&")}`}return`#${d}`}_getCurrentHash(){const r=i.window.location.hash.replace("#","");if(this._hashName){let n;return r.split("&").map(i=>i.split("=")).forEach(i=>{i[0]===this._hashName&&(n=i)}),(n&&n[1]||"").split("/")}return r.split("/")}_onHashChange(){const i=this._getCurrentHash();if(i.length>=3&&!i.some(i=>isNaN(i))){const r=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(i[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+i[2],+i[1]],zoom:+i[0],bearing:r,pitch:+(i[4]||0)}),!0}return!1}_updateHashUnthrottled(){const r=i.window.location.href.replace(/(#.+)?$/,this.getHashString());i.window.history.replaceState(i.window.history.state,null,r)}}("string"==typeof r.hash&&r.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch}),r.bounds&&(this.resize(),this.fitBounds(r.bounds,i.extend({},r.fitBoundsOptions,{duration:0})))),this.resize(),r.attributionControl&&this.addControl(new iQ({customAttribution:r.customAttribution})),this._logoControl=new re,this.addControl(this._logoControl,r.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",r=>{this._update("style"===r.dataType),this.fire(new i.Event(`${r.dataType}data`,r))}),this.on("dataloading",r=>{this.fire(new i.Event(`${r.dataType}dataloading`,r))})}_getMapId(){return this._mapId}addControl(r,n){if(void 0===n&&(n=r.getDefaultPosition?r.getDefaultPosition():"top-right"),!r||!r.onAdd)return this.fire(new i.ErrorEvent(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const o=r.onAdd(this);this._controls.push(r);const s=this._controlPositions[n];return -1!==n.indexOf("bottom")?s.insertBefore(o,s.firstChild):s.appendChild(o),this}removeControl(r){if(!r||!r.onRemove)return this.fire(new i.ErrorEvent(Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const n=this._controls.indexOf(r);return n>-1&&this._controls.splice(n,1),r.onRemove(this),this}hasControl(i){return this._controls.indexOf(i)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(r){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const n=!this._moving;return n&&this.fire(new i.Event("movestart",r)).fire(new i.Event("move",r)),this.fire(new i.Event("resize",r)),n&&this.fire(new i.Event("moveend",r)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(r){return this.transform.setMaxBounds(i.LngLatBounds.convert(r)),this._update()}setMinZoom(r){if((r=null==r?-2:r)>=-2&&r<=this.transform.maxZoom)return this.transform.minZoom=r,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=r,this._update(),this.getZoom()>r?this.setZoom(r):this.fire(new i.Event("zoomstart")).fire(new i.Event("zoom")).fire(new i.Event("zoomend")),this;throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(r){if((r=null==r?0:r)<0)throw Error("minPitch must be greater than or equal to 0");if(r>=0&&r<=this.transform.maxPitch)return this.transform.minPitch=r,this._update(),this.getPitch()85)throw Error("maxPitch must be less than or equal to 85");if(r>=this.transform.minPitch)return this.transform.maxPitch=r,this._update(),this.getPitch()>r?this.setPitch(r):this.fire(new i.Event("pitchstart")).fire(new i.Event("pitch")).fire(new i.Event("pitchend")),this;throw Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(i){return this.transform.renderWorldCopies=i,this._update()}getProjection(){return this.transform.getProjection()}setProjection(i){return this._lazyInitEmptyStyle(),"string"==typeof i&&(i={name:i}),this._runtimeProjection=i,this.style.updateProjection(),this._transitionFromGlobe=!1,this}project(r){return this.transform.locationPoint3D(i.LngLat.convert(r))}unproject(r){return this.transform.pointLocation3D(i.pointGeometry.convert(r))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()}_createDelegatedListener(i,r,n){if("mouseenter"===i||"mouseover"===i){let o=!1;const s=s=>{const a=r.filter(i=>this.getLayer(i)),l=a.length?this.queryRenderedFeatures(s.point,{layers:a}):[];l.length?o||(o=!0,n.call(this,new iT(i,this,s.originalEvent,{features:l}))):o=!1},a=()=>{o=!1};return{layers:new Set(r),listener:n,delegates:{mousemove:s,mouseout:a}}}if("mouseleave"===i||"mouseout"===i){let l=!1;const c=o=>{const s=r.filter(i=>this.getLayer(i));(s.length?this.queryRenderedFeatures(o.point,{layers:s}):[]).length?l=!0:l&&(l=!1,n.call(this,new iT(i,this,o.originalEvent)))},u=r=>{l&&(l=!1,n.call(this,new iT(i,this,r.originalEvent)))};return{layers:new Set(r),listener:n,delegates:{mousemove:c,mouseout:u}}}{const h=i=>{const o=r.filter(i=>this.getLayer(i)),s=o.length?this.queryRenderedFeatures(i.point,{layers:o}):[];s.length&&(i.features=s,n.call(this,i),delete i.features)};return{layers:new Set(r),listener:n,delegates:{[i]:h}}}}on(i,r,n){if(void 0===n)return super.on(i,r);Array.isArray(r)||(r=[r]);const o=this._createDelegatedListener(i,r,n);for(const s in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[i]=this._delegatedListeners[i]||[],this._delegatedListeners[i].push(o),o.delegates)this.on(s,o.delegates[s]);return this}once(i,r,n){if(void 0===n)return super.once(i,r);Array.isArray(r)||(r=[r]);const o=this._createDelegatedListener(i,r,n);for(const s in o.delegates)this.once(s,o.delegates[s]);return this}off(i,r,n){if(void 0===n)return super.off(i,r);r=new Set(Array.isArray(r)?r:[r]);const o=(i,r)=>{if(i.size!==r.size)return!1;for(const n of i)if(!r.has(n))return!1;return!0},s=this._delegatedListeners?this._delegatedListeners[i]:void 0;return s&&(i=>{for(let s=0;s{r?this.fire(new i.ErrorEvent(r)):o&&this._updateDiff(o,n)})}else"object"==typeof r&&this._updateDiff(r,n)}_updateDiff(r,n){try{this.style.setState(r)&&this._update(!0)}catch(o){i.warnOnce(`Unable to perform style diff: ${o.message||o.error||o}. Rebuilding the style from scratch.`),this._updateStyle(r,n)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():i.warnOnce("There is no style added to the map.")}addSource(i,r){return this._lazyInitEmptyStyle(),this.style.addSource(i,r),this._update(!0)}isSourceLoaded(r){const n=this.style&&this.style._getSourceCaches(r);if(0!==n.length)return n.every(i=>i.loaded());this.fire(new i.ErrorEvent(Error(`There is no source with ID '${r}'`)))}areTilesLoaded(){const i=this.style&&this.style._sourceCaches;for(const r in i){const n=i[r]._tiles;for(const o in n){const s=n[o];if("loaded"!==s.state&&"errored"!==s.state)return!1}}return!0}addSourceType(i,r,n){return this._lazyInitEmptyStyle(),this.style.addSourceType(i,r,n)}removeSource(i){return this.style.removeSource(i),this._updateTerrain(),this._update(!0)}getSource(i){return this.style.getSource(i)}addImage(r,n,{pixelRatio:o=1,sdf:s=!1,stretchX:a,stretchY:l,content:c}={}){if(this._lazyInitEmptyStyle(),n instanceof ro||ra&&n instanceof ra){const{width:u,height:h,data:d}=i.exported.getImageData(n);this.style.addImage(r,{data:new i.RGBAImage({width:u,height:h},d),pixelRatio:o,stretchX:a,stretchY:l,content:c,sdf:s,version:0})}else{if(void 0===n.width||void 0===n.height)return this.fire(new i.ErrorEvent(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:p,height:f,data:m}=n,g=n;this.style.addImage(r,{data:new i.RGBAImage({width:p,height:f},new Uint8Array(m)),pixelRatio:o,stretchX:a,stretchY:l,content:c,sdf:s,version:0,userImage:g}),g.onAdd&&g.onAdd(this,r)}}}updateImage(r,n){const o=this.style.getImage(r);if(!o)return this.fire(new i.ErrorEvent(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const s=n instanceof ro||ra&&n instanceof ra?i.exported.getImageData(n):n,{width:a,height:l,data:c}=s;return void 0===a||void 0===l?this.fire(new i.ErrorEvent(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`"))):a!==o.data.width||l!==o.data.height?this.fire(new i.ErrorEvent(Error("The width and height of the updated image must be that same as the previous version of the image"))):(o.data.replace(c,!(n instanceof ro||ra&&n instanceof ra)),void this.style.updateImage(r,o))}hasImage(r){return r?!!this.style.getImage(r):(this.fire(new i.ErrorEvent(Error("Missing required image id"))),!1)}removeImage(i){this.style.removeImage(i)}loadImage(r,n){i.getImage(this._requestManager.transformRequest(r,i.ResourceType.Image),(r,o)=>{n(r,o instanceof ro?i.exported.getImageData(o):o)})}listImages(){return this.style.listImages()}addLayer(i,r){return this._lazyInitEmptyStyle(),this.style.addLayer(i,r),this._update(!0)}moveLayer(i,r){return this.style.moveLayer(i,r),this._update(!0)}removeLayer(i){return this.style.removeLayer(i),this._update(!0)}getLayer(i){return this.style.getLayer(i)}setLayerZoomRange(i,r,n){return this.style.setLayerZoomRange(i,r,n),this._update(!0)}setFilter(i,r,n={}){return this.style.setFilter(i,r,n),this._update(!0)}getFilter(i){return this.style.getFilter(i)}setPaintProperty(i,r,n,o={}){return this.style.setPaintProperty(i,r,n,o),this._update(!0)}getPaintProperty(i,r){return this.style.getPaintProperty(i,r)}setLayoutProperty(i,r,n,o={}){return this.style.setLayoutProperty(i,r,n,o),this._update(!0)}getLayoutProperty(i,r){return this.style.getLayoutProperty(i,r)}setLight(i,r={}){return this._lazyInitEmptyStyle(),this.style.setLight(i,r),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(i){return this._lazyInitEmptyStyle(),!i&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(i),this._averageElevationLastSampledAt=-1/0,this._update(!0)}_updateProjection(){"globe"===this.transform.projection.name&&this.transform.zoom>=i.GLOBE_ZOOM_THRESHOLD_MAX&&!this._transitionFromGlobe&&(this.setProjection({name:"mercator"}),this._transitionFromGlobe=!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(i){return this._lazyInitEmptyStyle(),this.style.setFog(i),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(r){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(i.LngLat.convert(r),this.transform):0}setFeatureState(i,r){return this.style.setFeatureState(i,r),this._update()}removeFeatureState(i,r){return this.style.removeFeatureState(i,r),this._update()}getFeatureState(i){return this.style.getFeatureState(i)}_updateContainerDimensions(){if(!this._container)return;const r=this._container.getBoundingClientRect().width||400,n=this._container.getBoundingClientRect().height||300;let o,s=this._container;for(;s&&!o;){const a=i.window.getComputedStyle(s).transform;a&&"none"!==a&&(o=a.match(/matrix.*\((.+)\)/)[1].split(", ")),s=s.parentElement}o?(this._containerWidth=o[0]&&"0"!==o[0]?Math.abs(r/o[0]):r,this._containerHeight=o[3]&&"0"!==o[3]?Math.abs(n/o[3]):n):(this._containerWidth=r,this._containerHeight=n)}_detectMissingCSS(){"rgb(250, 128, 114)"!==i.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&i.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const i=this._container;i.classList.add("mapboxgl-map"),(this._missingCSSCanary=l.create("div","mapboxgl-canary",i)).style.visibility="hidden",this._detectMissingCSS();const r=this._canvasContainer=l.create("div","mapboxgl-canvas-container",i);this._interactive&&r.classList.add("mapboxgl-interactive"),this._canvas=l.create("canvas","mapboxgl-canvas",r),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const n=this._controlContainer=l.create("div","mapboxgl-control-container",i),o=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right",].forEach(i=>{o[i]=l.create("div",`mapboxgl-ctrl-${i}`,n)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(r,n){const o=i.exported.devicePixelRatio||1;this._canvas.width=o*Math.ceil(r),this._canvas.height=o*Math.ceil(n),this._canvas.style.width=`${r}px`,this._canvas.style.height=`${n}px`}_addMarker(i){this._markers.push(i)}_removeMarker(i){const r=this._markers.indexOf(i);-1!==r&&this._markers.splice(r,1)}_setupPainter(){const n=i.extend({},r.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),o=this._canvas.getContext("webgl",n)||this._canvas.getContext("experimental-webgl",n);o?(i.storeAuthState(o,!0),this.painter=new it(o,this.transform),this.on("data",i=>{"source"===i.dataType&&this.painter.setTileLoadedFlag(!0)}),i.exported$1.testSupport(o)):this.fire(new i.ErrorEvent(Error("Failed to initialize WebGL")))}_contextLost(r){r.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.Event("webglcontextlost",{originalEvent:r}))}_contextRestored(r){this._setupPainter(),this.resize(),this._update(),this.fire(new i.Event("webglcontextrestored",{originalEvent:r}))}_onMapScroll(i){if(i.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(i){return this.style&&(this._styleDirty=this._styleDirty||i,this._sourcesDirty=!0,this.triggerRepaint()),this}_requestRenderFrame(i){return this._update(),this._renderTaskQueue.add(i)}_cancelRenderFrame(i){this._renderTaskQueue.remove(i)}_requestDomTask(i){!this.loaded()||this.loaded()&&!this.isMoving()?i():this._domRenderTaskQueue.add(i)}_render(r){let n;const o=this.painter.context.extTimerQuery,s=i.exported.now();this.listens("gpu-timing-frame")&&(n=o.createQueryEXT(),o.beginQueryEXT(o.TIME_ELAPSED_EXT,n));let a=this._updateAverageElevation(s);if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(r),this._domRenderTaskQueue.run(r),this._removed)return;this._updateProjection();let l=!1;const c=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const u=this.transform.zoom,h=this.transform.pitch,d=i.exported.now();this.style.zoomHistory.update(u,d);const p=new i.EvaluationParameters(u,{now:d,fadeDuration:c,pitch:h,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),f=p.crossFadingFactor();1===f&&f===this._crossFadingFactor||(l=!0,this._crossFadingFactor=f),this.style.update(p)}if(this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0),this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),this.style._updateSources(this.transform),this._forceMarkerUpdate()),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,c,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:c,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new i.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new i.Event("load"))),this.style&&(this.style.hasTransitions()||l)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const m=i.exported.now()-s;o.endQueryEXT(o.TIME_ELAPSED_EXT,n),setTimeout(()=>{const r=o.getQueryObjectEXT(n,o.QUERY_RESULT_EXT)/1e6;o.deleteQueryEXT(n),this.fire(new i.Event("gpu-timing-frame",{cpuTime:m,gpuTime:r}))},50)}if(this.listens("gpu-timing-layer")){const g=this.painter.collectGpuTimers();setTimeout(()=>{const r=this.painter.queryGpuTimers(g);this.fire(new i.Event("gpu-timing-layer",{layerTimes:r}))},50)}const y=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(y||this._repaint)this.triggerRepaint();else{const x=!this.isMoving()&&this.loaded();if(x&&(a=this._updateAverageElevation(s,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),x&&(this.fire(new i.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const $=this._calculateSpeedIndex();this.fire(new i.Event("speedindexcompleted",{speedIndex:$})),this.speedIndexTiming=!1}}return!this._loaded||this._fullyLoaded||y||(this._fullyLoaded=!0,this._authenticate()),this}_forceMarkerUpdate(){for(const i of this._markers)i._update()}_updateAverageElevation(i,r=!1){const n=i=>(this.transform.averageElevation=i,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&n(0);if((r||i-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(i)){const o=this.transform.averageElevation;let s=this.transform.sampleAverageElevation();isNaN(s)?s=0:this._averageElevationLastSampledAt=i;const a=Math.abs(o-s);if(a>1){if(this._isInitialLoad)return this._averageElevation.jumpTo(s),n(s);this._averageElevation.easeTo(s,i,300)}else if(a>1e-4)return this._averageElevation.jumpTo(s),n(s)}return!!this._averageElevation.isEasing(i)&&n(this._averageElevation.getValue(i))}_authenticate(){i.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,r=>{if(r&&(r.message===i.AUTH_ERR_MSG||401===r.status)){const n=this.painter.context.gl;i.storeAuthState(n,!1),this._logoControl instanceof re&&this._logoControl._updateLogo(),n&&n.clear(n.DEPTH_BUFFER_BIT|n.COLOR_BUFFER_BIT|n.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new i.ErrorEvent(Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),i.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const i=this.painter.canvasCopy(),r=this.painter.getCanvasCopiesAndTimestamps();r.timeStamps.push(performance.now());const n=this.painter.context.gl,o=n.createFramebuffer();function s(i){n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,i,0);const r=new Uint8Array(n.drawingBufferWidth*n.drawingBufferHeight*4);return n.readPixels(0,0,n.drawingBufferWidth,n.drawingBufferHeight,n.RGBA,n.UNSIGNED_BYTE,r),r}return n.bindFramebuffer(n.FRAMEBUFFER,o),this._canvasPixelComparison(s(i),r.canvasCopies.map(s),r.timeStamps)}_canvasPixelComparison(i,r,n){let o=n[1]-n[0];const s=i.length/4;for(let a=0;a{const r=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,r&&this._render(i)}))}_preloadTiles(r){const n=this.style&&Object.values(this.style._sourceCaches)||[];return i.asyncAll(n,(i,n)=>i._preloadTiles(r,n),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(i){this._trackResize&&this.resize({originalEvent:i})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(i){this._showTileBoundaries!==i&&(this._showTileBoundaries=i,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(i){this._showTerrainWireframe!==i&&(this._showTerrainWireframe=i,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(i){this._speedIndexTiming!==i&&(this._speedIndexTiming=i,this._update())}get showPadding(){return!!this._showPadding}set showPadding(i){this._showPadding!==i&&(this._showPadding=i,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(i){this._showCollisionBoxes!==i&&(this._showCollisionBoxes=i,i?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(i){this._showOverdrawInspector!==i&&(this._showOverdrawInspector=i,this._update())}get repaint(){return!!this._repaint}set repaint(i){this._repaint!==i&&(this._repaint=i,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(i){this._vertices=i,this._update()}_setCacheLimits(r,n){i.setCacheLimits(r,n)}get version(){return i.version}},NavigationControl:class{constructor(r){this.options=i.extend({},{showCompass:!0,showZoom:!0,visualizePitch:!1},r),this._container=l.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",i=>i.preventDefault()),this.options.showZoom&&(i.bindAll(["_setButtonTitle","_updateZoomButtons",],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",i=>this._map.zoomIn({},{originalEvent:i})),l.create("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden",!0),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",i=>this._map.zoomOut({},{originalEvent:i})),l.create("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden",!0)),this.options.showCompass&&(i.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",i=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:i}):this._map.resetNorth({},{originalEvent:i})}),this._compassIcon=l.create("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden",!0))}_updateZoomButtons(){const i=this._map.getZoom(),r=i===this._map.getMaxZoom(),n=i===this._map.getMinZoom();this._zoomInButton.disabled=r,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute("aria-disabled",r.toString()),this._zoomOutButton.setAttribute("aria-disabled",n.toString())}_rotateCompassArrow(){const i=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._map._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=i)})}onAdd(i){return this._map=i,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._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new rc(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(i,r){const n=l.create("button",i,this._container);return n.type="button",n.addEventListener("click",r),n}_setButtonTitle(i,r){const n=this._map._getUIString(`NavigationControl.${r}`);i.setAttribute("aria-label",n),i.firstElementChild&&i.firstElementChild.setAttribute("title",n)}},GeolocateControl:class extends i.Evented{constructor(r){super(),this.options=i.extend({},{positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},r),i.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation",],this),this._onDeviceOrientationListener=this._onDeviceOrientation.bind(this),this._updateMarkerRotationThrottled=iy(this._updateMarkerRotation,20)}onAdd(r){var n;return this._map=r,this._container=l.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),n=this._setupUI,void 0!==ru?n(ru):void 0!==i.window.navigator.permissions?i.window.navigator.permissions.query({name:"geolocation"}).then(i=>{n(ru="denied"!==i.state)}):n(ru=!!i.window.navigator.geolocation),this._container}onRemove(){void 0!==this._geolocationWatchID&&(i.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(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,rh=0,rd=!1}_isOutOfMapMaxBounds(i){const r=this._map.getMaxBounds(),n=i.coords;return r&&(n.longituder.getEast()||n.latituder.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(r){if(this._map){if(this._isOutOfMapMaxBounds(r))return this._setErrorState(),this.fire(new i.Event("outofmaxbounds",r)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=r,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(r),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(r),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new i.Event("geolocate",r)),this._finish()}}_updateCamera(r){const n=new i.LngLat(r.coords.longitude,r.coords.latitude),o=r.coords.accuracy,s=this._map.getBearing(),a=i.extend({bearing:s},this.options.fitBoundsOptions);this._map.fitBounds(n.toBounds(o),a,{geolocateSource:!0})}_updateMarker(r){if(r){const n=new i.LngLat(r.coords.longitude,r.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=r.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const i=this._map._containerHeight/2,r=this._map.unproject([0,i]),n=this._map.unproject([100,i]),o=r.distanceTo(n)/100,s=Math.ceil(2*this._accuracy/o);this._circleElement.style.width=`${s}px`,this._circleElement.style.height=`${s}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(r){if(this._map){if(this.options.trackUserLocation){if(1===r.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",n),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",n),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===r.code&&rd)return;this._setErrorState()}}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new i.Event("error",r)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(r){if(this._container.addEventListener("contextmenu",i=>i.preventDefault()),this._geolocateButton=l.create("button","mapboxgl-ctrl-geolocate",this._container),l.create("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden",!0),this._geolocateButton.type="button",!1===r){i.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",n),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",n)}else{const o=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",o),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",o)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=l.create("div","mapboxgl-user-location"),this._dotElement.appendChild(l.create("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(l.create("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new rn({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=l.create("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new rn({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",r=>{r.geolocateSource||"ACTIVE_LOCK"!==this._watchState||r.originalEvent&&"resize"===r.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new i.Event("trackuserlocationend")))})}_onDeviceOrientation(i){this._userLocationDotMarker&&(i.webkitCompassHeading?this._heading=i.webkitCompassHeading:!0===i.absolute&&(this._heading=-1*i.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return i.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new i.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":rh--,rd=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new i.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new i.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let r;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),++rh>1?(r={maximumAge:6e5,timeout:0},rd=!0):(r=this.options.positionOptions,rd=!1),this._geolocationWatchID=i.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,r),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else i.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const r=()=>{i.window.addEventListener("ondeviceorientationabsolute"in i.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientationListener)};void 0!==i.window.DeviceMotionEvent&&"function"==typeof i.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(i=>{"granted"===i&&r()}).catch(console.error):r()}_clearWatch(){i.window.navigator.geolocation.clearWatch(this._geolocationWatchID),i.window.removeEventListener("deviceorientation",this._onDeviceOrientationListener),i.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientationListener),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:iQ,ScaleControl:class{constructor(r){this.options=i.extend({},{maxWidth:100,unit:"metric"},r),i.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){rp(this._map,this._container,this.options)}onAdd(i){return this._map=i,this._container=l.create("div","mapboxgl-ctrl mapboxgl-ctrl-scale",i.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}setUnit(i){this.options.unit=i,rp(this._map,this._container,this.options)}},FullscreenControl:class{constructor(r){this._fullscreen=!1,r&&r.container&&(r.container instanceof i.window.HTMLElement?this._container=r.container:i.warnOnce("Full screen control 'container' must be a DOM element.")),i.bindAll(["_onClickFullscreen","_changeIcon",],this),"onfullscreenchange"in i.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in i.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(r){return this._map=r,this._container||(this._container=this._map.getContainer()),this._controlContainer=l.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,i.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!i.window.document.fullscreenEnabled&&!i.window.document.webkitFullscreenEnabled)}_setupUI(){const r=this._fullscreenButton=l.create("button","mapboxgl-ctrl-fullscreen",this._controlContainer);l.create("span","mapboxgl-ctrl-icon",r).setAttribute("aria-hidden",!0),r.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),i.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const i=this._getTitle();this._fullscreenButton.setAttribute("aria-label",i),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",i)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(i.window.document.fullscreenElement||i.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?i.window.document.exitFullscreen?i.window.document.exitFullscreen():i.window.document.webkitCancelFullScreen&&i.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends i.Evented{constructor(r){super(),this.options=i.extend(Object.create({closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"}),r),i.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag",],this),this._classList=new Set(r&&r.className?r.className.trim().split(/\s+/):[])}addTo(r){return this._map&&this.remove(),this._map=r,this.options.closeOnClick&&this._map.on("preclick",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._map._canvasContainer.classList.add("mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new i.Event("open")),this}isOpen(){return!!this._map}remove(){return this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new i.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(r){return this._lngLat=i.LngLat.convert(r),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._map._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(r){return this.setDOMContent(i.window.document.createTextNode(r))}setHTML(r){const n=i.window.document.createDocumentFragment(),o=i.window.document.createElement("body");let s;for(o.innerHTML=r;s=o.firstChild;)n.appendChild(s);return this.setDOMContent(n)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(i){return this.options.maxWidth=i,this._update(),this}setDOMContent(i){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=l.create("div","mapboxgl-popup-content",this._container);return this._content.appendChild(i),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(i){return this._classList.add(i),this._container&&this._updateClassList(),this}removeClassName(i){return this._classList.delete(i),this._container&&this._updateClassList(),this}setOffset(i){return this.options.offset=i,this._update(),this}toggleClassName(i){let r;return this._classList.delete(i)?r=!1:(this._classList.add(i),r=!0),this._container&&this._updateClassList(),r}_createCloseButton(){this.options.closeButton&&(this._closeButton=l.create("button","mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.setAttribute("aria-hidden","true"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(i){this._update(i.point)}_onMouseMove(i){this._update(i.point)}_onDrag(i){this._update(i.point)}_getAnchor(i){if(this.options.anchor)return this.options.anchor;const r=this._pos,n=this._container.offsetWidth,o=this._container.offsetHeight;let s;return s=r.y+i.bottom.ythis._map.transform.height-o?["bottom"]:[],r.xthis._map.transform.width-n/2&&s.push("right"),0===s.length?"bottom":s.join("-")}_updateClassList(){const i=[...this._classList];i.push("mapboxgl-popup"),this._anchor&&i.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&i.push("mapboxgl-popup-track-pointer"),this._container.className=i.join(" ")}_update(r){if(this._map&&(this._lngLat||this._trackPointer)&&this._content){if(this._container||(this._container=l.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=l.create("div","mapboxgl-popup-tip",this._container),this._container.appendChild(this._content)),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=ri(this._lngLat,this._pos,this._map.transform)),!this._trackPointer||r){const n=this._pos=this._trackPointer&&r?r:this._map.project(this._lngLat),o=function(r){if(r||(r=new i.pointGeometry(0,0)),"number"==typeof r){const n=Math.round(Math.sqrt(.5*Math.pow(r,2)));return{center:new i.pointGeometry(0,0),top:new i.pointGeometry(0,r),"top-left":new i.pointGeometry(n,n),"top-right":new i.pointGeometry(-n,n),bottom:new i.pointGeometry(0,-r),"bottom-left":new i.pointGeometry(n,-n),"bottom-right":new i.pointGeometry(-n,-n),left:new i.pointGeometry(r,0),right:new i.pointGeometry(-r,0)}}if(r instanceof i.pointGeometry||Array.isArray(r)){const o=i.pointGeometry.convert(r);return{center:o,top:o,"top-left":o,"top-right":o,bottom:o,"bottom-left":o,"bottom-right":o,left:o,right:o}}return{center:i.pointGeometry.convert(r.center||[0,0,]),top:i.pointGeometry.convert(r.top||[0,0]),"top-left":i.pointGeometry.convert(r["top-left"]||[0,0]),"top-right":i.pointGeometry.convert(r["top-right"]||[0,0]),bottom:i.pointGeometry.convert(r.bottom||[0,0,]),"bottom-left":i.pointGeometry.convert(r["bottom-left"]||[0,0]),"bottom-right":i.pointGeometry.convert(r["bottom-right"]||[0,0]),left:i.pointGeometry.convert(r.left||[0,0]),right:i.pointGeometry.convert(r.right||[0,0,])}}(this.options.offset),s=this._anchor=this._getAnchor(o),a=n.add(o[s]).round();this._map._requestDomTask(()=>{this._container&&s&&(this._container.style.transform=`${rr[s]} translate(${a.x}px,${a.y}px)`)})}this._updateClassList()}}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const i=this._container.querySelector("a[href], [tabindex]:not([tabindex='-1']), [contenteditable]:not([contenteditable='false']), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])");i&&i.focus()}_onClose(){this.remove()}_setOpacity(i){this._content&&(this._content.style.opacity=i),this._tip&&(this._tip.style.opacity=i)}},Marker:rn,Style:eN,LngLat:i.LngLat,LngLatBounds:i.LngLatBounds,Point:i.pointGeometry,MercatorCoordinate:i.MercatorCoordinate,FreeCameraOptions:il,Evented:i.Evented,config:i.config,prewarm:function(){et().acquire(J)},clearPrewarmedResources:function(){const i=ee;i&&(i.isPreloaded()&&1===i.numActive()?(i.release(J),ee=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return i.config.ACCESS_TOKEN},set accessToken(t){i.config.ACCESS_TOKEN=t},get baseApiUrl(){return i.config.API_URL},set baseApiUrl(t){i.config.API_URL=t},get workerCount(){return Q.workerCount},set workerCount(e){Q.workerCount=e},get maxParallelImageRequests(){return i.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){i.config.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(r){i.clearTileCache(r)},workerUrl:"",workerClass:null,setNow:i.exported.setNow,restoreNow:i.exported.restoreNow};return rm}),n})}},]); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/arrow/concise_methods_with_computed_property2/output.js b/crates/swc_ecma_minifier/tests/terser/compress/arrow/concise_methods_with_computed_property2/output.js index 110671d88c0..a1930650cce 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/arrow/concise_methods_with_computed_property2/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/arrow/concise_methods_with_computed_property2/output.js @@ -1,9 +1,7 @@ var foo = { [[ 1 - ]] (v) { - return v; - } + ]]: (v)=>v }; console.log(foo[[ 1 diff --git a/crates/swc_ecma_minifier/tests/terser/compress/arrow/export_default_object_expression/output.js b/crates/swc_ecma_minifier/tests/terser/compress/arrow/export_default_object_expression/output.js index 04ddf04ea0e..dd74e83149c 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/arrow/export_default_object_expression/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/arrow/export_default_object_expression/output.js @@ -1,8 +1,6 @@ export default { foo: 3, - bar () { - return 4; - }, + bar: ()=>4, get baz () { return this.foo; } diff --git a/crates/swc_ecma_minifier/tests/terser/compress/arrow/issue_3092b/output.js b/crates/swc_ecma_minifier/tests/terser/compress/arrow/issue_3092b/output.js index cca62277b47..243a1b41a57 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/arrow/issue_3092b/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/arrow/issue_3092b/output.js @@ -1,7 +1,5 @@ var obj = { - async bar (x) { - return await x, 2; - }, + bar: async (x)=>(await x, 2), *gen (x) { return yield x.toUpperCase(), 2; }