Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mapbox/search-js-core

Package Overview
Dependencies
Maintainers
28
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mapbox/search-js-core - npm Package Compare versions

Comparing version 1.0.0-beta.14 to 1.0.0-beta.15

.turbo/turbo-test.log

33

dist/autofill/MapboxAutofill.d.ts

@@ -34,31 +34,16 @@ import { AutofillSuggestion, AutofillFeatureSuggestion } from './types';

/**
* @typedef AutofillOptions
* Options used by {@link MapboxAutofill} and {@link useMapboxAutofill} to control the location, language, country, and limit of results. All properties are optional.
*
* @typedef {Object} AutofillOptions
* @property {string} language The [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) to be returned. If not specified, `en` will be used.
* @property {string} country An [ISO 3166 alpha-2 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) to be returned. If not specified, results will not be filtered by country.
* @property {string | LatLngBoundsLike} bbox Limit results to only those contained within the supplied bounding box.
* @property {string | number} limit The number of results to return, up to `10`.
* @property {string | LngLatLike} proximity Bias the response to favor results that are closer to this location. Provide a point coordinate provided as a{@link LngLatLike}, or use the string `ip` to use the requester's IP address.
*/
export interface AutofillOptions {
/**
* The [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) to be returned.
*
* If not specified, `en` will be used.
*/
language: string;
/**
* An [ISO 3166 alpha-2 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) to be returned.
*
* If not specified, results will not be filtered by country.
*/
country: string;
/**
* Limit results to only those contained within the supplied bounding box.
*/
bbox: string | LngLatBoundsLike;
/**
* The number of results to return, up to `10`.
*/
limit: string | number;
/**
* Bias the response to favor results that are closer to this location.
*
* When both {@link AutofillOptions#proximity} and {@link AutofillOptions#origin} are specified, `origin` is interpreted as the
* target of a route, while `proximity` indicates the current user location.
*/
proximity: string | LngLatLike;

@@ -80,2 +65,3 @@ }

suggestions: AutofillSuggestion[];
url: string;
}

