@maptiler/client 1.6.0 → 1.7.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/dist/maptiler-client.cjs +482 -309
  2. package/dist/maptiler-client.cjs.map +1 -1
  3. package/dist/maptiler-client.d.ts +114 -5
  4. package/dist/maptiler-client.min.mjs +1 -1
  5. package/dist/maptiler-client.mjs +471 -309
  6. package/dist/maptiler-client.mjs.map +1 -1
  7. package/dist/maptiler-client.umd.js +483 -310
  8. package/dist/maptiler-client.umd.js.map +1 -1
  9. package/dist/maptiler-client.umd.min.js +1 -1
  10. package/package.json +25 -18
  11. package/readme.md +1 -1
  12. package/rollup.config.js +3 -3
  13. package/src/callFetch.ts +2 -2
  14. package/src/config.ts +4 -1
  15. package/src/demProfiler/getElevation.ts +46 -0
  16. package/src/demProfiler/index.ts +240 -0
  17. package/src/demProfiler/tileCover.ts +96 -0
  18. package/src/geometry/area.ts +96 -0
  19. package/src/geometry/distance.ts +45 -0
  20. package/src/geometry/index.ts +3 -0
  21. package/src/geometry/util.ts +34 -0
  22. package/src/index.ts +3 -0
  23. package/src/language.ts +1 -1
  24. package/src/mapstyle.ts +5 -5
  25. package/src/services/ServiceError.ts +5 -2
  26. package/src/services/coordinates.ts +14 -9
  27. package/src/services/data.ts +3 -3
  28. package/src/services/geocoding.ts +17 -14
  29. package/src/services/geolocation.ts +2 -2
  30. package/src/services/simplify.ts +3 -3
  31. package/src/services/staticMaps.ts +9 -9
  32. package/tsconfig.json +1 -1
  33. package/docs/.nojekyll +0 -1
  34. package/docs/assets/custom.css +0 -118
  35. package/docs/assets/highlight.css +0 -85
  36. package/docs/assets/main.js +0 -58
  37. package/docs/assets/search.js +0 -1
  38. package/docs/assets/style.css +0 -1280
  39. package/docs/classes/config.ClientConfig.html +0 -132
  40. package/docs/classes/services_ServiceError.ServiceError.html +0 -103
  41. package/docs/functions/language.getAutoLanguageGeocoding.html +0 -60
  42. package/docs/functions/services_simplify.default.html +0 -65
  43. package/docs/images/JS-logo.svg +0 -4
  44. package/docs/images/TS-logo.svg +0 -6
  45. package/docs/images/maptiler-client-logo.afdesign +0 -0
  46. package/docs/images/maptiler-client-logo.svg +0 -75
  47. package/docs/images/maptiler-logo-256.png +0 -0
  48. package/docs/images/maptiler-logo.svg +0 -23
  49. package/docs/images/screenshots/static-bounded-europe-1024.png +0 -0
  50. package/docs/images/screenshots/static-bounded-europe-2048.png +0 -0
  51. package/docs/images/screenshots/static-bounded-portugal-1024x2048.png +0 -0
  52. package/docs/images/screenshots/static-bounded-portugal-2048x2048.png +0 -0
  53. package/docs/images/screenshots/static-with-path.png +0 -0
  54. package/docs/index.html +0 -340
  55. package/docs/modules/config.html +0 -71
  56. package/docs/modules/language.html +0 -71
  57. package/docs/modules/services_ServiceError.html +0 -61
  58. package/docs/modules/services_coordinates.html +0 -84
  59. package/docs/modules/services_data.html +0 -66
  60. package/docs/modules/services_geocoding.html +0 -82
  61. package/docs/modules/services_geolocation.html +0 -68
  62. package/docs/modules/services_simplify.html +0 -61
  63. package/docs/modules/services_staticMaps.html +0 -74
  64. package/docs/modules.html +0 -59
  65. package/docs/types/config.FetchFunction.html +0 -71
  66. package/docs/types/language.LanguageGeocodingString.html +0 -58
  67. package/docs/types/services_coordinates.CoordinateExport.html +0 -71
  68. package/docs/types/services_coordinates.CoordinateGrid.html +0 -69
  69. package/docs/types/services_coordinates.CoordinateId.html +0 -71
  70. package/docs/types/services_coordinates.CoordinateSearch.html +0 -93
  71. package/docs/types/services_coordinates.CoordinateSearchResult.html +0 -75
  72. package/docs/types/services_coordinates.CoordinateTransformResult.html +0 -76
  73. package/docs/types/services_coordinates.CoordinateTransformation.html +0 -89
  74. package/docs/types/services_coordinates.CoordinatesSearchOptions.html +0 -83
  75. package/docs/types/services_coordinates.CoordinatesTransformOptions.html +0 -85
  76. package/docs/types/services_coordinates.XYZ.html +0 -73
  77. package/docs/types/services_data.GetDataOptions.html +0 -64
  78. package/docs/types/services_geocoding.ByIdGeocodingOptions.html +0 -63
  79. package/docs/types/services_geocoding.CommonForwardAndReverseGeocodingOptions.html +0 -63
  80. package/docs/types/services_geocoding.Coordinates.html +0 -63
  81. package/docs/types/services_geocoding.FeatureHierarchy.html +0 -63
  82. package/docs/types/services_geocoding.GeocodingFeature.html +0 -63
  83. package/docs/types/services_geocoding.GeocodingOptions.html +0 -63
  84. package/docs/types/services_geocoding.GeocodingSearchResult.html +0 -80
  85. package/docs/types/services_geocoding.LanguageGeocodingOptions.html +0 -70
  86. package/docs/types/services_geocoding.ReverseGeocodingOptions.html +0 -63
  87. package/docs/types/services_geolocation.GeolocationInfoOptions.html +0 -65
  88. package/docs/types/services_geolocation.GeolocationResult.html +0 -128
  89. package/docs/types/services_staticMaps.AutomaticStaticMapOptions.html +0 -61
  90. package/docs/types/services_staticMaps.BoundedStaticMapOptions.html +0 -61
  91. package/docs/types/services_staticMaps.CenteredStaticMapOptions.html +0 -61
  92. package/docs/types/services_staticMaps.StaticMapBaseOptions.html +0 -157
  93. package/docs/types/services_staticMaps.StaticMapMarker.html +0 -61
  94. package/docs/variables/config.config.html +0 -58
  95. package/docs/variables/language.LanguageGeocoding.html +0 -171
  96. package/docs/variables/services_coordinates.coordinates.html +0 -110
  97. package/docs/variables/services_data.data.html +0 -80
  98. package/docs/variables/services_geocoding.geocoding.html +0 -265
  99. package/docs/variables/services_geolocation.geolocation.html +0 -79
  100. package/docs/variables/services_staticMaps.staticMaps.html +0 -128
  101. package/docsmd/.nojekyll +0 -1
  102. package/docsmd/README.md +0 -873
  103. package/docsmd/assets/custom.css +0 -118
  104. package/docsmd/classes/ClientConfig.md +0 -90
  105. package/docsmd/classes/MapStyleVariant.md +0 -234
  106. package/docsmd/classes/ReferenceMapStyle.md +0 -169
  107. package/docsmd/classes/ServiceError.md +0 -52
  108. package/images/JS-logo.svg +0 -4
  109. package/images/TS-logo.svg +0 -6
  110. package/images/maptiler-client-logo.afdesign +0 -0
  111. package/images/maptiler-client-logo.svg +0 -75
  112. package/images/maptiler-logo-256.png +0 -0
  113. package/images/maptiler-logo.svg +0 -23
  114. package/images/screenshots/static-bounded-europe-1024.png +0 -0
  115. package/images/screenshots/static-bounded-europe-2048.png +0 -0
  116. package/images/screenshots/static-bounded-portugal-1024x2048.png +0 -0
  117. package/images/screenshots/static-bounded-portugal-2048x2048.png +0 -0
  118. package/images/screenshots/static-with-path.png +0 -0
