@maptiler/client 1.6.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/.github/pull_request_template.md +11 -0
  2. package/.github/workflows/format-lint.yml +24 -0
  3. package/CHANGELOG.md +25 -0
  4. package/dist/maptiler-client.cjs +587 -332
  5. package/dist/maptiler-client.cjs.map +1 -1
  6. package/dist/maptiler-client.d.ts +291 -12
  7. package/dist/maptiler-client.min.mjs +1 -1
  8. package/dist/maptiler-client.mjs +580 -332
  9. package/dist/maptiler-client.mjs.map +1 -1
  10. package/package.json +29 -20
  11. package/readme.md +134 -2
  12. package/rollup.config.js +3 -3
  13. package/tsconfig.json +1 -1
  14. package/dist/maptiler-client.umd.js +0 -1368
  15. package/dist/maptiler-client.umd.js.map +0 -1
  16. package/dist/maptiler-client.umd.min.js +0 -1
  17. package/docs/.nojekyll +0 -1
  18. package/docs/assets/custom.css +0 -118
  19. package/docs/assets/highlight.css +0 -85
  20. package/docs/assets/main.js +0 -58
  21. package/docs/assets/search.js +0 -1
  22. package/docs/assets/style.css +0 -1280
  23. package/docs/classes/config.ClientConfig.html +0 -132
  24. package/docs/classes/services_ServiceError.ServiceError.html +0 -103
  25. package/docs/functions/language.getAutoLanguageGeocoding.html +0 -60
  26. package/docs/functions/services_simplify.default.html +0 -65
  27. package/docs/images/JS-logo.svg +0 -4
  28. package/docs/images/TS-logo.svg +0 -6
  29. package/docs/images/maptiler-client-logo.afdesign +0 -0
  30. package/docs/images/maptiler-client-logo.svg +0 -75
  31. package/docs/images/maptiler-logo-256.png +0 -0
  32. package/docs/images/maptiler-logo.svg +0 -23
  33. package/docs/images/screenshots/static-bounded-europe-1024.png +0 -0
  34. package/docs/images/screenshots/static-bounded-europe-2048.png +0 -0
  35. package/docs/images/screenshots/static-bounded-portugal-1024x2048.png +0 -0
  36. package/docs/images/screenshots/static-bounded-portugal-2048x2048.png +0 -0
  37. package/docs/images/screenshots/static-with-path.png +0 -0
  38. package/docs/index.html +0 -340
  39. package/docs/modules/config.html +0 -71
  40. package/docs/modules/language.html +0 -71
  41. package/docs/modules/services_ServiceError.html +0 -61
  42. package/docs/modules/services_coordinates.html +0 -84
  43. package/docs/modules/services_data.html +0 -66
  44. package/docs/modules/services_geocoding.html +0 -82
  45. package/docs/modules/services_geolocation.html +0 -68
  46. package/docs/modules/services_simplify.html +0 -61
  47. package/docs/modules/services_staticMaps.html +0 -74
  48. package/docs/modules.html +0 -59
  49. package/docs/types/config.FetchFunction.html +0 -71
  50. package/docs/types/language.LanguageGeocodingString.html +0 -58
  51. package/docs/types/services_coordinates.CoordinateExport.html +0 -71
  52. package/docs/types/services_coordinates.CoordinateGrid.html +0 -69
  53. package/docs/types/services_coordinates.CoordinateId.html +0 -71
  54. package/docs/types/services_coordinates.CoordinateSearch.html +0 -93
  55. package/docs/types/services_coordinates.CoordinateSearchResult.html +0 -75
  56. package/docs/types/services_coordinates.CoordinateTransformResult.html +0 -76
  57. package/docs/types/services_coordinates.CoordinateTransformation.html +0 -89
  58. package/docs/types/services_coordinates.CoordinatesSearchOptions.html +0 -83
  59. package/docs/types/services_coordinates.CoordinatesTransformOptions.html +0 -85
  60. package/docs/types/services_coordinates.XYZ.html +0 -73
  61. package/docs/types/services_data.GetDataOptions.html +0 -64
  62. package/docs/types/services_geocoding.ByIdGeocodingOptions.html +0 -63
  63. package/docs/types/services_geocoding.CommonForwardAndReverseGeocodingOptions.html +0 -63
  64. package/docs/types/services_geocoding.Coordinates.html +0 -63
  65. package/docs/types/services_geocoding.FeatureHierarchy.html +0 -63
  66. package/docs/types/services_geocoding.GeocodingFeature.html +0 -63
  67. package/docs/types/services_geocoding.GeocodingOptions.html +0 -63
  68. package/docs/types/services_geocoding.GeocodingSearchResult.html +0 -80
  69. package/docs/types/services_geocoding.LanguageGeocodingOptions.html +0 -70
  70. package/docs/types/services_geocoding.ReverseGeocodingOptions.html +0 -63
  71. package/docs/types/services_geolocation.GeolocationInfoOptions.html +0 -65
  72. package/docs/types/services_geolocation.GeolocationResult.html +0 -128
  73. package/docs/types/services_staticMaps.AutomaticStaticMapOptions.html +0 -61
  74. package/docs/types/services_staticMaps.BoundedStaticMapOptions.html +0 -61
  75. package/docs/types/services_staticMaps.CenteredStaticMapOptions.html +0 -61
  76. package/docs/types/services_staticMaps.StaticMapBaseOptions.html +0 -157
  77. package/docs/types/services_staticMaps.StaticMapMarker.html +0 -61
  78. package/docs/variables/config.config.html +0 -58
  79. package/docs/variables/language.LanguageGeocoding.html +0 -171
  80. package/docs/variables/services_coordinates.coordinates.html +0 -110
  81. package/docs/variables/services_data.data.html +0 -80
  82. package/docs/variables/services_geocoding.geocoding.html +0 -265
  83. package/docs/variables/services_geolocation.geolocation.html +0 -79
  84. package/docs/variables/services_staticMaps.staticMaps.html +0 -128
  85. package/docsmd/.nojekyll +0 -1
  86. package/docsmd/README.md +0 -873
  87. package/docsmd/assets/custom.css +0 -118
  88. package/docsmd/classes/ClientConfig.md +0 -90
  89. package/docsmd/classes/MapStyleVariant.md +0 -234
  90. package/docsmd/classes/ReferenceMapStyle.md +0 -169
  91. package/docsmd/classes/ServiceError.md +0 -52
  92. package/examples/test-browser-es.html +0 -103
  93. package/examples/test-browser-umd.html +0 -90
  94. package/examples/test-node.js +0 -52
  95. package/images/JS-logo.svg +0 -4
  96. package/images/TS-logo.svg +0 -6
  97. package/images/maptiler-client-logo.afdesign +0 -0
  98. package/images/maptiler-client-logo.svg +0 -75
  99. package/images/maptiler-logo-256.png +0 -0
  100. package/images/maptiler-logo.svg +0 -23
  101. package/images/screenshots/static-bounded-europe-1024.png +0 -0
  102. package/images/screenshots/static-bounded-europe-2048.png +0 -0
  103. package/images/screenshots/static-bounded-portugal-1024x2048.png +0 -0
  104. package/images/screenshots/static-bounded-portugal-2048x2048.png +0 -0
  105. package/images/screenshots/static-with-path.png +0 -0
  106. package/src/callFetch.ts +0 -18
  107. package/src/config.ts +0 -65
  108. package/src/defaults.ts +0 -11
  109. package/src/index.ts +0 -111
  110. package/src/language.ts +0 -87
  111. package/src/mapstyle.ts +0 -968
  112. package/src/services/ServiceError.ts +0 -10
  113. package/src/services/coordinates.ts +0 -258
  114. package/src/services/data.ts +0 -63
  115. package/src/services/geocoding.ts +0 -458
  116. package/src/services/geolocation.ts +0 -139
  117. package/src/services/simplify.ts +0 -87
  118. package/src/services/staticMaps.ts +0 -463
@@ -1,7 +1,66 @@
1
- import { BBox, Position, Feature, Geometry, FeatureCollection } from 'geojson';
2
- export { BBox, Position } from 'geojson';
1
+ import { BBox, Position, Feature, Geometry, FeatureCollection, LineString, MultiLineString, GeoJsonObject } from 'geojson';
2
+ export { BBox, LineString, MultiLineString, Position } from 'geojson';
3
+ import QuickLRU from 'quick-lru';
3
4
 
