Socket
Socket
Sign inDemoInstall

@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.15 to 1.0.0-beta.16

12

dist/autofill/AddressAutofillCore.d.ts

@@ -26,6 +26,6 @@ import { AddressAutofillSuggestion, AddressAutofillFeatureSuggestion } from './types';

/**
* A customer-provided session token value, which groups a series of requests together for [billing purposes](https://docs.mapbox.com/api/search/search/#search-api-pricing).
* A customer-provided session token value, which groups a series of requests together for [billing purposes](https://docs.mapbox.com/api/search/search-box/#search-box-api-pricing).
*
* Reference:
* https://docs.mapbox.com/api/search/search/#session-based-pricing
* https://docs.mapbox.com/api/search/search-box/#session-billing
*/

@@ -65,2 +65,3 @@ sessionToken: SessionTokenLike;

suggestions: AddressAutofillSuggestion[];
url: string;
}

@@ -82,6 +83,7 @@ /**

features: AddressAutofillFeatureSuggestion[];
url: string;
}
/**
* A `AddressAutofillCore` object is an application's main entrypoint to the
* Mapbox Address Autofill API. The Mapbox Address Autofill API is an API similar to {@link MapboxSearch},
* Mapbox Address Autofill API. The Mapbox Address Autofill API is an API similar to {@link SearchBoxCore},
* but targeted towards **address** autocomplete.

@@ -124,6 +126,6 @@ *

*
* Suggestion objects **do not include geographic coordinates**. To get the coordinates of the result, use {@link MapboxSearch#retrieve}.
* Suggestion objects **do not include geographic coordinates**. To get the coordinates of the result, use {@link AddressAutofillCore#retrieve}.
*
* For tracking purposes, it is useful for any follow-up requests based on this suggestion to include same
* {@link Suggestion#sessionToken} as the original request.
* {@link SessionToken} as the original request.
*

@@ -130,0 +132,0 @@ * If you'd like session tokens to be handled automatically, see {@link SearchSession}.

import { LngLatBoundsLike } from '../LngLatBounds';
import { MatchCode } from '../types';
/**
* An `AutofillSuggestion` object represents a suggestion
* result from the Mapbox Autofill API.
* An `AddressAutofillSuggestion` object represents a suggestion
* result from the Mapbox Address Autofill API.
*

@@ -10,3 +10,3 @@ * Suggestion objects are "part one" of the two-step interactive autofill experience.

*
* To get the coordinates of the result, use {@link MapboxAutofill#retrieve}.
* To get the coordinates of the result, use {@link AddressAutofillCore#retrieve}.
*

@@ -16,6 +16,6 @@ * For tracking purposes, it is useful for any follow-up requests based on this suggestion to include same

*
* @typedef AutofillSuggestion
* @typedef AddressAutofillSuggestion
* @example
* ```typescript
* const autofill = new MapboxAutofill({ accessToken: 'pk.my-mapbox-access-token' });
* const autofill = new AddressAutofillCore({ accessToken: 'pk.my-mapbox-access-token' });
*

@@ -31,3 +31,3 @@ * const sessionToken = new SessionToken();

*/
export interface AutofillSuggestion {
export interface AddressAutofillSuggestion {
/**

@@ -39,4 +39,4 @@ * A point accuracy metric for the returned address feature. Can be one of `rooftop`, `parcel`, `point`, `interpolated`, `intersection`, `street`.

/**
* This is added by {@link MapboxAutofill} and is **not** part of the
* Autofill API.
* This is added by {@link AddressAutofillCore} and is **not** part of the
* Mapbox Address Autofill API.
*

@@ -135,8 +135,8 @@ * @ignore

/**
* An `AutofillFeatureSuggestion` object represents [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/)
* suggestion results from the Mapbox Autofill API.
* An `AddressAutofillFeatureSuggestion` object represents [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/)
* suggestion results from the Mapbox Address Autofill API.
*
* As per the Mapbox Autofill API, this will always be [Point](https://geojson.org/geojson-spec.html#point).
* As per the Mapbox Address Autofill API, this will always be [Point](https://geojson.org/geojson-spec.html#point).
*
* @typedef AutofillFeatureSuggestion
* @typedef AddressAutofillFeatureSuggestion
* @example

@@ -156,3 +156,3 @@ * ```typescript

*/
export declare type AutofillFeatureSuggestion = GeoJSON.Feature<GeoJSON.Point, Omit<AutofillSuggestion, 'original_search_text' | 'action'>> & {
export declare type AddressAutofillFeatureSuggestion = GeoJSON.Feature<GeoJSON.Point, Omit<AddressAutofillSuggestion, 'original_search_text' | 'action'>> & {
/**

@@ -159,0 +159,0 @@ * A bounding box for the feature. This may be significantly

@@ -1,5 +0,5 @@

import { FeatureSuggestion, Suggestion } from './search/types';
import { AutofillFeatureSuggestion, AutofillSuggestion } from './autofill/types';
declare function featureToSuggestion(feature: FeatureSuggestion): Suggestion;
declare function featureToSuggestion(feature: AutofillFeatureSuggestion): AutofillSuggestion;
import { SearchBoxFeatureSuggestion, SearchBoxFeatureProperties } from './searchbox/types';
import { AddressAutofillFeatureSuggestion, AddressAutofillSuggestion } from './autofill/types';
declare function featureToSuggestion(feature: SearchBoxFeatureSuggestion): SearchBoxFeatureProperties;
declare function featureToSuggestion(feature: AddressAutofillFeatureSuggestion): AddressAutofillSuggestion;
export { featureToSuggestion };

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

attribution: string;
url: string;
}

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

@@ -17,5 +17,5 @@ import { LngLatLike } from '../LngLat';

*
* @typedef GeocodeFeatureProperties
* @typedef GeocodingFeatureProperties
*/
export interface GeocodeFeatureProperties {
export interface GeocodingFeatureProperties {
/**

@@ -48,7 +48,7 @@ * A point accuracy metric for the returned address feature. Can be one of `rooftop`, `parcel`, `point`, `interpolated`, `intersection`, `street`.

/**
* Object representing one level of hierarcy among encompassing parent features for a given {@link GeocodeFeature}.
* Object representing one level of hierarcy among encompassing parent features for a given {@link GeocodingFeature}.
*
* @typedef GeocodeFeatureContext
* @typedef GeocodingFeatureContext
*/
export declare type GeocodeFeatureContext = Partial<GeocodeFeatureProperties> & {
export declare type GeocodingFeatureContext = Partial<GeocodingFeatureProperties> & {
/**

@@ -64,3 +64,3 @@ * A feature ID in the format `{type}.{id}`.

/**
* A `GeocodeFeature` object represents a [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/) feature result from the [Mapbox Geocoding API](https://docs.mapbox.com/api/search/geocoding/).
* A `GeocodingFeature` object represents a [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/) feature result from the [Mapbox Geocoding API](https://docs.mapbox.com/api/search/geocoding/).
*

@@ -82,7 +82,6 @@ * **Legal terms:**

*
* @typedef GeocodeFeature
* @typedef GeocodingFeature
* @see [Geocoding response object](https://docs.mapbox.com/api/search/geocoding/#geocoding-response-object)
*/
export declare type GeocodeFeature = GeoJSON.Feature<GeoJSON.Point, GeocodeFeatureProperties> & {
accuracy?: string;
export declare type GeocodingFeature = GeoJSON.Feature<GeoJSON.Point, GeocodingFeatureProperties> & {
/**

@@ -136,3 +135,3 @@ * A feature ID in the format `{type}.{id}` where `{type}` is the lowest hierarchy feature in the `place_type` field.

*/
context: GeocodeFeatureContext[];
context: GeocodingFeatureContext[];
};

@@ -98,10 +98,11 @@ var __defProp = Object.defineProperty;

__export(src_exports, {
AddressAutofillCore: () => AddressAutofillCore,
Evented: () => Evented,
GeocodingCore: () => GeocodingCore,
LngLat: () => LngLat,
LngLatBounds: () => LngLatBounds,
MapboxAutofill: () => MapboxAutofill,
MapboxAutofill: () => AddressAutofillCore,
MapboxError: () => MapboxError,
MapboxGeocode: () => MapboxGeocode,
MapboxSearch: () => MapboxSearch,
MapboxValidate: () => MapboxValidate,
MapboxGeocode: () => GeocodingCore,
MapboxValidate: () => ValidationCore,
MatchCodeConfidence: () => MatchCodeConfidence,

@@ -111,2 +112,3 @@ SearchBoxCore: () => SearchBoxCore,

SessionToken: () => SessionToken,
ValidationCore: () => ValidationCore,
debounce: () => debounce,

@@ -117,14 +119,8 @@ featureToSuggestion: () => featureToSuggestion,

// src/search/constants.ts
var SEARCH_URL = `https://api.mapbox.com/search/v1`;
// src/autofill/constants.ts
var SEARCH_URL = `https://api.mapbox.com/autofill/v1`;
var ENDPOINT_SUGGEST = "suggest";
var ENDPOINT_RETRIEVE = "retrieve";
var ENDPOINT_FORWARD = "forward";
var ENDPOINT_REVERSE = "reverse";
var SUGGEST_URL = `${SEARCH_URL}/${ENDPOINT_SUGGEST}`;
var RETRIEVE_URL = `${SEARCH_URL}/${ENDPOINT_RETRIEVE}`;
var FORWARD_URL = `${SEARCH_URL}/${ENDPOINT_FORWARD}`;
var PERMANENT_FORWARD_URL = `${SEARCH_URL}/permanent/${ENDPOINT_FORWARD}`;
var REVERSE_URL = `${SEARCH_URL}/${ENDPOINT_REVERSE}`;
var PERMANENT_REVERSE_URL = `${SEARCH_URL}/permanent/${ENDPOINT_REVERSE}`;

@@ -308,11 +304,10 @@ // src/LngLat.ts

// src/search/MapboxSearch.ts
var _getQueryParams, getQueryParams_fn, _getFetchInfo, getFetchInfo_fn;
var _MapboxSearch = class {
// src/autofill/AddressAutofillCore.ts
var _getQueryParams, getQueryParams_fn;
var _AddressAutofillCore = class {
constructor(options = {}) {
__privateAdd(this, _getQueryParams);
__privateAdd(this, _getFetchInfo);
const _a = options, { accessToken } = _a, defaults = __objRest(_a, ["accessToken"]);
this.accessToken = accessToken;
this.defaults = __spreadValues(__spreadValues({}, _MapboxSearch.defaults), defaults);
this.defaults = __spreadValues(__spreadValues({}, _AddressAutofillCore.defaults), defaults);
}

@@ -328,8 +323,2 @@ suggest(searchText, optionsArg) {

});
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_URL}/${encodeURIComponent(searchText)}`);

@@ -343,4 +332,10 @@ url.search = __privateMethod(this, _getQueryParams, getQueryParams_fn).call(this, options);

const json = yield res.json();
json.url = url.toString();
return json;
return __spreadProps(__spreadValues({}, json), {
suggestions: json.suggestions.map((suggestion) => {
return __spreadProps(__spreadValues({}, suggestion), {
original_search_text: searchText
});
}),
url: url.toString()
});
});

@@ -358,3 +353,3 @@ }

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

@@ -365,5 +360,3 @@ access_token: this.accessToken,

const { fetch } = getFetch();
const res = yield fetch(url.toString(), __spreadProps(__spreadValues({}, __privateMethod(this, _getFetchInfo, getFetchInfo_fn).call(this, suggestion)), {
signal
}));
const res = yield fetch(url.toString(), { signal });
yield handleNonOkRes(res);

@@ -377,72 +370,17 @@ const json = yield res.json();

const action = suggestion.action;
if (!action) {
return false;
}
return action.method === "POST" && action.endpoint === ENDPOINT_RETRIEVE;
return typeof (action == null ? void 0 : action.id) === "string";
}
canSuggest(suggestion) {
const action = suggestion.action;
if (!action) {
return false;
}
return action.method === "POST" && action.endpoint === ENDPOINT_SUGGEST;
}
forward(_0) {
return __async(this, arguments, function* (searchText, optionsArg = {}) {
if (!searchText) {
throw new Error("searchText is required");
}
const options = __spreadValues(__spreadValues({}, this.defaults), optionsArg);
const baseUrl = options.permanent ? PERMANENT_FORWARD_URL : FORWARD_URL;
const url = new URL(`${baseUrl}/${encodeURIComponent(searchText)}`);
url.search = __privateMethod(this, _getQueryParams, getQueryParams_fn).call(this, options);
const { fetch } = getFetch();
const res = yield fetch(url.toString(), {
signal: options.signal
});
yield handleNonOkRes(res);
const json = yield res.json();
return json;
});
}
reverse(_0) {
return __async(this, arguments, function* (lngLat, optionsArg = {}) {
if (!lngLat) {
throw new Error("lngLat is required");
}
const options = __spreadValues(__spreadValues({}, this.defaults), optionsArg);
const searchText = typeof lngLat === "string" ? lngLat : LngLat.convert(lngLat).toArray().join(",");
const baseUrl = options.permanent ? PERMANENT_REVERSE_URL : REVERSE_URL;
const url = new URL(`${baseUrl}/${encodeURIComponent(searchText)}`);
url.search = queryParams({
access_token: this.accessToken,
language: options.language,
limit: options.limit
}, options.types && {
types: typeof options.types === "string" ? options.types : [...options.types].join(",")
});
const { fetch } = getFetch();
const res = yield fetch(url.toString(), {
signal: options.signal
});
yield handleNonOkRes(res);
const json = yield res.json();
return json;
});
}
};
var MapboxSearch = _MapboxSearch;
var AddressAutofillCore = _AddressAutofillCore;
_getQueryParams = new WeakSet();
getQueryParams_fn = function(options) {
return queryParams({
types: "address",
streets: true,
access_token: this.accessToken,
language: options.language,
country: options.country,
limit: options.limit,
navigation_profile: options.navigation_profile,
eta_type: options.eta_type
limit: options.limit
}, options.sessionToken && {
session_token: SessionToken.convert(options.sessionToken).id
}, options.origin && {
origin: typeof options.origin === "string" ? options.origin : LngLat.convert(options.origin).toArray().join(",")
}, options.proximity && {

@@ -452,25 +390,8 @@ proximity: typeof options.proximity === "string" ? options.proximity : LngLat.convert(options.proximity).toArray().join(",")

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(",")
});
};
_getFetchInfo = new WeakSet();
getFetchInfo_fn = function(suggestion) {
if (!this.canRetrieve(suggestion) && !this.canSuggest(suggestion)) {
throw new Error("Suggestion cannot be retrieved or suggested");
}
const action = suggestion.action;
const body = JSON.stringify(action.body);
return {
method: action.method,
body,
headers: {
"Content-Type": "application/json",
"Content-Length": body.length.toString()
}
};
AddressAutofillCore.defaults = {
language: "en",
proximity: "ip"
};
MapboxSearch.defaults = {
language: "en"
};

@@ -481,4 +402,8 @@ // src/searchbox/constants.ts

var ENDPOINT_RETRIEVE2 = "retrieve";
var ENDPOINT_CATEGORY = "category";
var ENDPOINT_REVERSE = "reverse";
var SUGGEST_URL2 = `${SEARCH_URL2}/${ENDPOINT_SUGGEST2}`;
var RETRIEVE_URL2 = `${SEARCH_URL2}/${ENDPOINT_RETRIEVE2}`;
var CATEGORY_URL = `${SEARCH_URL2}/${ENDPOINT_CATEGORY}`;
var REVERSE_URL = `${SEARCH_URL2}/${ENDPOINT_REVERSE}`;

@@ -544,2 +469,50 @@ // src/searchbox/SearchBoxCore.ts

}
category(_0) {
return __async(this, arguments, function* (category, optionsArg = {}) {
if (!category) {
throw new Error("category is required");
}
const options = __spreadValues(__spreadValues({}, this.defaults), optionsArg);
const url = new URL(`${CATEGORY_URL}/${encodeURIComponent(category)}`);
url.search = __privateMethod(this, _getQueryParams2, getQueryParams_fn2).call(this, options);
const { fetch } = getFetch();
const res = yield fetch(url.toString(), {
signal: options.signal
});
yield handleNonOkRes(res);
const json = yield res.json();
json.url = url.toString();
return json;
});
}
reverse(_0) {
return __async(this, arguments, function* (lngLat, optionsArg = {}) {
if (!lngLat) {
throw new Error("lngLat is required");
}
const [lng, lat] = typeof lngLat === "string" ? lngLat.split(",").map((x) => parseFloat(x)) : LngLat.convert(lngLat).toArray();
if (isNaN(lng) || isNaN(lat)) {
throw new Error("lngLat is required");
}
const options = __spreadValues(__spreadValues({}, this.defaults), optionsArg);
const url = new URL(REVERSE_URL);
url.search = queryParams({
access_token: this.accessToken,
language: options.language,
limit: options.limit,
longitude: lng,
latitude: lat
}, options.types && {
types: typeof options.types === "string" ? options.types : [...options.types].join(",")
});
const { fetch } = getFetch();
const res = yield fetch(url.toString(), {
signal: options.signal
});
yield handleNonOkRes(res);
const json = yield res.json();
json.url = url.toString();
return json;
});
}
};

@@ -582,12 +555,10 @@ var SearchBoxCore = _SearchBoxCore;

// src/autofill/constants.ts
// src/validate/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}`;
var ENDPOINT_VALIDATE = "retrieve";
var VALIDATE_URL = `${SEARCH_URL3}/${ENDPOINT_VALIDATE}`;
// src/autofill/MapboxAutofill.ts
// src/validate/ValidationCore.ts
var _getQueryParams3, getQueryParams_fn3;
var _MapboxAutofill = class {
var _ValidationCore = class {
constructor(options = {}) {

@@ -597,96 +568,4 @@ __privateAdd(this, _getQueryParams3);

this.accessToken = accessToken;
this.defaults = __spreadValues(__spreadValues({}, _MapboxAutofill.defaults), defaults);
this.defaults = __spreadValues(__spreadValues({}, _ValidationCore.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), {
suggestions: json.suggestions.map((suggestion) => {
return __spreadProps(__spreadValues({}, suggestion), {
original_search_text: searchText
});
}),
url: url.toString()
});
});
}
retrieve(suggestion, optionsArg) {
return __async(this, null, function* () {
if (!suggestion) {
throw new Error("suggestion is required");
}
if (!this.canRetrieve(suggestion)) {
throw new Error("suggestion cannot be retrieved");
}
const { sessionToken: sessionTokenLike, signal } = optionsArg;
const sessionToken = SessionToken.convert(sessionTokenLike);
const url = new URL(`${RETRIEVE_URL3}/${suggestion.action.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;
});
}
canRetrieve(suggestion) {
const action = suggestion.action;
return typeof (action == null ? void 0 : action.id) === "string";
}
};
var MapboxAutofill = _MapboxAutofill;
_getQueryParams3 = new WeakSet();
getQueryParams_fn3 = function(options) {
return queryParams({
types: "address",
streets: true,
access_token: this.accessToken,
language: options.language,
country: options.country,
limit: options.limit
}, 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.bbox && {
bbox: typeof options.bbox === "string" ? options.bbox : LngLatBounds.convert(options.bbox).toFlatArray().join(",")
});
};
MapboxAutofill.defaults = {
language: "en",
proximity: "ip"
};
// src/validate/constants.ts
var SEARCH_URL4 = `https://api.mapbox.com/autofill/v1`;
var ENDPOINT_VALIDATE = "retrieve";
var VALIDATE_URL = `${SEARCH_URL4}/${ENDPOINT_VALIDATE}`;
// src/validate/MapboxValidate.ts
var _getQueryParams4, getQueryParams_fn4;
var _MapboxValidate = class {
constructor(options = {}) {
__privateAdd(this, _getQueryParams4);
const _a = options, { accessToken } = _a, defaults = __objRest(_a, ["accessToken"]);
this.accessToken = accessToken;
this.defaults = __spreadValues(__spreadValues({}, _MapboxValidate.defaults), defaults);
}
validate(searchText, optionsArg) {

@@ -702,3 +581,3 @@ return __async(this, null, function* () {

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

@@ -718,5 +597,5 @@ const res = yield fetch(url.toString(), {

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

@@ -734,3 +613,3 @@ access_token: this.accessToken,

};
MapboxValidate.defaults = {
ValidationCore.defaults = {
language: "en",

@@ -741,11 +620,11 @@ proximity: "ip"

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

@@ -767,3 +646,3 @@ this.accessToken = accessToken;

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

@@ -791,3 +670,3 @@ const fetchInit = signal ? { signal } : {};

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

@@ -803,4 +682,4 @@ const fetchInit = signal ? { signal } : {};

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

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

@@ -75,14 +75,8 @@ var __defProp = Object.defineProperty;

// src/search/constants.ts
var SEARCH_URL = `https://api.mapbox.com/search/v1`;
// src/autofill/constants.ts
var SEARCH_URL = `https://api.mapbox.com/autofill/v1`;
var ENDPOINT_SUGGEST = "suggest";
var ENDPOINT_RETRIEVE = "retrieve";
var ENDPOINT_FORWARD = "forward";
var ENDPOINT_REVERSE = "reverse";
var SUGGEST_URL = `${SEARCH_URL}/${ENDPOINT_SUGGEST}`;
var RETRIEVE_URL = `${SEARCH_URL}/${ENDPOINT_RETRIEVE}`;
var FORWARD_URL = `${SEARCH_URL}/${ENDPOINT_FORWARD}`;
var PERMANENT_FORWARD_URL = `${SEARCH_URL}/permanent/${ENDPOINT_FORWARD}`;
var REVERSE_URL = `${SEARCH_URL}/${ENDPOINT_REVERSE}`;
var PERMANENT_REVERSE_URL = `${SEARCH_URL}/permanent/${ENDPOINT_REVERSE}`;

@@ -266,11 +260,10 @@ // src/LngLat.ts

// src/search/MapboxSearch.ts
var _getQueryParams, getQueryParams_fn, _getFetchInfo, getFetchInfo_fn;
var _MapboxSearch = class {
// src/autofill/AddressAutofillCore.ts
var _getQueryParams, getQueryParams_fn;
var _AddressAutofillCore = class {
constructor(options = {}) {
__privateAdd(this, _getQueryParams);
__privateAdd(this, _getFetchInfo);
const _a = options, { accessToken } = _a, defaults = __objRest(_a, ["accessToken"]);
this.accessToken = accessToken;
this.defaults = __spreadValues(__spreadValues({}, _MapboxSearch.defaults), defaults);
this.defaults = __spreadValues(__spreadValues({}, _AddressAutofillCore.defaults), defaults);
}

@@ -286,8 +279,2 @@ suggest(searchText, optionsArg) {

});
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_URL}/${encodeURIComponent(searchText)}`);

@@ -301,4 +288,10 @@ url.search = __privateMethod(this, _getQueryParams, getQueryParams_fn).call(this, options);

const json = yield res.json();
json.url = url.toString();
return json;
return __spreadProps(__spreadValues({}, json), {
suggestions: json.suggestions.map((suggestion) => {
return __spreadProps(__spreadValues({}, suggestion), {
original_search_text: searchText
});
}),
url: url.toString()
});
});

@@ -316,3 +309,3 @@ }

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

@@ -323,5 +316,3 @@ access_token: this.accessToken,

const { fetch } = getFetch();
const res = yield fetch(url.toString(), __spreadProps(__spreadValues({}, __privateMethod(this, _getFetchInfo, getFetchInfo_fn).call(this, suggestion)), {
signal
}));
const res = yield fetch(url.toString(), { signal });
yield handleNonOkRes(res);

@@ -335,72 +326,17 @@ const json = yield res.json();

const action = suggestion.action;
if (!action) {
return false;
}
return action.method === "POST" && action.endpoint === ENDPOINT_RETRIEVE;
return typeof (action == null ? void 0 : action.id) === "string";
}
canSuggest(suggestion) {
const action = suggestion.action;
if (!action) {
return false;
}
return action.method === "POST" && action.endpoint === ENDPOINT_SUGGEST;
}
forward(_0) {
return __async(this, arguments, function* (searchText, optionsArg = {}) {
if (!searchText) {
throw new Error("searchText is required");
}
const options = __spreadValues(__spreadValues({}, this.defaults), optionsArg);
const baseUrl = options.permanent ? PERMANENT_FORWARD_URL : FORWARD_URL;
const url = new URL(`${baseUrl}/${encodeURIComponent(searchText)}`);
url.search = __privateMethod(this, _getQueryParams, getQueryParams_fn).call(this, options);
const { fetch } = getFetch();
const res = yield fetch(url.toString(), {
signal: options.signal
});
yield handleNonOkRes(res);
const json = yield res.json();
return json;
});
}
reverse(_0) {
return __async(this, arguments, function* (lngLat, optionsArg = {}) {
if (!lngLat) {
throw new Error("lngLat is required");
}
const options = __spreadValues(__spreadValues({}, this.defaults), optionsArg);
const searchText = typeof lngLat === "string" ? lngLat : LngLat.convert(lngLat).toArray().join(",");
const baseUrl = options.permanent ? PERMANENT_REVERSE_URL : REVERSE_URL;
const url = new URL(`${baseUrl}/${encodeURIComponent(searchText)}`);
url.search = queryParams({
access_token: this.accessToken,
language: options.language,
limit: options.limit
}, options.types && {
types: typeof options.types === "string" ? options.types : [...options.types].join(",")
});
const { fetch } = getFetch();
const res = yield fetch(url.toString(), {
signal: options.signal
});
yield handleNonOkRes(res);
const json = yield res.json();
return json;
});
}
};
var MapboxSearch = _MapboxSearch;
var AddressAutofillCore = _AddressAutofillCore;
_getQueryParams = new WeakSet();
getQueryParams_fn = function(options) {
return queryParams({
types: "address",
streets: true,
access_token: this.accessToken,
language: options.language,
country: options.country,
limit: options.limit,
navigation_profile: options.navigation_profile,
eta_type: options.eta_type
limit: options.limit
}, options.sessionToken && {
session_token: SessionToken.convert(options.sessionToken).id
}, options.origin && {
origin: typeof options.origin === "string" ? options.origin : LngLat.convert(options.origin).toArray().join(",")
}, options.proximity && {

@@ -410,25 +346,8 @@ proximity: typeof options.proximity === "string" ? options.proximity : LngLat.convert(options.proximity).toArray().join(",")

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(",")
});
};
_getFetchInfo = new WeakSet();
getFetchInfo_fn = function(suggestion) {
if (!this.canRetrieve(suggestion) && !this.canSuggest(suggestion)) {
throw new Error("Suggestion cannot be retrieved or suggested");
}
const action = suggestion.action;
const body = JSON.stringify(action.body);
return {
method: action.method,
body,
headers: {
"Content-Type": "application/json",
"Content-Length": body.length.toString()
}
};
AddressAutofillCore.defaults = {
language: "en",
proximity: "ip"
};
MapboxSearch.defaults = {
language: "en"
};

@@ -439,4 +358,8 @@ // src/searchbox/constants.ts

var ENDPOINT_RETRIEVE2 = "retrieve";
var ENDPOINT_CATEGORY = "category";
var ENDPOINT_REVERSE = "reverse";
var SUGGEST_URL2 = `${SEARCH_URL2}/${ENDPOINT_SUGGEST2}`;
var RETRIEVE_URL2 = `${SEARCH_URL2}/${ENDPOINT_RETRIEVE2}`;
var CATEGORY_URL = `${SEARCH_URL2}/${ENDPOINT_CATEGORY}`;
var REVERSE_URL = `${SEARCH_URL2}/${ENDPOINT_REVERSE}`;

@@ -502,2 +425,50 @@ // src/searchbox/SearchBoxCore.ts

}
category(_0) {
return __async(this, arguments, function* (category, optionsArg = {}) {
if (!category) {
throw new Error("category is required");
}
const options = __spreadValues(__spreadValues({}, this.defaults), optionsArg);
const url = new URL(`${CATEGORY_URL}/${encodeURIComponent(category)}`);
url.search = __privateMethod(this, _getQueryParams2, getQueryParams_fn2).call(this, options);
const { fetch } = getFetch();
const res = yield fetch(url.toString(), {
signal: options.signal
});
yield handleNonOkRes(res);
const json = yield res.json();
json.url = url.toString();
return json;
});
}
reverse(_0) {
return __async(this, arguments, function* (lngLat, optionsArg = {}) {
if (!lngLat) {
throw new Error("lngLat is required");
}
const [lng, lat] = typeof lngLat === "string" ? lngLat.split(",").map((x) => parseFloat(x)) : LngLat.convert(lngLat).toArray();
if (isNaN(lng) || isNaN(lat)) {
throw new Error("lngLat is required");
}
const options = __spreadValues(__spreadValues({}, this.defaults), optionsArg);
const url = new URL(REVERSE_URL);
url.search = queryParams({
access_token: this.accessToken,
language: options.language,
limit: options.limit,
longitude: lng,
latitude: lat
}, options.types && {
types: typeof options.types === "string" ? options.types : [...options.types].join(",")
});
const { fetch } = getFetch();
const res = yield fetch(url.toString(), {
signal: options.signal
});
yield handleNonOkRes(res);
const json = yield res.json();
json.url = url.toString();
return json;
});
}
};

@@ -540,12 +511,10 @@ var SearchBoxCore = _SearchBoxCore;

// src/autofill/constants.ts
// src/validate/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}`;
var ENDPOINT_VALIDATE = "retrieve";
var VALIDATE_URL = `${SEARCH_URL3}/${ENDPOINT_VALIDATE}`;
// src/autofill/MapboxAutofill.ts
// src/validate/ValidationCore.ts
var _getQueryParams3, getQueryParams_fn3;
var _MapboxAutofill = class {
var _ValidationCore = class {
constructor(options = {}) {

@@ -555,96 +524,4 @@ __privateAdd(this, _getQueryParams3);

this.accessToken = accessToken;
this.defaults = __spreadValues(__spreadValues({}, _MapboxAutofill.defaults), defaults);
this.defaults = __spreadValues(__spreadValues({}, _ValidationCore.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), {
suggestions: json.suggestions.map((suggestion) => {
return __spreadProps(__spreadValues({}, suggestion), {
original_search_text: searchText
});
}),
url: url.toString()
});
});
}
retrieve(suggestion, optionsArg) {
return __async(this, null, function* () {
if (!suggestion) {
throw new Error("suggestion is required");
}
if (!this.canRetrieve(suggestion)) {
throw new Error("suggestion cannot be retrieved");
}
const { sessionToken: sessionTokenLike, signal } = optionsArg;
const sessionToken = SessionToken.convert(sessionTokenLike);
const url = new URL(`${RETRIEVE_URL3}/${suggestion.action.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;
});
}
canRetrieve(suggestion) {
const action = suggestion.action;
return typeof (action == null ? void 0 : action.id) === "string";
}
};
var MapboxAutofill = _MapboxAutofill;
_getQueryParams3 = new WeakSet();
getQueryParams_fn3 = function(options) {
return queryParams({
types: "address",
streets: true,
access_token: this.accessToken,
language: options.language,
country: options.country,
limit: options.limit
}, 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.bbox && {
bbox: typeof options.bbox === "string" ? options.bbox : LngLatBounds.convert(options.bbox).toFlatArray().join(",")
});
};
MapboxAutofill.defaults = {
language: "en",
proximity: "ip"
};
// src/validate/constants.ts
var SEARCH_URL4 = `https://api.mapbox.com/autofill/v1`;
var ENDPOINT_VALIDATE = "retrieve";
var VALIDATE_URL = `${SEARCH_URL4}/${ENDPOINT_VALIDATE}`;
// src/validate/MapboxValidate.ts
var _getQueryParams4, getQueryParams_fn4;
var _MapboxValidate = class {
constructor(options = {}) {
__privateAdd(this, _getQueryParams4);
const _a = options, { accessToken } = _a, defaults = __objRest(_a, ["accessToken"]);
this.accessToken = accessToken;
this.defaults = __spreadValues(__spreadValues({}, _MapboxValidate.defaults), defaults);
}
validate(searchText, optionsArg) {

@@ -660,3 +537,3 @@ return __async(this, null, function* () {

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

@@ -676,5 +553,5 @@ const res = yield fetch(url.toString(), {

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

@@ -692,3 +569,3 @@ access_token: this.accessToken,

};
MapboxValidate.defaults = {
ValidationCore.defaults = {
language: "en",

@@ -699,11 +576,11 @@ proximity: "ip"

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

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

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

@@ -749,3 +626,3 @@ const fetchInit = signal ? { signal } : {};

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

@@ -761,4 +638,4 @@ const fetchInit = signal ? { signal } : {};

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

@@ -961,10 +838,11 @@ ["proximity", "autocomplete", "fuzzyMatch", "bbox"].forEach((key) => {

export {
AddressAutofillCore,
Evented,
GeocodingCore,
LngLat,
LngLatBounds,
MapboxAutofill,
AddressAutofillCore as MapboxAutofill,
MapboxError,
MapboxGeocode,
MapboxSearch,
MapboxValidate,
GeocodingCore as MapboxGeocode,
ValidationCore as MapboxValidate,
MatchCodeConfidence,

@@ -974,2 +852,3 @@ SearchBoxCore,

SessionToken,
ValidationCore,
debounce,

@@ -976,0 +855,0 @@ featureToSuggestion,

@@ -1,11 +0,9 @@

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';
import { AutofillSuggestion, AutofillFeatureSuggestion } from './autofill/types';
import { ValidateOptions, MapboxValidate, ValidateResponse } from './validate/MapboxValidate';
import { ValidateFeature } from './validate/types';
import { GeocodeOptions, MapboxGeocode, GeocodeResponse } from './geocode/MapboxGeocode';
import { GeocodeFeatureProperties, GeocodeFeatureContext, GeocodeFeature, DataTypes } from './geocode/types';
import { AddressAutofillOptions, AddressAutofillCore, AddressAutofillSuggestionResponse, AddressAutofillRetrieveResponse } from './autofill/AddressAutofillCore';
import { AddressAutofillSuggestion, AddressAutofillFeatureSuggestion } from './autofill/types';
import { SearchBoxOptions, SearchBoxCore, SearchBoxSuggestionResponse, SearchBoxRetrieveResponse, SearchBoxCategoryResponse, SearchBoxReverseResponse } from './searchbox/SearchBoxCore';
import { SearchBoxAdministrativeUnitTypes, SearchBoxSuggestion, SearchBoxFeatureSuggestion, SearchBoxCategorySuggestion } from './searchbox/types';
import { ValidationOptions, ValidationCore, ValidationResponse } from './validate/ValidationCore';
import { ValidationFeature } from './validate/types';
import { GeocodingOptions, GeocodingCore, GeocodingResponse } from './geocode/GeocodingCore';
import { GeocodingFeatureProperties, GeocodingFeatureContext, GeocodingFeature, DataTypes } from './geocode/types';
import { MatchCodeConfidence, MatchCode } from './types';

@@ -21,2 +19,2 @@ import { SearchSession } from './SearchSession';

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, SearchBoxOptions, SearchBoxCore, SearchBoxSuggestionResponse, SearchBoxRetrieveResponse, SearchBoxAdministrativeUnitTypes, SearchBoxSuggestion, SearchBoxFeatureSuggestion };
export { SearchBoxOptions, SearchBoxCore, SearchBoxSuggestionResponse, SearchBoxRetrieveResponse, SearchBoxAdministrativeUnitTypes, SearchBoxSuggestion, SearchBoxFeatureSuggestion, SearchBoxCategoryResponse, SearchBoxReverseResponse, SearchBoxCategorySuggestion, AddressAutofillOptions, AddressAutofillCore, AddressAutofillSuggestionResponse, AddressAutofillRetrieveResponse, AddressAutofillSuggestion, AddressAutofillFeatureSuggestion, MatchCode, MatchCodeConfidence, SearchSession, SessionToken, SessionTokenLike, MapboxError, LngLat, LngLatLike, LngLatBounds, LngLatBoundsLike, polyfillFetch, featureToSuggestion, Evented, debounce, ValidationOptions, ValidationCore, ValidationResponse, ValidationFeature, GeocodingOptions, GeocodingCore, GeocodingResponse, GeocodingFeatureProperties, GeocodingFeatureContext, GeocodingFeature, DataTypes, AddressAutofillOptions as AutofillOptions, AddressAutofillCore as MapboxAutofill, AddressAutofillSuggestionResponse as AutofillSuggestionResponse, AddressAutofillRetrieveResponse as AutofillRetrieveResponse, AddressAutofillSuggestion as AutofillSuggestion, AddressAutofillFeatureSuggestion as AutofillFeatureSuggestion, ValidationOptions as ValidateOptions, ValidationCore as MapboxValidate, ValidationResponse as ValidateResponse, ValidationFeature as ValidateFeature, GeocodingOptions as GeocodeOptions, GeocodingCore as MapboxGeocode, GeocodingResponse as GeocodeResponse, GeocodingFeatureProperties as GeocodeFeatureProperties, GeocodingFeatureContext as GeocodeFeatureContext, GeocodingFeature as GeocodeFeature };

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

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);
var U=Object.defineProperty,Le=Object.defineProperties,be=Object.getOwnPropertyDescriptor,ye=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertyNames,B=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var te=(o,e,t)=>e in o?U(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,g=(o,e)=>{for(var t in e||(e={}))M.call(e,t)&&te(o,t,e[t]);if(B)for(var t of B(e))re.call(e,t)&&te(o,t,e[t]);return o},x=(o,e)=>Le(o,ye(e)),Re=o=>U(o,"__esModule",{value:!0});var v=(o,e)=>{var t={};for(var r in o)M.call(o,r)&&e.indexOf(r)<0&&(t[r]=o[r]);if(o!=null&&B)for(var r of B(o))e.indexOf(r)<0&&re.call(o,r)&&(t[r]=o[r]);return t};var ke=(o,e)=>{for(var t in e)U(o,t,{get:e[t],enumerable:!0})},ve=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of xe(e))!M.call(o,s)&&(t||s!=="default")&&U(o,s,{get:()=>e[s],enumerable:!(r=be(e,s))||r.enumerable});return o};var Te=(o=>(e,t)=>o&&o.get(e)||(t=ve(Re({}),e,1),o&&o.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var K=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var L=(o,e,t)=>(K(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)},A=(o,e,t,r)=>(K(o,e,"write to private field"),r?r.call(o,t):e.set(o,t),t);var R=(o,e,t)=>(K(o,e,"access private method"),t);var p=(o,e,t)=>new Promise((r,s)=>{var n=c=>{try{a(t.next(c))}catch(u){s(u)}},i=c=>{try{a(t.throw(c))}catch(u){s(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(n,i);a((t=t.apply(o,e)).next())});var $e={};ke($e,{AddressAutofillCore:()=>$,Evented:()=>_,GeocodingCore:()=>J,LngLat:()=>l,LngLatBounds:()=>m,MapboxAutofill:()=>$,MapboxError:()=>j,MapboxGeocode:()=>J,MapboxValidate:()=>V,MatchCodeConfidence:()=>X,SearchBoxCore:()=>I,SearchSession:()=>ee,SessionToken:()=>f,ValidationCore:()=>V,debounce:()=>D,featureToSuggestion:()=>Se,polyfillFetch:()=>ge});var oe="https://api.mapbox.com/autofill/v1",Ae="suggest",we="retrieve",se=`${oe}/${Ae}`,ne=`${oe}/${we}`;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 m=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 m)return new m(e.getSouthWest(),e.getNorthEast());if(Array.isArray(e)&&e.length===2)return new m(l.convert(e[0]),l.convert(e[1]));if(Array.isArray(e)&&e.length===4)return new m(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 ie(){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:ie()}toString(){return this.id}static convert(e){return new f(e instanceof f?e.id:e.toString())}};var Ee="Unknown error",j=class extends Error{constructor(e,t){super(String(e.message||e.error||Ee));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 N=globalThis.fetch,ae=globalThis.AbortController;function ge({fetch:o,AbortController:e},t=!1){if(!o)throw new Error("Fetch implementation must include implementations of `fetch`.");N&&!t||(N=o,ae=e)}function h(){if(!N)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:N,AbortController:ae}}function b(...o){let e=[];for(let t of o){if(!t)continue;let r=Object.entries(t);for(let[s,n]of r)n!=null&&e.push(`${s}=${encodeURIComponent(String(n))}`)}return e.join("&")}var C,Oe,z=class{constructor(e={}){d(this,C);let s=e,{accessToken:t}=s,r=v(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},z.defaults),r)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=x(g(g({},this.defaults),t),{sessionToken:r}),i=new URL(`${se}/${encodeURIComponent(e)}`);i.search=R(this,C,Oe).call(this,n);let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});yield S(c);let u=yield c.json();return x(g({},u),{suggestions:u.suggestions.map(y=>x(g({},y),{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:r,signal:s}=t,n=f.convert(r),i=new URL(`${ne}/${e.action.id}`);i.search=b({access_token:this.accessToken,session_token:n.id});let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});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"}},$=z;C=new WeakSet,Oe=function(e){return b({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:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")})},$.defaults={language:"en",proximity:"ip"};var G="https://api.mapbox.com/search/searchbox/v1",_e="suggest",Pe="retrieve",Fe="category",Be="reverse",ce=`${G}/${_e}`,ue=`${G}/${Pe}`,le=`${G}/${Fe}`,pe=`${G}/${Be}`;var E,me,Q=class{constructor(e={}){d(this,E);let s=e,{accessToken:t}=s,r=v(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},Q.defaults),r)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=x(g(g({},this.defaults),t),{q:e,sessionToken:r});if(n.eta_type&&(!n.origin||!n.navigation_profile))throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");if(n.origin&&!n.navigation_profile)throw new Error("to provide distance estimate: both navigation_profile and origin are required");let i=new URL(ce);i.search=R(this,E,me).call(this,n);let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});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:r,signal:s}=t,n=f.convert(r),i=new URL(`${ue}/${encodeURIComponent(e.mapbox_id)}`);i.search=b({access_token:this.accessToken,session_token:n.id});let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});yield S(c);let u=yield c.json();return u.url=i.toString(),u})}category(r){return p(this,arguments,function*(e,t={}){if(!e)throw new Error("category is required");let s=g(g({},this.defaults),t),n=new URL(`${le}/${encodeURIComponent(e)}`);n.search=R(this,E,me).call(this,s);let{fetch:i}=h(),a=yield i(n.toString(),{signal:s.signal});yield S(a);let c=yield a.json();return c.url=n.toString(),c})}reverse(r){return p(this,arguments,function*(e,t={}){if(!e)throw new Error("lngLat is required");let[s,n]=typeof e=="string"?e.split(",").map(F=>parseFloat(F)):l.convert(e).toArray();if(isNaN(s)||isNaN(n))throw new Error("lngLat is required");let i=g(g({},this.defaults),t),a=new URL(pe);a.search=b({access_token:this.accessToken,language:i.language,limit:i.limit,longitude:s,latitude:n},i.types&&{types:typeof i.types=="string"?i.types:[...i.types].join(",")});let{fetch:c}=h(),u=yield c(a.toString(),{signal:i.signal});yield S(u);let y=yield u.json();return y.url=a.toString(),y})}},I=Q;E=new WeakSet,me=function(e){return b({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:f.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:m.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},I.defaults={language:"en"};var Ue="https://api.mapbox.com/autofill/v1",je="retrieve",fe=`${Ue}/${je}`;var q,Ne,W=class{constructor(e={}){d(this,q);let s=e,{accessToken:t}=s,r=v(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},W.defaults),r)}validate(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=x(g(g({},this.defaults),t),{sessionToken:r}),i=new URL(`${fe}/${encodeURIComponent(e)}`);i.search=R(this,q,Ne).call(this,n);let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});yield S(c);let u=yield c.json();return u.url=i.toString(),u.features.length>0&&(u.features=[u.features[0]]),u})}},V=W;q=new WeakSet,Ne=function(e){return b({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:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")})},V.defaults={language:"en",proximity:"ip"};var he="https://api.mapbox.com/geocoding/v5",H=`${he}/mapbox.places`,Y=`${he}/mapbox.places-permanent`;var O,de,J=class{constructor(e={}){d(this,O);let s=e,{accessToken:t}=s,r=v(s,["accessToken"]);this.accessToken=t,this.defaults=g({},r)}forward(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let r;t&&({signal:r}=t);let s=g(g({},this.defaults),t),n=s.permanent?Y:H,i=new URL(`${n}/${encodeURIComponent(e)}.json`);i.search=R(this,O,de).call(this,s);let{fetch:a}=h(),c=r?{signal:r}:{},u=yield a(i.toString(),c);yield S(u);let y=yield u.json();return y.url=i.toString(),y})}reverse(e,t){return p(this,null,function*(){if(!e)throw new Error("lngLat is required");let r;t&&({signal:r}=t);let s=g(g({},this.defaults),t),n=typeof e=="string"?e:l.convert(e).toArray().join(","),i=s.permanent?Y:H,a=new URL(`${i}/${encodeURIComponent(n)}.json`);a.search=R(this,O,de).call(this,s,!0);let{fetch:c}=h(),u=r?{signal:r}:{},y=yield c(a.toString(),u);yield S(y);let F=yield y.json();return F.url=a.toString(),F})}};O=new WeakSet,de=function(e,t=!1){return t&&["proximity","autocomplete","fuzzyMatch","bbox"].forEach(r=>{r in e&&delete e[r]}),b({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:m.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})};var X=(s=>(s.exact="exact",s.high="high",s.medium="medium",s.low="low",s))(X||{});var w,_=class{constructor(){d(this,w,{})}addEventListener(e,t){let r=L(this,w);r[e]||(r[e]=[]),r[e].push(t)}removeEventListener(e,t){let r=L(this,w);if(!r[e])return;let s=r[e],n=s.indexOf(t);n!==-1&&s.splice(n,1)}fire(e,t){let r=L(this,w);if(!r[e])return;let s=r[e];for(let n of s)n(t)}};w=new WeakMap;function D(o,e,t){let r=null;return(...s)=>{r!==null&&clearTimeout(r);let n=t&&t();r=setTimeout(()=>{r=null,!(n==null?void 0:n.aborted)&&o(...s)},e)}}function Z(){let{AbortController:o}=h();return new o}var T,k,P,ee=class extends _{constructor(e,t=0){super();this.sessionToken=new f;d(this,T,void 0);d(this,k,Z());d(this,P,void 0);A(this,P,D((n,...i)=>p(this,[n,...i],function*(r,s={}){if(L(this,k).abort(),A(this,k,Z()),!r){A(this,T,null),this.fire("suggest",L(this,T));return}try{let a=yield this.search.suggest(r,x(g({sessionToken:this.sessionToken},s),{signal:L(this,k).signal}));A(this,T,a),this.fire("suggest",a)}catch(a){if(a.name==="AbortError")return;this.fire("suggesterror",a)}}),t,()=>L(this,k).signal)),Object.defineProperties(this,{search:{value:e,writable:!1},debounce:{value:t,writable:!1}})}get suggestions(){return L(this,T)}suggest(e,t){return L(this,P).call(this,e,t),new Promise((r,s)=>{let n,i;n=a=>{this.removeEventListener("suggest",n),this.removeEventListener("suggesterror",i),r(a)},i=a=>{this.removeEventListener("suggest",n),this.removeEventListener("suggesterror",i),s(a)},this.addEventListener("suggest",n),this.addEventListener("suggesterror",i)})}clear(){this.suggest("")}retrieve(e,t){return p(this,null,function*(){let r=yield this.search.retrieve(e,g({sessionToken:this.sessionToken},t));return this.fire("retrieve",r),r})}canRetrieve(e){return this.search.canRetrieve?this.search.canRetrieve(e):!0}canSuggest(e){return this.search.canSuggest?this.search.canSuggest(e):!0}abort(){L(this,k).abort(),A(this,k,Z())}};T=new WeakMap,k=new WeakMap,P=new WeakMap;function Se(o){let{properties:e}=o;return g({},e)}module.exports=Te($e);
//# sourceMappingURL=index.js.map

@@ -6,4 +6,4 @@ export declare const UNKNOWN_ERROR = "Unknown error";

* See common errors here:
* - [MapboxSearch](https://docs.mapbox.com/api/search/search/#search-api-errors)
* - [MapboxAutofill](https://docs.mapbox.com/api/search/geocoding/#geocoding-api-errors)
* - [SearchBoxCore](https://docs.mapbox.com/api/search/search-box/#search-box-api-errors)
* - [AddressAutofillCore](https://docs.mapbox.com/api/search/geocoding/#geocoding-api-errors)
*/

@@ -22,4 +22,4 @@ export declare class MapboxError extends Error {

* If not, throw a {@link MapboxError} filled out by the
* [JSON error format](https://docs.mapbox.com/api/search/search/#search-api-errors).
* [JSON error format](https://docs.mapbox.com/api/search/search-box/#search-box-api-errors).
*/
export declare function handleNonOkRes(res: Response): Promise<void>;

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

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);})();
var mapboxsearchcore=(()=>{var U=Object.defineProperty,Le=Object.defineProperties,be=Object.getOwnPropertyDescriptor,ye=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertyNames,B=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var te=(o,e,t)=>e in o?U(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,g=(o,e)=>{for(var t in e||(e={}))M.call(e,t)&&te(o,t,e[t]);if(B)for(var t of B(e))re.call(e,t)&&te(o,t,e[t]);return o},x=(o,e)=>Le(o,ye(e)),Re=o=>U(o,"__esModule",{value:!0});var v=(o,e)=>{var t={};for(var r in o)M.call(o,r)&&e.indexOf(r)<0&&(t[r]=o[r]);if(o!=null&&B)for(var r of B(o))e.indexOf(r)<0&&re.call(o,r)&&(t[r]=o[r]);return t};var ke=(o,e)=>{for(var t in e)U(o,t,{get:e[t],enumerable:!0})},ve=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of xe(e))!M.call(o,s)&&(t||s!=="default")&&U(o,s,{get:()=>e[s],enumerable:!(r=be(e,s))||r.enumerable});return o};var Te=(o=>(e,t)=>o&&o.get(e)||(t=ve(Re({}),e,1),o&&o.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var K=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var L=(o,e,t)=>(K(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)},A=(o,e,t,r)=>(K(o,e,"write to private field"),r?r.call(o,t):e.set(o,t),t);var R=(o,e,t)=>(K(o,e,"access private method"),t);var p=(o,e,t)=>new Promise((r,s)=>{var n=c=>{try{a(t.next(c))}catch(u){s(u)}},i=c=>{try{a(t.throw(c))}catch(u){s(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(n,i);a((t=t.apply(o,e)).next())});var $e={};ke($e,{AddressAutofillCore:()=>$,Evented:()=>_,GeocodingCore:()=>J,LngLat:()=>l,LngLatBounds:()=>m,MapboxAutofill:()=>$,MapboxError:()=>j,MapboxGeocode:()=>J,MapboxValidate:()=>V,MatchCodeConfidence:()=>X,SearchBoxCore:()=>I,SearchSession:()=>ee,SessionToken:()=>f,ValidationCore:()=>V,debounce:()=>D,featureToSuggestion:()=>Se,polyfillFetch:()=>ge});var oe="https://api.mapbox.com/autofill/v1",Ae="suggest",we="retrieve",se=`${oe}/${Ae}`,ne=`${oe}/${we}`;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 m=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 m)return new m(e.getSouthWest(),e.getNorthEast());if(Array.isArray(e)&&e.length===2)return new m(l.convert(e[0]),l.convert(e[1]));if(Array.isArray(e)&&e.length===4)return new m(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 ie(){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:ie()}toString(){return this.id}static convert(e){return new f(e instanceof f?e.id:e.toString())}};var Ee="Unknown error",j=class extends Error{constructor(e,t){super(String(e.message||e.error||Ee));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 N=globalThis.fetch,ae=globalThis.AbortController;function ge({fetch:o,AbortController:e},t=!1){if(!o)throw new Error("Fetch implementation must include implementations of `fetch`.");N&&!t||(N=o,ae=e)}function h(){if(!N)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:N,AbortController:ae}}function b(...o){let e=[];for(let t of o){if(!t)continue;let r=Object.entries(t);for(let[s,n]of r)n!=null&&e.push(`${s}=${encodeURIComponent(String(n))}`)}return e.join("&")}var C,Oe,z=class{constructor(e={}){d(this,C);let s=e,{accessToken:t}=s,r=v(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},z.defaults),r)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=x(g(g({},this.defaults),t),{sessionToken:r}),i=new URL(`${se}/${encodeURIComponent(e)}`);i.search=R(this,C,Oe).call(this,n);let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});yield S(c);let u=yield c.json();return x(g({},u),{suggestions:u.suggestions.map(y=>x(g({},y),{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:r,signal:s}=t,n=f.convert(r),i=new URL(`${ne}/${e.action.id}`);i.search=b({access_token:this.accessToken,session_token:n.id});let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});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"}},$=z;C=new WeakSet,Oe=function(e){return b({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:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")})},$.defaults={language:"en",proximity:"ip"};var G="https://api.mapbox.com/search/searchbox/v1",_e="suggest",Pe="retrieve",Fe="category",Be="reverse",ce=`${G}/${_e}`,ue=`${G}/${Pe}`,le=`${G}/${Fe}`,pe=`${G}/${Be}`;var E,me,Q=class{constructor(e={}){d(this,E);let s=e,{accessToken:t}=s,r=v(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},Q.defaults),r)}suggest(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=x(g(g({},this.defaults),t),{q:e,sessionToken:r});if(n.eta_type&&(!n.origin||!n.navigation_profile))throw new Error("to provide eta estimate: eta, navigation_profile, and origin are required");if(n.origin&&!n.navigation_profile)throw new Error("to provide distance estimate: both navigation_profile and origin are required");let i=new URL(ce);i.search=R(this,E,me).call(this,n);let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});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:r,signal:s}=t,n=f.convert(r),i=new URL(`${ue}/${encodeURIComponent(e.mapbox_id)}`);i.search=b({access_token:this.accessToken,session_token:n.id});let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});yield S(c);let u=yield c.json();return u.url=i.toString(),u})}category(r){return p(this,arguments,function*(e,t={}){if(!e)throw new Error("category is required");let s=g(g({},this.defaults),t),n=new URL(`${le}/${encodeURIComponent(e)}`);n.search=R(this,E,me).call(this,s);let{fetch:i}=h(),a=yield i(n.toString(),{signal:s.signal});yield S(a);let c=yield a.json();return c.url=n.toString(),c})}reverse(r){return p(this,arguments,function*(e,t={}){if(!e)throw new Error("lngLat is required");let[s,n]=typeof e=="string"?e.split(",").map(F=>parseFloat(F)):l.convert(e).toArray();if(isNaN(s)||isNaN(n))throw new Error("lngLat is required");let i=g(g({},this.defaults),t),a=new URL(pe);a.search=b({access_token:this.accessToken,language:i.language,limit:i.limit,longitude:s,latitude:n},i.types&&{types:typeof i.types=="string"?i.types:[...i.types].join(",")});let{fetch:c}=h(),u=yield c(a.toString(),{signal:i.signal});yield S(u);let y=yield u.json();return y.url=a.toString(),y})}},I=Q;E=new WeakSet,me=function(e){return b({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:f.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:m.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})},I.defaults={language:"en"};var Ue="https://api.mapbox.com/autofill/v1",je="retrieve",fe=`${Ue}/${je}`;var q,Ne,W=class{constructor(e={}){d(this,q);let s=e,{accessToken:t}=s,r=v(s,["accessToken"]);this.accessToken=t,this.defaults=g(g({},W.defaults),r)}validate(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let{sessionToken:r,signal:s}=t,n=x(g(g({},this.defaults),t),{sessionToken:r}),i=new URL(`${fe}/${encodeURIComponent(e)}`);i.search=R(this,q,Ne).call(this,n);let{fetch:a}=h(),c=yield a(i.toString(),{signal:s});yield S(c);let u=yield c.json();return u.url=i.toString(),u.features.length>0&&(u.features=[u.features[0]]),u})}},V=W;q=new WeakSet,Ne=function(e){return b({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:l.convert(e.proximity).toArray().join(",")},e.bbox&&{bbox:typeof e.bbox=="string"?e.bbox:m.convert(e.bbox).toFlatArray().join(",")})},V.defaults={language:"en",proximity:"ip"};var he="https://api.mapbox.com/geocoding/v5",H=`${he}/mapbox.places`,Y=`${he}/mapbox.places-permanent`;var O,de,J=class{constructor(e={}){d(this,O);let s=e,{accessToken:t}=s,r=v(s,["accessToken"]);this.accessToken=t,this.defaults=g({},r)}forward(e,t){return p(this,null,function*(){if(!e)throw new Error("searchText is required");let r;t&&({signal:r}=t);let s=g(g({},this.defaults),t),n=s.permanent?Y:H,i=new URL(`${n}/${encodeURIComponent(e)}.json`);i.search=R(this,O,de).call(this,s);let{fetch:a}=h(),c=r?{signal:r}:{},u=yield a(i.toString(),c);yield S(u);let y=yield u.json();return y.url=i.toString(),y})}reverse(e,t){return p(this,null,function*(){if(!e)throw new Error("lngLat is required");let r;t&&({signal:r}=t);let s=g(g({},this.defaults),t),n=typeof e=="string"?e:l.convert(e).toArray().join(","),i=s.permanent?Y:H,a=new URL(`${i}/${encodeURIComponent(n)}.json`);a.search=R(this,O,de).call(this,s,!0);let{fetch:c}=h(),u=r?{signal:r}:{},y=yield c(a.toString(),u);yield S(y);let F=yield y.json();return F.url=a.toString(),F})}};O=new WeakSet,de=function(e,t=!1){return t&&["proximity","autocomplete","fuzzyMatch","bbox"].forEach(r=>{r in e&&delete e[r]}),b({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:m.convert(e.bbox).toFlatArray().join(",")},e.types&&{types:typeof e.types=="string"?e.types:[...e.types].join(",")})};var X=(s=>(s.exact="exact",s.high="high",s.medium="medium",s.low="low",s))(X||{});var w,_=class{constructor(){d(this,w,{})}addEventListener(e,t){let r=L(this,w);r[e]||(r[e]=[]),r[e].push(t)}removeEventListener(e,t){let r=L(this,w);if(!r[e])return;let s=r[e],n=s.indexOf(t);n!==-1&&s.splice(n,1)}fire(e,t){let r=L(this,w);if(!r[e])return;let s=r[e];for(let n of s)n(t)}};w=new WeakMap;function D(o,e,t){let r=null;return(...s)=>{r!==null&&clearTimeout(r);let n=t&&t();r=setTimeout(()=>{r=null,!(n==null?void 0:n.aborted)&&o(...s)},e)}}function Z(){let{AbortController:o}=h();return new o}var T,k,P,ee=class extends _{constructor(e,t=0){super();this.sessionToken=new f;d(this,T,void 0);d(this,k,Z());d(this,P,void 0);A(this,P,D((n,...i)=>p(this,[n,...i],function*(r,s={}){if(L(this,k).abort(),A(this,k,Z()),!r){A(this,T,null),this.fire("suggest",L(this,T));return}try{let a=yield this.search.suggest(r,x(g({sessionToken:this.sessionToken},s),{signal:L(this,k).signal}));A(this,T,a),this.fire("suggest",a)}catch(a){if(a.name==="AbortError")return;this.fire("suggesterror",a)}}),t,()=>L(this,k).signal)),Object.defineProperties(this,{search:{value:e,writable:!1},debounce:{value:t,writable:!1}})}get suggestions(){return L(this,T)}suggest(e,t){return L(this,P).call(this,e,t),new Promise((r,s)=>{let n,i;n=a=>{this.removeEventListener("suggest",n),this.removeEventListener("suggesterror",i),r(a)},i=a=>{this.removeEventListener("suggest",n),this.removeEventListener("suggesterror",i),s(a)},this.addEventListener("suggest",n),this.addEventListener("suggesterror",i)})}clear(){this.suggest("")}retrieve(e,t){return p(this,null,function*(){let r=yield this.search.retrieve(e,g({sessionToken:this.sessionToken},t));return this.fire("retrieve",r),r})}canRetrieve(e){return this.search.canRetrieve?this.search.canRetrieve(e):!0}canSuggest(e){return this.search.canSuggest?this.search.canSuggest(e):!0}abort(){L(this,k).abort(),A(this,k,Z())}};T=new WeakMap,k=new WeakMap,P=new WeakMap;function Se(o){let{properties:e}=o;return g({},e)}return Te($e);})();
//# sourceMappingURL=mapboxsearchcore.js.map
export declare const SEARCH_URL = "https://api.mapbox.com/search/searchbox/v1";
export declare const ENDPOINT_SUGGEST = "suggest";
export declare const ENDPOINT_RETRIEVE = "retrieve";
export declare const ENDPOINT_CATEGORY = "category";
export declare const ENDPOINT_REVERSE = "reverse";
export declare const SUGGEST_URL: string;
export declare const RETRIEVE_URL: string;
export declare const CATEGORY_URL: string;
export declare const REVERSE_URL: string;

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

import { SearchBoxAdministrativeUnitTypes, SearchBoxSuggestion, SearchBoxFeatureSuggestion } from './types';
import { SearchBoxAdministrativeUnitTypes, SearchBoxSuggestion, SearchBoxFeatureSuggestion, SearchBoxCategorySuggestion } from './types';
import { LngLatLike } from '../LngLat';

@@ -26,6 +26,6 @@ import { LngLatBoundsLike } from '../LngLatBounds';

* A customer-provided session token value, which groups a series of requests
* together for [billing purposes](https://docs.tilestream.net/api/search/search-box/#search-box-api-pricing).
* together for [billing purposes](https://docs.mapbox.com/api/search/search-box/#search-box-api-pricing).
*
* Reference:
* https://docs.tilestream.net/api/search/search-box/#search-box-api-pricing
* https://docs.mapbox.com/api/search/search-box/#search-box-api-pricing
*/

@@ -122,3 +122,3 @@ sessionToken: SessionTokenLike;

* Reference:
* https://docs.tilestream.net/api/search/search-box/#administrative-unit-types
* https://docs.mapbox.com/api/search/search-box/#administrative-unit-types
*/

@@ -150,3 +150,3 @@ types?: string | Set<SearchBoxAdministrativeUnitTypes>;

* Reference:
* https://docs.tilestream.net/api/search/search-box/#response-retrieve-a-suggestion
* https://docs.mapbox.com/api/search/search-box/#response-get-suggested-results
*/

@@ -169,3 +169,3 @@ export interface SearchBoxSuggestionResponse {

* Reference:
* https://docs.tilestream.net/api/search/search-box/#response-retrieve-a-suggestion
* https://docs.mapbox.com/api/search/search-box/#response-retrieve-a-suggested-feature
*/

@@ -187,3 +187,41 @@ export interface SearchBoxRetrieveResponse {

/**
* A `SearchBoxCore` object is an application's main entrypoint to the [Mapbox Search Box API](https://docs.tilestream.net/api/search/search-box/).
* @typedef SearchBoxReverseResponse
* Reference:
* https://docs.mapbox.com/api/search/search-box/#response-perform-a-reverse-lookup
*/
export interface SearchBoxReverseResponse {
type: 'FeatureCollection';
/**
* The attribution data for results.
*/
attribution?: string;
/**
* The returned feature objects.
*
* @see {@link SearchBoxFeatureSuggestion}
*/
features: SearchBoxFeatureSuggestion[];
url: string;
}
/**
* @typedef SearchBoxCategoryResponse
* Reference:
* https://docs.mapbox.com/api/search/search-box/#response-retrieve-pois-by-category
*/
export interface SearchBoxCategoryResponse {
type: 'FeatureCollection';
/**
* The attribution data for results.
*/
attribution?: string;
/**
* The returned feature objects.
*
* @see {@link SearchBoxCategorySuggestion}
*/
features: SearchBoxCategorySuggestion[];
url: string;
}
/**
* A `SearchBoxCore` object is an application's main entrypoint to the [Mapbox Search Box API](https://docs.mapbox.com/api/search/search-box/).
*

@@ -271,3 +309,47 @@ * `SearchBoxCore` is focused on the two-step, interactive search experience. These steps are:

retrieve(suggestion: SearchBoxSuggestion, optionsArg: SessionTokenOptions & Partial<FetchOptions>): Promise<SearchBoxRetrieveResponse>;
/** @section {Programmatic search} */
/**
* {@link SearchBoxCore#category} makes it possible to browse entire categories of results,
* like coffee shops, hotels, and bookstores around a specific location or along a route and returns feature collection
* in [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/) format.
*
* **Legal terms:**
*
* The [Mapbox Terms of Service](https://www.mapbox.com/tos/) states any rendering of a feature suggestion
* must be using Mapbox map services (for example, displaying results on Google Maps or MapKit JS is not allowed).
*
* **Disclaimer:**
*
* The failure of Mapbox to exercise or enforce any right or provision of these Terms will not constitute a waiver of such right or provision.
*
* @param {Options} optionsArg
* @param {AbortSignal} [optionsArg.signal]
* @param {boolean} [optionsArg.permanent]
*/
category(category: string, optionsArg?: Partial<FetchOptions & SearchBoxOptions>): Promise<SearchBoxCategoryResponse>;
/**
* {@link SearchBoxCore#reverse} endpoint allows you to look up a single pair of coordinates and returns the geographic feature or features
* that exist at that location. The response to a request is a [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/) FeatureCollection.
*
* Using the limit parameter, you can increase the maximum number of results up to 10. Pagination is not available, but this feature may be added in a later release.
* There is not an option to customize the order of search results.
*
* Multiple feature suggestions may be returned from a single search query, for example in an airport with
* multiple terminals.
*
* **Legal terms:**
*
* The [Mapbox Terms of Service](https://www.mapbox.com/tos/) states any rendering of a feature suggestion
* must be using Mapbox map services (for example, displaying results on Google Maps or MapKit JS is not allowed).
*
* **Disclaimer:**
*
* The failure of Mapbox to exercise or enforce any right or provision of these Terms will not constitute a waiver of such right or provision.
*
* @param lngLat - Either a {@link LngLatLike} object or string in 'lng,lat' comma-separated format.
* @param {Options} optionsArg
* @param {AbortSignal} [optionsArg.signal]
*/
reverse(lngLat: string | LngLatLike, optionsArg?: Partial<FetchOptions & SearchBoxOptions>): Promise<SearchBoxReverseResponse>;
}
export {};
/**
* Administrative unit types for the [Mapbox Search Box API](https://docs.tilestream.net/api/search/search-box/).
* Administrative unit types for the [Mapbox Search Box API](https://docs.mapbox.com/api/search/search-box/).
*
* @typedef SearchBoxAdministrativeUnitTypes
* @see https://docs.tilestream.net/api/search/search-box/#administrative-unit-types
* @see https://docs.mapbox.com/api/search/search-box/#administrative-unit-types
*/

@@ -13,6 +13,6 @@ export declare type SearchBoxAdministrativeUnitTypes = 'country' | 'region' | 'postcode' | 'district' | 'place' | 'locality' | 'neighborhood' | 'street' | 'address' | 'block';

/**
* Raw JSON form of a suggestion result's "context" from the [Mapbox Search Box API](https://docs.tilestream.net/api/search/search-box/).
* Raw JSON form of a suggestion result's "context" from the [Mapbox Search Box API](https://docs.mapbox.com/api/search/search-box/).
*
* Reference:
* https://docs.tilestream.net/api/search/search-box/#response-retrieve-a-suggestion
* https://docs.mapbox.com/api/search/search-box/#response-get-suggested-results
*/

@@ -77,3 +77,3 @@ export interface SuggestionJSONContext {

/**
* A `SearchBoxSuggestion` object represents a suggestion result from the [Mapbox Search Box API](https://docs.tilestream.net/api/search/search-box/).
* A `SearchBoxSuggestion` object represents a suggestion result from the [Mapbox Search Box API](https://docs.mapbox.com/api/search/search-box/).
*

@@ -89,3 +89,3 @@ * SearchBoxSuggestion objects are "part one" of the two-step interactive search experience, and include useful information about the result,

* Reference:
* https://docs.tilestream.net/api/search/search-box/#response-retrieve-a-suggestion
* https://docs.mapbox.com/api/search/search-box/#response-get-suggested-results
*

@@ -124,3 +124,3 @@ * @typedef SearchBoxSuggestion

* For address-type results, the global context hierarchy is used (`country`, `region`, `postcode`, `district`, `place`, `locality`, `neighborhood`, `address`).
* See the [Administrative unit types section](https://docs.tilestream.net/api/search/search-box/#administrative-unit-types) for details about these types.
* See the [Administrative unit types section](https://docs.mapbox.com/api/search/search-box/#administrative-unit-types) for details about these types.
*/

@@ -141,3 +141,3 @@ feature_type: string;

/**
* The context of the feature. This context has layers that follow the [Administrative unit types](https://docs.tilestream.net/api/search/search-box/#administrative-unit-types).
* The context of the feature. This context has layers that follow the [Administrative unit types](https://docs.mapbox.com/api/search/search-box/#administrative-unit-types).
*/

@@ -194,75 +194,13 @@ context: SuggestionJSONContext;

* Raw [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/) feature properties
* from the [Mapbox Search Box API](https://docs.tilestream.net/api/search/search-box/).
* from the [Mapbox Search Box API](https://docs.mapbox.com/api/search/search-box/).
*
* Reference:
* https://docs.tilestream.net/api/search/search-box/#response-retrieve-a-suggested-feature
* https://docs.mapbox.com/api/search/search-box/#response-retrieve-a-suggested-feature
*
* @typedef SearchBoxFeatureProperties
* @see {@link SearchBoxFeatureSuggestion}
* @see {@link SearchBoxSuggestion}
*/
export interface SearchBoxFeatureProperties {
export interface SearchBoxFeatureProperties extends Omit<SearchBoxSuggestion, 'distance' | 'eta' | 'added_distance' | 'added_time'> {
/**
* The name of the feature.
*/
name: string;
/**
* The preferred name of the feature, if different than {@link SearchBoxFeatureProperties#name}.
*/
name_preferred: string;
/**
* The id to use with {@link SearchBoxCore#retrieve} to obtain full feature details.
*/
mapbox_id: string;
/**
* The type of the result. For POIs, this will be `poi`.
* For categories, this will be `category`.
* For address-type results, the global context hierarchy is used (`country`, `region`, `postcode`, `district`, `place`, `locality`, `neighborhood`, `address`).
* See the [Administrative unit types section](https://docs.tilestream.net/api/search/search-box/#administrative-unit-types) for details about these types.
*/
feature_type: string;
/**
* The address of the result containing the address number and street.
*/
address: string;
/**
* The full address of the result, which concatenates {@link SearchBoxFeatureProperties#address} and {@link SearchBoxFeatureProperties#place_formatted}.
*/
full_address: string;
/**
* A formatted string of result context comprised of the place, region, country, and postcode.
*/
place_formatted: string;
/**
* The context of the feature. This context has layers that follow the [Administrative unit types](https://docs.tilestream.net/api/search/search-box/#administrative-unit-types).
*/
context: SuggestionJSONContext;
/**
* An IETF language tag indicating the language of the result.
*/
language: string;
/**
* A string representing an associated [Maki icon](https://docs.mapbox.com/help/glossary/maki/) to use for this result.
*/
maki: string;
/**
* An array including the POI categories the result falls into, if it is a POI.
*/
poi_category: string[];
/**
* The brand name of the result, if it is a POI and is applicable.
*/
brand: string;
/**
* The canonical brand ID of the result, if it is a POI and is applicable.
*/
brand_id: string;
/**
* An object containing the IDs of the feature found in external databases, with the keys being the data source names and the values being the IDs.
*/
external_ids: any;
/**
* An object containing additional metadata for the feature, if applicable.
*/
metadata: any;
/**
* The geographical coordinates of the result.

@@ -273,5 +211,5 @@ */

* The accuracy of the geographical coordinate of the result.
* This is only available for address-type results and the options are `rooftop`, `parcel`, `point`, `interpolated`, `intersection`, `approximate`, and `street`.
* This is only available for address and street-type results and the options are `rooftop`, `parcel`, `proximate`, and `street`.
*/
accuracy: string;
accuracy?: string;
/**

@@ -285,2 +223,10 @@ * The longitudinal coordinate of the result.

latitude: number;
/**
* An array of objects containing information about the feature's routable points.
*/
routable_points?: {
name: string;
latitude: number;
longitude: number;
}[];
};

@@ -291,23 +237,5 @@ /**

bbox?: [number, number, number, number];
/**
* An object containing information about the feature's routable point.
*/
routable_point?: {
/**
* An object containing the coordinates for the feature's routable point.
*/
coordinates: {
/**
* The longitudinal coordinate of the feature's routable point.
*/
longitude: number;
/**
* The latitudinal coordinate of the feature's routable point.
*/
latitude: number;
};
};
}
/**
* A `SearchBoxFeatureSuggestion` object represents a [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/) suggestion result from the [Mapbox Search Box API](https://docs.tilestream.net/api/search/search-box/).
* A `SearchBoxFeatureSuggestion` object represents a [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/) suggestion result from the [Mapbox Search Box API](https://docs.mapbox.com/api/search/search-box/).
*

@@ -317,3 +245,3 @@ * Feature suggestions are "part two" of the two-step interactive search experience and includes geographic coordinates. Multiple feature suggestions may be returned from a single search query,

*
* As per the [Mapbox Search Box API](https://docs.tilestream.net/api/search/search-box/), this will always be
* As per the [Mapbox Search Box API](https://docs.mapbox.com/api/search/search-box/), this will always be
* [Point](https://geojson.org/geojson-spec.html#point).

@@ -344,4 +272,38 @@ *

* ```
* @see [Response: Retrieve feature](https://docs.tilestream.net/api/search/search-box/#response-retrieve-a-suggested-feature)
* @see [Response: Retrieve feature](https://docs.mapbox.com/api/search/search-box/#response-retrieve-a-suggested-feature)
*/
export declare type SearchBoxFeatureSuggestion = GeoJSON.Feature<GeoJSON.Point, SearchBoxFeatureProperties>;
/**
* A `SearchBoxCategorySuggestion` object represents a [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/) result
* that is points of interest (POIs) filtered by a category at a specific location or along a route
* from the [Mapbox Search Box API](https://docs.mapbox.com/api/search/search-box/).
*
* As per the [Mapbox Search Box API](https://docs.mapbox.com/api/search/search-box/), this will always be
* [Point](https://geojson.org/geojson-spec.html#point).
*
* **Legal terms:**
*
* The [Mapbox Terms of Service](https://www.mapbox.com/tos/) states any rendering of a feature suggestion
* must be using Mapbox map services (for example, displaying results on Google Maps or MapKit JS is not allowed).
*
* **Disclaimer:**
*
* The failure of Mapbox to exercise or enforce any right or provision of these Terms will not constitute a waiver of such right or provision.
*
* @typedef SearchBoxCategorySuggestion
* @example
* ```typescript
* const categoryFeature = {
* type: 'Feature',
* geometry: {
* type: 'Point',
* coordinates: [0,0]
* },
* properties: {
* name: 'Washington D.C.',
* }
* };
* ```
* @see [Response: Category search](https://docs.mapbox.com/api/search/search-box/#response-retrieve-pois-by-category)
*/
export declare type SearchBoxCategorySuggestion = GeoJSON.Feature<GeoJSON.Point, SearchBoxFeatureProperties>;

@@ -12,3 +12,3 @@ import { SessionToken, SessionTokenLike } from './SessionToken';

* Despite the name {@link SearchSession}, in Search JS Web we use it to control
* both {@link MapboxSearch} **and** {@link MapboxAutofill} instances. Both
* both {@link SearchBoxCore} **and** {@link AddressAutofillCore} instances. Both
* of these have similar workflows, but are separate APIs with different options

@@ -25,3 +25,3 @@ * and responses.

* ```typescript
* const autofill = new MapboxAutofill({
* const autofill = new AddressAutofillCore({
* accessToken: 'pk.my-fancy-token',

@@ -33,6 +33,6 @@ * });

* `session` has inferred type = SearchSession<
* AutofillOptions,
* AutofillSuggestion,
* AutofillSuggestionResponse,
* AutofillRetrieveResponse
* AddressAutofillOptions,
* AddressAutofillSuggestion,
* AddressAutofillSuggestionResponse,
* AddressAutofillRetrieveResponse
* >

@@ -53,4 +53,4 @@ * ```

/**
* A `SearchSession` object is a managed entrypoint to the [Mapbox Search API](https://docs.mapbox.com/api/search/search/)
* or Mapbox Autocomplete API.
* A `SearchSession` object is a managed entrypoint to the [Mapbox Search Box API](https://docs.mapbox.com/api/search/search-box/)
* or Mapbox Address Autofill API.
*

@@ -67,3 +67,3 @@ * `SearchSession` abstracts the suggest/retrieve flow of the two-step interactive search experience.

* ```typescript
* const search = new MapboxSearch({ accessToken: 'pk.my-mapbox-access-token' });
* const search = new SearchBoxCore({ accessToken: 'pk.my-mapbox-access-token' });
* const session = new SearchSession(search);

@@ -96,3 +96,3 @@ *

* ```
* @param {MapboxSearch | MapboxAutofill} search - The search interface to wrap.
* @param {SearchBoxCore | AddressAutofillCore} search - The search interface to wrap.
* @param {number} wait - The time in milliseconds to wait before sending a new request to the {@link SearchSession#suggest} call.

@@ -135,3 +135,3 @@ */

* ```typescript
* const search = new MapboxSearch({ accessToken: 'pk.my-mapbox-access-token' });
* const search = new SearchBoxCore({ accessToken: 'pk.my-mapbox-access-token' });
* const session = new SearchSession(search);

@@ -180,3 +180,3 @@ *

*
* This indicates the [Mapbox Search API](https://docs.mapbox.com/api/search/search/) has geographic coordinates
* This indicates the [Mapbox Search Box API](https://docs.mapbox.com/api/search/search-box/) has geographic coordinates
* for this suggestion.

@@ -191,3 +191,3 @@ *

*
* This indicates the [Mapbox Search API](https://docs.mapbox.com/api/search/search/) wants to do another
* This indicates the [Mapbox Search Box API](https://docs.mapbox.com/api/search/search-box/) wants to do another
* suggestion search on this result, and does not have geographic coordinates.

@@ -194,0 +194,0 @@ *

/**
* A `SessionToken` object is a unique identifier that groups together `suggest` / `retrieve` calls as part of the
* [Mapbox Search API](https://docs.mapbox.com/api/search/search/#retrieve-a-suggestion).
* [Mapbox Search Box API](https://docs.mapbox.com/api/search/search-box/#retrieve-a-suggested-feature).
*
* Session tokens are used for [billing](https://docs.mapbox.com/api/search/search/#search-api-pricing) and
* Session tokens are used for [billing](https://docs.mapbox.com/api/search/search-box/#search-box-api-pricing) and
* customer-accessible analytics.

@@ -42,3 +42,3 @@ *

/**
* A {@link SessionToken} object or string representing a Mapbox Search API session token.
* A {@link SessionToken} object or string representing a Mapbox Search Box API session token.
*

@@ -45,0 +45,0 @@ * It's recommended this value is a [UUIDv4](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)) value.

import { LngLatBoundsLike } from '../LngLatBounds';
import { MatchCode } from '../types';
/**
* Validate feature properties from the Mapbox Validate API.
* Validation feature properties from the Mapbox Validation API.
*
*
* @typedef ValidateFeatureProperties
* @typedef ValidationFeatureProperties
* @example
* ```typescript
* const validate = new MapboxValidate({ accessToken: 'pk.my-mapbox-access-token' });
* const validate = new ValidationCore({ accessToken: 'pk.my-mapbox-access-token' });
*

@@ -20,3 +20,3 @@ * const sessionToken = new SessionToken();

*/
export interface ValidateFeatureProperties {
export interface ValidationFeatureProperties {
/**

@@ -99,10 +99,10 @@ * The name of the feature.

/**
* A `ValidateFeature` object represents [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/)
* A `ValidationFeature` object represents [GeoJSON](https://docs.mapbox.com/help/glossary/geojson/)
*
* As per the Mapbox Validate API, this will always be a [Point](https://geojson.org/geojson-spec.html#point).
* As per the Mapbox Validation API, this will always be a [Point](https://geojson.org/geojson-spec.html#point).
*
* @typedef ValidateFeature
* @typedef ValidationFeature
* @example
* ```typescript
* const validateFeature = {
* const validationFeature = {
* type: 'Feature',

@@ -119,3 +119,3 @@ * geometry: {

*/
export declare type ValidateFeature = GeoJSON.Feature<GeoJSON.Point, ValidateFeatureProperties> & {
export declare type ValidationFeature = GeoJSON.Feature<GeoJSON.Point, ValidationFeatureProperties> & {
/**

@@ -122,0 +122,0 @@ * A bounding box for the feature. This may be significantly

@@ -26,6 +26,6 @@ import { ValidationFeature } from './types';

/**
* A customer-provided session token value, which groups a series of requests together for [billing purposes](https://docs.mapbox.com/api/search/search/#search-api-pricing).
* A customer-provided session token value, which groups a series of requests together for [billing purposes](https://docs.mapbox.com/api/search/search-box/#search-box-api-pricing).
*
* Reference:
* https://docs.mapbox.com/api/search/search/#session-based-pricing
* https://docs.mapbox.com/api/search/search-box/#session-billing
*/

@@ -77,2 +77,3 @@ sessionToken: SessionTokenLike;

features: ValidationFeature[];
url: string;
}

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

/* eslint @typescript-eslint/no-var-requires: "off" */
require('cross-fetch/polyfill');
// Test MapboxSearch in Node environment
const { MapboxSearch } = require('../dist');
const search = new MapboxSearch({
// Test SearchBoxCore in Node environment
const { SearchBoxCore, SessionToken } = require('../dist');
const search = new SearchBoxCore({
accessToken: process.env.MAPBOX_ACCESS_TOKEN
});
const sessionToken = new SessionToken();
search
.forward('740 15th St NW')
.then((res) => console.log(res.features[0].properties.place_name));
.suggest('740 15th St NW', { sessionToken })
.then((res) =>
console.log(
res.suggestions[0].name + ', ' + res.suggestions[0].place_formatted
)
);
{
"name": "@mapbox/search-js-core",
"version": "1.0.0-beta.15",
"description": "Platform agnostic wrappers for the Search API and Geocoding API.",
"version": "1.0.0-beta.16",
"description": "Platform agnostic wrappers for the Search Box, Address Autofill, and Geocoding APIs.",
"main": "dist/index.js",

@@ -6,0 +6,0 @@ "module": "dist/index-esm.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