@@ -1,7 +1,8 @@
1
- import { BBox, Position, Feature, Geometry, FeatureCollection } from 'geojson';
1
+ import { BBox, Position, Feature, Geometry, FeatureCollection, LineString } from 'geojson';
2
2
  export { BBox, Position } from 'geojson';
3
+ import { Point } from 'web-merc-projection';
3
4
 
4
- type FetchFunction = (url: string, options: object) => Promise<any>;
5
+ type FetchFunction = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
5
6
  /**
6
7
  * The configuration object definition
7
8
  */
@@ -147,7 +148,9 @@ type GeocodingOptions = CommonForwardAndReverseGeocodingOptions & {
147
148
  autocomplete?: boolean;
148
149
  };
149
150
  type ReverseGeocodingOptions = CommonForwardAndReverseGeocodingOptions;
150
- type ByIdGeocodingOptions = LanguageGeocodingOptions;
151
+ type ByIdGeocodingOptions = LanguageGeocodingOptions & {
152
+ apiKey?: string;
153
+ };
151
154
  type Coordinates = Position;
152
155
  type FeatureProperties = {
153
156
  /**
@@ -516,9 +519,13 @@ type CoordinateSearch = {
516
519
  /**
517
520
  * Most suitable transformation for this CRS.
518
521
  */
519
- default_transformation?: any;
522
+ default_transformation?: DefaultTransformation;
520
523
  exports: CoordinateExport;
521
524
  };