@@ -97,2 +83,3 @@ /**

features: AutofillFeatureSuggestion[];
url: string;
}

@@ -99,0 +86,0 @@ /**

@@ -117,2 +117,3 @@ import { LngLatLike } from '../LngLat';

attribution: string;
url: string;
}

@@ -119,0 +120,0 @@ /**

@@ -107,2 +107,3 @@ var __defProp = Object.defineProperty;

MatchCodeConfidence: () => MatchCodeConfidence,
SearchBoxCore: () => SearchBoxCore,
SearchSession: () => SearchSession,

@@ -338,2 +339,3 @@ SessionToken: () => SessionToken,

const json = yield res.json();
json.url = url.toString();
return json;

@@ -363,2 +365,3 @@ });

const json = yield res.json();
json.url = url.toString();
return json;

@@ -467,4 +470,4 @@ });

// src/autofill/constants.ts
var SEARCH_URL2 = `https://api.mapbox.com/autofill/v1`;
// src/searchbox/constants.ts
var SEARCH_URL2 = `https://api.mapbox.com/search/searchbox/v1`;
var ENDPOINT_SUGGEST2 = "suggest";

@@ -475,5 +478,5 @@ var ENDPOINT_RETRIEVE2 = "retrieve";

// src/autofill/MapboxAutofill.ts
// src/searchbox/SearchBoxCore.ts
var _getQueryParams2, getQueryParams_fn2;
var _MapboxAutofill = class {
var _SearchBoxCore = class {
constructor(options = {}) {

@@ -483,3 +486,3 @@ __privateAdd(this, _getQueryParams2);

this.accessToken = accessToken;
this.defaults = __spreadValues(__spreadValues({}, _MapboxAutofill.defaults), defaults);
this.defaults = __spreadValues(__spreadValues({}, _SearchBoxCore.defaults), defaults);
}

@@ -493,5 +496,12 @@ suggest(searchText, optionsArg) {

const options = __spreadProps(__spreadValues(__spreadValues({}, this.defaults), optionsArg), {
q: searchText,
sessionToken
});
const url = new URL(`${SUGGEST_URL2}/${encodeURIComponent(searchText)}`);
if (options.eta_type && (!options.origin || !options.navigation_profile)) {
throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");
}
if (options.origin && !options.navigation_profile) {
throw new Error("to provide distance estimate: both navigation_profile and origin are required");
}
const url = new URL(SUGGEST_URL2);
url.search = __privateMethod(this, _getQueryParams2, getQueryParams_fn2).call(this, options);

@@ -504,2 +514,98 @@ const { fetch } = getFetch();

const json = yield res.json();
json.url = url.toString();
return json;
});
}
retrieve(suggestion, optionsArg) {
return __async(this, null, function* () {
if (!suggestion) {
throw new Error("suggestion is required");
}
const { sessionToken: sessionTokenLike, signal } = optionsArg;
const sessionToken = SessionToken.convert(sessionTokenLike);
const url = new URL(`${RETRIEVE_URL2}/${encodeURIComponent(suggestion.mapbox_id)}`);
url.search = queryParams({
access_token: this.accessToken,
session_token: sessionToken.id
});
const { fetch } = getFetch();
const res = yield fetch(url.toString(), {
signal
});
yield handleNonOkRes(res);
const json = yield res.json();
json.url = url.toString();
return json;
});
}
};
var SearchBoxCore = _SearchBoxCore;
_getQueryParams2 = new WeakSet();
getQueryParams_fn2 = function(options) {
return queryParams({
q: options.q,
access_token: this.accessToken,
language: options.language,
limit: options.limit,
navigation_profile: options.navigation_profile,
route: options.route,
route_geometry: options.route_geometry,
sar_type: options.sar_type,
time_deviation: options.time_deviation,
eta_type: options.eta_type,
country: options.country,
poi_category: options.poi_category,
radius: options.radius,
user_id: options.user_id,
rich_metadata_provider: options.rich_metadata_provider,
poi_category_exclusions: options.poi_category_exclusions
}, options.sessionToken && {
session_token: SessionToken.convert(options.sessionToken).id
}, options.proximity && {
proximity: typeof options.proximity === "string" ? options.proximity : LngLat.convert(options.proximity).toArray().join(",")
}, options.origin && {
origin: typeof options.origin === "string" ? options.origin : LngLat.convert(options.origin).toArray().join(",")
}, options.bbox && {
bbox: typeof options.bbox === "string" ? options.bbox : LngLatBounds.convert(options.bbox).toFlatArray().join(",")
}, options.types && {
types: typeof options.types === "string" ? options.types : [...options.types].join(",")
});
};
SearchBoxCore.defaults = {
language: "en"
};
// src/autofill/constants.ts
var SEARCH_URL3 = `https://api.mapbox.com/autofill/v1`;
var ENDPOINT_SUGGEST3 = "suggest";
var ENDPOINT_RETRIEVE3 = "retrieve";
var SUGGEST_URL3 = `${SEARCH_URL3}/${ENDPOINT_SUGGEST3}`;
var RETRIEVE_URL3 = `${SEARCH_URL3}/${ENDPOINT_RETRIEVE3}`;
// src/autofill/MapboxAutofill.ts
var _getQueryParams3, getQueryParams_fn3;
var _MapboxAutofill = class {
constructor(options = {}) {
__privateAdd(this, _getQueryParams3);
const _a = options, { accessToken } = _a, defaults = __objRest(_a, ["accessToken"]);
this.accessToken = accessToken;
this.defaults = __spreadValues(__spreadValues({}, _MapboxAutofill.defaults), defaults);
}
suggest(searchText, optionsArg) {
return __async(this, null, function* () {
if (!searchText) {
throw new Error("searchText is required");
}
const { sessionToken, signal } = optionsArg;
const options = __spreadProps(__spreadValues(__spreadValues({}, this.defaults), optionsArg), {
sessionToken
});
const url = new URL(`${SUGGEST_URL3}/${encodeURIComponent(searchText)}`);
url.search = __privateMethod(this, _getQueryParams3, getQueryParams_fn3).call(this, options);
const { fetch } = getFetch();
const res = yield fetch(url.toString(), {
signal
});
yield handleNonOkRes(res);
const json = yield res.json();
return __spreadProps(__spreadValues({}, json), {

@@ -510,3 +616,4 @@ suggestions: json.suggestions.map((suggestion) => {

});
})
}),
url: url.toString()
});

@@ -525,3 +632,3 @@ });

const sessionToken = SessionToken.convert(sessionTokenLike);
const url = new URL(`${RETRIEVE_URL2}/${suggestion.action.id}`);
const url = new URL(`${RETRIEVE_URL3}/${suggestion.action.id}`);
url.search = queryParams({

@@ -535,2 +642,3 @@ access_token: this.accessToken,

const json = yield res.json();
json.url = url.toString();
return json;

@@ -545,4 +653,4 @@ });

var MapboxAutofill = _MapboxAutofill;
_getQueryParams2 = new WeakSet();
getQueryParams_fn2 = function(options) {
_getQueryParams3 = new WeakSet();
getQueryParams_fn3 = function(options) {
return queryParams({

@@ -569,11 +677,11 @@ types: "address",

// src/validate/constants.ts
var SEARCH_URL3 = `https://api.mapbox.com/autofill/v1`;
var SEARCH_URL4 = `https://api.mapbox.com/autofill/v1`;
var ENDPOINT_VALIDATE = "retrieve";
var VALIDATE_URL = `${SEARCH_URL3}/${ENDPOINT_VALIDATE}`;
var VALIDATE_URL = `${SEARCH_URL4}/${ENDPOINT_VALIDATE}`;
// src/validate/MapboxValidate.ts
var _getQueryParams3, getQueryParams_fn3;
var _getQueryParams4, getQueryParams_fn4;
var _MapboxValidate = class {
constructor(options = {}) {
__privateAdd(this, _getQueryParams3);
__privateAdd(this, _getQueryParams4);
const _a = options, { accessToken } = _a, defaults = __objRest(_a, ["accessToken"]);

@@ -593,3 +701,3 @@ this.accessToken = accessToken;

const url = new URL(`${VALIDATE_URL}/${encodeURIComponent(searchText)}`);
url.search = __privateMethod(this, _getQueryParams3, getQueryParams_fn3).call(this, options);
url.search = __privateMethod(this, _getQueryParams4, getQueryParams_fn4).call(this, options);
const { fetch } = getFetch();

@@ -601,2 +709,3 @@ const res = yield fetch(url.toString(), {

const json = yield res.json();
json.url = url.toString();
if (json.features.length > 0) {

@@ -610,4 +719,4 @@ json.features = [json.features[0]];

var MapboxValidate = _MapboxValidate;
_getQueryParams3 = new WeakSet();
getQueryParams_fn3 = function(options) {
_getQueryParams4 = new WeakSet();
getQueryParams_fn4 = function(options) {
return queryParams({

@@ -631,11 +740,11 @@ access_token: this.accessToken,

// src/geocode/constants.ts
var SEARCH_URL4 = `https://api.mapbox.com/geocoding/v5`;
var TEMP_URL = `${SEARCH_URL4}/mapbox.places`;
var PERMANENT_URL = `${SEARCH_URL4}/mapbox.places-permanent`;
var SEARCH_URL5 = `https://api.mapbox.com/geocoding/v5`;
var TEMP_URL = `${SEARCH_URL5}/mapbox.places`;
var PERMANENT_URL = `${SEARCH_URL5}/mapbox.places-permanent`;
// src/geocode/MapboxGeocode.ts
var _getQueryParams4, getQueryParams_fn4;
var _getQueryParams5, getQueryParams_fn5;
var MapboxGeocode = class {
constructor(options = {}) {
__privateAdd(this, _getQueryParams4);
__privateAdd(this, _getQueryParams5);
const _a = options, { accessToken } = _a, defaults = __objRest(_a, ["accessToken"]);

@@ -657,3 +766,3 @@ this.accessToken = accessToken;

const url = new URL(`${baseUrl}/${encodeURIComponent(searchText)}.json`);
url.search = __privateMethod(this, _getQueryParams4, getQueryParams_fn4).call(this, options);
url.search = __privateMethod(this, _getQueryParams5, getQueryParams_fn5).call(this, options);
const { fetch } = getFetch();

@@ -664,2 +773,3 @@ const fetchInit = signal ? { signal } : {};

const json = yield res.json();
json.url = url.toString();
return json;

@@ -681,3 +791,3 @@ });

const url = new URL(`${baseUrl}/${encodeURIComponent(searchText)}.json`);
url.search = __privateMethod(this, _getQueryParams4, getQueryParams_fn4).call(this, options, true);
url.search = __privateMethod(this, _getQueryParams5, getQueryParams_fn5).call(this, options, true);
const { fetch } = getFetch();

@@ -688,2 +798,3 @@ const fetchInit = signal ? { signal } : {};

const json = yield res.json();
json.url = url.toString();
return json;

@@ -693,4 +804,4 @@ });

};
_getQueryParams4 = new WeakSet();
getQueryParams_fn4 = function(options, isReverse = false) {
_getQueryParams5 = new WeakSet();
getQueryParams_fn5 = function(options, isReverse = false) {
if (isReverse) {

@@ -697,0 +808,0 @@ ["proximity", "autocomplete", "fuzzyMatch", "bbox"].forEach((key) => {

@@ -298,2 +298,3 @@ var __defProp = Object.defineProperty;

const json = yield res.json();
json.url = url.toString();
return json;

@@ -323,2 +324,3 @@ });

const json = yield res.json();
json.url = url.toString();
return json;

@@ -427,4 +429,4 @@ });

// src/autofill/constants.ts
var SEARCH_URL2 = `https://api.mapbox.com/autofill/v1`;
// src/searchbox/constants.ts
var SEARCH_URL2 = `https://api.mapbox.com/search/searchbox/v1`;
var ENDPOINT_SUGGEST2 = "suggest";

@@ -435,5 +437,5 @@ var ENDPOINT_RETRIEVE2 = "retrieve";

// src/autofill/MapboxAutofill.ts
// src/searchbox/SearchBoxCore.ts
var _getQueryParams2, getQueryParams_fn2;
var _MapboxAutofill = class {
var _SearchBoxCore = class {
constructor(options = {}) {

@@ -443,3 +445,3 @@ __privateAdd(this, _getQueryParams2);

this.accessToken = accessToken;
this.defaults = __spreadValues(__spreadValues({}, _MapboxAutofill.defaults), defaults);
this.defaults = __spreadValues(__spreadValues({}, _SearchBoxCore.defaults), defaults);
}

@@ -453,5 +455,12 @@ suggest(searchText, optionsArg) {

const options = __spreadProps(__spreadValues(__spreadValues({}, this.defaults), optionsArg), {
q: searchText,
sessionToken
});
const url = new URL(`${SUGGEST_URL2}/${encodeURIComponent(searchText)}`);
if (options.eta_type && (!options.origin || !options.navigation_profile)) {
throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");
}
if (options.origin && !options.navigation_profile) {
throw new Error("to provide distance estimate: both navigation_profile and origin are required");
}
const url = new URL(SUGGEST_URL2);
url.search = __privateMethod(this, _getQueryParams2, getQueryParams_fn2).call(this, options);

@@ -464,2 +473,98 @@ const { fetch } = getFetch();

const json = yield res.json();
json.url = url.toString();
return json;
});
}
retrieve(suggestion, optionsArg) {
return __async(this, null, function* () {
if (!suggestion) {
throw new Error("suggestion is required");
}
const { sessionToken: sessionTokenLike, signal } = optionsArg;
const sessionToken = SessionToken.convert(sessionTokenLike);
const url = new URL(`${RETRIEVE_URL2}/${encodeURIComponent(suggestion.mapbox_id)}`);
url.search = queryParams({
access_token: this.accessToken,
session_token: sessionToken.id
});
const { fetch } = getFetch();
const res = yield fetch(url.toString(), {
signal
});
yield handleNonOkRes(res);
const json = yield res.json();
json.url = url.toString();
return json;
});
}
};
var SearchBoxCore = _SearchBoxCore;
_getQueryParams2 = new WeakSet();
getQueryParams_fn2 = function(options) {
return queryParams({
q: options.q,
access_token: this.accessToken,
language: options.language,
limit: options.limit,
navigation_profile: options.navigation_profile,
route: options.route,
route_geometry: options.route_geometry,
sar_type: options.sar_type,
time_deviation: options.time_deviation,
eta_type: options.eta_type,
country: options.country,
poi_category: options.poi_category,
radius: options.radius,
user_id: options.user_id,
rich_metadata_provider: options.rich_metadata_provider,
poi_category_exclusions: options.poi_category_exclusions
}, options.sessionToken && {
session_token: SessionToken.convert(options.sessionToken).id
}, options.proximity && {
proximity: typeof options.proximity === "string" ? options.proximity : LngLat.convert(options.proximity).toArray().join(",")
}, options.origin && {
origin: typeof options.origin === "string" ? options.origin : LngLat.convert(options.origin).toArray().join(",")
}, options.bbox && {
bbox: typeof options.bbox === "string" ? options.bbox : LngLatBounds.convert(options.bbox).toFlatArray().join(",")
}, options.types && {
types: typeof options.types === "string" ? options.types : [...options.types].join(",")
});
};
SearchBoxCore.defaults = {
language: "en"
};
// src/autofill/constants.ts
var SEARCH_URL3 = `https://api.mapbox.com/autofill/v1`;
var ENDPOINT_SUGGEST3 = "suggest";
var ENDPOINT_RETRIEVE3 = "retrieve";
var SUGGEST_URL3 = `${SEARCH_URL3}/${ENDPOINT_SUGGEST3}`;
var RETRIEVE_URL3 = `${SEARCH_URL3}/${ENDPOINT_RETRIEVE3}`;
// src/autofill/MapboxAutofill.ts
var _getQueryParams3, getQueryParams_fn3;
var _MapboxAutofill = class {
constructor(options = {}) {
__privateAdd(this, _getQueryParams3);
const _a = options, { accessToken } = _a, defaults = __objRest(_a, ["accessToken"]);
this.accessToken = accessToken;
this.defaults = __spreadValues(__spreadValues({}, _MapboxAutofill.defaults), defaults);
}
suggest(searchText, optionsArg) {
return __async(this, null, function* () {
if (!searchText) {
throw new Error("searchText is required");
}
const { sessionToken, signal } = optionsArg;
const options = __spreadProps(__spreadValues(__spreadValues({}, this.defaults), optionsArg), {
sessionToken
});
const url = new URL(`${SUGGEST_URL3}/${encodeURIComponent(searchText)}`);
url.search = __privateMethod(this, _getQueryParams3, getQueryParams_fn3).call(this, options);
const { fetch } = getFetch();
const res = yield fetch(url.toString(), {
signal
});
yield handleNonOkRes(res);
const json = yield res.json();
return __spreadProps(__spreadValues({}, json), {

@@ -470,3 +575,4 @@ suggestions: json.suggestions.map((suggestion) => {

});
})
}),
url: url.toString()
});

@@ -485,3 +591,3 @@ });

const sessionToken = SessionToken.convert(sessionTokenLike);
const url = new URL(`${RETRIEVE_URL2}/${suggestion.action.id}`);
const url = new URL(`${RETRIEVE_URL3}/${suggestion.action.id}`);
url.search = queryParams({

@@ -495,2 +601,3 @@ access_token: this.accessToken,

const json = yield res.json();
json.url = url.toString();
return json;

@@ -505,4 +612,4 @@ });

var MapboxAutofill = _MapboxAutofill;
_getQueryParams2 = new WeakSet();
getQueryParams_fn2 = function(options) {
_getQueryParams3 = new WeakSet();
getQueryParams_fn3 = function(options) {
return queryParams({

@@ -529,11 +636,11 @@ types: "address",

// src/validate/constants.ts
var SEARCH_URL3 = `https://api.mapbox.com/autofill/v1`;
var SEARCH_URL4 = `https://api.mapbox.com/autofill/v1`;
var ENDPOINT_VALIDATE = "retrieve";
var VALIDATE_URL = `${SEARCH_URL3}/${ENDPOINT_VALIDATE}`;
var VALIDATE_URL = `${SEARCH_URL4}/${ENDPOINT_VALIDATE}`;
// src/validate/MapboxValidate.ts
var _getQueryParams3, getQueryParams_fn3;
var _getQueryParams4, getQueryParams_fn4;
var _MapboxValidate = class {
constructor(options = {}) {
__privateAdd(this, _getQueryParams3);
__privateAdd(this, _getQueryParams4);
const _a = options, { accessToken } = _a, defaults = __objRest(_a, ["accessToken"]);

@@ -553,3 +660,3 @@ this.accessToken = accessToken;

const url = new URL(`${VALIDATE_URL}/${encodeURIComponent(searchText)}`);
url.search = __privateMethod(this, _getQueryParams3, getQueryParams_fn3).call(this, options);
url.search = __privateMethod(this, _getQueryParams4, getQueryParams_fn4).call(this, options);
const { fetch } = getFetch();

@@ -561,2 +668,3 @@ const res = yield fetch(url.toString(), {

const json = yield res.json();
json.url = url.toString();
if (json.features.length > 0) {

@@ -570,4 +678,4 @@ json.features = [json.features[0]];

var MapboxValidate = _MapboxValidate;
_getQueryParams3 = new WeakSet();
getQueryParams_fn3 = function(options) {
_getQueryParams4 = new WeakSet();
getQueryParams_fn4 = function(options) {
return queryParams({

@@ -591,11 +699,11 @@ access_token: this.accessToken,

// src/geocode/constants.ts
var SEARCH_URL4 = `https://api.mapbox.com/geocoding/v5`;
var TEMP_URL = `${SEARCH_URL4}/mapbox.places`;
var PERMANENT_URL = `${SEARCH_URL4}/mapbox.places-permanent`;
var SEARCH_URL5 = `https://api.mapbox.com/geocoding/v5`;
var TEMP_URL = `${SEARCH_URL5}/mapbox.places`;
var PERMANENT_URL = `${SEARCH_URL5}/mapbox.places-permanent`;
// src/geocode/MapboxGeocode.ts
var _getQueryParams4, getQueryParams_fn4;
var _getQueryParams5, getQueryParams_fn5;
var MapboxGeocode = class {
constructor(options = {}) {
__privateAdd(this, _getQueryParams4);
__privateAdd(this, _getQueryParams5);
const _a = options, { accessToken } = _a, defaults = __objRest(_a, ["accessToken"]);

@@ -617,3 +725,3 @@ this.accessToken = accessToken;

const url = new URL(`${baseUrl}/${encodeURIComponent(searchText)}.json`);
url.search = __privateMethod(this, _getQueryParams4, getQueryParams_fn4).call(this, options);
url.search = __privateMethod(this, _getQueryParams5, getQueryParams_fn5).call(this, options);
const { fetch } = getFetch();

@@ -624,2 +732,3 @@ const fetchInit = signal ? { signal } : {};

const json = yield res.json();
json.url = url.toString();
return json;

@@ -641,3 +750,3 @@ });

const url = new URL(`${baseUrl}/${encodeURIComponent(searchText)}.json`);
url.search = __privateMethod(this, _getQueryParams4, getQueryParams_fn4).call(this, options, true);
url.search = __privateMethod(this, _getQueryParams5, getQueryParams_fn5).call(this, options, true);
const { fetch } = getFetch();

@@ -648,2 +757,3 @@ const fetchInit = signal ? { signal } : {};

const json = yield res.json();
json.url = url.toString();
return json;

@@ -653,4 +763,4 @@ });

};
_getQueryParams4 = new WeakSet();
getQueryParams_fn4 = function(options, isReverse = false) {
_getQueryParams5 = new WeakSet();
getQueryParams_fn5 = function(options, isReverse = false) {
if (isReverse) {

@@ -862,2 +972,3 @@ ["proximity", "autocomplete", "fuzzyMatch", "bbox"].forEach((key) => {

MatchCodeConfidence,
SearchBoxCore,
SearchSession,

@@ -864,0 +975,0 @@ SessionToken,

import { Options, MapboxSearch, SuggestionResponse, RetrieveResponse } from './search/MapboxSearch';
import { AdministrativeUnitTypes, Suggestion, FeatureSuggestion } from './search/types';
import { SearchBoxOptions, SearchBoxCore, SearchBoxSuggestionResponse, SearchBoxRetrieveResponse } from './searchbox/SearchBoxCore';
import { SearchBoxAdministrativeUnitTypes, SearchBoxSuggestion, SearchBoxFeatureSuggestion } from './searchbox/types';
import { AutofillOptions, MapboxAutofill, AutofillSuggestionResponse, AutofillRetrieveResponse } from './autofill/MapboxAutofill';

@@ -19,2 +21,2 @@ import { AutofillSuggestion, AutofillFeatureSuggestion } from './autofill/types';

import { debounce } from './utils/debounce';
export { Options, MapboxSearch, SuggestionResponse, RetrieveResponse, Suggestion, FeatureSuggestion, AutofillOptions, MapboxAutofill, AutofillSuggestionResponse, AutofillRetrieveResponse, AutofillSuggestion, AutofillFeatureSuggestion, MatchCode, MatchCodeConfidence, AdministrativeUnitTypes, SearchSession, SessionToken, SessionTokenLike, MapboxError, LngLat, LngLatLike, LngLatBounds, LngLatBoundsLike, polyfillFetch, featureToSuggestion, Evented, debounce, ValidateOptions, MapboxValidate, ValidateResponse, ValidateFeature, GeocodeOptions, MapboxGeocode, GeocodeResponse, GeocodeFeatureProperties, GeocodeFeatureContext, GeocodeFeature, DataTypes };
export { Options, MapboxSearch, SuggestionResponse, RetrieveResponse, Suggestion, FeatureSuggestion, AutofillOptions, MapboxAutofill, AutofillSuggestionResponse, AutofillRetrieveResponse, AutofillSuggestion, AutofillFeatureSuggestion, MatchCode, MatchCodeConfidence, AdministrativeUnitTypes, SearchSession, SessionToken, SessionTokenLike, MapboxError, LngLat, LngLatLike, LngLatBounds, LngLatBoundsLike, polyfillFetch, featureToSuggestion, Evented, debounce, ValidateOptions, MapboxValidate, ValidateResponse, ValidateFeature, GeocodeOptions, MapboxGeocode, GeocodeResponse, GeocodeFeatureProperties, GeocodeFeatureContext, GeocodeFeature, DataTypes, SearchBoxOptions, SearchBoxCore, SearchBoxSuggestionResponse, SearchBoxRetrieveResponse, SearchBoxAdministrativeUnitTypes, SearchBoxSuggestion, SearchBoxFeatureSuggestion };

@@ -1,2 +0,2 @@

var j=Object.defineProperty,ve=Object.defineProperties,xe=Object.getOwnPropertyDescriptor,we=Object.getOwnPropertyDescriptors,Ee=Object.getOwnPropertyNames,U=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var oe=(o,e,t)=>e in o?j(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,a=(o,e)=>{for(var t in e||(e={}))M.call(e,t)&&oe(o,t,e[t]);if(U)for(var t of U(e))re.call(e,t)&&oe(o,t,e[t]);return o},R=(o,e)=>ve(o,we(e)),Oe=o=>j(o,"__esModule",{value:!0});var T=(o,e)=>{var t={};for(var n in o)M.call(o,n)&&e.indexOf(n)<0&&(t[n]=o[n]);if(o!=null&&U)for(var n of U(o))e.indexOf(n)<0&&re.call(o,n)&&(t[n]=o[n]);return t};var Ae=(o,e)=>{for(var t in e)j(o,t,{get:e[t],enumerable:!0})},Pe=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ee(e))!M.call(o,r)&&(t||r!=="default")&&j(o,r,{get:()=>e[r],enumerable:!(n=xe(e,r))||n.enumerable});return o};var _e=(o=>(e,t)=>o&&o.get(e)||(t=Pe(Oe({}),e,1),o&&o.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var W=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var b=(o,e,t)=>(W(o,e,"read from private field"),t?t.call(o):e.get(o)),h=(o,e,t)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,t)},w=(o,e,t,n)=>(W(o,e,"write to private field"),n?n.call(o,t):e.set(o,t),t);var S=(o,e,t)=>(W(o,e,"access private method"),t);var m=(o,e,t)=>new Promise((n,r)=>{var s=c=>{try{i(t.next(c))}catch(l){r(l)}},g=c=>{try{i(t.throw(c))}catch(l){r(l)}},i=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,g);i((t=t.apply(o,e)).next())});var Ve={};Ae(Ve,{Evented:()=>_,LngLat:()=>u,LngLatBounds:()=>p,MapboxAutofill:()=>C,MapboxError:()=>N,MapboxGeocode:()=>Z,MapboxSearch:()=>I,MapboxValidate:()=>D,MatchCodeConfidence:()=>ee,SearchSession:()=>ne,SessionToken:()=>f,debounce:()=>B,featureToSuggestion:()=>Te,polyfillFetch:()=>he});var E="https://api.mapbox.com/search/v1",K="suggest",z="retrieve",se="forward",ie="reverse",ae=`${E}/${K}`,ge=`${E}/${z}`,ce=`${E}/${se}`,ue=`${E}/permanent/${se}`,le=`${E}/${ie}`,me=`${E}/permanent/${ie}`;var u=class{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90");if(this.lng>180||this.lng<-180)throw new Error("Invalid LngLat longitude value: must be between -180 and 180")}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}static convert(e){if(e instanceof u)return new u(e.lng,e.lat);if(Array.isArray(e)&&e.length===2)return new u(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null&&("lng"in e||"lon"in e)&&"lat"in e)return new u(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}};var p=class{constructor(e,t){this._sw=u.convert(e),this._ne=u.convert(t)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new u(this.getWest(),this.getNorth())}getSouthEast(){return new u(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toFlatArray(){return[this._sw.lng,this._sw.lat,this._ne.lng,this._ne.lat]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}static convert(e){if(!e)throw new Error("Invalid LngLatBounds convert value: falsy");if(e instanceof p)return new p(e.getSouthWest(),e.getNorthEast());if(Array.isArray(e)&&e.length===2)return new p(u.convert(e[0]),u.convert(e[1]));if(Array.isArray(e)&&e.length===4)return new p(u.convert([e[0],e[1]]),u.convert([e[2],e[3]]));throw new Error("`LngLatBoundsLike` argument must be specified as an array [<LngLatLike>, <LngLatLike>] or an array [<west>, <south>, <east>, <north>]")}};function pe(){let e=(Math.random().toString(16)+Date.now().toString(16)+Math.random().toString(16)).replace(/\./g,"");return[e.slice(0,8),e.slice(8,12),"4"+e.slice(12,15)+"-8"+e.slice(15,18),e.slice(18,30)].join("-")}var f=class{constructor(e){this.id=e!=null?e:pe()}toString(){return this.id}static convert(e){return new f(e instanceof f?e.id:e.toString())}};var Fe="Unknown error",N=class extends Error{constructor(e,t){super(String(e.message||e.error||Fe));this.name="MapboxError",this.statusCode=t}toString(){return`${this.name} (${this.statusCode}): ${this.message}`}};function L(o){return m(this,null,function*(){if(!o.ok){let e=yield o.json();throw new N(e,o.status)}})}var $=globalThis.fetch,fe=globalThis.AbortController;function he({fetch:o,AbortController:e},t=!1){if(!o)throw new Error("Fetch implementation must include implementations of `fetch`.");$&&!t||($=o,fe=e)}function d(){if(!$)throw new Error("Fetch implementation not found. Please include a fetch polyfill in your application or use `polyfillFetch` from `@mapbox/search-js-core` to fix this issue.");return{fetch:$,AbortController:fe}}function y(...o){let e=[];for(let t of o){if(!t)continue;let n=Object.entries(t);for(let[r,s]of n)s!=null&&e.push(`${r}=${encodeURIComponent(String(s))}`)}return e.join("&")}var A,de,G,Ue,H=class{constructor(e={}){h(this,A);h(this,G);let r=e,{accessToken:t}=r,n=T(r,["accessToken"]);this.accessToken=t,this.defaults=a(a({},H.defaults),n)}suggest(e,t){return m(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:n,signal:r}=t,s=R(a(a({},this.defaults),t),{sessionToken:n});if(s.eta_type&&(!s.origin||!s.navigation_profile))throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");if(s.origin&&!s.navigation_profile)throw new Error("to provide distance estimate: both navigation_profile and origin are required");let g=new URL(`${ae}/${encodeURIComponent(e)}`);g.search=S(this,A,de).call(this,s);let{fetch:i}=d(),c=yield i(g.toString(),{signal:r});return yield L(c),yield c.json()})}retrieve(e,t){return m(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");let{sessionToken:n,signal:r}=t,s=f.convert(n),g=new URL(ge);g.search=y({access_token:this.accessToken,session_token:s.id});let{fetch:i}=d(),c=yield i(g.toString(),R(a({},S(this,G,Ue).call(this,e)),{signal:r}));return yield L(c),yield c.json()})}canRetrieve(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===z:!1}canSuggest(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===K:!1}forward(n){return m(this,arguments,function*(e,t={}){if(!e)throw new Error("searchText is required");let r=a(a({},this.defaults),t),s=r.permanent?ue:ce,g=new URL(`${s}/${encodeURIComponent(e)}`);g.search=S(this,A,de).call(this,r);let{fetch:i}=d(),c=yield i(g.toString(),{signal:r.signal});return yield L(c),yield c.json()})}reverse(n){return m(this,arguments,function*(e,t={}){if(!e)throw new Error("lngLat is required");let r=a(a({},this.defaults),t),s=typeof e=="string"?e:u.convert(e).toArray().join(","),g=r.permanent?me:le,i=new URL(`${g}/${encodeURIComponent(s)}`);i.search=y({access_token:this.accessToken,language:r.language,limit:r.limit},r.types&&{types:typeof r.types=="string"?r.types:[...r.types].join(",")});let{fetch:c}=d(),l=yield c(i.toString(),{signal:r.signal});return yield L(l),yield l.json()})}},I=H;A=new WeakSet,de=function(e){return y({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit,navigation_profile:e.navigation_profile,eta_type:e.eta_type},e.sessionToken&&{session_token:f.convert(e.sessionToken).id},e.origin&&{origin:typeof e.origin=="string"?e.origin:u.convert(e.origin).toArray().join(",")},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:u.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:p.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},G=new WeakSet,Ue=function(e){if(!this.canRetrieve(e)&&!this.canSuggest(e))throw new Error("Suggestion cannot be retrieved or suggested");let t=e.action,n=JSON.stringify(t.body);return{method:t.method,body:n,headers:{"Content-Type":"application/json","Content-Length":n.length.toString()}}},I.defaults={language:"en"};var Le="https://api.mapbox.com/autofill/v1",je="suggest",Ne="retrieve",be=`${Le}/${je}`,Re=`${Le}/${Ne}`;var V,$e,Q=class{constructor(e={}){h(this,V);let r=e,{accessToken:t}=r,n=T(r,["accessToken"]);this.accessToken=t,this.defaults=a(a({},Q.defaults),n)}suggest(e,t){return m(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:n,signal:r}=t,s=R(a(a({},this.defaults),t),{sessionToken:n}),g=new URL(`${be}/${encodeURIComponent(e)}`);g.search=S(this,V,$e).call(this,s);let{fetch:i}=d(),c=yield i(g.toString(),{signal:r});yield L(c);let l=yield c.json();return R(a({},l),{suggestions:l.suggestions.map(x=>R(a({},x),{original_search_text:e}))})})}retrieve(e,t){return m(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");let{sessionToken:n,signal:r}=t,s=f.convert(n),g=new URL(`${Re}/${e.action.id}`);g.search=y({access_token:this.accessToken,session_token:s.id});let{fetch:i}=d(),c=yield i(g.toString(),{signal:r});return yield L(c),yield c.json()})}canRetrieve(e){let t=e.action;return typeof(t==null?void 0:t.id)=="string"}},C=Q;V=new WeakSet,$e=function(e){return y({types:"address",streets:!0,access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit},e.sessionToken&&{session_token:f.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:u.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:p.convert(e.bbox).toFlatArray().join(",")})},C.defaults={language:"en",proximity:"ip"};var Ie="https://api.mapbox.com/autofill/v1",Ge="retrieve",Se=`${Ie}/${Ge}`;var q,Ce,J=class{constructor(e={}){h(this,q);let r=e,{accessToken:t}=r,n=T(r,["accessToken"]);this.accessToken=t,this.defaults=a(a({},J.defaults),n)}validate(e,t){return m(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:n,signal:r}=t,s=R(a(a({},this.defaults),t),{sessionToken:n}),g=new URL(`${Se}/${encodeURIComponent(e)}`);g.search=S(this,q,Ce).call(this,s);let{fetch:i}=d(),c=yield i(g.toString(),{signal:r});yield L(c);let l=yield c.json();return l.features.length>0&&(l.features=[l.features[0]]),l})}},D=J;q=new WeakSet,Ce=function(e){return y({access_token:this.accessToken,language:e.language,country:e.country},e.sessionToken&&{session_token:f.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:u.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:p.convert(e.bbox).toFlatArray().join(",")})},D.defaults={language:"en",proximity:"ip"};var ye="https://api.mapbox.com/geocoding/v5",X=`${ye}/mapbox.places`,Y=`${ye}/mapbox.places-permanent`;var P,ke,Z=class{constructor(e={}){h(this,P);let r=e,{accessToken:t}=r,n=T(r,["accessToken"]);this.accessToken=t,this.defaults=a({},n)}forward(e,t){return m(this,null,function*(){if(!e)throw new Error("searchText is required");let n;t&&({signal:n}=t);let r=a(a({},this.defaults),t),s=r.permanent?Y:X,g=new URL(`${s}/${encodeURIComponent(e)}.json`);g.search=S(this,P,ke).call(this,r);let{fetch:i}=d(),c=n?{signal:n}:{},l=yield i(g.toString(),c);return yield L(l),yield l.json()})}reverse(e,t){return m(this,null,function*(){if(!e)throw new Error("lngLat is required");let n;t&&({signal:n}=t);let r=a(a({},this.defaults),t),s=typeof e=="string"?e:u.convert(e).toArray().join(","),g=r.permanent?Y:X,i=new URL(`${g}/${encodeURIComponent(s)}.json`);i.search=S(this,P,ke).call(this,r,!0);let{fetch:c}=d(),l=n?{signal:n}:{},x=yield c(i.toString(),l);return yield L(x),yield x.json()})}};P=new WeakSet,ke=function(e,t=!1){return t&&["proximity","autocomplete","fuzzyMatch","bbox"].forEach(n=>{n in e&&delete e[n]}),y({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit,autocomplete:e.autocomplete,fuzzyMatch:e.fuzzyMatch,routing:e.routing,worldview:e.worldview},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:u.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:p.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})};var ee=(r=>(r.exact="exact",r.high="high",r.medium="medium",r.low="low",r))(ee||{});var O,_=class{constructor(){h(this,O,{})}addEventListener(e,t){let n=b(this,O);n[e]||(n[e]=[]),n[e].push(t)}removeEventListener(e,t){let n=b(this,O);if(!n[e])return;let r=n[e],s=r.indexOf(t);s!==-1&&r.splice(s,1)}fire(e,t){let n=b(this,O);if(!n[e])return;let r=n[e];for(let s of r)s(t)}};O=new WeakMap;function B(o,e,t){let n=null;return(...r)=>{n!==null&&clearTimeout(n);let s=t&&t();n=setTimeout(()=>{n=null,!(s==null?void 0:s.aborted)&&o(...r)},e)}}function te(){let{AbortController:o}=d();return new o}var v,k,F,ne=class extends _{constructor(e,t=0){super();this.sessionToken=new f;h(this,v,void 0);h(this,k,te());h(this,F,void 0);w(this,F,B((s,...g)=>m(this,[s,...g],function*(n,r={}){if(b(this,k).abort(),w(this,k,te()),!n){w(this,v,null),this.fire("suggest",b(this,v));return}try{let i=yield this.search.suggest(n,R(a({sessionToken:this.sessionToken},r),{signal:b(this,k).signal}));w(this,v,i),this.fire("suggest",i)}catch(i){if(i.name==="AbortError")return;this.fire("suggesterror",i)}}),t,()=>b(this,k).signal)),Object.defineProperties(this,{search:{value:e,writable:!1},debounce:{value:t,writable:!1}})}get suggestions(){return b(this,v)}suggest(e,t){return b(this,F).call(this,e,t),new Promise((n,r)=>{let s,g;s=i=>{this.removeEventListener("suggest",s),this.removeEventListener("suggesterror",g),n(i)},g=i=>{this.removeEventListener("suggest",s),this.removeEventListener("suggesterror",g),r(i)},this.addEventListener("suggest",s),this.addEventListener("suggesterror",g)})}clear(){this.suggest("")}retrieve(e,t){return m(this,null,function*(){let n=yield this.search.retrieve(e,a({sessionToken:this.sessionToken},t));return this.fire("retrieve",n),n})}canRetrieve(e){return this.search.canRetrieve?this.search.canRetrieve(e):!0}canSuggest(e){return this.search.canSuggest?this.search.canSuggest(e):!0}abort(){b(this,k).abort(),w(this,k,te())}};v=new WeakMap,k=new WeakMap,F=new WeakMap;function Te(o){let{properties:e}=o;return a({},e)}module.exports=_e(Ve);
var N=Object.defineProperty,Pe=Object.defineProperties,Ue=Object.getOwnPropertyDescriptor,Fe=Object.getOwnPropertyDescriptors,Ne=Object.getOwnPropertyNames,F=Object.getOwnPropertySymbols;var K=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable;var ae=(o,e,t)=>e in o?N(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,g=(o,e)=>{for(var t in e||(e={}))K.call(e,t)&&ae(o,t,e[t]);if(F)for(var t of F(e))ge.call(e,t)&&ae(o,t,e[t]);return o},y=(o,e)=>Pe(o,Fe(e)),je=o=>N(o,"__esModule",{value:!0});var k=(o,e)=>{var t={};for(var n in o)K.call(o,n)&&e.indexOf(n)<0&&(t[n]=o[n]);if(o!=null&&F)for(var n of F(o))e.indexOf(n)<0&&ge.call(o,n)&&(t[n]=o[n]);return t};var $e=(o,e)=>{for(var t in e)N(o,t,{get:e[t],enumerable:!0})},Ie=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ne(e))!K.call(o,r)&&(t||r!=="default")&&N(o,r,{get:()=>e[r],enumerable:!(n=Ue(e,r))||n.enumerable});return o};var Be=(o=>(e,t)=>o&&o.get(e)||(t=Ie(je({}),e,1),o&&o.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var z=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var R=(o,e,t)=>(z(o,e,"read from private field"),t?t.call(o):e.get(o)),d=(o,e,t)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,t)},w=(o,e,t,n)=>(z(o,e,"write to private field"),n?n.call(o,t):e.set(o,t),t);var b=(o,e,t)=>(z(o,e,"access private method"),t);var p=(o,e,t)=>new Promise((n,r)=>{var s=c=>{try{a(t.next(c))}catch(u){r(u)}},i=c=>{try{a(t.throw(c))}catch(u){r(u)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,i);a((t=t.apply(o,e)).next())});var Je={};$e(Je,{Evented:()=>P,LngLat:()=>l,LngLatBounds:()=>f,MapboxAutofill:()=>V,MapboxError:()=>j,MapboxGeocode:()=>ne,MapboxSearch:()=>I,MapboxValidate:()=>q,MatchCodeConfidence:()=>re,SearchBoxCore:()=>G,SearchSession:()=>se,SessionToken:()=>m,debounce:()=>W,featureToSuggestion:()=>Ae,polyfillFetch:()=>ye});var E="https://api.mapbox.com/search/v1",Q="suggest",H="retrieve",ce="forward",ue="reverse",le=`${E}/${Q}`,pe=`${E}/${H}`,me=`${E}/${ce}`,fe=`${E}/permanent/${ce}`,he=`${E}/${ue}`,de=`${E}/permanent/${ue}`;var l=class{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90");if(this.lng>180||this.lng<-180)throw new Error("Invalid LngLat longitude value: must be between -180 and 180")}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}static convert(e){if(e instanceof l)return new l(e.lng,e.lat);if(Array.isArray(e)&&e.length===2)return new l(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null&&("lng"in e||"lon"in e)&&"lat"in e)return new l(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}};var f=class{constructor(e,t){this._sw=l.convert(e),this._ne=l.convert(t)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new l(this.getWest(),this.getNorth())}getSouthEast(){return new l(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toFlatArray(){return[this._sw.lng,this._sw.lat,this._ne.lng,this._ne.lat]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}static convert(e){if(!e)throw new Error("Invalid LngLatBounds convert value: falsy");if(e instanceof f)return new f(e.getSouthWest(),e.getNorthEast());if(Array.isArray(e)&&e.length===2)return new f(l.convert(e[0]),l.convert(e[1]));if(Array.isArray(e)&&e.length===4)return new f(l.convert([e[0],e[1]]),l.convert([e[2],e[3]]));throw new Error("`LngLatBoundsLike` argument must be specified as an array [<LngLatLike>, <LngLatLike>] or an array [<west>, <south>, <east>, <north>]")}};function Se(){let e=(Math.random().toString(16)+Date.now().toString(16)+Math.random().toString(16)).replace(/\./g,"");return[e.slice(0,8),e.slice(8,12),"4"+e.slice(12,15)+"-8"+e.slice(15,18),e.slice(18,30)].join("-")}var m=class{constructor(e){this.id=e!=null?e:Se()}toString(){return this.id}static convert(e){return new m(e instanceof m?e.id:e.toString())}};var Ge="Unknown error",j=class extends Error{constructor(e,t){super(String(e.message||e.error||Ge));this.name="MapboxError",this.statusCode=t}toString(){return`${this.name} (${this.statusCode}): ${this.message}`}};function S(o){return p(this,null,function*(){if(!o.ok){let e=yield o.json();throw new j(e,o.status)}})}var $=globalThis.fetch,Le=globalThis.AbortController;function ye({fetch:o,AbortController:e},t=!1){if(!o)throw new Error("Fetch implementation must include implementations of `fetch`.");$&&!t||($=o,Le=e)}function h(){if(!$)throw new Error("Fetch implementation not found. Please include a fetch polyfill in your application or use `polyfillFetch` from `@mapbox/search-js-core` to fix this issue.");return{fetch:$,AbortController:Le}}function L(...o){let e=[];for(let t of o){if(!t)continue;let n=Object.entries(t);for(let[r,s]of n)s!=null&&e.push(`${r}=${encodeURIComponent(String(s))}`)}return e.join("&")}var _,be,B,Ce,J=class{constructor(e={}){d(this,_);d(this,B);let r=e,{accessToken:t}=r,n=k(r,["accessToken"]);this.accessToken=t,this.defaults=g(g({},J.defaults),n)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:n,signal:r}=t,s=y(g(g({},this.defaults),t),{sessionToken:n});if(s.eta_type&&(!s.origin||!s.navigation_profile))throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");if(s.origin&&!s.navigation_profile)throw new Error("to provide distance estimate: both navigation_profile and origin are required");let i=new URL(`${le}/${encodeURIComponent(e)}`);i.search=b(this,_,be).call(this,s);let{fetch:a}=h(),c=yield a(i.toString(),{signal:r});yield S(c);let u=yield c.json();return u.url=i.toString(),u})}retrieve(e,t){return p(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");let{sessionToken:n,signal:r}=t,s=m.convert(n),i=new URL(pe);i.search=L({access_token:this.accessToken,session_token:s.id});let{fetch:a}=h(),c=yield a(i.toString(),y(g({},b(this,B,Ce).call(this,e)),{signal:r}));yield S(c);let u=yield c.json();return u.url=i.toString(),u})}canRetrieve(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===H:!1}canSuggest(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===Q:!1}forward(n){return p(this,arguments,function*(e,t={}){if(!e)throw new Error("searchText is required");let r=g(g({},this.defaults),t),s=r.permanent?fe:me,i=new URL(`${s}/${encodeURIComponent(e)}`);i.search=b(this,_,be).call(this,r);let{fetch:a}=h(),c=yield a(i.toString(),{signal:r.signal});return yield S(c),yield c.json()})}reverse(n){return p(this,arguments,function*(e,t={}){if(!e)throw new Error("lngLat is required");let r=g(g({},this.defaults),t),s=typeof e=="string"?e:l.convert(e).toArray().join(","),i=r.permanent?de:he,a=new URL(`${i}/${encodeURIComponent(s)}`);a.search=L({access_token:this.accessToken,language:r.language,limit:r.limit},r.types&&{types:typeof r.types=="string"?r.types:[...r.types].join(",")});let{fetch:c}=h(),u=yield c(a.toString(),{signal:r.signal});return yield S(u),yield u.json()})}},I=J;_=new WeakSet,be=function(e){return L({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit,navigation_profile:e.navigation_profile,eta_type:e.eta_type},e.sessionToken&&{session_token:m.convert(e.sessionToken).id},e.origin&&{origin:typeof e.origin=="string"?e.origin:l.convert(e.origin).toArray().join(",")},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:f.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},B=new WeakSet,Ce=function(e){if(!this.canRetrieve(e)&&!this.canSuggest(e))throw new Error("Suggestion cannot be retrieved or suggested");let t=e.action,n=JSON.stringify(t.body);return{method:t.method,body:n,headers:{"Content-Type":"application/json","Content-Length":n.length.toString()}}},I.defaults={language:"en"};var Re="https://api.mapbox.com/search/searchbox/v1",Ve="suggest",De="retrieve",ke=`${Re}/${Ve}`,xe=`${Re}/${De}`;var C,qe,X=class{constructor(e={}){d(this,C);let r=e,{accessToken:t}=r,n=k(r,["accessToken"]);this.accessToken=t,this.defaults=g(g({},X.defaults),n)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:n,signal:r}=t,s=y(g(g({},this.defaults),t),{q:e,sessionToken:n});if(s.eta_type&&(!s.origin||!s.navigation_profile))throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");if(s.origin&&!s.navigation_profile)throw new Error("to provide distance estimate: both navigation_profile and origin are required");let i=new URL(ke);i.search=b(this,C,qe).call(this,s);let{fetch:a}=h(),c=yield a(i.toString(),{signal:r});yield S(c);let u=yield c.json();return u.url=i.toString(),u})}retrieve(e,t){return p(this,null,function*(){if(!e)throw new Error("suggestion is required");let{sessionToken:n,signal:r}=t,s=m.convert(n),i=new URL(`${xe}/${encodeURIComponent(e.mapbox_id)}`);i.search=L({access_token:this.accessToken,session_token:s.id});let{fetch:a}=h(),c=yield a(i.toString(),{signal:r});yield S(c);let u=yield c.json();return u.url=i.toString(),u})}},G=X;C=new WeakSet,qe=function(e){return L({q:e.q,access_token:this.accessToken,language:e.language,limit:e.limit,navigation_profile:e.navigation_profile,route:e.route,route_geometry:e.route_geometry,sar_type:e.sar_type,time_deviation:e.time_deviation,eta_type:e.eta_type,country:e.country,poi_category:e.poi_category,radius:e.radius,user_id:e.user_id,rich_metadata_provider:e.rich_metadata_provider,poi_category_exclusions:e.poi_category_exclusions},e.sessionToken&&{session_token:m.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.origin&&{origin:typeof e.origin=="string"?e.origin:l.convert(e.origin).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:f.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},G.defaults={language:"en"};var Te="https://api.mapbox.com/autofill/v1",Me="suggest",We="retrieve",ve=`${Te}/${Me}`,we=`${Te}/${We}`;var D,Ke,Y=class{constructor(e={}){d(this,D);let r=e,{accessToken:t}=r,n=k(r,["accessToken"]);this.accessToken=t,this.defaults=g(g({},Y.defaults),n)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:n,signal:r}=t,s=y(g(g({},this.defaults),t),{sessionToken:n}),i=new URL(`${ve}/${encodeURIComponent(e)}`);i.search=b(this,D,Ke).call(this,s);let{fetch:a}=h(),c=yield a(i.toString(),{signal:r});yield S(c);let u=yield c.json();return y(g({},u),{suggestions:u.suggestions.map(T=>y(g({},T),{original_search_text:e})),url:i.toString()})})}retrieve(e,t){return p(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");let{sessionToken:n,signal:r}=t,s=m.convert(n),i=new URL(`${we}/${e.action.id}`);i.search=L({access_token:this.accessToken,session_token:s.id});let{fetch:a}=h(),c=yield a(i.toString(),{signal:r});yield S(c);let u=yield c.json();return u.url=i.toString(),u})}canRetrieve(e){let t=e.action;return typeof(t==null?void 0:t.id)=="string"}},V=Y;D=new WeakSet,Ke=function(e){return L({types:"address",streets:!0,access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit},e.sessionToken&&{session_token:m.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:f.convert(e.bbox).toFlatArray().join(",")})},V.defaults={language:"en",proximity:"ip"};var ze="https://api.mapbox.com/autofill/v1",Qe="retrieve",Ee=`${ze}/${Qe}`;var M,He,Z=class{constructor(e={}){d(this,M);let r=e,{accessToken:t}=r,n=k(r,["accessToken"]);this.accessToken=t,this.defaults=g(g({},Z.defaults),n)}validate(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:n,signal:r}=t,s=y(g(g({},this.defaults),t),{sessionToken:n}),i=new URL(`${Ee}/${encodeURIComponent(e)}`);i.search=b(this,M,He).call(this,s);let{fetch:a}=h(),c=yield a(i.toString(),{signal:r});yield S(c);let u=yield c.json();return u.url=i.toString(),u.features.length>0&&(u.features=[u.features[0]]),u})}},q=Z;M=new WeakSet,He=function(e){return L({access_token:this.accessToken,language:e.language,country:e.country},e.sessionToken&&{session_token:m.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:f.convert(e.bbox).toFlatArray().join(",")})},q.defaults={language:"en",proximity:"ip"};var Oe="https://api.mapbox.com/geocoding/v5",ee=`${Oe}/mapbox.places`,te=`${Oe}/mapbox.places-permanent`;var A,_e,ne=class{constructor(e={}){d(this,A);let r=e,{accessToken:t}=r,n=k(r,["accessToken"]);this.accessToken=t,this.defaults=g({},n)}forward(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let n;t&&({signal:n}=t);let r=g(g({},this.defaults),t),s=r.permanent?te:ee,i=new URL(`${s}/${encodeURIComponent(e)}.json`);i.search=b(this,A,_e).call(this,r);let{fetch:a}=h(),c=n?{signal:n}:{},u=yield a(i.toString(),c);yield S(u);let T=yield u.json();return T.url=i.toString(),T})}reverse(e,t){return p(this,null,function*(){if(!e)throw new Error("lngLat is required");let n;t&&({signal:n}=t);let r=g(g({},this.defaults),t),s=typeof e=="string"?e:l.convert(e).toArray().join(","),i=r.permanent?te:ee,a=new URL(`${i}/${encodeURIComponent(s)}.json`);a.search=b(this,A,_e).call(this,r,!0);let{fetch:c}=h(),u=n?{signal:n}:{},T=yield c(a.toString(),u);yield S(T);let ie=yield T.json();return ie.url=a.toString(),ie})}};A=new WeakSet,_e=function(e,t=!1){return t&&["proximity","autocomplete","fuzzyMatch","bbox"].forEach(n=>{n in e&&delete e[n]}),L({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit,autocomplete:e.autocomplete,fuzzyMatch:e.fuzzyMatch,routing:e.routing,worldview:e.worldview},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:f.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})};var re=(r=>(r.exact="exact",r.high="high",r.medium="medium",r.low="low",r))(re||{});var O,P=class{constructor(){d(this,O,{})}addEventListener(e,t){let n=R(this,O);n[e]||(n[e]=[]),n[e].push(t)}removeEventListener(e,t){let n=R(this,O);if(!n[e])return;let r=n[e],s=r.indexOf(t);s!==-1&&r.splice(s,1)}fire(e,t){let n=R(this,O);if(!n[e])return;let r=n[e];for(let s of r)s(t)}};O=new WeakMap;function W(o,e,t){let n=null;return(...r)=>{n!==null&&clearTimeout(n);let s=t&&t();n=setTimeout(()=>{n=null,!(s==null?void 0:s.aborted)&&o(...r)},e)}}function oe(){let{AbortController:o}=h();return new o}var v,x,U,se=class extends P{constructor(e,t=0){super();this.sessionToken=new m;d(this,v,void 0);d(this,x,oe());d(this,U,void 0);w(this,U,W((s,...i)=>p(this,[s,...i],function*(n,r={}){if(R(this,x).abort(),w(this,x,oe()),!n){w(this,v,null),this.fire("suggest",R(this,v));return}try{let a=yield this.search.suggest(n,y(g({sessionToken:this.sessionToken},r),{signal:R(this,x).signal}));w(this,v,a),this.fire("suggest",a)}catch(a){if(a.name==="AbortError")return;this.fire("suggesterror",a)}}),t,()=>R(this,x).signal)),Object.defineProperties(this,{search:{value:e,writable:!1},debounce:{value:t,writable:!1}})}get suggestions(){return R(this,v)}suggest(e,t){return R(this,U).call(this,e,t),new Promise((n,r)=>{let s,i;s=a=>{this.removeEventListener("suggest",s),this.removeEventListener("suggesterror",i),n(a)},i=a=>{this.removeEventListener("suggest",s),this.removeEventListener("suggesterror",i),r(a)},this.addEventListener("suggest",s),this.addEventListener("suggesterror",i)})}clear(){this.suggest("")}retrieve(e,t){return p(this,null,function*(){let n=yield this.search.retrieve(e,g({sessionToken:this.sessionToken},t));return this.fire("retrieve",n),n})}canRetrieve(e){return this.search.canRetrieve?this.search.canRetrieve(e):!0}canSuggest(e){return this.search.canSuggest?this.search.canSuggest(e):!0}abort(){R(this,x).abort(),w(this,x,oe())}};v=new WeakMap,x=new WeakMap,U=new WeakMap;function Ae(o){let{properties:e}=o;return g({},e)}module.exports=Be(Je);
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

var mapboxsearchcore=(()=>{var j=Object.defineProperty,ve=Object.defineProperties,xe=Object.getOwnPropertyDescriptor,we=Object.getOwnPropertyDescriptors,Ee=Object.getOwnPropertyNames,U=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var oe=(o,e,t)=>e in o?j(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,a=(o,e)=>{for(var t in e||(e={}))M.call(e,t)&&oe(o,t,e[t]);if(U)for(var t of U(e))re.call(e,t)&&oe(o,t,e[t]);return o},R=(o,e)=>ve(o,we(e)),Oe=o=>j(o,"__esModule",{value:!0});var T=(o,e)=>{var t={};for(var n in o)M.call(o,n)&&e.indexOf(n)<0&&(t[n]=o[n]);if(o!=null&&U)for(var n of U(o))e.indexOf(n)<0&&re.call(o,n)&&(t[n]=o[n]);return t};var Ae=(o,e)=>{for(var t in e)j(o,t,{get:e[t],enumerable:!0})},Pe=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ee(e))!M.call(o,r)&&(t||r!=="default")&&j(o,r,{get:()=>e[r],enumerable:!(n=xe(e,r))||n.enumerable});return o};var _e=(o=>(e,t)=>o&&o.get(e)||(t=Pe(Oe({}),e,1),o&&o.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var W=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var b=(o,e,t)=>(W(o,e,"read from private field"),t?t.call(o):e.get(o)),h=(o,e,t)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,t)},w=(o,e,t,n)=>(W(o,e,"write to private field"),n?n.call(o,t):e.set(o,t),t);var S=(o,e,t)=>(W(o,e,"access private method"),t);var m=(o,e,t)=>new Promise((n,r)=>{var s=c=>{try{i(t.next(c))}catch(l){r(l)}},g=c=>{try{i(t.throw(c))}catch(l){r(l)}},i=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,g);i((t=t.apply(o,e)).next())});var Ve={};Ae(Ve,{Evented:()=>_,LngLat:()=>u,LngLatBounds:()=>p,MapboxAutofill:()=>C,MapboxError:()=>N,MapboxGeocode:()=>Z,MapboxSearch:()=>I,MapboxValidate:()=>D,MatchCodeConfidence:()=>ee,SearchSession:()=>ne,SessionToken:()=>f,debounce:()=>B,featureToSuggestion:()=>Te,polyfillFetch:()=>he});var E="https://api.mapbox.com/search/v1",K="suggest",z="retrieve",se="forward",ie="reverse",ae=`${E}/${K}`,ge=`${E}/${z}`,ce=`${E}/${se}`,ue=`${E}/permanent/${se}`,le=`${E}/${ie}`,me=`${E}/permanent/${ie}`;var u=class{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90");if(this.lng>180||this.lng<-180)throw new Error("Invalid LngLat longitude value: must be between -180 and 180")}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}static convert(e){if(e instanceof u)return new u(e.lng,e.lat);if(Array.isArray(e)&&e.length===2)return new u(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null&&("lng"in e||"lon"in e)&&"lat"in e)return new u(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}};var p=class{constructor(e,t){this._sw=u.convert(e),this._ne=u.convert(t)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new u(this.getWest(),this.getNorth())}getSouthEast(){return new u(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toFlatArray(){return[this._sw.lng,this._sw.lat,this._ne.lng,this._ne.lat]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}static convert(e){if(!e)throw new Error("Invalid LngLatBounds convert value: falsy");if(e instanceof p)return new p(e.getSouthWest(),e.getNorthEast());if(Array.isArray(e)&&e.length===2)return new p(u.convert(e[0]),u.convert(e[1]));if(Array.isArray(e)&&e.length===4)return new p(u.convert([e[0],e[1]]),u.convert([e[2],e[3]]));throw new Error("`LngLatBoundsLike` argument must be specified as an array [<LngLatLike>, <LngLatLike>] or an array [<west>, <south>, <east>, <north>]")}};function pe(){let e=(Math.random().toString(16)+Date.now().toString(16)+Math.random().toString(16)).replace(/\./g,"");return[e.slice(0,8),e.slice(8,12),"4"+e.slice(12,15)+"-8"+e.slice(15,18),e.slice(18,30)].join("-")}var f=class{constructor(e){this.id=e!=null?e:pe()}toString(){return this.id}static convert(e){return new f(e instanceof f?e.id:e.toString())}};var Fe="Unknown error",N=class extends Error{constructor(e,t){super(String(e.message||e.error||Fe));this.name="MapboxError",this.statusCode=t}toString(){return`${this.name} (${this.statusCode}): ${this.message}`}};function L(o){return m(this,null,function*(){if(!o.ok){let e=yield o.json();throw new N(e,o.status)}})}var $=globalThis.fetch,fe=globalThis.AbortController;function he({fetch:o,AbortController:e},t=!1){if(!o)throw new Error("Fetch implementation must include implementations of `fetch`.");$&&!t||($=o,fe=e)}function d(){if(!$)throw new Error("Fetch implementation not found. Please include a fetch polyfill in your application or use `polyfillFetch` from `@mapbox/search-js-core` to fix this issue.");return{fetch:$,AbortController:fe}}function y(...o){let e=[];for(let t of o){if(!t)continue;let n=Object.entries(t);for(let[r,s]of n)s!=null&&e.push(`${r}=${encodeURIComponent(String(s))}`)}return e.join("&")}var A,de,G,Ue,H=class{constructor(e={}){h(this,A);h(this,G);let r=e,{accessToken:t}=r,n=T(r,["accessToken"]);this.accessToken=t,this.defaults=a(a({},H.defaults),n)}suggest(e,t){return m(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:n,signal:r}=t,s=R(a(a({},this.defaults),t),{sessionToken:n});if(s.eta_type&&(!s.origin||!s.navigation_profile))throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");if(s.origin&&!s.navigation_profile)throw new Error("to provide distance estimate: both navigation_profile and origin are required");let g=new URL(`${ae}/${encodeURIComponent(e)}`);g.search=S(this,A,de).call(this,s);let{fetch:i}=d(),c=yield i(g.toString(),{signal:r});return yield L(c),yield c.json()})}retrieve(e,t){return m(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");let{sessionToken:n,signal:r}=t,s=f.convert(n),g=new URL(ge);g.search=y({access_token:this.accessToken,session_token:s.id});let{fetch:i}=d(),c=yield i(g.toString(),R(a({},S(this,G,Ue).call(this,e)),{signal:r}));return yield L(c),yield c.json()})}canRetrieve(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===z:!1}canSuggest(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===K:!1}forward(n){return m(this,arguments,function*(e,t={}){if(!e)throw new Error("searchText is required");let r=a(a({},this.defaults),t),s=r.permanent?ue:ce,g=new URL(`${s}/${encodeURIComponent(e)}`);g.search=S(this,A,de).call(this,r);let{fetch:i}=d(),c=yield i(g.toString(),{signal:r.signal});return yield L(c),yield c.json()})}reverse(n){return m(this,arguments,function*(e,t={}){if(!e)throw new Error("lngLat is required");let r=a(a({},this.defaults),t),s=typeof e=="string"?e:u.convert(e).toArray().join(","),g=r.permanent?me:le,i=new URL(`${g}/${encodeURIComponent(s)}`);i.search=y({access_token:this.accessToken,language:r.language,limit:r.limit},r.types&&{types:typeof r.types=="string"?r.types:[...r.types].join(",")});let{fetch:c}=d(),l=yield c(i.toString(),{signal:r.signal});return yield L(l),yield l.json()})}},I=H;A=new WeakSet,de=function(e){return y({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit,navigation_profile:e.navigation_profile,eta_type:e.eta_type},e.sessionToken&&{session_token:f.convert(e.sessionToken).id},e.origin&&{origin:typeof e.origin=="string"?e.origin:u.convert(e.origin).toArray().join(",")},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:u.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:p.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},G=new WeakSet,Ue=function(e){if(!this.canRetrieve(e)&&!this.canSuggest(e))throw new Error("Suggestion cannot be retrieved or suggested");let t=e.action,n=JSON.stringify(t.body);return{method:t.method,body:n,headers:{"Content-Type":"application/json","Content-Length":n.length.toString()}}},I.defaults={language:"en"};var Le="https://api.mapbox.com/autofill/v1",je="suggest",Ne="retrieve",be=`${Le}/${je}`,Re=`${Le}/${Ne}`;var V,$e,Q=class{constructor(e={}){h(this,V);let r=e,{accessToken:t}=r,n=T(r,["accessToken"]);this.accessToken=t,this.defaults=a(a({},Q.defaults),n)}suggest(e,t){return m(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:n,signal:r}=t,s=R(a(a({},this.defaults),t),{sessionToken:n}),g=new URL(`${be}/${encodeURIComponent(e)}`);g.search=S(this,V,$e).call(this,s);let{fetch:i}=d(),c=yield i(g.toString(),{signal:r});yield L(c);let l=yield c.json();return R(a({},l),{suggestions:l.suggestions.map(x=>R(a({},x),{original_search_text:e}))})})}retrieve(e,t){return m(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");let{sessionToken:n,signal:r}=t,s=f.convert(n),g=new URL(`${Re}/${e.action.id}`);g.search=y({access_token:this.accessToken,session_token:s.id});let{fetch:i}=d(),c=yield i(g.toString(),{signal:r});return yield L(c),yield c.json()})}canRetrieve(e){let t=e.action;return typeof(t==null?void 0:t.id)=="string"}},C=Q;V=new WeakSet,$e=function(e){return y({types:"address",streets:!0,access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit},e.sessionToken&&{session_token:f.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:u.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:p.convert(e.bbox).toFlatArray().join(",")})},C.defaults={language:"en",proximity:"ip"};var Ie="https://api.mapbox.com/autofill/v1",Ge="retrieve",Se=`${Ie}/${Ge}`;var q,Ce,J=class{constructor(e={}){h(this,q);let r=e,{accessToken:t}=r,n=T(r,["accessToken"]);this.accessToken=t,this.defaults=a(a({},J.defaults),n)}validate(e,t){return m(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:n,signal:r}=t,s=R(a(a({},this.defaults),t),{sessionToken:n}),g=new URL(`${Se}/${encodeURIComponent(e)}`);g.search=S(this,q,Ce).call(this,s);let{fetch:i}=d(),c=yield i(g.toString(),{signal:r});yield L(c);let l=yield c.json();return l.features.length>0&&(l.features=[l.features[0]]),l})}},D=J;q=new WeakSet,Ce=function(e){return y({access_token:this.accessToken,language:e.language,country:e.country},e.sessionToken&&{session_token:f.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:u.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:p.convert(e.bbox).toFlatArray().join(",")})},D.defaults={language:"en",proximity:"ip"};var ye="https://api.mapbox.com/geocoding/v5",X=`${ye}/mapbox.places`,Y=`${ye}/mapbox.places-permanent`;var P,ke,Z=class{constructor(e={}){h(this,P);let r=e,{accessToken:t}=r,n=T(r,["accessToken"]);this.accessToken=t,this.defaults=a({},n)}forward(e,t){return m(this,null,function*(){if(!e)throw new Error("searchText is required");let n;t&&({signal:n}=t);let r=a(a({},this.defaults),t),s=r.permanent?Y:X,g=new URL(`${s}/${encodeURIComponent(e)}.json`);g.search=S(this,P,ke).call(this,r);let{fetch:i}=d(),c=n?{signal:n}:{},l=yield i(g.toString(),c);return yield L(l),yield l.json()})}reverse(e,t){return m(this,null,function*(){if(!e)throw new Error("lngLat is required");let n;t&&({signal:n}=t);let r=a(a({},this.defaults),t),s=typeof e=="string"?e:u.convert(e).toArray().join(","),g=r.permanent?Y:X,i=new URL(`${g}/${encodeURIComponent(s)}.json`);i.search=S(this,P,ke).call(this,r,!0);let{fetch:c}=d(),l=n?{signal:n}:{},x=yield c(i.toString(),l);return yield L(x),yield x.json()})}};P=new WeakSet,ke=function(e,t=!1){return t&&["proximity","autocomplete","fuzzyMatch","bbox"].forEach(n=>{n in e&&delete e[n]}),y({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit,autocomplete:e.autocomplete,fuzzyMatch:e.fuzzyMatch,routing:e.routing,worldview:e.worldview},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:u.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:p.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})};var ee=(r=>(r.exact="exact",r.high="high",r.medium="medium",r.low="low",r))(ee||{});var O,_=class{constructor(){h(this,O,{})}addEventListener(e,t){let n=b(this,O);n[e]||(n[e]=[]),n[e].push(t)}removeEventListener(e,t){let n=b(this,O);if(!n[e])return;let r=n[e],s=r.indexOf(t);s!==-1&&r.splice(s,1)}fire(e,t){let n=b(this,O);if(!n[e])return;let r=n[e];for(let s of r)s(t)}};O=new WeakMap;function B(o,e,t){let n=null;return(...r)=>{n!==null&&clearTimeout(n);let s=t&&t();n=setTimeout(()=>{n=null,!(s==null?void 0:s.aborted)&&o(...r)},e)}}function te(){let{AbortController:o}=d();return new o}var v,k,F,ne=class extends _{constructor(e,t=0){super();this.sessionToken=new f;h(this,v,void 0);h(this,k,te());h(this,F,void 0);w(this,F,B((s,...g)=>m(this,[s,...g],function*(n,r={}){if(b(this,k).abort(),w(this,k,te()),!n){w(this,v,null),this.fire("suggest",b(this,v));return}try{let i=yield this.search.suggest(n,R(a({sessionToken:this.sessionToken},r),{signal:b(this,k).signal}));w(this,v,i),this.fire("suggest",i)}catch(i){if(i.name==="AbortError")return;this.fire("suggesterror",i)}}),t,()=>b(this,k).signal)),Object.defineProperties(this,{search:{value:e,writable:!1},debounce:{value:t,writable:!1}})}get suggestions(){return b(this,v)}suggest(e,t){return b(this,F).call(this,e,t),new Promise((n,r)=>{let s,g;s=i=>{this.removeEventListener("suggest",s),this.removeEventListener("suggesterror",g),n(i)},g=i=>{this.removeEventListener("suggest",s),this.removeEventListener("suggesterror",g),r(i)},this.addEventListener("suggest",s),this.addEventListener("suggesterror",g)})}clear(){this.suggest("")}retrieve(e,t){return m(this,null,function*(){let n=yield this.search.retrieve(e,a({sessionToken:this.sessionToken},t));return this.fire("retrieve",n),n})}canRetrieve(e){return this.search.canRetrieve?this.search.canRetrieve(e):!0}canSuggest(e){return this.search.canSuggest?this.search.canSuggest(e):!0}abort(){b(this,k).abort(),w(this,k,te())}};v=new WeakMap,k=new WeakMap,F=new WeakMap;function Te(o){let{properties:e}=o;return a({},e)}return _e(Ve);})();
var mapboxsearchcore=(()=>{var N=Object.defineProperty,Pe=Object.defineProperties,Ue=Object.getOwnPropertyDescriptor,Fe=Object.getOwnPropertyDescriptors,Ne=Object.getOwnPropertyNames,F=Object.getOwnPropertySymbols;var K=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable;var ae=(o,e,t)=>e in o?N(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,g=(o,e)=>{for(var t in e||(e={}))K.call(e,t)&&ae(o,t,e[t]);if(F)for(var t of F(e))ge.call(e,t)&&ae(o,t,e[t]);return o},y=(o,e)=>Pe(o,Fe(e)),je=o=>N(o,"__esModule",{value:!0});var k=(o,e)=>{var t={};for(var n in o)K.call(o,n)&&e.indexOf(n)<0&&(t[n]=o[n]);if(o!=null&&F)for(var n of F(o))e.indexOf(n)<0&&ge.call(o,n)&&(t[n]=o[n]);return t};var $e=(o,e)=>{for(var t in e)N(o,t,{get:e[t],enumerable:!0})},Ie=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ne(e))!K.call(o,r)&&(t||r!=="default")&&N(o,r,{get:()=>e[r],enumerable:!(n=Ue(e,r))||n.enumerable});return o};var Be=(o=>(e,t)=>o&&o.get(e)||(t=Ie(je({}),e,1),o&&o.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var z=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var R=(o,e,t)=>(z(o,e,"read from private field"),t?t.call(o):e.get(o)),d=(o,e,t)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,t)},w=(o,e,t,n)=>(z(o,e,"write to private field"),n?n.call(o,t):e.set(o,t),t);var b=(o,e,t)=>(z(o,e,"access private method"),t);var p=(o,e,t)=>new Promise((n,r)=>{var s=c=>{try{a(t.next(c))}catch(u){r(u)}},i=c=>{try{a(t.throw(c))}catch(u){r(u)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,i);a((t=t.apply(o,e)).next())});var Je={};$e(Je,{Evented:()=>P,LngLat:()=>l,LngLatBounds:()=>f,MapboxAutofill:()=>V,MapboxError:()=>j,MapboxGeocode:()=>ne,MapboxSearch:()=>I,MapboxValidate:()=>q,MatchCodeConfidence:()=>re,SearchBoxCore:()=>G,SearchSession:()=>se,SessionToken:()=>m,debounce:()=>W,featureToSuggestion:()=>Ae,polyfillFetch:()=>ye});var E="https://api.mapbox.com/search/v1",Q="suggest",H="retrieve",ce="forward",ue="reverse",le=`${E}/${Q}`,pe=`${E}/${H}`,me=`${E}/${ce}`,fe=`${E}/permanent/${ce}`,he=`${E}/${ue}`,de=`${E}/permanent/${ue}`;var l=class{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90");if(this.lng>180||this.lng<-180)throw new Error("Invalid LngLat longitude value: must be between -180 and 180")}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}static convert(e){if(e instanceof l)return new l(e.lng,e.lat);if(Array.isArray(e)&&e.length===2)return new l(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null&&("lng"in e||"lon"in e)&&"lat"in e)return new l(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}};var f=class{constructor(e,t){this._sw=l.convert(e),this._ne=l.convert(t)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new l(this.getWest(),this.getNorth())}getSouthEast(){return new l(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toFlatArray(){return[this._sw.lng,this._sw.lat,this._ne.lng,this._ne.lat]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}static convert(e){if(!e)throw new Error("Invalid LngLatBounds convert value: falsy");if(e instanceof f)return new f(e.getSouthWest(),e.getNorthEast());if(Array.isArray(e)&&e.length===2)return new f(l.convert(e[0]),l.convert(e[1]));if(Array.isArray(e)&&e.length===4)return new f(l.convert([e[0],e[1]]),l.convert([e[2],e[3]]));throw new Error("`LngLatBoundsLike` argument must be specified as an array [<LngLatLike>, <LngLatLike>] or an array [<west>, <south>, <east>, <north>]")}};function Se(){let e=(Math.random().toString(16)+Date.now().toString(16)+Math.random().toString(16)).replace(/\./g,"");return[e.slice(0,8),e.slice(8,12),"4"+e.slice(12,15)+"-8"+e.slice(15,18),e.slice(18,30)].join("-")}var m=class{constructor(e){this.id=e!=null?e:Se()}toString(){return this.id}static convert(e){return new m(e instanceof m?e.id:e.toString())}};var Ge="Unknown error",j=class extends Error{constructor(e,t){super(String(e.message||e.error||Ge));this.name="MapboxError",this.statusCode=t}toString(){return`${this.name} (${this.statusCode}): ${this.message}`}};function S(o){return p(this,null,function*(){if(!o.ok){let e=yield o.json();throw new j(e,o.status)}})}var $=globalThis.fetch,Le=globalThis.AbortController;function ye({fetch:o,AbortController:e},t=!1){if(!o)throw new Error("Fetch implementation must include implementations of `fetch`.");$&&!t||($=o,Le=e)}function h(){if(!$)throw new Error("Fetch implementation not found. Please include a fetch polyfill in your application or use `polyfillFetch` from `@mapbox/search-js-core` to fix this issue.");return{fetch:$,AbortController:Le}}function L(...o){let e=[];for(let t of o){if(!t)continue;let n=Object.entries(t);for(let[r,s]of n)s!=null&&e.push(`${r}=${encodeURIComponent(String(s))}`)}return e.join("&")}var _,be,B,Ce,J=class{constructor(e={}){d(this,_);d(this,B);let r=e,{accessToken:t}=r,n=k(r,["accessToken"]);this.accessToken=t,this.defaults=g(g({},J.defaults),n)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:n,signal:r}=t,s=y(g(g({},this.defaults),t),{sessionToken:n});if(s.eta_type&&(!s.origin||!s.navigation_profile))throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");if(s.origin&&!s.navigation_profile)throw new Error("to provide distance estimate: both navigation_profile and origin are required");let i=new URL(`${le}/${encodeURIComponent(e)}`);i.search=b(this,_,be).call(this,s);let{fetch:a}=h(),c=yield a(i.toString(),{signal:r});yield S(c);let u=yield c.json();return u.url=i.toString(),u})}retrieve(e,t){return p(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");let{sessionToken:n,signal:r}=t,s=m.convert(n),i=new URL(pe);i.search=L({access_token:this.accessToken,session_token:s.id});let{fetch:a}=h(),c=yield a(i.toString(),y(g({},b(this,B,Ce).call(this,e)),{signal:r}));yield S(c);let u=yield c.json();return u.url=i.toString(),u})}canRetrieve(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===H:!1}canSuggest(e){let t=e.action;return t?t.method==="POST"&&t.endpoint===Q:!1}forward(n){return p(this,arguments,function*(e,t={}){if(!e)throw new Error("searchText is required");let r=g(g({},this.defaults),t),s=r.permanent?fe:me,i=new URL(`${s}/${encodeURIComponent(e)}`);i.search=b(this,_,be).call(this,r);let{fetch:a}=h(),c=yield a(i.toString(),{signal:r.signal});return yield S(c),yield c.json()})}reverse(n){return p(this,arguments,function*(e,t={}){if(!e)throw new Error("lngLat is required");let r=g(g({},this.defaults),t),s=typeof e=="string"?e:l.convert(e).toArray().join(","),i=r.permanent?de:he,a=new URL(`${i}/${encodeURIComponent(s)}`);a.search=L({access_token:this.accessToken,language:r.language,limit:r.limit},r.types&&{types:typeof r.types=="string"?r.types:[...r.types].join(",")});let{fetch:c}=h(),u=yield c(a.toString(),{signal:r.signal});return yield S(u),yield u.json()})}},I=J;_=new WeakSet,be=function(e){return L({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit,navigation_profile:e.navigation_profile,eta_type:e.eta_type},e.sessionToken&&{session_token:m.convert(e.sessionToken).id},e.origin&&{origin:typeof e.origin=="string"?e.origin:l.convert(e.origin).toArray().join(",")},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:f.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},B=new WeakSet,Ce=function(e){if(!this.canRetrieve(e)&&!this.canSuggest(e))throw new Error("Suggestion cannot be retrieved or suggested");let t=e.action,n=JSON.stringify(t.body);return{method:t.method,body:n,headers:{"Content-Type":"application/json","Content-Length":n.length.toString()}}},I.defaults={language:"en"};var Re="https://api.mapbox.com/search/searchbox/v1",Ve="suggest",De="retrieve",ke=`${Re}/${Ve}`,xe=`${Re}/${De}`;var C,qe,X=class{constructor(e={}){d(this,C);let r=e,{accessToken:t}=r,n=k(r,["accessToken"]);this.accessToken=t,this.defaults=g(g({},X.defaults),n)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:n,signal:r}=t,s=y(g(g({},this.defaults),t),{q:e,sessionToken:n});if(s.eta_type&&(!s.origin||!s.navigation_profile))throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");if(s.origin&&!s.navigation_profile)throw new Error("to provide distance estimate: both navigation_profile and origin are required");let i=new URL(ke);i.search=b(this,C,qe).call(this,s);let{fetch:a}=h(),c=yield a(i.toString(),{signal:r});yield S(c);let u=yield c.json();return u.url=i.toString(),u})}retrieve(e,t){return p(this,null,function*(){if(!e)throw new Error("suggestion is required");let{sessionToken:n,signal:r}=t,s=m.convert(n),i=new URL(`${xe}/${encodeURIComponent(e.mapbox_id)}`);i.search=L({access_token:this.accessToken,session_token:s.id});let{fetch:a}=h(),c=yield a(i.toString(),{signal:r});yield S(c);let u=yield c.json();return u.url=i.toString(),u})}},G=X;C=new WeakSet,qe=function(e){return L({q:e.q,access_token:this.accessToken,language:e.language,limit:e.limit,navigation_profile:e.navigation_profile,route:e.route,route_geometry:e.route_geometry,sar_type:e.sar_type,time_deviation:e.time_deviation,eta_type:e.eta_type,country:e.country,poi_category:e.poi_category,radius:e.radius,user_id:e.user_id,rich_metadata_provider:e.rich_metadata_provider,poi_category_exclusions:e.poi_category_exclusions},e.sessionToken&&{session_token:m.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.origin&&{origin:typeof e.origin=="string"?e.origin:l.convert(e.origin).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:f.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},G.defaults={language:"en"};var Te="https://api.mapbox.com/autofill/v1",Me="suggest",We="retrieve",ve=`${Te}/${Me}`,we=`${Te}/${We}`;var D,Ke,Y=class{constructor(e={}){d(this,D);let r=e,{accessToken:t}=r,n=k(r,["accessToken"]);this.accessToken=t,this.defaults=g(g({},Y.defaults),n)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:n,signal:r}=t,s=y(g(g({},this.defaults),t),{sessionToken:n}),i=new URL(`${ve}/${encodeURIComponent(e)}`);i.search=b(this,D,Ke).call(this,s);let{fetch:a}=h(),c=yield a(i.toString(),{signal:r});yield S(c);let u=yield c.json();return y(g({},u),{suggestions:u.suggestions.map(T=>y(g({},T),{original_search_text:e})),url:i.toString()})})}retrieve(e,t){return p(this,null,function*(){if(!e)throw new Error("suggestion is required");if(!this.canRetrieve(e))throw new Error("suggestion cannot be retrieved");let{sessionToken:n,signal:r}=t,s=m.convert(n),i=new URL(`${we}/${e.action.id}`);i.search=L({access_token:this.accessToken,session_token:s.id});let{fetch:a}=h(),c=yield a(i.toString(),{signal:r});yield S(c);let u=yield c.json();return u.url=i.toString(),u})}canRetrieve(e){let t=e.action;return typeof(t==null?void 0:t.id)=="string"}},V=Y;D=new WeakSet,Ke=function(e){return L({types:"address",streets:!0,access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit},e.sessionToken&&{session_token:m.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:f.convert(e.bbox).toFlatArray().join(",")})},V.defaults={language:"en",proximity:"ip"};var ze="https://api.mapbox.com/autofill/v1",Qe="retrieve",Ee=`${ze}/${Qe}`;var M,He,Z=class{constructor(e={}){d(this,M);let r=e,{accessToken:t}=r,n=k(r,["accessToken"]);this.accessToken=t,this.defaults=g(g({},Z.defaults),n)}validate(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:n,signal:r}=t,s=y(g(g({},this.defaults),t),{sessionToken:n}),i=new URL(`${Ee}/${encodeURIComponent(e)}`);i.search=b(this,M,He).call(this,s);let{fetch:a}=h(),c=yield a(i.toString(),{signal:r});yield S(c);let u=yield c.json();return u.url=i.toString(),u.features.length>0&&(u.features=[u.features[0]]),u})}},q=Z;M=new WeakSet,He=function(e){return L({access_token:this.accessToken,language:e.language,country:e.country},e.sessionToken&&{session_token:m.convert(e.sessionToken).id},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:f.convert(e.bbox).toFlatArray().join(",")})},q.defaults={language:"en",proximity:"ip"};var Oe="https://api.mapbox.com/geocoding/v5",ee=`${Oe}/mapbox.places`,te=`${Oe}/mapbox.places-permanent`;var A,_e,ne=class{constructor(e={}){d(this,A);let r=e,{accessToken:t}=r,n=k(r,["accessToken"]);this.accessToken=t,this.defaults=g({},n)}forward(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let n;t&&({signal:n}=t);let r=g(g({},this.defaults),t),s=r.permanent?te:ee,i=new URL(`${s}/${encodeURIComponent(e)}.json`);i.search=b(this,A,_e).call(this,r);let{fetch:a}=h(),c=n?{signal:n}:{},u=yield a(i.toString(),c);yield S(u);let T=yield u.json();return T.url=i.toString(),T})}reverse(e,t){return p(this,null,function*(){if(!e)throw new Error("lngLat is required");let n;t&&({signal:n}=t);let r=g(g({},this.defaults),t),s=typeof e=="string"?e:l.convert(e).toArray().join(","),i=r.permanent?te:ee,a=new URL(`${i}/${encodeURIComponent(s)}.json`);a.search=b(this,A,_e).call(this,r,!0);let{fetch:c}=h(),u=n?{signal:n}:{},T=yield c(a.toString(),u);yield S(T);let ie=yield T.json();return ie.url=a.toString(),ie})}};A=new WeakSet,_e=function(e,t=!1){return t&&["proximity","autocomplete","fuzzyMatch","bbox"].forEach(n=>{n in e&&delete e[n]}),L({access_token:this.accessToken,language:e.language,country:e.country,limit:e.limit,autocomplete:e.autocomplete,fuzzyMatch:e.fuzzyMatch,routing:e.routing,worldview:e.worldview},e.proximity&&{proximity:typeof e.proximity=="string"?e.proximity:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:f.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})};var re=(r=>(r.exact="exact",r.high="high",r.medium="medium",r.low="low",r))(re||{});var O,P=class{constructor(){d(this,O,{})}addEventListener(e,t){let n=R(this,O);n[e]||(n[e]=[]),n[e].push(t)}removeEventListener(e,t){let n=R(this,O);if(!n[e])return;let r=n[e],s=r.indexOf(t);s!==-1&&r.splice(s,1)}fire(e,t){let n=R(this,O);if(!n[e])return;let r=n[e];for(let s of r)s(t)}};O=new WeakMap;function W(o,e,t){let n=null;return(...r)=>{n!==null&&clearTimeout(n);let s=t&&t();n=setTimeout(()=>{n=null,!(s==null?void 0:s.aborted)&&o(...r)},e)}}function oe(){let{AbortController:o}=h();return new o}var v,x,U,se=class extends P{constructor(e,t=0){super();this.sessionToken=new m;d(this,v,void 0);d(this,x,oe());d(this,U,void 0);w(this,U,W((s,...i)=>p(this,[s,...i],function*(n,r={}){if(R(this,x).abort(),w(this,x,oe()),!n){w(this,v,null),this.fire("suggest",R(this,v));return}try{let a=yield this.search.suggest(n,y(g({sessionToken:this.sessionToken},r),{signal:R(this,x).signal}));w(this,v,a),this.fire("suggest",a)}catch(a){if(a.name==="AbortError")return;this.fire("suggesterror",a)}}),t,()=>R(this,x).signal)),Object.defineProperties(this,{search:{value:e,writable:!1},debounce:{value:t,writable:!1}})}get suggestions(){return R(this,v)}suggest(e,t){return R(this,U).call(this,e,t),new Promise((n,r)=>{let s,i;s=a=>{this.removeEventListener("suggest",s),this.removeEventListener("suggesterror",i),n(a)},i=a=>{this.removeEventListener("suggest",s),this.removeEventListener("suggesterror",i),r(a)},this.addEventListener("suggest",s),this.addEventListener("suggesterror",i)})}clear(){this.suggest("")}retrieve(e,t){return p(this,null,function*(){let n=yield this.search.retrieve(e,g({sessionToken:this.sessionToken},t));return this.fire("retrieve",n),n})}canRetrieve(e){return this.search.canRetrieve?this.search.canRetrieve(e):!0}canSuggest(e){return this.search.canSuggest?this.search.canSuggest(e):!0}abort(){R(this,x).abort(),w(this,x,oe())}};v=new WeakMap,x=new WeakMap,U=new WeakMap;function Ae(o){let{properties:e}=o;return g({},e)}return Be(Je);})();
//# sourceMappingURL=mapboxsearchcore.js.map

@@ -131,2 +131,3 @@ import { AdministrativeUnitTypes, Suggestion, FeatureSuggestion } from './types';

suggestions: Suggestion[];
url: string;
}

@@ -148,2 +149,3 @@ /**

features: FeatureSuggestion[];
url: string;
}

@@ -150,0 +152,0 @@ /**

@@ -76,2 +76,3 @@ import { ValidateFeature } from './types';

features: ValidateFeature[];
url: string;
}

@@ -78,0 +79,0 @@ /**

{
"name": "@mapbox/search-js-core",
"version": "1.0.0-beta.14",
"version": "1.0.0-beta.15",
"description": "Platform agnostic wrappers for the Search API and Geocoding API.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc