@maptiler/client 1.0.3 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/maptiler-client.cjs +586 -21
  2. package/dist/maptiler-client.cjs.map +1 -1
  3. package/dist/maptiler-client.d.ts +405 -2
  4. package/dist/maptiler-client.min.mjs +1 -1
  5. package/dist/maptiler-client.mjs +582 -22
  6. package/dist/maptiler-client.mjs.map +1 -1
  7. package/dist/maptiler-client.umd.js +586 -21
  8. package/dist/maptiler-client.umd.js.map +1 -1
  9. package/dist/maptiler-client.umd.min.js +1 -1
  10. package/docs/assets/custom.css +28 -1
  11. package/docs/classes/config.ClientConfig.html +9 -9
  12. package/docs/classes/services_ServiceError.ServiceError.html +7 -7
  13. package/docs/functions/language.getAutoLanguageGeocoding.html +5 -5
  14. package/docs/functions/services_simplify.default.html +5 -5
  15. package/docs/index.html +111 -30
  16. package/docs/modules/config.html +5 -5
  17. package/docs/modules/language.html +5 -5
  18. package/docs/modules/services_ServiceError.html +5 -5
  19. package/docs/modules/services_coordinates.html +5 -5
  20. package/docs/modules/services_data.html +5 -5
  21. package/docs/modules/services_geocoding.html +5 -5
  22. package/docs/modules/services_geolocation.html +5 -5
  23. package/docs/modules/services_simplify.html +5 -5
  24. package/docs/modules/services_staticMaps.html +5 -5
  25. package/docs/modules.html +4 -4
  26. package/docs/types/config.FetchFunction.html +5 -5
  27. package/docs/types/language.LanguageGeocodingString.html +5 -5
  28. package/docs/types/services_coordinates.CoordinateExport.html +5 -5
  29. package/docs/types/services_coordinates.CoordinateGrid.html +5 -5
  30. package/docs/types/services_coordinates.CoordinateId.html +5 -5
  31. package/docs/types/services_coordinates.CoordinateSearch.html +5 -5
  32. package/docs/types/services_coordinates.CoordinateSearchResult.html +5 -5
  33. package/docs/types/services_coordinates.CoordinateTransformResult.html +5 -5
  34. package/docs/types/services_coordinates.CoordinateTransformation.html +5 -5
  35. package/docs/types/services_coordinates.CoordinatesSearchOptions.html +5 -5
  36. package/docs/types/services_coordinates.CoordinatesTransformOptions.html +5 -5
  37. package/docs/types/services_coordinates.XYZ.html +5 -5
  38. package/docs/types/services_data.GetDataOptions.html +5 -5
  39. package/docs/types/services_geocoding.Coordinates.html +5 -5
  40. package/docs/types/services_geocoding.FeatureHierarchy.html +5 -5
  41. package/docs/types/services_geocoding.GeocodingFeature.html +5 -5
  42. package/docs/types/services_geocoding.GeocodingOptions.html +5 -5
  43. package/docs/types/services_geocoding.GeocodingSearchResult.html +5 -5
  44. package/docs/types/services_geocoding.ReverseGeocodingOptions.html +5 -5
  45. package/docs/types/services_geolocation.GeolocationInfoOptions.html +5 -5
  46. package/docs/types/services_geolocation.GeolocationResult.html +5 -5
  47. package/docs/types/services_staticMaps.AutomaticStaticMapOptions.html +5 -5
  48. package/docs/types/services_staticMaps.BoundedStaticMapOptions.html +5 -5
  49. package/docs/types/services_staticMaps.CenteredStaticMapOptions.html +5 -5
  50. package/docs/types/services_staticMaps.StaticMapBaseOptions.html +7 -7
  51. package/docs/types/services_staticMaps.StaticMapMarker.html +5 -5
  52. package/docs/variables/config.config.html +5 -5
  53. package/docs/variables/language.LanguageGeocoding.html +5 -5
  54. package/docs/variables/services_coordinates.coordinates.html +5 -5
  55. package/docs/variables/services_data.data.html +5 -5
  56. package/docs/variables/services_geocoding.geocoding.html +5 -5
  57. package/docs/variables/services_geolocation.geolocation.html +5 -5
  58. package/docs/variables/services_staticMaps.staticMaps.html +5 -5
  59. package/docsmd/README.md +145 -36
  60. package/docsmd/assets/custom.css +28 -1
  61. package/docsmd/classes/ClientConfig.md +5 -5
  62. package/docsmd/classes/MapStyleVariant.md +234 -0
  63. package/docsmd/classes/ReferenceMapStyle.md +169 -0
  64. package/docsmd/classes/ServiceError.md +3 -3
  65. package/examples/test-browser-umd.html +1 -1
  66. package/package.json +1 -1
  67. package/readme.md +86 -27
  68. package/src/index.ts +17 -0
  69. package/src/mapstyle.ts +874 -0
  70. package/src/services/staticMaps.ts +5 -4
  71. package/tsconfig.json +0 -1
  72. package/typedoc.css +28 -1
@@ -524,6 +524,409 @@ declare const data: {
524
524
  get: typeof get;
525
525
  };
526
526
 