4
- type FetchFunction = (url: string, options: object) => Promise<any>;
5
+ /**
6
+ * Informations about an image
7
+ */
8
+ type PixelData = {
9
+ /**
10
+ * The array of pixels as RGBRGB or RGBARGBA in a row-major order
11
+ */
12
+ pixels: Uint8ClampedArray | Uint8Array;
13
+ /**
14
+ * Width of the image in number of pixels
15
+ */
16
+ width: number;
17
+ /**
18
+ * Height of the image in number of pixels
19
+ */
20
+ height: number;
21
+ /**
22
+ * Number of components per pixel (3 if image is RGB, 4 if image is RGBA)
23
+ */
24
+ components: number;
25
+ };
26
+ /**
27
+ * Type for the function that decodes an image file ArrayBuffer into valid pixel data
28
+ */
29
+ type BufferToPixelDataFunction = (ArrayBuffer: any) => Promise<PixelData>;
30
+ /**
31
+ * Main properties necessary from a TileJSON
32
+ */
33
+ type TileJSON = {
34
+ scale: string;
35
+ format: string;
36
+ maxzoom: number;
37
+ minzoom: number;
38
+ profile: string;
39
+ description: string;
40
+ attribution: string;
41
+ bounds: [number, number, number, number];
42
+ center: [number, number, number];
43
+ /**
44
+ * TileJSON version
45
+ */
46
+ tilejson: string;
47
+ name: string;
48
+ crs: string;
49
+ crs_wkt: string;
50
+ extent: [number, number, number, number];
51
+ tiles: string[];
52
+ };
53
+ /**
54
+ * Singleton-like function to access the tile cache
55
+ */
56
+ declare function getTileCache(): QuickLRU<string, PixelData>;
57
+ /**
58
+ * Browser function to decode an image file buffer into valid pixel data
59
+ */
60
+ declare function bufferToPixelDataBrowser(buff: ArrayBuffer): Promise<PixelData>;
61
+ declare function getBufferToPixelDataParser(): BufferToPixelDataFunction;
62
+
63
+ type FetchFunction = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
5
64
  /**
6
65
  * The configuration object definition
7
66
  */
