@maptiler/sdk 2.1.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,13 @@
1
- import maplibregl from 'maplibre-gl';
2
- import { Base64 } from 'js-base64';
1
+ import maplibregl, { addProtocol } from 'maplibre-gl';
2
+ export { AJAXError, AttributionControl as AttributionControlMLGL, BoxZoomHandler as BoxZoomHandlerMLGL, CanvasSource as CanvasSourceMLGL, CooperativeGesturesHandler as CooperativeGesturesHandlerMLGL, DoubleClickZoomHandler, DragPanHandler, DragRotateHandler, EdgeInsets, Evented, FullscreenControl as FullscreenControlMLGL, GeoJSONSource as GeoJSONSourceMLGL, GeolocateControl as GeolocateControlMLGL, Hash, ImageSource as ImageSourceMLGL, KeyboardHandler as KeyboardHandlerMLGL, LngLat, LngLatBounds, LogoControl as LogoControlMLGL, Map as MapMLGL, MapMouseEvent as MapMouseEventMLGL, MapTouchEvent as MapTouchEventMLGL, MapWheelEvent as MapWheelEventMLGL, Marker as MarkerMLGL, MercatorCoordinate, NavigationControl as NavigationControlMLGL, Point, Popup as PopupMLGL, RasterDEMTileSource as RasterDEMTileSourceMLGL, RasterTileSource as RasterTileSourceMLGL, ScaleControl as ScaleControlMLGL, ScrollZoomHandler as ScrollZoomHandlerMLGL, Style as StyleMLGL, TerrainControl as TerrainControlMLGL, TwoFingersTouchPitchHandler as TwoFingersTouchPitchHandlerMLGL, TwoFingersTouchRotateHandler, TwoFingersTouchZoomHandler, TwoFingersTouchZoomRotateHandler, VectorTileSource as VectorTileSourceMLGL, VideoSource as VideoSourceMLGL, addProtocol, addSourceType, clearPrewarmedResources, config as configMLGL, getVersion as getMapLibreVersion, getMaxParallelImageRequests, getRTLTextPluginStatus, getWorkerCount, getWorkerUrl, importScriptInWorkers, prewarm, removeProtocol, setMaxParallelImageRequests, setRTLTextPlugin, setWorkerCount, setWorkerUrl } from 'maplibre-gl';
3
3
  import EventEmitter from 'events';
4
- import { config as config$2, MapStyle, mapStylePresetList, expandMapStyle, MapStyleVariant, ReferenceMapStyle, geolocation } from '@maptiler/client';
4
+ import { config as config$1, MapStyle, mapStylePresetList, expandMapStyle, MapStyleVariant, ReferenceMapStyle, geolocation } from '@maptiler/client';
5
5
  export { LanguageGeocoding, MapStyle, MapStyleVariant, ReferenceMapStyle, ServiceError, bufferToPixelDataBrowser, circumferenceAtLatitude, coordinates, data, elevation, expandMapStyle, geocoding, geolocation, getAutoLanguageGeocoding, getBufferToPixelDataParser, getTileCache, mapStylePresetList, math, misc, staticMaps, styleToStyle } from '@maptiler/client';
6
6
  import { v4 } from 'uuid';
7
+ import { Base64 } from 'js-base64';
7
8
 
8
9
  var name = "@maptiler/sdk";
9
- var version = "2.1.0";
10
+ var version = "2.2.1";
10
11
  var description = "The Javascript & TypeScript map SDK tailored for MapTiler Cloud";
11
12
  var module = "dist/maptiler-sdk.mjs";
12
13
  var types = "dist/maptiler-sdk.d.ts";