527
+ /**
528
+ * Expand the map style provided as argument of the Map constructor
529
+ * @param style
530
+ * @returns
531
+ */
532
+ declare function expandMapStyle(style: any): string;
533
+ /**
534
+ * Type for object containing style details
535
+ */
536
+ type MapStylePreset = {
537
+ referenceStyleID: string;
538
+ name: string;
539
+ description: string;
540
+ variants: Array<{
541
+ id: string;
542
+ name: string;
543
+ variantType: string;
544
+ description: string;
545
+ imageURL: string;
546
+ }>;
547
+ };
548
+ /**
549
+ * An instance of MapStyleVariant contains information about a style to use that belong to a reference style
550
+ */
551
+ declare class MapStyleVariant {
552
+ /**
553
+ * Human-friendly name
554
+ */
555
+ private name;
556
+ /**
557
+ * Variant name the variant is addressed to from its reference style: `MapStyle.REFERNCE_STYLE_NAME.VARIANT_TYPE`
558
+ */
559
+ private variantType;
560
+ /**
561
+ * MapTiler Cloud id
562
+ */
563
+ private id;
564
+ /**
565
+ * Reference map style, used to retrieve sibling variants
566
+ */
567
+ private referenceStyle;
568
+ /**
569
+ * Human-friendly description
570
+ */
571
+ private description;
572
+ /**
573
+ * URL to an image describing the style variant
574
+ */
575
+ private imageURL;
576
+ constructor(
577
+ /**
578
+ * Human-friendly name
579
+ */
580
+ name: string,
581
+ /**
582
+ * Variant name the variant is addressed to from its reference style: `MapStyle.REFERNCE_STYLE_NAME.VARIANT_TYPE`
583
+ */
584
+ variantType: string,
585
+ /**
586
+ * MapTiler Cloud id
587
+ */
588
+ id: string,
589
+ /**
590
+ * Reference map style, used to retrieve sibling variants
591
+ */
592
+ referenceStyle: ReferenceMapStyle,
593
+ /**
594
+ * Human-friendly description
595
+ */
596
+ description: string,
597
+ /**
598
+ * URL to an image describing the style variant
599
+ */
600
+ imageURL: string);
601
+ /**
602
+ * Get the human-friendly name
603
+ * @returns
604
+ */
605
+ getName(): string;
606
+ getFullName(): string;
607
+ /**
608
+ * Get the variant type (eg. "DEFAULT", "DARK", "PASTEL", etc.)
609
+ * @returns
610
+ */
611
+ getType(): string;
612
+ /**
613
+ * Get the MapTiler Cloud id
614
+ * @returns
615
+ */
616
+ getId(): string;
617
+ /**
618
+ * Get the human-friendly description
619
+ */
620
+ getDescription(): string;
621
+ /**
622
+ * Get the reference style this variant belongs to
623
+ * @returns
624
+ */
625
+ getReferenceStyle(): ReferenceMapStyle;
626
+ /**
627
+ * Check if a variant of a given type exists for _this_ variants
628
+ * (eg. if this is a "DARK", then we can check if there is a "LIGHT" variant of it)
629
+ * @param variantType
630
+ * @returns
631
+ */
632
+ hasVariant(variantType: string): boolean;
633
+ /**
634
+ * Retrieve the variant of a given type. If not found, will return the "DEFAULT" variant.
635
+ * (eg. _this_ "DARK" variant does not have any "PASTEL" variant, then the "DEFAULT" is returned)
636
+ * @param variantType
637
+ * @returns
638
+ */
639
+ getVariant(variantType: string): MapStyleVariant;
640
+ /**
641
+ * Get all the variants for _this_ variants, except _this_ current one
642
+ * @returns
643
+ */
644
+ getVariants(): Array<MapStyleVariant>;
645
+ /**
646
+ * Get the image URL that represent _this_ variant
647
+ * @returns
648
+ */
649
+ getImageURL(): string;
650
+ /**
651
+ * Get the style as usable by MapLibre, a string (URL) or a plain style description (StyleSpecification)
652
+ * @returns
653
+ */
654
+ getExpandedStyleURL(): string;
655
+ }
656
+ /**
657
+ * An instance of reference style contains a list of StyleVariants ordered by relevance
658
+ */
659
+ declare class ReferenceMapStyle {
660
+ /**
661
+ * Human-friendly name of this reference style
662
+ */
663
+ private name;
664
+ /**
665
+ * ID of this reference style
666
+ */
667
+ private id;
668
+ /**
669
+ * Variants that belong to this reference style, key being the reference type
670
+ */
671
+ private variants;
672
+ /**
673
+ * Variants that belong to this reference style, ordered by relevance
674
+ */
675
+ private orderedVariants;
676
+ constructor(
677
+ /**
678
+ * Human-friendly name of this reference style
679
+ */
680
+ name: string,
681
+ /**
682
+ * ID of this reference style
683
+ */
684
+ id: string);
685
+ /**
686
+ * Get the human-friendly name of this reference style
687
+ * @returns
688
+ */
689
+ getName(): string;
690
+ /**
691
+ * Get the id of _this_ reference style
692
+ * @returns
693
+ */
694
+ getId(): string;
695
+ /**
696
+ * Add a variant to _this_ reference style
697
+ * @param v
698
+ */
699
+ addVariant(v: MapStyleVariant): void;
700
+ /**
701
+ * Check if a given variant type exists for this reference style
702
+ * @param variantType
703
+ * @returns
704
+ */
705
+ hasVariant(variantType: string): boolean;
706
+ /**
707
+ * Get a given variant. If the given type of variant does not exist for this reference style,
708
+ * then the most relevant default variant is returned instead
709
+ * @param variantType
710
+ * @returns
711
+ */
712
+ getVariant(variantType: string): MapStyleVariant;
713
+ /**
714
+ * Get the list of variants for this reference style
715
+ * @returns
716
+ */
717
+ getVariants(): Array<MapStyleVariant>;
718
+ /**
719
+ * Get the defualt variant for this reference style
720
+ * @returns
721
+ */
722
+ getDefaultVariant(): MapStyleVariant;
723
+ }
724
+ /**
725
+ * All the styles and variants maintained by MapTiler.
726
+ */
727
+ type MapStyleType = {
728
+ /**
729
+ * Suitable for navigation, with high level of detail on urban areas, plenty of POIs and 3D buildings
730
+ */
731
+ STREETS: ReferenceMapStyle & {
732
+ /**
733
+ * Suitable for navigation, with high level of detail on urban areas, plenty of POIs and 3D buildings.
734
+ */
735
+ DEFAULT: MapStyleVariant;
736
+ /**
737
+ * Suitable for navigation, with high level of detail on urban areas, plenty of POIs and 3D buildings, in dark mode.
738
+ */
739
+ DARK: MapStyleVariant;
740
+ /**
741
+ * Suitable for navigation, with high level of detail on urban areas, plenty of POIs and 3D buildings, in light mode.
742
+ */
743
+ LIGHT: MapStyleVariant;
744
+ /**
745
+ * Suitable for navigation, with high level of detail on urban areas, plenty of POIs and 3D buildings, with a pastel color palette.
746
+ */
747
+ PASTEL: MapStyleVariant;
748
+ };
749
+ /**
750
+ * Suitable for outdoor activities. With elevation isolines and hillshading.
751
+ */
752
+ OUTDOOR: ReferenceMapStyle & {
753
+ /**
754
+ * Suitable for outdoor activities. With elevation isolines and hillshading.
755
+ */
756
+ DEFAULT: MapStyleVariant;
757
+ };
758
+ /**
759
+ * Suitabe for winter outdoor activities. With ski tracks, elevation isolines and hillshading.
760
+ */
761
+ WINTER: ReferenceMapStyle & {
762
+ /**
763
+ * Suitabe for winter outdoor activities. With ski tracks, elevation isolines and hillshading.
764
+ */
765
+ DEFAULT: MapStyleVariant;
766
+ };
767
+ /**
768
+ * High resolution imagery only, without any label.
769
+ */
770
+ SATELLITE: ReferenceMapStyle & {
771
+ /**
772
+ * High resolution imagery only, without any label.
773
+ */
774
+ DEFAULT: MapStyleVariant;
775
+ };
776
+ /**
777
+ * High resolution imagery with labels, political borders and roads.
778
+ */
779
+ HYBRID: ReferenceMapStyle & {
780
+ /**
781
+ * High resolution imagery with labels, political borders and roads.
782
+ */
783
+ DEFAULT: MapStyleVariant;
784
+ };
785
+ /**
786
+ * A minimalist street-oriented style without POI
787
+ */
788
+ BASIC: ReferenceMapStyle & {
789
+ /**
790
+ * A minimalist street-oriented style without POI
791
+ */
792
+ DEFAULT: MapStyleVariant;
793
+ /**
794
+ * A minimalist street-oriented style without POI, in dark mode
795
+ */
796
+ DARK: MapStyleVariant;
797
+ /**
798
+ * A minimalist street-oriented style without POI, in light mode
799
+ */
800
+ LIGHT: MapStyleVariant;
801
+ };
802
+ /**
803
+ * A bright street-oriented style, a nice alternative to `streets`
804
+ */
805
+ BRIGHT: ReferenceMapStyle & {
806
+ /**
807
+ * A bright street-oriented style, a nice alternative to `streets`
808
+ */
809
+ DEFAULT: MapStyleVariant;
810
+ /**
811
+ * A bright street-oriented style, a nice alternative to `streets`, in dark mode
812
+ */
813
+ DARK: MapStyleVariant;
814
+ /**
815
+ * A bright street-oriented style, a nice alternative to `streets`, in light mode
816
+ */
817
+ LIGHT: MapStyleVariant;
818
+ /**
819
+ * A bright street-oriented style, a nice alternative to `streets`, with a soft pastel color palette
820
+ */
821
+ PASTEL: MapStyleVariant;
822
+ };
823
+ /**
824
+ * Classic OpenStreetMap style
825
+ */
826
+ OPENSTREETMAP: ReferenceMapStyle & {
827
+ DEFAULT: MapStyleVariant;
828
+ };
829
+ /**
830
+ * A nice high-contrast, yet less saturated alternative to the `outdoor` style, with hillshading, 3D buildings and fairly high street details
831
+ */
832
+ TOPO: ReferenceMapStyle & {
833
+ /**
834
+ * A nice high-contrast, yet less saturated alternative to the `outdoor` style, with hillshading, 3D buildings and fairly high street details
835
+ */
836
+ DEFAULT: MapStyleVariant;
837
+ /**
838
+ * A nice high-contrast, and high saturation alternative to the `outdoor` style, with hillshading, 3D buildings and fairly high street details
839
+ */
840
+ SHINY: MapStyleVariant;
841
+ /**
842
+ * A nice low-contrast, alternative to the `outdoor` style, with hillshading, 3D buildings and fairly high street details, using a soft pastel color palette
843
+ */
844
+ PASTEL: MapStyleVariant;
845
+ /**
846
+ * A nice very high-contrast, yet less saturated alternative to the `outdoor` style, with hillshading, 3D buildings and fairly high street details
847
+ */
848
+ TOPOGRAPHIQUE: MapStyleVariant;
849
+ };
850
+ /**
851
+ * A nice alternative to `streets` with a soft color palette
852
+ */
853
+ VOYAGER: ReferenceMapStyle & {
854
+ /**
855
+ * A nice alternative to `streets` with a soft color palette
856
+ */
857
+ DEFAULT: MapStyleVariant;
858
+ /**
859
+ * A nice alternative to `streets`, in very dark mode
860
+ */
861
+ DARK: MapStyleVariant;
862
+ /**
863
+ * A nice alternative to `streets`, in light mode
864
+ */
865
+ LIGHT: MapStyleVariant;
866
+ /**
867
+ * A nice alternative to `streets` with a soft sepia color palette and vintage look
868
+ */
869
+ VINTAGE: MapStyleVariant;
870
+ };
871
+ /**
872
+ * A bold very high contrast black and white (no gray!) style for the city
873
+ */
874
+ TONER: ReferenceMapStyle & {
875
+ /**
876
+ * A bold very high contrast black and white (no gray!) style for the city
877
+ */
878
+ DEFAULT: MapStyleVariant;
879
+ /**
880
+ * A bold very high contrast black and white (no gray!) style for the city, without any label
881
+ */
882
+ BACKGROUND: MapStyleVariant;
883
+ /**
884
+ * A bold very high contrast, yet faded, style for the city
885
+ */
886
+ LITE: MapStyleVariant;
887
+ /**
888
+ * A bold very high contrast black and white (no gray!) style for the city, with no building, only roads!
889
+ */
890
+ LINES: MapStyleVariant;
891
+ };
892
+ /**
893
+ * Minimalist style, perfect for data visualization
894
+ */
895
+ STAGE: ReferenceMapStyle & {
896
+ /**
897
+ * Minimalist style, perfect for data visualization
898
+ */
899
+ DEFAULT: MapStyleVariant;
900
+ /**
901
+ * Minimalist style, perfect for data visualization in dark mode
902
+ */
903
+ DARK: MapStyleVariant;
904
+ /**
905
+ * Minimalist style, perfect for data visualization in light mode
906
+ */
907
+ LIGHT: MapStyleVariant;
908
+ };
909
+ /**
910
+ * Explore deep see trenches and mountains, with isolines and depth labels
911
+ */
912
+ OCEAN: ReferenceMapStyle & {
913
+ /**
914
+ * Explore deep see trenches and mountains, with isolines and depth labels
915
+ */
916
+ DEFAULT: MapStyleVariant;
917
+ };
918
+ };
919
+ declare const mapStylePresetList: Array<MapStylePreset>;
920
+ /**
921
+ * Contains all the reference map style created by MapTiler team as well as all the variants.
922
+ * For example, `MapStyle.STREETS` and the variants:
923
+ * - `MapStyle.STREETS.DARK`
924
+ * - `MapStyle.STREETS.LIGHT`
925
+ * - `MapStyle.STREETS.PASTEL`
926
+ *
927
+ */
928
+ declare const MapStyle: MapStyleType;
929
+
527
930
  /**
528
931
  * Base set of options that can be provided to all the types of static maps
529
932
  */
