!function(e,t){"function"==typeof define&&define.amd?define(["b"],function(r){return e.returnExportsGlobal=t()}):"object"==typeof module&&module.exports?module.exports=t(require("b")):e.OpenLocationCode=t()}(this,function(){var e={};e.CODE_PRECISION_NORMAL=10,e.CODE_PRECISION_EXTRA=11;var t="23456789CFGHJMPQRVWX",r=t.length,n=[20,1,.05,.0025,125e-6],o=(e.getAlphabet=function(){return t},e.isValid=function(e){if(!e||"string"!=typeof e)return!1;if(-1==e.indexOf("+"))return!1;if(e.indexOf("+")!=e.lastIndexOf("+"))return!1;if(1==e.length)return!1;if(e.indexOf("+")>8||e.indexOf("+")%2==1)return!1;if(e.indexOf("0")>-1){if(0==e.indexOf("0"))return!1;var r=e.match(new RegExp("(0+)","g"));if(r.length>1||r[0].length%2==1||r[0].length>6)return!1;if("+"!=e.charAt(e.length-1))return!1}if(e.length-e.indexOf("+")-1==1)return!1;for(var n=0,o=(e=e.replace(new RegExp("\\++"),"").replace(new RegExp("0+"),"")).length;n=0&&e.indexOf("+")<8)},a=e.isFull=function(e){return!!o(e)&&(!i(e)&&(!(t.indexOf(e.charAt(0).toUpperCase())*r>=180)&&!(e.length>1&&t.indexOf(e.charAt(1).toUpperCase())*r>=360)))},u=e.encode=function(t,r,n){if(t=Number(t),r=Number(r),n=void 0===n?e.CODE_PRECISION_NORMAL:Number(n),isNaN(t)||isNaN(r)||isNaN(n))throw"ValueError: Parameters are not numbers";if(n<2||n<10&&n%2==1)throw"IllegalArgumentException: Invalid Open Location Code length";t=l(t),r=h(r),90==t&&(t-=d(n));var o=s(t,r,Math.min(n,10));return n>10&&(o+=c(t,r,n-10)),o},f=e.decode=function(e){if(!a(e))throw"IllegalArgumentException: Passed Open Location Code is not a valid full code: "+e;e=(e=(e=e.replace("+","")).replace(new RegExp("0+"),"")).toUpperCase();var t=g(e.substring(0,10));if(e.length<=10)return t;var r=C(e.substring(10));return x(t.latitudeLo+r.latitudeLo,t.longitudeLo+r.longitudeLo,t.latitudeLo+r.latitudeHi,t.longitudeLo+r.longitudeHi,t.codeLength+r.codeLength)},l=(e.recoverNearest=function(e,t,r){if(!i(e)){if(a(e))return e;throw"ValueError: Passed short code is not valid: "+e}if(t=Number(t),r=Number(r),isNaN(t)||isNaN(r))throw"ValueError: Reference position are not numbers";t=l(t),r=h(r);var n=8-(e=e.toUpperCase()).indexOf("+"),o=Math.pow(20,2-n/2),d=o/2,s=f(u(t,r).substr(0,n)+e);return t+d=-90?s.latitudeCenter-=o:t-d>s.latitudeCenter&&s.latitudeCenter+o<=90&&(s.latitudeCenter+=o),r+ds.longitudeCenter&&(s.longitudeCenter+=o),u(s.latitudeCenter,s.longitudeCenter,s.codeLength)},e.shorten=function(e,t,r){if(!a(e))throw"ValueError: Passed code is not valid and full: "+e;if(-1!=e.indexOf("0"))throw"ValueError: Cannot shorten padded codes: "+e;var e=e.toUpperCase(),o=f(e);if(o.codeLength<6)throw"ValueError: Code length must be at least 6";if(t=Number(t),r=Number(r),isNaN(t)||isNaN(r))throw"ValueError: Reference position are not numbers";t=l(t),r=h(r);for(var i=Math.max(Math.abs(o.latitudeCenter-t),Math.abs(o.longitudeCenter-r)),u=n.length-2;u>=1;u--)if(i<.3*n[u])return e.substring(2*(u+1));return e},function(e){return Math.min(90,Math.max(-90,e))}),d=function(e){return e<=10?Math.pow(20,Math.floor(e/-2+2)):Math.pow(20,-3)/Math.pow(5,e-10)},h=function(e){for(;e<-180;)e+=360;for(;e>=180;)e-=360;return e},s=function(e,r,o){for(var i="",a=e+90,u=r+180,f=0;f