@@ -15,6 +74,11 @@ declare class ClientConfig {
15
74
  * will be automatically resolved.
16
75
  */
17
76
  private _fetch;
77
+ /**
78
+ * Number of tiles to keep in cache
79
+ */
80
+ tileCacheSize: number;
81
+ bufferToPixelData: BufferToPixelDataFunction | null;
18
82
  /**
19
83
  * Set the MapTiler Cloud API key
20
84
  */
@@ -102,6 +166,7 @@ type Values<T> = T[keyof T];
102
166
  * Built-in languages values as strings
103
167
  */
104
168
  type LanguageGeocodingString = Values<typeof LanguageGeocoding>;
169
+ declare function getAutoLanguageGeocoding(): LanguageGeocodingString;
105
170
 
106
171
  type LanguageGeocodingOptions = {
107
172
  /**
@@ -119,9 +184,14 @@ type CommonForwardAndReverseGeocodingOptions = LanguageGeocodingOptions & {
119
184
  */
120
185
  limit?: number;
121
186
  /**
122
- * Filter of feature types to return. If not specified, all available feature types are returned.
187
+ * Filter of feature types to return.
188
+ * If not specified, feature of all available types except `poi` are returned (`types = ["poi"]`, `excludeTypes = true`).
123
189
  */
124
190
  types?: ("country" | "region" | "subregion" | "county" | "joint_municipality" | "joint_submunicipality" | "municipality" | "municipal_district" | "locality" | "neighbourhood" | "place" | "postal_code" | "address" | "poi")[];
191
+ /**
192
+ * Set to `true` to use all available feature types except those mentioned in `types`. Default value is `false` if `types` is specified.
193
+ */
194
+ excludeTypes?: boolean;
125
195
  };
126
196
  type GeocodingOptions = CommonForwardAndReverseGeocodingOptions & {
127
197
  /**
@@ -131,7 +201,7 @@ type GeocodingOptions = CommonForwardAndReverseGeocodingOptions & {
131
201
  /**
132
202
  * Prefer results close to a specific location.
133
203
  */
134
- proximity?: Position;
204
+ proximity?: Position | "ip";
135
205
  /**
136
206
  * Limit search to specific country/countries specified as list of Alpha-2 ISO 3166-1 codes.
137
207
  */
@@ -141,13 +211,14 @@ type GeocodingOptions = CommonForwardAndReverseGeocodingOptions & {
141
211
  */
142
212
  fuzzyMatch?: boolean;
143
213
  /**
144
- * Set to `true` to use autocomplete, `false` to disable it.
145
- * Default (`undefined`) is to combine autocomplete with non-autocomplete results.
214
+ * Set to `true` to use autocomplete, `false` to disable it. Default is `true`.
146
215
  */
147
216
  autocomplete?: boolean;
148
217
  };
149
218
  type ReverseGeocodingOptions = CommonForwardAndReverseGeocodingOptions;
150
- type ByIdGeocodingOptions = LanguageGeocodingOptions;
219
+ type ByIdGeocodingOptions = LanguageGeocodingOptions & {
220
+ apiKey?: string;
221
+ };
151
222
  type Coordinates = Position;
152
223
  type FeatureProperties = {
153
224
  /**
@@ -174,6 +245,10 @@ type FeatureProperties = {
174
245
  * Array of POI categories. Only available for `poi` type.
175
246
  */
176
247
  categories?: string[];
248
+ /**
249
+ * Wikidata identifier.
250
+ */
251
+ wikidata?: string;
177
252
  };
178
253
  type FeatureBase = {
179
254
  /**
@@ -294,7 +369,7 @@ declare function byId(id: string, options?: ByIdGeocodingOptions): Promise<Geoco
294
369
  * @param options
295
370
  * @returns
296
371
  */
297
- declare function batch(queries: string[], options?: GeocodingOptions): Promise<GeocodingSearchResult[]>;
372
+ declare function batch$1(queries: string[], options?: GeocodingOptions): Promise<GeocodingSearchResult[]>;
298
373
  /**
299
374
  * The **geocoding** namespace contains asynchronous functions to call the [MapTiler Geocoding API](https://docs.maptiler.com/cloud/api/geocoding/).
300
375
  * The **Geocoding API** provides ways to get geographic coordinates from a human-readable search query of a place (forward geocoding)
@@ -304,7 +379,7 @@ declare const geocoding: {
304
379
  forward: typeof forward;
305
380
  reverse: typeof reverse;
306
381
  byId: typeof byId;
307
- batch: typeof batch;
382
+ batch: typeof batch$1;
308
383
  language: {
309
384
  AUTO: string;
310
385
  ALBANIAN: string;
@@ -516,9 +591,13 @@ type CoordinateSearch = {
516
591
  /**
517
592
  * Most suitable transformation for this CRS.
518
593
  */
519
- default_transformation?: any;
594
+ default_transformation?: DefaultTransformation;
520
595
  exports: CoordinateExport;
521
596
  };
597
+ type DefaultTransformation = {
598
+ authority: string;
599
+ code: number;
600
+ };
522
601
  type CoordinateSearchResult = {
523
602
  /**
524
603
  * The coordinate search results
@@ -1040,6 +1119,7 @@ type MapStyleType = {
1040
1119
  };
1041
1120
  };
1042
1121
  declare const mapStylePresetList: Array<MapStylePreset>;
1122
+ declare function styleToStyle(style: string | ReferenceMapStyle | MapStyleVariant | null | undefined): string;
1043
1123
  /**
1044
1124
  * Contains all the reference map style created by MapTiler team as well as all the variants.
1045
1125
  * For example, `MapStyle.STREETS` and the variants:
@@ -1225,4 +1305,203 @@ declare class ServiceError extends Error {
1225
1305
  constructor(res: Response, customMessage?: string);
1226
1306
  }
1227
1307
 
1228
- export { AutomaticStaticMapOptions, BoundedStaticMapOptions, CenteredStaticMapOptions, ClientConfig, CommonForwardAndReverseGeocodingOptions, CoordinateExport, CoordinateGrid, CoordinateId, CoordinateSearch, CoordinateSearchResult, CoordinateTransformResult, CoordinateTransformation, Coordinates, CoordinatesSearchOptions, CoordinatesTransformOptions, FeatureHierarchy, FetchFunction, GeocodingFeature, GeocodingOptions, GeocodingSearchResult, GeolocationInfoOptions, GeolocationResult, GetDataOptions, LanguageGeocoding, LanguageGeocodingOptions, LanguageGeocodingString, MapStyle, MapStylePreset, MapStyleType, MapStyleVariant, ReferenceMapStyle, ReverseGeocodingOptions, ServiceError, StaticMapBaseOptions, StaticMapMarker, XYZ, config, coordinates, data, expandMapStyle, geocoding, geolocation, mapStylePresetList, staticMaps };
1308
+ /**
1309
+ * Convert a wgs84 longitude to web Mercator X (west-east axis), where westmost X is 0 and eastmost X is 1.
1310
+ */
1311
+ declare function longitudeToMercatorX(lng: number): number;
1312
+ /**
1313
+ * Convert a wgs84 latitude to web Mercator Y (north-south axis), where northmost Y is 0 and southmost Y is 1.
1314
+ */
1315
+ declare function latitudeToMercatorY(lat: number): number;
1316
+ /**
1317
+ * Convert a wgs84 position into a web Mercator position where north-west is [0, 0] and south-east is [1, 1]
1318
+ */
1319
+ declare function wgs84ToMercator(position: Position): Position;
1320
+ /**
1321
+ * Converts a mercator X (west-east axis in [0, 1]) to wgs84 longitude
1322
+ */
1323
+ declare function mercatorXToLongitude(x: number): number;
1324
+ /**
1325
+ * Converts a mercator Y (north-south axis in [0, 1]) to wgs84 latitude
1326
+ */
1327
+ declare function mercatorYToLatitude(y: number): number;
1328
+ /**
1329
+ * Converts a web Mercator position where north-west is [0, 0] and south-east is [1, 1] into a wgs84
1330
+ */
1331
+ declare function mercatorToWgs84(position: Position): Position;
1332
+ /**
1333
+ * Gives the distance in meters between two positions using the Haversine Formula.
1334
+ */
1335
+ declare function haversineDistanceWgs84(from: Position, to: Position): number;
1336
+ /**
1337
+ * Compute the cumulated distance for each position of an array of positions.
1338
+ * For I positions, there are I-1 distance, hence the distance at i corresponds
1339
+ * to the distance from the (i-1)th position to ith
1340
+ */
1341
+ declare function haversineCumulatedDistanceWgs84(positions: Position[]): number[];
1342
+ /**
1343
+ * Returns a position that has longitude in [-180, 180]
1344
+ */
1345
+ declare function wrapWgs84(position: Position): Position;
1346
+ declare function circumferenceAtLatitude(latitude: number): number;
1347
+ /**
1348
+ * From a given mercator coordinate and a zoom level, computes the tile index
1349
+ */
1350
+ declare function mercatorToTileIndex(
1351
+ /**
1352
+ * Mercator coordinates (north-west is [0, 0], sourth-east is [1, 1])
1353
+ */
1354
+ position: Position,
1355
+ /**
1356
+ * Zoom level
1357
+ */
1358
+ zoom: number,
1359
+ /**
1360
+ * Returns integer tile indices if `true` or floating-point values if `false`
1361
+ */
1362
+ strict?: boolean): Position;
1363
+ /**
1364
+ * From a given wgs84 coordinate and a zoom level, computes the tile index
1365
+ */
1366
+ declare function wgs84ToTileIndex(
1367
+ /**
1368
+ * Wgs84 coordinates
1369
+ */
1370
+ position: Position,
1371
+ /**
1372
+ * Zoom level
1373
+ */
1374
+ zoom: number,
1375
+ /**
1376
+ * Returns integer tile indices if `true` or floating-point values if `false`
1377
+ */
1378
+ strict?: boolean): Position;
1379
+ /**
1380
+ * Converts a degree angle into a radian angle
1381
+ */
1382
+ declare function toRadians(degrees: number): number;
1383
+ /**
1384
+ * Converts a radian angle to a degree angle
1385
+ */
1386
+ declare function toDegrees(radians: number): number;
1387
+ /**
1388
+ * Compute an intermediate point between two reference points using the Haversine formula.
1389
+ * If ratio is `0`, the returned position is pos1.
1390
+ * If ratio is `1`, the returned position is pos2.
1391
+ * If ratio is `0.5`, the returned position is halfway pos1 pos2 in distance.
1392
+ */
1393
+ declare function haversineIntermediateWgs84(pos1: Position, pos2: Position, ratio: number): Position;
1394
+ declare const math: {
1395
+ EARTH_RADIUS: number;
1396
+ EARTH_CIRCUMFERENCE: number;
1397
+ longitudeToMercatorX: typeof longitudeToMercatorX;
1398
+ latitudeToMercatorY: typeof latitudeToMercatorY;
1399
+ wgs84ToMercator: typeof wgs84ToMercator;
1400
+ mercatorXToLongitude: typeof mercatorXToLongitude;
1401
+ mercatorYToLatitude: typeof mercatorYToLatitude;
1402
+ mercatorToWgs84: typeof mercatorToWgs84;
1403
+ haversineDistanceWgs84: typeof haversineDistanceWgs84;
1404
+ wrapWgs84: typeof wrapWgs84;
1405
+ circumferenceAtLatitude: typeof circumferenceAtLatitude;
1406
+ mercatorToTileIndex: typeof mercatorToTileIndex;
1407
+ wgs84ToTileIndex: typeof wgs84ToTileIndex;
1408
+ toRadians: typeof toRadians;
1409
+ toDegrees: typeof toDegrees;
1410
+ haversineIntermediateWgs84: typeof haversineIntermediateWgs84;
1411
+ haversineCumulatedDistanceWgs84: typeof haversineCumulatedDistanceWgs84;
1412
+ };
1413
+
1414
+ type ElevationAtOptions = {
1415
+ /**
1416
+ * Custom MapTiler Cloud API key to use instead of the one in global `config`
1417
+ */
1418
+ apiKey?: string;
1419
+ /**
1420
+ * Zoom level to use for the terrain RGB tileset.
1421
+ * If not provided, the highest zoom level will be used
1422
+ */
1423
+ zoom?: number;
1424
+ };
1425
+ /**
1426
+ * Options for batch elevation lookup
1427
+ */
1428
+ type ElevationBatchOptions = ElevationAtOptions & {
1429
+ /**
1430
+ * If provided, a median kernel of the given size will smooth the elevation
1431
+ * to reduce very small local variations
1432
+ */
1433
+ smoothingKernelSize?: number;
1434
+ };
1435
+ /**
1436
+ * Get the elevation at a given position.
1437
+ * The returned position is of form [longitude, latitude, altitude]
1438
+ */
1439
+ declare function at(
1440
+ /**
1441
+ * Wgs84 position as [longitude, latitude]
1442
+ */
1443
+ position: Position,
1444
+ /**
1445
+ * Options
1446
+ */
1447
+ options?: ElevationAtOptions): Promise<Position>;
1448
+ /**
1449
+ * Perform a batch elevation request
1450
+ */
1451
+ declare function batch(
1452
+ /**
1453
+ * Wgs84 positions as [[lng0, lat0], [lng1, lat1], [lng2, lat2], ...]
1454
+ */
1455
+ positions: Position[],
1456
+ /**
1457
+ * Options
1458
+ */
1459
+ options?: ElevationBatchOptions): Promise<Position[]>;
1460
+ /**
1461
+ * Creates a clone of a GeoJSON LineString (deep copy with structuredClone) that contains the computed elevation
1462
+ * as the third element of each position array ([lng, lat, alt])
1463
+ */
1464
+ declare function fromLineString(
1465
+ /**
1466
+ * A GeoJSON LineStriung feature
1467
+ */
1468
+ ls: LineString,
1469
+ /**
1470
+ * Options
1471
+ */
1472
+ options?: ElevationBatchOptions): Promise<LineString>;
1473
+ /**
1474
+ * Creates a clone of a MultiLineString (deep copy with structuredClone) that contains the computed elevation
1475
+ * as the third element of each position array ([lng, lat, alt])
1476
+ */
1477
+ declare function fromMultiLineString(
1478
+ /**
1479
+ * A GeoJSON LineStriung feature
1480
+ */
1481
+ ls: MultiLineString,
1482
+ /**
1483
+ * Options
1484
+ */
1485
+ options?: ElevationBatchOptions): Promise<MultiLineString>;
1486
+ declare const elevation: {
1487
+ at: typeof at;
1488
+ batch: typeof batch;
1489
+ fromLineString: typeof fromLineString;
1490
+ fromMultiLineString: typeof fromMultiLineString;
1491
+ };
1492
+
1493
+ /**
1494
+ * From a generic GeoJSON object extract thepossibly nested LineString and MultiLineString features
1495
+ * it contains. The result is a flat array made of LineString and MultiLineString.
1496
+ */
1497
+ declare function extractLineStrings(geoJson: GeoJsonObject): Array<LineString | MultiLineString>;
1498
+ /**
1499
+ * Simplify a path made of a list of GeoJSON Positions, with a tolerance.
1500
+ */
1501
+ declare function simplify(points: Array<Position>, tolerance: number): Array<Position>;
1502
+ declare const misc: {
1503
+ extractLineStrings: typeof extractLineStrings;
1504
+ simplify: typeof simplify;
1505
+ };
1506
+
1507
+ export { type AutomaticStaticMapOptions, type BoundedStaticMapOptions, type BufferToPixelDataFunction, type ByIdGeocodingOptions, type CenteredStaticMapOptions, ClientConfig, type CommonForwardAndReverseGeocodingOptions, type CoordinateExport, type CoordinateGrid, type CoordinateId, type CoordinateSearch, type CoordinateSearchResult, type CoordinateTransformResult, type CoordinateTransformation, type Coordinates, type CoordinatesSearchOptions, type CoordinatesTransformOptions, type DefaultTransformation, type ElevationAtOptions, type ElevationBatchOptions, type FeatureHierarchy, type FetchFunction, type GeocodingFeature, type GeocodingOptions, type GeocodingSearchResult, type GeolocationInfoOptions, type GeolocationResult, type GetDataOptions, LanguageGeocoding, type LanguageGeocodingOptions, type LanguageGeocodingString, MapStyle, type MapStylePreset, type MapStyleType, MapStyleVariant, type PixelData, ReferenceMapStyle, type ReverseGeocodingOptions, ServiceError, type StaticMapBaseOptions, type StaticMapMarker, type TileJSON, type XYZ, bufferToPixelDataBrowser, circumferenceAtLatitude, config, coordinates, data, elevation, expandMapStyle, geocoding, geolocation, getAutoLanguageGeocoding, getBufferToPixelDataParser, getTileCache, mapStylePresetList, math, misc, staticMaps, styleToStyle };
@@ -1 +1 @@
1
- function F(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class N{constructor(){this._apiKey="",this._fetch=F()}set apiKey(e){this._apiKey=e}get apiKey(){return this._apiKey}set fetch(e){this._fetch=e}get fetch(){return this._fetch}}const y=new N,L={AUTO:"auto",ALBANIAN:"sq",ARABIC:"ar",ARMENIAN:"hy",AZERBAIJANI:"az",BELORUSSIAN:"be",BOSNIAN:"bs",BRETON:"br",BULGARIAN:"bg",CATALAN:"ca",CHINESE:"zh",CROATIAN:"hr",CZECH:"cs",DANISH:"da",DUTCH:"nl",ENGLISH:"en",ESPERANTO:"eo",ESTONIAN:"et",FINNISH:"fi",FRENCH:"fr",FRISIAN:"fy",GEORGIAN:"ka",GERMAN:"de",GREEK:"el",HEBREW:"he",HUNGARIAN:"hu",ICELANDIC:"is",IRISH:"ga",ITALIAN:"it",JAPANESE:"ja",KANNADA:"kn",KAZAKH:"kk",KOREAN:"ko",ROMAN_LATIN:"la",LATVIAN:"lv",LITHUANIAN:"lt",LUXEMBOURGISH:"lb",MACEDONIAN:"mk",MALTESE:"mt",NORWEGIAN:"no",POLISH:"pl",PORTUGUESE:"pt",ROMANIAN:"ro",ROMANSH:"rm",RUSSIAN:"ru",SCOTTISH_GAELIC:"gd",SERBIAN_CYRILLIC:"sr",SLOVAK:"sk",SLOVENE:"sl",SPANISH:"es",SWEDISH:"sv",THAI:"th",TURKISH:"tr",UKRAINIAN:"uk",WELSH:"cy"},B=new Set(Object.values(L));function M(){if(typeof navigator>"u")return Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];const n=Array.from(new Set(navigator.languages.map(e=>e.split("-")[0]))).filter(e=>B.has(e));return n.length?n[0]:L.ENGLISH}var W=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});function A(n){return W(this,arguments,function*(e,t={}){if(y.fetch===null)throw new Error("The fetch function was not found. If on NodeJS < 18 please specify the fetch function with config.fetch");if(new URL(e).searchParams.get("key").trim()==="")throw new Error("The MapTiler Cloud API key is missing. Set it in `config.apiKey` or get one for free at https://maptiler.com");return y.fetch(e,t)})}const d={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(d);class v extends Error{constructor(e,t=""){super(`Call to enpoint ${e.url} failed with the status code ${e.status}. ${t}`),this.res=e}}var R=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});const I={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function b(n,e){if(e.language==null)return;const t=Array.from(new Set((Array.isArray(e.language)?e.language:[e.language]).map(r=>r===L.AUTO?M():r))).join(",");n.set("language",t)}function C(n,e){var t;n.set("key",(t=e.apiKey)!=null?t:y.apiKey),e.limit!=null&&n.set("limit",String(e.limit)),e.types!=null&&n.set("types",e.types.join(",")),b(n,e)}function K(n,e){C(n,e),e.bbox!=null&&n.set("bbox",e.bbox.join(",")),e.proximity!=null&&n.set("proximity",e.proximity.join(",")),e.country!=null&&n.set("country",e.country.join(",")),e.fuzzyMatch!=null&&n.set("fuzzyMatch",e.fuzzyMatch?"true":"false"),e.autocomplete!=null&&n.set("autocomplete",e.autocomplete?"true":"false")}function z(n){return R(this,arguments,function*(e,t={}){var r;if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const i=new URL(`geocoding/${encodeURIComponent(e)}.json`,d.maptilerApiURL),{searchParams:s}=i;K(s,t);const a=i.toString(),c=yield A(a);if(!c.ok)throw new v(c,(r=I[c.status])!=null?r:"");return yield c.json()})}function _(n){return R(this,arguments,function*(e,t={}){var r;if(!Array.isArray(e)||e.length<2)throw new Error("The position must be an array of form [lng, lat].");const i=new URL(`geocoding/${e[0]},${e[1]}.json`,d.maptilerApiURL);C(i.searchParams,t);const s=i.toString(),a=yield A(s);if(!a.ok)throw new v(a,(r=I[a.status])!=null?r:"");return yield a.json()})}function q(n){return R(this,arguments,function*(e,t={}){var r;const i=new URL(`geocoding/${e}.json`,d.maptilerApiURL);b(i.searchParams,t);const s=i.toString(),a=yield A(s);if(!a.ok)throw new v(a,(r=I[a.status])!=null?r:"");return yield a.json()})}function Y(n){return R(this,arguments,function*(e,t={}){var r;if(!e.length)return[];const i=e.map(g=>encodeURIComponent(g)).join(";"),s=new URL(`geocoding/${i}.json`,d.maptilerApiURL),{searchParams:a}=s;K(a,t);const c=s.toString(),o=yield A(c);if(!o.ok)throw new v(o,(r=I[o.status])!=null?r:"");const l=yield o.json();return e.length===1?[l]:l})}const Z={forward:z,reverse:_,byId:q,batch:Y,language:L};var J=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});const O={403:"Key is missing, invalid or restricted"};function Q(){return J(this,arguments,function*(n={}){var e;const t=new URL("geolocation/ip.json",d.maptilerApiURL);t.searchParams.set("key",(e=n.apiKey)!=null?e:y.apiKey);const r=t.toString(),i=yield A(r);if(!i.ok)throw new v(i,i.status in O?O[i.status]:"");return yield i.json()})}const X={info:Q};var j=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});const S={403:"Key is missing, invalid or restricted"};function ee(n){return j(this,arguments,function*(e,t={}){var r;if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const i=new URL(`coordinates/search/${e}.json`,d.maptilerApiURL);i.searchParams.set("key",(r=t.apiKey)!=null?r:y.apiKey),"limit"in t&&i.searchParams.set("limit",t.limit.toString()),"transformations"in t&&i.searchParams.set("transformations",t.transformations.toString()),"exports"in t&&i.searchParams.set("exports",t.exports.toString());const s=i.toString(),a=yield A(s);if(!a.ok)throw new v(a,a.status in S?S[a.status]:"");return yield a.json()})}function te(n){return j(this,arguments,function*(e,t={}){var r;const i=(Array.isArray(e[0])?e:[e]).map(o=>`${o[0]},${o[1]}`).join(";"),s=new URL(`coordinates/transform/${i}.json`,d.maptilerApiURL);s.searchParams.set("key",(r=t.apiKey)!=null?r:y.apiKey),"sourceCrs"in t&&s.searchParams.set("s_srs",t.sourceCrs.toString()),"targetCrs"in t&&s.searchParams.set("t_srs",t.targetCrs.toString()),"operations"in t&&s.searchParams.set("ops",(Array.isArray(t.operations)?t.operations:[t.operations]).join("|"));const a=s.toString(),c=yield A(a);if(!c.ok)throw new v(c,c.status in S?S[c.status]:"");return yield c.json()})}const ne={search:ee,transform:te};var re=(n,e,t)=>new Promise((r,i)=>{var s=o=>{try{c(t.next(o))}catch(l){i(l)}},a=o=>{try{c(t.throw(o))}catch(l){i(l)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((t=t.apply(n,e)).next())});const H={403:"Key is missing, invalid or restricted"};function ie(n){return re(this,arguments,function*(e,t={}){var r;if(typeof e!="string"||e.trim().length===0)throw new Error("The data ID must be a non-empty string");const i=new URL(`data/${encodeURIComponent(e)}/features.json`,d.maptilerApiURL);i.searchParams.set("key",(r=t.apiKey)!=null?r:y.apiKey);const s=i.toString(),a=yield A(s);if(!a.ok)throw new v(a,a.status in H?H[a.status]:"");return yield a.json()})}const ae={get:ie};function x(n){const e=/^maptiler:\/\/(.*)/;let t;const r=n.trim();let i;return r.startsWith("http://")||r.startsWith("https://")?i=r:(t=e.exec(r))!==null?i=`https://api.maptiler.com/maps/${t[1]}/style.json`:i=`https://api.maptiler.com/maps/${r}/style.json`,i}class D{constructor(e,t,r,i,s,a){this.name=e,this.variantType=t,this.id=r,this.referenceStyle=i,this.description=s,this.imageURL=a}getName(){return this.name}getFullName(){return`${this.referenceStyle.getName()} ${this.name}`}getType(){return this.variantType}getId(){return this.id}getDescription(){return this.description}getReferenceStyle(){return this.referenceStyle}hasVariant(e){return this.referenceStyle.hasVariant(e)}getVariant(e){return this.referenceStyle.getVariant(e)}getVariants(){return this.referenceStyle.getVariants().filter(e=>e!==this)}getImageURL(){return this.imageURL}getExpandedStyleURL(){return x(this.getId())}}class k{constructor(e,t){this.name=e,this.id=t,this.variants={},this.orderedVariants=[]}getName(){return this.name}getId(){return this.id}addVariant(e){this.variants[e.getType()]=e,this.orderedVariants.push(e)}hasVariant(e){return e in this.variants}getVariant(e){return e in this.variants?this.variants[e]:this.orderedVariants[0]}getVariants(){return Object.values(this.variants)}getDefaultVariant(){return this.orderedVariants[0]}}const T=[{referenceStyleID:"STREETS",name:"Streets",description:"",variants:[{id:"streets-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"streets-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"streets-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"streets-v2-night",name:"Night",variantType:"NIGHT",description:"",imageURL:""},{id:"streets-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OUTDOOR",name:"Outdoor",description:"",variants:[{id:"outdoor-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"outdoor-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"WINTER",name:"Winter",description:"",variants:[{id:"winter-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"winter-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"SATELLITE",name:"Satellite",description:"",variants:[{id:"satellite",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"HYBRID",name:"Hybrid",description:"",variants:[{id:"hybrid",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"BASIC",name:"Basic",description:"",variants:[{id:"basic-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"basic-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"basic-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"BRIGHT",name:"Bright",description:"",variants:[{id:"bright-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"bright-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"bright-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"bright-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OPENSTREETMAP",name:"OpenStreetMap",description:"",variants:[{id:"openstreetmap",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"TOPO",name:"Topo",description:"",variants:[{id:"topo-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"topo-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"topo-v2-shiny",name:"Shiny",variantType:"SHINY",description:"",imageURL:""},{id:"topo-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""},{id:"topo-v2-topographique",name:"Topographique",variantType:"TOPOGRAPHIQUE",description:"",imageURL:""}]},{referenceStyleID:"VOYAGER",name:"Voyager",description:"",variants:[{id:"voyager-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"voyager-v2-darkmatter",name:"Darkmatter",variantType:"DARK",description:"",imageURL:""},{id:"voyager-v2-positron",name:"Positron",variantType:"LIGHT",description:"",imageURL:""},{id:"voyager-v2-vintage",name:"Vintage",variantType:"VINTAGE",description:"",imageURL:""}]},{referenceStyleID:"TONER",name:"Toner",description:"",variants:[{id:"toner-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"toner-v2-background",name:"Background",variantType:"BACKGROUND",description:"",imageURL:""},{id:"toner-v2-lite",name:"Lite",variantType:"LITE",description:"",imageURL:""},{id:"toner-v2-lines",name:"Lines",variantType:"LINES",description:"",imageURL:""}]},{referenceStyleID:"DATAVIZ",name:"Dataviz",description:"",variants:[{id:"dataviz",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"dataviz-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"dataviz-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"BACKDROP",name:"Backdrop",description:"",variants:[{id:"backdrop",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"backdrop-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"backdrop-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"OCEAN",name:"Ocean",description:"",variants:[{id:"ocean",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]}];function se(n){return new Proxy(n,{get(e,t,r){return e.hasVariant(t)?e.getVariant(t):t.toString().toUpperCase()===t?n.getDefaultVariant():Reflect.get(e,t,r)}})}function oe(){const n={};for(let e=0;e<T.length;e+=1){const t=T[e],r=se(new k(t.name,t.referenceStyleID));for(let i=0;i<t.variants.length;i+=1){const s=t.variants[i],a=new D(s.name,s.variantType,s.id,r,s.description,s.imageURL);r.addVariant(a)}n[t.referenceStyleID]=r}return n}function $(n){if(!n)return V[T[0].referenceStyleID].getDefaultVariant().getId();if(typeof n=="string"||n instanceof String)return n.trim().toLowerCase();if(n instanceof D)return n.getId();if(n instanceof k)return n.getDefaultVariant().getId()}const V=oe();function ce(n,e,t){let r=e[0],i=e[1],s=t[0]-r,a=t[1]-i;if(s!==0||a!==0){const c=((n[0]-r)*s+(n[1]-i)*a)/(s*s+a*a);c>1?(r=t[0],i=t[1]):c>0&&(r+=s*c,i+=a*c)}return s=n[0]-r,a=n[1]-i,s*s+a*a}function E(n,e,t,r,i){let s=r,a;for(let c=e+1;c<t;c++){const o=ce(n[c],n[e],n[t]);o>s&&(a=c,s=o)}s>r&&(a-e>1&&E(n,e,a,r,i),i.push(n[a]),t-a>1&&E(n,a,t,r,i))}function le(n,e){const t=n.length-1,r=[n[0]];return E(n,0,t,e,r),r.push(n[t]),r}function pe(n,e){if(n.length<=2)return n;const t=e!==void 0?e*e:1;return le(n,t)}function w(n,e=!0){let t=`${n[0]},${n[1]}`;return n.length===3&&e&&(t+=`,${n[2]}`),t}function P(n,e=3e3){let t=n.map(s=>s.join(",")).join("|"),r=5e-6;const i=1e-5;for(;t.length>e;)t=pe(n,r).map(s=>`${s[0]},${s[1]}`).join("|"),r+=i;return t}function me(n,e,t={}){var r,i,s,a,c;const o=$(t.style),l=t.hiDPI?"@2x":"",g=(r=t.format)!=null?r:"png";let u=~~((i=t.width)!=null?i:1024),m=~~((s=t.height)!=null?s:1024);t.hiDPI&&(u=~~(u/2),m=~~(m/2));const p=new URL(`maps/${encodeURIComponent(o)}/static/${n[0]},${n[1]},${e}/${u}x${m}${l}.${g}`,d.maptilerApiURL);if("attribution"in t&&p.searchParams.set("attribution",t.attribution.toString()),"markers"in t){let h="";const f="markerIcon"in t;f&&(h+=`icon:${t.markerIcon}|`),f&&"markerAnchor"in t&&(h+=`anchor:${t.markerAnchor}|`),f&&t.hiDPI&&(h+="scale:2|");const U=Array.isArray(t.markers[0])?t.markers:[t.markers];h+=U.map(G=>w(G,!f)).join("|"),p.searchParams.set("markers",h)}if("path"in t){let h="";if(h+=`fill:${(a=t.pathFillColor)!=null?a:"none"}|`,"pathStrokeColor"in t&&(h+=`stroke:${t.pathStrokeColor}|`),"pathWidth"in t){const f=t.pathWidth/(t.hiDPI?2:1);h+=`width:${f.toString()}|`}h+=P(t.path),p.searchParams.set("path",h)}return p.searchParams.set("key",(c=t.apiKey)!=null?c:y.apiKey),p.toString()}function he(n,e={}){var t,r,i,s,a;const c=$(e.style),o=e.hiDPI?"@2x":"",l=(t=e.format)!=null?t:"png";let g=~~((r=e.width)!=null?r:1024),u=~~((i=e.height)!=null?i:1024);e.hiDPI&&(g=~~(g/2),u=~~(u/2));const m=new URL(`maps/${encodeURIComponent(c)}/static/${n[0]},${n[1]},${n[2]},${n[3]}/${g}x${u}${o}.${l}`,d.maptilerApiURL);if("attribution"in e&&m.searchParams.set("attribution",e.attribution.toString()),"padding"in e&&m.searchParams.set("padding",e.padding.toString()),"markers"in e){let p="";const h="markerIcon"in e;h&&(p+=`icon:${e.markerIcon}|`),h&&"markerAnchor"in e&&(p+=`anchor:${e.markerAnchor}|`),h&&e.hiDPI&&(p+="scale:2|");const f=Array.isArray(e.markers[0])?e.markers:[e.markers];p+=f.map(U=>w(U,!h)).join("|"),m.searchParams.set("markers",p)}if("path"in e){let p="";if(p+=`fill:${(s=e.pathFillColor)!=null?s:"none"}|`,"pathStrokeColor"in e&&(p+=`stroke:${e.pathStrokeColor}|`),"pathWidth"in e){const h=e.pathWidth/(e.hiDPI?2:1);p+=`width:${h.toString()}|`}p+=P(e.path),m.searchParams.set("path",p)}return m.searchParams.set("key",(a=e.apiKey)!=null?a:y.apiKey),m.toString()}function ue(n={}){var e,t,r,i,s;if(!("markers"in n)&&!("path"in n))throw new Error("Automatic static maps require markers and/or path to be created.");const a=$(n.style),c=n.hiDPI?"@2x":"",o=(e=n.format)!=null?e:"png";let l=~~((t=n.width)!=null?t:1024),g=~~((r=n.height)!=null?r:1024);n.hiDPI&&(l=~~(l/2),g=~~(g/2));const u=new URL(`maps/${encodeURIComponent(a)}/static/auto/${l}x${g}${c}.${o}`,d.maptilerApiURL);if("attribution"in n&&u.searchParams.set("attribution",n.attribution.toString()),"padding"in n&&u.searchParams.set("padding",n.padding.toString()),"markers"in n){let m="";const p="markerIcon"in n;p&&(m+=`icon:${n.markerIcon}|`),p&&"markerAnchor"in n&&(m+=`anchor:${n.markerAnchor}|`),p&&n.hiDPI&&(m+="scale:2|");const h=Array.isArray(n.markers[0])?n.markers:[n.markers];m+=h.map(f=>w(f,!p)).join("|"),u.searchParams.set("markers",m)}if("path"in n){let m="";if(m+=`fill:${(i=n.pathFillColor)!=null?i:"none"}|`,"pathStrokeColor"in n&&(m+=`stroke:${n.pathStrokeColor}|`),"pathWidth"in n){const p=n.pathWidth/(n.hiDPI?2:1);m+=`width:${p.toString()}|`}m+=P(n.path),u.searchParams.set("path",m)}return u.searchParams.set("key",(s=n.apiKey)!=null?s:y.apiKey),u.toString()}const de={centered:me,bounded:he,automatic:ue};export{N as ClientConfig,L as LanguageGeocoding,V as MapStyle,D as MapStyleVariant,k as ReferenceMapStyle,v as ServiceError,y as config,ne as coordinates,ae as data,x as expandMapStyle,Z as geocoding,X as geolocation,T as mapStylePresetList,de as staticMaps};
1
+ import At from"quick-lru";function Lt(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class q{constructor(){this._apiKey="",this._fetch=Lt(),this.tileCacheSize=200}set apiKey(e){this._apiKey=e}get apiKey(){return this._apiKey}set fetch(e){this._fetch=e}get fetch(){return this._fetch}}const m=new q,k={AUTO:"auto",ALBANIAN:"sq",ARABIC:"ar",ARMENIAN:"hy",AZERBAIJANI:"az",BELORUSSIAN:"be",BOSNIAN:"bs",BRETON:"br",BULGARIAN:"bg",CATALAN:"ca",CHINESE:"zh",CROATIAN:"hr",CZECH:"cs",DANISH:"da",DUTCH:"nl",ENGLISH:"en",ESPERANTO:"eo",ESTONIAN:"et",FINNISH:"fi",FRENCH:"fr",FRISIAN:"fy",GEORGIAN:"ka",GERMAN:"de",GREEK:"el",HEBREW:"he",HUNGARIAN:"hu",ICELANDIC:"is",IRISH:"ga",ITALIAN:"it",JAPANESE:"ja",KANNADA:"kn",KAZAKH:"kk",KOREAN:"ko",ROMAN_LATIN:"la",LATVIAN:"lv",LITHUANIAN:"lt",LUXEMBOURGISH:"lb",MACEDONIAN:"mk",MALTESE:"mt",NORWEGIAN:"no",POLISH:"pl",PORTUGUESE:"pt",ROMANIAN:"ro",ROMANSH:"rm",RUSSIAN:"ru",SCOTTISH_GAELIC:"gd",SERBIAN_CYRILLIC:"sr",SLOVAK:"sk",SLOVENE:"sl",SPANISH:"es",SWEDISH:"sv",THAI:"th",TURKISH:"tr",UKRAINIAN:"uk",WELSH:"cy"},Tt=new Set(Object.values(k));function Y(){if(typeof navigator>"u")return Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];const t=Array.from(new Set(navigator.languages.map(e=>e.split("-")[0]))).filter(e=>Tt.has(e));return t.length?t[0]:k.ENGLISH}async function L(t,e={}){if(m.fetch===null)throw new Error("The fetch function was not found. If on NodeJS < 18 please specify the fetch function with config.fetch");if(new URL(t).searchParams.get("key").trim()==="")throw new Error("The MapTiler Cloud API key is missing. Set it in `config.apiKey` or get one for free at https://maptiler.com");return m.fetch(t,e)}const y={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(y);class A extends Error{constructor(e,n=""){super(`Call to enpoint ${e.url} failed with the status code ${e.status}. ${n}`),this.res=e}}const E={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function J(t,e){const{language:n}=e;if(n==null)return;const i=Array.from(new Set((Array.isArray(n)?n:[n]).map(a=>a===k.AUTO?Y():a))).join(",");t.set("language",i)}function Z(t,e){const{apiKey:n,limit:i,types:a,excludeTypes:r}=e;t.set("key",n??m.apiKey),i!=null&&t.set("limit",String(i)),a!=null&&t.set("types",a.join(",")),r!=null&&t.set("excludeTypes",String(r)),J(t,e)}function X(t,e){Z(t,e);const{bbox:n,proximity:i,country:a,fuzzyMatch:r,autocomplete:o}=e;n!=null&&t.set("bbox",n.join(",")),i!=null&&t.set("proximity",i==="ip"?i:i.join(",")),a!=null&&t.set("country",a.join(",")),r!=null&&t.set("fuzzyMatch",r?"true":"false"),o!=null&&t.set("autocomplete",o?"true":"false")}async function It(t,e={}){if(typeof t!="string"||t.trim().length===0)throw new Error("The query must be a non-empty string");const n=new URL(`geocoding/${encodeURIComponent(t)}.json`,y.maptilerApiURL),{searchParams:i}=n;X(i,e);const a=n.toString(),r=await L(a);if(!r.ok)throw new A(r,E[r.status]??"");return await r.json()}async function wt(t,e={}){if(!Array.isArray(t)||t.length<2)throw new Error("The position must be an array of form [lng, lat].");const n=new URL(`geocoding/${t[0]},${t[1]}.json`,y.maptilerApiURL);Z(n.searchParams,e);const i=n.toString(),a=await L(i);if(!a.ok)throw new A(a,E[a.status]??"");return await a.json()}async function Rt(t,e={}){const n=new URL(`geocoding/${t}.json`,y.maptilerApiURL);n.searchParams.set("key",e.apiKey??m.apiKey),J(n.searchParams,e);const i=n.toString(),a=await L(i);if(!a.ok)throw new A(a,E[a.status]??"");return await a.json()}async function vt(t,e={}){if(!t.length)return[];const n=t.map(c=>encodeURIComponent(c)).join(";"),i=new URL(`geocoding/${n}.json`,y.maptilerApiURL),{searchParams:a}=i;X(a,e);const r=i.toString(),o=await L(r);if(!o.ok)throw new A(o,E[o.status]??"");const s=await o.json();return t.length===1?[s]:s}const Ut={forward:It,reverse:wt,byId:Rt,batch:vt,language:k},Q={403:"Key is missing, invalid or restricted"};async function Dt(t={}){const e=new URL("geolocation/ip.json",y.maptilerApiURL);e.searchParams.set("key",t.apiKey??m.apiKey);const n=e.toString(),i=await L(n);if(!i.ok)throw new A(i,i.status in Q?Q[i.status]:"");return await i.json()}const kt={info:Dt},P={403:"Key is missing, invalid or restricted"};async function $t(t,e={}){if(typeof t!="string"||t.trim().length===0)throw new Error("The query must be a non-empty string");const n=new URL(`coordinates/search/${t}.json`,y.maptilerApiURL);n.searchParams.set("key",e.apiKey??m.apiKey),"limit"in e&&n.searchParams.set("limit",e.limit.toString()),"transformations"in e&&n.searchParams.set("transformations",e.transformations.toString()),"exports"in e&&n.searchParams.set("exports",e.exports.toString());const i=n.toString(),a=await L(i);if(!a.ok)throw new A(a,a.status in P?P[a.status]:"");return await a.json()}async function Et(t,e={}){const n=(Array.isArray(t[0])?t:[t]).map(o=>`${o[0]},${o[1]}`).join(";"),i=new URL(`coordinates/transform/${n}.json`,y.maptilerApiURL);i.searchParams.set("key",e.apiKey??m.apiKey),"sourceCrs"in e&&i.searchParams.set("s_srs",e.sourceCrs.toString()),"targetCrs"in e&&i.searchParams.set("t_srs",e.targetCrs.toString()),"operations"in e&&i.searchParams.set("ops",(Array.isArray(e.operations)?e.operations:[e.operations]).join("|"));const a=i.toString(),r=await L(a);if(!r.ok)throw new A(r,r.status in P?P[r.status]:"");return await r.json()}const Pt={search:$t,transform:Et},tt={403:"Key is missing, invalid or restricted"};async function Nt(t,e={}){if(typeof t!="string"||t.trim().length===0)throw new Error("The data ID must be a non-empty string");const n=new URL(`data/${encodeURIComponent(t)}/features.json`,y.maptilerApiURL);n.searchParams.set("key",e.apiKey??m.apiKey);const i=n.toString(),a=await L(i);if(!a.ok)throw new A(a,a.status in tt?tt[a.status]:"");return await a.json()}const Mt={get:Nt};function et(t){const e=/^maptiler:\/\/(.*)/;let n;const i=t.trim();let a;return i.startsWith("http://")||i.startsWith("https://")?a=i:(n=e.exec(i))!==null?a=`https://api.maptiler.com/maps/${n[1]}/style.json`:a=`https://api.maptiler.com/maps/${i}/style.json`,a}class C{constructor(e,n,i,a,r,o){this.name=e,this.variantType=n,this.id=i,this.referenceStyle=a,this.description=r,this.imageURL=o}getName(){return this.name}getFullName(){return`${this.referenceStyle.getName()} ${this.name}`}getType(){return this.variantType}getId(){return this.id}getDescription(){return this.description}getReferenceStyle(){return this.referenceStyle}hasVariant(e){return this.referenceStyle.hasVariant(e)}getVariant(e){return this.referenceStyle.getVariant(e)}getVariants(){return this.referenceStyle.getVariants().filter(e=>e!==this)}getImageURL(){return this.imageURL}getExpandedStyleURL(){return et(this.getId())}}class K{constructor(e,n){this.name=e,this.id=n,this.variants={},this.orderedVariants=[]}getName(){return this.name}getId(){return this.id}addVariant(e){this.variants[e.getType()]=e,this.orderedVariants.push(e)}hasVariant(e){return e in this.variants}getVariant(e){return e in this.variants?this.variants[e]:this.orderedVariants[0]}getVariants(){return Object.values(this.variants)}getDefaultVariant(){return this.orderedVariants[0]}}const N=[{referenceStyleID:"STREETS",name:"Streets",description:"",variants:[{id:"streets-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"streets-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"streets-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"streets-v2-night",name:"Night",variantType:"NIGHT",description:"",imageURL:""},{id:"streets-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OUTDOOR",name:"Outdoor",description:"",variants:[{id:"outdoor-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"outdoor-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"WINTER",name:"Winter",description:"",variants:[{id:"winter-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"winter-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"SATELLITE",name:"Satellite",description:"",variants:[{id:"satellite",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"HYBRID",name:"Hybrid",description:"",variants:[{id:"hybrid",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"BASIC",name:"Basic",description:"",variants:[{id:"basic-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"basic-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"basic-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"BRIGHT",name:"Bright",description:"",variants:[{id:"bright-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"bright-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"bright-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"bright-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OPENSTREETMAP",name:"OpenStreetMap",description:"",variants:[{id:"openstreetmap",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"TOPO",name:"Topo",description:"",variants:[{id:"topo-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"topo-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"topo-v2-shiny",name:"Shiny",variantType:"SHINY",description:"",imageURL:""},{id:"topo-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""},{id:"topo-v2-topographique",name:"Topographique",variantType:"TOPOGRAPHIQUE",description:"",imageURL:""}]},{referenceStyleID:"VOYAGER",name:"Voyager",description:"",variants:[{id:"voyager-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"voyager-v2-darkmatter",name:"Darkmatter",variantType:"DARK",description:"",imageURL:""},{id:"voyager-v2-positron",name:"Positron",variantType:"LIGHT",description:"",imageURL:""},{id:"voyager-v2-vintage",name:"Vintage",variantType:"VINTAGE",description:"",imageURL:""}]},{referenceStyleID:"TONER",name:"Toner",description:"",variants:[{id:"toner-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"toner-v2-background",name:"Background",variantType:"BACKGROUND",description:"",imageURL:""},{id:"toner-v2-lite",name:"Lite",variantType:"LITE",description:"",imageURL:""},{id:"toner-v2-lines",name:"Lines",variantType:"LINES",description:"",imageURL:""}]},{referenceStyleID:"DATAVIZ",name:"Dataviz",description:"",variants:[{id:"dataviz",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"dataviz-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"dataviz-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"BACKDROP",name:"Backdrop",description:"",variants:[{id:"backdrop",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"backdrop-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"backdrop-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"OCEAN",name:"Ocean",description:"",variants:[{id:"ocean",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]}];function bt(t){return new Proxy(t,{get(e,n,i){return e.hasVariant(n)?e.getVariant(n):n.toString().toUpperCase()===n?t.getDefaultVariant():Reflect.get(e,n,i)}})}function Ct(){const t={};for(let e=0;e<N.length;e+=1){const n=N[e],i=bt(new K(n.name,n.referenceStyleID));for(let a=0;a<n.variants.length;a+=1){const r=n.variants[a],o=new C(r.name,r.variantType,r.id,i,r.description,r.imageURL);i.addVariant(o)}t[n.referenceStyleID]=i}return t}function M(t){if(!t)return nt[N[0].referenceStyleID].getDefaultVariant().getId();if(typeof t=="string"||t instanceof String)return t.trim().toLowerCase();if(t instanceof C)return t.getId();if(t instanceof K)return t.getDefaultVariant().getId()}const nt=Ct();function Kt(t){const e=[];function n(r){(r.type==="LineString"||r.type==="MultiLineString")&&e.push(r)}function i(r){r.geometry&&n(r.geometry)}function a(r){for(const o of r.features)o.type==="Feature"?i(o):o.type==="FeatureCollection"&&a(o)}return t.type==="Feature"?i(t):t.type==="FeatureCollection"?a(t):n(t),e}function xt(t,e,n){let i=e[0],a=e[1],r=n[0]-i,o=n[1]-a;if(r!==0||o!==0){const s=((t[0]-i)*r+(t[1]-a)*o)/(r*r+o*o);s>1?(i=n[0],a=n[1]):s>0&&(i+=r*s,a+=o*s)}return r=t[0]-i,o=t[1]-a,r*r+o*o}function x(t,e,n,i,a){let r=i,o;for(let s=e+1;s<n;s++){const c=xt(t[s],t[e],t[n]);c>r&&(o=s,r=c)}r>i&&(o-e>1&&x(t,e,o,i,a),a.push(t[o]),n-o>1&&x(t,o,n,i,a))}function Ot(t,e){const n=t.length-1,i=[t[0]];return x(t,0,n,e,i),i.push(t[n]),i}function jt(t,e){if(t.length<=2)return t;const n=e!==void 0?e*e:1;return Ot(t,n)}const it={extractLineStrings:Kt,simplify:jt};function O(t,e=!0){let n=`${t[0]},${t[1]}`;return t.length===3&&e&&(n+=`,${t[2]}`),n}function j(t,e=3e3){let n=t.map(r=>r.join(",")).join("|"),i=5e-6;const a=1e-5;for(;n.length>e;)n=it.simplify(t,i).map(r=>`${r[0]},${r[1]}`).join("|"),i+=a;return n}function Ht(t,e,n={}){const i=M(n.style),a=n.hiDPI?"@2x":"",r=n.format??"png";let o=~~(n.width??1024),s=~~(n.height??1024);n.hiDPI&&(o=~~(o/2),s=~~(s/2));const c=new URL(`maps/${encodeURIComponent(i)}/static/${t[0]},${t[1]},${e}/${o}x${s}${a}.${r}`,y.maptilerApiURL);if("attribution"in n&&c.searchParams.set("attribution",n.attribution.toString()),"markers"in n){let h="";const l="markerIcon"in n;l&&(h+=`icon:${n.markerIcon}|`),l&&"markerAnchor"in n&&(h+=`anchor:${n.markerAnchor}|`),l&&n.hiDPI&&(h+="scale:2|");const S=Array.isArray(n.markers[0])?n.markers:[n.markers];h+=S.map(g=>O(g,!l)).join("|"),c.searchParams.set("markers",h)}if("path"in n){let h="";if(h+=`fill:${n.pathFillColor??"none"}|`,"pathStrokeColor"in n&&(h+=`stroke:${n.pathStrokeColor}|`),"pathWidth"in n){const l=n.pathWidth/(n.hiDPI?2:1);h+=`width:${l.toString()}|`}h+=j(n.path),c.searchParams.set("path",h)}return c.searchParams.set("key",n.apiKey??m.apiKey),c.toString()}function Vt(t,e={}){const n=M(e.style),i=e.hiDPI?"@2x":"",a=e.format??"png";let r=~~(e.width??1024),o=~~(e.height??1024);e.hiDPI&&(r=~~(r/2),o=~~(o/2));const s=new URL(`maps/${encodeURIComponent(n)}/static/${t[0]},${t[1]},${t[2]},${t[3]}/${r}x${o}${i}.${a}`,y.maptilerApiURL);if("attribution"in e&&s.searchParams.set("attribution",e.attribution.toString()),"padding"in e&&s.searchParams.set("padding",e.padding.toString()),"markers"in e){let c="";const h="markerIcon"in e;h&&(c+=`icon:${e.markerIcon}|`),h&&"markerAnchor"in e&&(c+=`anchor:${e.markerAnchor}|`),h&&e.hiDPI&&(c+="scale:2|");const l=Array.isArray(e.markers[0])?e.markers:[e.markers];c+=l.map(S=>O(S,!h)).join("|"),s.searchParams.set("markers",c)}if("path"in e){let c="";if(c+=`fill:${e.pathFillColor??"none"}|`,"pathStrokeColor"in e&&(c+=`stroke:${e.pathStrokeColor}|`),"pathWidth"in e){const h=e.pathWidth/(e.hiDPI?2:1);c+=`width:${h.toString()}|`}c+=j(e.path),s.searchParams.set("path",c)}return s.searchParams.set("key",e.apiKey??m.apiKey),s.toString()}function Ft(t={}){if(!("markers"in t)&&!("path"in t))throw new Error("Automatic static maps require markers and/or path to be created.");const e=M(t.style),n=t.hiDPI?"@2x":"",i=t.format??"png";let a=~~(t.width??1024),r=~~(t.height??1024);t.hiDPI&&(a=~~(a/2),r=~~(r/2));const o=new URL(`maps/${encodeURIComponent(e)}/static/auto/${a}x${r}${n}.${i}`,y.maptilerApiURL);if("attribution"in t&&o.searchParams.set("attribution",t.attribution.toString()),"padding"in t&&o.searchParams.set("padding",t.padding.toString()),"markers"in t){let s="";const c="markerIcon"in t;c&&(s+=`icon:${t.markerIcon}|`),c&&"markerAnchor"in t&&(s+=`anchor:${t.markerAnchor}|`),c&&t.hiDPI&&(s+="scale:2|");const h=Array.isArray(t.markers[0])?t.markers:[t.markers];s+=h.map(l=>O(l,!c)).join("|"),o.searchParams.set("markers",s)}if("path"in t){let s="";if(s+=`fill:${t.pathFillColor??"none"}|`,"pathStrokeColor"in t&&(s+=`stroke:${t.pathStrokeColor}|`),"pathWidth"in t){const c=t.pathWidth/(t.hiDPI?2:1);s+=`width:${c.toString()}|`}s+=j(t.path),o.searchParams.set("path",s)}return o.searchParams.set("key",t.apiKey??m.apiKey),o.toString()}const Gt={centered:Ht,bounded:Vt,automatic:Ft},b=63710088e-1,at=2*Math.PI*b;function rt(t){return(180+t)/360}function ot(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function st(t){const e=ht(t);return[rt(e[0]),ot(e[1])]}function ct(t){return t*360-180}function pt(t){const e=180-t*360;return 360/Math.PI*Math.atan(Math.exp(e*Math.PI/180))-90}function Bt(t){return[ct(t[0]),pt(t[1])]}function H(t,e){const n=Math.PI/180,i=t[1]*n,a=e[1]*n,r=Math.sin(i)*Math.sin(a)+Math.cos(i)*Math.cos(a)*Math.cos((e[0]-t[0])*n);return b*Math.acos(Math.min(r,1))}function _t(t){const e=Array(t.length);e[0]=0;const n=e.length;for(let i=1;i<n;i++)e[i]=H(t[i-1],t[i])+e[i-1];return e}function ht(t){const e=t[0],n=t[1],i=360,a=((e+180)%i+i)%i-180;return[a===-180?180:a,n]}function lt(t){return at*Math.cos(t*Math.PI/180)}function mt(t,e,n=!0){const i=2**e,a=[t[0]*i,t[1]*i];return n?[~~a[0],~~a[1]]:a}function zt(t,e,n=!0){const i=st(t);return mt(i,e,n)}function $(t){return t*Math.PI/180}function V(t){return t*180/Math.PI}function Wt(t,e,n){const i=H(t,e),a=$(t[0]),r=$(t[1]),o=$(e[0]),s=$(e[1]),c=i/b,h=Math.sin((1-n)*c)/Math.sin(c),l=Math.sin(n*c)/Math.sin(c),S=h*Math.cos(r)*Math.cos(a)+l*Math.cos(s)*Math.cos(o),g=h*Math.cos(r)*Math.sin(a)+l*Math.cos(s)*Math.sin(o),w=h*Math.sin(r)+l*Math.sin(s),v=Math.atan2(w,Math.sqrt(S*S+g*g)),R=Math.atan2(g,S);return[V(R),V(v)]}const F={EARTH_RADIUS:b,EARTH_CIRCUMFERENCE:at,longitudeToMercatorX:rt,latitudeToMercatorY:ot,wgs84ToMercator:st,mercatorXToLongitude:ct,mercatorYToLatitude:pt,mercatorToWgs84:Bt,haversineDistanceWgs84:H,wrapWgs84:ht,circumferenceAtLatitude:lt,mercatorToTileIndex:mt,wgs84ToTileIndex:zt,toRadians:$,toDegrees:V,haversineIntermediateWgs84:Wt,haversineCumulatedDistanceWgs84:_t};let G=null;function B(){return G||(G=new At({maxSize:m.tileCacheSize})),G}async function ut(t){const e=new Blob([t]),n=await createImageBitmap(e),i=document.createElement("canvas"),a=i.getContext("2d");i.width=n.width,i.height=n.height,a.drawImage(n,0,0);const r=a.getImageData(0,0,i.width,i.height);return{pixels:r.data,width:i.width,height:i.height,components:r.data.length/(i.width*i.height)}}function _(){if(m.bufferToPixelData)return m.bufferToPixelData;if(typeof window<"u")return ut;throw new Error("An image file buffer to pixel data parser is necessary. Specify it in `config.bufferToPixelData`")}const qt="tiles/terrain-rgb-v2/tiles.json";let I=null;const z={403:"Key is missing, invalid or restricted"};async function gt(t){const e=new URL(qt,y.maptilerApiURL);e.searchParams.set("key",t);const n=e.toString(),i=await L(n);if(i.ok)return I=await i.json(),I;if(!i.ok)throw new A(i,z[i.status]??"")}async function Yt(t,e={}){const n=e.apiKey??m.apiKey;I||await gt(n);const i=I.maxzoom;let a=~~(e.zoom??i);(a>i||a<0)&&(a=i);const r=F.wgs84ToTileIndex(t,a,!1),o=~~r[0],s=~~r[1];if(!I.tiles.length)throw new Error("Terrain tileJSON tile list is empty.");const c=`terrain_${a.toString()}_${o.toString()}_${s.toString()}`;let h;const l=B();if(l.has(c))h=l.get(c);else{const T=I.tiles[0].replace("{x}",o.toString()).replace("{y}",s.toString()).replace("{z}",a.toString()),u=await L(T);if(!u.ok)throw new A(u,z[u.status]??"");const d=await u.arrayBuffer();h=await _()(d),l.set(c,h)}const S=~~(h.width*(r[0]%1)),g=(~~(h.height*(r[1]%1))*h.width+S)*h.components,w=h.pixels[g],v=h.pixels[g+1],R=h.pixels[g+2],p=-1e4+(w*256*256+v*256+R)*.1;return[t[0],t[1],p]}async function W(t,e={}){const n=e.apiKey??m.apiKey;I||await gt(n);const i=_(),a=I.tiles[0],r=B(),o=I.maxzoom;let s=~~(e.zoom??o);(s>o||s<0)&&(s=o);const c=t.map(p=>F.wgs84ToTileIndex(p,s,!1)),h=c.map(p=>[~~p[0],~~p[1]]).map(p=>`terrain_${s.toString()}_${p[0].toString()}_${p[1].toString()}`),l=Array.from(new Set(h.filter(p=>!r.has(p)))).map(p=>p.split("_").slice(1)),S=l.map(p=>a.replace("{x}",p[1].toString()).replace("{y}",p[2].toString()).replace("{z}",p[0].toString())).map(p=>L(p)),g=(await Promise.allSettled(S)).map(p=>p.status==="fulfilled"?p.value:null).filter(p=>p),w=g.filter(p=>!p.ok);if(g.length!==S.length)throw new Error("Some tiles could not be fetched.");if(w.length)throw new A(w[0],z[w[0].status]??"");const v=await Promise.all(g.map(p=>p.arrayBuffer()));if(!v.every(p=>p.byteLength>0))throw new Error("Some tiles are not available.");(await Promise.all(v.map(p=>i(p)))).forEach((p,T)=>{const u=l[T],d=`terrain_${u[0].toString()}_${u[1].toString()}_${u[2].toString()}`;r.set(d,p)});const R=t.map((p,T)=>{const u=h[T],d=c[T],f=r.get(u),U=Math.min(Math.round(f.width*(d[0]%1)),f.width-1),D=(Math.min(Math.round(f.height*(d[1]%1)),f.height-1)*f.width+U)*f.components,dt=f.pixels[D],ft=f.pixels[D+1],yt=f.pixels[D+2],St=-1e4+(dt*256*256+ft*256+yt)*.1;return[p[0],p[1],~~(St*1e3)/1e3]});if(e.smoothingKernelSize){const p=~~(e.smoothingKernelSize/2)*2+1,T=R.map(d=>d[2]),u=~~(p/2);for(let d=u;d<T.length-u-1;d+=1){let f=0;for(let U=0;U<p;U+=1){const D=T[d-u+U];f+=D}f/=p,R[d][2]=f}}return R}async function Jt(t,e={}){if(t.type!=="LineString")throw new Error("The provided object is not a GeoJSON LineString");const n=structuredClone(t),i=await W(n.coordinates,e);return n.coordinates=i,n}async function Zt(t,e={}){if(t.type!=="MultiLineString")throw new Error("The provided object is not a GeoJSON MultiLineString");const n=structuredClone(t),i=n.coordinates.map(c=>c.length),a=n.coordinates.flat(),r=await W(a,e),o=[];let s=0;for(const c of i)o.push(r.slice(s,s+c)),s+=c;return n.coordinates=o,n}const Xt={at:Yt,batch:W,fromLineString:Jt,fromMultiLineString:Zt};export{q as ClientConfig,k as LanguageGeocoding,nt as MapStyle,C as MapStyleVariant,K as ReferenceMapStyle,A as ServiceError,ut as bufferToPixelDataBrowser,lt as circumferenceAtLatitude,m as config,Pt as coordinates,Mt as data,Xt as elevation,et as expandMapStyle,Ut as geocoding,kt as geolocation,Y as getAutoLanguageGeocoding,_ as getBufferToPixelDataParser,B as getTileCache,N as mapStylePresetList,F as math,it as misc,Gt as staticMaps,M as styleToStyle};