@@ -536,7 +939,7 @@ type StaticMapBaseOptions = {
536
939
  * Style of the map (not full style URL). Example: "winter", "streets-v2".
537
940
  * Default: `"streets-v2"`
538
941
  */
539
- style?: string;
942
+ style?: string | ReferenceMapStyle | MapStyleVariant;
540
943
  /**
541
944
  * Double the size of the static map image to support hiDPI/Retina monitors.
542
945
  * Default: `false`
@@ -699,4 +1102,4 @@ declare class ServiceError extends Error {
699
1102
  constructor(res: Response, customMessage?: string);
700
1103
  }
701
1104
 
702
- export { AutomaticStaticMapOptions, BoundedStaticMapOptions, CenteredStaticMapOptions, ClientConfig, CoordinateExport, CoordinateGrid, CoordinateId, CoordinateSearch, CoordinateSearchResult, CoordinateTransformResult, CoordinateTransformation, Coordinates, CoordinatesSearchOptions, CoordinatesTransformOptions, FeatureHierarchy, FetchFunction, GeocodingFeature, GeocodingOptions, GeocodingSearchResult, GeolocationInfoOptions, GeolocationResult, GetDataOptions, LanguageGeocoding, LanguageGeocodingString, ReverseGeocodingOptions, ServiceError, StaticMapBaseOptions, StaticMapMarker, XYZ, config, coordinates, data, geocoding, geolocation, staticMaps };
1105
+ export { AutomaticStaticMapOptions, BoundedStaticMapOptions, CenteredStaticMapOptions, ClientConfig, CoordinateExport, CoordinateGrid, CoordinateId, CoordinateSearch, CoordinateSearchResult, CoordinateTransformResult, CoordinateTransformation, Coordinates, CoordinatesSearchOptions, CoordinatesTransformOptions, FeatureHierarchy, FetchFunction, GeocodingFeature, GeocodingOptions, GeocodingSearchResult, GeolocationInfoOptions, GeolocationResult, GetDataOptions, LanguageGeocoding, LanguageGeocodingString, MapStyle, MapStylePreset, MapStyleType, MapStyleVariant, ReferenceMapStyle, ReverseGeocodingOptions, ServiceError, StaticMapBaseOptions, StaticMapMarker, XYZ, config, coordinates, data, expandMapStyle, geocoding, geolocation, mapStylePresetList, staticMaps };
@@ -1 +1 @@
1
- function j(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class E{constructor(){this._apiKey="",this._fetch=j()}set apiKey(e){this._apiKey=e}get apiKey(){return this._apiKey}set fetch(e){this._fetch=e}get fetch(){return this._fetch}}const g=new E,S={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"},T=new Set(Object.values(S));function L(){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=>T.has(e));return n.length?n[0]:S.ENGLISH}var O=(n,e,t)=>new Promise((s,r)=>{var o=i=>{try{c(t.next(i))}catch(l){r(l)}},a=i=>{try{c(t.throw(i))}catch(l){r(l)}},c=i=>i.done?s(i.value):Promise.resolve(i.value).then(o,a);c((t=t.apply(n,e)).next())});function k(n){return O(this,arguments,function*(e,t={}){if(g.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 g.fetch(e,t)})}const f={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(f);class I extends Error{constructor(e,t=""){super(`Call to enpoint ${e.url} failed with the status code ${e.status}. ${t}`),this.res=e}}var U=(n,e,t)=>new Promise((s,r)=>{var o=i=>{try{c(t.next(i))}catch(l){r(l)}},a=i=>{try{c(t.throw(i))}catch(l){r(l)}},c=i=>i.done?s(i.value):Promise.resolve(i.value).then(o,a);c((t=t.apply(n,e)).next())});const w={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function H(n){return U(this,arguments,function*(e,t={}){var s;if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const r=new URL(`geocoding/${encodeURIComponent(e)}.json`,f.maptilerApiURL);if(r.searchParams.set("key",(s=t.apiKey)!=null?s:g.apiKey),"bbox"in t&&r.searchParams.set("bbox",t.bbox.join(",")),"proximity"in t&&r.searchParams.set("proximity",t.proximity.join(",")),"language"in t){const c=Array.from(new Set((Array.isArray(t.language)?t.language:[t.language]).map(i=>i===S.AUTO?L():i))).join(",");r.searchParams.set("language",c)}const o=r.toString(),a=yield k(o);if(!a.ok)throw new I(a,a.status in w?w[a.status]:"");return yield a.json()})}function D(n){return U(this,arguments,function*(e,t={}){var s;if(!Array.isArray(e)||e.length<2)throw new Error("The position must be an array of form [lng, lat].");const r=new URL(`geocoding/${e[0]},${e[1]}.json`,f.maptilerApiURL);if(r.searchParams.set("key",(s=t.apiKey)!=null?s:g.apiKey),"language"in t){const c=Array.from(new Set((Array.isArray(t.language)?t.language:[t.language]).map(i=>i===S.AUTO?L():i))).join(",");r.searchParams.set("language",c)}const o=r.toString(),a=yield k(o);if(!a.ok)throw new I(a,a.status in w?w[a.status]:"");return yield a.json()})}const G={forward:H,reverse:D,language:S};var M=(n,e,t)=>new Promise((s,r)=>{var o=i=>{try{c(t.next(i))}catch(l){r(l)}},a=i=>{try{c(t.throw(i))}catch(l){r(l)}},c=i=>i.done?s(i.value):Promise.resolve(i.value).then(o,a);c((t=t.apply(n,e)).next())});const C={403:"Key is missing, invalid or restricted"};function _(){return M(this,arguments,function*(n={}){var e;const t=new URL("geolocation/ip.json",f.maptilerApiURL);t.searchParams.set("key",(e=n.apiKey)!=null?e:g.apiKey);const s=t.toString(),r=yield k(s);if(!r.ok)throw new I(r,r.status in C?C[r.status]:"");return yield r.json()})}const B={info:_};var K=(n,e,t)=>new Promise((s,r)=>{var o=i=>{try{c(t.next(i))}catch(l){r(l)}},a=i=>{try{c(t.throw(i))}catch(l){r(l)}},c=i=>i.done?s(i.value):Promise.resolve(i.value).then(o,a);c((t=t.apply(n,e)).next())});const $={403:"Key is missing, invalid or restricted"};function W(n){return K(this,arguments,function*(e,t={}){var s;if(typeof e!="string"||e.trim().length===0)throw new Error("The query must be a non-empty string");const r=new URL(`coordinates/search/${e}.json`,f.maptilerApiURL);r.searchParams.set("key",(s=t.apiKey)!=null?s:g.apiKey),"limit"in t&&r.searchParams.set("limit",t.limit.toString()),"transformations"in t&&r.searchParams.set("transformations",t.transformations.toString()),"exports"in t&&r.searchParams.set("exports",t.exports.toString());const o=r.toString(),a=yield k(o);if(!a.ok)throw new I(a,a.status in $?$[a.status]:"");return yield a.json()})}function F(n){return K(this,arguments,function*(e,t={}){var s;const r=(Array.isArray(e[0])?e:[e]).map(i=>`${i[0]},${i[1]}`).join(";"),o=new URL(`coordinates/transform/${r}.json`,f.maptilerApiURL);o.searchParams.set("key",(s=t.apiKey)!=null?s:g.apiKey),"sourceCrs"in t&&o.searchParams.set("s_srs",t.sourceCrs.toString()),"targetCrs"in t&&o.searchParams.set("t_srs",t.targetCrs.toString()),"operations"in t&&o.searchParams.set("ops",(Array.isArray(t.operations)?t.operations:[t.operations]).join("|"));const a=o.toString(),c=yield k(a);if(!c.ok)throw new I(c,c.status in $?$[c.status]:"");return yield c.json()})}const q={search:W,transform:F};var z=(n,e,t)=>new Promise((s,r)=>{var o=i=>{try{c(t.next(i))}catch(l){r(l)}},a=i=>{try{c(t.throw(i))}catch(l){r(l)}},c=i=>i.done?s(i.value):Promise.resolve(i.value).then(o,a);c((t=t.apply(n,e)).next())});const b={403:"Key is missing, invalid or restricted"};function J(n){return z(this,arguments,function*(e,t={}){var s;if(typeof e!="string"||e.trim().length===0)throw new Error("The data ID must be a non-empty string");const r=new URL(`data/${encodeURIComponent(e)}/features.json`,f.maptilerApiURL);r.searchParams.set("key",(s=t.apiKey)!=null?s:g.apiKey);const o=r.toString(),a=yield k(o);if(!a.ok)throw new I(a,a.status in b?b[a.status]:"");return yield a.json()})}const V={get:J};function Z(n,e,t){let s=e[0],r=e[1],o=t[0]-s,a=t[1]-r;if(o!==0||a!==0){const c=((n[0]-s)*o+(n[1]-r)*a)/(o*o+a*a);c>1?(s=t[0],r=t[1]):c>0&&(s+=o*c,r+=a*c)}return o=n[0]-s,a=n[1]-r,o*o+a*a}function N(n,e,t,s,r){let o=s,a;for(let c=e+1;c<t;c++){const i=Z(n[c],n[e],n[t]);i>o&&(a=c,o=i)}o>s&&(a-e>1&&N(n,e,a,s,r),r.push(n[a]),t-a>1&&N(n,a,t,s,r))}function Q(n,e){const t=n.length-1,s=[n[0]];return N(n,0,t,e,s),s.push(n[t]),s}function X(n,e){if(n.length<=2)return n;const t=e!==void 0?e*e:1;return Q(n,t)}function R(n,e=!0){let t=`${n[0]},${n[1]}`;return n.length===3&&e&&(t+=`,${n[2]}`),t}function v(n,e=3e3){let t=n.map(o=>o.join(",")).join("|"),s=5e-6;const r=1e-5;for(;t.length>e;)t=X(n,s).map(o=>`${o[0]},${o[1]}`).join("|"),s+=r;return t}function Y(n,e,t={}){var s,r,o,a,c,i;const l=(s=t.style)!=null?s:f.mapStyle,d=t.hiDPI?"@2x":"",A=(r=t.format)!=null?r:"png";let p=~~((o=t.width)!=null?o:1024),u=~~((a=t.height)!=null?a:1024);t.hiDPI&&(p=~~(p/2),u=~~(u/2));const h=new URL(`maps/${encodeURIComponent(l)}/static/${n[0]},${n[1]},${e}/${p}x${u}${d}.${A}`,f.maptilerApiURL);if("attribution"in t&&h.searchParams.set("attribution",t.attribution.toString()),"markers"in t){let m="";const y="markerIcon"in t;y&&(m+=`icon:${t.markerIcon}|`),y&&"markerAnchor"in t&&(m+=`anchor:${t.markerAnchor}|`),y&&t.hiDPI&&(m+="scale:2|");const P=Array.isArray(t.markers[0])?t.markers:[t.markers];m+=P.map(x=>R(x,!y)).join("|"),h.searchParams.set("markers",m)}if("path"in t){let m="";if(m+=`fill:${(c=t.pathFillColor)!=null?c:"none"}|`,"pathStrokeColor"in t&&(m+=`stroke:${t.pathStrokeColor}|`),"pathWidth"in t){const y=t.pathWidth/(t.hiDPI?2:1);m+=`width:${y.toString()}|`}m+=v(t.path),h.searchParams.set("path",m)}return h.searchParams.set("key",(i=t.apiKey)!=null?i:g.apiKey),h.toString()}function tt(n,e={}){var t,s,r,o,a,c;const i=(t=e.style)!=null?t:f.mapStyle,l=e.hiDPI?"@2x":"",d=(s=e.format)!=null?s:"png";let A=~~((r=e.width)!=null?r:1024),p=~~((o=e.height)!=null?o:1024);e.hiDPI&&(A=~~(A/2),p=~~(p/2));const u=new URL(`maps/${encodeURIComponent(i)}/static/${n[0]},${n[1]},${n[2]},${n[3]}/${A}x${p}${l}.${d}`,f.maptilerApiURL);if("attribution"in e&&u.searchParams.set("attribution",e.attribution.toString()),"padding"in e&&u.searchParams.set("padding",e.padding.toString()),"markers"in e){let h="";const m="markerIcon"in e;m&&(h+=`icon:${e.markerIcon}|`),m&&"markerAnchor"in e&&(h+=`anchor:${e.markerAnchor}|`),m&&e.hiDPI&&(h+="scale:2|");const y=Array.isArray(e.markers[0])?e.markers:[e.markers];h+=y.map(P=>R(P,!m)).join("|"),u.searchParams.set("markers",h)}if("path"in e){let h="";if(h+=`fill:${(a=e.pathFillColor)!=null?a:"none"}|`,"pathStrokeColor"in e&&(h+=`stroke:${e.pathStrokeColor}|`),"pathWidth"in e){const m=e.pathWidth/(e.hiDPI?2:1);h+=`width:${m.toString()}|`}h+=v(e.path),u.searchParams.set("path",h)}return u.searchParams.set("key",(c=e.apiKey)!=null?c:g.apiKey),u.toString()}function et(n={}){var e,t,s,r,o,a;if(!("markers"in n)&&!("path"in n))throw new Error("Automatic static maps require markers and/or path to be created.");const c=(e=n.style)!=null?e:f.mapStyle,i=n.hiDPI?"@2x":"",l=(t=n.format)!=null?t:"png";let d=~~((s=n.width)!=null?s:1024),A=~~((r=n.height)!=null?r:1024);n.hiDPI&&(d=~~(d/2),A=~~(A/2));const p=new URL(`maps/${encodeURIComponent(c)}/static/auto/${d}x${A}${i}.${l}`,f.maptilerApiURL);if("attribution"in n&&p.searchParams.set("attribution",n.attribution.toString()),"padding"in n&&p.searchParams.set("padding",n.padding.toString()),"markers"in n){let u="";const h="markerIcon"in n;h&&(u+=`icon:${n.markerIcon}|`),h&&"markerAnchor"in n&&(u+=`anchor:${n.markerAnchor}|`),h&&n.hiDPI&&(u+="scale:2|");const m=Array.isArray(n.markers[0])?n.markers:[n.markers];u+=m.map(y=>R(y,!h)).join("|"),p.searchParams.set("markers",u)}if("path"in n){let u="";if(u+=`fill:${(o=n.pathFillColor)!=null?o:"none"}|`,"pathStrokeColor"in n&&(u+=`stroke:${n.pathStrokeColor}|`),"pathWidth"in n){const h=n.pathWidth/(n.hiDPI?2:1);u+=`width:${h.toString()}|`}u+=v(n.path),p.searchParams.set("path",u)}return p.searchParams.set("key",(a=n.apiKey)!=null?a:g.apiKey),p.toString()}const nt={centered:Y,bounded:tt,automatic:et};export{E as ClientConfig,S as LanguageGeocoding,I as ServiceError,g as config,q as coordinates,V as data,G as geocoding,B as geolocation,nt as staticMaps};
1
+ function V(){return typeof self<"u"?fetch.bind(self):typeof global<"u"&&global.fetch?global.fetch:null}class w{constructor(){this._apiKey="",this._fetch=V()}set apiKey(t){this._apiKey=t}get apiKey(){return this._apiKey}set fetch(t){this._fetch=t}get fetch(){return this._fetch}}const u=new w,A={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"},G=new Set(Object.values(A));function N(){if(typeof navigator>"u")return Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];const r=Array.from(new Set(navigator.languages.map(t=>t.split("-")[0]))).filter(t=>G.has(t));return r.length?r[0]:A.ENGLISH}var F=(r,t,e)=>new Promise((a,n)=>{var s=o=>{try{c(e.next(o))}catch(l){n(l)}},i=o=>{try{c(e.throw(o))}catch(l){n(l)}},c=o=>o.done?a(o.value):Promise.resolve(o.value).then(s,i);c((e=e.apply(r,t)).next())});function S(r){return F(this,arguments,function*(t,e={}){if(u.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 u.fetch(t,e)})}const y={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(y);class v extends Error{constructor(t,e=""){super(`Call to enpoint ${t.url} failed with the status code ${t.status}. ${e}`),this.res=t}}var b=(r,t,e)=>new Promise((a,n)=>{var s=o=>{try{c(e.next(o))}catch(l){n(l)}},i=o=>{try{c(e.throw(o))}catch(l){n(l)}},c=o=>o.done?a(o.value):Promise.resolve(o.value).then(s,i);c((e=e.apply(r,t)).next())});const I={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function B(r){return b(this,arguments,function*(t,e={}){var a;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);if(n.searchParams.set("key",(a=e.apiKey)!=null?a:u.apiKey),"bbox"in e&&n.searchParams.set("bbox",e.bbox.join(",")),"proximity"in e&&n.searchParams.set("proximity",e.proximity.join(",")),"language"in e){const c=Array.from(new Set((Array.isArray(e.language)?e.language:[e.language]).map(o=>o===A.AUTO?N():o))).join(",");n.searchParams.set("language",c)}const s=n.toString(),i=yield S(s);if(!i.ok)throw new v(i,i.status in I?I[i.status]:"");return yield i.json()})}function M(r){return b(this,arguments,function*(t,e={}){var a;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);if(n.searchParams.set("key",(a=e.apiKey)!=null?a:u.apiKey),"language"in e){const c=Array.from(new Set((Array.isArray(e.language)?e.language:[e.language]).map(o=>o===A.AUTO?N():o))).join(",");n.searchParams.set("language",c)}const s=n.toString(),i=yield S(s);if(!i.ok)throw new v(i,i.status in I?I[i.status]:"");return yield i.json()})}const W={forward:B,reverse:M,language:A};var _=(r,t,e)=>new Promise((a,n)=>{var s=o=>{try{c(e.next(o))}catch(l){n(l)}},i=o=>{try{c(e.throw(o))}catch(l){n(l)}},c=o=>o.done?a(o.value):Promise.resolve(o.value).then(s,i);c((e=e.apply(r,t)).next())});const C={403:"Key is missing, invalid or restricted"};function q(){return _(this,arguments,function*(r={}){var t;const e=new URL("geolocation/ip.json",y.maptilerApiURL);e.searchParams.set("key",(t=r.apiKey)!=null?t:u.apiKey);const a=e.toString(),n=yield S(a);if(!n.ok)throw new v(n,n.status in C?C[n.status]:"");return yield n.json()})}const Y={info:q};var K=(r,t,e)=>new Promise((a,n)=>{var s=o=>{try{c(e.next(o))}catch(l){n(l)}},i=o=>{try{c(e.throw(o))}catch(l){n(l)}},c=o=>o.done?a(o.value):Promise.resolve(o.value).then(s,i);c((e=e.apply(r,t)).next())});const L={403:"Key is missing, invalid or restricted"};function z(r){return K(this,arguments,function*(t,e={}){var a;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",(a=e.apiKey)!=null?a:u.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 s=n.toString(),i=yield S(s);if(!i.ok)throw new v(i,i.status in L?L[i.status]:"");return yield i.json()})}function J(r){return K(this,arguments,function*(t,e={}){var a;const n=(Array.isArray(t[0])?t:[t]).map(o=>`${o[0]},${o[1]}`).join(";"),s=new URL(`coordinates/transform/${n}.json`,y.maptilerApiURL);s.searchParams.set("key",(a=e.apiKey)!=null?a:u.apiKey),"sourceCrs"in e&&s.searchParams.set("s_srs",e.sourceCrs.toString()),"targetCrs"in e&&s.searchParams.set("t_srs",e.targetCrs.toString()),"operations"in e&&s.searchParams.set("ops",(Array.isArray(e.operations)?e.operations:[e.operations]).join("|"));const i=s.toString(),c=yield S(i);if(!c.ok)throw new v(c,c.status in L?L[c.status]:"");return yield c.json()})}const Z={search:z,transform:J};var Q=(r,t,e)=>new Promise((a,n)=>{var s=o=>{try{c(e.next(o))}catch(l){n(l)}},i=o=>{try{c(e.throw(o))}catch(l){n(l)}},c=o=>o.done?a(o.value):Promise.resolve(o.value).then(s,i);c((e=e.apply(r,t)).next())});const O={403:"Key is missing, invalid or restricted"};function X(r){return Q(this,arguments,function*(t,e={}){var a;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",(a=e.apiKey)!=null?a:u.apiKey);const s=n.toString(),i=yield S(s);if(!i.ok)throw new v(i,i.status in O?O[i.status]:"");return yield i.json()})}const ee={get:X};function x(r){const t=/^maptiler:\/\/(.*)/;let e;const a=r.trim();let n;return a.startsWith("http://")||a.startsWith("https://")?n=a:(e=t.exec(a))!==null?n=`https://api.maptiler.com/maps/${e[1]}/style.json`:n=`https://api.maptiler.com/maps/${a}/style.json`,n}class U{constructor(t,e,a,n,s,i){this.name=t,this.variantType=e,this.id=a,this.referenceStyle=n,this.description=s,this.imageURL=i}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(t){return this.referenceStyle.hasVariant(t)}getVariant(t){return this.referenceStyle.getVariant(t)}getVariants(){return this.referenceStyle.getVariants().filter(t=>t!==this)}getImageURL(){return this.imageURL}getExpandedStyleURL(){return x(this.getId())}}class k{constructor(t,e){this.name=t,this.id=e,this.variants={},this.orderedVariants=[]}getName(){return this.name}getId(){return this.id}addVariant(t){this.variants[t.getType()]=t,this.orderedVariants.push(t)}hasVariant(t){return t in this.variants}getVariant(t){return t in this.variants?this.variants[t]:this.orderedVariants[0]}getVariants(){return Object.values(this.variants)}getDefaultVariant(){return this.orderedVariants[0]}}const R=[{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-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OUTDOOR",name:"Outdoor",description:"",variants:[{id:"outdoor-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"WINTER",name:"Winter",description:"",variants:[{id:"winter-v2",name:"Winter",variantType:"DEFAULT",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-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:"STAGE",name:"Stage",description:"",variants:[{id:"stage",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"stage-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"stage-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"OCEAN",name:"Ocean",description:"",variants:[{id:"ocean",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]}];function te(r){return new Proxy(r,{get(t,e,a){return t.hasVariant(e)?t.getVariant(e):e.toString().toUpperCase()===e?r.getDefaultVariant():Reflect.get(t,e,a)}})}function re(){const r={};for(let t=0;t<R.length;t+=1){const e=R[t],a=te(new k(e.name,e.referenceStyleID));for(let n=0;n<e.variants.length;n+=1){const s=e.variants[n],i=new U(s.name,s.variantType,s.id,a,s.description,s.imageURL);a.addVariant(i)}r[e.referenceStyleID]=a}return r}function D(r){if(!r)return H[R[0].referenceStyleID].getDefaultVariant().getId();if(typeof r=="string"||r instanceof String)return r.trim().toLowerCase();if(r instanceof U)return r.getId();if(r instanceof k)return r.getDefaultVariant().getId()}const H=re();function ne(r,t,e){let a=t[0],n=t[1],s=e[0]-a,i=e[1]-n;if(s!==0||i!==0){const c=((r[0]-a)*s+(r[1]-n)*i)/(s*s+i*i);c>1?(a=e[0],n=e[1]):c>0&&(a+=s*c,n+=i*c)}return s=r[0]-a,i=r[1]-n,s*s+i*i}function E(r,t,e,a,n){let s=a,i;for(let c=t+1;c<e;c++){const o=ne(r[c],r[t],r[e]);o>s&&(i=c,s=o)}s>a&&(i-t>1&&E(r,t,i,a,n),n.push(r[i]),e-i>1&&E(r,i,e,a,n))}function ae(r,t){const e=r.length-1,a=[r[0]];return E(r,0,e,t,a),a.push(r[e]),a}function ie(r,t){if(r.length<=2)return r;const e=t!==void 0?t*t:1;return ae(r,e)}function P(r,t=!0){let e=`${r[0]},${r[1]}`;return r.length===3&&t&&(e+=`,${r[2]}`),e}function $(r,t=3e3){let e=r.map(s=>s.join(",")).join("|"),a=5e-6;const n=1e-5;for(;e.length>t;)e=ie(r,a).map(s=>`${s[0]},${s[1]}`).join("|"),a+=n;return e}function se(r,t,e={}){var a,n,s,i,c;const o=D(e.style),l=e.hiDPI?"@2x":"",f=(a=e.format)!=null?a:"png";let g=~~((n=e.width)!=null?n:1024),m=~~((s=e.height)!=null?s:1024);e.hiDPI&&(g=~~(g/2),m=~~(m/2));const p=new URL(`maps/${encodeURIComponent(o)}/static/${r[0]},${r[1]},${t}/${g}x${m}${l}.${f}`,y.maptilerApiURL);if("attribution"in e&&p.searchParams.set("attribution",e.attribution.toString()),"markers"in e){let h="";const d="markerIcon"in e;d&&(h+=`icon:${e.markerIcon}|`),d&&"markerAnchor"in e&&(h+=`anchor:${e.markerAnchor}|`),d&&e.hiDPI&&(h+="scale:2|");const T=Array.isArray(e.markers[0])?e.markers:[e.markers];h+=T.map(j=>P(j,!d)).join("|"),p.searchParams.set("markers",h)}if("path"in e){let h="";if(h+=`fill:${(i=e.pathFillColor)!=null?i:"none"}|`,"pathStrokeColor"in e&&(h+=`stroke:${e.pathStrokeColor}|`),"pathWidth"in e){const d=e.pathWidth/(e.hiDPI?2:1);h+=`width:${d.toString()}|`}h+=$(e.path),p.searchParams.set("path",h)}return p.searchParams.set("key",(c=e.apiKey)!=null?c:u.apiKey),p.toString()}function oe(r,t={}){var e,a,n,s,i;const c=D(t.style),o=t.hiDPI?"@2x":"",l=(e=t.format)!=null?e:"png";let f=~~((a=t.width)!=null?a:1024),g=~~((n=t.height)!=null?n:1024);t.hiDPI&&(f=~~(f/2),g=~~(g/2));const m=new URL(`maps/${encodeURIComponent(c)}/static/${r[0]},${r[1]},${r[2]},${r[3]}/${f}x${g}${o}.${l}`,y.maptilerApiURL);if("attribution"in t&&m.searchParams.set("attribution",t.attribution.toString()),"padding"in t&&m.searchParams.set("padding",t.padding.toString()),"markers"in t){let p="";const h="markerIcon"in t;h&&(p+=`icon:${t.markerIcon}|`),h&&"markerAnchor"in t&&(p+=`anchor:${t.markerAnchor}|`),h&&t.hiDPI&&(p+="scale:2|");const d=Array.isArray(t.markers[0])?t.markers:[t.markers];p+=d.map(T=>P(T,!h)).join("|"),m.searchParams.set("markers",p)}if("path"in t){let p="";if(p+=`fill:${(s=t.pathFillColor)!=null?s:"none"}|`,"pathStrokeColor"in t&&(p+=`stroke:${t.pathStrokeColor}|`),"pathWidth"in t){const h=t.pathWidth/(t.hiDPI?2:1);p+=`width:${h.toString()}|`}p+=$(t.path),m.searchParams.set("path",p)}return m.searchParams.set("key",(i=t.apiKey)!=null?i:u.apiKey),m.toString()}function ce(r={}){var t,e,a,n,s;if(!("markers"in r)&&!("path"in r))throw new Error("Automatic static maps require markers and/or path to be created.");const i=D(r.style),c=r.hiDPI?"@2x":"",o=(t=r.format)!=null?t:"png";let l=~~((e=r.width)!=null?e:1024),f=~~((a=r.height)!=null?a:1024);r.hiDPI&&(l=~~(l/2),f=~~(f/2));const g=new URL(`maps/${encodeURIComponent(i)}/static/auto/${l}x${f}${c}.${o}`,y.maptilerApiURL);if("attribution"in r&&g.searchParams.set("attribution",r.attribution.toString()),"padding"in r&&g.searchParams.set("padding",r.padding.toString()),"markers"in r){let m="";const p="markerIcon"in r;p&&(m+=`icon:${r.markerIcon}|`),p&&"markerAnchor"in r&&(m+=`anchor:${r.markerAnchor}|`),p&&r.hiDPI&&(m+="scale:2|");const h=Array.isArray(r.markers[0])?r.markers:[r.markers];m+=h.map(d=>P(d,!p)).join("|"),g.searchParams.set("markers",m)}if("path"in r){let m="";if(m+=`fill:${(n=r.pathFillColor)!=null?n:"none"}|`,"pathStrokeColor"in r&&(m+=`stroke:${r.pathStrokeColor}|`),"pathWidth"in r){const p=r.pathWidth/(r.hiDPI?2:1);m+=`width:${p.toString()}|`}m+=$(r.path),g.searchParams.set("path",m)}return g.searchParams.set("key",(s=r.apiKey)!=null?s:u.apiKey),g.toString()}const le={centered:se,bounded:oe,automatic:ce};export{w as ClientConfig,A as LanguageGeocoding,H as MapStyle,U as MapStyleVariant,k as ReferenceMapStyle,v as ServiceError,u as config,Z as coordinates,ee as data,x as expandMapStyle,W as geocoding,Y as geolocation,R as mapStylePresetList,le as staticMaps};