@@ -42,32 +43,25 @@ var repository = {
42
43
  var scripts = {
43
44
  build: "rm -rf dist/* && NODE_ENV=production rollup -c",
44
45
  dev: "rm -rf dist/* && NODE_ENV=development rollup -c -w",
45
- "format:fix": "prettier --write \"src/**/*.{js,ts,tsx}\"",
46
- format: "prettier -c \"src/**/*.{js,ts,tsx}\"",
47
- "lint:fix": "eslint --fix \"src/**/*.{js,ts}\"",
48
- lint: "eslint \"src/**/*.{js,ts}\"",
46
+ biome: "biome check --max-diagnostics=1000",
47
+ "biome:fix": "npx @biomejs/biome check --max-diagnostics=1000 --write",
49
48
  doc: "rm -rf docs/* && typedoc --out docs && cp -r images docs/",
50
- prepare: "npm run format:fix && npm run lint:fix && npm run build && npm run test",
49
+ prepare: "npm run biome:fix && npm run build && npm run test",
51
50
  "test:dev": "vitest dev",
52
51
  test: "vitest run"
53
52
  };
54
53
  var author = "MapTiler";
55
54
  var devDependencies = {
56
- "@rollup/plugin-commonjs": "^24.1.0",
57
- "@rollup/plugin-json": "^6.0.0",
58
- "@rollup/plugin-node-resolve": "^15.0.2",
55
+ "@biomejs/biome": "1.8.3",
56
+ "@rollup/plugin-commonjs": "^26.0.1",
57
+ "@rollup/plugin-json": "^6.1.0",
58
+ "@rollup/plugin-node-resolve": "^15.2.3",
59
59
  "@types/uuid": "^9.0.2",
60
60
  "@types/xmldom": "^0.1.31",
61
- "@typescript-eslint/eslint-plugin": "^6.9.0",
62
- "@typescript-eslint/parser": "^6.9.0",
63
- eslint: "^8.52.0",
64
- "eslint-config-prettier": "^9.0.0",
65
- "eslint-plugin-prettier": "^5.0.1",
66
- prettier: "^3.0.3",
67
- rollup: "^3.20.6",
68
- "rollup-plugin-copy-merge": "^1.0.0",
69
- "rollup-plugin-dts": "^5.3.0",
70
- "rollup-plugin-esbuild": "^5.0.0",
61
+ rollup: "^4.18.0",
62
+ "rollup-plugin-copy-merge": "^1.0.2",
63
+ "rollup-plugin-dts": "^6.1.1",
64
+ "rollup-plugin-esbuild": "^6.1.1",
71
65
  "rollup-plugin-node-globals": "^1.4.0",
72
66
  "rollup-plugin-shell": "^1.0.9",
73
67
  "rollup-plugin-string": "^3.0.0",
@@ -241,9 +235,9 @@ function getBrowserLanguage() {
241
235
  if (typeof navigator === "undefined") {
242
236
  return `name:${Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0]}`;
243
237
  }
244
- const canditatelangs = Array.from(
245
- new Set(navigator.languages.map((l) => `name:${l.split("-")[0]}`))
246
- ).filter((l) => languageCodeSet.has(l));
238
+ const canditatelangs = Array.from(new Set(navigator.languages.map((l) => `name:${l.split("-")[0]}`))).filter(
239
+ (l) => languageCodeSet.has(l)
240
+ );
247
241
  return canditatelangs.length ? canditatelangs[0] : Language.LOCAL;
248
242
  }
249
243
 
@@ -259,25 +253,14 @@ const defaults = {
259
253
  };
260
254
  Object.freeze(defaults);
261
255
 
262
- var __defProp$a = Object.defineProperty;
263
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
264
- var __publicField$7 = (obj, key, value) => {
265
- __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
266
- return value;
267
- };
268
256
  const MAPTILER_SESSION_ID = v4();
269
257
  class SdkConfig extends EventEmitter {
270
258
  constructor() {
271
- super();
259
+ super(...arguments);
272
260
  /**
273
261
  * The primary language. By default, the language of the web browser is used.
274
262
  */
275
- __publicField$7(this, "primaryLanguage", defaults.primaryLanguage);
276
- /**
277
- * The secondary language, to overwrite the default language defined in the map style.
278
- * This settings is highly dependant on the style compatibility and may not work in most cases.
279
- */
280
- __publicField$7(this, "secondaryLanguage");
263
+ this.primaryLanguage = defaults.primaryLanguage;
281
264
  /**
282
265
  * Setting on whether of not the SDK runs with a session logic.
283
266
  * A "session" is started at the initialization of the SDK and finished when the browser
@@ -285,21 +268,21 @@ class SdkConfig extends EventEmitter {
285
268
  * When `session` is enabled (default: true), the extra URL param `mtsid` is added to queries
286
269
  * on the MapTiler Cloud API. This allows MapTiler to enable "session based billing".
287
270
  */
288
- __publicField$7(this, "session", true);
271
+ this.session = true;
289
272
  /**
290
273
  * Enables client-side caching of requests for tiles and fonts.
291
274
  * The cached requests persist multiple browser sessions and will be reused when possible.
292
275
  * Works only for requests to the MapTiler Cloud API when sessions are enabled.
293
276
  */
294
- __publicField$7(this, "caching", true);
277
+ this.caching = true;
295
278
  /**
296
279
  * Unit to be used
297
280
  */
298
- __publicField$7(this, "_unit", "metric");
281
+ this._unit = "metric";
299
282
  /**
300
283
  * MapTiler Cloud API key
301
284
  */
302
- __publicField$7(this, "_apiKey", "");
285
+ this._apiKey = "";
303
286
  }
304
287
  /**
305
288
  * Set the unit system
@@ -319,7 +302,7 @@ class SdkConfig extends EventEmitter {
319
302
  */
320
303
  set apiKey(k) {
321
304
  this._apiKey = k;
322
- config$2.apiKey = k;
305
+ config$1.apiKey = k;
323
306
  this.emit("apiKey", k);
324
307
  }
325
308
  /**
@@ -332,160 +315,75 @@ class SdkConfig extends EventEmitter {
332
315
  * Set a the custom fetch function to replace the default one
333
316
  */
334
317
  set fetch(f) {
335
- config$2.fetch = f;
318
+ config$1.fetch = f;
336
319
  }
337
320
  /**
338
321
  * Get the fetch fucntion
339
322
  */
340
323
  get fetch() {
341
- return config$2.fetch;
342
- }
343
- }
344
- const config$1 = new SdkConfig();
345
-
346
- class LogoControl extends maplibregl.LogoControl {
347
- onAdd(map) {
348
- return super.onAdd(map);
324
+ return config$1.fetch;
349
325
  }
350
326
  }
327
+ const config = new SdkConfig();
351
328
 
352
- var __defProp$9 = Object.defineProperty;
353
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
354
- var __publicField$6 = (obj, key, value) => {
355
- __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
356
- return value;
357
- };
358
- class MaptilerLogoControl extends LogoControl {
359
- constructor(options = {}) {
360
- var _a, _b;
361
- super(options);
362
- __publicField$6(this, "logoURL", "");
363
- __publicField$6(this, "linkURL", "");
364
- this.logoURL = (_a = options.logoURL) != null ? _a : defaults.maptilerLogoURL;
365
- this.linkURL = (_b = options.linkURL) != null ? _b : defaults.maptilerURL;
366
- }
367
- onAdd(map) {
368
- var _a;
369
- this._map = map;
370
- this._compact = (_a = this.options.compact) != null ? _a : false;
371
- this._container = window.document.createElement("div");
372
- this._container.className = "maplibregl-ctrl";
373
- const anchor = window.document.createElement("a");
374
- anchor.style.backgroundRepeat = "no-repeat";
375
- anchor.style.cursor = "pointer";
376
- anchor.style.display = "block";
377
- anchor.style.height = "23px";
378
- anchor.style.margin = "0 0 -4px -4px";
379
- anchor.style.overflow = "hidden";
380
- anchor.style.width = "88px";
381
- anchor.style.backgroundImage = `url(${this.logoURL})`;
382
- anchor.style.backgroundSize = "100px 30px";
383
- anchor.style.width = "100px";
384
- anchor.style.height = "30px";
385
- anchor.target = "_blank";
386
- anchor.rel = "noopener";
387
- anchor.href = this.linkURL;
388
- anchor.setAttribute("aria-label", "MapTiler logo");
389
- anchor.setAttribute("rel", "noopener");
390
- this._container.appendChild(anchor);
391
- this._container.style.display = "block";
392
- this._map.on("resize", this._updateCompact);
393
- this._updateCompact();
394
- return this._container;
395
- }
396
- }
397
-
398
- var __async$2 = (__this, __arguments, generator) => {
399
- return new Promise((resolve, reject) => {
400
- var fulfilled = (value) => {
401
- try {
402
- step(generator.next(value));
403
- } catch (e) {
404
- reject(e);
405
- }
406
- };
407
- var rejected = (value) => {
408
- try {
409
- step(generator.throw(value));
410
- } catch (e) {
411
- reject(e);
412
- }
413
- };
414
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
415
- step((generator = generator.apply(__this, __arguments)).next());
416
- });
417
- };
418
329
  const LOCAL_CACHE_PROTOCOL_SOURCE = "localcache_source";
419
330
  const LOCAL_CACHE_PROTOCOL_DATA = "localcache";
420
331
  const LOCAL_CACHE_NAME = "maptiler_sdk";
421
332
  const CACHE_LIMIT_ITEMS = 1e3;
422
333
  const CACHE_LIMIT_CHECK_INTERVAL = 100;
334
+ const CACHE_API_AVAILABLE = typeof caches !== "undefined";
423
335
  function localCacheTransformRequest(reqUrl, resourceType) {
424
- if (config$1.caching && config$1.session && reqUrl.host === defaults.maptilerApiHost) {
425
- if (resourceType == "Source" && reqUrl.href.includes("tiles.json")) {
426
- return reqUrl.href.replace(
427
- "https://",
428
- `${LOCAL_CACHE_PROTOCOL_SOURCE}://`
429
- );
430
- } else if (resourceType == "Tile" || resourceType == "Glyphs") {
336
+ if (CACHE_API_AVAILABLE && config.caching && config.session && reqUrl.host === defaults.maptilerApiHost) {
337
+ if (resourceType === "Source" && reqUrl.href.includes("tiles.json")) {
338
+ return reqUrl.href.replace("https://", `${LOCAL_CACHE_PROTOCOL_SOURCE}://`);
339
+ }
340
+ if (resourceType === "Tile" || resourceType === "Glyphs") {
431
341
  return reqUrl.href.replace("https://", `${LOCAL_CACHE_PROTOCOL_DATA}://`);
432
342
  }
433
343
  }
434
344
  return reqUrl.href;
435
345
  }
436
346
  let cacheInstance;
437
- function getCache() {
438
- return __async$2(this, null, function* () {
439
- if (!cacheInstance) {
440
- cacheInstance = yield caches.open(LOCAL_CACHE_NAME);
441
- }
442
- return cacheInstance;
443
- });
347
+ async function getCache() {
348
+ if (!cacheInstance) {
349
+ cacheInstance = await caches.open(LOCAL_CACHE_NAME);
350
+ }
351
+ return cacheInstance;
444
352
  }
445
353
  let cachePutCounter = 0;
446
- function limitCache() {
447
- return __async$2(this, null, function* () {
448
- const cache = yield getCache();
449
- const keys = yield cache.keys();
450
- const toPurge = keys.slice(0, Math.max(keys.length - CACHE_LIMIT_ITEMS, 0));
451
- for (const key of toPurge) {
452
- cache.delete(key);
453
- }
454
- });
354
+ async function limitCache() {
355
+ const cache = await getCache();
356
+ const keys = await cache.keys();
357
+ const toPurge = keys.slice(0, Math.max(keys.length - CACHE_LIMIT_ITEMS, 0));
358
+ for (const key of toPurge) {
359
+ cache.delete(key);
360
+ }
455
361
  }
456
362
  function registerLocalCacheProtocol() {
457
363
  addProtocol(
458
364
  LOCAL_CACHE_PROTOCOL_SOURCE,
459
- (params, abortController) => __async$2(this, null, function* () {
460
- if (!params.url)
461
- throw new Error("");
462
- params.url = params.url.replace(
463
- `${LOCAL_CACHE_PROTOCOL_SOURCE}://`,
464
- "https://"
465
- );
365
+ async (params, abortController) => {
366
+ if (!params.url) throw new Error("");
367
+ params.url = params.url.replace(`${LOCAL_CACHE_PROTOCOL_SOURCE}://`, "https://");
466
368
  const requestInit = params;
467
369
  requestInit.signal = abortController.signal;
468
- const response = yield fetch(params.url, requestInit);
469
- const json = yield response.json();
370
+ const response = await fetch(params.url, requestInit);
371
+ const json = await response.json();
470
372
  if (json.tiles && json.tiles.length > 0) {
471
- json.tiles[0] += "&last-modified=" + response.headers.get("Last-Modified");
373
+ json.tiles[0] += `&last-modified=${response.headers.get("Last-Modified")}`;
472
374
  }
473
375
  return {
474
376
  data: json,
475
377
  cacheControl: response.headers.get("Cache-Control"),
476
378
  expires: response.headers.get("Expires")
477
379
  };
478
- })
380
+ }
479
381
  );
480
382
  addProtocol(
481
383
  LOCAL_CACHE_PROTOCOL_DATA,
482
- (params, abortController) => __async$2(this, null, function* () {
483
- if (!params.url)
484
- throw new Error("");
485
- params.url = params.url.replace(
486
- `${LOCAL_CACHE_PROTOCOL_DATA}://`,
487
- "https://"
488
- );
384
+ async (params, abortController) => {
385
+ if (!params.url) throw new Error("");
386
+ params.url = params.url.replace(`${LOCAL_CACHE_PROTOCOL_DATA}://`, "https://");
489
387
  const url = new URL(params.url);
490
388
  const cacheableUrl = new URL(url);
491
389
  cacheableUrl.searchParams.delete("mtsid");
@@ -494,77 +392,54 @@ function registerLocalCacheProtocol() {
494
392
  const fetchableUrl = new URL(url);
495
393
  fetchableUrl.searchParams.delete("last-modified");
496
394
  const fetchUrl = fetchableUrl.toString();
497
- const respond = (response) => __async$2(this, null, function* () {
395
+ const respond = async (response2) => {
498
396
  return {
499
- data: yield response.arrayBuffer(),
500
- cacheControl: response.headers.get("Cache-Control"),
501
- expires: response.headers.get("Expires")
397
+ data: await response2.arrayBuffer(),
398
+ cacheControl: response2.headers.get("Cache-Control"),
399
+ expires: response2.headers.get("Expires")
502
400
  };
503
- });
504
- const cache = yield getCache();
505
- const cacheMatch = yield cache.match(cacheKey);
401
+ };
402
+ const cache = await getCache();
403
+ const cacheMatch = await cache.match(cacheKey);
506
404
  if (cacheMatch) {
507
405
  return respond(cacheMatch);
508
- } else {
509
- const requestInit = params;
510
- requestInit.signal = abortController.signal;
511
- const response = yield fetch(fetchUrl, requestInit);
512
- if (response.status >= 200 && response.status < 300) {
513
- cache.put(cacheKey, response.clone()).catch(() => {
514
- });
515
- if (++cachePutCounter > CACHE_LIMIT_CHECK_INTERVAL) {
516
- limitCache();
517
- cachePutCounter = 0;
518
- }
406
+ }
407
+ const requestInit = params;
408
+ requestInit.signal = abortController.signal;
409
+ const response = await fetch(fetchUrl, requestInit);
410
+ if (response.status >= 200 && response.status < 300) {
411
+ cache.put(cacheKey, response.clone()).catch(() => {
412
+ });
413
+ if (++cachePutCounter > CACHE_LIMIT_CHECK_INTERVAL) {
414
+ limitCache();
415
+ cachePutCounter = 0;
519
416
  }
520
- return respond(response);
521
417
  }
522
- })
418
+ return respond(response);
419
+ }
523
420
  );
524
421
  }
525
422
 
526
- var __defProp$8 = Object.defineProperty;
527
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
528
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
529
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
530
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
531
- var __spreadValues$5 = (a, b) => {
532
- for (var prop in b || (b = {}))
533
- if (__hasOwnProp$5.call(b, prop))
534
- __defNormalProp$8(a, prop, b[prop]);
535
- if (__getOwnPropSymbols$5)
536
- for (var prop of __getOwnPropSymbols$5(b)) {
537
- if (__propIsEnum$5.call(b, prop))
538
- __defNormalProp$8(a, prop, b[prop]);
539
- }
540
- return a;
541
- };
542
423
  function enableRTL() {
543
- if (maplibregl.getRTLTextPluginStatus() === "unavailable") {
544
- maplibregl.setRTLTextPlugin(
545
- defaults.rtlPluginURL,
546
- (err) => {
547
- if (err)
548
- console.error(err);
549
- },
550
- true
551
- // Lazy load the plugin
552
- );
424
+ if (typeof window === "undefined") return;
425
+ const status = maplibregl.getRTLTextPluginStatus();
426
+ if (status === "unavailable" || status === "requested") {
427
+ try {
428
+ maplibregl.setRTLTextPlugin(defaults.rtlPluginURL, true);
429
+ } catch (e) {
430
+ }
553
431
  }
554
432
  }
555
433
  function bindAll(fns, context) {
556
- fns.forEach((fn) => {
557
- if (typeof context[fn] !== "function")
558
- return;
434
+ for (const fn of fns) {
435
+ if (typeof context[fn] !== "function") continue;
559
436
  context[fn] = context[fn].bind(context);
560
- });
437
+ }
561
438
  }
562
439
  function DOMcreate(tagName, className, container) {
563
440
  const el = window.document.createElement(tagName);
564
- if (className !== void 0)
565
- el.className = className;
566
- if (container)
567
- container.appendChild(el);
441
+ if (className !== void 0) el.className = className;
442
+ if (container) container.appendChild(el);
568
443
  return el;
569
444
  }
570
445
  function DOMremove(node) {
@@ -583,9 +458,9 @@ function maptilerCloudTransformRequest(url, resourceType) {
583
458
  }
584
459
  if (reqUrl.host === defaults.maptilerApiHost) {
585
460
  if (!reqUrl.searchParams.has("key")) {
586
- reqUrl.searchParams.append("key", config$1.apiKey);
461
+ reqUrl.searchParams.append("key", config.apiKey);
587
462
  }
588
- if (config$1.session) {
463
+ if (config.session) {
589
464
  reqUrl.searchParams.append("mtsid", MAPTILER_SESSION_ID);
590
465
  }
591
466
  }
@@ -594,15 +469,16 @@ function maptilerCloudTransformRequest(url, resourceType) {
594
469
  };
595
470
  }
596
471
  function combineTransformRequest(userDefinedRTF) {
597
- return function(url, resourceType) {
598
- var _a;
472
+ return (url, resourceType) => {
599
473
  if (userDefinedRTF !== void 0 && userDefinedRTF !== null) {
600
474
  const rp = userDefinedRTF(url, resourceType);
601
- const rp2 = maptilerCloudTransformRequest((_a = rp == null ? void 0 : rp.url) != null ? _a : "", resourceType);
602
- return __spreadValues$5(__spreadValues$5({}, rp), rp2);
603
- } else {
604
- return maptilerCloudTransformRequest(url, resourceType);
475
+ const rp2 = maptilerCloudTransformRequest(rp?.url ?? "", resourceType);
476
+ return {
477
+ ...rp,
478
+ ...rp2
479
+ };
605
480
  }
481
+ return maptilerCloudTransformRequest(url, resourceType);
606
482
  };
607
483
  }
608
484
  function generateRandomString() {
@@ -619,6 +495,222 @@ function jsonParseNoThrow(doc) {
619
495
  }
620
496
  return null;
621
497
  }
498
+ function getWebGLSupportError() {
499
+ const gl = document.createElement("canvas").getContext("webgl2");
500
+ if (!gl) {
501
+ if (typeof WebGL2RenderingContext !== "undefined") {
502
+ return "Graphic rendering with WebGL2 has been disabled or is not supported by your graphic card. The map cannot be displayed.";
503
+ }
504
+ return "Your browser does not support graphic rendering with WebGL2. The map cannot be displayed.";
505
+ }
506
+ return null;
507
+ }
508
+ function displayNoWebGlWarning(container) {
509
+ const webglError = getWebGLSupportError();
510
+ if (!webglError) return;
511
+ let actualContainer = null;
512
+ if (typeof container === "string") {
513
+ actualContainer = document.getElementById(container);
514
+ } else if (container instanceof HTMLElement) {
515
+ actualContainer = container;
516
+ }
517
+ if (!actualContainer) {
518
+ throw new Error("The Map container must be provided.");
519
+ }
520
+ const errorMessageDiv = document.createElement("div");
521
+ errorMessageDiv.innerHTML = webglError;
522
+ errorMessageDiv.classList.add("no-webgl-support-div");
523
+ actualContainer.appendChild(errorMessageDiv);
524
+ throw new Error(webglError);
525
+ }
526
+
527
+ let Marker$1 = class Marker extends maplibregl.Marker {
528
+ addTo(map) {
529
+ return super.addTo(map);
530
+ }
531
+ };
532
+
533
+ class Popup extends maplibregl.Popup {
534
+ addTo(map) {
535
+ return super.addTo(map);
536
+ }
537
+ }
538
+
539
+ class Style extends maplibregl.Style {
540
+ constructor(map, options = {}) {
541
+ super(map, options);
542
+ }
543
+ }
544
+
545
+ class CanvasSource extends maplibregl.CanvasSource {
546
+ onAdd(map) {
547
+ super.onAdd(map);
548
+ }
549
+ }
550
+
551
+ class GeoJSONSource extends maplibregl.GeoJSONSource {
552
+ onAdd(map) {
553
+ super.onAdd(map);
554
+ }
555
+ }
556
+
557
+ class ImageSource extends maplibregl.ImageSource {
558
+ onAdd(map) {
559
+ super.onAdd(map);
560
+ }
561
+ }
562
+
563
+ class RasterTileSource extends maplibregl.RasterTileSource {
564
+ onAdd(map) {
565
+ super.onAdd(map);
566
+ }
567
+ }
568
+
569
+ class RasterDEMTileSource extends maplibregl.RasterDEMTileSource {
570
+ onAdd(map) {
571
+ super.onAdd(map);
572
+ }
573
+ }
574
+
575
+ class VectorTileSource extends maplibregl.VectorTileSource {
576
+ onAdd(map) {
577
+ super.onAdd(map);
578
+ }
579
+ }
580
+
581
+ class VideoSource extends maplibregl.VideoSource {
582
+ onAdd(map) {
583
+ super.onAdd(map);
584
+ }
585
+ }
586
+
587
+ class NavigationControl extends maplibregl.NavigationControl {
588
+ onAdd(map) {
589
+ return super.onAdd(map);
590
+ }
591
+ }
592
+
593
+ class GeolocateControl extends maplibregl.GeolocateControl {
594
+ onAdd(map) {
595
+ return super.onAdd(map);
596
+ }
597
+ }
598
+
599
+ class AttributionControl extends maplibregl.AttributionControl {
600
+ onAdd(map) {
601
+ return super.onAdd(map);
602
+ }
603
+ }
604
+
605
+ class LogoControl extends maplibregl.LogoControl {
606
+ onAdd(map) {
607
+ return super.onAdd(map);
608
+ }
609
+ }
610
+
611
+ class ScaleControl extends maplibregl.ScaleControl {
612
+ onAdd(map) {
613
+ return super.onAdd(map);
614
+ }
615
+ }
616
+
617
+ class FullscreenControl extends maplibregl.FullscreenControl {
618
+ onAdd(map) {
619
+ return super.onAdd(map);
620
+ }
621
+ }
622
+
623
+ class TerrainControl extends maplibregl.TerrainControl {
624
+ onAdd(map) {
625
+ return super.onAdd(map);
626
+ }
627
+ }
628
+
629
+ class BoxZoomHandler extends maplibregl.BoxZoomHandler {
630
+ constructor(map, options) {
631
+ super(map, options);
632
+ }
633
+ }
634
+
635
+ class ScrollZoomHandler extends maplibregl.ScrollZoomHandler {
636
+ constructor(map, triggerRenderFrame) {
637
+ super(map, triggerRenderFrame);
638
+ }
639
+ }
640
+
641
+ class CooperativeGesturesHandler extends maplibregl.CooperativeGesturesHandler {
642
+ constructor(map, options) {
643
+ super(map, options);
644
+ }
645
+ }
646
+
647
+ class KeyboardHandler extends maplibregl.KeyboardHandler {
648
+ constructor(map) {
649
+ super(map);
650
+ }
651
+ }
652
+
653
+ class TwoFingersTouchPitchHandler extends maplibregl.TwoFingersTouchPitchHandler {
654
+ constructor(map) {
655
+ super(map);
656
+ }
657
+ }
658
+
659
+ class MapWheelEvent extends maplibregl.MapWheelEvent {
660
+ constructor(type, map, originalEvent) {
661
+ super(type, map, originalEvent);
662
+ }
663
+ }
664
+
665
+ class MapTouchEvent extends maplibregl.MapTouchEvent {
666
+ constructor(type, map, originalEvent) {
667
+ super(type, map, originalEvent);
668
+ }
669
+ }
670
+
671
+ class MapMouseEvent extends maplibregl.MapMouseEvent {
672
+ constructor(type, map, originalEvent, data = {}) {
673
+ super(type, map, originalEvent, data);
674
+ }
675
+ }
676
+
677
+ class MaptilerLogoControl extends LogoControl {
678
+ constructor(options = {}) {
679
+ super(options);
680
+ this.logoURL = "";
681
+ this.linkURL = "";
682
+ this.logoURL = options.logoURL ?? defaults.maptilerLogoURL;
683
+ this.linkURL = options.linkURL ?? defaults.maptilerURL;
684
+ }
685
+ onAdd(map) {
686
+ this._map = map;
687
+ this._compact = this.options.compact ?? false;
688
+ this._container = window.document.createElement("div");
689
+ this._container.className = "maplibregl-ctrl";
690
+ const anchor = window.document.createElement("a");
691
+ anchor.style.backgroundRepeat = "no-repeat";
692
+ anchor.style.cursor = "pointer";
693
+ anchor.style.display = "block";
694
+ anchor.style.height = "23px";
695
+ anchor.style.margin = "0 0 -4px -4px";
696
+ anchor.style.overflow = "hidden";
697
+ anchor.style.width = "88px";
698
+ anchor.style.backgroundImage = `url(${this.logoURL})`;
699
+ anchor.style.backgroundSize = "100px 30px";
700
+ anchor.style.width = "100px";
701
+ anchor.style.height = "30px";
702
+ anchor.target = "_blank";
703
+ anchor.rel = "noopener";
704
+ anchor.href = this.linkURL;
705
+ anchor.setAttribute("aria-label", "MapTiler logo");
706
+ anchor.setAttribute("rel", "noopener");
707
+ this._container.appendChild(anchor);
708
+ this._container.style.display = "block";
709
+ this._map.on("resize", this._updateCompact);
710
+ this._updateCompact();
711
+ return this._container;
712
+ }
713
+ }
622
714
 
623
715
  function styleToStyle(style) {
624
716
  if (!style) {
@@ -627,9 +719,8 @@ function styleToStyle(style) {
627
719
  if (typeof style === "string" || style instanceof String) {
628
720
  if (!style.startsWith("http") && style.toLowerCase().includes(".json")) {
629
721
  return style;
630
- } else {
631
- return expandMapStyle(style);
632
722
  }
723
+ return expandMapStyle(style);
633
724
  }
634
725
  if (style instanceof MapStyleVariant) {
635
726
  return style.getExpandedStyleURL();
@@ -640,31 +731,15 @@ function styleToStyle(style) {
640
731
  return style;
641
732
  }
642
733
 
643
- var __defProp$7 = Object.defineProperty;
644
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
645
- var __publicField$5 = (obj, key, value) => {
646
- __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
647
- return value;
648
- };
649
734
  class MaptilerTerrainControl {
650
735
  constructor() {
651
- __publicField$5(this, "_map");
652
- __publicField$5(this, "_container");
653
- __publicField$5(this, "_terrainButton");
654
736
  bindAll(["_toggleTerrain", "_updateTerrainIcon"], this);
655
737
  }
656
738
  onAdd(map) {
657
739
  this._map = map;
658
740
  this._container = DOMcreate("div", "maplibregl-ctrl maplibregl-ctrl-group");
659
- this._terrainButton = DOMcreate(
660
- "button",
661
- "maplibregl-ctrl-terrain",
662
- this._container
663
- );
664
- DOMcreate("span", "maplibregl-ctrl-icon", this._terrainButton).setAttribute(
665
- "aria-hidden",
666
- "true"
667
- );
741
+ this._terrainButton = DOMcreate("button", "maplibregl-ctrl-terrain", this._container);
742
+ DOMcreate("span", "maplibregl-ctrl-icon", this._terrainButton).setAttribute("aria-hidden", "true");
668
743
  this._terrainButton.type = "button";
669
744
  this._terrainButton.addEventListener("click", this._toggleTerrain);
670
745
  this._updateTerrainIcon();
@@ -689,30 +764,14 @@ class MaptilerTerrainControl {
689
764
  this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled");
690
765
  if (this._map.hasTerrain()) {
691
766
  this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled");
692
- this._terrainButton.title = this._map._getUIString(
693
- "TerrainControl.Disable"
694
- );
767
+ this._terrainButton.title = this._map._getUIString("TerrainControl.Disable");
695
768
  } else {
696
769
  this._terrainButton.classList.add("maplibregl-ctrl-terrain");
697
- this._terrainButton.title = this._map._getUIString(
698
- "TerrainControl.Enable"
699
- );
770
+ this._terrainButton.title = this._map._getUIString("TerrainControl.Enable");
700
771
  }
701
772
  }
702
773
  }
703
774
 
704
- class NavigationControl extends maplibregl.NavigationControl {
705
- onAdd(map) {
706
- return super.onAdd(map);
707
- }
708
- }
709
-
710
- var __defProp$6 = Object.defineProperty;
711
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
712
- var __publicField$4 = (obj, key, value) => {
713
- __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
714
- return value;
715
- };
716
775
  class MaptilerNavigationControl extends NavigationControl {
717
776
  constructor() {
718
777
  super({
@@ -723,20 +782,14 @@ class MaptilerNavigationControl extends NavigationControl {
723
782
  /**
724
783
  * Overloading: Limit how flat the compass icon can get
725
784
  */
726
- __publicField$4(this, "_rotateCompassArrow", () => {
785
+ this._rotateCompassArrow = () => {
727
786
  const rotate = this.options.visualizePitch ? `scale(${Math.min(
728
787
  1.5,
729
- 1 / Math.pow(
730
- Math.cos(this._map.transform.pitch * (Math.PI / 180)),
731
- 0.5
732
- )
788
+ 1 / Math.cos(this._map.transform.pitch * (Math.PI / 180)) ** 0.5
733
789
  )}) rotateX(${Math.min(70, this._map.transform.pitch)}deg) rotateZ(${this._map.transform.angle * (180 / Math.PI)}deg)` : `rotate(${this._map.transform.angle * (180 / Math.PI)}deg)`;
734
790
  this._compassIcon.style.transform = rotate;
735
- });
736
- this._compass.removeEventListener(
737
- "click",
738
- this._compass.clickFunction
739
- );
791
+ };
792
+ this._compass.removeEventListener("click", this._compass.clickFunction);
740
793
  this._compass.addEventListener("click", (e) => {
741
794
  {
742
795
  const currentPitch = this._map.getPitch();
@@ -756,72 +809,39 @@ class MaptilerNavigationControl extends NavigationControl {
756
809
  * Overloading: the button now stores its click callback so that we can later on delete it and replace it
757
810
  */
758
811
  _createButton(className, fn) {
759
- const button = super._createButton(className, fn);
760
- button.clickFunction = fn;
761
- return button;
762
- }
763
- }
764
-
765
- class GeolocateControl extends maplibregl.GeolocateControl {
766
- onAdd(map) {
767
- return super.onAdd(map);
812
+ const button = super._createButton(className, fn);
813
+ button.clickFunction = fn;
814
+ return button;
768
815
  }
769
816
  }
770
817
 
771
- var __defProp$5 = Object.defineProperty;
772
- var __defProps$3 = Object.defineProperties;
773
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
774
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
775
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
776
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
777
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
778
- var __spreadValues$4 = (a, b) => {
779
- for (var prop in b || (b = {}))
780
- if (__hasOwnProp$4.call(b, prop))
781
- __defNormalProp$5(a, prop, b[prop]);
782
- if (__getOwnPropSymbols$4)
783
- for (var prop of __getOwnPropSymbols$4(b)) {
784
- if (__propIsEnum$4.call(b, prop))
785
- __defNormalProp$5(a, prop, b[prop]);
786
- }
787
- return a;
788
- };
789
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
790
- var __publicField$3 = (obj, key, value) => {
791
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
792
- return value;
793
- };
794
- const Marker$1 = maplibregl.Marker;
795
- const LngLat$1 = maplibregl.LngLat;
796
- const LngLatBounds$1 = maplibregl.LngLatBounds;
818
+ const Marker = maplibregl.Marker;
819
+ const LngLat = maplibregl.LngLat;
820
+ const LngLatBounds = maplibregl.LngLatBounds;
797
821
  class MaptilerGeolocateControl extends GeolocateControl {
798
822
  constructor() {
799
823
  super(...arguments);
800
- __publicField$3(this, "lastUpdatedCenter", new LngLat$1(0, 0));
824
+ this.lastUpdatedCenter = new LngLat(0, 0);
801
825
  /**
802
826
  * Update the camera location to center on the current position
803
827
  *
804
828
  * @param {Position} position the Geolocation API Position
805
829
  * @private
806
830
  */
807
- __publicField$3(this, "_updateCamera", (position) => {
808
- var _a, _b, _c;
809
- const center = new LngLat$1(
810
- position.coords.longitude,
811
- position.coords.latitude
812
- );
831
+ this._updateCamera = (position) => {
832
+ const center = new LngLat(position.coords.longitude, position.coords.latitude);
813
833
  const radius = position.coords.accuracy;
814
834
  const bearing = this._map.getBearing();
815
- const options = __spreadProps$3(__spreadValues$4({
816
- bearing
817
- }, this.options.fitBoundsOptions), {
835
+ const options = {
836
+ bearing,
837
+ ...this.options.fitBoundsOptions,
818
838
  linear: true
819
- });
839
+ };
820
840
  const currentMapZoom = this._map.getZoom();
821
- if (currentMapZoom > ((_c = (_b = (_a = this.options) == null ? void 0 : _a.fitBoundsOptions) == null ? void 0 : _b.maxZoom) != null ? _c : 30)) {
841
+ if (currentMapZoom > (this.options?.fitBoundsOptions?.maxZoom ?? 30)) {
822
842
  options.zoom = currentMapZoom;
823
843
  }
824
- this._map.fitBounds(LngLatBounds$1.fromLngLat(center, radius), options, {
844
+ this._map.fitBounds(LngLatBounds.fromLngLat(center, radius), options, {
825
845
  geolocateSource: true
826
846
  // tag this camera change so it won't cause the control to change to background state
827
847
  });
@@ -847,28 +867,15 @@ class MaptilerGeolocateControl extends GeolocateControl {
847
867
  }
848
868
  this.lastUpdatedCenter = this._map.getCenter();
849
869
  });
850
- });
851
- __publicField$3(this, "_setupUI", (supported) => {
870
+ };
871
+ this._setupUI = (supported) => {
852
872
  this.lastUpdatedCenter = this._map.getCenter();
853
- this._container.addEventListener(
854
- "contextmenu",
855
- (e) => e.preventDefault()
856
- );
857
- this._geolocateButton = DOMcreate(
858
- "button",
859
- "maplibregl-ctrl-geolocate",
860
- this._container
861
- );
862
- DOMcreate(
863
- "span",
864
- "maplibregl-ctrl-icon",
865
- this._geolocateButton
866
- ).setAttribute("aria-hidden", "true");
873
+ this._container.addEventListener("contextmenu", (e) => e.preventDefault());
874
+ this._geolocateButton = DOMcreate("button", "maplibregl-ctrl-geolocate", this._container);
875
+ DOMcreate("span", "maplibregl-ctrl-icon", this._geolocateButton).setAttribute("aria-hidden", "true");
867
876
  this._geolocateButton.type = "button";
868
877
  if (supported === false) {
869
- const title = this._map._getUIString(
870
- "GeolocateControl.LocationNotAvailable"
871
- );
878
+ const title = this._map._getUIString("GeolocateControl.LocationNotAvailable");
872
879
  this._geolocateButton.disabled = true;
873
880
  this._geolocateButton.title = title;
874
881
  this._geolocateButton.setAttribute("aria-label", title);
@@ -883,17 +890,13 @@ class MaptilerGeolocateControl extends GeolocateControl {
883
890
  }
884
891
  if (this.options.showUserLocation) {
885
892
  this._dotElement = DOMcreate("div", "maplibregl-user-location-dot");
886
- this._userLocationDotMarker = new Marker$1({ element: this._dotElement });
887
- this._circleElement = DOMcreate(
888
- "div",
889
- "maplibregl-user-location-accuracy-circle"
890
- );
891
- this._accuracyCircleMarker = new Marker$1({
893
+ this._userLocationDotMarker = new Marker({ element: this._dotElement });
894
+ this._circleElement = DOMcreate("div", "maplibregl-user-location-accuracy-circle");
895
+ this._accuracyCircleMarker = new Marker({
892
896
  element: this._circleElement,
893
897
  pitchAlignment: "map"
894
898
  });
895
- if (this.options.trackUserLocation)
896
- this._watchState = "OFF";
899
+ if (this.options.trackUserLocation) this._watchState = "OFF";
897
900
  this._map.on("move", this._onZoom);
898
901
  }
899
902
  this._geolocateButton.addEventListener("click", this.trigger.bind(this));
@@ -901,27 +904,21 @@ class MaptilerGeolocateControl extends GeolocateControl {
901
904
  if (this.options.trackUserLocation) {
902
905
  this._map.on("moveend", (event) => {
903
906
  const fromResize = event.originalEvent && event.originalEvent.type === "resize";
904
- const movingDistance = this.lastUpdatedCenter.distanceTo(
905
- this._map.getCenter()
906
- );
907
+ const movingDistance = this.lastUpdatedCenter.distanceTo(this._map.getCenter());
907
908
  if (!event.geolocateSource && this._watchState === "ACTIVE_LOCK" && !fromResize && movingDistance > 1) {
908
909
  this._watchState = "BACKGROUND";
909
- this._geolocateButton.classList.add(
910
- "maplibregl-ctrl-geolocate-background"
911
- );
912
- this._geolocateButton.classList.remove(
913
- "maplibregl-ctrl-geolocate-active"
914
- );
910
+ this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");
911
+ this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active");
915
912
  this.fire(new Event("trackuserlocationend"));
916
913
  }
917
914
  });
918
915
  }
919
- });
920
- __publicField$3(this, "_onZoom", () => {
916
+ };
917
+ this._onZoom = () => {
921
918
  if (this.options.showUserLocation && this.options.showAccuracyCircle) {
922
919
  this._updateCircleRadius();
923
920
  }
924
- });
921
+ };
925
922
  }
926
923
  _updateCircleRadius() {
927
924
  if (this._watchState !== "BACKGROUND" && this._watchState !== "ACTIVE_LOCK") {
@@ -933,10 +930,7 @@ class MaptilerGeolocateControl extends GeolocateControl {
933
930
  ];
934
931
  const projectedLocation = this._map.project(lastKnownLocation);
935
932
  const a = this._map.unproject([projectedLocation.x, projectedLocation.y]);
936
- const b = this._map.unproject([
937
- projectedLocation.x + 20,
938
- projectedLocation.y
939
- ]);
933
+ const b = this._map.unproject([projectedLocation.x + 20, projectedLocation.y]);
940
934
  const metersPerPixel = a.distanceTo(b) / 20;
941
935
  const circleDiameter = Math.ceil(2 * this._accuracy / metersPerPixel);
942
936
  this._circleElement.style.width = `${circleDiameter}px`;
@@ -944,85 +938,32 @@ class MaptilerGeolocateControl extends GeolocateControl {
944
938
  }
945
939
  }
946
940
 
947
- class ScaleControl extends maplibregl.ScaleControl {
948
- onAdd(map) {
949
- return super.onAdd(map);
950
- }
951
- }
952
-
953
- class FullscreenControl extends maplibregl.FullscreenControl {
954
- onAdd(map) {
955
- return super.onAdd(map);
956
- }
957
- }
958
-
959
- var __defProp$4 = Object.defineProperty;
960
- var __defProps$2 = Object.defineProperties;
961
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
962
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
963
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
964
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
965
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
966
- var __spreadValues$3 = (a, b) => {
967
- for (var prop in b || (b = {}))
968
- if (__hasOwnProp$3.call(b, prop))
969
- __defNormalProp$4(a, prop, b[prop]);
970
- if (__getOwnPropSymbols$3)
971
- for (var prop of __getOwnPropSymbols$3(b)) {
972
- if (__propIsEnum$3.call(b, prop))
973
- __defNormalProp$4(a, prop, b[prop]);
974
- }
975
- return a;
976
- };
977
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
978
- var __publicField$2 = (obj, key, value) => {
979
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
980
- return value;
981
- };
982
- var __accessCheck = (obj, member, msg) => {
983
- if (!member.has(obj))
984
- throw TypeError("Cannot " + msg);
985
- };
986
- var __privateGet = (obj, member, getter) => {
987
- __accessCheck(obj, member, "read from private field");
988
- return getter ? getter.call(obj) : member.get(obj);
989
- };
990
- var __privateAdd = (obj, member, value) => {
991
- if (member.has(obj))
992
- throw TypeError("Cannot add the same private member more than once");
993
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
994
- };
995
- var __privateSet = (obj, member, value, setter) => {
996
- __accessCheck(obj, member, "write to private field");
997
- setter ? setter.call(obj, value) : member.set(obj, value);
998
- return value;
999
- };
1000
- var __privateMethod = (obj, member, method) => {
1001
- __accessCheck(obj, member, "access private method");
1002
- return method;
941
+ var __typeError = (msg) => {
942
+ throw TypeError(msg);
1003
943
  };
1004
- var _options, _parentMap, _container, _canvasContainer, _parentRect, _differentStyle, _desync, _addParentRect, addParentRect_fn, _setParentBounds, setParentBounds_fn, _syncMaps, syncMaps_fn;
944
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
945
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
946
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
947
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
948
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
949
+ var _options, _parentMap, _container, _canvasContainer, _parentRect, _differentStyle, _desync, _Minimap_instances, addParentRect_fn, setParentBounds_fn, syncMaps_fn;
1005
950
  class Minimap {
1006
951
  constructor(options, mapOptions) {
1007
- __privateAdd(this, _addParentRect);
1008
- __privateAdd(this, _setParentBounds);
1009
- __privateAdd(this, _syncMaps);
1010
- __privateAdd(this, _options, void 0);
1011
- __publicField$2(this, "map");
1012
- __privateAdd(this, _parentMap, void 0);
1013
- __privateAdd(this, _container, void 0);
1014
- __privateAdd(this, _canvasContainer, void 0);
1015
- __privateAdd(this, _parentRect, void 0);
952
+ __privateAdd(this, _Minimap_instances);
953
+ __privateAdd(this, _options);
954
+ __privateAdd(this, _parentMap);
955
+ __privateAdd(this, _container);
956
+ __privateAdd(this, _canvasContainer);
957
+ __privateAdd(this, _parentRect);
1016
958
  __privateAdd(this, _differentStyle, false);
1017
- __privateAdd(this, _desync, void 0);
1018
- var _a;
1019
- if (options.style !== void 0)
1020
- __privateSet(this, _differentStyle, true);
1021
- __privateSet(this, _options, __spreadProps$2(__spreadValues$3(__spreadProps$2(__spreadValues$3({
959
+ __privateAdd(this, _desync);
960
+ if (options.style !== void 0) __privateSet(this, _differentStyle, true);
961
+ __privateSet(this, _options, {
1022
962
  // set defaults
1023
963
  zoomAdjust: -4,
1024
- position: "top-right"
1025
- }, mapOptions), {
964
+ position: "top-right",
965
+ // inherit map options
966
+ ...mapOptions,
1026
967
  // override any lingering control options
1027
968
  forceNoAttributionControl: true,
1028
969
  attributionControl: false,
@@ -1031,70 +972,63 @@ class Minimap {
1031
972
  maptilerLogo: false,
1032
973
  minimap: false,
1033
974
  hash: false,
1034
- pitchAdjust: false
1035
- }), options), {
1036
- containerStyle: __spreadValues$3({
975
+ pitchAdjust: false,
976
+ // override map options with new user defined minimap options
977
+ ...options,
978
+ containerStyle: {
1037
979
  border: "1px solid #000",
1038
980
  width: "400px",
1039
- height: "300px"
1040
- }, (_a = options.containerStyle) != null ? _a : {})
1041
- }));
981
+ height: "300px",
982
+ ...options.containerStyle ?? {}
983
+ }
984
+ });
1042
985
  if (options.lockZoom !== void 0) {
1043
986
  __privateGet(this, _options).minZoom = options.lockZoom;
1044
987
  __privateGet(this, _options).maxZoom = options.lockZoom;
1045
988
  }
1046
989
  }
1047
990
  setStyle(style, options) {
1048
- if (!__privateGet(this, _differentStyle))
1049
- this.map.setStyle(style, options);
1050
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
991
+ if (!__privateGet(this, _differentStyle)) this.map.setStyle(style, options);
992
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
1051
993
  }
1052
994
  addLayer(layer, beforeId) {
1053
- if (!__privateGet(this, _differentStyle))
1054
- this.map.addLayer(layer, beforeId);
1055
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
995
+ if (!__privateGet(this, _differentStyle)) this.map.addLayer(layer, beforeId);
996
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
1056
997
  return this.map;
1057
998
  }
1058
999
  moveLayer(id, beforeId) {
1059
- if (!__privateGet(this, _differentStyle))
1060
- this.map.moveLayer(id, beforeId);
1061
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1000
+ if (!__privateGet(this, _differentStyle)) this.map.moveLayer(id, beforeId);
1001
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
1062
1002
  return this.map;
1063
1003
  }
1064
1004
  removeLayer(id) {
1065
- if (!__privateGet(this, _differentStyle))
1066
- this.map.removeLayer(id);
1067
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1005
+ if (!__privateGet(this, _differentStyle)) this.map.removeLayer(id);
1006
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
1068
1007
  return this;
1069
1008
  }
1070
1009
  setLayerZoomRange(layerId, minzoom, maxzoom) {
1071
- if (!__privateGet(this, _differentStyle))
1072
- this.map.setLayerZoomRange(layerId, minzoom, maxzoom);
1073
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1010
+ if (!__privateGet(this, _differentStyle)) this.map.setLayerZoomRange(layerId, minzoom, maxzoom);
1011
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
1074
1012
  return this;
1075
1013
  }
1076
1014
  setFilter(layerId, filter, options) {
1077
- if (!__privateGet(this, _differentStyle))
1078
- this.map.setFilter(layerId, filter, options);
1079
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1015
+ if (!__privateGet(this, _differentStyle)) this.map.setFilter(layerId, filter, options);
1016
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
1080
1017
  return this;
1081
1018
  }
1082
1019
  setPaintProperty(layerId, name, value, options) {
1083
- if (!__privateGet(this, _differentStyle))
1084
- this.map.setPaintProperty(layerId, name, value, options);
1085
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1020
+ if (!__privateGet(this, _differentStyle)) this.map.setPaintProperty(layerId, name, value, options);
1021
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
1086
1022
  return this;
1087
1023
  }
1088
1024
  setLayoutProperty(layerId, name, value, options) {
1089
- if (!__privateGet(this, _differentStyle))
1090
- this.map.setLayoutProperty(layerId, name, value, options);
1091
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1025
+ if (!__privateGet(this, _differentStyle)) this.map.setLayoutProperty(layerId, name, value, options);
1026
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
1092
1027
  return this;
1093
1028
  }
1094
1029
  setGlyphs(glyphsUrl, options) {
1095
- if (!__privateGet(this, _differentStyle))
1096
- this.map.setGlyphs(glyphsUrl, options);
1097
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1030
+ if (!__privateGet(this, _differentStyle)) this.map.setGlyphs(glyphsUrl, options);
1031
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
1098
1032
  return this;
1099
1033
  }
1100
1034
  onAdd(parentMap) {
@@ -1110,8 +1044,8 @@ class Minimap {
1110
1044
  this.map.resize();
1111
1045
  });
1112
1046
  this.map.once("load", () => {
1113
- __privateMethod(this, _addParentRect, addParentRect_fn).call(this, __privateGet(this, _options).parentRect);
1114
- __privateSet(this, _desync, __privateMethod(this, _syncMaps, syncMaps_fn).call(this));
1047
+ __privateMethod(this, _Minimap_instances, addParentRect_fn).call(this, __privateGet(this, _options).parentRect);
1048
+ __privateSet(this, _desync, __privateMethod(this, _Minimap_instances, syncMaps_fn).call(this));
1115
1049
  });
1116
1050
  return __privateGet(this, _container);
1117
1051
  }
@@ -1128,7 +1062,7 @@ _canvasContainer = new WeakMap();
1128
1062
  _parentRect = new WeakMap();
1129
1063
  _differentStyle = new WeakMap();
1130
1064
  _desync = new WeakMap();
1131
- _addParentRect = new WeakSet();
1065
+ _Minimap_instances = new WeakSet();
1132
1066
  addParentRect_fn = function(rect) {
1133
1067
  if (rect === void 0 || rect.linePaint === void 0 && rect.fillPaint === void 0) {
1134
1068
  return;
@@ -1152,12 +1086,15 @@ addParentRect_fn = function(rect) {
1152
1086
  id: "parentRectOutline",
1153
1087
  type: "line",
1154
1088
  source: "parentRect",
1155
- layout: __spreadValues$3({}, rect.lineLayout),
1156
- paint: __spreadValues$3({
1089
+ layout: {
1090
+ ...rect.lineLayout
1091
+ },
1092
+ paint: {
1157
1093
  "line-color": "#FFF",
1158
1094
  "line-width": 1,
1159
- "line-opacity": 0.85
1160
- }, rect.linePaint)
1095
+ "line-opacity": 0.85,
1096
+ ...rect.linePaint
1097
+ }
1161
1098
  });
1162
1099
  }
1163
1100
  if (rect.fillPaint !== void 0) {
@@ -1166,18 +1103,17 @@ addParentRect_fn = function(rect) {
1166
1103
  type: "fill",
1167
1104
  source: "parentRect",
1168
1105
  layout: {},
1169
- paint: __spreadValues$3({
1106
+ paint: {
1170
1107
  "fill-color": "#08F",
1171
- "fill-opacity": 0.135
1172
- }, rect.fillPaint)
1108
+ "fill-opacity": 0.135,
1109
+ ...rect.fillPaint
1110
+ }
1173
1111
  });
1174
1112
  }
1175
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1113
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
1176
1114
  };
1177
- _setParentBounds = new WeakSet();
1178
1115
  setParentBounds_fn = function() {
1179
- if (__privateGet(this, _parentRect) === void 0)
1180
- return;
1116
+ if (__privateGet(this, _parentRect) === void 0) return;
1181
1117
  const { devicePixelRatio } = window;
1182
1118
  const canvas = __privateGet(this, _parentMap).getCanvas();
1183
1119
  const width = canvas.width / devicePixelRatio;
@@ -1188,18 +1124,11 @@ setParentBounds_fn = function() {
1188
1124
  const southWest = unproject([0, height]);
1189
1125
  const southEast = unproject([width, height]);
1190
1126
  __privateGet(this, _parentRect).geometry.coordinates = [
1191
- [
1192
- southWest.toArray(),
1193
- southEast.toArray(),
1194
- northEast.toArray(),
1195
- northWest.toArray(),
1196
- southWest.toArray()
1197
- ]
1127
+ [southWest.toArray(), southEast.toArray(), northEast.toArray(), northWest.toArray(), southWest.toArray()]
1198
1128
  ];
1199
1129
  const source = this.map.getSource("parentRect");
1200
1130
  source.setData(__privateGet(this, _parentRect));
1201
1131
  };
1202
- _syncMaps = new WeakSet();
1203
1132
  syncMaps_fn = function() {
1204
1133
  const { pitchAdjust } = __privateGet(this, _options);
1205
1134
  const parentCallback = () => {
@@ -1217,12 +1146,11 @@ syncMaps_fn = function() {
1217
1146
  this.map.off("move", minimapCallback);
1218
1147
  };
1219
1148
  const sync = (which) => {
1220
- var _a;
1221
1149
  off();
1222
1150
  const from = which === "parent" ? __privateGet(this, _parentMap) : this.map;
1223
1151
  const to = which === "parent" ? this.map : __privateGet(this, _parentMap);
1224
1152
  const center = from.getCenter();
1225
- const zoom = from.getZoom() + ((_a = __privateGet(this, _options).zoomAdjust) != null ? _a : -4) * (which === "parent" ? 1 : -1);
1153
+ const zoom = from.getZoom() + (__privateGet(this, _options).zoomAdjust ?? -4) * (which === "parent" ? 1 : -1);
1226
1154
  const bearing = from.getBearing();
1227
1155
  const pitch = from.getPitch();
1228
1156
  to.jumpTo({
@@ -1231,7 +1159,7 @@ syncMaps_fn = function() {
1231
1159
  bearing,
1232
1160
  pitch: pitchAdjust ? pitch : 0
1233
1161
  });
1234
- __privateMethod(this, _setParentBounds, setParentBounds_fn).call(this);
1162
+ __privateMethod(this, _Minimap_instances, setParentBounds_fn).call(this);
1235
1163
  on();
1236
1164
  };
1237
1165
  on();
@@ -1240,65 +1168,20 @@ syncMaps_fn = function() {
1240
1168
  };
1241
1169
  };
1242
1170
 
1243
- var __defProp$3 = Object.defineProperty;
1244
- var __defProps$1 = Object.defineProperties;
1245
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
1246
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1247
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1248
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
1249
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1250
- var __spreadValues$2 = (a, b) => {
1251
- for (var prop in b || (b = {}))
1252
- if (__hasOwnProp$2.call(b, prop))
1253
- __defNormalProp$3(a, prop, b[prop]);
1254
- if (__getOwnPropSymbols$2)
1255
- for (var prop of __getOwnPropSymbols$2(b)) {
1256
- if (__propIsEnum$2.call(b, prop))
1257
- __defNormalProp$3(a, prop, b[prop]);
1258
- }
1259
- return a;
1260
- };
1261
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
1262
- var __publicField$1 = (obj, key, value) => {
1263
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
1264
- return value;
1265
- };
1266
- var __async$1 = (__this, __arguments, generator) => {
1267
- return new Promise((resolve, reject) => {
1268
- var fulfilled = (value) => {
1269
- try {
1270
- step(generator.next(value));
1271
- } catch (e) {
1272
- reject(e);
1273
- }
1274
- };
1275
- var rejected = (value) => {
1276
- try {
1277
- step(generator.throw(value));
1278
- } catch (e) {
1279
- reject(e);
1280
- }
1281
- };
1282
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1283
- step((generator = generator.apply(__this, __arguments)).next());
1284
- });
1285
- };
1286
1171
  const GeolocationType = {
1287
1172
  POINT: "POINT",
1288
1173
  COUNTRY: "COUNTRY"
1289
1174
  };
1290
1175
  class Map extends maplibregl.Map {
1291
1176
  constructor(options) {
1292
- var _a, _b, _c;
1177
+ displayNoWebGlWarning(options.container);
1293
1178
  if (options.apiKey) {
1294
- config$1.apiKey = options.apiKey;
1179
+ config.apiKey = options.apiKey;
1295
1180
  }
1296
1181
  const style = styleToStyle(options.style);
1297
1182
  const hashPreConstructor = location.hash;
1298
- if (!config$1.apiKey) {
1299
- console.warn(
1300
- "MapTiler Cloud API key is not set. Visit https://maptiler.com and try Cloud for free!"
1301
- );
1183
+ if (!config.apiKey) {
1184
+ console.warn("MapTiler Cloud API key is not set. Visit https://maptiler.com and try Cloud for free!");
1302
1185
  }
1303
1186
  let attributionControlOptions = {
1304
1187
  compact: false
@@ -1306,31 +1189,36 @@ class Map extends maplibregl.Map {
1306
1189
  if (options.customAttribution) {
1307
1190
  attributionControlOptions.customAttribution = options.customAttribution;
1308
1191
  } else if (options.attributionControl && typeof options.attributionControl === "object") {
1309
- attributionControlOptions = __spreadValues$2(__spreadValues$2({}, attributionControlOptions), options.attributionControl);
1192
+ attributionControlOptions = {
1193
+ ...attributionControlOptions,
1194
+ ...options.attributionControl
1195
+ };
1310
1196
  }
1311
- super(__spreadProps$1(__spreadValues$2({}, options), {
1197
+ super({
1198
+ ...options,
1312
1199
  style,
1313
1200
  maplibreLogo: false,
1314
1201
  transformRequest: combineTransformRequest(options.transformRequest),
1315
1202
  attributionControl: options.forceNoAttributionControl === true ? false : attributionControlOptions
1316
- }));
1317
- __publicField$1(this, "isTerrainEnabled", false);
1318
- __publicField$1(this, "terrainExaggeration", 1);
1319
- __publicField$1(this, "primaryLanguage");
1320
- __publicField$1(this, "terrainGrowing", false);
1321
- __publicField$1(this, "terrainFlattening", false);
1322
- __publicField$1(this, "minimap");
1323
- __publicField$1(this, "forceLanguageUpdate");
1324
- __publicField$1(this, "languageAlwaysBeenStyle");
1325
- __publicField$1(this, "isReady", false);
1326
- if (config$1.caching) {
1203
+ });
1204
+ this.isTerrainEnabled = false;
1205
+ this.terrainExaggeration = 1;
1206
+ this.terrainGrowing = false;
1207
+ this.terrainFlattening = false;
1208
+ this.isReady = false;
1209
+ if (config.caching && !CACHE_API_AVAILABLE) {
1210
+ console.warn(
1211
+ "The cache API is only available in secure contexts. More info at https://developer.mozilla.org/en-US/docs/Web/API/Cache"
1212
+ );
1213
+ }
1214
+ if (config.caching && CACHE_API_AVAILABLE) {
1327
1215
  registerLocalCacheProtocol();
1328
1216
  }
1329
- this.primaryLanguage = (_a = options.language) != null ? _a : config$1.primaryLanguage;
1217
+ this.primaryLanguage = options.language ?? config.primaryLanguage;
1330
1218
  this.forceLanguageUpdate = this.primaryLanguage === Language.STYLE || this.primaryLanguage === Language.STYLE_LOCK ? false : true;
1331
1219
  this.languageAlwaysBeenStyle = this.primaryLanguage === Language.STYLE;
1332
- this.terrainExaggeration = (_b = options.terrainExaggeration) != null ? _b : this.terrainExaggeration;
1333
- this.once("styledata", () => __async$1(this, null, function* () {
1220
+ this.terrainExaggeration = options.terrainExaggeration ?? this.terrainExaggeration;
1221
+ this.once("styledata", async () => {
1334
1222
  if (!options.geolocate) {
1335
1223
  return;
1336
1224
  }
@@ -1342,7 +1230,7 @@ class Map extends maplibregl.Map {
1342
1230
  }
1343
1231
  try {
1344
1232
  if (options.geolocate === GeolocationType.COUNTRY) {
1345
- yield this.fitToIpBounds();
1233
+ await this.fitToIpBounds();
1346
1234
  return;
1347
1235
  }
1348
1236
  } catch (e) {
@@ -1350,12 +1238,12 @@ class Map extends maplibregl.Map {
1350
1238
  }
1351
1239
  let ipLocatedCameraHash;
1352
1240
  try {
1353
- yield this.centerOnIpPoint(options.zoom);
1241
+ await this.centerOnIpPoint(options.zoom);
1354
1242
  ipLocatedCameraHash = this.getCameraHash();
1355
1243
  } catch (e) {
1356
1244
  console.warn(e.message);
1357
1245
  }
1358
- const locationResult = yield navigator.permissions.query({
1246
+ const locationResult = await navigator.permissions.query({
1359
1247
  name: "geolocation"
1360
1248
  });
1361
1249
  if (locationResult.state === "granted") {
@@ -1393,7 +1281,7 @@ class Map extends maplibregl.Map {
1393
1281
  }
1394
1282
  );
1395
1283
  }
1396
- }));
1284
+ });
1397
1285
  this.on("styledata", () => {
1398
1286
  this.setPrimaryLanguage(this.primaryLanguage);
1399
1287
  });
@@ -1402,41 +1290,33 @@ class Map extends maplibregl.Map {
1402
1290
  this.enableTerrain(this.terrainExaggeration);
1403
1291
  }
1404
1292
  });
1405
- this.once("load", () => __async$1(this, null, function* () {
1406
- enableRTL();
1407
- }));
1408
- this.once("load", () => __async$1(this, null, function* () {
1293
+ this.once("load", async () => {
1409
1294
  let tileJsonContent = { logo: null };
1410
1295
  try {
1411
1296
  const possibleSources = Object.keys(this.style.sourceCaches).map((sourceName) => this.getSource(sourceName)).filter(
1412
- (s) => s && "url" in s && typeof s.url === "string" && (s == null ? void 0 : s.url.includes("tiles.json"))
1413
- );
1414
- const styleUrl = new URL(
1415
- possibleSources[0].url
1297
+ (s) => s && "url" in s && typeof s.url === "string" && s?.url.includes("tiles.json")
1416
1298
  );
1299
+ const styleUrl = new URL(possibleSources[0].url);
1417
1300
  if (!styleUrl.searchParams.has("key")) {
1418
- styleUrl.searchParams.append("key", config$1.apiKey);
1301
+ styleUrl.searchParams.append("key", config.apiKey);
1419
1302
  }
1420
- const tileJsonRes = yield fetch(styleUrl.href);
1421
- tileJsonContent = yield tileJsonRes.json();
1303
+ const tileJsonRes = await fetch(styleUrl.href);
1304
+ tileJsonContent = await tileJsonRes.json();
1422
1305
  } catch (e) {
1423
1306
  }
1424
1307
  if (options.forceNoAttributionControl !== true) {
1425
1308
  if ("logo" in tileJsonContent && tileJsonContent.logo) {
1426
1309
  const logoURL = tileJsonContent.logo;
1427
- this.addControl(
1428
- new MaptilerLogoControl({ logoURL }),
1429
- options.logoPosition
1430
- );
1310
+ this.addControl(new MaptilerLogoControl({ logoURL }), options.logoPosition);
1431
1311
  } else if (options.maptilerLogo) {
1432
1312
  this.addControl(new MaptilerLogoControl(), options.logoPosition);
1433
1313
  }
1434
1314
  }
1435
1315
  if (options.scaleControl) {
1436
1316
  const position = options.scaleControl === true || options.scaleControl === void 0 ? "bottom-right" : options.scaleControl;
1437
- const scaleControl = new ScaleControl({ unit: config$1.unit });
1317
+ const scaleControl = new ScaleControl({ unit: config.unit });
1438
1318
  this.addControl(scaleControl, position);
1439
- config$1.on("unit", (unit) => {
1319
+ config.on("unit", (unit) => {
1440
1320
  scaleControl.setUnit(unit);
1441
1321
  });
1442
1322
  }
@@ -1474,7 +1354,7 @@ class Map extends maplibregl.Map {
1474
1354
  }
1475
1355
  this.isReady = true;
1476
1356
  this.fire("ready", { target: this });
1477
- }));
1357
+ });
1478
1358
  let loadEventTriggered = false;
1479
1359
  let terrainEventTriggered = false;
1480
1360
  let terrainEventData;
@@ -1485,7 +1365,6 @@ class Map extends maplibregl.Map {
1485
1365
  }
1486
1366
  });
1487
1367
  this.once("style.load", () => {
1488
- var _a2;
1489
1368
  const { minimap } = options;
1490
1369
  if (typeof minimap === "object") {
1491
1370
  const {
@@ -1535,7 +1414,7 @@ class Map extends maplibregl.Map {
1535
1414
  pixelRatio,
1536
1415
  validateStyle
1537
1416
  });
1538
- this.addControl(this.minimap, (_a2 = minimap.position) != null ? _a2 : "bottom-left");
1417
+ this.addControl(this.minimap, minimap.position ?? "bottom-left");
1539
1418
  } else if (minimap === true) {
1540
1419
  this.minimap = new Minimap({}, options);
1541
1420
  this.addControl(this.minimap, "bottom-left");
@@ -1545,8 +1424,7 @@ class Map extends maplibregl.Map {
1545
1424
  }
1546
1425
  });
1547
1426
  const terrainCallback = (evt) => {
1548
- if (!evt.terrain)
1549
- return;
1427
+ if (!evt.terrain) return;
1550
1428
  terrainEventTriggered = true;
1551
1429
  terrainEventData = {
1552
1430
  type: "loadWithTerrain",
@@ -1560,9 +1438,7 @@ class Map extends maplibregl.Map {
1560
1438
  };
1561
1439
  this.on("terrain", terrainCallback);
1562
1440
  if (options.terrain) {
1563
- this.enableTerrain(
1564
- (_c = options.terrainExaggeration) != null ? _c : this.terrainExaggeration
1565
- );
1441
+ this.enableTerrain(options.terrainExaggeration ?? this.terrainExaggeration);
1566
1442
  }
1567
1443
  }
1568
1444
  /**
@@ -1571,15 +1447,13 @@ class Map extends maplibregl.Map {
1571
1447
  * otherwise, it is resolved as a result of the "load" event.
1572
1448
  * @returns
1573
1449
  */
1574
- onLoadAsync() {
1575
- return __async$1(this, null, function* () {
1576
- return new Promise((resolve) => {
1577
- if (this.loaded()) {
1578
- return resolve(this);
1579
- }
1580
- this.once("load", () => {
1581
- resolve(this);
1582
- });
1450
+ async onLoadAsync() {
1451
+ return new Promise((resolve) => {
1452
+ if (this.loaded()) {
1453
+ return resolve(this);
1454
+ }
1455
+ this.once("load", () => {
1456
+ resolve(this);
1583
1457
  });
1584
1458
  });
1585
1459
  }
@@ -1591,15 +1465,13 @@ class Map extends maplibregl.Map {
1591
1465
  * dealt with. This happens after the "load" event, due to the asynchronous nature
1592
1466
  * of some built-in controls.
1593
1467
  */
1594
- onReadyAsync() {
1595
- return __async$1(this, null, function* () {
1596
- return new Promise((resolve) => {
1597
- if (this.isReady) {
1598
- return resolve(this);
1599
- }
1600
- this.once("ready", () => {
1601
- resolve(this);
1602
- });
1468
+ async onReadyAsync() {
1469
+ return new Promise((resolve) => {
1470
+ if (this.isReady) {
1471
+ return resolve(this);
1472
+ }
1473
+ this.once("ready", () => {
1474
+ resolve(this);
1603
1475
  });
1604
1476
  });
1605
1477
  }
@@ -1610,15 +1482,13 @@ class Map extends maplibregl.Map {
1610
1482
  * otherwise, it is resolved as a result of the "loadWithTerrain" event.
1611
1483
  * @returns
1612
1484
  */
1613
- onLoadWithTerrainAsync() {
1614
- return __async$1(this, null, function* () {
1615
- return new Promise((resolve) => {
1616
- if (this.isReady && this.terrain) {
1617
- return resolve(this);
1618
- }
1619
- this.once("loadWithTerrain", () => {
1620
- resolve(this);
1621
- });
1485
+ async onLoadWithTerrainAsync() {
1486
+ return new Promise((resolve) => {
1487
+ if (this.isReady && this.terrain) {
1488
+ return resolve(this);
1489
+ }
1490
+ this.once("loadWithTerrain", () => {
1491
+ resolve(this);
1622
1492
  });
1623
1493
  });
1624
1494
  }
@@ -1630,8 +1500,7 @@ class Map extends maplibregl.Map {
1630
1500
  * - a longer form with the prefix `"maptiler://"` (eg. `"maptiler://streets-v2"`)
1631
1501
  */
1632
1502
  setStyle(style, options) {
1633
- var _a;
1634
- (_a = this.minimap) == null ? void 0 : _a.setStyle(style);
1503
+ this.minimap?.setStyle(style);
1635
1504
  this.forceLanguageUpdate = true;
1636
1505
  this.once("idle", () => {
1637
1506
  this.forceLanguageUpdate = false;
@@ -1658,8 +1527,7 @@ class Map extends maplibregl.Map {
1658
1527
  * @returns `this`
1659
1528
  */
1660
1529
  addLayer(layer, beforeId) {
1661
- var _a;
1662
- (_a = this.minimap) == null ? void 0 : _a.addLayer(layer, beforeId);
1530
+ this.minimap?.addLayer(layer, beforeId);
1663
1531
  return super.addLayer(layer, beforeId);
1664
1532
  }
1665
1533
  /**
@@ -1676,8 +1544,7 @@ class Map extends maplibregl.Map {
1676
1544
  * ```
1677
1545
  */
1678
1546
  moveLayer(id, beforeId) {
1679
- var _a;
1680
- (_a = this.minimap) == null ? void 0 : _a.moveLayer(id, beforeId);
1547
+ this.minimap?.moveLayer(id, beforeId);
1681
1548
  return super.moveLayer(id, beforeId);
1682
1549
  }
1683
1550
  /**
@@ -1695,8 +1562,7 @@ class Map extends maplibregl.Map {
1695
1562
  * ```
1696
1563
  */
1697
1564
  removeLayer(id) {
1698
- var _a;
1699
- (_a = this.minimap) == null ? void 0 : _a.removeLayer(id);
1565
+ this.minimap?.removeLayer(id);
1700
1566
  return super.removeLayer(id);
1701
1567
  }
1702
1568
  /**
@@ -1711,8 +1577,7 @@ class Map extends maplibregl.Map {
1711
1577
  * layer will not be rendered at all zoom levels in the zoom range.
1712
1578
  */
1713
1579
  setLayerZoomRange(layerId, minzoom, maxzoom) {
1714
- var _a;
1715
- (_a = this.minimap) == null ? void 0 : _a.setLayerZoomRange(layerId, minzoom, maxzoom);
1580
+ this.minimap?.setLayerZoomRange(layerId, minzoom, maxzoom);
1716
1581
  return super.setLayerZoomRange(layerId, minzoom, maxzoom);
1717
1582
  }
1718
1583
  /**
@@ -1727,8 +1592,7 @@ class Map extends maplibregl.Map {
1727
1592
  * To clear the filter, pass `null` or `undefined` as the second parameter.
1728
1593
  */
1729
1594
  setFilter(layerId, filter, options) {
1730
- var _a;
1731
- (_a = this.minimap) == null ? void 0 : _a.setFilter(layerId, filter, options);
1595
+ this.minimap?.setFilter(layerId, filter, options);
1732
1596
  return super.setFilter(layerId, filter, options);
1733
1597
  }
1734
1598
  /**
@@ -1746,8 +1610,7 @@ class Map extends maplibregl.Map {
1746
1610
  * ```
1747
1611
  */
1748
1612
  setPaintProperty(layerId, name, value, options) {
1749
- var _a;
1750
- (_a = this.minimap) == null ? void 0 : _a.setPaintProperty(layerId, name, value, options);
1613
+ this.minimap?.setPaintProperty(layerId, name, value, options);
1751
1614
  return super.setPaintProperty(layerId, name, value, options);
1752
1615
  }
1753
1616
  /**
@@ -1764,8 +1627,7 @@ class Map extends maplibregl.Map {
1764
1627
  * @returns `this`
1765
1628
  */
1766
1629
  setLayoutProperty(layerId, name, value, options) {
1767
- var _a;
1768
- (_a = this.minimap) == null ? void 0 : _a.setLayoutProperty(layerId, name, value, options);
1630
+ this.minimap?.setLayoutProperty(layerId, name, value, options);
1769
1631
  return super.setLayoutProperty(layerId, name, value, options);
1770
1632
  }
1771
1633
  /**
@@ -1780,27 +1642,22 @@ class Map extends maplibregl.Map {
1780
1642
  * ```
1781
1643
  */
1782
1644
  setGlyphs(glyphsUrl, options) {
1783
- var _a;
1784
- (_a = this.minimap) == null ? void 0 : _a.setGlyphs(glyphsUrl, options);
1645
+ this.minimap?.setGlyphs(glyphsUrl, options);
1785
1646
  return super.setGlyphs(glyphsUrl, options);
1786
1647
  }
1787
1648
  getStyleLanguage() {
1788
- if (!this.style.stylesheet.metadata)
1789
- return null;
1790
- if (typeof this.style.stylesheet.metadata !== "object")
1791
- return null;
1649
+ if (!this.style.stylesheet.metadata) return null;
1650
+ if (typeof this.style.stylesheet.metadata !== "object") return null;
1792
1651
  if ("maptiler:language" in this.style.stylesheet.metadata && typeof this.style.stylesheet.metadata["maptiler:language"] === "string") {
1793
1652
  return this.style.stylesheet.metadata["maptiler:language"];
1794
- } else {
1795
- return null;
1796
1653
  }
1654
+ return null;
1797
1655
  }
1798
1656
  /**
1799
1657
  * Define the primary language of the map. Note that not all the languages shorthands provided are available.
1800
1658
  */
1801
1659
  setLanguage(language) {
1802
- var _a, _b;
1803
- (_b = (_a = this.minimap) == null ? void 0 : _a.map) == null ? void 0 : _b.setLanguage(language);
1660
+ this.minimap?.map?.setLanguage(language);
1804
1661
  this.onStyleReady(() => {
1805
1662
  this.setPrimaryLanguage(language);
1806
1663
  });
@@ -1846,7 +1703,7 @@ class Map extends maplibregl.Map {
1846
1703
  }
1847
1704
  let langStr = Language.LOCAL;
1848
1705
  let replacer = `{${langStr}}`;
1849
- if (languageNonStyle == Language.VISITOR) {
1706
+ if (languageNonStyle === Language.VISITOR) {
1850
1707
  langStr = getBrowserLanguage();
1851
1708
  replacer = [
1852
1709
  "case",
@@ -1855,18 +1712,11 @@ class Map extends maplibregl.Map {
1855
1712
  "case",
1856
1713
  ["==", ["get", langStr], ["get", Language.LOCAL]],
1857
1714
  ["get", Language.LOCAL],
1858
- [
1859
- "format",
1860
- ["get", langStr],
1861
- { "font-scale": 0.8 },
1862
- "\n",
1863
- ["get", Language.LOCAL],
1864
- { "font-scale": 1.1 }
1865
- ]
1715
+ ["format", ["get", langStr], { "font-scale": 0.8 }, "\n", ["get", Language.LOCAL], { "font-scale": 1.1 }]
1866
1716
  ],
1867
1717
  ["get", Language.LOCAL]
1868
1718
  ];
1869
- } else if (languageNonStyle == Language.VISITOR_ENGLISH) {
1719
+ } else if (languageNonStyle === Language.VISITOR_ENGLISH) {
1870
1720
  langStr = Language.ENGLISH;
1871
1721
  replacer = [
1872
1722
  "case",
@@ -1875,36 +1725,19 @@ class Map extends maplibregl.Map {
1875
1725
  "case",
1876
1726
  ["==", ["get", langStr], ["get", Language.LOCAL]],
1877
1727
  ["get", Language.LOCAL],
1878
- [
1879
- "format",
1880
- ["get", langStr],
1881
- { "font-scale": 0.8 },
1882
- "\n",
1883
- ["get", Language.LOCAL],
1884
- { "font-scale": 1.1 }
1885
- ]
1728
+ ["format", ["get", langStr], { "font-scale": 0.8 }, "\n", ["get", Language.LOCAL], { "font-scale": 1.1 }]
1886
1729
  ],
1887
1730
  ["get", Language.LOCAL]
1888
1731
  ];
1889
1732
  } else if (languageNonStyle === Language.AUTO) {
1890
1733
  langStr = getBrowserLanguage();
1891
- replacer = [
1892
- "case",
1893
- ["has", langStr],
1894
- ["get", langStr],
1895
- ["get", Language.LOCAL]
1896
- ];
1734
+ replacer = ["case", ["has", langStr], ["get", langStr], ["get", Language.LOCAL]];
1897
1735
  } else if (languageNonStyle === Language.LOCAL) {
1898
1736
  langStr = Language.LOCAL;
1899
1737
  replacer = `{${langStr}}`;
1900
1738
  } else {
1901
1739
  langStr = languageNonStyle;
1902
- replacer = [
1903
- "case",
1904
- ["has", langStr],
1905
- ["get", langStr],
1906
- ["get", Language.LOCAL]
1907
- ];
1740
+ replacer = ["case", ["has", langStr], ["get", langStr], ["get", Language.LOCAL]];
1908
1741
  }
1909
1742
  const { layers } = this.getStyle();
1910
1743
  for (const genericLayer of layers) {
@@ -1974,7 +1807,7 @@ class Map extends maplibregl.Map {
1974
1807
  }
1975
1808
  const positionInLoop = (performance.now() - startTime) / durationMs;
1976
1809
  if (positionInLoop < 0.99) {
1977
- const exaggerationFactor = 1 - Math.pow(1 - positionInLoop, 4);
1810
+ const exaggerationFactor = 1 - (1 - positionInLoop) ** 4;
1978
1811
  const newExaggeration = currentExaggeration + exaggerationFactor * deltaExaggeration;
1979
1812
  this.terrain.exaggeration = newExaggeration;
1980
1813
  requestAnimationFrame(updateExaggeration);
@@ -1997,7 +1830,7 @@ class Map extends maplibregl.Map {
1997
1830
  console.warn("Terrain exaggeration cannot be negative.");
1998
1831
  return;
1999
1832
  }
2000
- const dataEventTerrainGrow = (evt) => __async$1(this, null, function* () {
1833
+ const dataEventTerrainGrow = async (evt) => {
2001
1834
  if (!this.terrain) {
2002
1835
  return;
2003
1836
  }
@@ -2016,7 +1849,7 @@ class Map extends maplibregl.Map {
2016
1849
  }
2017
1850
  this.off("data", dataEventTerrainGrow);
2018
1851
  this.growTerrain(exaggeration);
2019
- });
1852
+ };
2020
1853
  const addTerrain = () => {
2021
1854
  this.isTerrainEnabled = true;
2022
1855
  this.terrainExaggeration = exaggeration;
@@ -2066,7 +1899,7 @@ class Map extends maplibregl.Map {
2066
1899
  }
2067
1900
  const positionInLoop = (performance.now() - startTime) / animationLoopDuration;
2068
1901
  if (positionInLoop < 0.99) {
2069
- const exaggerationFactor = Math.pow(1 - positionInLoop, 4);
1902
+ const exaggerationFactor = (1 - positionInLoop) ** 4;
2070
1903
  const newExaggeration = currentExaggeration * exaggerationFactor;
2071
1904
  this.terrain.exaggeration = newExaggeration;
2072
1905
  requestAnimationFrame(updateExaggeration);
@@ -2094,230 +1927,83 @@ class Map extends maplibregl.Map {
2094
1927
  */
2095
1928
  setTerrainExaggeration(exaggeration, animate = true) {
2096
1929
  if (!animate && this.terrain) {
2097
- this.terrainExaggeration = exaggeration;
2098
- this.terrain.exaggeration = exaggeration;
2099
- this.triggerRepaint();
2100
- } else {
2101
- this.enableTerrain(exaggeration);
2102
- }
2103
- }
2104
- /**
2105
- * Perform an action when the style is ready. It could be at the moment of calling this method
2106
- * or later.
2107
- */
2108
- onStyleReady(cb) {
2109
- if (this.isStyleLoaded()) {
2110
- cb();
2111
- } else {
2112
- this.once("styledata", () => {
2113
- cb();
2114
- });
2115
- }
2116
- }
2117
- fitToIpBounds() {
2118
- return __async$1(this, null, function* () {
2119
- const ipGeolocateResult = yield geolocation.info();
2120
- this.fitBounds(
2121
- ipGeolocateResult.country_bounds,
2122
- {
2123
- duration: 0,
2124
- padding: 100
2125
- }
2126
- );
2127
- });
2128
- }
2129
- centerOnIpPoint(zoom) {
2130
- return __async$1(this, null, function* () {
2131
- var _a, _b;
2132
- const ipGeolocateResult = yield geolocation.info();
2133
- this.jumpTo({
2134
- center: [
2135
- (_a = ipGeolocateResult == null ? void 0 : ipGeolocateResult.longitude) != null ? _a : 0,
2136
- (_b = ipGeolocateResult == null ? void 0 : ipGeolocateResult.latitude) != null ? _b : 0
2137
- ],
2138
- zoom: zoom || 11
2139
- });
2140
- });
2141
- }
2142
- getCameraHash() {
2143
- const hashBin = new Float32Array(5);
2144
- const center = this.getCenter();
2145
- hashBin[0] = center.lng;
2146
- hashBin[1] = center.lat;
2147
- hashBin[2] = this.getZoom();
2148
- hashBin[3] = this.getPitch();
2149
- hashBin[4] = this.getBearing();
2150
- return Base64.fromUint8Array(new Uint8Array(hashBin.buffer));
2151
- }
2152
- /**
2153
- * Get the SDK config object.
2154
- * This is convenient to dispatch the SDK configuration to externally built layers
2155
- * that do not directly have access to the SDK configuration but do have access to a Map instance.
2156
- */
2157
- getSdkConfig() {
2158
- return config$1;
2159
- }
2160
- /**
2161
- * Get the MapTiler session ID. Convenient to dispatch to externaly built component
2162
- * that do not directly have access to the SDK configuration but do have access to a Map instance.
2163
- * @returns
2164
- */
2165
- getMaptilerSessionId() {
2166
- return MAPTILER_SESSION_ID;
2167
- }
2168
- /**
2169
- * Updates the requestManager's transform request with a new function.
2170
- *
2171
- * @param transformRequest A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests.
2172
- * Expected to return an object with a `url` property and optionally `headers` and `credentials` properties
2173
- *
2174
- * @returns {Map} `this`
2175
- *
2176
- * @example
2177
- * map.setTransformRequest((url: string, resourceType: string) => {});
2178
- */
2179
- setTransformRequest(transformRequest) {
2180
- super.setTransformRequest(combineTransformRequest(transformRequest));
2181
- return this;
2182
- }
2183
- }
2184
-
2185
- class Marker extends maplibregl.Marker {
2186
- addTo(map) {
2187
- return super.addTo(map);
2188
- }
2189
- }
2190
-
2191
- class Popup extends maplibregl.Popup {
2192
- addTo(map) {
2193
- return super.addTo(map);
2194
- }
2195
- }
2196
-
2197
- class Style extends maplibregl.Style {
2198
- constructor(map, options = {}) {
2199
- super(map, options);
2200
- }
2201
- }
2202
-
2203
- class CanvasSource extends maplibregl.CanvasSource {
2204
- onAdd(map) {
2205
- super.onAdd(map);
2206
- }
2207
- }
2208
-
2209
- class GeoJSONSource extends maplibregl.GeoJSONSource {
2210
- onAdd(map) {
2211
- super.onAdd(map);
2212
- }
2213
- }
2214
-
2215
- class ImageSource extends maplibregl.ImageSource {
2216
- onAdd(map) {
2217
- super.onAdd(map);
2218
- }
2219
- }
2220
-
2221
- class RasterTileSource extends maplibregl.RasterTileSource {
2222
- onAdd(map) {
2223
- super.onAdd(map);
2224
- }
2225
- }
2226
-
2227
- class RasterDEMTileSource extends maplibregl.RasterDEMTileSource {
2228
- onAdd(map) {
2229
- super.onAdd(map);
2230
- }
2231
- }
2232
-
2233
- class VectorTileSource extends maplibregl.VectorTileSource {
2234
- onAdd(map) {
2235
- super.onAdd(map);
2236
- }
2237
- }
2238
-
2239
- class VideoSource extends maplibregl.VideoSource {
2240
- onAdd(map) {
2241
- super.onAdd(map);
2242
- }
2243
- }
2244
-
2245
- class AttributionControl extends maplibregl.AttributionControl {
2246
- onAdd(map) {
2247
- return super.onAdd(map);
2248
- }
2249
- }
2250
-
2251
- class TerrainControl extends maplibregl.TerrainControl {
2252
- onAdd(map) {
2253
- return super.onAdd(map);
2254
- }
2255
- }
2256
-
2257
- class BoxZoomHandler extends maplibregl.BoxZoomHandler {
2258
- constructor(map, options) {
2259
- super(map, options);
1930
+ this.terrainExaggeration = exaggeration;
1931
+ this.terrain.exaggeration = exaggeration;
1932
+ this.triggerRepaint();
1933
+ } else {
1934
+ this.enableTerrain(exaggeration);
1935
+ }
2260
1936
  }
2261
- }
2262
-
2263
- class ScrollZoomHandler extends maplibregl.ScrollZoomHandler {
2264
- constructor(map, triggerRenderFrame) {
2265
- super(map, triggerRenderFrame);
1937
+ /**
1938
+ * Perform an action when the style is ready. It could be at the moment of calling this method
1939
+ * or later.
1940
+ */
1941
+ onStyleReady(cb) {
1942
+ if (this.isStyleLoaded()) {
1943
+ cb();
1944
+ } else {
1945
+ this.once("styledata", () => {
1946
+ cb();
1947
+ });
1948
+ }
2266
1949
  }
2267
- }
2268
-
2269
- class CooperativeGesturesHandler extends maplibregl.CooperativeGesturesHandler {
2270
- constructor(map, options) {
2271
- super(map, options);
1950
+ async fitToIpBounds() {
1951
+ const ipGeolocateResult = await geolocation.info();
1952
+ this.fitBounds(ipGeolocateResult.country_bounds, {
1953
+ duration: 0,
1954
+ padding: 100
1955
+ });
2272
1956
  }
2273
- }
2274
-
2275
- class KeyboardHandler extends maplibregl.KeyboardHandler {
2276
- constructor(map) {
2277
- super(map);
1957
+ async centerOnIpPoint(zoom) {
1958
+ const ipGeolocateResult = await geolocation.info();
1959
+ this.jumpTo({
1960
+ center: [ipGeolocateResult?.longitude ?? 0, ipGeolocateResult?.latitude ?? 0],
1961
+ zoom: zoom || 11
1962
+ });
2278
1963
  }
2279
- }
2280
-
2281
- class TwoFingersTouchPitchHandler extends maplibregl.TwoFingersTouchPitchHandler {
2282
- constructor(map) {
2283
- super(map);
1964
+ getCameraHash() {
1965
+ const hashBin = new Float32Array(5);
1966
+ const center = this.getCenter();
1967
+ hashBin[0] = center.lng;
1968
+ hashBin[1] = center.lat;
1969
+ hashBin[2] = this.getZoom();
1970
+ hashBin[3] = this.getPitch();
1971
+ hashBin[4] = this.getBearing();
1972
+ return Base64.fromUint8Array(new Uint8Array(hashBin.buffer));
2284
1973
  }
2285
- }
2286
-
2287
- class MapWheelEvent extends maplibregl.MapWheelEvent {
2288
- constructor(type, map, originalEvent) {
2289
- super(type, map, originalEvent);
1974
+ /**
1975
+ * Get the SDK config object.
1976
+ * This is convenient to dispatch the SDK configuration to externally built layers
1977
+ * that do not directly have access to the SDK configuration but do have access to a Map instance.
1978
+ */
1979
+ getSdkConfig() {
1980
+ return config;
2290
1981
  }
2291
- }
2292
-
2293
- class MapTouchEvent extends maplibregl.MapTouchEvent {
2294
- constructor(type, map, originalEvent) {
2295
- super(type, map, originalEvent);
1982
+ /**
1983
+ * Get the MapTiler session ID. Convenient to dispatch to externaly built component
1984
+ * that do not directly have access to the SDK configuration but do have access to a Map instance.
1985
+ * @returns
1986
+ */
1987
+ getMaptilerSessionId() {
1988
+ return MAPTILER_SESSION_ID;
2296
1989
  }
2297
- }
2298
-
2299
- class MapMouseEvent extends maplibregl.MapMouseEvent {
2300
- constructor(type, map, originalEvent, data = {}) {
2301
- super(type, map, originalEvent, data);
1990
+ /**
1991
+ * Updates the requestManager's transform request with a new function.
1992
+ *
1993
+ * @param transformRequest A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests.
1994
+ * Expected to return an object with a `url` property and optionally `headers` and `credentials` properties
1995
+ *
1996
+ * @returns {Map} `this`
1997
+ *
1998
+ * @example
1999
+ * map.setTransformRequest((url: string, resourceType: string) => {});
2000
+ */
2001
+ setTransformRequest(transformRequest) {
2002
+ super.setTransformRequest(combineTransformRequest(transformRequest));
2003
+ return this;
2302
2004
  }
2303
2005
  }
2304
2006
 
2305
- var __defProp$2 = Object.defineProperty;
2306
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
2307
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
2308
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
2309
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2310
- var __spreadValues$1 = (a, b) => {
2311
- for (var prop in b || (b = {}))
2312
- if (__hasOwnProp$1.call(b, prop))
2313
- __defNormalProp$2(a, prop, b[prop]);
2314
- if (__getOwnPropSymbols$1)
2315
- for (var prop of __getOwnPropSymbols$1(b)) {
2316
- if (__propIsEnum$1.call(b, prop))
2317
- __defNormalProp$2(a, prop, b[prop]);
2318
- }
2319
- return a;
2320
- };
2321
2007
  function str2xml(str) {
2322
2008
  if (typeof DOMParser !== "undefined") {
2323
2009
  const doc = new DOMParser().parseFromString(str, "application/xml");
@@ -2325,9 +2011,8 @@ function str2xml(str) {
2325
2011
  throw new Error("The provided string is not valid XML");
2326
2012
  }
2327
2013
  return doc;
2328
- } else {
2329
- throw new Error("No XML parser found");
2330
2014
  }
2015
+ throw new Error("No XML parser found");
2331
2016
  }
2332
2017
  function hasChildNodeWithName(doc, nodeName) {
2333
2018
  if (!doc.hasChildNodes()) {
@@ -2348,27 +2033,24 @@ function xml2str(node) {
2348
2033
  throw new Error("No XML serializer found");
2349
2034
  }
2350
2035
  function gpx(doc) {
2351
- if (typeof doc === "string")
2352
- doc = str2xml(doc);
2353
- if (!hasChildNodeWithName(doc, "gpx")) {
2036
+ const actualDoc = typeof doc === "string" ? str2xml(doc) : doc;
2037
+ if (!hasChildNodeWithName(actualDoc, "gpx")) {
2354
2038
  throw new Error("The XML document is not valid GPX");
2355
2039
  }
2356
- const tracks = get(doc, "trk");
2357
- const routes = get(doc, "rte");
2358
- const waypoints = get(doc, "wpt");
2040
+ const tracks = get(actualDoc, "trk");
2041
+ const routes = get(actualDoc, "rte");
2042
+ const waypoints = get(actualDoc, "wpt");
2359
2043
  const gj = {
2360
2044
  type: "FeatureCollection",
2361
2045
  features: []
2362
2046
  };
2363
2047
  for (const track of Array.from(tracks)) {
2364
2048
  const feature = getTrack(track);
2365
- if (feature)
2366
- gj.features.push(feature);
2049
+ if (feature) gj.features.push(feature);
2367
2050
  }
2368
2051
  for (const route of Array.from(routes)) {
2369
2052
  const feature = getRoute(route);
2370
- if (feature)
2371
- gj.features.push(feature);
2053
+ if (feature) gj.features.push(feature);
2372
2054
  }
2373
2055
  for (const waypoint of Array.from(waypoints)) {
2374
2056
  gj.features.push(getPoint(waypoint));
@@ -2376,10 +2058,9 @@ function gpx(doc) {
2376
2058
  return gj;
2377
2059
  }
2378
2060
  function kml(doc, xml2string) {
2379
- var _a;
2380
- if (typeof doc === "string")
2381
- doc = str2xml(doc);
2382
- if (!hasChildNodeWithName(doc, "kml")) {
2061
+ let actualDoc = doc;
2062
+ if (typeof actualDoc === "string") actualDoc = str2xml(actualDoc);
2063
+ if (!hasChildNodeWithName(actualDoc, "kml")) {
2383
2064
  throw new Error("The XML document is not valid KML");
2384
2065
  }
2385
2066
  const gj = {
@@ -2389,76 +2070,68 @@ function kml(doc, xml2string) {
2389
2070
  const styleIndex = {};
2390
2071
  const styleByHash = {};
2391
2072
  const styleMapIndex = {};
2392
- const placemarks = get(doc, "Placemark");
2393
- const styles = get(doc, "Style");
2394
- const styleMaps = get(doc, "StyleMap");
2073
+ const placemarks = get(actualDoc, "Placemark");
2074
+ const styles = get(actualDoc, "Style");
2075
+ const styleMaps = get(actualDoc, "StyleMap");
2395
2076
  for (const style of Array.from(styles)) {
2396
- const hash = okhash(
2397
- xml2string !== void 0 ? xml2string(style) : xml2str(style)
2398
- ).toString(16);
2399
- styleIndex["#" + attr(style, "id")] = hash;
2077
+ const hash = okhash(xml2string !== void 0 ? xml2string(style) : xml2str(style)).toString(16);
2078
+ styleIndex[`#${attr(style, "id")}`] = hash;
2400
2079
  styleByHash[hash] = style;
2401
2080
  }
2402
2081
  for (const styleMap of Array.from(styleMaps)) {
2403
- styleIndex["#" + attr(styleMap, "id")] = okhash(
2082
+ styleIndex[`#${attr(styleMap, "id")}`] = okhash(
2404
2083
  xml2string !== void 0 ? xml2string(styleMap) : xml2str(styleMap)
2405
2084
  ).toString(16);
2406
2085
  const pairs = get(styleMap, "Pair");
2407
2086
  const pairsMap = {};
2408
2087
  for (const pair of Array.from(pairs)) {
2409
- pairsMap[(_a = nodeVal(get1(pair, "key"))) != null ? _a : ""] = nodeVal(
2410
- get1(pair, "styleUrl")
2411
- );
2088
+ pairsMap[nodeVal(get1(pair, "key")) ?? ""] = nodeVal(get1(pair, "styleUrl"));
2412
2089
  }
2413
- styleMapIndex["#" + attr(styleMap, "id")] = pairsMap;
2090
+ styleMapIndex[`#${attr(styleMap, "id")}`] = pairsMap;
2414
2091
  }
2415
2092
  for (const placemark of Array.from(placemarks)) {
2416
- gj.features = gj.features.concat(
2417
- getPlacemark(placemark, styleIndex, styleByHash, styleMapIndex)
2418
- );
2093
+ gj.features = gj.features.concat(getPlacemark(placemark, styleIndex, styleByHash, styleMapIndex));
2419
2094
  }
2420
2095
  return gj;
2421
2096
  }
2422
2097
  function kmlColor(v) {
2423
- if (v === null)
2424
- return ["#000000", 1];
2098
+ if (v === null) return ["#000000", 1];
2425
2099
  let color = "";
2426
2100
  let opacity = 1;
2427
- if (v.substring(0, 1) === "#")
2428
- v = v.substring(1);
2429
- if (v.length === 6 || v.length === 3)
2430
- color = v;
2431
- if (v.length === 8) {
2432
- opacity = parseInt(v.substring(0, 2), 16) / 255;
2433
- color = "#" + v.substring(6, 8) + v.substring(4, 6) + v.substring(2, 4);
2434
- }
2435
- return [color != null ? color : "#000000", opacity != null ? opacity : 1];
2101
+ let validV = v;
2102
+ if (validV.substring(0, 1) === "#") validV = validV.substring(1);
2103
+ if (validV.length === 6 || validV.length === 3) color = validV;
2104
+ if (validV.length === 8) {
2105
+ opacity = Number.parseInt(validV.substring(0, 2), 16) / 255;
2106
+ color = `#${validV.substring(6, 8)}${validV.substring(4, 6)}${validV.substring(2, 4)}`;
2107
+ }
2108
+ return [color ?? "#000000", opacity ?? 1];
2436
2109
  }
2437
2110
  function gxCoord(v) {
2438
2111
  return numarray(v.split(" "));
2439
2112
  }
2440
2113
  function gxCoords(root) {
2441
- var _a;
2442
2114
  let elems = get(root, "coord");
2443
2115
  const coords = [];
2444
2116
  const times = [];
2445
- if (elems.length === 0)
2446
- elems = get(root, "gx:coord");
2117
+ if (elems.length === 0) elems = get(root, "gx:coord");
2447
2118
  for (const elem of Array.from(elems)) {
2448
- coords.push(gxCoord((_a = nodeVal(elem)) != null ? _a : ""));
2119
+ coords.push(gxCoord(nodeVal(elem) ?? ""));
2449
2120
  }
2450
2121
  const timeElems = get(root, "when");
2451
- for (const timeElem of Array.from(timeElems))
2452
- times.push(nodeVal(timeElem));
2122
+ for (const timeElem of Array.from(timeElems)) times.push(nodeVal(timeElem));
2453
2123
  return {
2454
2124
  coords,
2455
2125
  times
2456
2126
  };
2457
2127
  }
2458
2128
  function getGeometry(root) {
2459
- var _a, _b, _c;
2460
2129
  const geotypes = ["Polygon", "LineString", "Point", "Track", "gx:Track"];
2461
- let geomNode, geomNodes, i, j, k;
2130
+ let geomNode;
2131
+ let geomNodes;
2132
+ let i;
2133
+ let j;
2134
+ let k;
2462
2135
  const geoms = [];
2463
2136
  const coordTimes = [];
2464
2137
  if (get1(root, "MultiGeometry") !== null) {
@@ -2478,18 +2151,18 @@ function getGeometry(root) {
2478
2151
  if (geotypes[i] === "Point") {
2479
2152
  geoms.push({
2480
2153
  type: "Point",
2481
- coordinates: coord1((_a = nodeVal(get1(geomNode, "coordinates"))) != null ? _a : "")
2154
+ coordinates: coord1(nodeVal(get1(geomNode, "coordinates")) ?? "")
2482
2155
  });
2483
2156
  } else if (geotypes[i] === "LineString") {
2484
2157
  geoms.push({
2485
2158
  type: "LineString",
2486
- coordinates: coord((_b = nodeVal(get1(geomNode, "coordinates"))) != null ? _b : "")
2159
+ coordinates: coord(nodeVal(get1(geomNode, "coordinates")) ?? "")
2487
2160
  });
2488
2161
  } else if (geotypes[i] === "Polygon") {
2489
2162
  const rings = get(geomNode, "LinearRing");
2490
2163
  const coords = [];
2491
2164
  for (k = 0; k < rings.length; k++) {
2492
- coords.push(coord((_c = nodeVal(get1(rings[k], "coordinates"))) != null ? _c : ""));
2165
+ coords.push(coord(nodeVal(get1(rings[k], "coordinates")) ?? ""));
2493
2166
  }
2494
2167
  geoms.push({
2495
2168
  type: "Polygon",
@@ -2501,8 +2174,7 @@ function getGeometry(root) {
2501
2174
  type: "LineString",
2502
2175
  coordinates: track.coords
2503
2176
  });
2504
- if (track.times.length)
2505
- coordTimes.push(track.times);
2177
+ if (track.times.length) coordTimes.push(track.times);
2506
2178
  }
2507
2179
  }
2508
2180
  }
@@ -2510,7 +2182,6 @@ function getGeometry(root) {
2510
2182
  return { geoms, coordTimes };
2511
2183
  }
2512
2184
  function getPlacemark(root, styleIndex, styleByHash, styleMapIndex) {
2513
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2514
2185
  const geomsAndTimes = getGeometry(root);
2515
2186
  const properties = {};
2516
2187
  const name = nodeVal(get1(root, "name"));
@@ -2524,62 +2195,50 @@ function getPlacemark(root, styleIndex, styleByHash, styleMapIndex) {
2524
2195
  let styleUrl = nodeVal(get1(root, "styleUrl"));
2525
2196
  let lineStyle = get1(root, "LineStyle");
2526
2197
  let polyStyle = get1(root, "PolyStyle");
2527
- if (!geomsAndTimes.geoms.length)
2528
- return [];
2529
- if (name)
2530
- properties.name = name;
2531
- if (address)
2532
- properties.address = address;
2198
+ if (!geomsAndTimes.geoms.length) return [];
2199
+ if (name) properties.name = name;
2200
+ if (address) properties.address = address;
2533
2201
  if (styleUrl) {
2534
- if (styleUrl[0] !== "#")
2535
- styleUrl = "#" + styleUrl;
2202
+ if (styleUrl[0] !== "#") styleUrl = `#${styleUrl}`;
2536
2203
  properties.styleUrl = styleUrl;
2537
2204
  if (styleIndex[styleUrl]) {
2538
2205
  properties.styleHash = styleIndex[styleUrl];
2539
2206
  }
2540
2207
  if (styleMapIndex[styleUrl]) {
2541
2208
  properties.styleMapHash = styleMapIndex[styleUrl];
2542
- properties.styleHash = styleIndex[(_a = styleMapIndex[styleUrl].normal) != null ? _a : ""];
2209
+ properties.styleHash = styleIndex[styleMapIndex[styleUrl].normal ?? ""];
2543
2210
  }
2544
- const style = styleByHash[(_b = properties.styleHash) != null ? _b : ""];
2211
+ const style = styleByHash[properties.styleHash ?? ""];
2545
2212
  if (style) {
2546
- if (!lineStyle)
2547
- lineStyle = get1(style, "LineStyle");
2548
- if (!polyStyle)
2549
- polyStyle = get1(style, "PolyStyle");
2213
+ if (!lineStyle) lineStyle = get1(style, "LineStyle");
2214
+ if (!polyStyle) polyStyle = get1(style, "PolyStyle");
2550
2215
  const iconStyle = get1(style, "IconStyle");
2551
2216
  if (iconStyle) {
2552
2217
  const icon = get1(iconStyle, "Icon");
2553
2218
  if (icon) {
2554
2219
  const href = nodeVal(get1(icon, "href"));
2555
- if (href)
2556
- properties.icon = href;
2220
+ if (href) properties.icon = href;
2557
2221
  }
2558
2222
  }
2559
2223
  }
2560
2224
  }
2561
- if (description)
2562
- properties.description = description;
2225
+ if (description) properties.description = description;
2563
2226
  if (timeSpan) {
2564
2227
  const begin = nodeVal(get1(timeSpan, "begin"));
2565
2228
  const end = nodeVal(get1(timeSpan, "end"));
2566
- if (begin && end)
2567
- properties.timespan = { begin, end };
2229
+ if (begin && end) properties.timespan = { begin, end };
2568
2230
  }
2569
2231
  if (timeStamp !== null) {
2570
- properties.timestamp = (_c = nodeVal(get1(timeStamp, "when"))) != null ? _c : (/* @__PURE__ */ new Date()).toISOString();
2232
+ properties.timestamp = nodeVal(get1(timeStamp, "when")) ?? (/* @__PURE__ */ new Date()).toISOString();
2571
2233
  }
2572
2234
  if (lineStyle !== null) {
2573
2235
  const linestyles = kmlColor(nodeVal(get1(lineStyle, "color")));
2574
2236
  const color = linestyles[0];
2575
2237
  const opacity = linestyles[1];
2576
- const width = parseFloat((_d = nodeVal(get1(lineStyle, "width"))) != null ? _d : "");
2577
- if (color)
2578
- properties.stroke = color;
2579
- if (!isNaN(opacity))
2580
- properties["stroke-opacity"] = opacity;
2581
- if (!isNaN(width))
2582
- properties["stroke-width"] = width;
2238
+ const width = Number.parseFloat(nodeVal(get1(lineStyle, "width")) ?? "");
2239
+ if (color) properties.stroke = color;
2240
+ if (!Number.isNaN(opacity)) properties["stroke-opacity"] = opacity;
2241
+ if (!Number.isNaN(width)) properties["stroke-width"] = width;
2583
2242
  }
2584
2243
  if (polyStyle) {
2585
2244
  const polystyles = kmlColor(nodeVal(get1(polyStyle, "color")));
@@ -2587,26 +2246,23 @@ function getPlacemark(root, styleIndex, styleByHash, styleMapIndex) {
2587
2246
  const popacity = polystyles[1];
2588
2247
  const fill = nodeVal(get1(polyStyle, "fill"));
2589
2248
  const outline = nodeVal(get1(polyStyle, "outline"));
2590
- if (pcolor)
2591
- properties.fill = pcolor;
2592
- if (!isNaN(popacity))
2593
- properties["fill-opacity"] = popacity;
2594
- if (fill)
2595
- properties["fill-opacity"] = fill === "1" ? properties["fill-opacity"] || 1 : 0;
2596
- if (outline)
2597
- properties["stroke-opacity"] = outline === "1" ? properties["stroke-opacity"] || 1 : 0;
2249
+ if (pcolor) properties.fill = pcolor;
2250
+ if (!Number.isNaN(popacity)) properties["fill-opacity"] = popacity;
2251
+ if (fill) properties["fill-opacity"] = fill === "1" ? properties["fill-opacity"] || 1 : 0;
2252
+ if (outline) properties["stroke-opacity"] = outline === "1" ? properties["stroke-opacity"] || 1 : 0;
2598
2253
  }
2599
2254
  if (extendedData) {
2600
- const datas = get(extendedData, "Data"), simpleDatas = get(extendedData, "SimpleData");
2255
+ const datas = get(extendedData, "Data");
2256
+ const simpleDatas = get(extendedData, "SimpleData");
2601
2257
  for (i = 0; i < datas.length; i++) {
2602
- properties[(_e = datas[i].getAttribute("name")) != null ? _e : ""] = (_f = nodeVal(get1(datas[i], "value"))) != null ? _f : "";
2258
+ properties[datas[i].getAttribute("name") ?? ""] = nodeVal(get1(datas[i], "value")) ?? "";
2603
2259
  }
2604
2260
  for (i = 0; i < simpleDatas.length; i++) {
2605
- properties[(_g = simpleDatas[i].getAttribute("name")) != null ? _g : ""] = (_h = nodeVal(simpleDatas[i])) != null ? _h : "";
2261
+ properties[simpleDatas[i].getAttribute("name") ?? ""] = nodeVal(simpleDatas[i]) ?? "";
2606
2262
  }
2607
2263
  }
2608
2264
  if (visibility !== null) {
2609
- properties.visibility = (_i = nodeVal(visibility)) != null ? _i : "";
2265
+ properties.visibility = nodeVal(visibility) ?? "";
2610
2266
  }
2611
2267
  if (geomsAndTimes.coordTimes.length !== 0) {
2612
2268
  properties.coordTimes = geomsAndTimes.coordTimes.length === 1 ? geomsAndTimes.coordTimes[0] : geomsAndTimes.coordTimes;
@@ -2619,8 +2275,7 @@ function getPlacemark(root, styleIndex, styleByHash, styleMapIndex) {
2619
2275
  },
2620
2276
  properties
2621
2277
  };
2622
- if (attr(root, "id"))
2623
- feature.id = (_j = attr(root, "id")) != null ? _j : void 0;
2278
+ if (attr(root, "id")) feature.id = attr(root, "id") ?? void 0;
2624
2279
  return [feature];
2625
2280
  }
2626
2281
  function getPoints(node, pointname) {
@@ -2629,16 +2284,13 @@ function getPoints(node, pointname) {
2629
2284
  const times = [];
2630
2285
  let heartRates = [];
2631
2286
  const ptsLength = pts.length;
2632
- if (ptsLength < 2)
2633
- return;
2287
+ if (ptsLength < 2) return;
2634
2288
  for (let i = 0; i < ptsLength; i++) {
2635
2289
  const cPair = coordPair(pts[i]);
2636
2290
  line.push(cPair.coordinates);
2637
- if (cPair.time)
2638
- times.push(cPair.time);
2291
+ if (cPair.time) times.push(cPair.time);
2639
2292
  if (cPair.heartRate || heartRates.length) {
2640
- if (heartRates.length === 0)
2641
- heartRates = new Array(i).fill(null);
2293
+ if (heartRates.length === 0) heartRates = new Array(i).fill(null);
2642
2294
  heartRates.push(cPair.heartRate);
2643
2295
  }
2644
2296
  }
@@ -2657,10 +2309,8 @@ function getTrack(node) {
2657
2309
  for (let i = 0; i < segments.length; i++) {
2658
2310
  line = getPoints(segments[i], "trkpt");
2659
2311
  if (line !== void 0) {
2660
- if (line.line)
2661
- track.push(line.line);
2662
- if (line.times && line.times.length)
2663
- times.push(line.times);
2312
+ if (line.line) track.push(line.line);
2313
+ if (line.times && line.times.length) times.push(line.times);
2664
2314
  if (heartRates.length || line.heartRates && line.heartRates.length) {
2665
2315
  if (!heartRates.length) {
2666
2316
  for (let s = 0; s < i; s++) {
@@ -2675,11 +2325,12 @@ function getTrack(node) {
2675
2325
  }
2676
2326
  }
2677
2327
  }
2678
- if (track.length === 0)
2679
- return;
2680
- const properties = __spreadValues$1(__spreadValues$1({}, getProperties(node)), getLineStyle(get1(node, "extensions")));
2681
- if (times.length !== 0)
2682
- properties.coordTimes = track.length === 1 ? times[0] : times;
2328
+ if (track.length === 0) return;
2329
+ const properties = {
2330
+ ...getProperties(node),
2331
+ ...getLineStyle(get1(node, "extensions"))
2332
+ };
2333
+ if (times.length !== 0) properties.coordTimes = track.length === 1 ? times[0] : times;
2683
2334
  if (heartRates.length !== 0) {
2684
2335
  properties.heartRates = track.length === 1 ? heartRates[0] : heartRates;
2685
2336
  }
@@ -2692,22 +2343,23 @@ function getTrack(node) {
2692
2343
  coordinates: track[0]
2693
2344
  }
2694
2345
  };
2695
- } else {
2696
- return {
2697
- type: "Feature",
2698
- properties,
2699
- geometry: {
2700
- type: "MultiLineString",
2701
- coordinates: track
2702
- }
2703
- };
2704
2346
  }
2347
+ return {
2348
+ type: "Feature",
2349
+ properties,
2350
+ geometry: {
2351
+ type: "MultiLineString",
2352
+ coordinates: track
2353
+ }
2354
+ };
2705
2355
  }
2706
2356
  function getRoute(node) {
2707
2357
  const line = getPoints(node, "rtept");
2708
- if (line === void 0)
2709
- return;
2710
- const prop = __spreadValues$1(__spreadValues$1({}, getProperties(node)), getLineStyle(get1(node, "extensions")));
2358
+ if (line === void 0) return;
2359
+ const prop = {
2360
+ ...getProperties(node),
2361
+ ...getLineStyle(get1(node, "extensions"))
2362
+ };
2711
2363
  return {
2712
2364
  type: "Feature",
2713
2365
  properties: prop,
@@ -2718,7 +2370,7 @@ function getRoute(node) {
2718
2370
  };
2719
2371
  }
2720
2372
  function getPoint(node) {
2721
- const prop = __spreadValues$1(__spreadValues$1({}, getProperties(node)), getMulti(node, ["sym"]));
2373
+ const prop = { ...getProperties(node), ...getMulti(node, ["sym"]) };
2722
2374
  return {
2723
2375
  type: "Feature",
2724
2376
  properties: prop,
@@ -2729,20 +2381,16 @@ function getPoint(node) {
2729
2381
  };
2730
2382
  }
2731
2383
  function getLineStyle(extensions) {
2732
- var _a, _b;
2733
2384
  const style = {};
2734
2385
  if (extensions) {
2735
2386
  const lineStyle = get1(extensions, "line");
2736
2387
  if (lineStyle) {
2737
2388
  const color = nodeVal(get1(lineStyle, "color"));
2738
- const opacity = parseFloat((_a = nodeVal(get1(lineStyle, "opacity"))) != null ? _a : "0");
2739
- const width = parseFloat((_b = nodeVal(get1(lineStyle, "width"))) != null ? _b : "0");
2740
- if (color)
2741
- style.stroke = color;
2742
- if (!isNaN(opacity))
2743
- style["stroke-opacity"] = opacity;
2744
- if (!isNaN(width))
2745
- style["stroke-width"] = width * 96 / 25.4;
2389
+ const opacity = Number.parseFloat(nodeVal(get1(lineStyle, "opacity")) ?? "0");
2390
+ const width = Number.parseFloat(nodeVal(get1(lineStyle, "width")) ?? "0");
2391
+ if (color) style.stroke = color;
2392
+ if (!Number.isNaN(opacity)) style["stroke-opacity"] = opacity;
2393
+ if (!Number.isNaN(width)) style["stroke-width"] = width * 96 / 25.4;
2746
2394
  }
2747
2395
  }
2748
2396
  return style;
@@ -2760,9 +2408,10 @@ function getProperties(node) {
2760
2408
  if (links.length !== 0) {
2761
2409
  prop.links = [];
2762
2410
  for (const l of Array.from(links)) {
2763
- const link = __spreadValues$1({
2764
- href: attr(l, "href")
2765
- }, getMulti(l, ["text", "type"]));
2411
+ const link = {
2412
+ href: attr(l, "href"),
2413
+ ...getMulti(l, ["text", "type"])
2414
+ };
2766
2415
  prop.links.push(link);
2767
2416
  }
2768
2417
  }
@@ -2770,8 +2419,7 @@ function getProperties(node) {
2770
2419
  }
2771
2420
  function okhash(x) {
2772
2421
  let h = 0;
2773
- if (!x || !x.length)
2774
- return h;
2422
+ if (!x || !x.length) return h;
2775
2423
  for (let i = 0; i < x.length; i++) {
2776
2424
  h = (h << 5) - h + x.charCodeAt(i) | 0;
2777
2425
  }
@@ -2784,35 +2432,30 @@ function attr(x, y) {
2784
2432
  return x.getAttribute(y);
2785
2433
  }
2786
2434
  function attrf(x, y) {
2787
- var _a;
2788
- return parseFloat((_a = attr(x, y)) != null ? _a : "0");
2435
+ return Number.parseFloat(attr(x, y) ?? "0");
2789
2436
  }
2790
2437
  function get1(x, y) {
2791
2438
  const n = get(x, y);
2792
2439
  return n.length ? n[0] : null;
2793
2440
  }
2794
2441
  function norm(el) {
2795
- if (el.normalize)
2796
- el.normalize();
2442
+ if (el.normalize) el.normalize();
2797
2443
  return el;
2798
2444
  }
2799
2445
  function numarray(x) {
2800
- return x.map(parseFloat).map((n) => isNaN(n) ? null : n);
2446
+ return x.map(Number.parseFloat).map((n) => Number.isNaN(n) ? null : n);
2801
2447
  }
2802
2448
  function nodeVal(x) {
2803
- if (x)
2804
- norm(x);
2449
+ if (x) norm(x);
2805
2450
  return x && x.textContent;
2806
2451
  }
2807
2452
  function getMulti(x, ys) {
2808
- var _a;
2809
2453
  const o = {};
2810
2454
  let n;
2811
2455
  let k;
2812
2456
  for (k = 0; k < ys.length; k++) {
2813
2457
  n = get1(x, ys[k]);
2814
- if (n)
2815
- o[ys[k]] = (_a = nodeVal(n)) != null ? _a : "";
2458
+ if (n) o[ys[k]] = nodeVal(n) ?? "";
2816
2459
  }
2817
2460
  return o;
2818
2461
  }
@@ -2822,66 +2465,57 @@ function coord1(v) {
2822
2465
  function coord(v) {
2823
2466
  const coords = v.replace(/^\s*|\s*$/g, "").split(/\s+/);
2824
2467
  const out = [];
2825
- for (const coord2 of coords)
2826
- out.push(coord1(coord2));
2468
+ for (const coord2 of coords) out.push(coord1(coord2));
2827
2469
  return out;
2828
2470
  }
2829
2471
  function coordPair(x) {
2830
- var _a, _b;
2831
2472
  const ll = [attrf(x, "lon"), attrf(x, "lat")];
2832
2473
  const ele = get1(x, "ele");
2833
2474
  const heartRate = get1(x, "gpxtpx:hr") || get1(x, "hr");
2834
2475
  const time = get1(x, "time");
2835
2476
  let e;
2836
2477
  if (ele) {
2837
- e = parseFloat((_a = nodeVal(ele)) != null ? _a : "0");
2838
- if (!isNaN(e))
2839
- ll.push(e);
2478
+ e = Number.parseFloat(nodeVal(ele) ?? "0");
2479
+ if (!Number.isNaN(e)) ll.push(e);
2840
2480
  }
2841
2481
  return {
2842
2482
  coordinates: ll,
2843
2483
  time: time ? nodeVal(time) : null,
2844
- heartRate: heartRate !== null ? parseFloat((_b = nodeVal(heartRate)) != null ? _b : "0") : null
2484
+ heartRate: heartRate !== null ? Number.parseFloat(nodeVal(heartRate) ?? "0") : null
2845
2485
  };
2846
2486
  }
2847
2487
  function gpxOrKml(doc) {
2488
+ let actualDoc = doc;
2848
2489
  try {
2849
- if (typeof doc === "string")
2850
- doc = str2xml(doc);
2490
+ if (typeof actualDoc === "string") actualDoc = str2xml(actualDoc);
2851
2491
  } catch (e) {
2852
2492
  return null;
2853
2493
  }
2854
2494
  try {
2855
- const result = gpx(doc);
2495
+ const result = gpx(actualDoc);
2856
2496
  return result;
2857
2497
  } catch (e) {
2858
2498
  }
2859
2499
  try {
2860
- const result = kml(doc);
2500
+ const result = kml(actualDoc);
2861
2501
  return result;
2862
2502
  } catch (e) {
2863
2503
  }
2864
2504
  return null;
2865
2505
  }
2866
2506
 
2867
- var __defProp$1 = Object.defineProperty;
2868
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2869
- var __publicField = (obj, key, value) => {
2870
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
2871
- return value;
2872
- };
2873
2507
  function componentToHex(c) {
2874
2508
  const hex = c.toString(16);
2875
- return hex.length == 1 ? "0" + hex : hex;
2509
+ return hex.length === 1 ? `0${hex}` : hex;
2876
2510
  }
2877
2511
  function rgbToHex(rgb) {
2878
- return "#" + componentToHex(rgb[0]) + componentToHex(rgb[1]) + componentToHex(rgb[2]) + (rgb.length === 4 ? componentToHex(rgb[3]) : "");
2512
+ return `#${componentToHex(rgb[0])}${componentToHex(rgb[1])}${componentToHex(rgb[2])}${rgb.length === 4 ? componentToHex(rgb[3]) : ""}`;
2879
2513
  }
2880
2514
  class ColorRamp extends Array {
2881
2515
  constructor(options = {}) {
2882
2516
  super();
2883
- __publicField(this, "min", 0);
2884
- __publicField(this, "max", 1);
2517
+ this.min = 0;
2518
+ this.max = 1;
2885
2519
  if ("min" in options) {
2886
2520
  this.min = options.min;
2887
2521
  }
@@ -2909,8 +2543,8 @@ class ColorRamp extends Array {
2909
2543
  setStops(stops, options = { clone: true }) {
2910
2544
  const colorRamp = options.clone ? this.clone() : this;
2911
2545
  colorRamp.length = 0;
2912
- let min = Infinity;
2913
- let max = -Infinity;
2546
+ let min = Number.POSITIVE_INFINITY;
2547
+ let max = Number.NEGATIVE_INFINITY;
2914
2548
  for (let i = 0; i < stops.length; i += 1) {
2915
2549
  min = Math.min(min, stops[i].value);
2916
2550
  max = Math.max(max, stops[i].value);
@@ -2920,9 +2554,7 @@ class ColorRamp extends Array {
2920
2554
  // we want to make sure we do a deep copy and not a reference
2921
2555
  });
2922
2556
  }
2923
- colorRamp.sort(
2924
- (a, b) => a.value < b.value ? -1 : 1
2925
- );
2557
+ colorRamp.sort((a, b) => a.value < b.value ? -1 : 1);
2926
2558
  this.min = min;
2927
2559
  this.max = max;
2928
2560
  return colorRamp;
@@ -2953,9 +2585,8 @@ class ColorRamp extends Array {
2953
2585
  at(pos) {
2954
2586
  if (pos < 0) {
2955
2587
  return this[this.length + pos];
2956
- } else {
2957
- return this[pos];
2958
2588
  }
2589
+ return this[pos];
2959
2590
  }
2960
2591
  clone() {
2961
2592
  return new ColorRamp({ stops: this.getRawColorStops() });
@@ -3018,10 +2649,7 @@ class ColorRamp extends Array {
3018
2649
  */
3019
2650
  getColorRelative(value, options = { smooth: true }) {
3020
2651
  const bounds = this.getBounds();
3021
- return this.getColor(
3022
- bounds.min + value * (bounds.max - bounds.min),
3023
- options
3024
- );
2652
+ return this.getColor(bounds.min + value * (bounds.max - bounds.min), options);
3025
2653
  }
3026
2654
  getCanvasStrip(options = {
3027
2655
  horizontal: true,
@@ -3032,8 +2660,7 @@ class ColorRamp extends Array {
3032
2660
  canvas.width = options.horizontal ? options.size : 1;
3033
2661
  canvas.height = options.horizontal ? 1 : options.size;
3034
2662
  const ctx = canvas.getContext("2d");
3035
- if (!ctx)
3036
- throw new Error("Canvs context is missing");
2663
+ if (!ctx) throw new Error("Canvs context is missing");
3037
2664
  const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
3038
2665
  const imageDataArray = imageData.data;
3039
2666
  const size = options.size;
@@ -3064,42 +2691,42 @@ class ColorRamp extends Array {
3064
2691
  if (method === "ease-in-square") {
3065
2692
  stops = Array.from({ length: samples }, (_, i) => {
3066
2693
  const x = i * step;
3067
- const y = Math.pow(x, 2);
2694
+ const y = x ** 2;
3068
2695
  const color = inputNormalized.getColor(y);
3069
2696
  return { value: x, color };
3070
2697
  });
3071
2698
  } else if (method === "ease-out-square") {
3072
2699
  stops = Array.from({ length: samples }, (_, i) => {
3073
2700
  const x = i * step;
3074
- const y = 1 - Math.pow(1 - x, 2);
2701
+ const y = 1 - (1 - x) ** 2;
3075
2702
  const color = inputNormalized.getColor(y);
3076
2703
  return { value: x, color };
3077
2704
  });
3078
2705
  } else if (method === "ease-out-sqrt") {
3079
2706
  stops = Array.from({ length: samples }, (_, i) => {
3080
2707
  const x = i * step;
3081
- const y = Math.pow(x, 0.5);
2708
+ const y = x ** 0.5;
3082
2709
  const color = inputNormalized.getColor(y);
3083
2710
  return { value: x, color };
3084
2711
  });
3085
2712
  } else if (method === "ease-in-sqrt") {
3086
2713
  stops = Array.from({ length: samples }, (_, i) => {
3087
2714
  const x = i * step;
3088
- const y = 1 - Math.pow(1 - x, 0.5);
2715
+ const y = 1 - (1 - x) ** 0.5;
3089
2716
  const color = inputNormalized.getColor(y);
3090
2717
  return { value: x, color };
3091
2718
  });
3092
2719
  } else if (method === "ease-out-exp") {
3093
2720
  stops = Array.from({ length: samples }, (_, i) => {
3094
2721
  const x = i * step;
3095
- const y = 1 - Math.pow(2, -10 * x);
2722
+ const y = 1 - 2 ** (-10 * x);
3096
2723
  const color = inputNormalized.getColor(y);
3097
2724
  return { value: x, color };
3098
2725
  });
3099
2726
  } else if (method === "ease-in-exp") {
3100
2727
  stops = Array.from({ length: samples }, (_, i) => {
3101
2728
  const x = i * step;
3102
- const y = Math.pow(2, 10 * x - 10);
2729
+ const y = 2 ** (10 * x - 10);
3103
2730
  const color = inputNormalized.getColor(y);
3104
2731
  return { value: x, color };
3105
2732
  });
@@ -3120,11 +2747,11 @@ class ColorRamp extends Array {
3120
2747
  color: stops[0].color.slice()
3121
2748
  });
3122
2749
  stops[1].value += 1e-3;
3123
- stops.forEach((s) => {
2750
+ for (const s of stops) {
3124
2751
  if (s.color.length === 3) {
3125
2752
  s.color.push(255);
3126
2753
  }
3127
- });
2754
+ }
3128
2755
  stops[0].color[3] = 0;
3129
2756
  return new ColorRamp({ stops });
3130
2757
  }
@@ -3938,83 +3565,48 @@ function lerpZoomNumberValues(znv, z) {
3938
3565
  return 0;
3939
3566
  }
3940
3567
  function paintColorOptionsToPaintSpec(color) {
3941
- return [
3942
- "interpolate",
3943
- ["linear"],
3944
- ["zoom"],
3945
- ...color.map((el) => [el.zoom, el.value]).flat()
3946
- ];
3568
+ return ["interpolate", ["linear"], ["zoom"], ...color.flatMap((el) => [el.zoom, el.value])];
3947
3569
  }
3948
3570
  function rampedOptionsToLayerPaintSpec(ramp) {
3949
- return [
3950
- "interpolate",
3951
- ["linear"],
3952
- ["zoom"],
3953
- ...ramp.map((el) => [el.zoom, el.value]).flat()
3954
- ];
3571
+ return ["interpolate", ["linear"], ["zoom"], ...ramp.flatMap((el) => [el.zoom, el.value])];
3955
3572
  }
3956
3573
  function computeRampedOutlineWidth(lineWidth, outlineWidth) {
3957
3574
  if (typeof outlineWidth === "number" && typeof lineWidth === "number") {
3958
3575
  return 2 * outlineWidth + lineWidth;
3959
- } else if (typeof outlineWidth === "number" && Array.isArray(lineWidth)) {
3960
- return [
3961
- "interpolate",
3962
- ["linear"],
3963
- ["zoom"],
3964
- ...lineWidth.map((el) => [el.zoom, 2 * outlineWidth + el.value]).flat()
3965
- ];
3966
- } else if (typeof lineWidth === "number" && Array.isArray(outlineWidth)) {
3967
- return [
3968
- "interpolate",
3969
- ["linear"],
3970
- ["zoom"],
3971
- ...outlineWidth.map((el) => [el.zoom, 2 * el.value + lineWidth]).flat()
3972
- ];
3576
+ }
3577
+ if (typeof outlineWidth === "number" && Array.isArray(lineWidth)) {
3578
+ return ["interpolate", ["linear"], ["zoom"], ...lineWidth.flatMap((el) => [el.zoom, 2 * outlineWidth + el.value])];
3579
+ }
3580
+ if (typeof lineWidth === "number" && Array.isArray(outlineWidth)) {
3581
+ return ["interpolate", ["linear"], ["zoom"], ...outlineWidth.flatMap((el) => [el.zoom, 2 * el.value + lineWidth])];
3973
3582
  }
3974
3583
  if (Array.isArray(lineWidth) && Array.isArray(outlineWidth)) {
3975
3584
  const allStops = Array.from(
3976
- /* @__PURE__ */ new Set([
3977
- ...lineWidth.map((el) => el.zoom),
3978
- ...outlineWidth.map((el) => el.zoom)
3979
- ])
3585
+ /* @__PURE__ */ new Set([...lineWidth.map((el) => el.zoom), ...outlineWidth.map((el) => el.zoom)])
3980
3586
  ).sort((a, b) => a < b ? -1 : 1);
3981
3587
  return [
3982
3588
  "interpolate",
3983
3589
  ["linear"],
3984
3590
  ["zoom"],
3985
- ...allStops.map((z) => [
3986
- z,
3987
- 2 * lerpZoomNumberValues(outlineWidth, z) + lerpZoomNumberValues(lineWidth, z)
3988
- ]).flat()
3591
+ ...allStops.flatMap((z) => [z, 2 * lerpZoomNumberValues(outlineWidth, z) + lerpZoomNumberValues(lineWidth, z)])
3989
3592
  ];
3990
3593
  }
3991
3594
  return 0;
3992
3595
  }
3993
3596
  function rampedPropertyValueWeight(ramp, property) {
3994
- return [
3995
- "interpolate",
3996
- ["linear"],
3997
- ["get", property],
3998
- ...ramp.map((el) => [el.propertyValue, el.value]).flat()
3999
- ];
3597
+ return ["interpolate", ["linear"], ["get", property], ...ramp.flatMap((el) => [el.propertyValue, el.value])];
4000
3598
  }
4001
3599
  function dashArrayMaker(pattern) {
4002
3600
  const startTrimmedPattern = pattern.trimStart();
4003
- const fixedPattern = `${startTrimmedPattern}${" ".repeat(
4004
- pattern.length - startTrimmedPattern.length
4005
- )}`;
3601
+ const fixedPattern = `${startTrimmedPattern}${" ".repeat(pattern.length - startTrimmedPattern.length)}`;
4006
3602
  const patternArr = Array.from(fixedPattern);
4007
3603
  const isOnlyDashesAndSpaces = patternArr.every((c) => c === " " || c === "_");
4008
3604
  if (!isOnlyDashesAndSpaces) {
4009
- throw new Error(
4010
- "A dash pattern must be composed only of whitespace and underscore characters."
4011
- );
3605
+ throw new Error("A dash pattern must be composed only of whitespace and underscore characters.");
4012
3606
  }
4013
3607
  const hasBothDashesAndWhitespaces = patternArr.some((c) => c === "_") && patternArr.some((c) => c === " ");
4014
3608
  if (!hasBothDashesAndWhitespaces) {
4015
- throw new Error(
4016
- "A dash pattern must contain at least one underscore and one whitespace character"
4017
- );
3609
+ throw new Error("A dash pattern must contain at least one underscore and one whitespace character");
4018
3610
  }
4019
3611
  const dashArray = [1];
4020
3612
  for (let i = 1; i < patternArr.length; i += 1) {
@@ -4029,111 +3621,46 @@ function dashArrayMaker(pattern) {
4029
3621
  return dashArray;
4030
3622
  }
4031
3623
  function colorDrivenByProperty(style, property) {
4032
- return [
4033
- "interpolate",
4034
- ["linear"],
4035
- ["get", property],
4036
- ...style.map((el) => [el.value, el.color]).flat()
4037
- ];
3624
+ return ["interpolate", ["linear"], ["get", property], ...style.flatMap((el) => [el.value, el.color])];
4038
3625
  }
4039
3626
  function radiusDrivenByProperty(style, property, zoomCompensation = true) {
4040
3627
  if (!zoomCompensation) {
4041
- return [
4042
- "interpolate",
4043
- ["linear"],
4044
- ["get", property],
4045
- ...style.map((el) => [el.value, el.pointRadius]).flat()
4046
- ];
3628
+ return ["interpolate", ["linear"], ["get", property], ...style.flatMap((el) => [el.value, el.pointRadius])];
4047
3629
  }
4048
3630
  return [
4049
3631
  "interpolate",
4050
3632
  ["linear"],
4051
3633
  ["zoom"],
4052
3634
  0,
4053
- [
4054
- "interpolate",
4055
- ["linear"],
4056
- ["get", property],
4057
- ...style.map((el) => [el.value, el.pointRadius * 0.025]).flat()
4058
- ],
3635
+ ["interpolate", ["linear"], ["get", property], ...style.flatMap((el) => [el.value, el.pointRadius * 0.025])],
4059
3636
  2,
4060
- [
4061
- "interpolate",
4062
- ["linear"],
4063
- ["get", property],
4064
- ...style.map((el) => [el.value, el.pointRadius * 0.05]).flat()
4065
- ],
3637
+ ["interpolate", ["linear"], ["get", property], ...style.flatMap((el) => [el.value, el.pointRadius * 0.05])],
4066
3638
  4,
4067
- [
4068
- "interpolate",
4069
- ["linear"],
4070
- ["get", property],
4071
- ...style.map((el) => [el.value, el.pointRadius * 0.1]).flat()
4072
- ],
3639
+ ["interpolate", ["linear"], ["get", property], ...style.flatMap((el) => [el.value, el.pointRadius * 0.1])],
4073
3640
  8,
4074
- [
4075
- "interpolate",
4076
- ["linear"],
4077
- ["get", property],
4078
- ...style.map((el) => [el.value, el.pointRadius * 0.25]).flat()
4079
- ],
3641
+ ["interpolate", ["linear"], ["get", property], ...style.flatMap((el) => [el.value, el.pointRadius * 0.25])],
4080
3642
  16,
4081
- [
4082
- "interpolate",
4083
- ["linear"],
4084
- ["get", property],
4085
- ...style.map((el) => [el.value, el.pointRadius]).flat()
4086
- ]
3643
+ ["interpolate", ["linear"], ["get", property], ...style.flatMap((el) => [el.value, el.pointRadius])]
4087
3644
  ];
4088
3645
  }
4089
3646
  function radiusDrivenByPropertyHeatmap(style, property, zoomCompensation = true) {
4090
3647
  if (!zoomCompensation) {
4091
- return [
4092
- "interpolate",
4093
- ["linear"],
4094
- ["get", property],
4095
- ...style.map((el) => [el.propertyValue, el.value]).flat()
4096
- ];
3648
+ return ["interpolate", ["linear"], ["get", property], ...style.flatMap((el) => [el.propertyValue, el.value])];
4097
3649
  }
4098
3650
  return [
4099
3651
  "interpolate",
4100
3652
  ["linear"],
4101
3653
  ["zoom"],
4102
3654
  0,
4103
- [
4104
- "interpolate",
4105
- ["linear"],
4106
- ["get", property],
4107
- ...style.map((el) => [el.propertyValue, el.value * 0.025]).flat()
4108
- ],
3655
+ ["interpolate", ["linear"], ["get", property], ...style.flatMap((el) => [el.propertyValue, el.value * 0.025])],
4109
3656
  2,
4110
- [
4111
- "interpolate",
4112
- ["linear"],
4113
- ["get", property],
4114
- ...style.map((el) => [el.propertyValue, el.value * 0.05]).flat()
4115
- ],
3657
+ ["interpolate", ["linear"], ["get", property], ...style.flatMap((el) => [el.propertyValue, el.value * 0.05])],
4116
3658
  4,
4117
- [
4118
- "interpolate",
4119
- ["linear"],
4120
- ["get", property],
4121
- ...style.map((el) => [el.propertyValue, el.value * 0.1]).flat()
4122
- ],
3659
+ ["interpolate", ["linear"], ["get", property], ...style.flatMap((el) => [el.propertyValue, el.value * 0.1])],
4123
3660
  8,
4124
- [
4125
- "interpolate",
4126
- ["linear"],
4127
- ["get", property],
4128
- ...style.map((el) => [el.propertyValue, el.value * 0.25]).flat()
4129
- ],
3661
+ ["interpolate", ["linear"], ["get", property], ...style.flatMap((el) => [el.propertyValue, el.value * 0.25])],
4130
3662
  16,
4131
- [
4132
- "interpolate",
4133
- ["linear"],
4134
- ["get", property],
4135
- ...style.map((el) => [el.propertyValue, el.value]).flat()
4136
- ]
3663
+ ["interpolate", ["linear"], ["get", property], ...style.flatMap((el) => [el.propertyValue, el.value])]
4137
3664
  ];
4138
3665
  }
4139
3666
  function opacityDrivenByProperty(colorramp, property) {
@@ -4144,11 +3671,11 @@ function opacityDrivenByProperty(colorramp, property) {
4144
3671
  "interpolate",
4145
3672
  ["linear"],
4146
3673
  ["get", property],
4147
- ...colorramp.getRawColorStops().map((el) => {
3674
+ ...colorramp.getRawColorStops().flatMap((el) => {
4148
3675
  const value = el.value;
4149
3676
  const color = el.color;
4150
3677
  return [value, color.length === 4 ? color[3] / 255 : 1];
4151
- }).flat()
3678
+ })
4152
3679
  ];
4153
3680
  }
4154
3681
  function heatmapIntensityFromColorRamp(colorRamp, steps = 10) {
@@ -4163,92 +3690,41 @@ function heatmapIntensityFromColorRamp(colorRamp, steps = 10) {
4163
3690
  ];
4164
3691
  }
4165
3692
 
4166
- var __defProp = Object.defineProperty;
4167
- var __defProps = Object.defineProperties;
4168
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4169
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4170
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4171
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
4172
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4173
- var __spreadValues = (a, b) => {
4174
- for (var prop in b || (b = {}))
4175
- if (__hasOwnProp.call(b, prop))
4176
- __defNormalProp(a, prop, b[prop]);
4177
- if (__getOwnPropSymbols)
4178
- for (var prop of __getOwnPropSymbols(b)) {
4179
- if (__propIsEnum.call(b, prop))
4180
- __defNormalProp(a, prop, b[prop]);
4181
- }
4182
- return a;
4183
- };
4184
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
4185
- var __async = (__this, __arguments, generator) => {
4186
- return new Promise((resolve, reject) => {
4187
- var fulfilled = (value) => {
4188
- try {
4189
- step(generator.next(value));
4190
- } catch (e) {
4191
- reject(e);
4192
- }
4193
- };
4194
- var rejected = (value) => {
4195
- try {
4196
- step(generator.throw(value));
4197
- } catch (e) {
4198
- reject(e);
4199
- }
4200
- };
4201
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
4202
- step((generator = generator.apply(__this, __arguments)).next());
4203
- });
4204
- };
4205
- function addPolyline(_0, _1) {
4206
- return __async(this, arguments, function* (map, options, fetchOptions = {}) {
4207
- var _a, _b, _c;
4208
- if (!options.sourceId && !options.data) {
4209
- throw new Error(
4210
- "Creating a polyline layer requires an existing .sourceId or a valid .data property"
4211
- );
3693
+ async function addPolyline(map, options, fetchOptions = {}) {
3694
+ if (!options.sourceId && !options.data) {
3695
+ throw new Error("Creating a polyline layer requires an existing .sourceId or a valid .data property");
3696
+ }
3697
+ let data = options.data;
3698
+ if (typeof data === "string") {
3699
+ if (isUUID(data)) {
3700
+ data = `https://api.maptiler.com/data/${options.data}/features.json?key=${config.apiKey}`;
3701
+ } else if (data.split(".").pop()?.toLowerCase().trim() === "gpx") {
3702
+ const res = await fetch(data, fetchOptions);
3703
+ const gpxStr = await res.text();
3704
+ data = gpx(gpxStr);
3705
+ } else if (data.split(".").pop()?.toLowerCase().trim() === "kml") {
3706
+ const res = await fetch(data, fetchOptions);
3707
+ const kmlStr = await res.text();
3708
+ data = kml(kmlStr);
3709
+ } else {
3710
+ const tmpData = jsonParseNoThrow(data) ?? gpxOrKml(data);
3711
+ if (tmpData) data = tmpData;
4212
3712
  }
4213
- let data = options.data;
4214
- if (typeof data === "string") {
4215
- if (isUUID(data)) {
4216
- data = `https://api.maptiler.com/data/${options.data}/features.json?key=${config$1.apiKey}`;
4217
- } else if (((_a = data.split(".").pop()) == null ? void 0 : _a.toLowerCase().trim()) === "gpx") {
4218
- const res = yield fetch(data, fetchOptions);
4219
- const gpxStr = yield res.text();
4220
- data = gpx(gpxStr);
4221
- } else if (((_b = data.split(".").pop()) == null ? void 0 : _b.toLowerCase().trim()) === "kml") {
4222
- const res = yield fetch(data, fetchOptions);
4223
- const kmlStr = yield res.text();
4224
- data = kml(kmlStr);
4225
- } else {
4226
- const tmpData = (_c = jsonParseNoThrow(
4227
- data
4228
- )) != null ? _c : gpxOrKml(data);
4229
- if (tmpData)
4230
- data = tmpData;
4231
- }
4232
- if (!data) {
4233
- throw new Error(
4234
- "Polyline data was provided as string but is incompatible with valid formats."
4235
- );
4236
- }
3713
+ if (!data) {
3714
+ throw new Error("Polyline data was provided as string but is incompatible with valid formats.");
4237
3715
  }
4238
- return addGeoJSONPolyline(map, __spreadProps(__spreadValues({}, options), {
4239
- data
4240
- }));
3716
+ }
3717
+ return addGeoJSONPolyline(map, {
3718
+ ...options,
3719
+ data
4241
3720
  });
4242
3721
  }
4243
3722
  function addGeoJSONPolyline(map, options) {
4244
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
4245
3723
  if (options.layerId && map.getLayer(options.layerId)) {
4246
- throw new Error(
4247
- `A layer already exists with the layer id: ${options.layerId}`
4248
- );
3724
+ throw new Error(`A layer already exists with the layer id: ${options.layerId}`);
4249
3725
  }
4250
- const sourceId = (_a = options.sourceId) != null ? _a : generateRandomSourceName();
4251
- const layerId = (_b = options.layerId) != null ? _b : generateRandomLayerName();
3726
+ const sourceId = options.sourceId ?? generateRandomSourceName();
3727
+ const layerId = options.layerId ?? generateRandomLayerName();
4252
3728
  const returnedInfo = {
4253
3729
  polylineLayerId: layerId,
4254
3730
  polylineOutlineLayerId: "",
@@ -4260,16 +3736,16 @@ function addGeoJSONPolyline(map, options) {
4260
3736
  data: options.data
4261
3737
  });
4262
3738
  }
4263
- const lineWidth = (_c = options.lineWidth) != null ? _c : 3;
4264
- const lineColor = (_d = options.lineColor) != null ? _d : getRandomColor();
4265
- const lineOpacity = (_e = options.lineOpacity) != null ? _e : 1;
4266
- const lineBlur = (_f = options.lineBlur) != null ? _f : 0;
4267
- const lineGapWidth = (_g = options.lineGapWidth) != null ? _g : 0;
4268
- let lineDashArray = (_h = options.lineDashArray) != null ? _h : null;
4269
- const outlineWidth = (_i = options.outlineWidth) != null ? _i : 1;
4270
- const outlineColor = (_j = options.outlineColor) != null ? _j : "#FFFFFF";
4271
- const outlineOpacity = (_k = options.outlineOpacity) != null ? _k : 1;
4272
- const outlineBlur = (_l = options.outlineBlur) != null ? _l : 0;
3739
+ const lineWidth = options.lineWidth ?? 3;
3740
+ const lineColor = options.lineColor ?? getRandomColor();
3741
+ const lineOpacity = options.lineOpacity ?? 1;
3742
+ const lineBlur = options.lineBlur ?? 0;
3743
+ const lineGapWidth = options.lineGapWidth ?? 0;
3744
+ let lineDashArray = options.lineDashArray ?? null;
3745
+ const outlineWidth = options.outlineWidth ?? 1;
3746
+ const outlineColor = options.outlineColor ?? "#FFFFFF";
3747
+ const outlineOpacity = options.outlineOpacity ?? 1;
3748
+ const outlineBlur = options.outlineBlur ?? 0;
4273
3749
  if (typeof lineDashArray === "string") {
4274
3750
  lineDashArray = dashArrayMaker(lineDashArray);
4275
3751
  }
@@ -4282,11 +3758,11 @@ function addGeoJSONPolyline(map, options) {
4282
3758
  type: "line",
4283
3759
  source: sourceId,
4284
3760
  layout: {
4285
- "line-join": (_m = options.lineJoin) != null ? _m : "round",
4286
- "line-cap": (_n = options.lineCap) != null ? _n : "round"
3761
+ "line-join": options.lineJoin ?? "round",
3762
+ "line-cap": options.lineCap ?? "round"
4287
3763
  },
4288
- minzoom: (_o = options.minzoom) != null ? _o : 0,
4289
- maxzoom: (_p = options.maxzoom) != null ? _p : 23,
3764
+ minzoom: options.minzoom ?? 0,
3765
+ maxzoom: options.maxzoom ?? 23,
4290
3766
  paint: {
4291
3767
  "line-opacity": typeof outlineOpacity === "number" ? outlineOpacity : rampedOptionsToLayerPaintSpec(outlineOpacity),
4292
3768
  "line-color": typeof outlineColor === "string" ? outlineColor : paintColorOptionsToPaintSpec(outlineColor),
@@ -4303,32 +3779,35 @@ function addGeoJSONPolyline(map, options) {
4303
3779
  type: "line",
4304
3780
  source: sourceId,
4305
3781
  layout: {
4306
- "line-join": (_q = options.lineJoin) != null ? _q : "round",
4307
- "line-cap": (_r = options.lineCap) != null ? _r : "round"
3782
+ "line-join": options.lineJoin ?? "round",
3783
+ "line-cap": options.lineCap ?? "round"
4308
3784
  },
4309
- minzoom: (_s = options.minzoom) != null ? _s : 0,
4310
- maxzoom: (_t = options.maxzoom) != null ? _t : 23,
4311
- paint: __spreadValues({
3785
+ minzoom: options.minzoom ?? 0,
3786
+ maxzoom: options.maxzoom ?? 23,
3787
+ paint: {
4312
3788
  "line-opacity": typeof lineOpacity === "number" ? lineOpacity : rampedOptionsToLayerPaintSpec(lineOpacity),
4313
3789
  "line-color": typeof lineColor === "string" ? lineColor : paintColorOptionsToPaintSpec(lineColor),
4314
3790
  "line-width": typeof lineWidth === "number" ? lineWidth : rampedOptionsToLayerPaintSpec(lineWidth),
4315
3791
  "line-blur": typeof lineBlur === "number" ? lineBlur : rampedOptionsToLayerPaintSpec(lineBlur),
4316
- "line-gap-width": typeof lineGapWidth === "number" ? lineGapWidth : rampedOptionsToLayerPaintSpec(lineGapWidth)
4317
- }, lineDashArray && { "line-dasharray": lineDashArray })
3792
+ "line-gap-width": typeof lineGapWidth === "number" ? lineGapWidth : rampedOptionsToLayerPaintSpec(lineGapWidth),
3793
+ // For some reasons passing "line-dasharray" with the value "undefined"
3794
+ // results in no showing the line while it should have the same behavior
3795
+ // of not adding the property "line-dasharray" as all.
3796
+ // As a workaround, we are inlining the addition of the prop with a conditional
3797
+ // which is less readable.
3798
+ ...lineDashArray && { "line-dasharray": lineDashArray }
3799
+ }
4318
3800
  },
4319
3801
  options.beforeId
4320
3802
  );
4321
3803
  return returnedInfo;
4322
3804
  }
4323
3805
  function addPolygon(map, options) {
4324
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
4325
3806
  if (options.layerId && map.getLayer(options.layerId)) {
4326
- throw new Error(
4327
- `A layer already exists with the layer id: ${options.layerId}`
4328
- );
3807
+ throw new Error(`A layer already exists with the layer id: ${options.layerId}`);
4329
3808
  }
4330
- const sourceId = (_a = options.sourceId) != null ? _a : generateRandomSourceName();
4331
- const layerId = (_b = options.layerId) != null ? _b : generateRandomLayerName();
3809
+ const sourceId = options.sourceId ?? generateRandomSourceName();
3810
+ const layerId = options.layerId ?? generateRandomLayerName();
4332
3811
  const returnedInfo = {
4333
3812
  polygonLayerId: layerId,
4334
3813
  polygonOutlineLayerId: options.outline ? `${layerId}_outline` : "",
@@ -4337,38 +3816,39 @@ function addPolygon(map, options) {
4337
3816
  if (options.data && !map.getSource(sourceId)) {
4338
3817
  let data = options.data;
4339
3818
  if (typeof data === "string" && isUUID(data)) {
4340
- data = `https://api.maptiler.com/data/${data}/features.json?key=${config$1.apiKey}`;
3819
+ data = `https://api.maptiler.com/data/${data}/features.json?key=${config.apiKey}`;
4341
3820
  }
4342
3821
  map.addSource(sourceId, {
4343
3822
  type: "geojson",
4344
3823
  data
4345
3824
  });
4346
3825
  }
4347
- let outlineDashArray = (_c = options.outlineDashArray) != null ? _c : null;
4348
- const outlineWidth = (_d = options.outlineWidth) != null ? _d : 1;
4349
- const outlineColor = (_e = options.outlineColor) != null ? _e : "#FFFFFF";
4350
- const outlineOpacity = (_f = options.outlineOpacity) != null ? _f : 1;
4351
- const outlineBlur = (_g = options.outlineBlur) != null ? _g : 0;
4352
- const fillColor = (_h = options.fillColor) != null ? _h : getRandomColor();
4353
- const fillOpacity = (_i = options.fillOpacity) != null ? _i : 1;
4354
- const outlinePosition = (_j = options.outlinePosition) != null ? _j : "center";
4355
- const pattern = (_k = options.pattern) != null ? _k : null;
3826
+ let outlineDashArray = options.outlineDashArray ?? null;
3827
+ const outlineWidth = options.outlineWidth ?? 1;
3828
+ const outlineColor = options.outlineColor ?? "#FFFFFF";
3829
+ const outlineOpacity = options.outlineOpacity ?? 1;
3830
+ const outlineBlur = options.outlineBlur ?? 0;
3831
+ const fillColor = options.fillColor ?? getRandomColor();
3832
+ const fillOpacity = options.fillOpacity ?? 1;
3833
+ const outlinePosition = options.outlinePosition ?? "center";
3834
+ const pattern = options.pattern ?? null;
4356
3835
  if (typeof outlineDashArray === "string") {
4357
3836
  outlineDashArray = dashArrayMaker(outlineDashArray);
4358
3837
  }
4359
3838
  const addLayers = (patternImageId = null) => {
4360
- var _a2, _b2, _c2, _d2, _e2, _f2;
4361
3839
  map.addLayer(
4362
3840
  {
4363
3841
  id: layerId,
4364
3842
  type: "fill",
4365
3843
  source: sourceId,
4366
- minzoom: (_a2 = options.minzoom) != null ? _a2 : 0,
4367
- maxzoom: (_b2 = options.maxzoom) != null ? _b2 : 23,
4368
- paint: __spreadValues({
3844
+ minzoom: options.minzoom ?? 0,
3845
+ maxzoom: options.maxzoom ?? 23,
3846
+ paint: {
4369
3847
  "fill-color": typeof fillColor === "string" ? fillColor : paintColorOptionsToPaintSpec(fillColor),
4370
- "fill-opacity": typeof fillOpacity === "number" ? fillOpacity : rampedOptionsToLayerPaintSpec(fillOpacity)
4371
- }, patternImageId && { "fill-pattern": patternImageId })
3848
+ "fill-opacity": typeof fillOpacity === "number" ? fillOpacity : rampedOptionsToLayerPaintSpec(fillOpacity),
3849
+ // Adding a pattern if provided
3850
+ ...patternImageId && { "fill-pattern": patternImageId }
3851
+ }
4372
3852
  },
4373
3853
  options.beforeId
4374
3854
  );
@@ -4405,20 +3885,26 @@ function addPolygon(map, options) {
4405
3885
  type: "line",
4406
3886
  source: sourceId,
4407
3887
  layout: {
4408
- "line-join": (_c2 = options.outlineJoin) != null ? _c2 : "round",
4409
- "line-cap": (_d2 = options.outlineCap) != null ? _d2 : "butt"
3888
+ "line-join": options.outlineJoin ?? "round",
3889
+ "line-cap": options.outlineCap ?? "butt"
4410
3890
  },
4411
- minzoom: (_e2 = options.minzoom) != null ? _e2 : 0,
4412
- maxzoom: (_f2 = options.maxzoom) != null ? _f2 : 23,
4413
- paint: __spreadValues({
3891
+ minzoom: options.minzoom ?? 0,
3892
+ maxzoom: options.maxzoom ?? 23,
3893
+ paint: {
4414
3894
  "line-opacity": typeof outlineOpacity === "number" ? outlineOpacity : rampedOptionsToLayerPaintSpec(outlineOpacity),
4415
3895
  "line-color": typeof outlineColor === "string" ? outlineColor : paintColorOptionsToPaintSpec(outlineColor),
4416
3896
  "line-width": typeof outlineWidth === "number" ? outlineWidth : rampedOptionsToLayerPaintSpec(outlineWidth),
4417
3897
  "line-blur": typeof outlineBlur === "number" ? outlineBlur : rampedOptionsToLayerPaintSpec(outlineBlur),
4418
- "line-offset": computedOutlineOffset
4419
- }, outlineDashArray && {
4420
- "line-dasharray": outlineDashArray
4421
- })
3898
+ "line-offset": computedOutlineOffset,
3899
+ // For some reasons passing "line-dasharray" with the value "undefined"
3900
+ // results in no showing the line while it should have the same behavior
3901
+ // of not adding the property "line-dasharray" as all.
3902
+ // As a workaround, we are inlining the addition of the prop with a conditional
3903
+ // which is less readable.
3904
+ ...outlineDashArray && {
3905
+ "line-dasharray": outlineDashArray
3906
+ }
3907
+ }
4422
3908
  },
4423
3909
  options.beforeId
4424
3910
  );
@@ -4442,33 +3928,27 @@ function addPolygon(map, options) {
4442
3928
  return returnedInfo;
4443
3929
  }
4444
3930
  function addPoint(map, options) {
4445
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
4446
3931
  if (options.layerId && map.getLayer(options.layerId)) {
4447
- throw new Error(
4448
- `A layer already exists with the layer id: ${options.layerId}`
4449
- );
3932
+ throw new Error(`A layer already exists with the layer id: ${options.layerId}`);
4450
3933
  }
4451
- const minPointRadius = (_a = options.minPointRadius) != null ? _a : 10;
4452
- const maxPointRadius = (_b = options.maxPointRadius) != null ? _b : 50;
4453
- const cluster = (_c = options.cluster) != null ? _c : false;
3934
+ const minPointRadius = options.minPointRadius ?? 10;
3935
+ const maxPointRadius = options.maxPointRadius ?? 50;
3936
+ const cluster = options.cluster ?? false;
4454
3937
  const nbDefaultDataDrivenStyleSteps = 20;
4455
- const colorramp = Array.isArray(options.pointColor) ? options.pointColor : ColorRampCollection.TURBO.scale(
4456
- 10,
4457
- options.cluster ? 1e4 : 1e3
4458
- ).resample("ease-out-square");
3938
+ const colorramp = Array.isArray(options.pointColor) ? options.pointColor : ColorRampCollection.TURBO.scale(10, options.cluster ? 1e4 : 1e3).resample("ease-out-square");
4459
3939
  const colorRampBounds = colorramp.getBounds();
4460
- const sourceId = (_d = options.sourceId) != null ? _d : generateRandomSourceName();
4461
- const layerId = (_e = options.layerId) != null ? _e : generateRandomLayerName();
4462
- const showLabel = (_f = options.showLabel) != null ? _f : cluster;
4463
- const alignOnViewport = (_g = options.alignOnViewport) != null ? _g : true;
4464
- const outline = (_h = options.outline) != null ? _h : false;
4465
- const outlineOpacity = (_i = options.outlineOpacity) != null ? _i : 1;
4466
- const outlineWidth = (_j = options.outlineWidth) != null ? _j : 1;
4467
- const outlineColor = (_k = options.outlineColor) != null ? _k : "#FFFFFF";
3940
+ const sourceId = options.sourceId ?? generateRandomSourceName();
3941
+ const layerId = options.layerId ?? generateRandomLayerName();
3942
+ const showLabel = options.showLabel ?? cluster;
3943
+ const alignOnViewport = options.alignOnViewport ?? true;
3944
+ const outline = options.outline ?? false;
3945
+ const outlineOpacity = options.outlineOpacity ?? 1;
3946
+ const outlineWidth = options.outlineWidth ?? 1;
3947
+ const outlineColor = options.outlineColor ?? "#FFFFFF";
4468
3948
  let pointOpacity;
4469
- const zoomCompensation = (_l = options.zoomCompensation) != null ? _l : true;
4470
- const minzoom = (_m = options.minzoom) != null ? _m : 0;
4471
- const maxzoom = (_n = options.maxzoom) != null ? _n : 23;
3949
+ const zoomCompensation = options.zoomCompensation ?? true;
3950
+ const minzoom = options.minzoom ?? 0;
3951
+ const maxzoom = options.maxzoom ?? 23;
4472
3952
  if (typeof options.pointOpacity === "number") {
4473
3953
  pointOpacity = options.pointOpacity;
4474
3954
  } else if (Array.isArray(options.pointOpacity)) {
@@ -4494,7 +3974,7 @@ function addPoint(map, options) {
4494
3974
  if (options.data && !map.getSource(sourceId)) {
4495
3975
  let data = options.data;
4496
3976
  if (typeof data === "string" && isUUID(data)) {
4497
- data = `https://api.maptiler.com/data/${data}/features.json?key=${config$1.apiKey}`;
3977
+ data = `https://api.maptiler.com/data/${data}/features.json?key=${config.apiKey}`;
4498
3978
  }
4499
3979
  map.addSource(sourceId, {
4500
3980
  type: "geojson",
@@ -4504,36 +3984,34 @@ function addPoint(map, options) {
4504
3984
  }
4505
3985
  if (cluster) {
4506
3986
  returnedInfo.clusterLayerId = `${layerId}_cluster`;
4507
- const clusterStyle = Array.from(
4508
- { length: nbDefaultDataDrivenStyleSteps },
4509
- (_, i) => {
4510
- const value = colorRampBounds.min + i * (colorRampBounds.max - colorRampBounds.min) / (nbDefaultDataDrivenStyleSteps - 1);
4511
- return {
4512
- value,
4513
- pointRadius: minPointRadius + (maxPointRadius - minPointRadius) * Math.pow(i / (nbDefaultDataDrivenStyleSteps - 1), 0.5),
4514
- color: colorramp.getColorHex(value)
4515
- };
4516
- }
4517
- );
3987
+ const clusterStyle = Array.from({ length: nbDefaultDataDrivenStyleSteps }, (_, i) => {
3988
+ const value = colorRampBounds.min + i * (colorRampBounds.max - colorRampBounds.min) / (nbDefaultDataDrivenStyleSteps - 1);
3989
+ return {
3990
+ value,
3991
+ pointRadius: minPointRadius + (maxPointRadius - minPointRadius) * (i / (nbDefaultDataDrivenStyleSteps - 1)) ** 0.5,
3992
+ color: colorramp.getColorHex(value)
3993
+ };
3994
+ });
4518
3995
  map.addLayer(
4519
3996
  {
4520
3997
  id: returnedInfo.clusterLayerId,
4521
3998
  type: "circle",
4522
3999
  source: sourceId,
4523
4000
  filter: ["has", "point_count"],
4524
- paint: __spreadValues({
4001
+ paint: {
4525
4002
  // 'circle-color': options.pointColor ?? colorDrivenByProperty(clusterStyle, "point_count"),
4526
4003
  "circle-color": typeof options.pointColor === "string" ? options.pointColor : colorDrivenByProperty(clusterStyle, "point_count"),
4527
4004
  "circle-radius": typeof options.pointRadius === "number" ? options.pointRadius : Array.isArray(options.pointRadius) ? rampedOptionsToLayerPaintSpec(options.pointRadius) : radiusDrivenByProperty(clusterStyle, "point_count", false),
4528
4005
  "circle-pitch-alignment": alignOnViewport ? "viewport" : "map",
4529
4006
  "circle-pitch-scale": "map",
4530
4007
  // scale with camera distance regardless of viewport/biewport alignement
4531
- "circle-opacity": pointOpacity
4532
- }, outline && {
4533
- "circle-stroke-opacity": typeof outlineOpacity === "number" ? outlineOpacity : rampedOptionsToLayerPaintSpec(outlineOpacity),
4534
- "circle-stroke-width": typeof outlineWidth === "number" ? outlineWidth : rampedOptionsToLayerPaintSpec(outlineWidth),
4535
- "circle-stroke-color": typeof outlineColor === "string" ? outlineColor : paintColorOptionsToPaintSpec(outlineColor)
4536
- }),
4008
+ "circle-opacity": pointOpacity,
4009
+ ...outline && {
4010
+ "circle-stroke-opacity": typeof outlineOpacity === "number" ? outlineOpacity : rampedOptionsToLayerPaintSpec(outlineOpacity),
4011
+ "circle-stroke-width": typeof outlineWidth === "number" ? outlineWidth : rampedOptionsToLayerPaintSpec(outlineWidth),
4012
+ "circle-stroke-color": typeof outlineColor === "string" ? outlineColor : paintColorOptionsToPaintSpec(outlineColor)
4013
+ }
4014
+ },
4537
4015
  minzoom,
4538
4016
  maxzoom
4539
4017
  },
@@ -4545,19 +4023,20 @@ function addPoint(map, options) {
4545
4023
  type: "circle",
4546
4024
  source: sourceId,
4547
4025
  filter: ["!", ["has", "point_count"]],
4548
- paint: __spreadValues({
4026
+ paint: {
4549
4027
  "circle-pitch-alignment": alignOnViewport ? "viewport" : "map",
4550
4028
  "circle-pitch-scale": "map",
4551
4029
  // scale with camera distance regardless of viewport/biewport alignement
4552
4030
  // 'circle-color': options.pointColor ?? clusterStyle[0].color,
4553
4031
  "circle-color": typeof options.pointColor === "string" ? options.pointColor : colorramp.getColorHex(colorramp.getBounds().min),
4554
4032
  "circle-radius": typeof options.pointRadius === "number" ? options.pointRadius : Array.isArray(options.pointRadius) ? rampedOptionsToLayerPaintSpec(options.pointRadius) : clusterStyle[0].pointRadius * 0.75,
4555
- "circle-opacity": pointOpacity
4556
- }, outline && {
4557
- "circle-stroke-opacity": typeof outlineOpacity === "number" ? outlineOpacity : rampedOptionsToLayerPaintSpec(outlineOpacity),
4558
- "circle-stroke-width": typeof outlineWidth === "number" ? outlineWidth : rampedOptionsToLayerPaintSpec(outlineWidth),
4559
- "circle-stroke-color": typeof outlineColor === "string" ? outlineColor : paintColorOptionsToPaintSpec(outlineColor)
4560
- }),
4033
+ "circle-opacity": pointOpacity,
4034
+ ...outline && {
4035
+ "circle-stroke-opacity": typeof outlineOpacity === "number" ? outlineOpacity : rampedOptionsToLayerPaintSpec(outlineOpacity),
4036
+ "circle-stroke-width": typeof outlineWidth === "number" ? outlineWidth : rampedOptionsToLayerPaintSpec(outlineWidth),
4037
+ "circle-stroke-color": typeof outlineColor === "string" ? outlineColor : paintColorOptionsToPaintSpec(outlineColor)
4038
+ }
4039
+ },
4561
4040
  minzoom,
4562
4041
  maxzoom
4563
4042
  },
@@ -4579,23 +4058,16 @@ function addPoint(map, options) {
4579
4058
  { zoom: 16, value: minPointRadius * 1 }
4580
4059
  ]) : minPointRadius;
4581
4060
  if (options.property && Array.isArray(options.pointColor)) {
4582
- const dataDrivenStyle = Array.from(
4583
- { length: nbDefaultDataDrivenStyleSteps },
4584
- (_, i) => {
4585
- const value = colorRampBounds.min + i * (colorRampBounds.max - colorRampBounds.min) / (nbDefaultDataDrivenStyleSteps - 1);
4586
- return {
4587
- value,
4588
- pointRadius: typeof options.pointRadius === "number" ? options.pointRadius : minPointRadius + (maxPointRadius - minPointRadius) * Math.pow(i / (nbDefaultDataDrivenStyleSteps - 1), 0.5),
4589
- color: typeof options.pointColor === "string" ? options.pointColor : colorramp.getColorHex(value)
4590
- };
4591
- }
4592
- );
4061
+ const dataDrivenStyle = Array.from({ length: nbDefaultDataDrivenStyleSteps }, (_, i) => {
4062
+ const value = colorRampBounds.min + i * (colorRampBounds.max - colorRampBounds.min) / (nbDefaultDataDrivenStyleSteps - 1);
4063
+ return {
4064
+ value,
4065
+ pointRadius: typeof options.pointRadius === "number" ? options.pointRadius : minPointRadius + (maxPointRadius - minPointRadius) * (i / (nbDefaultDataDrivenStyleSteps - 1)) ** 0.5,
4066
+ color: typeof options.pointColor === "string" ? options.pointColor : colorramp.getColorHex(value)
4067
+ };
4068
+ });
4593
4069
  pointColor = colorDrivenByProperty(dataDrivenStyle, options.property);
4594
- pointRadius = radiusDrivenByProperty(
4595
- dataDrivenStyle,
4596
- options.property,
4597
- zoomCompensation
4598
- );
4070
+ pointRadius = radiusDrivenByProperty(dataDrivenStyle, options.property, zoomCompensation);
4599
4071
  }
4600
4072
  map.addLayer(
4601
4073
  {
@@ -4606,18 +4078,19 @@ function addPoint(map, options) {
4606
4078
  // Contrary to labels, we want to see the small one in front. Weirdly "circle-sort-key" works in the opposite direction as "symbol-sort-key".
4607
4079
  "circle-sort-key": options.property ? ["/", 1, ["get", options.property]] : 0
4608
4080
  },
4609
- paint: __spreadValues({
4081
+ paint: {
4610
4082
  "circle-pitch-alignment": alignOnViewport ? "viewport" : "map",
4611
4083
  "circle-pitch-scale": "map",
4612
4084
  // scale with camera distance regardless of viewport/biewport alignement
4613
4085
  "circle-color": pointColor,
4614
4086
  "circle-opacity": pointOpacity,
4615
- "circle-radius": pointRadius
4616
- }, outline && {
4617
- "circle-stroke-opacity": typeof outlineOpacity === "number" ? outlineOpacity : rampedOptionsToLayerPaintSpec(outlineOpacity),
4618
- "circle-stroke-width": typeof outlineWidth === "number" ? outlineWidth : rampedOptionsToLayerPaintSpec(outlineWidth),
4619
- "circle-stroke-color": typeof outlineColor === "string" ? outlineColor : paintColorOptionsToPaintSpec(outlineColor)
4620
- }),
4087
+ "circle-radius": pointRadius,
4088
+ ...outline && {
4089
+ "circle-stroke-opacity": typeof outlineOpacity === "number" ? outlineOpacity : rampedOptionsToLayerPaintSpec(outlineOpacity),
4090
+ "circle-stroke-width": typeof outlineWidth === "number" ? outlineWidth : rampedOptionsToLayerPaintSpec(outlineWidth),
4091
+ "circle-stroke-color": typeof outlineColor === "string" ? outlineColor : paintColorOptionsToPaintSpec(outlineColor)
4092
+ }
4093
+ },
4621
4094
  minzoom,
4622
4095
  maxzoom
4623
4096
  },
@@ -4626,30 +4099,20 @@ function addPoint(map, options) {
4626
4099
  }
4627
4100
  if (showLabel !== false && (options.cluster || options.property)) {
4628
4101
  returnedInfo.labelLayerId = `${layerId}_label`;
4629
- const labelColor = (_o = options.labelColor) != null ? _o : "#fff";
4630
- const labelSize = (_p = options.labelSize) != null ? _p : 12;
4102
+ const labelColor = options.labelColor ?? "#fff";
4103
+ const labelSize = options.labelSize ?? 12;
4631
4104
  map.addLayer(
4632
4105
  {
4633
4106
  id: returnedInfo.labelLayerId,
4634
4107
  type: "symbol",
4635
4108
  source: sourceId,
4636
- filter: [
4637
- "has",
4638
- options.cluster ? "point_count" : options.property
4639
- ],
4109
+ filter: ["has", options.cluster ? "point_count" : options.property],
4640
4110
  layout: {
4641
4111
  "text-field": options.cluster ? "{point_count_abbreviated}" : `{${options.property}}`,
4642
4112
  "text-font": ["Noto Sans Regular"],
4643
4113
  "text-size": labelSize,
4644
4114
  "text-pitch-alignment": alignOnViewport ? "viewport" : "map",
4645
- "symbol-sort-key": [
4646
- "/",
4647
- 1,
4648
- [
4649
- "get",
4650
- options.cluster ? "point_count" : options.property
4651
- ]
4652
- ]
4115
+ "symbol-sort-key": ["/", 1, ["get", options.cluster ? "point_count" : options.property]]
4653
4116
  // so that the largest value goes on top
4654
4117
  },
4655
4118
  paint: {
@@ -4665,18 +4128,15 @@ function addPoint(map, options) {
4665
4128
  return returnedInfo;
4666
4129
  }
4667
4130
  function addHeatmap(map, options) {
4668
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4669
4131
  if (options.layerId && map.getLayer(options.layerId)) {
4670
- throw new Error(
4671
- `A layer already exists with the layer id: ${options.layerId}`
4672
- );
4673
- }
4674
- const sourceId = (_a = options.sourceId) != null ? _a : generateRandomSourceName();
4675
- const layerId = (_b = options.layerId) != null ? _b : generateRandomLayerName();
4676
- const minzoom = (_c = options.minzoom) != null ? _c : 0;
4677
- const maxzoom = (_d = options.maxzoom) != null ? _d : 23;
4678
- const zoomCompensation = (_e = options.zoomCompensation) != null ? _e : true;
4679
- const opacity = (_f = options.opacity) != null ? _f : [
4132
+ throw new Error(`A layer already exists with the layer id: ${options.layerId}`);
4133
+ }
4134
+ const sourceId = options.sourceId ?? generateRandomSourceName();
4135
+ const layerId = options.layerId ?? generateRandomLayerName();
4136
+ const minzoom = options.minzoom ?? 0;
4137
+ const maxzoom = options.maxzoom ?? 23;
4138
+ const zoomCompensation = options.zoomCompensation ?? true;
4139
+ const opacity = options.opacity ?? [
4680
4140
  { zoom: minzoom, value: 0 },
4681
4141
  { zoom: minzoom + 0.25, value: 1 },
4682
4142
  { zoom: maxzoom - 0.25, value: 1 },
@@ -4690,13 +4150,13 @@ function addHeatmap(map, options) {
4690
4150
  if (!colorRamp.hasTransparentStart()) {
4691
4151
  colorRamp = colorRamp.transparentStart();
4692
4152
  }
4693
- const intensity = (_g = options.intensity) != null ? _g : [
4153
+ const intensity = options.intensity ?? [
4694
4154
  { zoom: 0, value: 0.01 },
4695
4155
  { zoom: 4, value: 0.2 },
4696
4156
  { zoom: 16, value: 1 }
4697
4157
  ];
4698
- const property = (_h = options.property) != null ? _h : null;
4699
- const propertyValueWeight = (_i = options.weight) != null ? _i : 1;
4158
+ const property = options.property ?? null;
4159
+ const propertyValueWeight = options.weight ?? 1;
4700
4160
  let heatmapWeight = 1;
4701
4161
  if (property) {
4702
4162
  if (typeof propertyValueWeight === "number") {
@@ -4717,9 +4177,7 @@ function addHeatmap(map, options) {
4717
4177
  if (typeof propertyValueWeight === "number") {
4718
4178
  heatmapWeight = propertyValueWeight;
4719
4179
  } else if (Array.isArray(propertyValueWeight)) {
4720
- console.warn(
4721
- "The options `.propertyValueWeights` can only be used when `.property` is provided."
4722
- );
4180
+ console.warn("The options `.propertyValueWeights` can only be used when `.property` is provided.");
4723
4181
  }
4724
4182
  }
4725
4183
  const defaultRadiusZoomRamping = [
@@ -4729,29 +4187,19 @@ function addHeatmap(map, options) {
4729
4187
  { zoom: 8, value: 50 * 0.25 },
4730
4188
  { zoom: 16, value: 50 }
4731
4189
  ];
4732
- const radius = (_j = options.radius) != null ? _j : zoomCompensation ? defaultRadiusZoomRamping : 10;
4190
+ const radius = options.radius ?? (zoomCompensation ? defaultRadiusZoomRamping : 10);
4733
4191
  let radiusHeatmap = 1;
4734
4192
  if (typeof radius === "number") {
4735
4193
  radiusHeatmap = radius;
4736
4194
  } else if (Array.isArray(radius) && "zoom" in radius[0]) {
4737
4195
  radiusHeatmap = rampedOptionsToLayerPaintSpec(radius);
4738
4196
  } else if (property && Array.isArray(radius) && "propertyValue" in radius[0]) {
4739
- radiusHeatmap = radiusDrivenByPropertyHeatmap(
4740
- radius,
4741
- property,
4742
- zoomCompensation
4743
- );
4197
+ radiusHeatmap = radiusDrivenByPropertyHeatmap(radius, property, zoomCompensation);
4744
4198
  } else if (!property && Array.isArray(radius) && "propertyValue" in radius[0]) {
4745
- radiusHeatmap = rampedOptionsToLayerPaintSpec(
4746
- defaultRadiusZoomRamping
4747
- );
4748
- console.warn(
4749
- "The option `.radius` can only be property-driven if the option `.property` is provided."
4750
- );
4199
+ radiusHeatmap = rampedOptionsToLayerPaintSpec(defaultRadiusZoomRamping);
4200
+ console.warn("The option `.radius` can only be property-driven if the option `.property` is provided.");
4751
4201
  } else {
4752
- radiusHeatmap = rampedOptionsToLayerPaintSpec(
4753
- defaultRadiusZoomRamping
4754
- );
4202
+ radiusHeatmap = rampedOptionsToLayerPaintSpec(defaultRadiusZoomRamping);
4755
4203
  }
4756
4204
  const returnedInfo = {
4757
4205
  heatmapLayerId: layerId,
@@ -4760,7 +4208,7 @@ function addHeatmap(map, options) {
4760
4208
  if (options.data && !map.getSource(sourceId)) {
4761
4209
  let data = options.data;
4762
4210
  if (typeof data === "string" && isUUID(data)) {
4763
- data = `https://api.maptiler.com/data/${data}/features.json?key=${config$1.apiKey}`;
4211
+ data = `https://api.maptiler.com/data/${data}/features.json?key=${config.apiKey}`;
4764
4212
  }
4765
4213
  map.addSource(sourceId, {
4766
4214
  type: "geojson",
@@ -4775,14 +4223,10 @@ function addHeatmap(map, options) {
4775
4223
  maxzoom,
4776
4224
  paint: {
4777
4225
  "heatmap-weight": heatmapWeight,
4778
- "heatmap-intensity": typeof intensity === "number" ? intensity : rampedOptionsToLayerPaintSpec(
4779
- intensity
4780
- ),
4226
+ "heatmap-intensity": typeof intensity === "number" ? intensity : rampedOptionsToLayerPaintSpec(intensity),
4781
4227
  "heatmap-color": heatmapIntensityFromColorRamp(colorRamp),
4782
4228
  "heatmap-radius": radiusHeatmap,
4783
- "heatmap-opacity": typeof opacity === "number" ? opacity : rampedOptionsToLayerPaintSpec(
4784
- opacity
4785
- )
4229
+ "heatmap-opacity": typeof opacity === "number" ? opacity : rampedOptionsToLayerPaintSpec(opacity)
4786
4230
  }
4787
4231
  });
4788
4232
  return returnedInfo;
@@ -4795,70 +4239,10 @@ const helpers = {
4795
4239
  addHeatmap
4796
4240
  };
4797
4241
 
4798
- const {
4799
- // supported,
4800
- setRTLTextPlugin,
4801
- getRTLTextPluginStatus,
4802
- LngLat,
4803
- LngLatBounds,
4804
- MercatorCoordinate,
4805
- Evented,
4806
- AJAXError,
4807
- prewarm,
4808
- clearPrewarmedResources,
4809
- addProtocol,
4810
- removeProtocol,
4811
- Hash,
4812
- Point,
4813
- config,
4814
- EdgeInsets,
4815
- DragRotateHandler,
4816
- DragPanHandler,
4817
- TwoFingersTouchZoomRotateHandler,
4818
- DoubleClickZoomHandler,
4819
- TwoFingersTouchZoomHandler,
4820
- TwoFingersTouchRotateHandler,
4821
- getWorkerCount,
4822
- setWorkerCount,
4823
- getMaxParallelImageRequests,
4824
- setMaxParallelImageRequests,
4825
- getWorkerUrl,
4826
- setWorkerUrl,
4827
- addSourceType,
4828
- importScriptInWorkers
4829
- } = maplibregl;
4242
+ enableRTL();
4830
4243
  function getVersion() {
4831
4244
  return packagejson.version;
4832
4245
  }
4833
- function getMapLibreVersion() {
4834
- return maplibregl.getVersion();
4835
- }
4836
- const MapMLGL = maplibregl.Map;
4837
- const MarkerMLGL = maplibregl.Marker;
4838
- const PopupMLGL = maplibregl.Popup;
4839
- const StyleMLGL = maplibregl.Style;
4840
- const CanvasSourceMLGL = maplibregl.CanvasSource;
4841
- const GeoJSONSourceMLGL = maplibregl.GeoJSONSource;
4842
- const ImageSourceMLGL = maplibregl.ImageSource;
4843
- const RasterTileSourceMLGL = maplibregl.RasterTileSource;
4844
- const RasterDEMTileSourceMLGL = maplibregl.RasterDEMTileSource;
4845
- const VectorTileSourceMLGL = maplibregl.VectorTileSource;
4846
- const VideoSourceMLGL = maplibregl.VideoSource;
4847
- maplibregl.NavigationControl;
4848
- maplibregl.GeolocateControl;
4849
- maplibregl.AttributionControl;
4850
- maplibregl.LogoControl;
4851
- maplibregl.ScaleControl;
4852
- maplibregl.FullscreenControl;
4853
- maplibregl.TerrainControl;
4854
- const BoxZoomHandlerMLGL = maplibregl.BoxZoomHandler;
4855
- const ScrollZoomHandlerMLGL = maplibregl.ScrollZoomHandler;
4856
- const CooperativeGesturesHandlerMLGL = maplibregl.CooperativeGesturesHandler;
4857
- const KeyboardHandlerMLGL = maplibregl.KeyboardHandler;
4858
- const TwoFingersTouchPitchHandlerMLGL = maplibregl.TwoFingersTouchPitchHandler;
4859
- const MapWheelEventMLGL = maplibregl.MapWheelEvent;
4860
- const MapTouchEventMLGL = maplibregl.MapTouchEvent;
4861
- const MapMouseEventMLGL = maplibregl.MapMouseEvent;
4862
4246
 
4863
- export { AJAXError, AttributionControl, BoxZoomHandler, BoxZoomHandlerMLGL, CanvasSource, CanvasSourceMLGL, ColorRamp, ColorRampCollection, CooperativeGesturesHandler, CooperativeGesturesHandlerMLGL, DoubleClickZoomHandler, DragPanHandler, DragRotateHandler, EdgeInsets, Evented, FullscreenControl, GeoJSONSource, GeoJSONSourceMLGL, GeolocateControl, GeolocationType, Hash, ImageSource, ImageSourceMLGL, KeyboardHandler, KeyboardHandlerMLGL, Language, LngLat, LngLatBounds, LogoControl, Map, MapMLGL, MapMouseEvent, MapMouseEventMLGL, MapTouchEvent, MapTouchEventMLGL, MapWheelEvent, MapWheelEventMLGL, MaptilerGeolocateControl, MaptilerLogoControl, MaptilerNavigationControl, MaptilerTerrainControl, Marker, MarkerMLGL, MercatorCoordinate, NavigationControl, Point, Popup, PopupMLGL, RasterDEMTileSource, RasterDEMTileSourceMLGL, RasterTileSource, RasterTileSourceMLGL, ScaleControl, ScrollZoomHandler, ScrollZoomHandlerMLGL, SdkConfig, Style, StyleMLGL, TerrainControl, TwoFingersTouchPitchHandler, TwoFingersTouchPitchHandlerMLGL, TwoFingersTouchRotateHandler, TwoFingersTouchZoomHandler, TwoFingersTouchZoomRotateHandler, VectorTileSource, VectorTileSourceMLGL, VideoSource, VideoSourceMLGL, addProtocol, addSourceType, clearPrewarmedResources, config$1 as config, config as configMLGL, getBrowserLanguage, getMapLibreVersion, getMaxParallelImageRequests, getRTLTextPluginStatus, getVersion, getWorkerCount, getWorkerUrl, gpx, gpxOrKml, hasChildNodeWithName, helpers, importScriptInWorkers, isLanguageSupported, kml, prewarm, removeProtocol, setMaxParallelImageRequests, setRTLTextPlugin, setWorkerCount, setWorkerUrl, str2xml, xml2str };
4247
+ export { AttributionControl, BoxZoomHandler, CanvasSource, ColorRamp, ColorRampCollection, CooperativeGesturesHandler, FullscreenControl, GeoJSONSource, GeolocateControl, GeolocationType, ImageSource, KeyboardHandler, Language, LogoControl, Map, MapMouseEvent, MapTouchEvent, MapWheelEvent, MaptilerGeolocateControl, MaptilerLogoControl, MaptilerNavigationControl, MaptilerTerrainControl, Marker$1 as Marker, NavigationControl, Popup, RasterDEMTileSource, RasterTileSource, ScaleControl, ScrollZoomHandler, SdkConfig, Style, TerrainControl, TwoFingersTouchPitchHandler, VectorTileSource, VideoSource, config, getBrowserLanguage, getVersion, gpx, gpxOrKml, hasChildNodeWithName, helpers, isLanguageSupported, kml, str2xml, xml2str };
4864
4248
  //# sourceMappingURL=maptiler-sdk.mjs.map