UNPKG

universal-geocoder

Version:

Universal geocoding abstraction server-side and client-side with multiple built-in providers

1 lines 116 kB
(()=>{var t={98:function(t,e){var o="undefined"!=typeof self?self:this,r=function(){function t(){this.fetch=!1,this.DOMException=o.DOMException}return t.prototype=o,new t}();!function(t){!function(e){var o="URLSearchParams"in t,r="Symbol"in t&&"iterator"in Symbol,n="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),i="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function u(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function p(t){return"string"!=typeof t&&(t=String(t)),t}function l(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function h(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function y(t){return new Promise((function(e,o){t.onload=function(){e(t.result)},t.onerror=function(){o(t.error)}}))}function f(t){var e=new FileReader,o=y(e);return e.readAsArrayBuffer(t),o}function g(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:n&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:i&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:o&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&n&&(e=t)&&DataView.prototype.isPrototypeOf(e)?(this._bodyArrayBuffer=g(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||c(t))?this._bodyArrayBuffer=g(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):o&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},n&&(this.blob=function(){var t=h(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(f)}),this.text=function(){var t,e,o,r=h(this);if(r)return r;if(this._bodyBlob)return t=this._bodyBlob,o=y(e=new FileReader),e.readAsText(t),o;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),o=new Array(e.length),r=0;r<e.length;r++)o[r]=String.fromCharCode(e[r]);return o.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(w)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(t,e){t=u(t),e=p(e);var o=this.map[t];this.map[t]=o?o+", "+e:e},d.prototype.delete=function(t){delete this.map[u(t)]},d.prototype.get=function(t){return t=u(t),this.has(t)?this.map[t]:null},d.prototype.has=function(t){return this.map.hasOwnProperty(u(t))},d.prototype.set=function(t,e){this.map[u(t)]=p(e)},d.prototype.forEach=function(t,e){for(var o in this.map)this.map.hasOwnProperty(o)&&t.call(e,this.map[o],o,this)},d.prototype.keys=function(){var t=[];return this.forEach((function(e,o){t.push(o)})),l(t)},d.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),l(t)},d.prototype.entries=function(){var t=[];return this.forEach((function(e,o){t.push([o,e])})),l(t)},r&&(d.prototype[Symbol.iterator]=d.prototype.entries);var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function v(t,e){var o,r,n=(e=e||{}).body;if(t instanceof v){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new d(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new d(e.headers)),this.method=(r=(o=e.method||this.method||"GET").toUpperCase(),b.indexOf(r)>-1?r:o),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function w(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var o=t.split("="),r=o.shift().replace(/\+/g," "),n=o.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(n))}})),e}function O(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},m.call(v.prototype),m.call(O.prototype),O.prototype.clone=function(){return new O(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},O.error=function(){var t=new O(null,{status:0,statusText:""});return t.type="error",t};var j=[301,302,303,307,308];O.redirect=function(t,e){if(-1===j.indexOf(e))throw new RangeError("Invalid status code");return new O(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var o=Error(t);this.stack=o.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function P(t,o){return new Promise((function(r,i){var s=new v(t,o);if(s.signal&&s.signal.aborted)return i(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function c(){a.abort()}a.onload=function(){var t,e,o={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new d,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var o=t.split(":"),r=o.shift().trim();if(r){var n=o.join(":").trim();e.append(r,n)}})),e)};o.url="responseURL"in a?a.responseURL:o.headers.get("X-Request-URL");var n="response"in a?a.response:a.responseText;r(new O(n,o))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.onabort=function(){i(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&n&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",c),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",c)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}P.polyfill=!0,t.fetch||(t.fetch=P,t.Headers=d,t.Request=v,t.Response=O),e.Headers=d,e.Request=v,e.Response=O,e.fetch=P,Object.defineProperty(e,"__esModule",{value:!0})}({})}(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var n=r;(e=n.fetch).default=n.fetch,e.fetch=n.fetch,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,t.exports=e},875:t=>{function e(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}e.keys=()=>[],e.resolve=e,e.id=875,t.exports=e}},e={};function o(r){var n=e[r];if(void 0!==n)return n.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,o),i.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";var t={useSsl:!1,useJsonp:!1},e=function(){return(e=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};const r=function(){function t(t){var e=t.text,o=t.ip,r=t.bounds,n=t.locale,i=t.limit,s=void 0===i?5:i;if(this.limit=5,this.text=e,this.ip=o,!e&&!o)throw new Error('Either "text" or "ip" parameter is required.');if(r&&(!r.latitudeSW||!r.longitudeSW||!r.latitudeNE||!r.longitudeNE))throw new Error('The "bounds" parameter must be an object with the keys: "latitudeSW", "longitudeSW", "latitudeNE", "longitudeNE".');this.bounds=r,this.locale=n,this.limit=s}return t.create=function(t){return new this(t)},t.prototype.toObject=function(){return{text:this.text,ip:this.ip,bounds:this.bounds,locale:this.locale,limit:this.limit}},t.prototype.withText=function(t){return this.constructor.create(e(e({},this.toObject()),{text:t}))},t.prototype.withIp=function(t){return this.constructor.create(e(e({},this.toObject()),{ip:t}))},t.prototype.withBounds=function(t){return this.constructor.create(e(e({},this.toObject()),{bounds:t}))},t.prototype.withLocale=function(t){return this.constructor.create(e(e({},this.toObject()),{locale:t}))},t.prototype.withLimit=function(t){return this.constructor.create(e(e({},this.toObject()),{limit:t}))},t.prototype.getText=function(){return this.text},t.prototype.getIp=function(){return this.ip},t.prototype.getBounds=function(){return this.bounds},t.prototype.getLocale=function(){return this.locale},t.prototype.getLimit=function(){return this.limit},t}();var n=function(){return(n=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};const i=function(){function t(t){var e=t.coordinates,o=t.locale,r=t.limit,n=void 0===r?5:r;if(this.limit=5,e&&(!e.latitude||!e.longitude))throw new Error('The "coordinates" parameter must be an object with the keys: "latitude", "longitude".');this.coordinates=e,this.locale=o,this.limit=n}return t.create=function(t){return new this(t)},t.prototype.toObject=function(){return{coordinates:this.coordinates,locale:this.locale,limit:this.limit}},t.prototype.withCoordinates=function(t){return this.constructor.create(n(n({},this.toObject()),{coordinates:t}))},t.prototype.withLocale=function(t){return this.constructor.create(n(n({},this.toObject()),{locale:t}))},t.prototype.withLimit=function(t){return this.constructor.create(n(n({},this.toObject()),{limit:t}))},t.prototype.getCoordinates=function(){return this.coordinates},t.prototype.getLocale=function(){return this.locale},t.prototype.getLimit=function(){return this.limit},t}();var s=function(){return"undefined"!=typeof window},a=function(t){return Object.keys(t).reduce((function(e,o){var r=e,n=t[o];return void 0!==n&&(r[o]=n),r}),{})};const c=function(){function t(){}return t.getGeocodeQueryFromParameter=function(t,e){return void 0===e&&(e=r),"string"==typeof t?(o=t,new RegExp("^(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}$").test(o)||function(t){return new RegExp("^((?:[a-fA-F\\d]{1,4}:){7}(?:[a-fA-F\\d]{1,4}|:)|(?:[a-fA-F\\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|:[a-fA-F\\d]{1,4}|:)|(?:[a-fA-F\\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(:[a-fA-F\\d]{1,4}){1,2}|:)|(?:[a-fA-F\\d]{1,4}:){4}(?:(:[a-fA-F\\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(:[a-fA-F\\d]{1,4}){1,3}|:)|(?:[a-fA-F\\d]{1,4}:){3}(?:(:[a-fA-F\\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(:[a-fA-F\\d]{1,4}){1,4}|:)|(?:[a-fA-F\\d]{1,4}:){2}(?:(:[a-fA-F\\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(:[a-fA-F\\d]{1,4}){1,5}|:)|(?:[a-fA-F\\d]{1,4}:){1}(?:(:[a-fA-F\\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(:[a-fA-F\\d]{1,4}){1,6}|:)|(?::((?::[a-fA-F\\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,7}|:)))(%[0-9a-zA-Z]{1,})?$").test(t)}(t)?e.create({ip:t}):e.create({text:t})):t instanceof e?t:e.create(t);var o},t.getReverseQueryFromParameters=function(t,e,o){if(void 0===o&&(o=i),"number"==typeof t||"string"==typeof t){if("number"!=typeof e&&"string"!=typeof e)throw new Error("The second parameter of geodecode must be a longitude if the first one is a latitude");return o.create({coordinates:{latitude:t,longitude:e}})}return t instanceof o?t:o.create(t)},t.getCallbackFromParameters=function(t,e){return"number"!=typeof t&&"string"!=typeof t?t:e||void 0},t.getErrorCallbackFromParameters=function(t,e,o){return o||("number"!=typeof t&&"string"!=typeof t?e:void 0)},t}();var u=function(){return(u=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};const p=function(){function t(t){var e=t.coordinates,o=t.bounds,r=t.formattedAddress,n=t.streetNumber,i=t.streetName,s=t.subLocality,a=t.locality,c=t.postalCode,u=t.region,p=t.adminLevels,l=t.country,d=t.countryCode,h=t.timezone;this.coordinates=e,this.bounds=o,this.formattedAddress=r,this.streetNumber=n,this.streetName=i,this.subLocality=s,this.locality=a,this.postalCode=c,this.region=u,this.adminLevels=p||[],this.country=l,this.countryCode=d,this.timezone=h}return t.create=function(t){return new this(t)},t.prototype.toObject=function(){return{coordinates:this.coordinates,bounds:this.bounds,formattedAddress:this.formattedAddress,streetNumber:this.streetNumber,streetName:this.streetName,subLocality:this.subLocality,locality:this.locality,postalCode:this.postalCode,region:this.region,adminLevels:this.adminLevels,country:this.country,countryCode:this.countryCode,timezone:this.timezone}},t.prototype.withBounds=function(t){return this.constructor.create(u(u({},this.toObject()),{bounds:t}))},t.prototype.withCoordinates=function(t){return this.constructor.create(u(u({},this.toObject()),{coordinates:t}))},t.prototype.getCoordinates=function(){return this.coordinates},t.prototype.getBounds=function(){return this.bounds},t.prototype.getFormattedAddress=function(){return this.formattedAddress},t.prototype.getStreetNumber=function(){return this.streetNumber},t.prototype.getStreetName=function(){return this.streetName},t.prototype.getSubLocality=function(){return this.subLocality},t.prototype.getLocality=function(){return this.locality},t.prototype.getPostalCode=function(){return this.postalCode},t.prototype.getRegion=function(){return this.region},t.prototype.addAdminLevel=function(t){this.adminLevels.push(t)},t.prototype.getAdminLevels=function(){return this.adminLevels},t.prototype.getCountry=function(){return this.country},t.prototype.getCountryCode=function(){return this.countryCode},t.prototype.getTimezone=function(){return this.timezone},t}();var l,d=(l=function(t,e){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}l(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}),h=function(){return(h=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};const y=function(t){function e(e){var o=e.attribution,r=e.precision,n=function(t,e){var o={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(o[r[n]]=t[r[n]])}return o}(e,["attribution","precision"]),i=t.call(this,n)||this;return i.attribution=o,i.precision=r,i}return d(e,t),e.create=function(t){return new this(t)},e.prototype.toObject=function(){return h(h({},t.prototype.toObject.call(this)),{attribution:this.attribution,precision:this.precision})},e.prototype.withAttribution=function(t){return new e(h(h({},this.toObject()),{attribution:t}))},e.prototype.getAttribution=function(){return this.attribution},e.prototype.withPrecision=function(t){return new e(h(h({},this.toObject()),{precision:t}))},e.prototype.getPrecision=function(){return this.precision},e}(p);var f;!function(t){t[t.STATE_CODE=1]="STATE_CODE",t[t.COUNTY_CODE=2]="COUNTY_CODE"}(f||(f={}));const g=function(){function t(t){var e=t.level,o=t.name,r=t.code;this.level=e,this.name=o,this.code=r}return t.create=function(t){return new this(t)},t.prototype.toObject=function(){return{level:this.level,name:this.name,code:this.code}},t.prototype.getLevel=function(){return this.level},t.prototype.getName=function(){return this.name},t.prototype.getCode=function(){return this.code},t}();var m=function(){var t=function(e,o){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(e,o)};return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function r(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}}();const b=function(t){function e(o,r){var n=t.call(this,o)||this;return n.name="ResponseError",n.response=r,n.__proto__=e.prototype,n}return m(e,t),e.prototype.getResponse=function(){return this.response},e}(Error);var v=function(){return(v=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)},w=v(v({},t),{apiKey:""});const O=function(){function t(t,e){if(void 0===e&&(e=w),this.externalLoader=t,this.options=v(v({},w),e),!this.options.apiKey)throw new Error('An API key is required for the Bing provider. Please add it in the "apiKey" option.')}return t.prototype.geocode=function(t,e,o){var r=this,n=c.getGeocodeQueryFromParameter(t);if(n.getIp())throw new Error("The Bing provider does not support IP geolocation, only location geocoding.");this.externalLoader.setOptions({protocol:this.options.useSsl?"https":"http",host:"dev.virtualearth.net",pathname:"REST/v1/Locations/"+n.getText()});var i=this.withCommonParams({maxRes:n.getLimit()?n.getLimit().toString():void 0},n);return e?this.executeRequest(i,e,{},{},o):new Promise((function(t,e){return r.executeRequest(i,(function(e){return t(e)}),{},{},(function(t){return e(t)}))}))},t.prototype.geodecode=function(t,e,o,r){var n=this,i=c.getReverseQueryFromParameters(t,e),s=c.getCallbackFromParameters(e,o),a=c.getErrorCallbackFromParameters(e,o,r);this.externalLoader.setOptions({protocol:this.options.useSsl?"https":"http",host:"dev.virtualearth.net",pathname:"REST/v1/Locations/"+i.getCoordinates().latitude+","+i.getCoordinates().longitude});var u=this.withCommonParams({},i);return s?this.executeRequest(u,s,{},{},a):new Promise((function(t,e){return n.executeRequest(u,(function(e){return t(e)}),{},{},(function(t){return e(t)}))}))},t.prototype.withCommonParams=function(t,e){return v(v({},t),{key:this.options.apiKey,incl:"ciso2",c:e.getLocale(),jsonpCallback:this.options.useJsonp?"jsonp":void 0})},t.prototype.executeRequest=function(e,o,r,n,i){this.externalLoader.executeRequest(e,(function(e){o(e.resourceSets[0].resources.map((function(o){return t.mapToGeocoded(o,e.copyright)})))}),r,n,(function(t){t.getResponse().json().then((function(t){var e=t.errorDetails&&t.errorDetails.length>0?t.errorDetails[0]:t.statusDescription||"";i?i(new b(e,t)):setTimeout((function(){throw new Error(e)}))}))}))},t.mapToGeocoded=function(t,e){var o=t.point.coordinates[0],r=t.point.coordinates[1],n=t.address.formattedAddress,i=t.address.addressLine,s=t.address,a=s.locality,c=s.postalCode,u=t.address.adminDistrict,p=t.address.countryRegion,l=t.address.countryRegionIso2,d=t.confidence,h=y.create({coordinates:{latitude:o,longitude:r},formattedAddress:n,streetName:i,locality:a,postalCode:c,region:u,country:p,countryCode:l,attribution:e,precision:d});return h=h.withBounds({latitudeSW:t.bbox[0],longitudeSW:t.bbox[1],latitudeNE:t.bbox[2],longitudeNE:t.bbox[3]}),["adminDistrict","adminDistrict2"].forEach((function(e,o){t.address[e]&&h.addAdminLevel(g.create({level:o+1,name:t.address[e]||""}))})),h},t}();var j=function(){return(j=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)},P=j(j({},t),{providers:[]});const _=function(){function t(t){void 0===t&&(t=P),this.options=t}return t.prototype.geocode=function(t,e,o){var r=this;return this.options.parallelize||this.options.first?e?this.geocodeAllProviders(t,e,o):new Promise((function(e,o){return r.geocodeAllProviders(t,(function(t){return e(t)}),(function(t){return o(t)}))})):e?this.geocodeNextProvider(this.options.providers,t,e,o):new Promise((function(e,o){return r.geocodeNextProvider(r.options.providers,t,(function(t){return e(t)}),(function(t){return o(t)}))}))},t.prototype.geodecode=function(t,e,o,r){var n=this,i=c.getReverseQueryFromParameters(t,e),s=c.getCallbackFromParameters(e,o),a=c.getErrorCallbackFromParameters(e,o,r);return this.options.parallelize||this.options.first?s?this.geodecodeAllProviders(i,s,a):new Promise((function(t,e){return n.geodecodeAllProviders(i,(function(e){return t(e)}),(function(t){return e(t)}))})):s?this.geodecodeNextProvider(this.options.providers,i,s,a):new Promise((function(t,e){return n.geodecodeNextProvider(n.options.providers,i,(function(e){return t(e)}),(function(t){return e(t)}))}))},t.prototype.geocodeNextProvider=function(t,e,o,r){var n=this,i=t[0],s=t.slice(1),a=function(t){t.length>0?o(t):n.geocodeNextProvider(s,e,o,r)};i.geocode(e,a,(function(t){r&&r(t),r||console.error("An error has occurred when geocoding with the provider "+i.constructor.name,t),a([])}))},t.prototype.geodecodeNextProvider=function(t,e,o,r){var n=this,i=t[0],s=t.slice(1),a=function(t){t.length>0?o(t):n.geodecodeNextProvider(s,e,o,r)};i.geodecode(e,a,(function(t){r&&r(t),r||console.error("An error has occurred when geodecoding with the provider "+i.constructor.name,t),a([])}))},t.prototype.geocodeAllProviders=function(t,e,o){var r=this,n=new Map,i=!1,s=function(t){return function(o){n.set(t,o);var s=r.options.providers.reduce((function(t,e){var o=t;if(void 0===o&&r.options.first&&(o=[]),void 0!==o)return o.length>0?o:n.get(e.constructor.name)}),[]);!i&&s&&(e(s),i=!0)}};this.options.providers.forEach((function(e){var r=e.constructor.name;e.geocode(t,s(r),function(t){return function(e){o&&o(e),o||console.error("An error has occurred when geocoding with the provider "+t,e),s(t)([])}}(r))}))},t.prototype.geodecodeAllProviders=function(t,e,o){var r=this,n=new Map,i=!1,s=function(t){return function(o){n.set(t,o);var s=r.options.providers.reduce((function(t,e){var o=t;if(void 0===o&&r.options.first&&(o=[]),void 0!==o)return o.length>0?o:n.get(e.constructor.name)}),[]);!i&&s&&(e(s),i=!0)}};this.options.providers.forEach((function(e){var r=e.constructor.name;e.geodecode(t,s(r),function(t){return function(e){o&&o(e),o||console.error("An error has occurred when geodecoding with the provider "+t,e),s(t)([])}}(r))}))},t.prototype.executeRequest=function(t,e,o,r,n){throw new Error("executeRequest cannot be called directly from the chain provider.")},t}();var x=function(){var t=function(e,o){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(e,o)};return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function r(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}}(),C=function(){return(C=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};const E=function(t){function e(e){var o=e.attribution,r=function(t,e){var o={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(o[r[n]]=t[r[n]])}return o}(e,["attribution"]),n=t.call(this,r)||this;return n.attribution=o,n}return x(e,t),e.create=function(t){return new this(t)},e.prototype.toObject=function(){return C(C({},t.prototype.toObject.call(this)),{attribution:this.attribution})},e.prototype.withAttribution=function(t){return new e(C(C({},this.toObject()),{attribution:t}))},e.prototype.getAttribution=function(){return this.attribution},e}(p);var S=function(){return(S=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};const T=function(){function e(e,o){void 0===o&&(o=t),this.externalLoader=e,this.options=S(S({},t),o)}return e.prototype.geocode=function(t,e,o){var r=this,n=c.getGeocodeQueryFromParameter(t);if(n.getText())throw new Error("The GeoPlugin provider does not support location geocoding, only IP geolocation.");if(["127.0.0.1","::1"].includes(n.getIp()||"")){var i=E.create({locality:"localhost",country:"localhost"});return e?e([i]):new Promise((function(t){return t([i])}))}this.externalLoader.setOptions({protocol:this.options.useSsl?"https":"http",host:"www.geoplugin.net",pathname:"json.gp"});var s={ip:n.getIp()||""};return e?this.executeRequest(s,e,{},{},o):new Promise((function(t,e){return r.executeRequest(s,(function(e){return t(e)}),{},{},(function(t){return e(t)}))}))},e.prototype.geodecode=function(t,e,o,r){throw new Error("The GeoPlugin provider does not support reverse geocoding.")},e.prototype.executeRequest=function(t,o,r,n,i){this.externalLoader.executeRequest(t,(function(t){if(![200,206].includes(t.geoplugin_status)){var r="An error has occurred. Status: "+t.geoplugin_status+".";return i?void i(new b(r,t)):void setTimeout((function(){throw new Error(r)}))}o([e.mapToGeocoded(t)])}),r,n,i)},e.mapToGeocoded=function(t){var e=parseFloat(t.geoplugin_latitude),o=parseFloat(t.geoplugin_longitude),r=t.geoplugin_city||void 0,n=t.geoplugin_region||void 0,i=t.geoplugin_countryName||void 0,s=t.geoplugin_countryCode||void 0,a=t.geoplugin_timezone||void 0,c=[],u=t.geoplugin_credit||void 0;return t.geoplugin_regionName&&c.push(g.create({level:f.STATE_CODE,name:t.geoplugin_regionName,code:t.geoplugin_regionCode||void 0})),E.create({coordinates:{latitude:e,longitude:o},locality:r,region:n,adminLevels:c,country:i,countryCode:s,timezone:a,attribution:u})},e}();var A=function(){var t=function(e,o){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(e,o)};return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function r(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}}(),L=function(){return(L=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};const I=function(t){function e(e){var o=e.countryCodes,r=e.components,n=e.channel,i=function(t,e){var o={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(o[r[n]]=t[r[n]])}return o}(e,["countryCodes","components","channel"]),s=t.call(this,i)||this;if(o&&1!==o.length)throw new Error('The "countryCodes" parameter must have only one country code top-level domain.');return s.countryCodes=o,s.components=r,s.channel=n,s}return A(e,t),e.create=function(t){return new this(t)},e.prototype.toObject=function(){return L(L({},t.prototype.toObject.call(this)),{countryCodes:this.countryCodes,components:this.components,channel:this.channel})},e.prototype.withCountryCodes=function(t){return new e(L(L({},this.toObject()),{countryCodes:t}))},e.prototype.getCountryCodes=function(){return this.countryCodes},e.prototype.withComponents=function(t){return new e(L(L({},this.toObject()),{components:t}))},e.prototype.getComponents=function(){return this.components},e.prototype.withChannel=function(t){return new e(L(L({},this.toObject()),{channel:t}))},e.prototype.getChannel=function(){return this.channel},e}(r);var R=function(){var t=function(e,o){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(e,o)};return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function r(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}}(),k=function(){return(k=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};const N=function(t){function e(e){var o=e.types,r=e.precisions,n=e.channel,i=function(t,e){var o={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(o[r[n]]=t[r[n]])}return o}(e,["types","precisions","channel"]),s=t.call(this,i)||this;return s.types=o,s.precisions=r,s.channel=n,s}return R(e,t),e.create=function(t){return new this(t)},e.prototype.toObject=function(){return k(k({},t.prototype.toObject.call(this)),{types:this.types,precisions:this.precisions,channel:this.channel})},e.prototype.withTypes=function(t){return new e(k(k({},this.toObject()),{types:t}))},e.prototype.getTypes=function(){return this.types},e.prototype.withPrecisions=function(t){return new e(k(k({},this.toObject()),{precisions:t}))},e.prototype.getPrecisions=function(){return this.precisions},e.prototype.withChannel=function(t){return new e(k(k({},this.toObject()),{channel:t}))},e.prototype.getChannel=function(){return this.channel},e}(i);var q=function(){var t=function(e,o){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(e,o)};return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function r(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}}(),F=function(){return(F=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};const B=function(t){function e(e){var o=e.placeId,r=e.partialMatch,n=e.types,i=e.precision,s=e.streetAddress,a=e.intersection,c=e.political,u=e.colloquialArea,p=e.ward,l=e.neighborhood,d=e.premise,h=e.subpremise,y=e.naturalFeature,f=e.airport,g=e.park,m=e.pointOfInterest,b=e.establishment,v=e.postalCodeSuffix,w=e.subLocalityLevels,O=function(t,e){var o={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(o[r[n]]=t[r[n]])}return o}(e,["placeId","partialMatch","types","precision","streetAddress","intersection","political","colloquialArea","ward","neighborhood","premise","subpremise","naturalFeature","airport","park","pointOfInterest","establishment","postalCodeSuffix","subLocalityLevels"]),j=t.call(this,O)||this;return j.placeId=o,j.partialMatch=r,j.types=n,j.precision=i,j.streetAddress=s,j.intersection=a,j.political=c,j.colloquialArea=u,j.ward=p,j.neighborhood=l,j.premise=d,j.subpremise=h,j.naturalFeature=y,j.airport=f,j.park=g,j.pointOfInterest=m,j.establishment=b,j.postalCodeSuffix=v,j.subLocalityLevels=w||[],j}return q(e,t),e.create=function(t){return new this(t)},e.prototype.toObject=function(){return F(F({},t.prototype.toObject.call(this)),{placeId:this.placeId,partialMatch:this.partialMatch,types:this.types,precision:this.precision,streetAddress:this.streetAddress,intersection:this.intersection,political:this.political,colloquialArea:this.colloquialArea,ward:this.ward,neighborhood:this.neighborhood,premise:this.premise,subpremise:this.subpremise,naturalFeature:this.naturalFeature,airport:this.airport,park:this.park,pointOfInterest:this.pointOfInterest,establishment:this.establishment,postalCodeSuffix:this.postalCodeSuffix,subLocalityLevels:this.subLocalityLevels})},e.prototype.withPlaceId=function(t){return new e(F(F({},this.toObject()),{placeId:t}))},e.prototype.getPlaceId=function(){return this.placeId},e.prototype.withPartialMatch=function(t){return new e(F(F({},this.toObject()),{partialMatch:t}))},e.prototype.isPartialMatch=function(){return this.partialMatch},e.prototype.withTypes=function(t){return new e(F(F({},this.toObject()),{types:t}))},e.prototype.getTypes=function(){return this.types},e.prototype.withPrecision=function(t){return new e(F(F({},this.toObject()),{precision:t}))},e.prototype.getPrecision=function(){return this.precision},e.prototype.withStreetAddress=function(t){return new e(F(F({},this.toObject()),{streetAddress:t}))},e.prototype.getStreetAddress=function(){return this.streetAddress},e.prototype.withIntersection=function(t){return new e(F(F({},this.toObject()),{intersection:t}))},e.prototype.getIntersection=function(){return this.intersection},e.prototype.withPolitical=function(t){return new e(F(F({},this.toObject()),{political:t}))},e.prototype.getPolitical=function(){return this.political},e.prototype.withColloquialArea=function(t){return new e(F(F({},this.toObject()),{colloquialArea:t}))},e.prototype.getColloquialArea=function(){return this.colloquialArea},e.prototype.withWard=function(t){return new e(F(F({},this.toObject()),{ward:t}))},e.prototype.getWard=function(){return this.ward},e.prototype.withNeighborhood=function(t){return new e(F(F({},this.toObject()),{neighborhood:t}))},e.prototype.getNeighborhood=function(){return this.neighborhood},e.prototype.withPremise=function(t){return new e(F(F({},this.toObject()),{premise:t}))},e.prototype.getPremise=function(){return this.premise},e.prototype.withSubpremise=function(t){return new e(F(F({},this.toObject()),{subpremise:t}))},e.prototype.getSubpremise=function(){return this.subpremise},e.prototype.withNaturalFeature=function(t){return new e(F(F({},this.toObject()),{naturalFeature:t}))},e.prototype.getNaturalFeature=function(){return this.naturalFeature},e.prototype.withAirport=function(t){return new e(F(F({},this.toObject()),{airport:t}))},e.prototype.getAirport=function(){return this.airport},e.prototype.withPark=function(t){return new e(F(F({},this.toObject()),{park:t}))},e.prototype.getPark=function(){return this.park},e.prototype.withPointOfInterest=function(t){return new e(F(F({},this.toObject()),{pointOfInterest:t}))},e.prototype.getPointOfInterest=function(){return this.pointOfInterest},e.prototype.withEstablishment=function(t){return new e(F(F({},this.toObject()),{establishment:t}))},e.prototype.getEstablishment=function(){return this.establishment},e.prototype.withPostalCodeSuffix=function(t){return new e(F(F({},this.toObject()),{postalCodeSuffix:t}))},e.prototype.getPostalCodeSuffix=function(){return this.postalCodeSuffix},e.prototype.addSubLocalityLevel=function(t){this.subLocalityLevels.push(t)},e.prototype.getSubLocalityLevels=function(){return this.subLocalityLevels},e}(p);var M=function(){return(M=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};const D=function(){function e(e,o){if(void 0===o&&(o=t),this.externalLoader=e,this.options=M(M({},t),o),!this.options.apiKey&&!this.options.clientId)throw new Error('An API key or a client ID is required for the Google Maps provider. Please add it in the "apiKey" or the "clientId" option.');if(this.options.clientId&&!this.options.secret)throw new Error('An URL signing secret is required if you use a client ID (Premium only). Please add it in the "secret" option.');if(this.options.secret&&s())throw new Error('The "secret" option cannot be used in a browser environment.');if(this.options.countryCodes&&1!==this.options.countryCodes.length)throw new Error('The "countryCodes" option must have only one country code top-level domain.')}return e.prototype.geocode=function(t,e,o){var r,n,i,s,a,u,p,l=this,d=c.getGeocodeQueryFromParameter(t,I);if(d.getIp())throw new Error("The GoogleMaps provider does not support IP geolocation, only location geocoding.");this.externalLoader.setOptions({protocol:this.options.useSsl?"https":"http",host:"maps.googleapis.com",pathname:"maps/api/geocode/json"});var h=this.withCommonParams({address:d.getText(),bounds:d.getBounds()?(null===(r=d.getBounds())||void 0===r?void 0:r.latitudeSW)+","+(null===(n=d.getBounds())||void 0===n?void 0:n.longitudeSW)+"|"+(null===(i=d.getBounds())||void 0===i?void 0:i.latitudeNE)+","+(null===(s=d.getBounds())||void 0===s?void 0:s.longitudeNE):void 0,components:d.getComponents()?null===(a=d.getComponents())||void 0===a?void 0:a.map((function(t){return t.name+":"+t.value})).join("|"):void 0,region:d.getCountryCodes()?null===(u=d.getCountryCodes())||void 0===u?void 0:u.join(","):null===(p=this.options.countryCodes)||void 0===p?void 0:p.join(",")},d);return e?this.executeRequest(h,e,{},{},o):new Promise((function(t,e){return l.executeRequest(h,(function(e){return t(e)}),{},{},(function(t){return e(t)}))}))},e.prototype.geodecode=function(t,e,o,r){var n,i,s=this,a=c.getReverseQueryFromParameters(t,e,N),u=c.getCallbackFromParameters(e,o),p=c.getErrorCallbackFromParameters(e,o,r);this.externalLoader.setOptions({protocol:this.options.useSsl?"https":"http",host:"maps.googleapis.com",pathname:"maps/api/geocode/json"});var l=this.withCommonParams({latlng:a.getCoordinates().latitude+","+a.getCoordinates().longitude,result_type:a.getTypes()?null===(n=a.getTypes())||void 0===n?void 0:n.join("|"):void 0,location_type:a.getPrecisions()?null===(i=a.getPrecisions())||void 0===i?void 0:i.join("|"):void 0},a);return u?this.executeRequest(l,u,{},{},p):new Promise((function(t,e){return s.executeRequest(l,(function(e){return t(e)}),{},{},(function(t){return e(t)}))}))},e.prototype.withCommonParams=function(t,o){var r=M(M({},t),{key:this.options.apiKey,client:this.options.clientId,channel:o.getChannel(),language:o.getLocale(),limit:o.getLimit().toString()});return this.options.secret&&(r=M(M({},r),{signature:e.signQuery(this.options.secret,this.externalLoader.getOptions().pathname||"",r)})),r},e.prototype.executeRequest=function(t,o,r,n,i){var s=t.limit,a=function(t,e){var o={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(o[r[n]]=t[r[n]])}return o}(t,["limit"]);this.externalLoader.executeRequest(a,(function(t){var r;switch(t.status){case"REQUEST_DENIED":r="Request has been denied",t.error_message&&(r+=": "+t.error_message);break;case"OVER_QUERY_LIMIT":r="Exceeded daily quota when attempting geocoding request",t.error_message&&(r+=": "+t.error_message);break;case"OVER_DAILY_LIMIT":r="API usage has been limited",t.error_message&&(r+=": "+t.error_message);break;case"INVALID_REQUEST":r="The request is invalid",t.error_message&&(r+=": "+t.error_message);break;case"UNKNOWN_ERROR":r="Unknown error",t.error_message&&(r+=": "+t.error_message)}if(r&&i)i(new b(r,t));else if(r)setTimeout((function(){throw new Error(r)}));else{var n=t.results,a=n.length-parseInt(s||n.length.toString(),10);a>0&&n.splice(-a),o(n.map((function(t){return e.mapToGeocoded(t)})))}}),r,n,i)},e.mapToGeocoded=function(t){var e,o,r,n,i,s,a,c,u,p,l,d,h,y,f,m,b,v,w,O,j,P,_=t.geometry.location.lat,x=t.geometry.location.lng,C=t.formatted_address,E=[],S=t.place_id,T=t.partial_match,A=t.types,L=t.geometry.location_type,I=[];t.address_components.forEach((function(t){t.types.forEach((function(_){switch(_){case"street_number":e=t.long_name;break;case"route":o=t.long_name;break;case"sublocality":r=t.long_name;break;case"locality":case"postal_town":n=t.long_name;break;case"postal_code":i=t.long_name;break;case"administrative_area_level_1":case"administrative_area_level_2":case"administrative_area_level_3":case"administrative_area_level_4":case"administrative_area_level_5":"administrative_area_level_1"===_&&(s=t.long_name),E.push(g.create({level:parseInt(_.substr(-1),10),name:t.long_name,code:t.short_name}));break;case"sublocality_level_1":case"sublocality_level_2":case"sublocality_level_3":case"sublocality_level_4":case"sublocality_level_5":I.push(g.create({level:parseInt(_.substr(-1),10),name:t.long_name,code:t.short_name}));break;case"country":a=t.long_name,c=t.short_name;break;case"street_address":u=t.long_name;break;case"intersection":p=t.long_name;break;case"political":l=t.long_name;break;case"colloquial_area":d=t.long_name;break;case"ward":h=t.long_name;break;case"neighborhood":y=t.long_name;break;case"premise":f=t.long_name;break;case"subpremise":m=t.long_name;break;case"natural_feature":b=t.long_name;break;case"airport":v=t.long_name;break;case"park":w=t.long_name;break;case"point_of_interest":O=t.long_name;break;case"establishment":j=t.long_name;break;case"postal_code_suffix":P=t.long_name}}))}));var R=B.create({coordinates:{latitude:_,longitude:x},formattedAddress:C,streetNumber:e,streetName:o,subLocality:r,locality:n,postalCode:i,region:s,country:a,countryCode:c,adminLevels:E,placeId:S,partialMatch:T,types:A,precision:L,streetAddress:u,intersection:p,political:l,colloquialArea:d,ward:h,neighborhood:y,premise:f,subpremise:m,naturalFeature:b,airport:v,park:w,pointOfInterest:O,establishment:j,postalCodeSuffix:P,subLocalityLevels:I});if(t.geometry.bounds){var k=t.geometry.bounds;R=R.withBounds({latitudeSW:k.southwest.lat,longitudeSW:k.southwest.lng,latitudeNE:k.northeast.lat,longitudeNE:k.northeast.lng})}else if(t.geometry.viewport){var N=t.geometry.viewport;R=R.withBounds({latitudeSW:N.southwest.lat,longitudeSW:N.southwest.lng,latitudeNE:N.northeast.lat,longitudeNE:N.northeast.lng})}else"ROOFTOP"===L&&(R=R.withBounds({latitudeSW:_,longitudeSW:x,latitudeNE:_,longitudeNE:x}));return R},e.signQuery=function(t,e,r){var n=("function"==typeof require?require:o(875))("crypto"),i=a(r),c=function(t){if(s())throw new Error("decodeBase64 can only be used in a Node environment.");return Buffer.from(t,"base64").toString()}(t.replace(/-/g,"+").replace(/_/g,"/")),u=e+"?"+new URLSearchParams(i).toString();return n.createHmac("sha1",c).update(u).digest("base64").replace(/\+/g,"-").replace(/\//g,"_")},e}();var U=function(){var t=function(e,o){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(e,o)};return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function r(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}}(),z=function(){return(z=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};const G=function(t){function e(e){var o=e.countryCodes,r=e.excludePlaceIds,n=e.bounded,i=e.bounds,s=e.dedupe,a=function(t,e){var o={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(o[r[n]]=t[r[n]])}return o}(e,["countryCodes","excludePlaceIds","bounded","bounds","dedupe"]),c=t.call(this,z({bounds:i},a))||this;if(c.countryCodes=o,c.excludePlaceIds=r,n&&!i)throw new Error('The "bounded" parameter can only be used with the "bounds" parameter.');return c.bounded=n,c.dedupe=s,c}return U(e,t),e.create=function(t){return new this(t)},e.prototype.toObject=function(){return z(z({},t.prototype.toObject.call(this)),{countryCodes:this.countryCodes,excludePlaceIds:this.excludePlaceIds,bounded:this.bounded,dedupe:this.dedupe})},e.prototype.withCountryCodes=function(t){return new e(z(z({},this.toObject()),{countryCodes:t}))},e.prototype.getCountryCodes=function(){return this.countryCodes},e.prototype.withExcludePlaceIds=function(t){return new e(z(z({},this.toObject()),{excludePlaceIds:t}))},e.prototype.getExcludePlaceIds=function(){return this.excludePlaceIds},e.prototype.withBounded=function(t){return new e(z(z({},this.toObject()),{bounded:t}))},e.prototype.getBounded=function(){return this.bounded},e.prototype.withDedupe=function(t){return new e(z(z({},this.toObject()),{dedupe:t}))},e.prototype.getDedupe=function(){return this.dedupe},e}(r);var W=function(){var t=function(e,o){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(e,o)};return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function r(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}}(),K=function(){return(K=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};const Q=function(t){function e(e){var o=e.zoom,r=function(t,e){var o={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(o[r[n]]=t[r[n]])}return o}(e,["zoom"]),n=t.call(this,r)||this;return n.zoom=o,n}return W(e,t),e.create=function(t){return new this(t)},e.prototype.toObject=function(){return K(K({},t.prototype.toObject.call(this)),{zoom:this.zoom})},e.prototype.withZoom=function(t){return new e(K(K({},this.toObject()),{zoom:t}))},e.prototype.getZoom=function(){return this.zoom},e}(i);var H=function(){var t=function(e,o){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(e,o)};return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function r(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}}(),J=function(){return(J=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};const Y=function(t){function e(e){var o=e.placeId,r=e.displayName,n=e.osmId,i=e.osmType,s=e.categories,a=e.types,c=e.distance,u=e.precision,p=e.precisionCode,l=e.precisionType,d=e.attribution,h=e.subLocalityLevels,y=function(t,e){var o={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(o[r[n]]=t[r[n]])}return o}(e,["placeId","displayName","osmId","osmType","categories","types","distance","precision","precisionCode","precisionType","attribution","subLocalityLevels