525
+ type DefaultTransformation = {
526
+ authority: string;
527
+ code: number;
528
+ };
522
529
  type CoordinateSearchResult = {
523
530
  /**
524
531
  * The coordinate search results
@@ -1225,4 +1232,106 @@ declare class ServiceError extends Error {
1225
1232
  constructor(res: Response, customMessage?: string);
1226
1233
  }
1227
1234
 
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 };
1235
+ interface TileID {
1236
+ id: number;
1237
+ x: number;
1238
+ y: number;
1239
+ z: number;
1240
+ }
1241
+ interface TileCoverCoordinates {
1242
+ /** Store the coordinates as an ll-pair */
1243
+ coordinate: Point;
1244
+ /** Track the tile relative to the point */
1245
+ tile: TileID;
1246
+ }
1247
+ interface TileCoverOutput {
1248
+ coords: TileCoverCoordinates[];
1249
+ tiles: TileID[];
1250
+ }
1251
+
1252
+ type ElevationParser = (r: number, g: number, b: number, a: number) => number;
1253
+ /** Default elevation parser used by Mapbox and Maplibre. Result is in meters */
1254
+ declare function defaultElevationParser(r: number, g: number, b: number): number;
1255
+
1256
+ interface TileImage {
1257
+ channels: 1 | 2 | 3 | 4;
1258
+ image: Uint8ClampedArray;
1259
+ }
1260
+ type TileRequest = (x: number, y: number, zoom: number) => Promise<TileImage>;
1261
+ interface Options {
1262
+ /** type of metric to use. Meters or feet. Default: meters */
1263
+ metric?: "m" | "ft";
1264
+ /** Zoom that is queried from the server. Default: 13 */
1265
+ zoom?: number;
1266
+ /** Tile size of the images returned. Default 512 */
1267
+ tileSize?: number;
1268
+ /** Tile Request method */
1269
+ tileRequest: TileRequest;
1270
+ /** Elevation parser. Default: elevation = -10000 + ((R * 256 * 256 + G * 256 + B) * 0.1) */
1271
+ elevationParser?: ElevationParser;
1272
+ /** smooth out the elevation to make the visual aesthetic nicer */
1273
+ smooth?: boolean;
1274
+ }
1275
+ interface ElevPoint {
1276
+ /** Distance along path from the starting point in the metric defind by options */
1277
+ distance: number;
1278
+ /** Elevation of the point */
1279
+ elevation: number;
1280
+ /** Coordinates of the point in lat-lon */
1281
+ coordinate: [lon: number, lat: number];
1282
+ /** Tile that the point is in */
1283
+ tile: TileID;
1284
+ }
1285
+ interface Output {
1286
+ /** Total length of the path in the metric defined by options */
1287
+ distance: number;
1288
+ /** Minimum elevation of the path */
1289
+ minElevation: number;
1290
+ /** Maximum elevation of the path */
1291
+ maxElevation: number;
1292
+ /** Average elevation of the path */
1293
+ avgElevation: number;
1294
+ /** Elevation at the start of the path */
1295
+ startElevation: number;
1296
+ /** Elevation at the end of the path */
1297
+ endElevation: number;
1298
+ /** Array of points along the path */
1299
+ points: ElevPoint[];
1300
+ }
1301
+ /**
1302
+ * Given a GeoJSON LineString or Feature<Linestring>, return the elevation data for the path.
1303
+ * This algorithm will automatically break the path into denser segments relative to the zoom level if necessary.
1304
+ */
1305
+ declare function profileLineString(path: Feature<LineString> | LineString, options: Options): Promise<Output>;
1306
+
1307
+ /**
1308
+ * Finds the area of a Polygon or MultiPolygon in square meters.
1309
+ */
1310
+ declare function area(area: GeoJSON.Feature<GeoJSON.Polygon | GeoJSON.MultiPolygon> | GeoJSON.Polygon | GeoJSON.MultiPolygon): number;
1311
+ /**
1312
+ * Finds the area of a MultiPolygon in square meters.
1313
+ */
1314
+ declare function multiPolygonArea(multiPoly: GeoJSON.MultiPolygon | GeoJSON.Position[][][]): number;
1315
+ /**
1316
+ * Finds the area of a Polygon in square meters.
1317
+ */
1318
+ declare function polygonArea(poly: GeoJSON.Polygon | GeoJSON.Position[][]): number;
1319
+
1320
+ /** Get the distance of a LineString in meters */
1321
+ declare function lineDistance(line: GeoJSON.Feature<GeoJSON.LineString> | GeoJSON.LineString | GeoJSON.Position[]): number;
1322
+ /** Get the distance between two lon-lat pairs in meters */
1323
+ declare function pointDistance(from: GeoJSON.Position, to: GeoJSON.Position): number;
1324
+
1325
+ declare const earthRadius = 6371008.8;
1326
+ /** Convert meters to feet */
1327
+ declare function mToFt(m: number): number;
1328
+ /** Convert degrees to Radians */
1329
+ declare function degToRad(degrees: number): number;
1330
+ /** Convert radians to degrees */
1331
+ declare function radToDeg(radians: number): number;
1332
+ /** Given a latitude and zoom level, determine the max distance each segment can be in meters */
1333
+ declare function getZoomLevelResolution(latitude: number, zoom: number, tileSize?: number): number;
1334
+ /** Convert a tile's zoom-x-y to a number hash */
1335
+ declare function xyzToTileID(x: number, y: number, zoom: number): number;
1336
+
1337
+ export { type AutomaticStaticMapOptions, type BoundedStaticMapOptions, 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 ElevPoint, type ElevationParser, 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 Options, type Output, ReferenceMapStyle, type ReverseGeocodingOptions, ServiceError, type StaticMapBaseOptions, type StaticMapMarker, type TileCoverCoordinates, type TileCoverOutput, type TileID, type TileImage, type TileRequest, type XYZ, area, config, coordinates, data, defaultElevationParser, degToRad, earthRadius, expandMapStyle, geocoding, geolocation, getZoomLevelResolution, lineDistance, mToFt, mapStylePresetList, multiPolygonArea, pointDistance, polygonArea, profileLineString, radToDeg, staticMaps, xyzToTileID };
@@ -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{llToTile as W,llToTilePx as _}from"web-merc-projection";function q(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class b{constructor(){this._apiKey="",this._fetch=q()}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 b,v={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"},Z=new Set(Object.values(v));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=>Z.has(e));return t.length?t[0]:v.ENGLISH}async function f(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 h={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(h);class u extends Error{constructor(e,n=""){super(`Call to enpoint ${e.url} failed with the status code ${e.status}. ${n}`),this.res=e}}const R={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function K(t,e){if(e.language==null)return;const n=Array.from(new Set((Array.isArray(e.language)?e.language:[e.language]).map(i=>i===v.AUTO?Y():i))).join(",");t.set("language",n)}function C(t,e){t.set("key",e.apiKey??m.apiKey),e.limit!=null&&t.set("limit",String(e.limit)),e.types!=null&&t.set("types",e.types.join(",")),K(t,e)}function O(t,e){C(t,e),e.bbox!=null&&t.set("bbox",e.bbox.join(",")),e.proximity!=null&&t.set("proximity",e.proximity.join(",")),e.country!=null&&t.set("country",e.country.join(",")),e.fuzzyMatch!=null&&t.set("fuzzyMatch",e.fuzzyMatch?"true":"false"),e.autocomplete!=null&&t.set("autocomplete",e.autocomplete?"true":"false")}async function J(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`,h.maptilerApiURL),{searchParams:i}=n;O(i,e);const a=n.toString(),r=await f(a);if(!r.ok)throw new u(r,R[r.status]??"");return await r.json()}async function Q(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`,h.maptilerApiURL);C(n.searchParams,e);const i=n.toString(),a=await f(i);if(!a.ok)throw new u(a,R[a.status]??"");return await a.json()}async function X(t,e={}){const n=new URL(`geocoding/${t}.json`,h.maptilerApiURL);n.searchParams.set("key",e.apiKey??m.apiKey),K(n.searchParams,e);const i=n.toString(),a=await f(i);if(!a.ok)throw new u(a,R[a.status]??"");return await a.json()}async function tt(t,e={}){if(!t.length)return[];const n=t.map(c=>encodeURIComponent(c)).join(";"),i=new URL(`geocoding/${n}.json`,h.maptilerApiURL),{searchParams:a}=i;O(a,e);const r=i.toString(),s=await f(r);if(!s.ok)throw new u(s,R[s.status]??"");const o=await s.json();return t.length===1?[o]:o}const et={forward:J,reverse:Q,byId:X,batch:tt,language:v},j={403:"Key is missing, invalid or restricted"};async function nt(t={}){const e=new URL("geolocation/ip.json",h.maptilerApiURL);e.searchParams.set("key",t.apiKey??m.apiKey);const n=e.toString(),i=await f(n);if(!i.ok)throw new u(i,i.status in j?j[i.status]:"");return await i.json()}const it={info:nt},L={403:"Key is missing, invalid or restricted"};async function at(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`,h.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 f(i);if(!a.ok)throw new u(a,a.status in L?L[a.status]:"");return await a.json()}async function rt(t,e={}){const n=(Array.isArray(t[0])?t:[t]).map(s=>`${s[0]},${s[1]}`).join(";"),i=new URL(`coordinates/transform/${n}.json`,h.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 f(a);if(!r.ok)throw new u(r,r.status in L?L[r.status]:"");return await r.json()}const ot={search:at,transform:rt},M={403:"Key is missing, invalid or restricted"};async function st(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`,h.maptilerApiURL);n.searchParams.set("key",e.apiKey??m.apiKey);const i=n.toString(),a=await f(i);if(!a.ok)throw new u(a,a.status in M?M[a.status]:"");return await a.json()}const ct={get:st};function H(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 U{constructor(e,n,i,a,r,s){this.name=e,this.variantType=n,this.id=i,this.referenceStyle=a,this.description=r,this.imageURL=s}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 H(this.getId())}}class D{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 I=[{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 lt(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 pt(){const t={};for(let e=0;e<I.length;e+=1){const n=I[e],i=lt(new D(n.name,n.referenceStyleID));for(let a=0;a<n.variants.length;a+=1){const r=n.variants[a],s=new U(r.name,r.variantType,r.id,i,r.description,r.imageURL);i.addVariant(s)}t[n.referenceStyleID]=i}return t}function E(t){if(!t)return x[I[0].referenceStyleID].getDefaultVariant().getId();if(typeof t=="string"||t instanceof String)return t.trim().toLowerCase();if(t instanceof U)return t.getId();if(t instanceof D)return t.getDefaultVariant().getId()}const x=pt();function mt(t,e,n){let i=e[0],a=e[1],r=n[0]-i,s=n[1]-a;if(r!==0||s!==0){const o=((t[0]-i)*r+(t[1]-a)*s)/(r*r+s*s);o>1?(i=n[0],a=n[1]):o>0&&(i+=r*o,a+=s*o)}return r=t[0]-i,s=t[1]-a,r*r+s*s}function k(t,e,n,i,a){let r=i,s;for(let o=e+1;o<n;o++){const c=mt(t[o],t[e],t[n]);c>r&&(s=o,r=c)}r>i&&(s-e>1&&k(t,e,s,i,a),a.push(t[s]),n-s>1&&k(t,s,n,i,a))}function ht(t,e){const n=t.length-1,i=[t[0]];return k(t,0,n,e,i),i.push(t[n]),i}function dt(t,e){if(t.length<=2)return t;const n=e!==void 0?e*e:1;return ht(t,n)}function w(t,e=!0){let n=`${t[0]},${t[1]}`;return t.length===3&&e&&(n+=`,${t[2]}`),n}function $(t,e=3e3){let n=t.map(r=>r.join(",")).join("|"),i=5e-6;const a=1e-5;for(;n.length>e;)n=dt(t,i).map(r=>`${r[0]},${r[1]}`).join("|"),i+=a;return n}function ut(t,e,n={}){const i=E(n.style),a=n.hiDPI?"@2x":"",r=n.format??"png";let s=~~(n.width??1024),o=~~(n.height??1024);n.hiDPI&&(s=~~(s/2),o=~~(o/2));const c=new URL(`maps/${encodeURIComponent(i)}/static/${t[0]},${t[1]},${e}/${s}x${o}${a}.${r}`,h.maptilerApiURL);if("attribution"in n&&c.searchParams.set("attribution",n.attribution.toString()),"markers"in n){let l="";const p="markerIcon"in n;p&&(l+=`icon:${n.markerIcon}|`),p&&"markerAnchor"in n&&(l+=`anchor:${n.markerAnchor}|`),p&&n.hiDPI&&(l+="scale:2|");const d=Array.isArray(n.markers[0])?n.markers:[n.markers];l+=d.map(A=>w(A,!p)).join("|"),c.searchParams.set("markers",l)}if("path"in n){let l="";if(l+=`fill:${n.pathFillColor??"none"}|`,"pathStrokeColor"in n&&(l+=`stroke:${n.pathStrokeColor}|`),"pathWidth"in n){const p=n.pathWidth/(n.hiDPI?2:1);l+=`width:${p.toString()}|`}l+=$(n.path),c.searchParams.set("path",l)}return c.searchParams.set("key",n.apiKey??m.apiKey),c.toString()}function gt(t,e={}){const n=E(e.style),i=e.hiDPI?"@2x":"",a=e.format??"png";let r=~~(e.width??1024),s=~~(e.height??1024);e.hiDPI&&(r=~~(r/2),s=~~(s/2));const o=new URL(`maps/${encodeURIComponent(n)}/static/${t[0]},${t[1]},${t[2]},${t[3]}/${r}x${s}${i}.${a}`,h.maptilerApiURL);if("attribution"in e&&o.searchParams.set("attribution",e.attribution.toString()),"padding"in e&&o.searchParams.set("padding",e.padding.toString()),"markers"in e){let c="";const l="markerIcon"in e;l&&(c+=`icon:${e.markerIcon}|`),l&&"markerAnchor"in e&&(c+=`anchor:${e.markerAnchor}|`),l&&e.hiDPI&&(c+="scale:2|");const p=Array.isArray(e.markers[0])?e.markers:[e.markers];c+=p.map(d=>w(d,!l)).join("|"),o.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 l=e.pathWidth/(e.hiDPI?2:1);c+=`width:${l.toString()}|`}c+=$(e.path),o.searchParams.set("path",c)}return o.searchParams.set("key",e.apiKey??m.apiKey),o.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=E(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 s=new URL(`maps/${encodeURIComponent(e)}/static/auto/${a}x${r}${n}.${i}`,h.maptilerApiURL);if("attribution"in t&&s.searchParams.set("attribution",t.attribution.toString()),"padding"in t&&s.searchParams.set("padding",t.padding.toString()),"markers"in t){let o="";const c="markerIcon"in t;c&&(o+=`icon:${t.markerIcon}|`),c&&"markerAnchor"in t&&(o+=`anchor:${t.markerAnchor}|`),c&&t.hiDPI&&(o+="scale:2|");const l=Array.isArray(t.markers[0])?t.markers:[t.markers];o+=l.map(p=>w(p,!c)).join("|"),s.searchParams.set("markers",o)}if("path"in t){let o="";if(o+=`fill:${t.pathFillColor??"none"}|`,"pathStrokeColor"in t&&(o+=`stroke:${t.pathStrokeColor}|`),"pathWidth"in t){const c=t.pathWidth/(t.hiDPI?2:1);o+=`width:${c.toString()}|`}o+=$(t.path),s.searchParams.set("path",o)}return s.searchParams.set("key",t.apiKey??m.apiKey),s.toString()}const yt={centered:ut,bounded:gt,automatic:ft},S=63710088e-1;function g(t){return t*3.28084}function y(t){return t%360*Math.PI/180}function vt(t){return t*180/Math.PI}function V(t,e,n=512){return Math.cos(t*Math.PI/180)*2*Math.PI*6378137/(n*2**e)*3}function G(t,e,n){return((1<<n)*e+t)*32+n}function At(t){const e="geometry"in t?t.geometry:t;return e.type==="MultiPolygon"?F(e.coordinates):P(e.coordinates)}function F(t){const e="coordinates"in t?t.coordinates:t;let n=0;for(const i of e)n+=P(i);return n}function P(t){const e="coordinates"in t?t.coordinates:t;let n=0;for(const i of e)n+=Rt(i);return n}function Rt(t){let e,n,i,a,r,s,o,c=0;const l=t.length;if(l>2){for(o=0;o<l;o++)o===l-2?(a=l-2,r=l-1,s=0):o===l-1?(a=l-1,r=0,s=1):(a=o,r=o+1,s=o+2),e=t[a],n=t[r],i=t[s],c+=(y(i[0])-y(e[0]))*Math.sin(y(n[1]));c=c*S*S/2}return Math.abs(c)}function Lt(t){const e="geometry"in t?t.geometry.coordinates:"coordinates"in t?t.coordinates:t;let n=0,i;for(const a of e)i!==void 0&&(n+=T(i,a)),i=a;return n}function T(t,e){const{pow:n,sin:i,cos:a,sqrt:r,atan2:s}=Math,o=y(e[1]-t[1]),c=y(e[0]-t[0]),l=y(t[1]),p=y(e[1]),d=n(i(o/2),2)+n(i(c/2),2)*a(l)*a(p);return 2*s(r(d),r(1-d))*S}function It(t,e,n){const i=new Map,a=[],r=[],s=V(t[0][1],e,n),o=St(t,s);for(const c of o){const l=c,[p,d]=W(l,e,n),A=G(p,d,e),N={id:A,x:p,y:d,z:e};i.set(A,N),r.push({coordinate:l,tile:N})}for(const c of i.values())a.push(c);return{coords:r,tiles:a}}function St(t,e){const n=[];let i;for(const a of t){if(i!==void 0){const r=T(i,a),s=Math.ceil(r/e);for(let o=0;o<=s-1;o++){const c=[i[0]+(a[0]-i[0])*(o/s),i[1]+(a[1]-i[1])*(o/s)];n.push(c)}}else n.push(a);i=a}return n}function Tt(t,e,n,i,a=B){const{channels:r,image:s}=i;let[o,c]=_(t,e,n);o=z(o,n),c=z(c,n);const l=(c*n+o)*r;return a(s[l],s[l+1],s[l+2],r===4?s[l+3]:0)}function z(t,e){return Math.max(0,Math.min(e,Math.floor(t*e)))}function B(t,e,n){return-1e4+(t*256*256+e*256+n)*.1}async function Ut(t,e){const n="geometry"in t?t.geometry.coordinates:t.coordinates,{coords:i,tiles:a}=It(n,e.zoom??13,e.tileSize??512),r=await Dt(a,e.tileRequest);let s=Et(i,r,e.tileSize??512,e.elevationParser);e.smooth===!0&&(s=wt(s));let o=kt(s);return e.metric==="ft"&&(o=$t(o)),o}async function Dt(t,e){const n=new Map,i=[];for(const a of t)i.push(e(a.x,a.y,a.z).then(r=>(n.set(a.id,r),r)).catch(r=>{console.error(r)}));return await Promise.allSettled(i),n}function Et(t,e,n,i){const a=[];let r=0,s;for(const{tile:o,coordinate:c}of t){const l=e.get(o.id);if(l===void 0)throw new Error(`Missing tile ${o.id} (${o.x}-${o.y}-${o.z})`);const p=Tt(c,[o.z,o.x,o.y],n,l,i);a.push({distance:r,elevation:p,coordinate:c,tile:o}),s!==void 0&&(r+=T(s,c)),s=c}return a}function kt(t){let e=1/0,n=-1/0,i=0;for(const a of t)a.elevation<e&&(e=a.elevation),a.elevation>n&&(n=a.elevation),i+=a.elevation;return{distance:t[t.length-1].distance,minElevation:e,maxElevation:n,avgElevation:i/t.length,startElevation:t[0].elevation,endElevation:t[t.length-1].elevation,points:t}}function wt(t){const e=[];let n;for(let i=0;i<t.length;i++){const a=t[i],r=t[i+1]??t[i];if(n===void 0)e.push(a);else{const s={distance:a.distance,elevation:(n.elevation+a.elevation+r.elevation)/3,coordinate:a.coordinate,tile:a.tile};e.push(s)}n=a}return e}function $t(t){return{distance:g(t.distance),minElevation:g(t.minElevation),maxElevation:g(t.maxElevation),avgElevation:g(t.avgElevation),startElevation:g(t.startElevation),endElevation:g(t.endElevation),points:t.points.map(({distance:e,elevation:n,coordinate:i,tile:a})=>({distance:g(e),elevation:g(n),coordinate:i,tile:a}))}}export{b as ClientConfig,v as LanguageGeocoding,x as MapStyle,U as MapStyleVariant,D as ReferenceMapStyle,u as ServiceError,At as area,m as config,ot as coordinates,ct as data,B as defaultElevationParser,y as degToRad,S as earthRadius,H as expandMapStyle,et as geocoding,it as geolocation,V as getZoomLevelResolution,Lt as lineDistance,g as mToFt,I as mapStylePresetList,F as multiPolygonArea,T as pointDistance,P as polygonArea,Ut as profileLineString,vt as radToDeg,yt as staticMaps,G as xyzToTileID};