UNPKG

protomaps-leaflet

Version:

Vector tile rendering and labeling for [Leaflet](https://github.com/Leaflet/Leaflet).

1 lines 98.3 kB
var protomaps=(()=>{var xi=Object.create;var Te=Object.defineProperty;var gi=Object.getOwnPropertyDescriptor;var yi=Object.getOwnPropertyNames,Wt=Object.getOwnPropertySymbols,bi=Object.getPrototypeOf,Ht=Object.prototype.hasOwnProperty,wi=Object.prototype.propertyIsEnumerable;var Kt=(t,e,r)=>e in t?Te(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Jt=(t,e)=>{for(var r in e||(e={}))Ht.call(e,r)&&Kt(t,r,e[r]);if(Wt)for(var r of Wt(e))wi.call(e,r)&&Kt(t,r,e[r]);return t};var Gt=t=>Te(t,"__esModule",{value:!0});var W=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),vi=(t,e)=>{Gt(t);for(var r in e)Te(t,r,{get:e[r],enumerable:!0})},_i=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of yi(e))!Ht.call(t,i)&&i!=="default"&&Te(t,i,{get:()=>e[i],enumerable:!(r=gi(e,i))||r.enumerable});return t},U=t=>_i(Gt(Te(t!=null?xi(bi(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var O=(t,e,r)=>new Promise((i,n)=>{var a=l=>{try{o(r.next(l))}catch(u){n(u)}},s=l=>{try{o(r.throw(l))}catch(u){n(u)}},o=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,s);o((r=r.apply(t,e)).next())});var ee=W((ca,Qt)=>{"use strict";Qt.exports=me;function me(t,e){this.x=t,this.y=e}me.prototype={clone:function(){return new me(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=r,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),i=e*this.x-r*this.y,n=r*this.x+e*this.y;return this.x=i,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),i=Math.sin(t),n=e.x+r*(this.x-e.x)-i*(this.y-e.y),a=e.y+i*(this.x-e.x)+r*(this.y-e.y);return this.x=n,this.y=a,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}};me.convert=function(t){return t instanceof me?t:Array.isArray(t)?new me(t[0],t[1]):t}});var mt=W((da,er)=>{"use strict";var zi=ee();er.exports=pe;function pe(t,e,r,i,n){this.properties={},this.extent=r,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=n,t.readFields(Si,this,e)}function Si(t,e,r){t==1?e.id=r.readVarint():t==2?Li(r,e):t==3?e.type=r.readVarint():t==4&&(e._geometry=r.pos)}function Li(t,e){for(var r=t.readVarint()+t.pos;t.pos<r;){var i=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[i]=n}}pe.types=["Unknown","Point","LineString","Polygon"];pe.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,i=0,n=0,a=0,s=[],o;t.pos<e;){if(i<=0){var l=t.readVarint();r=l&7,i=l>>3}if(i--,r===1||r===2)n+=t.readSVarint(),a+=t.readSVarint(),r===1&&(o&&s.push(o),o=[]),o.push(new zi(n,a));else if(r===7)o&&o.push(o[0].clone());else throw new Error("unknown command "+r)}return o&&s.push(o),s};pe.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,i=0,n=0,a=0,s=1/0,o=-1/0,l=1/0,u=-1/0;t.pos<e;){if(i<=0){var f=t.readVarint();r=f&7,i=f>>3}if(i--,r===1||r===2)n+=t.readSVarint(),a+=t.readSVarint(),n<s&&(s=n),n>o&&(o=n),a<l&&(l=a),a>u&&(u=a);else if(r!==7)throw new Error("unknown command "+r)}return[s,l,o,u]};pe.prototype.toGeoJSON=function(t,e,r){var i=this.extent*Math.pow(2,r),n=this.extent*t,a=this.extent*e,s=this.loadGeometry(),o=pe.types[this.type],l,u;function f(g){for(var w=0;w<g.length;w++){var z=g[w],h=180-(z.y+a)*360/i;g[w]=[(z.x+n)*360/i-180,360/Math.PI*Math.atan(Math.exp(h*Math.PI/180))-90]}}switch(this.type){case 1:var c=[];for(l=0;l<s.length;l++)c[l]=s[l][0];s=c,f(s);break;case 2:for(l=0;l<s.length;l++)f(s[l]);break;case 3:for(s=Fi(s),l=0;l<s.length;l++)for(u=0;u<s[l].length;u++)f(s[l][u]);break}s.length===1?s=s[0]:o="Multi"+o;var d={type:"Feature",geometry:{type:o,coordinates:s},properties:this.properties};return"id"in this&&(d.id=this.id),d};function Fi(t){var e=t.length;if(e<=1)return[t];for(var r=[],i,n,a=0;a<e;a++){var s=ki(t[a]);s!==0&&(n===void 0&&(n=s<0),n===s<0?(i&&r.push(i),i=[t[a]]):i.push(t[a]))}return i&&r.push(i),r}function ki(t){for(var e=0,r=0,i=t.length,n=i-1,a,s;r<i;n=r++)a=t[r],s=t[n],e+=(s.x-a.x)*(a.y+s.y);return e}});var pt=W((ma,rr)=>{"use strict";var Mi=mt();rr.exports=tr;function tr(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Ci,this,e),this.length=this._features.length}function Ci(t,e,r){t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(Ti(r))}function Ti(t){for(var e=null,r=t.readVarint()+t.pos;t.pos<r;){var i=t.readVarint()>>3;e=i===1?t.readString():i===2?t.readFloat():i===3?t.readDouble():i===4?t.readVarint64():i===5?t.readVarint():i===6?t.readSVarint():i===7?t.readBoolean():null}return e}tr.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new Mi(this._pbf,e,this.extent,this._keys,this._values)}});var nr=W((pa,ir)=>{"use strict";var Pi=pt();ir.exports=Di;function Di(t,e){this.layers=t.readFields(Ai,{},e)}function Ai(t,e,r){if(t===3){var i=new Pi(r,r.readVarint()+r.pos);i.length&&(e[i.name]=i)}}});var ar=W((xa,Je)=>{Je.exports.VectorTile=nr();Je.exports.VectorTileFeature=mt();Je.exports.VectorTileLayer=pt()});var sr=W(xt=>{xt.read=function(t,e,r,i,n){var a,s,o=n*8-i-1,l=(1<<o)-1,u=l>>1,f=-7,c=r?n-1:0,d=r?-1:1,g=t[e+c];for(c+=d,a=g&(1<<-f)-1,g>>=-f,f+=o;f>0;a=a*256+t[e+c],c+=d,f-=8);for(s=a&(1<<-f)-1,a>>=-f,f+=i;f>0;s=s*256+t[e+c],c+=d,f-=8);if(a===0)a=1-u;else{if(a===l)return s?NaN:(g?-1:1)*(1/0);s=s+Math.pow(2,i),a=a-u}return(g?-1:1)*s*Math.pow(2,a-i)};xt.write=function(t,e,r,i,n,a){var s,o,l,u=a*8-n-1,f=(1<<u)-1,c=f>>1,d=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=i?0:a-1,w=i?1:-1,z=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+c>=1?e+=d/l:e+=d*Math.pow(2,1-c),e*l>=2&&(s++,l/=2),s+c>=f?(o=0,s=f):s+c>=1?(o=(e*l-1)*Math.pow(2,n),s=s+c):(o=e*Math.pow(2,c-1)*Math.pow(2,n),s=0));n>=8;t[r+g]=o&255,g+=w,o/=256,n-=8);for(s=s<<n|o,u+=n;u>0;t[r+g]=s&255,g+=w,s/=256,u-=8);t[r+g-w]|=z*128}});var cr=W((ya,fr)=>{"use strict";fr.exports=k;var Ge=sr();function k(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}k.Varint=0;k.Fixed64=1;k.Bytes=2;k.Fixed32=5;var gt=(1<<16)*(1<<16),or=1/gt,Bi=12,lr=typeof TextDecoder=="undefined"?null:new TextDecoder("utf8");k.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var i=this.readVarint(),n=i>>3,a=this.pos;this.type=i&7,t(n,e,this),this.pos===a&&this.skip(i)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Qe(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=hr(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Qe(this.buf,this.pos)+Qe(this.buf,this.pos+4)*gt;return this.pos+=8,t},readSFixed64:function(){var t=Qe(this.buf,this.pos)+hr(this.buf,this.pos+4)*gt;return this.pos+=8,t},readFloat:function(){var t=Ge.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Ge.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e=this.buf,r,i;return i=e[this.pos++],r=i&127,i<128||(i=e[this.pos++],r|=(i&127)<<7,i<128)||(i=e[this.pos++],r|=(i&127)<<14,i<128)||(i=e[this.pos++],r|=(i&127)<<21,i<128)?r:(i=e[this.pos],r|=(i&15)<<28,Ei(r,t,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=Bi&&lr?Hi(this.buf,e,t):Wi(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==k.Bytes)return t.push(this.readVarint(e));var r=ne(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==k.Bytes)return t.push(this.readSVarint());var e=ne(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==k.Bytes)return t.push(this.readBoolean());var e=ne(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==k.Bytes)return t.push(this.readFloat());var e=ne(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==k.Bytes)return t.push(this.readDouble());var e=ne(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==k.Bytes)return t.push(this.readFixed32());var e=ne(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==k.Bytes)return t.push(this.readSFixed32());var e=ne(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==k.Bytes)return t.push(this.readFixed64());var e=ne(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==k.Bytes)return t.push(this.readSFixed64());var e=ne(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=t&7;if(e===k.Varint)for(;this.buf[this.pos++]>127;);else if(e===k.Bytes)this.pos=this.readVarint()+this.pos;else if(e===k.Fixed32)this.pos+=4;else if(e===k.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+e)},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),ge(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),ge(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),ge(this.buf,t&-1,this.pos),ge(this.buf,Math.floor(t*or),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),ge(this.buf,t&-1,this.pos),ge(this.buf,Math.floor(t*or),this.pos+4),this.pos+=8},writeVarint:function(t){if(t=+t||0,t>268435455||t<0){Oi(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))},writeSVarint:function(t){this.writeVarint(t<0?-t*2-1:t*2)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(t.length*4),this.pos++;var e=this.pos;this.pos=Ki(this.buf,t,this.pos);var r=this.pos-e;r>=128&&ur(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),Ge.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Ge.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=t[r]},writeRawMessage:function(t,e){this.pos++;var r=this.pos;t(e,this);var i=this.pos-r;i>=128&&ur(r,i,this),this.pos=r-1,this.writeVarint(i),this.pos+=i},writeMessage:function(t,e,r){this.writeTag(t,k.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Xi,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,Vi,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,ji,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,Yi,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,Ui,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Ni,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,qi,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Zi,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,$i,e)},writeBytesField:function(t,e){this.writeTag(t,k.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,k.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,k.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,k.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,k.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,k.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,k.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,k.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,k.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,k.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};function Ei(t,e,r){var i=r.buf,n,a;if(a=i[r.pos++],n=(a&112)>>4,a<128||(a=i[r.pos++],n|=(a&127)<<3,a<128)||(a=i[r.pos++],n|=(a&127)<<10,a<128)||(a=i[r.pos++],n|=(a&127)<<17,a<128)||(a=i[r.pos++],n|=(a&127)<<24,a<128)||(a=i[r.pos++],n|=(a&1)<<31,a<128))return xe(t,n,e);throw new Error("Expected varint not more than 10 bytes")}function ne(t){return t.type===k.Bytes?t.readVarint()+t.pos:t.pos+1}function xe(t,e,r){return r?e*4294967296+(t>>>0):(e>>>0)*4294967296+(t>>>0)}function Oi(t,e){var r,i;if(t>=0?(r=t%4294967296|0,i=t/4294967296|0):(r=~(-t%4294967296),i=~(-t/4294967296),r^4294967295?r=r+1|0:(r=0,i=i+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),Ri(r,i,e),Ii(i,e)}function Ri(t,e,r){r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos]=t&127}function Ii(t,e){var r=(t&7)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),!!t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),!!t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),!!t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),!!t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),!!t&&(e.buf[e.pos++]=t&127)))))}function ur(t,e,r){var i=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(Math.LN2*7));r.realloc(i);for(var n=r.pos-1;n>=t;n--)r.buf[n+i]=r.buf[n]}function Xi(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r])}function Vi(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r])}function Yi(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r])}function Ui(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r])}function ji(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r])}function Ni(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r])}function qi(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r])}function Zi(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r])}function $i(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r])}function Qe(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+t[e+3]*16777216}function ge(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function hr(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function Wi(t,e,r){for(var i="",n=e;n<r;){var a=t[n],s=null,o=a>239?4:a>223?3:a>191?2:1;if(n+o>r)break;var l,u,f;o===1?a<128&&(s=a):o===2?(l=t[n+1],(l&192)==128&&(s=(a&31)<<6|l&63,s<=127&&(s=null))):o===3?(l=t[n+1],u=t[n+2],(l&192)==128&&(u&192)==128&&(s=(a&15)<<12|(l&63)<<6|u&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):o===4&&(l=t[n+1],u=t[n+2],f=t[n+3],(l&192)==128&&(u&192)==128&&(f&192)==128&&(s=(a&15)<<18|(l&63)<<12|(u&63)<<6|f&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,o=1):s>65535&&(s-=65536,i+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),i+=String.fromCharCode(s),n+=o}return i}function Hi(t,e,r){return lr.decode(t.subarray(e,r))}function Ki(t,e,r){for(var i=0,n,a;i<e.length;i++){if(n=e.charCodeAt(i),n>55295&&n<57344)if(a)if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,a=n;continue}else n=a-55296<<10|n-56320|65536,a=null;else{n>56319||i+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):a=n;continue}else a&&(t[r++]=239,t[r++]=191,t[r++]=189,a=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=n&63|128)}return r}});var Vr=W((Ft,kt)=>{(function(t,e){typeof Ft=="object"&&typeof kt!="undefined"?kt.exports=e():typeof define=="function"&&define.amd?define(e):(t=t||self).RBush=e()})(Ft,function(){"use strict";function t(h,m,p,b,x){(function y(v,_,S,F,P){for(;F>S;){if(F-S>600){var C=F-S+1,B=_-S+1,q=Math.log(C),Z=.5*Math.exp(2*q/3),re=.5*Math.sqrt(q*Z*(C-Z)/C)*(B-C/2<0?-1:1),X=Math.max(S,Math.floor(_-B*Z/C+re)),ft=Math.min(F,Math.floor(_+(C-B)*Z/C+re));y(v,_,X,ft,P)}var de=v[_],ie=S,E=F;for(e(v,S,_),P(v[F],de)>0&&e(v,S,F);ie<E;){for(e(v,ie,E),ie++,E--;P(v[ie],de)<0;)ie++;for(;P(v[E],de)>0;)E--}P(v[S],de)===0?e(v,S,E):e(v,++E,F),E<=_&&(S=E+1),_<=E&&(F=E-1)}})(h,m,p||0,b||h.length-1,x||r)}function e(h,m,p){var b=h[m];h[m]=h[p],h[p]=b}function r(h,m){return h<m?-1:h>m?1:0}var i=function(h){h===void 0&&(h=9),this._maxEntries=Math.max(4,h),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function n(h,m,p){if(!p)return m.indexOf(h);for(var b=0;b<m.length;b++)if(p(h,m[b]))return b;return-1}function a(h,m){s(h,0,h.children.length,m,h)}function s(h,m,p,b,x){x||(x=w(null)),x.minX=1/0,x.minY=1/0,x.maxX=-1/0,x.maxY=-1/0;for(var y=m;y<p;y++){var v=h.children[y];o(x,h.leaf?b(v):v)}return x}function o(h,m){return h.minX=Math.min(h.minX,m.minX),h.minY=Math.min(h.minY,m.minY),h.maxX=Math.max(h.maxX,m.maxX),h.maxY=Math.max(h.maxY,m.maxY),h}function l(h,m){return h.minX-m.minX}function u(h,m){return h.minY-m.minY}function f(h){return(h.maxX-h.minX)*(h.maxY-h.minY)}function c(h){return h.maxX-h.minX+(h.maxY-h.minY)}function d(h,m){return h.minX<=m.minX&&h.minY<=m.minY&&m.maxX<=h.maxX&&m.maxY<=h.maxY}function g(h,m){return m.minX<=h.maxX&&m.minY<=h.maxY&&m.maxX>=h.minX&&m.maxY>=h.minY}function w(h){return{children:h,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function z(h,m,p,b,x){for(var y=[m,p];y.length;)if(!((p=y.pop())-(m=y.pop())<=b)){var v=m+Math.ceil((p-m)/b/2)*b;t(h,v,m,p,x),y.push(m,v,v,p)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(h){var m=this.data,p=[];if(!g(h,m))return p;for(var b=this.toBBox,x=[];m;){for(var y=0;y<m.children.length;y++){var v=m.children[y],_=m.leaf?b(v):v;g(h,_)&&(m.leaf?p.push(v):d(h,_)?this._all(v,p):x.push(v))}m=x.pop()}return p},i.prototype.collides=function(h){var m=this.data;if(!g(h,m))return!1;for(var p=[];m;){for(var b=0;b<m.children.length;b++){var x=m.children[b],y=m.leaf?this.toBBox(x):x;if(g(h,y)){if(m.leaf||d(h,y))return!0;p.push(x)}}m=p.pop()}return!1},i.prototype.load=function(h){if(!h||!h.length)return this;if(h.length<this._minEntries){for(var m=0;m<h.length;m++)this.insert(h[m]);return this}var p=this._build(h.slice(),0,h.length-1,0);if(this.data.children.length)if(this.data.height===p.height)this._splitRoot(this.data,p);else{if(this.data.height<p.height){var b=this.data;this.data=p,p=b}this._insert(p,this.data.height-p.height-1,!0)}else this.data=p;return this},i.prototype.insert=function(h){return h&&this._insert(h,this.data.height-1),this},i.prototype.clear=function(){return this.data=w([]),this},i.prototype.remove=function(h,m){if(!h)return this;for(var p,b,x,y=this.data,v=this.toBBox(h),_=[],S=[];y||_.length;){if(y||(y=_.pop(),b=_[_.length-1],p=S.pop(),x=!0),y.leaf){var F=n(h,y.children,m);if(F!==-1)return y.children.splice(F,1),_.push(y),this._condense(_),this}x||y.leaf||!d(y,v)?b?(p++,y=b.children[p],x=!1):y=null:(_.push(y),S.push(p),p=0,b=y,y=y.children[0])}return this},i.prototype.toBBox=function(h){return h},i.prototype.compareMinX=function(h,m){return h.minX-m.minX},i.prototype.compareMinY=function(h,m){return h.minY-m.minY},i.prototype.toJSON=function(){return this.data},i.prototype.fromJSON=function(h){return this.data=h,this},i.prototype._all=function(h,m){for(var p=[];h;)h.leaf?m.push.apply(m,h.children):p.push.apply(p,h.children),h=p.pop();return m},i.prototype._build=function(h,m,p,b){var x,y=p-m+1,v=this._maxEntries;if(y<=v)return a(x=w(h.slice(m,p+1)),this.toBBox),x;b||(b=Math.ceil(Math.log(y)/Math.log(v)),v=Math.ceil(y/Math.pow(v,b-1))),(x=w([])).leaf=!1,x.height=b;var _=Math.ceil(y/v),S=_*Math.ceil(Math.sqrt(v));z(h,m,p,S,this.compareMinX);for(var F=m;F<=p;F+=S){var P=Math.min(F+S-1,p);z(h,F,P,_,this.compareMinY);for(var C=F;C<=P;C+=_){var B=Math.min(C+_-1,P);x.children.push(this._build(h,C,B,b-1))}}return a(x,this.toBBox),x},i.prototype._chooseSubtree=function(h,m,p,b){for(;b.push(m),!m.leaf&&b.length-1!==p;){for(var x=1/0,y=1/0,v=void 0,_=0;_<m.children.length;_++){var S=m.children[_],F=f(S),P=(C=h,B=S,(Math.max(B.maxX,C.maxX)-Math.min(B.minX,C.minX))*(Math.max(B.maxY,C.maxY)-Math.min(B.minY,C.minY))-F);P<y?(y=P,x=F<x?F:x,v=S):P===y&&F<x&&(x=F,v=S)}m=v||m.children[0]}var C,B;return m},i.prototype._insert=function(h,m,p){var b=p?h:this.toBBox(h),x=[],y=this._chooseSubtree(b,this.data,m,x);for(y.children.push(h),o(y,b);m>=0&&x[m].children.length>this._maxEntries;)this._split(x,m),m--;this._adjustParentBBoxes(b,x,m)},i.prototype._split=function(h,m){var p=h[m],b=p.children.length,x=this._minEntries;this._chooseSplitAxis(p,x,b);var y=this._chooseSplitIndex(p,x,b),v=w(p.children.splice(y,p.children.length-y));v.height=p.height,v.leaf=p.leaf,a(p,this.toBBox),a(v,this.toBBox),m?h[m-1].children.push(v):this._splitRoot(p,v)},i.prototype._splitRoot=function(h,m){this.data=w([h,m]),this.data.height=h.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(h,m,p){for(var b,x,y,v,_,S,F,P=1/0,C=1/0,B=m;B<=p-m;B++){var q=s(h,0,B,this.toBBox),Z=s(h,B,p,this.toBBox),re=(x=q,y=Z,v=void 0,_=void 0,S=void 0,F=void 0,v=Math.max(x.minX,y.minX),_=Math.max(x.minY,y.minY),S=Math.min(x.maxX,y.maxX),F=Math.min(x.maxY,y.maxY),Math.max(0,S-v)*Math.max(0,F-_)),X=f(q)+f(Z);re<P?(P=re,b=B,C=X<C?X:C):re===P&&X<C&&(C=X,b=B)}return b||p-m},i.prototype._chooseSplitAxis=function(h,m,p){var b=h.leaf?this.compareMinX:l,x=h.leaf?this.compareMinY:u;this._allDistMargin(h,m,p,b)<this._allDistMargin(h,m,p,x)&&h.children.sort(b)},i.prototype._allDistMargin=function(h,m,p,b){h.children.sort(b);for(var x=this.toBBox,y=s(h,0,m,x),v=s(h,p-m,p,x),_=c(y)+c(v),S=m;S<p-m;S++){var F=h.children[S];o(y,h.leaf?x(F):F),_+=c(y)}for(var P=p-m-1;P>=m;P--){var C=h.children[P];o(v,h.leaf?x(C):C),_+=c(v)}return _},i.prototype._adjustParentBBoxes=function(h,m,p){for(var b=p;b>=0;b--)o(m[b],h)},i.prototype._condense=function(h){for(var m=h.length-1,p=void 0;m>=0;m--)h[m].children.length===0?m>0?(p=h[m-1].children).splice(p.indexOf(h[m]),1):this.clear():a(h[m],this.toBBox)},i})});var $r=W(()=>{});var Wr=W((Tt,Pt)=>{(function(t,e){typeof Tt=="object"&&typeof Pt!="undefined"?Pt.exports=e():typeof define=="function"&&define.amd?define(e):(t=t||self,t.TinyQueue=e())})(Tt,function(){"use strict";var t=function(i,n){if(i===void 0&&(i=[]),n===void 0&&(n=e),this.data=i,this.length=this.data.length,this.compare=n,this.length>0)for(var a=(this.length>>1)-1;a>=0;a--)this._down(a)};t.prototype.push=function(i){this.data.push(i),this.length++,this._up(this.length-1)},t.prototype.pop=function(){if(this.length!==0){var i=this.data[0],n=this.data.pop();return this.length--,this.length>0&&(this.data[0]=n,this._down(0)),i}},t.prototype.peek=function(){return this.data[0]},t.prototype._up=function(i){for(var n=this,a=n.data,s=n.compare,o=a[i];i>0;){var l=i-1>>1,u=a[l];if(s(o,u)>=0)break;a[i]=u,i=l}a[i]=o},t.prototype._down=function(i){for(var n=this,a=n.data,s=n.compare,o=this.length>>1,l=a[i];i<o;){var u=(i<<1)+1,f=a[u],c=u+1;if(c<this.length&&s(a[c],f)<0&&(u=c,f=a[c]),s(f,l)>=0)break;a[i]=f,i=u}a[i]=l};function e(r,i){return r<i?-1:r>i?1:0}return t})});var Kr=W((Ya,Dt)=>{"use strict";var st=Wr();st.default&&(st=st.default);Dt.exports=Hr;Dt.exports.default=Hr;function Hr(t,e,r){e=e||1;for(var i,n,a,s,o=0;o<t[0].length;o++){var l=t[0][o];(!o||l[0]<i)&&(i=l[0]),(!o||l[1]<n)&&(n=l[1]),(!o||l[0]>a)&&(a=l[0]),(!o||l[1]>s)&&(s=l[1])}var u=a-i,f=s-n,c=Math.min(u,f),d=c/2;if(c===0){var g=[i,n];return g.distance=0,g}for(var w=new st(void 0,Nn),z=i;z<a;z+=c)for(var h=n;h<s;h+=c)w.push(new ue(z+d,h+d,d,t));var m=Zn(t),p=new ue(i+u/2,n+f/2,0,t);p.d>m.d&&(m=p);for(var b=w.length;w.length;){var x=w.pop();x.d>m.d&&(m=x,r&&console.log("found best %d after %d probes",Math.round(1e4*x.d)/1e4,b)),!(x.max-m.d<=e)&&(d=x.h/2,w.push(new ue(x.x-d,x.y-d,d,t)),w.push(new ue(x.x+d,x.y-d,d,t)),w.push(new ue(x.x-d,x.y+d,d,t)),w.push(new ue(x.x+d,x.y+d,d,t)),b+=4)}r&&(console.log("num probes: "+b),console.log("best distance: "+m.d));var y=[m.x,m.y];return y.distance=m.d,y}function Nn(t,e){return e.max-t.max}function ue(t,e,r,i){this.x=t,this.y=e,this.h=r,this.d=qn(t,e,i),this.max=this.d+this.h*Math.SQRT2}function qn(t,e,r){for(var i=!1,n=1/0,a=0;a<r.length;a++)for(var s=r[a],o=0,l=s.length,u=l-1;o<l;u=o++){var f=s[o],c=s[u];f[1]>e!=c[1]>e&&t<(c[0]-f[0])*(e-f[1])/(c[1]-f[1])+f[0]&&(i=!i),n=Math.min(n,$n(t,e,f,c))}return n===0?0:(i?1:-1)*Math.sqrt(n)}function Zn(t){for(var e=0,r=0,i=0,n=t[0],a=0,s=n.length,o=s-1;a<s;o=a++){var l=n[a],u=n[o],f=l[0]*u[1]-u[0]*l[1];r+=(l[0]+u[0])*f,i+=(l[1]+u[1])*f,e+=f*3}return e===0?new ue(n[0][0],n[0][1],0,t):new ue(r/e,i/e,0,t)}function $n(t,e,r,i){var n=r[0],a=r[1],s=i[0]-n,o=i[1]-a;if(s!==0||o!==0){var l=((t-n)*s+(e-a)*o)/(s*s+o*o);l>1?(n=i[0],a=i[1]):l>0&&(n+=s*l,a+=o*l)}return s=t-n,o=e-a,s*s+o*o}});var ha={};vi(ha,{CenteredSymbolizer:()=>Ot,CenteredTextSymbolizer:()=>te,CircleSymbolizer:()=>oe,FlexSymbolizer:()=>Ze,Font:()=>oa,GeomType:()=>G,GroupSymbolizer:()=>$e,IconSymbolizer:()=>ai,Index:()=>Mt,Justify:()=>Q,Labeler:()=>Ve,Labelers:()=>Ye,LineLabelPlacement:()=>Se,LineLabelSymbolizer:()=>Le,LineSymbolizer:()=>R,OffsetSymbolizer:()=>Rt,OffsetTextSymbolizer:()=>ce,PMTiles:()=>tt,Padding:()=>oi,PmtilesSource:()=>Ee,PolygonLabelSymbolizer:()=>Fe,PolygonSymbolizer:()=>A,Sheet:()=>pi,ShieldSymbolizer:()=>ot,Static:()=>ci,TextPlacements:()=>T,TextSymbolizer:()=>We,TileCache:()=>at,View:()=>Lt,ZxySource:()=>rt,arr:()=>Jn,covering:()=>jr,createPattern:()=>Kn,cubicBezier:()=>ea,dark:()=>_e,exp:()=>Y,filterFn:()=>Ke,getFont:()=>Ut,getZoom:()=>It,isCCW:()=>Er,isInRing:()=>St,json_style:()=>ua,labelRules:()=>Me,leafletLayer:()=>sa,light:()=>ve,linear:()=>Qn,numberFn:()=>ht,numberOrFn:()=>Vt,paintRules:()=>ke,painter:()=>Xe,pointInPolygon:()=>Or,pointMinDistToLines:()=>Ir,pointMinDistToPoints:()=>Rr,sourcesToViews:()=>Ie,step:()=>Gn,toIndex:()=>se,transformGeom:()=>Oe,widthFn:()=>Yt,wrap:()=>Re});var le=U(ee());var fe=U(ee());var we=U(ee()),Tr=U(ar()),Pr=U(cr());var V=(t,e,r)=>new Promise((i,n)=>{var a=l=>{try{o(r.next(l))}catch(u){n(u)}},s=l=>{try{o(r.throw(l))}catch(u){n(u)}},o=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,s);o((r=r.apply(t,e)).next())}),j=Uint8Array,he=Uint16Array,dr=Uint32Array,mr=new j([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),pr=new j([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ji=new j([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xr=function(t,e){for(var r=new he(31),i=0;i<31;++i)r[i]=e+=1<<t[i-1];for(var n=new dr(r[30]),i=1;i<30;++i)for(var a=r[i];a<r[i+1];++a)n[a]=a-r[i]<<5|i;return[r,n]},gr=xr(mr,2),yr=gr[0],Gi=gr[1];yr[28]=258,Gi[258]=28;var br=xr(pr,0),Qi=br[0],ba=br[1],yt=new he(32768);for(M=0;M<32768;++M)ae=(M&43690)>>>1|(M&21845)<<1,ae=(ae&52428)>>>2|(ae&13107)<<2,ae=(ae&61680)>>>4|(ae&3855)<<4,yt[M]=((ae&65280)>>>8|(ae&255)<<8)>>>1;var ae,M,Pe=function(t,e,r){for(var i=t.length,n=0,a=new he(e);n<i;++n)t[n]&&++a[t[n]-1];var s=new he(e);for(n=0;n<e;++n)s[n]=s[n-1]+a[n-1]<<1;var o;if(r){o=new he(1<<e);var l=15-e;for(n=0;n<i;++n)if(t[n])for(var u=n<<4|t[n],f=e-t[n],c=s[t[n]-1]++<<f,d=c|(1<<f)-1;c<=d;++c)o[yt[c]>>>l]=u}else for(o=new he(i),n=0;n<i;++n)t[n]&&(o[n]=yt[s[t[n]-1]++]>>>15-t[n]);return o},De=new j(288);for(M=0;M<144;++M)De[M]=8;var M;for(M=144;M<256;++M)De[M]=9;var M;for(M=256;M<280;++M)De[M]=7;var M;for(M=280;M<288;++M)De[M]=8;var M,wr=new j(32);for(M=0;M<32;++M)wr[M]=5;var M,en=Pe(De,9,1),tn=Pe(wr,5,1),bt=function(t){for(var e=t[0],r=1;r<t.length;++r)t[r]>e&&(e=t[r]);return e},H=function(t,e,r){var i=e/8|0;return(t[i]|t[i+1]<<8)>>(e&7)&r},wt=function(t,e){var r=e/8|0;return(t[r]|t[r+1]<<8|t[r+2]<<16)>>(e&7)},rn=function(t){return(t+7)/8|0},nn=function(t,e,r){(e==null||e<0)&&(e=0),(r==null||r>t.length)&&(r=t.length);var i=new(t.BYTES_PER_ELEMENT==2?he:t.BYTES_PER_ELEMENT==4?dr:j)(r-e);return i.set(t.subarray(e,r)),i},an=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],K=function(t,e,r){var i=new Error(e||an[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,K),!r)throw i;return i},vt=function(t,e,r){var i=t.length;if(!i||r&&r.f&&!r.l)return e||new j(0);var n=!e||r,a=!r||r.i;r||(r={}),e||(e=new j(i*3));var s=function(qt){var Zt=e.length;if(qt>Zt){var $t=new j(Math.max(Zt*2,qt));$t.set(e),e=$t}},o=r.f||0,l=r.p||0,u=r.b||0,f=r.l,c=r.d,d=r.m,g=r.n,w=i*8;do{if(!f){o=H(t,l,1);var z=H(t,l+1,3);if(l+=3,z)if(z==1)f=en,c=tn,d=9,g=5;else if(z==2){var b=H(t,l,31)+257,x=H(t,l+10,15)+4,y=b+H(t,l+5,31)+1;l+=14;for(var v=new j(y),_=new j(19),S=0;S<x;++S)_[Ji[S]]=H(t,l+S*3,7);l+=x*3;for(var F=bt(_),P=(1<<F)-1,C=Pe(_,F,1),S=0;S<y;){var B=C[H(t,l,P)];l+=B&15;var h=B>>>4;if(h<16)v[S++]=h;else{var q=0,Z=0;for(h==16?(Z=3+H(t,l,3),l+=2,q=v[S-1]):h==17?(Z=3+H(t,l,7),l+=3):h==18&&(Z=11+H(t,l,127),l+=7);Z--;)v[S++]=q}}var re=v.subarray(0,b),X=v.subarray(b);d=bt(re),g=bt(X),f=Pe(re,d,1),c=Pe(X,g,1)}else K(1);else{var h=rn(l)+4,m=t[h-4]|t[h-3]<<8,p=h+m;if(p>i){a&&K(0);break}n&&s(u+m),e.set(t.subarray(h,p),u),r.b=u+=m,r.p=l=p*8,r.f=o;continue}if(l>w){a&&K(0);break}}n&&s(u+131072);for(var ft=(1<<d)-1,de=(1<<g)-1,ie=l;;ie=l){var q=f[wt(t,l)&ft],E=q>>>4;if(l+=q&15,l>w){a&&K(0);break}if(q||K(2),E<256)e[u++]=E;else if(E==256){ie=l,f=null;break}else{var jt=E-254;if(E>264){var S=E-257,Ce=mr[S];jt=H(t,l,(1<<Ce)-1)+yr[S],l+=Ce}var ct=c[wt(t,l)&de],dt=ct>>>4;ct||K(3),l+=ct&15;var X=Qi[dt];if(dt>3){var Ce=pr[dt];X+=wt(t,l)&(1<<Ce)-1,l+=Ce}if(l>w){a&&K(0);break}n&&s(u+131072);for(var Nt=u+jt;u<Nt;u+=4)e[u]=e[u-X],e[u+1]=e[u+1-X],e[u+2]=e[u+2-X],e[u+3]=e[u+3-X];u=Nt}}r.l=f,r.p=ie,r.b=u,r.f=o,f&&(o=1,r.m=d,r.d=c,r.n=g)}while(!o);return u==e.length?e:nn(e,0,u)},sn=new j(0),on=function(t){(t[0]!=31||t[1]!=139||t[2]!=8)&&K(6,"invalid gzip data");var e=t[3],r=10;e&4&&(r+=t[10]|(t[11]<<8)+2);for(var i=(e>>3&1)+(e>>4&1);i>0;i-=!t[r++]);return r+(e&2)},ln=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0},un=function(t){((t[0]&15)!=8||t[0]>>>4>7||(t[0]<<8|t[1])%31)&&K(6,"invalid zlib data"),t[1]&32&&K(6,"invalid zlib data: preset dictionaries not supported")};function hn(t,e){return vt(t,e)}function fn(t,e){return vt(t.subarray(on(t),-8),e||new j(ln(t)))}function cn(t,e){return vt((un(t),t.subarray(2,-4)),e)}function _t(t,e){return t[0]==31&&t[1]==139&&t[2]==8?fn(t,e):(t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31?hn(t,e):cn(t,e)}var dn=typeof TextDecoder!="undefined"&&new TextDecoder,mn=0;try{dn.decode(sn,{stream:!0}),mn=1}catch(t){}var vr=(t,e)=>t*Math.pow(2,e),Ae=(t,e)=>Math.floor(t/Math.pow(2,e)),et=(t,e)=>vr(t.getUint16(e+1,!0),8)+t.getUint8(e),_r=(t,e)=>vr(t.getUint32(e+2,!0),16)+t.getUint16(e,!0),pn=(t,e,r,i,n)=>{if(t!=i.getUint8(n))return t-i.getUint8(n);let a=et(i,n+1);if(e!=a)return e-a;let s=et(i,n+4);return r!=s?r-s:0},xn=(t,e,r,i)=>{let n=Sr(t,e|128,r,i);return n?{z:e,x:r,y:i,offset:n[0],length:n[1],is_dir:!0}:null},zr=(t,e,r,i)=>{let n=Sr(t,e,r,i);return n?{z:e,x:r,y:i,offset:n[0],length:n[1],is_dir:!1}:null},Sr=(t,e,r,i)=>{let n=0,a=t.byteLength/17-1;for(;n<=a;){let s=a+n>>1,o=pn(e,r,i,t,s*17);if(o>0)n=s+1;else if(o<0)a=s-1;else return[_r(t,s*17+7),t.getUint32(s*17+13,!0)]}return null},gn=(t,e)=>t.is_dir&&!e.is_dir?1:!t.is_dir&&e.is_dir?-1:t.z!==e.z?t.z-e.z:t.x!==e.x?t.x-e.x:t.y-e.y,Lr=(t,e)=>{let r=t.getUint8(e*17);return{z:r&127,x:et(t,e*17+1),y:et(t,e*17+4),offset:_r(t,e*17+7),length:t.getUint32(e*17+13,!0),is_dir:r>>7==1}},Fr=t=>{let e=[],r=new DataView(t);for(let i=0;i<r.byteLength/17;i++)e.push(Lr(r,i));return yn(e)},yn=t=>{t.sort(gn);let e=new ArrayBuffer(17*t.length),r=new Uint8Array(e);for(let i=0;i<t.length;i++){let n=t[i],a=n.z;n.is_dir&&(a=a|128),r[i*17]=a,r[i*17+1]=n.x&255,r[i*17+2]=n.x>>8&255,r[i*17+3]=n.x>>16&255,r[i*17+4]=n.y&255,r[i*17+5]=n.y>>8&255,r[i*17+6]=n.y>>16&255,r[i*17+7]=n.offset&255,r[i*17+8]=Ae(n.offset,8)&255,r[i*17+9]=Ae(n.offset,16)&255,r[i*17+10]=Ae(n.offset,24)&255,r[i*17+11]=Ae(n.offset,32)&255,r[i*17+12]=Ae(n.offset,48)&255,r[i*17+13]=n.length&255,r[i*17+14]=n.length>>8&255,r[i*17+15]=n.length>>16&255,r[i*17+16]=n.length>>24&255}return e},bn=(t,e)=>{if(t.byteLength<17)return null;let r=t.byteLength/17,i=Lr(t,r-1);if(i.is_dir){let n=i.z,a=e.z-n,s=Math.trunc(e.x/(1<<a)),o=Math.trunc(e.y/(1<<a));return{z:n,x:s,y:o}}return null};function wn(t){return V(this,null,function*(){let e=yield t.getBytes(0,512e3),r=new DataView(e.data),i=r.getUint32(4,!0),n=r.getUint16(8,!0),a=new TextDecoder("utf-8"),s=JSON.parse(a.decode(new DataView(e.data,10,i))),o=0;s.compression==="gzip"&&(o=2);let l=0;"minzoom"in s&&(l=+s.minzoom);let u=0;"maxzoom"in s&&(u=+s.maxzoom);let f=0,c=0,d=0,g=-180,w=-85,z=180,h=85;if(s.bounds){let p=s.bounds.split(",");g=+p[0],w=+p[1],z=+p[2],h=+p[3]}if(s.center){let p=s.center.split(",");f=+p[0],c=+p[1],d=+p[2]}return{specVersion:r.getUint16(2,!0),rootDirectoryOffset:10+i,rootDirectoryLength:n*17,jsonMetadataOffset:10,jsonMetadataLength:i,leafDirectoryOffset:0,leafDirectoryLength:void 0,tileDataOffset:0,tileDataLength:void 0,numAddressedTiles:0,numTileEntries:0,numTileContents:0,clustered:!1,internalCompression:1,tileCompression:o,tileType:1,minZoom:l,maxZoom:u,minLon:g,minLat:w,maxLon:z,maxLat:h,centerZoom:d,centerLon:f,centerLat:c,etag:e.etag}})}function vn(t,e,r,i,n,a,s){return V(this,null,function*(){let o=yield r.getArrayBuffer(e,t.rootDirectoryOffset,t.rootDirectoryLength,t);t.specVersion===1&&(o=Fr(o));let l=zr(new DataView(o),i,n,a);if(l){let c=(yield e.getBytes(l.offset,l.length,s)).data,d=new DataView(c);return d.getUint8(0)==31&&d.getUint8(1)==139&&(c=_t(new Uint8Array(c))),{data:c}}let u=bn(new DataView(o),{z:i,x:n,y:a});if(u){let f=xn(new DataView(o),u.z,u.x,u.y);if(f){let c=yield r.getArrayBuffer(e,f.offset,f.length,t);t.specVersion===1&&(c=Fr(c));let d=zr(new DataView(c),i,n,a);if(d){let w=(yield e.getBytes(d.offset,d.length,s)).data,z=new DataView(w);return z.getUint8(0)==31&&z.getUint8(1)==139&&(w=_t(new Uint8Array(w))),{data:w}}}}})}var kr={getHeader:wn,getZxy:vn};function ye(t,e){return(e>>>0)*4294967296+(t>>>0)}function _n(t,e){let r=e.buf,i,n;if(n=r[e.pos++],i=(n&112)>>4,n<128||(n=r[e.pos++],i|=(n&127)<<3,n<128)||(n=r[e.pos++],i|=(n&127)<<10,n<128)||(n=r[e.pos++],i|=(n&127)<<17,n<128)||(n=r[e.pos++],i|=(n&127)<<24,n<128)||(n=r[e.pos++],i|=(n&1)<<31,n<128))return ye(t,i);throw new Error("Expected varint not more than 10 bytes")}function Be(t){let e=t.buf,r,i;return i=e[t.pos++],r=i&127,i<128||(i=e[t.pos++],r|=(i&127)<<7,i<128)||(i=e[t.pos++],r|=(i&127)<<14,i<128)||(i=e[t.pos++],r|=(i&127)<<21,i<128)?r:(i=e[t.pos],r|=(i&15)<<28,_n(r,t))}function zn(t,e,r,i){if(i==0){r==1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let n=e[0];e[0]=e[1],e[1]=n}}function Sn(t,e,r){if(t>26)throw Error("Tile zoom level exceeds max safe number limit (26)");if(e>Math.pow(2,t)-1||r>Math.pow(2,t)-1)throw Error("tile x/y outside zoom level bounds");let i=0,n=0;for(;n<t;)i+=Math.pow(2,n)*Math.pow(2,n),n++;let a=Math.pow(2,t),s=0,o=0,l=0,u=[e,r],f=a/2;for(;f>0;)s=(u[0]&f)>0?1:0,o=(u[1]&f)>0?1:0,l+=f*f*(3*s^o),zn(f,u,s,o),f=f/2;return i+l}function Mr(t,e){return V(this,null,function*(){if(e===1||e===0)return t;if(e===2)return _t(new Uint8Array(t));throw Error("Compression method not supported")})}var Ln=127;function Fn(t,e){let r=0,i=t.length-1;for(;r<=i;){let n=i+r>>1,a=e-t[n].tileId;if(a>0)r=n+1;else if(a<0)i=n-1;else return t[n]}return i>=0&&(t[i].runLength===0||e-t[i].tileId<t[i].runLength)?t[i]:null}var kn=class{constructor(t){this.url=t}getKey(){return this.url}getBytes(t,e,r){return V(this,null,function*(){let i;r||(i=new AbortController,r=i.signal);let n=yield fetch(this.url,{signal:r,headers:{Range:"bytes="+t+"-"+(t+e-1)}});if(n.status===416&&t===0){let o=n.headers.get("Content-Range");if(!o||!o.startsWith("bytes */"))throw Error("Missing content-length on 416 response");let l=+o.substr(8);n=yield fetch(this.url,{signal:r,headers:{Range:"bytes=0-"+(l-1)}})}if(n.status>=300)throw Error("Bad response code: "+n.status);let a=n.headers.get("Content-Length");if(n.status===200&&(!a||+a>e))throw i&&i.abort(),Error("Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.");return{data:yield n.arrayBuffer(),etag:n.headers.get("ETag")||void 0,cacheControl:n.headers.get("Cache-Control")||void 0,expires:n.headers.get("Expires")||void 0}})}};function J(t,e){let r=t.getUint32(e+4,!0),i=t.getUint32(e+0,!0);return r*Math.pow(2,32)+i}function Mn(t,e){let r=new DataView(t),i=r.getUint8(7);if(i>3)throw Error(`Archive is spec version ${i} but this library supports up to spec version 3`);return{specVersion:i,rootDirectoryOffset:J(r,8),rootDirectoryLength:J(r,16),jsonMetadataOffset:J(r,24),jsonMetadataLength:J(r,32),leafDirectoryOffset:J(r,40),leafDirectoryLength:J(r,48),tileDataOffset:J(r,56),tileDataLength:J(r,64),numAddressedTiles:J(r,72),numTileEntries:J(r,80),numTileContents:J(r,88),clustered:r.getUint8(96)===1,internalCompression:r.getUint8(97),tileCompression:r.getUint8(98),tileType:r.getUint8(99),minZoom:r.getUint8(100),maxZoom:r.getUint8(101),minLon:r.getInt32(102,!0)/1e7,minLat:r.getInt32(106,!0)/1e7,maxLon:r.getInt32(110,!0)/1e7,maxLat:r.getInt32(114,!0)/1e7,centerZoom:r.getUint8(118),centerLon:r.getInt32(119,!0)/1e7,centerLat:r.getInt32(123,!0)/1e7,etag:e}}function Cr(t){let e={buf:new Uint8Array(t),pos:0},r=Be(e),i=[],n=0;for(let a=0;a<r;a++){let s=Be(e);i.push({tileId:n+s,offset:0,length:0,runLength:1}),n+=s}for(let a=0;a<r;a++)i[a].runLength=Be(e);for(let a=0;a<r;a++)i[a].length=Be(e);for(let a=0;a<r;a++){let s=Be(e);s===0&&a>0?i[a].offset=i[a-1].offset+i[a-1].length:i[a].offset=s-1}return i}function Cn(t){let e=new DataView(t);return e.getUint16(2,!0)===2?(console.warn("PMTiles spec version 2 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade"),2):e.getUint16(2,!0)===1?(console.warn("PMTiles spec version 1 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade"),1):3}var be=class extends Error{};function Tn(t,e,r,i){return V(this,null,function*(){let n=yield t.getBytes(0,16384);if(new DataView(n.data).getUint16(0,!0)!==19792)throw new Error("Wrong magic number for PMTiles archive");if(Cn(n.data)<3)return[yield kr.getHeader(t)];let s=n.data.slice(0,Ln),o=n.etag;i&&n.etag!=i&&(console.warn("ETag conflict detected; your HTTP server might not support content-based ETag headers. ETags disabled for "+t.getKey()),o=void 0);let l=Mn(s,o);if(r){let u=n.data.slice(l.rootDirectoryOffset,l.rootDirectoryOffset+l.rootDirectoryLength),f=t.getKey()+"|"+(l.etag||"")+"|"+l.rootDirectoryOffset+"|"+l.rootDirectoryLength,c=Cr(yield e(u,l.internalCompression));return[l,[f,c.length,c]]}return[l,void 0]})}function Pn(t,e,r,i,n){return V(this,null,function*(){let a=yield t.getBytes(r,i);if(n.etag&&n.etag!==a.etag)throw new be(a.etag);let s=yield e(a.data,n.internalCompression),o=Cr(s);if(o.length===0)throw new Error("Empty directory is invalid");return o})}var Dn=class{constructor(t=100,e=!0,r=Mr){this.cache=new Map,this.maxCacheEntries=t,this.counter=1,this.prefetch=e,this.decompress=r}getHeader(t,e){return V(this,null,function*(){let r=t.getKey();if(this.cache.has(r))return this.cache.get(r).lastUsed=this.counter++,yield this.cache.get(r).data;let i=new Promise((n,a)=>{Tn(t,this.decompress,this.prefetch,e).then(s=>{s[1]&&this.cache.set(s[1][0],{lastUsed:this.counter++,data:Promise.resolve(s[1][2])}),n(s[0]),this.prune()}).catch(s=>{a(s)})});return this.cache.set(r,{lastUsed:this.counter++,data:i}),i})}getDirectory(t,e,r,i){return V(this,null,function*(){let n=t.getKey()+"|"+(i.etag||"")+"|"+e+"|"+r;if(this.cache.has(n))return this.cache.get(n).lastUsed=this.counter++,yield this.cache.get(n).data;let a=new Promise((s,o)=>{Pn(t,this.decompress,e,r,i).then(l=>{s(l),this.prune()}).catch(l=>{o(l)})});return this.cache.set(n,{lastUsed:this.counter++,data:a}),a})}getArrayBuffer(t,e,r,i){return V(this,null,function*(){let n=t.getKey()+"|"+(i.etag||"")+"|"+e+"|"+r;if(this.cache.has(n))return this.cache.get(n).lastUsed=this.counter++,yield this.cache.get(n).data;let a=new Promise((s,o)=>{t.getBytes(e,r).then(l=>{if(i.etag&&i.etag!==l.etag)throw new be(l.etag);s(l.data),this.cache.has(n),this.prune()}).catch(l=>{o(l)})});return this.cache.set(n,{lastUsed:this.counter++,data:a}),a})}prune(){if(this.cache.size>=this.maxCacheEntries){let t=1/0,e;this.cache.forEach((r,i)=>{r.lastUsed<t&&(t=r.lastUsed,e=i)}),e&&this.cache.delete(e)}}invalidate(t,e){return V(this,null,function*(){this.cache.delete(t.getKey()),yield this.getHeader(t,e)})}},tt=class{constructor(t,e,r){typeof t=="string"?this.source=new kn(t):this.source=t,r?this.decompress=r:this.decompress=Mr,e?this.cache=e:this.cache=new Dn}getHeader(){return V(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(t,e,r,i){return V(this,null,function*(){let n=Sn(t,e,r),a=yield this.cache.getHeader(this.source);if(a.specVersion<3)return kr.getZxy(a,this.source,this.cache,t,e,r,i);if(t<a.minZoom||t>a.maxZoom)return;let s=a.rootDirectoryOffset,o=a.rootDirectoryLength;for(let l=0;l<=3;l++){let u=yield this.cache.getDirectory(this.source,s,o,a),f=Fn(u,n);if(f)if(f.runLength>0){let c=yield this.source.getBytes(a.tileDataOffset+f.offset,f.length,i);if(a.etag&&a.etag!==c.etag)throw new be(c.etag);return{data:yield this.decompress(c.data,a.tileCompression),cacheControl:c.cacheControl,expires:c.expires}}else s=a.leafDirectoryOffset+f.offset,o=f.length;else return}throw Error("Maximum directory depth exceeded")})}getZxy(t,e,r,i){return V(this,null,function*(){try{return yield this.getZxyAttempt(t,e,r,i)}catch(n){if(n instanceof be)return this.cache.invalidate(this.source,n.message),yield this.getZxyAttempt(t,e,r,i);throw n}})}getMetadataAttempt(){return V(this,null,function*(){let t=yield this.cache.getHeader(this.source),e=yield this.source.getBytes(t.jsonMetadataOffset,t.jsonMetadataLength);if(t.etag&&t.etag!==e.etag)throw new be(e.etag);let r=yield this.decompress(e.data,t.internalCompression),i=new TextDecoder("utf-8");return JSON.parse(i.decode(r))})}getMetadata(){return V(this,null,function*(){try{return yield this.getMetadataAttempt()}catch(t){if(t instanceof be)return this.cache.invalidate(this.source,t.message),yield this.getMetadataAttempt();throw t}})}};var G;(function(i){i[i.Point=1]="Point",i[i.Line=2]="Line",i[i.Polygon=3]="Polygon"})(G||(G={}));function se(t){return t.x+":"+t.y+":"+t.z}var An=(t,e,r)=>{t.pos=e;for(var i=t.readVarint()+t.pos,n=1,a=0,s=0,o=0,l=1/0,u=-1/0,f=1/0,c=-1/0,d=[],g=[];t.pos<i;){if(a<=0){var w=t.readVarint();n=w&7,a=w>>3}if(a--,n===1||n===2)s+=t.readSVarint()*r,o+=t.readSVarint()*r,s<l&&(l=s),s>u&&(u=s),o<f&&(f=o),o>c&&(c=o),n===1&&(g.length>0&&d.push(g),g=[]),g.push(new we.default(s,o));else if(n===7)g&&g.push(g[0].clone());else throw new Error("unknown command "+n)}return g&&d.push(g),{geom:d,bbox:{minX:l,minY:f,maxX:u,maxY:c}}};function Dr(t,e){let r=new Tr.VectorTile(new Pr.default(t)),i=new Map;for(let[n,a]of Object.entries(r.layers)){let s=[],o=a;for(let l=0;l<o.length;l++){let u=An(o.feature(l)._pbf,o.feature(l)._geometry,e/o.extent),f=0;for(let c of u.geom)f+=c.length;s.push({id:o.feature(l).id,geomType:o.feature(l).type,geom:u.geom,numVertices:f,bbox:u.bbox,props:o.feature(l).properties})}i.set(n,s)}return i}var Ee=class{constructor(e,r){typeof e=="string"?this.p=new tt(e):this.p=e,this.controllers=[],this.shouldCancelZooms=r}get(e,r){return O(this,null,function*(){this.shouldCancelZooms&&(this.controllers=this.controllers.filter(s=>s[0]!=e.z?(s[1].abort(),!1):!0));let i=new AbortController;this.controllers.push([e.z,i]);let n=i.signal,a=yield this.p.getZxy(e.z,e.x,e.y,n);return a?Dr(a.data,r):new Map})}},rt=class{constructor(e,r){this.url=e,this.controllers=[],this.shouldCancelZooms=r}get(e,r){return O(this,null,function*(){this.shouldCancelZooms&&(this.controllers=this.controllers.filter(s=>s[0]!=e.z?(s[1].abort(),!1):!0));let i=this.url.replace("{z}",e.z.toString()).replace("{x}",e.x.toString()).replace("{y}",e.y.toString()),n=new AbortController;this.controllers.push([e.z,n]);let a=n.signal;return new Promise((s,o)=>{fetch(i,{signal:a}).then(l=>l.arrayBuffer()).then(l=>{let u=Dr(l,r);s(u)}).catch(l=>{o(l)})})})}},zt=6378137,Ar=85.0511287798,it=zt*Math.PI,Bn=t=>{let e=Math.PI/180,r=Math.max(Math.min(Ar,t[0]),-Ar),i=Math.sin(r*e);return new we.default(zt*t[1]*e,zt*Math.log((1+i)/(1-i))/2)};function Br(t){return t*t}function nt(t,e){return Br(t.x-e.x)+Br(t.y-e.y)}function En(t,e,r){var i=nt(e,r);if(i===0)return nt(t,e);var n=((t.x-e.x)*(r.x-e.x)+(t.y-e.y)*(r.y-e.y))/i;return n=Math.max(0,Math.min(1,n)),nt(t,new we.default(e.x+n*(r.x-e.x),e.y+n*(r.y-e.y)))}function St(t,e){for(var r=!1,i=0,n=e.length-1;i<e.length;n=i++){var a=e[i].x,s=e[i].y,o=e[n].x,l=e[n].y,u=s>t.y!=l>t.y&&t.x<(o-a)*(t.y-s)/(l-s)+a;u&&(r=!r)}return r}function Er(t){for(var e=0,r=0;r<t.length;r++){let i=(r+1)%t.length;e+=t[r].x*t[i].y,e-=t[i].x*t[r].y}return e<0}function Or(t,e){var r=!1;for(let i of e)if(Er(i))St(t,i)&&(r=!1);else{if(r)return!0;St(t,i)&&(r=!0)}return r}function Rr(t,e){let r=1/0;for(let i of e){let n=Math.sqrt(nt(t,i[0]));n<r&&(r=n)}return r}function Ir(t,e){let r=1/0;for(let n of e)for(var i=0;i<n.length-1;i++){let a=Math.sqrt(En(t,n[i],n[i+1]));a<r&&(r=a)}return r}var at=class{constructor(e,r){this.source=e,this.cache=new Map,this.inflight=new Map,this.tileSize=r}queryFeatures(e,r,i,n){let a=Bn([r,e]);var s=new we.default((a.x+it)/(it*2),1-(a.y+it)/(it*2));s.x>1&&(s.x=s.x-Math.floor(s.x));let o=s.mult(1<<i),l=Math.floor(o.x),u=Math.floor(o.y),f=se({z:i,x:l,y:u}),c=[],d=this.cache.get(f);if(d){let g=new we.default((o.x-l)*this.tileSize,(o.y-u)*this.tileSize);for(let[w,z]of d.data.entries())for(let h of z)h.geomType==1?Rr(g,h.geom)<n&&c.push({feature:h,layerName:w}):h.geomType==2?Ir(g,h.geom)<n&&c.push({feature:h,layerName:w}):Or(g,h.geom)&&c.push({feature:h,layerName:w})}return c}get(e){return O(this,null,function*(){let r=se(e);return new Promise((i,n)=>{let a=this.cache.get(r);if(a)a.used=performance.now(),i(a.data);else{let s=this.inflight.get(r);s?s.push([i,n]):(this.inflight.set(r,[]),this.source.get(e,this.tileSize).then(o=>{this.cache.set(r,{used:performance.now(),data:o});let l=this.inflight.get(r);if(l&&l.forEach(u=>u[0](o)),this.inflight.delete(r),i(o),this.cache.size>=64){let u=1/0,f;this.cache.forEach((c,d)=>{c.used<u&&(u=c.used,f=d)}),f&&this.cache.delete(f)}}).catch(o=>{let l=this.inflight.get(r);l&&l.forEach(u=>u[1](o)),this.inflight.delete(r),n(o)}))}})})}};var Oe=(t,e,r)=>{let i=[];for(let n of t){let a=[];for(let s of n)a.push(s.clone().mult(e).add(r));i.push(a)}return i},Re=(t,e)=>{let r=1<<e;return t<0&&(t=r+t),t>=r&&(t=t%r),t},Lt=class{constructor(e,r,i){this.tileCache=e,this.maxDataLevel=r,this.levelDiff=i}dataTilesForBounds(e,r){let i=Math.pow(2,e)/Math.pow(2,Math.ceil(e)),n=[];var a=1,s=this.tileCache.tileSize;if(e<this.levelDiff)a=1/(1<<this.levelDiff-e)*i,n.push({data_tile:{z:0,x:0,y:0},origin:new fe.default(0,0),scale:a,dim:s*a});else if(e<=this.levelDiff+this.maxDataLevel){let u=1<<this.levelDiff,f=256*i,c=Math.ceil(e)-this.levelDiff,d=Math.floor(r.minX/u/f),g=Math.floor(r.minY/u/f),w=Math.floor(r.maxX/u/f),z=Math.floor(r.maxY/u/f);for(var o=d;o<=w;o++)for(var l=g;l<=z;l++){let h=new fe.default(o*u*f,l*u*f);n.push({data_tile:{z:c,x:Re(o,c),y:Re(l,c)},origin:h,scale:i,dim:s*i})}}else{let u=1<<this.levelDiff;a=(1<<Math.ceil(e)-this.maxDataLevel-this.levelDiff)*i;let