UNPKG

@mapbox/mapbox-gl-geocoder

Version:
2 lines 70.5 kB
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.MapboxGeocoder=e()}}(function(){var e;return function(){function e(t,n,i){function r(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[s]={exports:{}};t[s][0].call(l.exports,function(e){return r(t[s][1][e]||e)},l,l.exports,e,t,n,i)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<i.length;s++)r(i[s]);return r}return e}()({1:[function(e,t,n){"use strict";function i(e){"@babel/helpers - typeof";return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e){this.origin=e.origin||"https://api.mapbox.com",this.endpoint="events/v2",this.access_token=e.accessToken,this.version="0.3.0",this.pluginSessionID=this.generateSessionID(),this.sessionIncrementer=0,this.userAgent=this.getUserAgent(),this.options=e,this.send=this.send.bind(this),this.countries=e.countries?e.countries.split(","):null,this.types=e.types?e.types.split(","):null,this.bbox=e.bbox?e.bbox:null,this.language=e.language?e.language.split(","):null,this.limit=e.limit?+e.limit:null,this.locale=navigator.language||null,this.enableEventLogging=this.shouldEnableLogging(e),this.eventQueue=new Array,this.flushInterval=e.flushInterval||1e3,this.maxQueueSize=e.maxQueueSize||100,this.timer=this.flushInterval?setTimeout(this.flush.bind(this),this.flushInterval):null,this.lastSentInput="",this.lastSentIndex=0}var o=e("nanoid").nanoid;r.prototype={select:function(e,t){var n=this.getEventPayload("search.select",t,{selectedFeature:e});if(n&&(n.resultIndex!==this.lastSentIndex||n.queryString!==this.lastSentInput)&&-1!=n.resultIndex)return this.lastSentIndex=n.resultIndex,this.lastSentInput=n.queryString,this.push(n)},start:function(e){var t=this.getEventPayload("search.start",e);if(t)return this.push(t)},keyevent:function(e,t){if(e.key&&!e.metaKey&&-1===[9,27,37,39,13,38,40].indexOf(e.keyCode)){var n=this.getEventPayload("search.keystroke",t,{key:e.key});if(n)return this.push(n)}},send:function(e,t){if(this.enableEventLogging){var n=this.getRequestOptions(e);this.request(n,function(e){return e?this.handleError(e,t):t?t():void 0}.bind(this))}else if(t)return t()},getRequestOptions:function(e){return Array.isArray(e)||(e=[e]),{method:"POST",host:this.origin,path:this.endpoint+"?access_token="+this.access_token,headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}},getEventPayload:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("search.select"===e&&!n.selectedFeature||"search.keystroke"===e&&!n.key)return null;var r;if(t.options.proximity)if("object"===i(t.options.proximity))r=[t.options.proximity.longitude,t.options.proximity.latitude];else if("ip"===t.options.proximity){var o=t._headers?t._headers["ip-proximity"]:null;r=o&&"string"==typeof o?o.split(",").map(parseFloat):[999,999]}else r=t.options.proximity;else r=null;var s=t._map?t._map.getZoom():void 0,a={event:e,version:this.getEventSchemaVersion(e),created:+new Date,sessionIdentifier:this.getSessionId(),country:this.countries,userAgent:this.userAgent,language:this.language,bbox:this.bbox,types:this.types,endpoint:"mapbox.places",autocomplete:t.options.autocomplete,fuzzyMatch:t.options.fuzzyMatch,proximity:r,limit:t.options.limit,routing:t.options.routing,worldview:t.options.worldview,mapZoom:s,keyboardLocale:this.locale};if("search.select"===e?a.queryString=t.inputString:"search.select"!=e&&t._inputEl?a.queryString=t._inputEl.value:a.queryString=t.inputString,["search.keystroke","search.select"].includes(e)&&(a.path="geocoding/v5/mapbox.places"),"search.keystroke"===e&&n.key)a.lastAction=n.key;else if("search.select"===e&&n.selectedFeature){var u=n.selectedFeature,c=this.getSelectedIndex(u,t);if(a.resultIndex=c,a.resultPlaceName=u.place_name,a.resultId=u.id,u.properties&&(a.resultMapboxId=u.properties.mapbox_id),t._typeahead){var l=t._typeahead.data;l&&l.length>0&&(a.suggestionIds=this.getSuggestionIds(l),a.suggestionNames=this.getSuggestionNames(l),a.suggestionTypes=this.getSuggestionTypes(l),a.suggestionSources=this.getSuggestionSources(l))}}return this.validatePayload(a)?a:null},request:function(e,t){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(4==this.readyState)return t(204==this.status?null:this.statusText)},n.open(e.method,e.host+"/"+e.path,!0);for(var i in e.headers){var r=e.headers[i];n.setRequestHeader(i,r)}n.send(e.body)},handleError:function(e,t){if(t)return t(e)},generateSessionID:function(){return o()},getSessionId:function(){return this.pluginSessionID+"."+this.sessionIncrementer},getUserAgent:function(){return"mapbox-gl-geocoder."+this.version+"."+navigator.userAgent},getSelectedIndex:function(e,t){if(t._typeahead){var n=t._typeahead.data,i=e.id;return n.map(function(e){return e.id}).indexOf(i)}},getSuggestionIds:function(e){return e.map(function(e){return e.properties?e.properties.mapbox_id||"":e.id||""})},getSuggestionNames:function(e){return e.map(function(e){return e.place_name||""})},getSuggestionTypes:function(e){return e.map(function(e){return e.place_type&&Array.isArray(e.place_type)?e.place_type[0]||"":""})},getSuggestionSources:function(e){return e.map(function(e){return e._source||""})},getEventSchemaVersion:function(e){return["search.keystroke","search.select"].includes(e)?"2.2":"2.0"},validatePayload:function(e){if(!e||!e.event)return!1;var t=["event","created","sessionIdentifier","queryString"],n=["event","created","sessionIdentifier","queryString","lastAction"],i=["event","created","sessionIdentifier","queryString","resultIndex","path","suggestionIds"],r=e.event;return"search.start"===r?this.objectHasRequiredProps(e,t):"search.keystroke"===r?this.objectHasRequiredProps(e,n):"search.select"!==r||this.objectHasRequiredProps(e,i)},objectHasRequiredProps:function(e,t){return t.every(function(t){return"queryString"===t?"string"==typeof e[t]&&e[t].length>0:void 0!==e[t]})},shouldEnableLogging:function(e){return!1!==e.enableEventLogging&&(!e.origin||"https://api.mapbox.com"===e.origin)},flush:function(){this.eventQueue.length>0&&(this.send(this.eventQueue),this.eventQueue=new Array),this.timer&&clearTimeout(this.timer),this.flushInterval&&(this.timer=setTimeout(this.flush.bind(this),this.flushInterval))},push:function(e,t){this.eventQueue.push(e),(this.eventQueue.length>=this.maxQueueSize||t)&&this.flush()},remove:function(){this.flush()}},t.exports=r},{nanoid:32}],2:[function(e,t,n){"use strict";t.exports={fr:{name:"France",bbox:[[-4.59235,41.380007],[9.560016,51.148506]]},us:{name:"United States",bbox:[[-171.791111,18.91619],[-66.96466,71.357764]]},ru:{name:"Russia",bbox:[[19.66064,41.151416],[190.10042,81.2504]]},ca:{name:"Canada",bbox:[[-140.99778,41.675105],[-52.648099,83.23324]]}}},{}],3:[function(e,t,n){"use strict";function i(){}i.prototype={isSupport:function(){return Boolean(window.navigator.geolocation)},getCurrentPosition:function(){var e={enableHighAccuracy:!0};return new Promise(function(t,n){window.navigator.geolocation.getCurrentPosition(t,n,e)})}},t.exports=i},{}],4:[function(e,t,n){"use strict";function i(){var e=document.createElement("div");return e.className="mapboxgl-ctrl-geocoder--powered-by",e.innerHTML='<a href="https://www.mapbox.com/search-service" target="_blank">Powered by Mapbox</a>',e}function r(e){this._eventEmitter=new u,this.options=a({},this.options,e),this.inputString="",this.fresh=!0,this.lastSelected=null,this.geolocation=new g}var o=e("suggestions"),s=e("lodash.debounce"),a=e("xtend"),u=e("events").EventEmitter,c=e("./exceptions"),l=e("@mapbox/mapbox-sdk"),h=e("@mapbox/mapbox-sdk/services/geocoding"),p=e("./events"),d=e("./localization"),f=e("subtag"),g=e("./geolocation"),y=e("./utils"),m={FORWARD:0,LOCAL:1,REVERSE:2};r.prototype={options:{zoom:16,flyTo:!0,trackProximity:!0,minLength:2,reverseGeocode:!1,flipCoordinates:!1,limit:5,origin:"https://api.mapbox.com",enableEventLogging:!0,marker:!0,mapboxgl:null,collapsed:!1,clearAndBlurOnEsc:!1,clearOnBlur:!1,enableGeolocation:!1,addressAccuracy:"street",useBrowserFocus:!1,getItemValue:function(e){return e.place_name},render:function(e){var t=e.place_name.split(",");return'<div class="mapboxgl-ctrl-geocoder--suggestion"><div class="mapboxgl-ctrl-geocoder--suggestion-title">'+t[0]+'</div><div class="mapboxgl-ctrl-geocoder--suggestion-address">'+t.splice(1,t.length).join(",")+"</div></div>"}},_headers:{},addTo:function(e){function t(e,t){if(!document.body.contains(t))throw new Error("Element provided to #addTo() exists, but is not in the DOM");var n=e.onAdd();t.appendChild(n)}if(e._controlContainer)e.addControl(this);else if(e instanceof HTMLElement)t(this,e);else{if("string"!=typeof e)throw new Error("Error: addTo must be a mapbox-gl-js map, an html element, or a CSS selector query for a single html element");var n=document.querySelectorAll(e);if(0===n.length)throw new Error("Element ",e,"not found.");if(n.length>1)throw new Error("Geocoder can only be added to a single html element");t(this,n[0])}},onAdd:function(e){if(e&&"string"!=typeof e&&(this._map=e),this.setLanguage(),this.options.localGeocoderOnly||(this.geocoderService=h(l({accessToken:this.options.accessToken,origin:this.options.origin}))),this.options.localGeocoderOnly&&!this.options.localGeocoder)throw new Error("A localGeocoder function must be specified to use localGeocoderOnly mode");this.eventManager=new p(this.options),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onPaste=this._onPaste.bind(this),this._onBlur=this._onBlur.bind(this),this._showButton=this._showButton.bind(this),this._hideButton=this._hideButton.bind(this),this._onQueryResult=this._onQueryResult.bind(this),this.clear=this.clear.bind(this),this._updateProximity=this._updateProximity.bind(this),this._collapse=this._collapse.bind(this),this._unCollapse=this._unCollapse.bind(this),this._clear=this._clear.bind(this),this._clearOnBlur=this._clearOnBlur.bind(this),this._geolocateUser=this._geolocateUser.bind(this),this._onSuggestionItemFocus=this._onSuggestionItemFocus.bind(this),this._onSuggestionItemKeyDown=this._onSuggestionItemKeydown.bind(this);var t=this.container=document.createElement("div");t.className="mapboxgl-ctrl-geocoder mapboxgl-ctrl";var n=this.createIcon("search",'<path d="M7.4 2.5c-2.7 0-4.9 2.2-4.9 4.9s2.2 4.9 4.9 4.9c1 0 1.8-.2 2.5-.8l3.7 3.7c.2.2.4.3.8.3.7 0 1.1-.4 1.1-1.1 0-.3-.1-.5-.3-.8L11.4 10c.4-.8.8-1.6.8-2.5.1-2.8-2.1-5-4.8-5zm0 1.6c1.8 0 3.2 1.4 3.2 3.2s-1.4 3.2-3.2 3.2-3.3-1.3-3.3-3.1 1.4-3.3 3.3-3.3z"/>');this._inputEl=document.createElement("input"),this._inputEl.type="text",this._inputEl.className="mapboxgl-ctrl-geocoder--input",this.setPlaceholder(),this.options.collapsed&&(this._collapse(),this.container.addEventListener("mouseenter",this._unCollapse),this.container.addEventListener("mouseleave",this._collapse),this._inputEl.addEventListener("focus",this._unCollapse)),(this.options.collapsed||this.options.clearOnBlur)&&this._inputEl.addEventListener("blur",this._onBlur),this._inputEl.addEventListener("keydown",s(this._onKeyDown,200)),this._inputEl.addEventListener("paste",this._onPaste),this._inputEl.addEventListener("change",this._onChange),this.container.addEventListener("mouseenter",this._showButton),this.container.addEventListener("mouseleave",this._hideButton),this._inputEl.addEventListener("keyup",function(e){this.eventManager.keyevent(e,this)}.bind(this));var r=document.createElement("div");r.classList.add("mapboxgl-ctrl-geocoder--pin-right"),this._clearEl=document.createElement("button"),this._clearEl.setAttribute("aria-label","Clear"),this._clearEl.addEventListener("click",this.clear),this._clearEl.className="mapboxgl-ctrl-geocoder--button";var a=this.createIcon("close",'<path d="M3.8 2.5c-.6 0-1.3.7-1.3 1.3 0 .3.2.7.5.8L7.2 9 3 13.2c-.3.3-.5.7-.5 1 0 .6.7 1.3 1.3 1.3.3 0 .7-.2 1-.5L9 10.8l4.2 4.2c.2.3.7.3 1 .3.6 0 1.3-.7 1.3-1.3 0-.3-.2-.7-.3-1l-4.4-4L15 4.6c.3-.2.5-.5.5-.8 0-.7-.7-1.3-1.3-1.3-.3 0-.7.2-1 .3L9 7.1 4.8 2.8c-.3-.1-.7-.3-1-.3z"/>');if(this._clearEl.appendChild(a),this._loadingEl=this.createIcon("loading",'<path fill="#333" d="M4.4 4.4l.8.8c2.1-2.1 5.5-2.1 7.6 0l.8-.8c-2.5-2.5-6.7-2.5-9.2 0z"/><path opacity=".1" d="M12.8 12.9c-2.1 2.1-5.5 2.1-7.6 0-2.1-2.1-2.1-5.5 0-7.7l-.8-.8c-2.5 2.5-2.5 6.7 0 9.2s6.6 2.5 9.2 0 2.5-6.6 0-9.2l-.8.8c2.2 2.1 2.2 5.6 0 7.7z"/>'),r.appendChild(this._clearEl),r.appendChild(this._loadingEl),t.appendChild(n),t.appendChild(this._inputEl),this.options.enableGeolocation&&this.geolocation.isSupport()){this._geolocateEl=document.createElement("button"),this._geolocateEl.setAttribute("aria-label","Geolocate"),this._geolocateEl.addEventListener("click",this._geolocateUser),this._geolocateEl.className="mapboxgl-ctrl-geocoder--button";var u=this.createIcon("geolocate",'<path d="M12.999 3.677L2.042 8.269c-.962.403-.747 1.823.29 1.912l5.032.431.431 5.033c.089 1.037 1.509 1.252 1.912.29l4.592-10.957c.345-.822-.477-1.644-1.299-1.299z" fill="#4264fb"/>');this._geolocateEl.appendChild(u),r.appendChild(this._geolocateEl),this._showGeolocateButton()}var c=this._typeahead=new o(this._inputEl,[],{hideOnBlur:!this.options.useBrowserFocus,filter:!1,minLength:this.options.minLength,limit:this.options.limit});t.insertBefore(r,c.list.wrapper),this.setRenderFunction(this.options.render),c.getItemValue=this.options.getItemValue;var d=this._typeahead.handleKeyDown.bind(this._typeahead),f=this._typeahead.handleKeyUp.bind(this._typeahead);this._typeahead.handleKeyUp,this.options.useBrowserFocus&&(this._typeahead.handleKeyDown=function(e){if(9!==e.keyCode||c.list.isEmpty())return 40===e.keyCode?(this._typeahead.list.active=0,this._typeahead.list.element.querySelectorAll("li").forEach(function(e){e.classList.remove("active")}),this._typeahead.list.element.querySelectorAll("li")[0].classList.add("active"),void this._typeahead.list.element.querySelectorAll("li")[0].focus()):38===e.keyCode?(this._typeahead.list.active=c.list.items.length-1,this._typeahead.list.element.querySelectorAll("li").forEach(function(e){e.classList.remove("active")}),this._typeahead.list.element.querySelectorAll("li")[this._typeahead.list.active].classList.add("active"),void this._typeahead.list.element.querySelectorAll("li")[this._typeahead.list.active].focus()):void d(e)}.bind(this),this._typeahead.handleKeyUp=function(e){if(e&&16===e.keyCode)return void e.preventDefault();f(e)});var g=c.list.draw,y=this._footerNode=i(),m=this;return c.list.draw=function(){m.options.useBrowserFocus&&c.list.element.querySelectorAll("li").forEach(function(e){e.removeEventListener("focus",m._onSuggestionItemFocus),e.removeEventListener("keydown",m._onSuggestionItemKeyDown)}),g.call(this),m.options.useBrowserFocus&&c.list.element.querySelectorAll("li").forEach(function(e,t){0===t&&e.focus(),e.setAttribute("data-index",t),e.tabIndex=0,e.addEventListener("focus",this._onSuggestionItemFocus),e.addEventListener("keydown",this._onSuggestionItemKeyDown)}.bind(m)),y.addEventListener("mousedown",function(){this.selectingListItem=!0}.bind(this)),y.addEventListener("mouseup",function(){this.selectingListItem=!1}.bind(this)),this.element.appendChild(y)},this.mapMarker=null,this._handleMarker=this._handleMarker.bind(this),this._map&&(this.options.trackProximity&&(this._updateProximity(),this._map.on("moveend",this._updateProximity)),this._mapboxgl=this.options.mapboxgl,!this._mapboxgl&&this.options.marker&&(console.error("No mapboxgl detected in options. Map markers are disabled. Please set options.mapboxgl."),this.options.marker=!1)),t},_onSuggestionItemKeydown:function(e){var t=e.keyCode;if(9!==t)if(13===t){e.preventDefault();var n=this._typeahead.list.element.querySelector(".active");if(n){var i=n.getAttribute("data-index"),r=this._typeahead.list.items[i];r&&(this._typeahead.value(r.original),this._typeahead.list.hide())}}else if(38===t||40===t){var o=this._typeahead.list.element.querySelectorAll("li");if(o.length>0){if(38===t){if(!(this._typeahead.list.active>0))return void this._typeahead.el.focus();e.preventDefault(),this._typeahead.list.active--}else if(40===t){if(e.preventDefault(),!(this._typeahead.list.active<o.length-1))return;this._typeahead.list.active++}o.forEach(function(e){e.classList.remove("active")});var s=o[this._typeahead.list.active];s&&(s.classList.add("active"),s.focus())}}},_onSuggestionItemFocus:function(e){this._typeahead.list.active=e.target.getAttribute("data-index"),this._typeahead.list.element.querySelectorAll("li").forEach(function(e){e.classList.remove("active")}),e.target.classList.add("active")},_geolocateUser:function(){this._hideGeolocateButton(),this._showLoadingIcon(),this.geolocation.getCurrentPosition().then(function(e){this._hideLoadingIcon();var t={geometry:{type:"Point",coordinates:[e.coords.longitude,e.coords.latitude]}};this._handleMarker(t),this._fly(t),this._typeahead.clear(),this._typeahead.selected=!0,this.lastSelected=JSON.stringify(t),this._showClearButton(),this.fresh=!1;var n={limit:1,language:[this.options.language],query:t.geometry.coordinates,types:["address"]};if(this.options.localGeocoderOnly){var i=t.geometry.coordinates[0]+","+t.geometry.coordinates[1];this._setInputValue(i),this._eventEmitter.emit("result",{result:t})}else this.geocoderService.reverseGeocode(n).send().then(function(e){var n=e.body.features[0];if(n){var i=y.transformFeatureToGeolocationText(n,this.options.addressAccuracy);this._setInputValue(i),n.user_coordinates=t.geometry.coordinates,this._eventEmitter.emit("result",{result:n})}else this._eventEmitter.emit("result",{result:{user_coordinates:t.geometry.coordinates}})}.bind(this))}.bind(this)).catch(function(e){1===e.code?this._renderUserDeniedGeolocationError():this._renderLocationError(),this._hideLoadingIcon(),this._showGeolocateButton(),this._hideAttribution()}.bind(this))},createIcon:function(e,t){var n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("class","mapboxgl-ctrl-geocoder--icon mapboxgl-ctrl-geocoder--icon-"+e),n.setAttribute("viewBox","0 0 18 18"),n.setAttribute("xml:space","preserve"),n.setAttribute("width",18),n.setAttribute("height",18),n.innerHTML=t,n},onRemove:function(){return this.container.parentNode.removeChild(this.container),this.options.trackProximity&&this._map&&this._map.off("moveend",this._updateProximity),this._removeMarker(),this._map=null,this},_setInputValue:function(e){this._inputEl.value=e,setTimeout(function(){this._inputEl.focus(),this._inputEl.scrollLeft=0,this._inputEl.setSelectionRange(0,0)}.bind(this),1)},_onPaste:function(e){var t=(e.clipboardData||window.clipboardData).getData("text");t.length>=this.options.minLength&&this._geocode(t)},_onKeyDown:function(e){if(27===e.keyCode&&this.options.clearAndBlurOnEsc)return this._clear(e),this._inputEl.blur();var t=e.target&&e.target.shadowRoot?e.target.shadowRoot.activeElement:e.target;if(!(t?t.value:""))return this.fresh=!0,9!==e.keyCode&&this.clear(e),this._showGeolocateButton(),this._hideClearButton();this._hideGeolocateButton(),e.metaKey||-1!==[9,27,37,39,13,38,40].indexOf(e.keyCode)||t.value.length>=this.options.minLength&&this._geocode(t.value)},_showButton:function(){this._typeahead.selected&&this._showClearButton()},_hideButton:function(){this._typeahead.selected&&this._hideClearButton()},_showClearButton:function(){this._clearEl.style.display="block"},_hideClearButton:function(){this._clearEl.style.display="none"},_showGeolocateButton:function(){this._geolocateEl&&this.geolocation.isSupport()&&(this._geolocateEl.style.display="block")},_hideGeolocateButton:function(){this._geolocateEl&&(this._geolocateEl.style.display="none")},_showLoadingIcon:function(){this._loadingEl.style.display="block"},_hideLoadingIcon:function(){this._loadingEl.style.display="none"},_showAttribution:function(){this._footerNode.style.display="block"},_hideAttribution:function(){this._footerNode.style.display="none"},_onBlur:function(e){this.options.clearOnBlur&&this._clearOnBlur(e),this.options.collapsed&&this._collapse()},_onChange:function(){var e=this._typeahead.selected;e&&JSON.stringify(e)!==this.lastSelected&&(this._hideClearButton(),this.options.flyTo&&this._fly(e),this.options.marker&&this._mapboxgl&&this._handleMarker(e),this._inputEl.focus(),this._inputEl.scrollLeft=0,this._inputEl.setSelectionRange(0,0),this.lastSelected=JSON.stringify(e),this._eventEmitter.emit("result",{result:e}),this.eventManager.select(e,this))},_fly:function(e){var t;if(e.properties&&c[e.properties.short_code])t=a({},this.options.flyTo),this._map&&this._map.fitBounds(c[e.properties.short_code].bbox,t);else if(e.bbox){var n=e.bbox;t=a({},this.options.flyTo),this._map&&this._map.fitBounds([[n[0],n[1]],[n[2],n[3]]],t)}else{var i={zoom:this.options.zoom};t=a({},i,this.options.flyTo),e.center?t.center=e.center:e.geometry&&e.geometry.type&&"Point"===e.geometry.type&&e.geometry.coordinates&&(t.center=e.geometry.coordinates),this._map&&this._map.flyTo(t)}},_requestType:function(e,t){return e.localGeocoderOnly?m.LOCAL:e.reverseGeocode&&y.REVERSE_GEOCODE_COORD_RGX.test(t)?m.REVERSE:m.FORWARD},_setupConfig:function(e,t){var n=["bbox","limit","proximity","countries","types","language","reverseMode","mode","autocomplete","fuzzyMatch","routing","worldview"],i=/[\s,]+/,r=this,o=n.reduce(function(e,t){if(void 0===r.options[t]||null===r.options[t])return e;["countries","types","language"].indexOf(t)>-1?e[t]=r.options[t].split(i):e[t]=r.options[t];var n="number"==typeof r.options[t].longitude&&"number"==typeof r.options[t].latitude;if("proximity"===t&&n){var o=r.options[t].longitude,s=r.options[t].latitude;e[t]=[o,s]}return e},{});switch(e){case m.REVERSE:var s=t.split(i).map(function(e){return parseFloat(e,10)});r.options.flipCoordinates||s.reverse(),o.types&&o.types[0],o=a(o,{query:s,limit:1}),["proximity","autocomplete","fuzzyMatch","bbox"].forEach(function(e){e in o&&delete o[e]});break;case m.FORWARD:/^(-?\d{1,3}(\.\d{0,256})?)[, ]+(-?\d{1,3}(\.\d{0,256})?)?$/.test(t.trim())&&(t=t.replace(/,/g," ")),o=a(o,{query:t})}return o.session_token=this.eventManager.getSessionId(),o},_geocode:function(e){this.inputString=e,this._showLoadingIcon(),this._eventEmitter.emit("loading",{query:e});var t,n=this._requestType(this.options,e),i=this._setupConfig(n,e);switch(n){case m.LOCAL:t=Promise.resolve();break;case m.FORWARD:t=this.geocoderService.forwardGeocode(i).send();break;case m.REVERSE:t=this.geocoderService.reverseGeocode(i).send()}var r=this.options.localGeocoder?this.options.localGeocoder(e)||[]:[],o=[],s=null;return t.catch(function(e){s=e}.bind(this)).then(function(t){this._hideLoadingIcon();var n={};return t?"200"==t.statusCode&&(n=t.body,n.request=t.request,n.headers=t.headers,this._headers=t.headers):n={type:"FeatureCollection",features:[]},n.config=i,this.fresh&&(this.eventManager.start(this),this.fresh=!1),n.features&&n.features.length&&n.features.map(function(e){e._source="mapbox"}),n.features=n.features?r.concat(n.features):r,this.options.externalGeocoder?(o=this.options.externalGeocoder(e,n.features)||Promise.resolve([]),o.then(function(e){return n.features=n.features?e.concat(n.features):e,n},function(){return n})):n}.bind(this)).then(function(e){if(s)throw s;this.options.filter&&e.features.length&&(e.features=e.features.filter(this.options.filter)),e.features.length?(this._showClearButton(),this._hideGeolocateButton(),this._showAttribution(),this._eventEmitter.emit("results",e),this._typeahead.update(e.features)):(this._hideClearButton(),this._hideAttribution(),this._typeahead.selected=null,this._renderNoResults(),this._eventEmitter.emit("results",e))}.bind(this)).catch(function(e){this._hideLoadingIcon(),this._hideAttribution(),r.length&&this.options.localGeocoder||o.length&&this.options.externalGeocoder?(this._showClearButton(),this._hideGeolocateButton(),this._typeahead.update(r)):(this._hideClearButton(),this._typeahead.selected=null,this._renderError()),this._eventEmitter.emit("results",{features:r}),this._eventEmitter.emit("error",{error:e})}.bind(this)),t},_clear:function(e){e&&e.preventDefault(),this._inputEl.value="",this._typeahead.selected=null,this._typeahead.clear(),this.eventManager.sessionIncrementer++,this._onChange(),this._hideClearButton(),this._showGeolocateButton(),this._removeMarker(),this.lastSelected=null,this._eventEmitter.emit("clear"),this.fresh=!0},clear:function(e){this._clear(e),this._inputEl.focus(),this.options.useBrowserFocus&&this._typeahead.list.hide()},_clearOnBlur:function(e){var t=this;e.relatedTarget&&t._clear(e)},_onQueryResult:function(e){var t=e.body;if(t.features.length){var n=t.features[0];this._typeahead.selected=n,this._inputEl.value=n.place_name,this._onChange()}},_updateProximity:function(){if(this._map&&this.options.trackProximity)if(this._map.getZoom()>9){var e=this._map.getCenter().wrap();this.setProximity({longitude:e.lng,latitude:e.lat},!1)}else this.setProximity(null,!1)},_collapse:function(){this._inputEl.value||this._inputEl===document.activeElement||this.container.classList.add("mapboxgl-ctrl-geocoder--collapsed")},_unCollapse:function(){this.container.classList.remove("mapboxgl-ctrl-geocoder--collapsed")},query:function(e){return this._geocode(e).then(this._onQueryResult),this},_renderError:function(){this._renderMessage("<div class='mapbox-gl-geocoder--error'>There was an error reaching the server</div>")},_renderLocationError:function(){this._renderMessage("<div class='mapbox-gl-geocoder--error'>A location error has occurred</div>")},_renderNoResults:function(){this._renderMessage("<div class='mapbox-gl-geocoder--error mapbox-gl-geocoder--no-results'>No results found</div>")},_renderUserDeniedGeolocationError:function(){this._renderMessage("<div class='mapbox-gl-geocoder--error'>Geolocation permission denied</div>")},_renderMessage:function(e){this._typeahead.update([]),this._typeahead.selected=null,this._typeahead.clear(),this._typeahead.renderError(e)},_getPlaceholderText:function(){if(this.options.placeholder)return this.options.placeholder;if(this.options.language){var e=this.options.language.split(",")[0],t=f.language(e),n=d.placeholder[t];if(n)return n}return"Search"},setInput:function(e,t){return void 0===t&&(t=!1),this._inputEl.value=e,this._typeahead.selected=null,this._typeahead.clear(),e.length>=this.options.minLength&&(t?this._geocode(e):this._onChange()),this},setProximity:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.options.proximity=e,t&&(this.options.trackProximity=!1),this},getProximity:function(){return this.options.proximity},setRenderFunction:function(e){return e&&"function"==typeof e&&(this._typeahead.render=e),this},getRenderFunction:function(){return this._typeahead.render},setLanguage:function(e){var t=navigator.language||navigator.userLanguage||navigator.browserLanguage;return this.options.language=e||this.options.language||t,this},getLanguage:function(){return this.options.language},getZoom:function(){return this.options.zoom},setZoom:function(e){return this.options.zoom=e,this},getFlyTo:function(){return this.options.flyTo},setFlyTo:function(e){return this.options.flyTo=e,this},getPlaceholder:function(){return this.options.placeholder},setPlaceholder:function(e){return this.options.placeholder=e||this._getPlaceholderText(),this._inputEl.placeholder=this.options.placeholder,this._inputEl.setAttribute("aria-label",this.options.placeholder),this},getBbox:function(){return this.options.bbox},setBbox:function(e){return this.options.bbox=e,this},getCountries:function(){return this.options.countries},setCountries:function(e){return this.options.countries=e,this},getTypes:function(){return this.options.types},setTypes:function(e){return this.options.types=e,this},getMinLength:function(){return this.options.minLength},setMinLength:function(e){return this.options.minLength=e,this._typeahead&&(this._typeahead.options.minLength=e),this},getLimit:function(){return this.options.limit},setLimit:function(e){return this.options.limit=e,this._typeahead&&(this._typeahead.options.limit=e),this},getFilter:function(){return this.options.filter},setFilter:function(e){return this.options.filter=e,this},setOrigin:function(e){return this.options.origin=e,this.geocoderService=h(l({accessToken:this.options.accessToken,origin:this.options.origin})),this},getOrigin:function(){return this.options.origin},setAccessToken:function(e){return this.options.accessToken=e,this.geocoderService=h(l({accessToken:this.options.accessToken,origin:this.options.origin})),this},setAutocomplete:function(e){return this.options.autocomplete=e,this},getAutocomplete:function(){return this.options.autocomplete},setFuzzyMatch:function(e){return this.options.fuzzyMatch=e,this},getFuzzyMatch:function(){return this.options.fuzzyMatch},setRouting:function(e){return this.options.routing=e,this},getRouting:function(){return this.options.routing},setWorldview:function(e){return this.options.worldview=e,this},getWorldview:function(){return this.options.worldview},_handleMarker:function(e){if(this._map){this._removeMarker();var t={color:"#4668F2"},n=a({},t,this.options.marker);return this.mapMarker=new this._mapboxgl.Marker(n),e.center?this.mapMarker.setLngLat(e.center).addTo(this._map):e.geometry&&e.geometry.type&&"Point"===e.geometry.type&&e.geometry.coordinates&&this.mapMarker.setLngLat(e.geometry.coordinates).addTo(this._map),this}},_removeMarker:function(){this.mapMarker&&(this.mapMarker.remove(),this.mapMarker=null)},on:function(e,t){return this._eventEmitter.on(e,t),this},off:function(e,t){return this._eventEmitter.removeListener(e,t),this.eventManager.remove(),this}},t.exports=r},{"./events":1,"./exceptions":2,"./geolocation":3,"./localization":5,"./utils":6,"@mapbox/mapbox-sdk":8,"@mapbox/mapbox-sdk/services/geocoding":19,events:27,"lodash.debounce":31,subtag:35,suggestions:36,xtend:39}],5:[function(e,t,n){"use strict";var i={de:"Suche",it:"Ricerca",en:"Search",nl:"Zoeken",fr:"Chercher",ca:"Cerca",he:"לחפש",ja:"サーチ",lv:"Meklēt",pt:"Procurar",sr:"Претрага",zh:"搜索",cs:"Vyhledávání",hu:"Keresés",ka:"ძიება",nb:"Søke",sk:"Vyhľadávanie",th:"ค้นหา",fi:"Hae",is:"Leita",ko:"수색",pl:"Szukaj",sl:"Iskanje",fa:"جستجو",ru:"Поиск"};t.exports={placeholder:i}},{}],6:[function(e,t,n){"use strict";function i(e,t){var n,i=r(e),o=["address","street","place","country"];if("function"==typeof t)return t(i);var s=o.indexOf(t);return n=-1===s?o:o.slice(s),n.reduce(function(e,t){return i[t]?(""!==e&&(e+=", "),e+i[t]):e},"")}function r(e){var t=e.address||"",n=e.text||"",i=e.place_name||"",r=i.split(",")[0],o={address:r,houseNumber:t,street:n,placeName:i};return e.context.forEach(function(e){var t=e.id.split(".")[0];o[t]=e.text}),o}var o=/^[ ]*(-?\d{1,3}(\.\d{0,256})?)[, ]+(-?\d{1,3}(\.\d{0,256})?)[ ]*$/;t.exports={transformFeatureToGeolocationText:i,getAddressInfo:r,REVERSE_GEOCODE_COORD_RGX:o}},{}],7:[function(e,t,n){"use strict";function i(e){var t=Array.isArray(e),n=function(n){return t?e[n]:e};return function(i){var o=r(g.plainArray,i);if(o)return o;if(t&&i.length!==e.length)return"an array with "+e.length+" items";for(var s=0;s<i.length;s++)if(o=r(n(s),i[s]))return[s].concat(o)}}function r(e,t){if(null!=t||e.hasOwnProperty("__required")){var n=e(t);return n?Array.isArray(n)?n:[n]:void 0}}function o(e,t){var n=e.length,i=e[n-1],r=e.slice(0,n-1);return 0===r.length&&(r=[f]),t=d(t,{path:r}),"function"==typeof i?i(t):c(t,a(i))}function s(e){return e.length<2?e[0]:2===e.length?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e.slice(-1)}function a(e){return"must be "+u(e)+"."}function u(e){ return/^an? /.test(e)?e:/^[aeiou]/i.test(e)?"an "+e:/^[a-z]/i.test(e)?"a "+e:e}function c(e,t){var n=l(e.path),i=e.path.join(".")+" "+t;return(n?"Item at position ":"")+i}function l(e){return"number"==typeof e[e.length-1]||"number"==typeof e[0]}function h(e){return Object.keys(e||{}).map(function(t){return{key:t,value:e[t]}})}var p=e("is-plain-obj"),d=e("xtend"),f="value",g={};g.assert=function(e,t){return t=t||{},function(n){var i=r(e,n);if(i){var s=o(i,t);throw t.apiName&&(s=t.apiName+": "+s),new Error(s)}}},g.shape=function(e){var t=h(e);return function(e){var n=r(g.plainObject,e);if(n)return n;for(var i,s,a=[],u=0;u<t.length;u++)i=t[u].key,s=t[u].value,(n=r(s,e[i]))&&a.push([i].concat(n));return a.length<2?a[0]:function(e){a=a.map(function(t){return"- "+t[0]+": "+o(t,e).split("\n").join("\n ")});var t=e.path.join(".");return"The following properties"+(t===f?"":" of "+t)+" have invalid values:\n "+a.join("\n ")}}},g.strictShape=function(e){var t=g.shape(e);return function(n){var i=t(n);if(i)return i;var r=Object.keys(n).reduce(function(t,n){return void 0===e[n]&&t.push(n),t},[]);return 0!==r.length?function(){return"The following keys are invalid: "+r.join(", ")}:void 0}},g.arrayOf=function(e){return i(e)},g.tuple=function(){return i(Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments))},g.required=function(e){function t(t){return null==t?function(e){return c(e,l(e.path)?"cannot be undefined/null.":"is required.")}:e.apply(this,arguments)}return t.__required=!0,t},g.oneOfType=function(){var e=Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments);return function(t){var n=e.map(function(e){return r(e,t)}).filter(Boolean);if(n.length===e.length)return n.every(function(e){return 1===e.length&&"string"==typeof e[0]})?s(n.map(function(e){return e[0]})):n.reduce(function(e,t){return t.length>e.length?t:e})}},g.equal=function(e){return function(t){if(t!==e)return JSON.stringify(e)}},g.oneOf=function(){var e=Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments),t=e.map(function(e){return g.equal(e)});return g.oneOfType.apply(this,t)},g.range=function(e){var t=e[0],n=e[1];return function(e){if(r(g.number,e)||e<t||e>n)return"number between "+t+" & "+n+" (inclusive)"}},g.any=function(){},g.boolean=function(e){if("boolean"!=typeof e)return"boolean"},g.number=function(e){if("number"!=typeof e)return"number"},g.plainArray=function(e){if(!Array.isArray(e))return"array"},g.plainObject=function(e){if(!p(e))return"object"},g.string=function(e){if("string"!=typeof e)return"string"},g.func=function(e){if("function"!=typeof e)return"function"},g.validate=r,g.processMessage=o,t.exports=g},{"is-plain-obj":30,xtend:39}],8:[function(e,t,n){"use strict";var i=e("./lib/client");t.exports=i},{"./lib/client":9}],9:[function(e,t,n){"use strict";function i(e){s.call(this,e)}function r(e){return new i(e)}var o=e("./browser-layer"),s=e("../classes/mapi-client");i.prototype=Object.create(s.prototype),i.prototype.constructor=i,i.prototype.sendRequest=o.browserSend,i.prototype.abortRequest=o.browserAbort,t.exports=r},{"../classes/mapi-client":11,"./browser-layer":10}],10:[function(e,t,n){"use strict";function i(e){var t=d[e.id];t&&(t.abort(),delete d[e.id])}function r(e,t){return new c(e,{body:t.response,headers:p(t.getAllResponseHeaders()),statusCode:t.status})}function o(e){var t=e.total,n=e.loaded;return{total:t,transferred:n,percent:100*n/t}}function s(e,t){return new Promise(function(n,i){t.onprogress=function(t){e.emitter.emit(h.EVENT_PROGRESS_DOWNLOAD,o(t))};var r=e.file;r&&(t.upload.onprogress=function(t){e.emitter.emit(h.EVENT_PROGRESS_UPLOAD,o(t))}),t.onerror=function(e){i(e)},t.onabort=function(){var t=new l({request:e,type:h.ERROR_REQUEST_ABORTED});i(t)},t.onload=function(){if(delete d[e.id],t.status<200||t.status>=400){var r=new l({request:e,body:t.response,statusCode:t.status});return void i(r)}n(t)};var s=e.body;"string"==typeof s?t.send(s):s?t.send(JSON.stringify(s)):r?t.send(r):t.send(),d[e.id]=t}).then(function(t){return r(e,t)})}function a(e,t){var n=e.url(t),i=new window.XMLHttpRequest;return i.open(e.method,n),Object.keys(e.headers).forEach(function(t){i.setRequestHeader(t,e.headers[t])}),i}function u(e){return Promise.resolve().then(function(){var t=a(e,e.client.accessToken);return s(e,t)})}var c=e("../classes/mapi-response"),l=e("../classes/mapi-error"),h=e("../constants"),p=e("../helpers/parse-headers"),d={};t.exports={browserAbort:i,sendRequestXhr:s,browserSend:u,createRequestXhr:a}},{"../classes/mapi-error":12,"../classes/mapi-response":14,"../constants":15,"../helpers/parse-headers":16}],11:[function(e,t,n){"use strict";function i(e){if(!e||!e.accessToken)throw new Error("Cannot create a client without an access token");r(e.accessToken),this.accessToken=e.accessToken,this.origin=e.origin||s.API_ORIGIN}var r=e("@mapbox/parse-mapbox-token"),o=e("./mapi-request"),s=e("../constants");i.prototype.createRequest=function(e){return new o(this,e)},t.exports=i},{"../constants":15,"./mapi-request":13,"@mapbox/parse-mapbox-token":25}],12:[function(e,t,n){"use strict";function i(e){var t,n=e.type||r.ERROR_HTTP;if(e.body)try{t=JSON.parse(e.body)}catch(n){t=e.body}else t=null;var i=e.message||null;i||("string"==typeof t?i=t:t&&"string"==typeof t.message?i=t.message:n===r.ERROR_REQUEST_ABORTED&&(i="Request aborted")),this.message=i,this.type=n,this.statusCode=e.statusCode||null,this.request=e.request,this.body=t}var r=e("../constants");t.exports=i},{"../constants":15}],13:[function(e,t,n){"use strict";function i(e,t){if(!e)throw new Error("MapiRequest requires a client");if(!t||!t.path||!t.method)throw new Error("MapiRequest requires an options object with path and method properties");var n={};t.body&&(n["content-type"]="application/json");var i=o(n,t.headers),r=Object.keys(i).reduce(function(e,t){return e[t.toLowerCase()]=i[t],e},{});this.id=c++,this._options=t,this.emitter=new s,this.client=e,this.response=null,this.error=null,this.sent=!1,this.aborted=!1,this.path=t.path,this.method=t.method,this.origin=t.origin||e.origin,this.query=t.query||{},this.params=t.params||{},this.body=t.body||null,this.file=t.file||null,this.encoding=t.encoding||"utf8",this.sendFileAs=t.sendFileAs||null,this.headers=r}var r=e("@mapbox/parse-mapbox-token"),o=e("xtend"),s=e("eventemitter3"),a=e("../helpers/url-utils"),u=e("../constants"),c=1;i.prototype.url=function(e){var t=a.prependOrigin(this.path,this.origin);t=a.appendQueryObject(t,this.query);var n=this.params,i=null==e?this.client.accessToken:e;if(i){t=a.appendQueryParam(t,"access_token",i);var s=r(i).user;n=o({ownerId:s},n)}return t=a.interpolateRouteParams(t,n),t},i.prototype.send=function(){var e=this;if(e.sent)throw new Error("This request has already been sent. Check the response and error properties. Create a new request with clone().");return e.sent=!0,e.client.sendRequest(e).then(function(t){return e.response=t,e.emitter.emit(u.EVENT_RESPONSE,t),t},function(t){throw e.error=t,e.emitter.emit(u.EVENT_ERROR,t),t})},i.prototype.abort=function(){this._nextPageRequest&&(this._nextPageRequest.abort(),delete this._nextPageRequest),this.response||this.error||this.aborted||(this.aborted=!0,this.client.abortRequest(this))},i.prototype.eachPage=function(e){function t(t){function n(){delete r._nextPageRequest;var e=t.nextPage();e&&(r._nextPageRequest=e,i(e))}e(null,t,n)}function n(t){e(t,null,function(){})}function i(e){e.send().then(t,n)}var r=this;i(this)},i.prototype.clone=function(){return this._extend()},i.prototype._extend=function(e){var t=o(this._options,e);return new i(this.client,t)},t.exports=i},{"../constants":15,"../helpers/url-utils":18,"@mapbox/parse-mapbox-token":25,eventemitter3:28,xtend:39}],14:[function(e,t,n){"use strict";function i(e,t){this.request=e,this.headers=t.headers,this.rawBody=t.body,this.statusCode=t.statusCode;try{this.body=JSON.parse(t.body||"{}")}catch(e){this.body=t.body}this.links=r(this.headers.link)}var r=e("../helpers/parse-link-header");i.prototype.hasNextPage=function(){return!!this.links.next},i.prototype.nextPage=function(){return this.hasNextPage()?this.request._extend({path:this.links.next.url}):null},t.exports=i},{"../helpers/parse-link-header":17}],15:[function(e,t,n){"use strict";t.exports={API_ORIGIN:"https://api.mapbox.com",EVENT_PROGRESS_DOWNLOAD:"downloadProgress",EVENT_PROGRESS_UPLOAD:"uploadProgress",EVENT_ERROR:"error",EVENT_RESPONSE:"response",ERROR_HTTP:"HttpError",ERROR_REQUEST_ABORTED:"RequestAbortedError"}},{}],16:[function(e,t,n){"use strict";function i(e){var t=e.indexOf(":");return{name:e.substring(0,t).trim().toLowerCase(),value:e.substring(t+1).trim()}}function r(e){var t={};return e?(e.trim().split(/[\r|\n]+/).forEach(function(e){var n=i(e);t[n.name]=n.value}),t):t}t.exports=r},{}],17:[function(e,t,n){"use strict";function i(e){var t=e.match(/\s*(.+)\s*=\s*"?([^"]+)"?/);return t?{key:t[1],value:t[2]}:null}function r(e){var t=e.match(/<?([^>]*)>(.*)/);if(!t)return null;var n=t[1],r=t[2].split(";"),o=null,s=r.reduce(function(e,t){var n=i(t);return n?"rel"===n.key?(o||(o=n.value),e):(e[n.key]=n.value,e):e},{});return o?{url:n,rel:o,params:s}:null}function o(e){return e?e.split(/,\s*</).reduce(function(e,t){var n=r(t);return n?(n.rel.split(/\s+/).forEach(function(t){e[t]||(e[t]={url:n.url,params:n.params})}),e):e},{}):{}}t.exports=o},{}],18:[function(e,t,n){"use strict";function i(e){return e.map(encodeURIComponent).join(",")}function r(e){return Array.isArray(e)?i(e):encodeURIComponent(String(e))}function o(e,t,n){if(!1===n||null===n)return e;var i=/\?/.test(e)?"&":"?",o=encodeURIComponent(t);return void 0!==n&&""!==n&&!0!==n&&(o+="="+r(n)),""+e+i+o}function s(e,t){if(!t)return e;var n=e;return Object.keys(t).forEach(function(e){var i=t[e];void 0!==i&&(Array.isArray(i)&&(i=i.filter(function(e){return null!==e&&void 0!==e}).join(",")),n=o(n,e,i))}),n}function a(e,t){if(!t)return e;if("http"===e.slice(0,4))return e;var n="/"===e[0]?"":"/";return""+t.replace(/\/$/,"")+n+e}function u(e,t){return t?e.replace(/\/:([a-zA-Z0-9]+)/g,function(e,n){var i=t[n];if(void 0===i)throw new Error("Unspecified route parameter "+n);return"/"+r(i)}):e}t.exports={appendQueryObject:s,appendQueryParam:o,prependOrigin:a,interpolateRouteParams:u}},{}],19:[function(e,t,n){"use strict";var i=e("xtend"),r=e("./service-helpers/validator"),o=e("./service-helpers/pick"),s=e("./service-helpers/stringify-booleans"),a=e("./service-helpers/create-service-factory"),u={},c=["country","region","postcode","district","place","locality","neighborhood","address","poi","poi.landmark"];u.forwardGeocode=function(e){r.assertShape({query:r.required(r.string),mode:r.oneOf("mapbox.places","mapbox.places-permanent"),countries:r.arrayOf(r.string),proximity:r.oneOf(r.coordinates,"ip"),types:r.arrayOf(r.oneOf(c)),autocomplete:r.boolean,bbox:r.arrayOf(r.number),limit:r.number,language:r.arrayOf(r.string),routing:r.boolean,fuzzyMatch:r.boolean,worldview:r.string,session_token:r.string})(e),e.mode=e.mode||"mapbox.places";var t=s(i({country:e.countries},o(e,["proximity","types","autocomplete","bbox","limit","language","routing","fuzzyMatch","worldview","session_token"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:o(e,["mode","query"]),query:t})},u.reverseGeocode=function(e){r.assertShape({query:r.required(r.coordinates),mode:r.oneOf("mapbox.places","mapbox.places-permanent"),countries:r.arrayOf(r.string),types:r.arrayOf(r.oneOf(c)),bbox:r.arrayOf(r.number),limit:r.number,language:r.arrayOf(r.string),reverseMode:r.oneOf("distance","score"),routing:r.boolean,worldview:r.string,session_token:r.string})(e),e.mode=e.mode||"mapbox.places";var t=s(i({country:e.countries},o(e,["country","types","bbox","limit","language","reverseMode","routing","worldview","session_token"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:o(e,["mode","query"]),query:t})},t.exports=a(u)},{"./service-helpers/create-service-factory":20,"./service-helpers/pick":22,"./service-helpers/stringify-booleans":23,"./service-helpers/validator":24,xtend:39}],20:[function(e,t,n){"use strict";function i(e){return function(t){var n;n=r.prototype.isPrototypeOf(t)?t:o(t);var i=Object.create(e);return i.client=n,i}}var r=e("../../lib/classes/mapi-client"),o=e("../../lib/client");t.exports=i},{"../../lib/classes/mapi-client":11,"../../lib/client":9}],21:[function(e,t,n){"use strict";function i(e,t){return Object.keys(e).reduce(function(n,i){return n[i]=t(i,e[i]),n},{})}t.exports=i},{}],22:[function(e,t,n){"use strict";function i(e,t){var n=function(e,n){return-1!==t.indexOf(e)&&void 0!==n};return"function"==typeof t&&(n=t),Object.keys(e).filter(function(t){return n(t,e[t])}).reduce(function(t,n){return t[n]=e[n],t},{})}t.exports=i},{}],23:[function(e,t,n){"use strict";function i(e){return r(e,function(e,t){return"boolean"==typeof t?JSON.stringify(t):t})}var r=e("./object-map");t.exports=i},{"./object-map":21}],24:[function(e,t,n){(function(n){(function(){"use strict";function i(e){if("undefined"!=typeof window){if(e instanceof n.Blob||e instanceof n.ArrayBuffer)return;return"Blob or ArrayBuffer"}if("string"!=typeof e&&void 0===e.pipe)return"Filename or Readable stream"}function r(e,t){return u.assert(u.strictShape(e),t)}function o(e){if("boolean"==typeof e)return"date";try{var t=new Date(e);if(t.getTime&&isNaN(t.getTime()))return"date"}catch(e){return"date"}}function s(e){return u.tuple(u.number,u.number)(e)}var a=e("xtend"),u=e("@mapbox/fusspot");t.exports=a(u,{file:i,date:o,coordinates:s,assertShape:r})}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"@mapbox/fusspot":7,xtend:39}],25:[function(e,t,n){"use strict";function i(e){if(a[e])return a[e];var t=e.split("."),n=t[0],i=t[1];if(!i)throw new Error("Invalid token");var s=r(i),u={usage:n,user:s.u};return o(s,"a")&&(u.authorization=s.a),o(s,"exp")&&(u.expires=1e3*s.exp),o(s,"iat")&&(u.created=1e3*s.iat),o(s,"scopes")&&(u.scopes=s.scopes),o(s,"client")&&(u.client=s.client),o(s,"ll")&&(u.lastLogin=s.ll),o(s,"iu")&&(u.impersonator=s.iu),a[e]=u,u}function r(e){try{return JSON.parse(s.decode(e))}catch(e){throw new Error("Invalid token")}}function o(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var s=e("base-64"),a={};t.exports=i},{"base-64":26}],26:[function(t,n,i){(function(t){(function(){"use strict";function r(e){"@babel/helpers - typeof";return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(o){var s="object"==(void 0===i?"undefined":r(i))&&i,a="object"==(void 0===n?"undefined":r(n))&&n&&n.exports==s&&n,u="object"==(void 0===t?"undefined":r(t))&&t;u.global!==u&&u.window!==u||(o=u);var c=function(e){this.message=e};c.prototype=new Error,c.prototype.name="InvalidCharacterError";var l=function(e){throw new c(e)},h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=/[\t\n\f\r ]/g,d=function(e){e=String(e).replace(p,"");var t=e.length;t%4==0&&(e=e.replace(/==?$/,""),t=e.length),(t%4==1||/[^+a-zA-Z0-9/]/.test(e))&&l("Invalid character: the string to be decoded is not correctly encoded.");for(var n,i,r=0,o="",s=-1;++s<t;)i=h.indexOf(e.charAt(s)),n=r%4?64*n+i:i,r++%4&&(o+=String.fromCharCode(255&n>>(-2*r&6)));return o},f=function(e){e=String(e),/[^\0-\xFF]/.test(e)&&l("The string to be encoded contains characters outside of the Latin1 range.");for(var t,n,i,r,o=e.length%3,s="",a=-1,u=e.length-o;++a<u;)t=e.charCodeAt(a)<<16,n=e.charCodeAt(++a)<<8,i=e.charCodeAt(++a),r=t+n+i,s+=h.charAt(r>>18&63)+h.charAt(r>>12&63)+h.charAt(r>>6&63)+h.charAt(63&r);return 2==o?(t=e.charCodeAt(a)<<8,n=e.charCodeAt(++a),r=t+n,s+=h.charAt(r>>10)+h.charAt(r>>4&63)+h.charAt(r<<2&63)+"="):1==o&&(r=e.charCodeAt(a),s+=h.charAt(r>>2)+h.charAt(r<<4&63)+"=="),s},g={encode:f,decode:d,version:"0.1.0"};if("function"==typeof e&&"object"==r(e.amd)&&e.amd)e(function(){return g});else if(s&&!s.nodeType)if(a)a.exports=g;else for(var y in g)g.hasOwnProperty(y)&&(s[y]=g[y]);else o.base64=g}(void 0)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],27:[function(e,t,n){"use strict";function i(e){"@babel/helpers - typeof";return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=x(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}function o(e){return void 0===e._maxListeners?r.defaultMaxListeners:e._maxListeners}function s(e,t,n){if(t)e.call(n);else for(var i=e.length,r=m(e,i),o=0;o<i;++o)r[o].call(n)}function a(e,t,n,i){if(t)e.call(n,i);else for(var r=e.length,o=m(e,r),s=0;s<r;++s)o[s].call(n,i)}function u(e,t,n,i,r){if(t)e.call(n,i,r);else for(var o=e.length,s=m(e,o),a=0;a<o;++a)s[a].call(n,i,r)}function c(e,t,n,i,r,o){if(t)e.call(n,i,r,o);else for(var s=e.length,a=m(e,s),u=0;u<s;++u)a[u].call(n,i,r,o)}function l(e,t,n,i){if(t)e.apply(n,i);else for(var r=e.length,o=m(e,r),s=0;s<r;++s)o[s].apply(n,i)}function h(e,t,n,r){var s,a,u;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if(a=e._events,a?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),u=a[t]):(a=e._events=x(null),e._eventsCount=0),u){if("function"==typeof u?u=a[t]=r?[n,u]:[u,n]:r?u.unshift(n):u.push(n),!u.warned&&(s=o(e))&&s>0&&u.length>s){u.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+u.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=u.length,"object"===("undefined"==typeof console?"undefined":i(console)