/* BEGIN geocoder.google-maps.js */
(function(n,t,i){"use strict";t.Modules.register({name:"Geolocation.GoogleMapsGeocoderAdapter",version:"1.0.0",description:"A singleton GeocoderAdapter instance that uses the Google Maps JavaScript geocoding API.",dependencies:["APIs.GoogleMaps","Geolocation.Geocoder"]},function(){function o(n,t){var r=Infinity,i=null;return n.forEach(function(n){var u=n.types.indexOf(t);u>-1&&u<r&&(r=u,i=n)}),i?new c.AddressComponent(i.short_name,i.long_name):null}function p(n,i,r){var b=[],g=0,y=0,k,d,l,h,e,p,a,w;if(r=f[r],r===u.NO_RESULTS||!(i instanceof Array)||i.length===0)return n.resolve(i,r);for(y=0,k=i.length;y<k;y++)l=i[y],h=l.address_components,a=o(h,"postal_code"),w=o(h,"postal_code_suffix"),e=new c,e.country=o(h,"country"),e.formatted=l.formatted_address,e.locality=o(h,"locality"),e.region=o(h,"administrative_area_level_1"),e.streetName=o(h,"route"),e.streetNumber=o(h,"street_number"),e.postalCode=a&&w?new c.AddressComponent(a.short,a.short+"-"+w.short):a,l.geometry&&l.geometry.location?p=new v(l.geometry.location):n instanceof s.GeocoderPointRequest&&(p=new v(n.point)),d=new t.Geolocation.Place(e,p),b[g++]=d;n.resolve(b,r)}function a(n){var t={},r;n.point&&(r=n.point);n instanceof s.GeocoderPointRequest?t.location=new google.maps.LatLng(r.latitude,r.longitude):t.address=n.address;y.geocode(t,p.bind(i,n))}var e=t.APIs.GoogleMaps,s=t.Geolocation,v=s.Point,c=t.Data.Address,u=s.GeocoderStatus,f={},r,h,l=[],y;r=new s.GeocoderAdapter;r.cacheKey="geocoder_gmaps";r.maxSimultaneousRequests=1;r.waitBetweenRequests=250;r.addressToPoint=function(n){var t;if(!e.isLoaded){t=this.options.apiKey;typeof t!="string"&&(t=null);l.push(n);e.load(t);return}a(n)};r.onOptionsChanged=function(n,t){"apiKey"in n&&!t.apiKey&&typeof n.apiKey=="string"&&!e.isLoaded&&e.load(n.apiKey)};r.pointToAddress=function(n){var t;if(!e.isLoaded){t=this.options.apiKey;typeof t!="string"&&(t=null);l.push(n);e.load(t);return}a(n)};e.onLoad(function(){var n=google.maps.GeocoderStatus;y=new google.maps.Geocoder;f[n.ERROR]=u.SERVICE_ERROR;f[n.INVALID_REQUEST]=u.INVALID_REQUEST;f[n.OK]=u.OK;f[n.OVER_QUERY_LIMIT]=u.OVER_LIMIT;f[n.REQUEST_DENIED]=u.SERVICE_ERROR;f[n.UNKNOWN_ERROR]=u.SERVICE_ERROR;f[n.ZERO_RESULTS]=u.NO_RESULTS;l.forEach(a)});return h=new s.Geocoder(r),Object.defineProperty(t.Geolocation,"GoogleMapsGeocoder",{enumerable:!0,value:h}),t.Intellisense.annotate(t.Geolocation,{GoogleMapsGeocoder:h}),n.g=h,r})})(window,Whereoware);
/* END   geocoder.google-maps.js */
