!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("fs"),require("path"),require("geobuf"),require("@turf/boolean-point-in-polygon"),require("@turf/helpers"),require("pbf")):"function"==typeof define&&define.amd?define(["exports","fs","path","geobuf","@turf/boolean-point-in-polygon","@turf/helpers","pbf"],e):e((t||self).geoTz={},t.fs,t.path,t.geobuf,t.inside,t.helpers,t.pbf)}(this,function(t,e,r,i,o,n,f){function d(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function l(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,e}var a=/*#__PURE__*/l(e),c=/*#__PURE__*/l(r),u=/*#__PURE__*/d(o),h=/*#__PURE__*/d(f),p=[{tzid:"Etc/GMT-12",left:172.5,right:180},{tzid:"Etc/GMT-11",left:157.5,right:172.5},{tzid:"Etc/GMT-10",left:142.5,right:157.5},{tzid:"Etc/GMT-9",left:127.5,right:142.5},{tzid:"Etc/GMT-8",left:112.5,right:127.5},{tzid:"Etc/GMT-7",left:97.5,right:112.5},{tzid:"Etc/GMT-6",left:82.5,right:97.5},{tzid:"Etc/GMT-5",left:67.5,right:82.5},{tzid:"Etc/GMT-4",left:52.5,right:67.5},{tzid:"Etc/GMT-3",left:37.5,right:52.5},{tzid:"Etc/GMT-2",left:22.5,right:37.5},{tzid:"Etc/GMT-1",left:7.5,right:22.5},{tzid:"Etc/GMT",left:-7.5,right:7.5},{tzid:"Etc/GMT+1",left:-22.5,right:-7.5},{tzid:"Etc/GMT+2",left:-37.5,right:-22.5},{tzid:"Etc/GMT+3",left:-52.5,right:-37.5},{tzid:"Etc/GMT+4",left:-67.5,right:-52.5},{tzid:"Etc/GMT+5",left:-82.5,right:-67.5},{tzid:"Etc/GMT+6",left:-97.5,right:-82.5},{tzid:"Etc/GMT+7",left:-112.5,right:-97.5},{tzid:"Etc/GMT+8",left:-127.5,right:-112.5},{tzid:"Etc/GMT+9",left:-142.5,right:-127.5},{tzid:"Etc/GMT+10",left:-157.5,right:-142.5},{tzid:"Etc/GMT+11",left:-172.5,right:-157.5},{tzid:"Etc/GMT+12",left:-180,right:-172.5}];function g(t){if(-180===t||180===t)return["Etc/GMT+12","Etc/GMT-12"];for(var e=[],r=0;r<p.length;r++){var i=p[r];if(i.left<=t&&i.right>=t)e.push(i.tzid);else if(i.right<t)break}return e}var s,E=require("../data/index.json"),m=c.join(__dirname,"..","data","geo.dat");function z(t){if(s=t&&t.store&&"function"==typeof t.store.get&&"function"==typeof t.store.set?t.store:new Map,t&&t.preload){var e=a.openSync(m,"r");if(e<0)throw new Error("Failed to open geo.dat file");!function(t){!function e(r,i){if(r.pos>=0&&r.len){var o=T(0,r.pos,r.len,t);s.set(i,o)}else"object"==typeof r&&Object.getOwnPropertyNames(r).forEach(function(t){e(r[t],i+t)})}(E.lookup,"")}(e),a.closeSync(e)}}function T(t,e,r,o){void 0===o&&(o=-1);var n=o;if(n<0&&(n=a.openSync(m,"r"))<0)throw new Error("Failed to open geo.dat file");var f=Buffer.alloc(r),d=a.readSync(n,f,0,r,e);if(o<0&&a.closeSync(n),d<r)throw new Error("tried to read "+r+" bytes from geo.dat but only got "+d+" bytes");var l=new h.default(f);return i.decode(l)}z(),t.default=function(t,e){var r=e;if(isNaN(t)||t>90||t<-90)throw new Error("Invalid latitude: "+t);if(isNaN(e)||e>180||e<-180)throw new Error("Invalid longitude: "+e);if(90===t)return p.map(function(t){return t.tzid});t>=89.9999?t=89.9999:t<=-89.9999&&(t=-89.9999),e>=179.9999?e=179.9999:e<=-179.9999&&(e=-179.9999);for(var i=n.point([e,t]),o={top:89.9999,bottom:-89.9999,left:-179.9999,right:179.9999,midLat:0,midLon:0},f="",d=E.lookup;;){var l=void 0;if(t>=o.midLat&&e>=o.midLon?(l="a",o.bottom=o.midLat,o.left=o.midLon):t>=o.midLat&&e<o.midLon?(l="b",o.bottom=o.midLat,o.right=o.midLon):t<o.midLat&&e<o.midLon?(l="c",o.top=o.midLat,o.right=o.midLon):(l="d",o.top=o.midLat,o.left=o.midLon),f+=l,!(d=d[l]))return g(r);if(d.pos>=0&&d.len){var a=s.get(f);a||(a=T(0,d.pos,d.len),s.set(f,a));for(var c=[],h=0;h<a.features.length;h++)u.default(i,a.features[h])&&c.push(a.features[h].properties.tzid);return c.length>0?c:g(r)}if(d.length>0)return d.map(function(t){return E.timezones[t]});if("object"!=typeof d)throw new Error("Unexpected data type");o.midLat=(o.top+o.bottom)/2,o.midLon=(o.left+o.right)/2}},t.preCache=function(){z({preload:!0})},t.setCache=z});
//# sourceMappingURL=geo-tz.umd.js.map
