From 5fe9682def085cac04d708c29f7fefdbb7590e52 Mon Sep 17 00:00:00 2001 From: Isaac Besora Vilardaga Date: Fri, 1 Apr 2022 17:21:24 +0200 Subject: [PATCH] feat(pick): Gets tile coords when picking features --- dist/protomaps.js | 16 +++++++++++++--- dist/protomaps.min.js | 2 +- dist/protomaps.module.js | 16 +++++++++++++--- dist/tilecache.d.ts | 3 +++ dist/tilecache.js | 16 +++++++++++++--- src/tilecache.ts | 19 ++++++++++++++++--- 6 files changed, 59 insertions(+), 13 deletions(-) diff --git a/dist/protomaps.js b/dist/protomaps.js index e3333f0b..6faaf6b1 100644 --- a/dist/protomaps.js +++ b/dist/protomaps.js @@ -3468,19 +3468,29 @@ var protomaps = (() => { }; for (let [layer_name, layer_arr] of entry.data.entries()) { for (let feature of layer_arr) { + let intersectedFeature; if (feature.geomType == 1) { if (pointMinDistToPoints(center, feature.geom) < brushSize) { - retval.push({ feature, layerName: layer_name }); + intersectedFeature = feature; } } else if (feature.geomType == 2) { if (pointMinDistToLines(center, feature.geom) < brushSize) { - retval.push({ feature, layerName: layer_name }); + intersectedFeature = feature; } } else { if (pointInPolygon(center, feature.geom)) { - retval.push({ feature, layerName: layer_name }); + intersectedFeature = feature; } } + if (intersectedFeature) { + retval.push({ + feature: intersectedFeature, + layerName: layer_name, + tileX: tile_x, + tileY: tile_y, + zoom + }); + } } } } diff --git a/dist/protomaps.min.js b/dist/protomaps.min.js index 5eec47a4..203cef80 100644 --- a/dist/protomaps.min.js +++ b/dist/protomaps.min.js @@ -1,4 +1,4 @@ -var protomaps=(()=>{var Ar=Object.create;var ye=Object.defineProperty;var Xr=Object.getOwnPropertyDescriptor;var Rr=Object.getOwnPropertyNames,zt=Object.getOwnPropertySymbols,Yr=Object.getPrototypeOf,St=Object.prototype.hasOwnProperty,Er=Object.prototype.propertyIsEnumerable;var Lt=(t,e,r)=>e in t?ye(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kt=(t,e)=>{for(var r in e||(e={}))St.call(e,r)&&Lt(t,r,e[r]);if(zt)for(var r of zt(e))Er.call(e,r)&&Lt(t,r,e[r]);return t};var Mt=t=>ye(t,"__esModule",{value:!0});var q=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ir=(t,e)=>{Mt(t);for(var r in e)ye(t,r,{get:e[r],enumerable:!0})},Vr=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Rr(e))!St.call(t,i)&&i!=="default"&&ye(t,i,{get:()=>e[i],enumerable:!(r=Xr(e,i))||r.enumerable});return t},V=t=>Vr(Mt(ye(t!=null?Ar(Yr(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var j=(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 W=q((tn,Pt)=>{"use strict";Pt.exports=se;function se(t,e){this.x=t,this.y=e}se.prototype={clone:function(){return new se(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}};se.convert=function(t){return t instanceof se?t:Array.isArray(t)?new se(t[0],t[1]):t}});var Ge=q((nn,Ct)=>{"use strict";var Nr=W();Ct.exports=oe;function oe(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(qr,this,e)}function qr(t,e,r){t==1?e.id=r.readVarint():t==2?jr(r,e):t==3?e.type=r.readVarint():t==4&&(e._geometry=r.pos)}function jr(t,e){for(var r=t.readVarint()+t.pos;t.pos>3}if(i--,r===1||r===2)n+=t.readSVarint(),a+=t.readSVarint(),r===1&&(o&&s.push(o),o=[]),o.push(new Nr(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};oe.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>3}if(i--,r===1||r===2)n+=t.readSVarint(),a+=t.readSVarint(),no&&(o=n),au&&(u=a);else if(r!==7)throw new Error("unknown command "+r)}return[s,l,o,u]};oe.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=oe.types[this.type],l,u;function h(p){for(var w=0;w{"use strict";var Ur=Ge();Bt.exports=Tt;function Tt(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(Zr,this,e),this.length=this._features.length}function Zr(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(Or(r))}function Or(t){for(var e=null,r=t.readVarint()+t.pos;t.pos>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}Tt.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 Ur(this._pbf,e,this.extent,this._keys,this._values)}});var At=q((sn,Dt)=>{"use strict";var Hr=Qe();Dt.exports=Jr;function Jr(t,e){this.layers=t.readFields(Gr,{},e)}function Gr(t,e,r){if(t===3){var i=new Hr(r,r.readVarint()+r.pos);i.length&&(e[i.name]=i)}}});var Xt=q((on,Be)=>{Be.exports.VectorTile=At();Be.exports.VectorTileFeature=Ge();Be.exports.VectorTileLayer=Qe()});var Rt=q(Ke=>{Ke.read=function(t,e,r,i,n){var a,s,o=n*8-i-1,l=(1<>1,h=-7,c=r?n-1:0,d=r?-1:1,p=t[e+c];for(c+=d,a=p&(1<<-h)-1,p>>=-h,h+=o;h>0;a=a*256+t[e+c],c+=d,h-=8);for(s=a&(1<<-h)-1,a>>=-h,h+=i;h>0;s=s*256+t[e+c],c+=d,h-=8);if(a===0)a=1-u;else{if(a===l)return s?NaN:(p?-1:1)*(1/0);s=s+Math.pow(2,i),a=a-u}return(p?-1:1)*s*Math.pow(2,a-i)};Ke.write=function(t,e,r,i,n,a){var s,o,l,u=a*8-n-1,h=(1<>1,d=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:a-1,w=i?1:-1,_=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=h):(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>=h?(o=0,s=h):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+p]=o&255,p+=w,o/=256,n-=8);for(s=s<0;t[r+p]=s&255,p+=w,s/=256,u-=8);t[r+p-w]|=_*128}});var qt=q((un,Nt)=>{"use strict";Nt.exports=k;var De=Rt();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 et=(1<<16)*(1<<16),Yt=1/et,Qr=12,Et=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>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=Ae(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Vt(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Ae(this.buf,this.pos)+Ae(this.buf,this.pos+4)*et;return this.pos+=8,t},readSFixed64:function(){var t=Ae(this.buf,this.pos)+Vt(this.buf,this.pos+4)*et;return this.pos+=8,t},readFloat:function(){var t=De.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=De.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,Kr(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>=Qr&&Et?ci(this.buf,e,t):di(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=O(this);for(t=t||[];this.pos127;);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;e268435455||t<0){ei(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=mi(this.buf,t,this.pos);var r=this.pos-e;r>=128&&It(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),De.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),De.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=128&&It(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,ii,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,ni,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,oi,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,ai,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,si,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,li,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,ui,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,hi,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,fi,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 Kr(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 le(t,n,e);throw new Error("Expected varint not more than 10 bytes")}function O(t){return t.type===k.Bytes?t.readVarint()+t.pos:t.pos+1}function le(t,e,r){return r?e*4294967296+(t>>>0):(e>>>0)*4294967296+(t>>>0)}function ei(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),ti(r,i,e),ri(i,e)}function ti(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 ri(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 It(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 ii(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function Vt(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function di(t,e,r){for(var i="",n=e;n239?4:a>223?3:a>191?2:1;if(n+o>r)break;var l,u,h;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],h=t[n+3],(l&192)==128&&(u&192)==128&&(h&192)==128&&(s=(a&15)<<18|(l&63)<<12|(u&63)<<6|h&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 ci(t,e,r){return Et.decode(t.subarray(e,r))}function mi(t,e,r){for(var i=0,n,a;i55295&&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 Ut=q(()=>{});var Zt=q((tt,rt)=>{(function(t,e){typeof tt=="object"&&typeof rt!="undefined"?rt.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=0)break;a[i]=h,i=u}a[i]=l};function e(r,i){return ri?1:0}return t})});var Ht=q((cn,it)=>{"use strict";var Xe=Zt();Xe.default&&(Xe=Xe.default);it.exports=Ot;it.exports.default=Ot;function Ot(t,e,r){e=e||1;for(var i,n,a,s,o=0;oa)&&(a=l[0]),(!o||l[1]>s)&&(s=l[1])}var u=a-i,h=s-n,c=Math.min(u,h),d=c/2;if(c===0){var p=[i,n];return p.distance=0,p}for(var w=new Xe(void 0,gi),_=i;_m.d&&(m=y);for(var g=w.length;w.length;){var b=w.pop();b.d>m.d&&(m=b,r&&console.log("found best %d after %d probes",Math.round(1e4*b.d)/1e4,g)),!(b.max-m.d<=e)&&(d=b.h/2,w.push(new Q(b.x-d,b.y-d,d,t)),w.push(new Q(b.x+d,b.y-d,d,t)),w.push(new Q(b.x-d,b.y+d,d,t)),w.push(new Q(b.x+d,b.y+d,d,t)),g+=4)}r&&(console.log("num probes: "+g),console.log("best distance: "+m.d));var x=[m.x,m.y];return x.distance=m.d,x}function gi(t,e){return e.max-t.max}function Q(t,e,r,i){this.x=t,this.y=e,this.h=r,this.d=wi(t,e,i),this.max=this.d+this.h*Math.SQRT2}function wi(t,e,r){for(var i=!1,n=1/0,a=0;ae!=c[1]>e&&t<(c[0]-h[0])*(e-h[1])/(c[1]-h[1])+h[0]&&(i=!i),n=Math.min(n,_i(t,e,h,c))}return n===0?0:(i?1:-1)*Math.sqrt(n)}function vi(t){for(var e=0,r=0,i=0,n=t[0],a=0,s=n.length,o=s-1;a1?(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 _r=q((mt,pt)=>{(function(t,e){typeof mt=="object"&&typeof pt!="undefined"?pt.exports=e():typeof define=="function"&&define.amd?define(e):(t=t||self).RBush=e()})(mt,function(){"use strict";function t(f,m,y,g,b){(function x(v,F,z,S,D){for(;S>z;){if(S-z>600){var P=S-z+1,A=F-z+1,pe=Math.log(P),K=.5*Math.exp(2*pe/3),ne=.5*Math.sqrt(pe*K*(P-K)/P)*(A-P/2<0?-1:1),ae=Math.max(z,Math.floor(F-A*K/P+ne)),Dr=Math.min(S,Math.floor(F+(P-A)*K/P+ne));x(v,F,ae,Dr,D)}var Te=v[F],be=z,N=S;for(e(v,z,F),D(v[S],Te)>0&&e(v,z,S);be0;)N--}D(v[z],Te)===0?e(v,z,N):e(v,++N,S),N<=F&&(z=N+1),F<=N&&(S=N-1)}})(f,m,y||0,g||f.length-1,b||r)}function e(f,m,y){var g=f[m];f[m]=f[y],f[y]=g}function r(f,m){return fm?1:0}var i=function(f){f===void 0&&(f=9),this._maxEntries=Math.max(4,f),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function n(f,m,y){if(!y)return m.indexOf(f);for(var g=0;g=f.minX&&m.maxY>=f.minY}function w(f){return{children:f,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function _(f,m,y,g,b){for(var x=[m,y];x.length;)if(!((y=x.pop())-(m=x.pop())<=g)){var v=m+Math.ceil((y-m)/g/2)*g;t(f,v,m,y,b),x.push(m,v,v,y)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(f){var m=this.data,y=[];if(!p(f,m))return y;for(var g=this.toBBox,b=[];m;){for(var x=0;x=0&&b[m].children.length>this._maxEntries;)this._split(b,m),m--;this._adjustParentBBoxes(g,b,m)},i.prototype._split=function(f,m){var y=f[m],g=y.children.length,b=this._minEntries;this._chooseSplitAxis(y,b,g);var x=this._chooseSplitIndex(y,b,g),v=w(y.children.splice(x,y.children.length-x));v.height=y.height,v.leaf=y.leaf,a(y,this.toBBox),a(v,this.toBBox),m?f[m-1].children.push(v):this._splitRoot(y,v)},i.prototype._splitRoot=function(f,m){this.data=w([f,m]),this.data.height=f.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(f,m,y){for(var g,b,x,v,F,z,S,D=1/0,P=1/0,A=m;A<=y-m;A++){var pe=s(f,0,A,this.toBBox),K=s(f,A,y,this.toBBox),ne=(b=pe,x=K,v=void 0,F=void 0,z=void 0,S=void 0,v=Math.max(b.minX,x.minX),F=Math.max(b.minY,x.minY),z=Math.min(b.maxX,x.maxX),S=Math.min(b.maxY,x.maxY),Math.max(0,z-v)*Math.max(0,S-F)),ae=h(pe)+h(K);ne=m;D--){var P=f.children[D];o(v,f.leaf?b(P):P),F+=c(v)}return F},i.prototype._adjustParentBBoxes=function(f,m,y){for(var g=y;g>=0;g--)o(m[g],f)},i.prototype._condense=function(f){for(var m=f.length-1,y=void 0;m>=0;m--)f[m].children.length===0?m>0?(y=f[m-1].children).splice(y.indexOf(f[m]),1):this.clear():a(f[m],this.toBBox)},i})});var Ki={};Ir(Ki,{BasemapLayerSourceName:()=>$,CenteredSymbolizer:()=>st,CenteredTextSymbolizer:()=>Z,CircleSymbolizer:()=>J,DataDrivenOffsetSymbolizer:()=>Ft,DataDrivenOffsetTextSymbolizer:()=>Br,FlexSymbolizer:()=>_e,Font:()=>Ji,GeomType:()=>Y,GroupSymbolizer:()=>Fe,GroupedLineSymbolizer:()=>nr,GroupedPolygonSymbolizer:()=>er,IconSymbolizer:()=>ar,Index:()=>bt,Justify:()=>R,Labeler:()=>yt,Labelers:()=>ke,LineLabelPlacement:()=>he,LineLabelSymbolizer:()=>fe,LineSymbolizer:()=>X,MAX_VERTICES_PER_DRAW_CALL:()=>H,OffsetSymbolizer:()=>ot,OffsetTextSymbolizer:()=>te,PMTiles:()=>ge,Padding:()=>or,PmtilesSource:()=>ze,PolygonLabelSymbolizer:()=>de,PolygonSymbolizer:()=>B,ShieldSymbolizer:()=>Ye,Sprites:()=>Gi,TextPlacements:()=>M,TextSymbolizer:()=>ee,TileCache:()=>$e,View:()=>ht,ZxySource:()=>Ne,arr:()=>Li,covering:()=>Sr,createPattern:()=>Si,cubicBezier:()=>Pi,dark:()=>Ue,exp:()=>I,filterFn:()=>Ce,getFont:()=>vt,isCCW:()=>Ie,isInRing:()=>ut,json_style:()=>Qi,labelRules:()=>Oe,leafletLayer:()=>Zi,light:()=>We,linear:()=>Mi,numberFn:()=>Je,numberOrFn:()=>gt,paintRules:()=>Ze,painter:()=>ct,pointInPolygon:()=>yr,pointMinDistToLines:()=>gr,pointMinDistToPoints:()=>xr,sourceToView:()=>Le,sourcesToViews:()=>ft,step:()=>ki,toIndex:()=>G,transformGeom:()=>ce,widthFn:()=>wt,wrap:()=>Se});var Cr=V(W());var re=V(W());var U;(function(n){n.TileFetchStart="tile-fetch-start",n.TileFetchEnd="tile-fetch-end",n.RerenderStart="rerender-start",n.RerenderEnd="rerender-end"})(U||(U={}));var Ve=V(W()),dr=V(Xt()),cr=V(qt());var pi=Object.defineProperty,bi=(t,e,r)=>e in t?pi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xe=(t,e,r)=>(bi(t,typeof e!="symbol"?e+"":e,r),r),jt=(t,e)=>t*Math.pow(2,e),$t=(t,e)=>jt(t.getUint16(e+1,!0),8)+t.getUint8(e,!0),yi=(t,e)=>jt(t.getUint32(e+2,!0),16)+t.getUint16(e,!0),xi=t=>{var e=t.getUint16(0,!0);if(e!==19792)throw new Error('File header does not begin with "PM"');var r=t.getUint16(2,!0),i=t.getUint32(4,!0),n=t.getUint16(8,!0);return{version:r,json_size:i,root_entries:n}},Wt=t=>{let e=new Map;for(var r=0;r>7,s=$t(t,r+1),o=$t(t,r+4),l=yi(t,r+7),u=t.getUint32(r+13,!0);e.set(n+"_"+s+"_"+o,[l,u,a])}return e},ge=class{constructor(e){xe(this,"metadata",n=>new Promise((a,s)=>{this.root.then(o=>{a(o.metadata)})})),xe(this,"getLeaf",(n,a)=>new Promise((s,o)=>{this.leaves.has(n)?(this.leaves.get(n)[0]++,s(this.leaves.get(n)[1])):this.outstanding_requests.has(n)?this.outstanding_requests.get(n).push(s):(this.outstanding_requests.set(n,[]),fetch(this.url,{headers:{Range:"bytes="+n+"-"+(n+a-1)}}).then(l=>l.arrayBuffer()).then(l=>{var u=Wt(new DataView(l),a/17);if(this.leaves.size>32){var h=1/0,c=void 0;this.leaves.forEach((d,p)=>{d[0]d(u)),this.outstanding_requests.delete(n)}))})),xe(this,"getZxy",(n,a,s)=>{var o=n+"_"+a+"_"+s;return this.root.then(l=>{if(l.dir.has(o)&&l.dir.get(o)[2]==0)return l.dir.get(o);if(n>=7){var u=n-7,h=[7,Math.trunc(a/(1<p.has(o)?p.get(o):null)}}return null})}),xe(this,"transformRequest",(n,a,s,o)=>{if(n.endsWith(".pmtiles")&&o){var l=s.tileID.canonical,u=l.z+"_"+l.x+"_"+l.y;this.getZxy(l.z,l.x,l.y).then(h=>{h&&o({url:this.url,headers:{Range:"bytes="+h[0]+"-"+(h[0]+h[1]-1)}})})}return{url:n}}),xe(this,"leafletLayer",n=>{let a=this;var s=L.GridLayer.extend({createTile:function(o,l){var u=document.createElement("img"),h;return a.getZxy(o.z,o.x,o.y).then(c=>{c!==null&&fetch(a.url,{headers:{Range:"bytes="+c[0]+"-"+(c[0]+c[1]-1)}}).then(d=>d.arrayBuffer()).then(d=>{var p=new Blob([d],{type:"image/png"}),w=window.URL.createObjectURL(p);u.src=w,l(h,u)})}),u},_removeTile:function(o){var l=this._tiles[o];!l||(l.el.width=0,l.el.height=0,l.el.deleted=!0,L.DomUtil.remove(l.el),delete this._tiles[o],this.fire("tileunload",{tile:l.el,coords:this._keyToTileCoords(o)}))}});return new s(n)}),this.url=e;let r=new AbortController,i=r.signal;this.root=fetch(this.url,{signal:i,headers:{Range:"bytes=0-511999"}}).then(n=>(n.headers.get("Content-Length")!=512e3&&(console.error("Content-Length mismatch indicates byte serving not supported; aborting."),r.abort()),n.arrayBuffer())).then(n=>{let a=xi(new DataView(n,0,10));var s=new TextDecoder("utf-8");return{metadata:JSON.parse(s.decode(new DataView(n,10,a.json_size))),dir:Wt(new DataView(n,10+a.json_size,17*a.root_entries))}}),this.step=0,this.leaves=new Map,this.outstanding_requests=new Map}};var E=V(W()),Qt=V(Ut());var Kt=V(Ht());var T=class{constructor(e,r=""){this.str=e||r,this.per_feature=typeof this.str=="function"&&this.str.length==2}get(e,r){return typeof this.str=="function"?this.str(e,r):this.str}},C=class{constructor(e,r=1){this.value=e||r,this.per_feature=typeof this.value=="function"&&this.value.length==2}get(e,r){return typeof this.value=="function"?this.value(e,r):this.value}},we=class{constructor(e={}){this.label_props=e.label_props||["name"],this.textTransform=e.textTransform,this.value=e.value}get(e,r){var i;if(this.value)i=this.value(e,r);else{var n;typeof this.label_props=="function"?n=this.label_props(e,r):n=this.label_props;for(let s of n)if(r.props.hasOwnProperty(s)){i=r.props[s],typeof i=="number"&&(i=`${i}`);break}}let a;return typeof this.textTransform=="function"?a=this.textTransform(e,r):a=this.textTransform,i&&a==="uppercase"?i=i.toUpperCase():i&&a==="lowercase"?i=i.toLowerCase():i&&a==="capitalize"&&(i=i.toLowerCase().split(" ").map(l=>l[0].toUpperCase()+l.slice(1)).join(" ")),i}},ve=class{constructor(e){e.font?this.font=e.font:(this.family=e.fontFamily||"sans-serif",this.size=e.fontSize||12,this.weight=e.fontWeight,this.style=e.fontStyle)}get(e,r){if(this.font)return typeof this.font=="function"?this.font(e,r):this.font;var i="";this.style&&(typeof this.style=="function"?i=this.style(e,r)+" ":i=this.style+" ");var n="";this.weight&&(typeof this.weight=="function"?n=this.weight(e,r)+" ":n=this.weight+" ");var a;typeof this.size=="function"?a=this.size(e,r):a=this.size;var s;return typeof this.family=="function"?s=this.family(e,r):s=this.family,`${i}${n}${a}px ${s}`}},Re=class{constructor(e,r=[]){this.value=e||r,this.per_feature=typeof this.value=="function"&&this.value.length==2}get(e,r){return typeof this.value=="function"?this.value(e,r):this.value}};function nt(t,e){if(t.length<=e)return[t];let r=e-1,i=t.lastIndexOf(" ",r),n=t.indexOf(" ",r);if(i==-1&&n==-1)return[t];let a,s;return n==-1||i>=0&&r-i{var i=[],n,a,s,o=0,l=0,u=0,h=0,c=0,d=0,p=0,w=0,_=0,f=0,m=0,y=0;if(t.length<2)return[];if(t.length===2)return u=Math.sqrt(Math.pow(t[1].x-t[0].x,2)+Math.pow(t[1].y-t[0].y,2)),[{length:u,beginIndex:0,beginDistance:0,endIndex:2,endDistance:u}];for(h=Math.sqrt(Math.pow(t[1].x-t[0].x,2)+Math.pow(t[1].y-t[0].y,2)),o=1,l=t.length-1;oe||u-y>r)&&(i.push({length:u-y,beginDistance:y,beginIndex:m,endIndex:o+1,endDistance:u}),m=o,y=u),h=c;return o-m>0&&i.push({length:u-y+c,beginIndex:m,beginDistance:y,endIndex:o+1,endDistance:u+c}),i};function Jt(t,e,r,i){let n,a,s=0,o=[];var l=-1/0;for(let h of t){let c=zi(h,Math.PI/45,e);for(let d of c)if(d.length>=e+i){let p=new at.default(h[d.beginIndex].x,h[d.beginIndex].y),w=h[d.endIndex-1],_=new at.default((w.x-p.x)/d.length,(w.y-p.y)/d.length);for(var u=i;u{let i=document.createElement("canvas"),n=i.getContext("2d");return i.width=t,i.height=e,r(i,n),i},B=class{constructor(e){this.pattern=e.pattern,this.fill=new T(e.fill,"black"),this.opacity=new C(e.opacity,1),this.stroke=new T(e.stroke,"black"),this.width=new C(e.width,0),this.per_feature=this.fill.per_feature||this.opacity.per_feature||this.stroke.per_feature||this.width.per_feature||e.per_feature,this.do_stroke=!1}before(e,r){if(!this.per_feature){e.globalAlpha=this.opacity.get(r),e.fillStyle=this.fill.get(r),e.strokeStyle=this.stroke.get(r);let i=this.width.get(r);i>0&&(this.do_stroke=!0),e.lineWidth=i}this.pattern&&(e.fillStyle=e.createPattern(this.pattern,"repeat"))}draw(e,r,i,n){var a=!1;if(this.per_feature){e.globalAlpha=this.opacity.get(i,n),e.fillStyle=this.fill.get(i,n);var s=this.width.get(i,n);s&&(a=!0,e.strokeStyle=this.stroke.get(i,n),e.lineWidth=s)}let o=()=>{e.fill(),(a||this.do_stroke)&&e.stroke()};var l=0;e.beginPath();for(var u of r){l+u.length>H&&(o(),l=0,e.beginPath());for(var h=0;h0&&o()}},er=class{constructor(e){this.pattern=e.pattern,this.fill=new T(e.fill,"black"),this.opacity=new C(e.opacity,1),this.stroke=new T(e.stroke,"black"),this.width=new C(e.width,0),this.do_stroke=!1}before(e,r){e.globalAlpha=this.opacity.get(r),e.fillStyle=this.fill.get(r),e.strokeStyle=this.stroke.get(r);let i=this.width.get(r);i>0&&(this.do_stroke=!0),e.lineWidth=i,this.pattern&&(e.fillStyle=e.createPattern(this.pattern,"repeat"))}drawGrouped(e,r,i,n,a,s){let o=()=>{e.fill(),this.do_stroke&&e.stroke()},l=0;e.save(),e.beginPath();for(let u of i)n(u)&&s(u)&&a(u.geom).forEach(c=>{l+c.length>H&&(o(),e.beginPath(),l=0),e.moveTo(c[0].x,c[0].y);for(var d=1;d{let i=r-t;return i>=0&&i{if(e.length<1)return 0;if(r<=e[0][0])return e[0][1];if(r>=e[e.length-1][0])return e[e.length-1][1];let i=tr(r,e),n=ir(r,i,t,e);return rr(n,e[i][1],e[i+1][1])}}function ki(t,e){return r=>{if(e.length<1)return 0;let i=t;for(let n=0;n=e[n][0]&&(i=e[n][1]);return i}}function Mi(t){return I(1,t)}function Pi(t,e,r,i,n){return a=>{if(n.length<1)return 0;let s=new Qt.default(t,e,r,i),o=tr(a,n),l=s.solve(ir(a,o,1,n));return rr(l,n[o][1],n[o+1][1])}}var X=class{constructor(e){this.color=new T(e.color,"black"),this.width=new C(e.width),this.opacity=new C(e.opacity),this.dash=e.dash?new Re(e.dash):null,this.dashColor=new T(e.dashColor,"black"),this.dashWidth=new C(e.dashWidth,1),this.lineCap=new T(e.lineCap,"butt"),this.lineJoin=new T(e.lineJoin,"miter"),this.skip=!1,this.per_feature=this.dash||this.color.per_feature||this.opacity.per_feature||this.width.per_feature||this.lineCap.per_feature||this.lineJoin.per_feature||e.per_feature}before(e,r){this.per_feature||(e.strokeStyle=this.color.get(r),e.lineWidth=this.width.get(r),e.globalAlpha=this.opacity.get(r),e.lineCap=this.lineCap.get(r),e.lineJoin=this.lineJoin.get(r))}draw(e,r,i,n){if(this.skip)return;let a=()=>{this.per_feature&&(e.globalAlpha=this.opacity.get(i,n),e.lineCap=this.lineCap.get(i,n),e.lineJoin=this.lineJoin.get(i,n)),this.dash?(e.lineWidth=this.dashWidth.get(i,n),e.strokeStyle=this.dashColor.get(i,n),e.setLineDash(this.dash.get(i,n))):this.per_feature&&(e.lineWidth=this.width.get(i,n),e.strokeStyle=this.color.get(i,n))};var s=0;e.save(),e.beginPath(),a();for(var o of r){s+o.length>H&&(e.stroke(),s=0,e.beginPath()),e.moveTo(o[0].x,o[0].y);for(var l=1;l0&&e.stroke(),e.restore()}},nr=class{constructor(e){this.color=new T(e.color,"black"),this.width=new C(e.width),this.opacity=new C(e.opacity),this.dash=e.dash?new Re(e.dash):null,this.dashColor=new T(e.dashColor,"black"),this.dashWidth=new C(e.dashWidth,1),this.lineCap=new T(e.lineCap,"butt"),this.lineJoin=new T(e.lineJoin,"miter"),this.skip=!1,this.per_feature=!1}before(e,r){e.strokeStyle=this.color.get(r),e.lineWidth=this.width.get(r),e.globalAlpha=this.opacity.get(r),e.lineCap=this.lineCap.get(r),e.lineJoin=this.lineJoin.get(r)}drawGrouped(e,r,i,n,a,s){if(this.skip)return;let o=u=>{this.dash&&(e.lineWidth=this.dashWidth.get(u),e.strokeStyle=this.dashColor.get(u),e.setLineDash(this.dash.get(u)))},l=0;e.save(),o(r),e.beginPath();for(let u of i)n(u)&&s(u)&&a(u.geom).forEach(c=>{l+c.length>H&&(e.stroke(),e.beginPath(),l=0),e.moveTo(c[0].x,c[0].y);for(var d=1;d{l.globalAlpha=1;let u=this.sprites.get(this.name);l.drawImage(u.canvas,u.x,u.y,u.w,u.h,-8,-8,u.w,u.h)}}]}},J=class{constructor(e){this.radius=new C(e.radius,3),this.fill=new T(e.fill,"black"),this.stroke=new T(e.stroke,"white"),this.width=new C(e.width,0),this.opacity=new C(e.opacity)}draw(e,r,i,n){e.globalAlpha=this.opacity.get(i,n);let a=this.radius.get(i,n),s=this.width.get(i,n);s>0&&(e.fillStyle=this.stroke.get(i,n),e.beginPath(),e.arc(r[0][0].x,r[0][0].y,a+s,0,2*Math.PI),e.fill()),e.fillStyle=this.fill.get(i,n),e.beginPath(),e.arc(r[0][0].x,r[0][0].y,a,0,2*Math.PI),e.fill()}place(e,r,i){let n=r[0],a=new E.default(r[0][0].x,r[0][0].y),s=this.radius.get(e.zoom,i),o={minX:a.x-s,minY:a.y-s,maxX:a.x+s,maxY:a.y+s};return[{anchor:a,bboxes:[o],draw:u=>{this.draw(u,[[new E.default(0,0)]],e.zoom,i)}}]}},Ye=class{constructor(e){this.font=new ve(e),this.text=new we(e),this.fill=new T(e.fill,"black"),this.background=new T(e.background,"white"),this.padding=new C(e.padding,0)}place(e,r,i){let n=this.text.get(e.zoom,i);if(!n)return;let a=this.font.get(e.zoom,i);e.scratch.font=a;let s=e.scratch.measureText(n),o=s.width,l=s.actualBoundingBoxAscent,u=s.actualBoundingBoxDescent,h=r[0],c=new E.default(r[0][0].x,r[0][0].y),d=this.padding.get(e.zoom,i),p={minX:c.x-o/2-d,minY:c.y-l-d,maxX:c.x+o/2+d,maxY:c.y+u+d};return[{anchor:c,bboxes:[p],draw:_=>{_.globalAlpha=1,_.fillStyle=this.background.get(e.zoom,i),_.fillRect(-o/2-d,-l-d,o+2*d,l+u+2*d),_.fillStyle=this.fill.get(e.zoom,i),_.font=a,_.fillText(n,-o/2,0)}}]}},_e=class{constructor(e,r){this.list=e}place(e,r,i){var n=this.list[0].place(e,r,i);if(!n)return;var a=n[0];let s=a.anchor,o=a.bboxes[0],l=o.maxY-o.minY,u=[{draw:a.draw,translate:{x:0,y:0}}],h=[[{x:r[0][0].x,y:r[0][0].y+l}]];for(let d=1;d{for(let p of u)d.save(),d.translate(p.translate.x,p.translate.y),p.draw(d),d.restore()}}]}},sr=(t,e)=>({minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}),Fe=class{constructor(e){this.list=e}place(e,r,i){let n=this.list[0];if(!n)return;var a=n.place(e,r,i);if(!a)return;var s=a[0];let o=s.anchor,l=s.bboxes[0],u=[s.draw];for(let c=1;c{u.forEach(d=>d(c))}}]}},st=class{constructor(e){this.symbolizer=e}place(e,r,i){let n=r[0][0],a=this.symbolizer.place(e,[[new E.default(0,0)]],i);if(!a||a.length==0)return;let s=a[0],o=s.bboxes[0],l=o.maxX-o.minX,u=o.maxY-o.minY,h={minX:n.x-l/2,maxX:n.x+l/2,minY:n.y-u/2,maxY:n.y+u/2};return[{anchor:n,bboxes:[h],draw:d=>{d.translate(-l/2,u/2-o.maxY),s.draw(d,{justify:2})}}]}},or=class{constructor(e,r){this.padding=new C(e,0),this.symbolizer=r}place(e,r,i){let n=this.symbolizer.place(e,r,i);if(!n||n.length==0)return;let a=this.padding.get(e.zoom,i);for(var s of n)for(var o of s.bboxes)o.minX-=a,o.minY-=a,o.maxX+=a,o.maxY+=a;return n}},ee=class{constructor(e){this.font=new ve(e),this.text=new we(e),this.fill=new T(e.fill,"black"),this.stroke=new T(e.stroke,"black"),this.width=new C(e.width,0),this.lineHeight=new C(e.lineHeight,1),this.letterSpacing=new C(e.letterSpacing,0),this.maxLineCodeUnits=new C(e.maxLineChars,15),this.justify=e.justify}place(e,r,i){let n=this.text.get(e.zoom,i);if(!n)return;let a=this.font.get(e.zoom,i);e.scratch.font=a;let s=this.letterSpacing.get(e.zoom,i),o=nt(n,this.maxLineCodeUnits.get(e.zoom,i));var l,u=0;for(let y of o)y.length>u&&(u=y.length,l=y);let h=e.scratch.measureText(l),c=h.width+s*(u-1),d=h.actualBoundingBoxAscent,p=h.actualBoundingBoxDescent,w=(d+p)*this.lineHeight.get(e.zoom,i),_=new E.default(r[0][0].x,r[0][0].y),f={minX:_.x,minY:_.y-d,maxX:_.x+c,maxY:_.y+p+(o.length-1)*w};return[{anchor:_,bboxes:[f],draw:(y,g)=>{y.globalAlpha=1,y.font=a,y.fillStyle=this.fill.get(e.zoom,i);let b=this.width.get(e.zoom,i);var x=0;for(let S of o){var v=0;if(this.justify==2||g&&g.justify==2?v=(c-y.measureText(S).width)/2:(this.justify==3||g&&g.justify==3)&&(v=c-y.measureText(S).width),b)if(y.lineWidth=b*2,y.strokeStyle=this.stroke.get(e.zoom,i),s>0){var F=v;for(var z of S)y.strokeText(z,F,x),F+=y.measureText(z).width+s}else y.strokeText(S,v,x);if(s>0){var F=v;for(var z of S)y.fillText(z,F,x),F+=y.measureText(z).width+s}else y.fillText(S,v,x);x+=w}}}]}},Z=class{constructor(e){this.centered=new st(new ee(e))}place(e,r,i){return this.centered.place(e,r,i)}},ot=class{constructor(e,r){this.symbolizer=e,this.offset=new C(r.offset,0)}place(e,r,i){if(i.geomType!==Y.Point)return;let n=r[0][0],a=this.symbolizer.place(e,[[new E.default(0,0)]],i);if(!a||a.length==0)return;let s=a[0],o=s.bboxes[0],l=this.offset.get(e.zoom,i),u=(w,_)=>({minX:w.x+_.x+o.minX,minY:w.y+_.y+o.minY,maxX:w.x+_.x+o.maxX,maxY:w.y+_.y+o.maxY});var h=new E.default(l,-l),c;let d=w=>{w.translate(h.x,h.y),s.draw(w,{justify:c})};var p=u(n,h);if(c=1,!e.index.bboxCollides(p,e.order))return[{anchor:n,bboxes:[p],draw:d}];if(h=new E.default(-l-o.maxX,l-o.minY),p=u(n,h),c=3,!e.index.bboxCollides(p,e.order))return[{anchor:n,bboxes:[p],draw:d}];if(h=new E.default(-l-o.maxX,-l),p=u(n,h),c=3,!e.index.bboxCollides(p,e.order))return[{anchor:n,bboxes:[p],draw:d}];if(h=new E.default(-l-o.maxX,l-o.minY),p=u(n,h),c=1,!e.index.bboxCollides(p,e.order))return[{anchor:n,bboxes:[p],draw:d}]}},te=class{constructor(e){this.symbolizer=new ot(new ee(e),e)}place(e,r,i){return this.symbolizer.place(e,r,i)}},he;(function(i){i[i.Above=1]="Above",i[i.Center=2]="Center",i[i.Below=3]="Below"})(he||(he={}));var fe=class{constructor(e){this.font=new ve(e),this.text=new we(e),this.fill=new T(e.fill,"black"),this.stroke=new T(e.stroke,"black"),this.width=new C(e.width,0),this.offset=new C(e.offset,0),this.position=e.position||1,this.maxLabelCodeUnits=new C(e.maxLabelChars,40),this.repeatDistance=new C(e.repeatDistance,250)}place(e,r,i){let n=this.text.get(e.zoom,i);if(!n||n.length>this.maxLabelCodeUnits.get(e.zoom,i))return;let a=20,s=i.bbox;if(s.maxY-s.minY4&&(c*=1<({minX:x.x-d/2,minY:x.y-d/2,maxX:x.x+d/2,maxY:x.y+d/2})),b=x=>{x.globalAlpha=1;let v=0;this.position===3?v=h:this.position===2&&(v=h/2);let F=Math.atan2(-m,f);x.translate(Math.cos(F-Math.PI/2)*v,-Math.sin(F-Math.PI/2)*v),x.rotate(-F),f<0&&(x.scale(-1,-1),x.translate(-u,2*v)),x.translate(0,-this.offset.get(e.zoom,i)),x.font=o;let z=this.width.get(e.zoom,i);z&&(x.lineWidth=z,x.strokeStyle=this.stroke.get(e.zoom,i),x.strokeText(n,0,0)),x.fillStyle=this.fill.get(e.zoom,i),x.fillText(n,0,0)};w.push({anchor:_.start,bboxes:g,draw:b,deduplicationKey:n,deduplicationDistance:c})}return w}},de=class{constructor(e){this.symbolizer=new ee(e)}place(e,r,i){let n=i.bbox;if((n.maxY-n.minY)*(n.maxX-n.minX)<2e4)return;let s=this.symbolizer.place(e,[[new E.default(0,0)]],i);if(!s||s.length==0)return;let o=s[0],l=o.bboxes[0],u=r[0],h=(0,Kt.default)([u.map(w=>[w.x,w.y])]),c=new E.default(h[0],h[1]),d={minX:c.x-(l.maxX-l.minX)/2,minY:c.y-(l.maxY-l.minY)/2,maxX:c.x+(l.maxX-l.minX)/2,maxY:c.y+(l.maxY-l.minY)/2};return[{anchor:c,bboxes:[d],draw:w=>{w.translate(o.anchor.x-(l.maxX-l.minX)/2,o.anchor.y),o.draw(w)}}]}};var Ee=(t,e)=>t[1].area-e[1].area;function Ci(){var t={},e=[];t.push=function(){for(var n=0,a=arguments.length;n0;){var s=(n+1>>1)-1,o=e[s];if(Ee(a,o)>=0)break;e[o.index=n]=o,e[a.index=n=s]=a}}function i(n){for(var a=e[n];;){var s=(n+1)*2,o=s-1,l=n,u=e[l];if(oMath.abs((t[0].x-t[2].x)*(t[1].y-t[0].y)-(t[0].x-t[1].x)*(t[2].y-t[0].y)),ur=(t,e)=>{let r=[];for(let s of t){let o=Ti(s,e);r=r.concat(o)}if(e>=r.length)return t;r.sort(function(s,o){return o-s});let i=[],n=r[e],a=0;for(let s of t){let o=s.filter(function(l){return l.area>n});o.length>=3&&(i.push(o),a+=o.length)}return i},Ti=(t,e)=>{var r=0;let i=Ci();var n;let a=[];for(var s=1,o=t.length-1;s0?h.area:1/0});return u},hr=(t,e)=>{let r=[];var i=[];let n=0;for(let s of t){var a=s;s.length>e&&(console.log("LineString with length: ",s.length),a=ur(s,e)),i.length>0&&n+a.length>e&&(r.push(i),i=[],n=0),i.push(a),n+=s.length}return i.length>0&&r.push(i),r},Bi=t=>{var e=0;for(let r of t)e+=r.length;return e},fr=(t,e)=>{let r=[],i=[];for(let u of t)i.length>0&&!Ie(u)&&(r.push(i),i=[]),i.push(u);i.length>0&&r.push(i);let n=[];var a=[],s=0;for(let u of r){var o=u,l=Bi(u);l>e&&(o=ur(u,e),l=e),a.length>0&&s+l>e&&(n.push(a),a=[],s=0),a=a.concat(o),s+=l}return a.length>0&&n.push(a),n};var Y;(function(i){i[i.Point=1]="Point",i[i.Line=2]="Line",i[i.Polygon=3]="Polygon"})(Y||(Y={}));function G(t){return t.x+":"+t.y+":"+t.z}var Di=(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,h=1/0,c=-1/0,d=[],p;t.pos>3}if(a--,n===1||n===2)s+=t.readSVarint()*r,o+=t.readSVarint()*r,su&&(u=s),oc&&(c=o),n===1&&(p&&d.push(p),p=[]),p.push(new Ve.default(s,o));else if(n===7)p&&p.push(p[0].clone());else throw new Error("unknown command "+n)}return p&&d.push(p),{geom:d,bbox:{minX:l,minY:h,maxX:u,maxY:c}}};function mr(t,e){let r=new dr.VectorTile(new cr.default(t)),i=new Map;for(let[n,a]of Object.entries(r.layers)){let s=[],o=a;for(let l=0;lH&&o.feature(l).type!=1){o.feature(l).type==2?c=hr(u.geom,H):c=fr(u.geom,H);for(let d of c)s.push({id:o.feature(l).id,geomType:o.feature(l).type,geom:d,numVertices:h,bbox:u.bbox,props:o.feature(l).properties})}else s.push({id:o.feature(l).id,geomType:o.feature(l).type,geom:u.geom,numVertices:h,bbox:u.bbox,props:o.feature(l).properties})}i.set(n,s)}return i}var ze=class{constructor(e,r){e.url?this.p=e:this.p=new ge(e),this.controllers=[],this.shouldCancelZooms=r}get(e,r){return j(this,null,function*(){this.shouldCancelZooms&&(this.controllers=this.controllers.filter(s=>s[0]!=e.z?(s[1].abort(),!1):!0));let i=yield this.p.getZxy(e.z,e.x,e.y);if(!i)throw new Error(`Tile ${e.z} ${e.x} ${e.y} not found in archive`);let n=new AbortController;this.controllers.push([e.z,n]);let a=n.signal;return new Promise((s,o)=>{fetch(this.p.url,{headers:{Range:"bytes="+i[0]+"-"+(i[0]+i[1]-1)},signal:a}).then(l=>l.arrayBuffer()).then(l=>{let u=mr(l,r);s(u)}).catch(l=>{o(l)})})})}},Ne=class{constructor(e,r){this.url=e,this.controllers=[],this.shouldCancelZooms=r}get(e,r){return j(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=mr(l,r);s(u)}).catch(l=>{o(l)})})})}},lt=6378137,pr=85.0511287798,qe=lt*Math.PI,Ai=t=>{let e=Math.PI/180,r=Math.max(Math.min(pr,t[0]),-pr),i=Math.sin(r*e);return new Ve.default(lt*t[1]*e,lt*Math.log((1+i)/(1-i))/2)};function br(t){return t*t}function je(t,e){return br(t.x-e.x)+br(t.y-e.y)}function Xi(t,e,r){var i=je(e,r);if(i===0)return je(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)),je(t,{x:e.x+n*(r.x-e.x),y:e.y+n*(r.y-e.y)})}function ut(t,e){for(var r=!1,i=0,n=e.length-1;it.y!=l>t.y&&t.x<(o-a)*(t.y-s)/(l-s)+a;u&&(r=!r)}return r}function Ie(t){for(var e=0,r=0;r1&&(s.x=s.x-Math.floor(s.x));let o=s.mult(1<{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,h;this.cache.forEach((c,d)=>{c.used{let l=this.inflight.get(r);l&&l.forEach(u=>u[1](o)),this.inflight.delete(r),n(o)}))}})})}};var ce=(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},Se=(t,e)=>{let r=1<=r&&(t=t%r),t},ht=class{constructor(e,r,i,n){this.tileCache=e,this.maxDataLevel=r,this.levelDiff=i,this.eventQueue=n}dataTilesForBounds(e,r){let i=Math.pow(2,e)/Math.pow(2,Math.ceil(e)),n=[];var a=1,s=this.tileCache.tileSize;if(ethis.tileCache.get(o.data_tile)));return(s=this.eventQueue)==null||s.publish(U.TileFetchEnd),n.map((o,l)=>{let u=i[l];return{data:o,z:e,data_tile:u.data_tile,scale:u.scale,dim:u.dim,origin:u.origin}})})}getDisplayTile(e){return j(this,null,function*(){let r=this.dataTileForDisplayTile(e);return{data:yield this.tileCache.get(r.data_tile),z:e.z,data_tile:r.data_tile,scale:r.scale,origin:r.origin,dim:r.dim}})}queryFeatures(e,r,i){let n=Math.round(i),a=Math.min(n-this.levelDiff,this.maxDataLevel),s=16/(1<{let e=t.levelDiff===void 0?2:t.levelDiff,r=t.maxDataZoom===void 0?14:t.maxDataZoom,i;t.url.url?i=new ze(t.url,!0):t.url.endsWith(".pmtiles")?i=new ze(t.url,!0):i=new Ne(t.url,!0);let n=new $e(i,256*1<{let e=new Map;if(t.sources)for(let[r,i]of Object.entries(t.sources))e.set(r,Le(i));else e.set($,Le(t));return e};var dt=V(W());var wr=(t,e,r,i)=>{let n=t.bbox;return!(n.maxX*e+r.xi.maxX||n.minY*e+r.y>i.maxY||n.maxY*e+r.y[{dataSource:t,dataLayer:e,symbolizer:new J({opacity:.7,fill:r,radius:4}),filter:(i,n)=>n.geomType==Y.Point},{dataSource:t,dataLayer:e,symbolizer:new X({opacity:.5,color:r,width:2}),filter:(i,n)=>n.geomType==Y.Line},{dataSource:t,dataLayer:e,symbolizer:new B({opacity:.5,fill:r,stroke:r,width:1}),filter:(i,n)=>n.geomType==Y.Polygon}],Ri=(t,e)=>{var r=[];for(var[i,n]of t)for(var a of n.data.keys())i===e.dataSource&&a===e.dataLayer||(r=r.concat(vr(i,a,"#999")));return r=r.concat(vr(e.dataSource||"",e.dataLayer,"steelblue")),r};function ct(t,e,r,i,n,a,s,o,l,u){let h=performance.now();t.save(),t.miterLimit=2;for(var c of r){u&&(n=Ri(c,u));for(var d of n){if(d.minzoom&&ed.maxzoom)continue;let f=c.get(d.dataSource||$);if(!f)continue;var p=f.data.get(d.dataLayer);if(p===void 0)continue;d.symbolizer.before&&d.symbolizer.before(t,f.z),t.save();let m=f.origin,y=f.dim,g=f.scale;if(t.translate(m.x-s.x,m.y-s.y),d.symbolizer.drawGrouped)d.symbolizer.drawGrouped(t,f.z,p,b=>wr(b,g,m,a),g!=1?b=>ce(b,g,new dt.default(0,0)):b=>b,b=>d.filter?d.filter(f.z,b):!0);else if(d.symbolizer.draw)for(var w of p){let b=w.geom;!wr(w,g,m,a)||d.filter&&!d.filter(f.z,w)||(g!=1&&(b=ce(b,g,new dt.default(0,0))),d.symbolizer.draw(t,b,f.z,w))}t.restore()}}if(o&&(t.beginPath(),t.rect(a.minX-s.x,a.minY-s.y,a.maxX-a.minX,a.maxY-a.minY),t.clip()),i&&!u){let f=i.searchBbox(a,1/0);for(var _ of f)if(t.save(),t.translate(_.anchor.x-s.x,_.anchor.y-s.y),_.draw(t),t.restore(),l){t.lineWidth=.5,t.strokeStyle=l,t.fillStyle=l,t.globalAlpha=1,t.fillRect(_.anchor.x-s.x-2,_.anchor.y-s.y-2,4,4);for(let m of _.bboxes)t.strokeRect(m.minX-s.x,m.minY-s.y,m.maxX-m.minX,m.maxY-m.minY)}}return t.restore(),performance.now()-h}var Fr=V(W());var zr=V(_r()),Sr=(t,e,r)=>{let i=256,n=e/i,a=Math.floor(r.minX/i),s=Math.floor(r.minY/i),o=Math.floor(r.maxX/i),l=Math.floor(r.maxY/i),u=Math.log2(n),h=[];for(let c=a;c<=o;c++){let d=c%(1<this.dim&&(o=!0)}if(s||o){var u=s?this.dim:-this.dim,h=[];for(let p of e.bboxes)h.push({minX:p.minX+u,minY:p.minY,maxX:p.maxX+u,maxY:p.maxY});let c={anchor:new Fr.default(e.anchor.x+u,e.anchor.y),bboxes:h,draw:e.draw,order:r,tileKey:i},d=this.current.get(i);d&&d.add(c);for(let p of h){var l=p;l.indexed_label=c,this.tree.insert(l)}}}pruneOrNoop(e){let r=e.split(":"),i,n=0,a=0;for(var s of this.current.keys()){let o=s.split(":");if(o[3]===r[3]){a++;let l=Math.sqrt(Math.pow(+o[0]-+r[0],2)+Math.pow(+o[1]-+r[1],2));l>n&&(n=l,i=s)}i&&a>this.maxLabeledTiles&&this.pruneKey(i)}}pruneKey(e){let r=this.current.get(e);if(!r)return;let i=[];for(let n of this.tree.all())r.has(n.indexed_label)&&i.push(n);i.forEach(n=>{this.tree.remove(n)}),this.current.delete(e)}removeLabel(e){let r=[];for(let n of this.tree.all())e==n.indexed_label&&r.push(n);r.forEach(n=>{this.tree.remove(n)});let i=this.current.get(e.tileKey);i&&i.delete(e)}},yt=class{constructor(e,r,i,n,a){this.index=new bt(256*1<l.maxzoom)continue;let u=l.dataSource||$,h=e.get(u);if(!h)continue;let c=G(h.data_tile)+":"+u;if(!i.has(c))continue;let d=h.data.get(l.dataLayer);if(d===void 0)continue;let p=d;l.sort&&p.sort((_,f)=>l.sort?l.sort(_.props,f.props):0);let w={index:this.index,zoom:this.z,scratch:this.scratch,order:o,overzoom:this.z-h.data_tile.z};for(let _ of p){if(l.filter&&!l.filter(this.z,_))continue;let f=ce(_.geom,h.scale,h.origin),m=l.symbolizer.place(w,f,_);if(!!m)for(let y of m){var a=!1;if(!(y.deduplicationKey&&this.index.deduplicationCollides(y))){if(this.index.labelCollides(y,1/0)){if(!this.index.labelCollides(y,o)){let g=this.index.searchLabel(y,1/0);for(let b of g){this.index.removeLabel(b);for(let x of b.bboxes)this.findInvalidatedTiles(n,h.dim,x,c)}this.index.insert(y,o,c),a=!0}}else this.index.insert(y,o,c),a=!0;if(a)for(let g of y.bboxes)(g.maxX>h.origin.x+h.dim||g.minXh.origin.y+h.dim)&&this.findInvalidatedTiles(n,h.dim,g,c)}}}}for(var s of i)this.index.pruneOrNoop(s);return n.size>0&&this.callback&&this.callback(n),performance.now()-r}findInvalidatedTiles(e,r,i,n){let a=Sr(this.z,r,i);for(let s of a)s.key!=n&&this.index.has(s.key)&&e.add(s.display)}add(e){var r=!0;for(let[i,n]of e)this.index.has(G(n.data_tile)+":"+i)||(r=!1);return r?0:this.layout(e)}},ke=class{constructor(e,r,i,n){this.labelers=new Map,this.scratch=e,this.labelRules=r,this.maxLabeledTiles=i,this.callback=n}add(e,r){var i=this.labelers.get(e);return i||(i=new yt(e,this.scratch,this.labelRules,this.maxLabeledTiles,this.callback),this.labelers.set(e,i)),i.add(r)}getIndex(e){let r=this.labelers.get(e);if(r)return r.index}};var We={earth:"#FFFBF6",glacier:"#ffffff",residential:"#F4F4F8",hospital:"#FFF6F6",cemetery:"#EFF2EE",school:"#F7F6FF",industrial:"#FFF9EF",wood:"#F4F9EF",grass:"#EBF9E3",park:"#E5F9D5",water:"#B7DFF2",sand:"#ebebeb",buildings:"#F2EDE8",highwayCasing:"#FFC3C3",majorRoadCasing:"#FFB9B9",mediumRoadCasing:"#FFCE8E",minorRoadCasing:"#cccccc",highway:"#FFCEBB",majorRoad:"#FFE4B3",mediumRoad:"#FFF2C8",minorRoad:"#ffffff",boundaries:"#9e9e9e",mask:"#dddddd",countryLabel:"#aaaaaa",cityLabel:"#6C6C6C",stateLabel:"#999999",neighbourhoodLabel:"#888888",landuseLabel:"#898989",waterLabel:"#41ABDC",naturalLabel:"#4B8F14",roadsLabel:"#888888",poisLabel:"#606060"};var Ue={earth:"#151515",glacier:"#1c1c1c",residential:"#252B2F",hospital:"#3E2C2C",cemetery:"#36483D",school:"#2C3440",industrial:"#33312C",wood:"#3A3E38",grass:"#4E604D",park:"#2C4034",water:"#4D5B73",sand:"#777777",buildings:"#464545",highwayCasing:"#000000",majorRoadCasing:"#1C1B1B",mediumRoadCasing:"#3E3E3E",minorRoadCasing:"#000000",highway:"#5B5B5B",majorRoad:"#595959",mediumRoad:"#4F4F4F",minorRoad:"#393939",boundaries:"#666666",mask:"#dddddd",countryLabel:"#ffffff",cityLabel:"#FFFFFF",stateLabel:"#ffffff",neighbourhoodLabel:"#FDFDFD",landuseLabel:"#DDDDDD",waterLabel:"#707E95",naturalLabel:"#4c4c4c",roadsLabel:"#C4C4C4",poisLabel:"#959393"};function Me(t,e,r){return Math.min(Math.max(t,r),e)}var me=class extends Error{constructor(e){super(`Failed to parse color: "${e}"`)}};function Yi(t){if(typeof t!="string")throw new me(t);if(t.trim().toLowerCase()==="transparent")return[0,0,0,0];let e=t.trim();e=ji.test(t)?function(s){let o=s.toLowerCase().trim(),l=Ei[function(u){let h=5381,c=u.length;for(;c;)h=33*h^u.charCodeAt(--c);return(h>>>0)%2341}(o)];if(!l)throw new me(s);return`#${l}`}(t):t;let r=Ii.exec(e);if(r){let s=Array.from(r).slice(1);return[...s.slice(0,3).map(o=>parseInt(Pe(o,2),16)),parseInt(Pe(s[3]||"f",2),16)/255]}let i=Vi.exec(e);if(i){let s=Array.from(i).slice(1);return[...s.slice(0,3).map(o=>parseInt(o,16)),parseInt(s[3]||"ff",16)/255]}let n=Ni.exec(e);if(n){let s=Array.from(n).slice(1);return[...s.slice(0,3).map(o=>parseInt(o,10)),parseFloat(s[3]||"1")]}let a=qi.exec(e);if(a){let[s,o,l,u]=Array.from(a).slice(1).map(parseFloat);if(Me(0,100,o)!==o)throw new me(t);if(Me(0,100,l)!==l)throw new me(t);return[...$i(s,o,l),u||1]}throw new me(t)}var Lr=t=>parseInt(t.replace(/_/g,""),36),Ei="1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm".split(" ").reduce((t,e)=>{let r=Lr(e.substring(0,3)),i=Lr(e.substring(3)).toString(16),n="";for(let a=0;a<6-i.length;a++)n+="0";return t[r]=`${n}${i}`,t},{}),Pe=(t,e)=>Array.from(Array(e)).map(()=>t).join(""),Ii=new RegExp(`^#${Pe("([a-f0-9])",3)}([a-f0-9])?$`,"i"),Vi=new RegExp(`^#${Pe("([a-f0-9]{2})",3)}([a-f0-9]{2})?$`,"i"),Ni=new RegExp(`^rgba?\\(\\s*(\\d+)\\s*${Pe(",\\s*(\\d+)\\s*",2)}(?:,\\s*([\\d.]+))?\\s*\\)$`,"i"),qi=/^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i,ji=/^[a-z]+$/i,kr=t=>Math.round(255*t),$i=(t,e,r)=>{let i=r/100;if(e===0)return[i,i,i].map(kr);let n=(t%360+360)%360/60,a=(1-Math.abs(2*i-1))*(e/100),s=a*(1-Math.abs(n%2-1)),o=0,l=0,u=0;n>=0&&n<1?(o=a,l=s):n>=1&&n<2?(o=s,l=a):n>=2&&n<3?(l=a,u=s):n>=3&&n<4?(l=s,u=a):n>=4&&n<5?(o=s,u=a):n>=5&&n<6&&(o=a,u=s);let h=i-a/2;return[o+h,l+h,u+h].map(kr)};function xt(t){let[e,r,i,n]=Yi(t).map((u,h)=>h===3?u:u/255),a=Math.max(e,r,i),s=Math.min(e,r,i),o=(a+s)/2;if(a===s)return[0,0,o,n];let l=a-s;return[60*(e===a?(r-i)/l+(r.5?l/(2-a-s):l/(a+s),o,n]}function Mr(t,e,r,i){return`hsla(${(t%360).toFixed()}, ${Me(0,100,100*e).toFixed()}%, ${Me(0,100,100*r).toFixed()}%, ${parseFloat(Me(0,1,i).toFixed(3))})`}var Pr=(t,e)=>{let r=xt(e),i=kt({},t);for(let[n,a]of Object.entries(t)){let s=xt(a);i[n]=Mr(r[0],r[1],s[2],s[3])}return i},Ze=(t,e)=>(e&&(t=Pr(t,e)),[{dataLayer:"earth",symbolizer:new B({fill:t.earth})},{dataLayer:"natural",symbolizer:new B({fill:t.glacier}),filter:(r,i)=>i.props.natural=="glacier"},{dataLayer:"landuse",symbolizer:new B({fill:t.residential}),filter:(r,i)=>i.props.landuse=="residential"||i.props.place=="neighbourhood"},{dataLayer:"landuse",symbolizer:new B({fill:t.hospital}),filter:(r,i)=>i.props.amenity=="hospital"},{dataLayer:"landuse",symbolizer:new B({fill:t.cemetery}),filter:(r,i)=>i.props.landuse=="cemetery"},{dataLayer:"landuse",symbolizer:new B({fill:t.school}),filter:(r,i)=>i.props.amenity=="school"||i.props.amenity=="kindergarten"||i.props.amenity=="university"||i.props.amenity=="college"},{dataLayer:"landuse",symbolizer:new B({fill:t.industrial}),filter:(r,i)=>i.props.landuse=="industrial"},{dataLayer:"natural",symbolizer:new B({fill:t.wood}),filter:(r,i)=>i.props.natural=="wood"},{dataLayer:"landuse",symbolizer:new B({fill:t.grass}),filter:(r,i)=>i.props.landuse=="grass"},{dataLayer:"landuse",symbolizer:new B({fill:t.park}),filter:(r,i)=>i.props.leisure=="park"},{dataLayer:"water",symbolizer:new B({fill:t.water})},{dataLayer:"natural",symbolizer:new B({fill:t.sand}),filter:(r,i)=>i.props.natural=="sand"},{dataLayer:"buildings",symbolizer:new B({fill:t.buildings})},{dataLayer:"roads",symbolizer:new X({color:t.highwayCasing,width:I(1.4,[[5,1.5],[11,4],[16,9],[20,40]])}),filter:(r,i)=>i.props["pmap:kind"]=="highway"},{dataLayer:"roads",symbolizer:new X({color:t.majorRoadCasing,width:I(1.4,[[9,3],[12,4],[17,8],[20,22]])}),filter:(r,i)=>i.props["pmap:kind"]=="major_road"},{dataLayer:"roads",symbolizer:new X({color:t.mediumRoadCasing,width:I(1.4,[[13,3],[17,6],[20,18]])}),filter:(r,i)=>i.props["pmap:kind"]=="medium_road"},{dataLayer:"roads",symbolizer:new X({color:t.minorRoadCasing,width:I(1.4,[[14,2],[17,5],[20,15]])}),filter:(r,i)=>i.props["pmap:kind"]=="minor_road"},{dataLayer:"roads",symbolizer:new X({color:t.minorRoad,width:I(1.4,[[14,1],[17,3],[20,13]])}),filter:(r,i)=>i.props["pmap:kind"]=="minor_road"},{dataLayer:"roads",symbolizer:new X({color:t.mediumRoad,width:I(1.4,[[13,2],[17,4],[20,15]])}),filter:(r,i)=>i.props["pmap:kind"]=="medium_road"},{dataLayer:"roads",symbolizer:new X({color:t.majorRoad,width:I(1.4,[[9,2],[12,3],[17,6],[20,20]])}),filter:(r,i)=>i.props["pmap:kind"]=="major_road"},{dataLayer:"roads",symbolizer:new X({color:t.highway,width:I(1.4,[[5,.5],[11,2.5],[16,7],[20,30]])}),filter:(r,i)=>i.props["pmap:kind"]=="highway"},{dataLayer:"boundaries",symbolizer:new X({color:t.boundaries,width:2,opacity:.4})},{dataLayer:"mask",symbolizer:new B({fill:t.mask})}]),Oe=(t,e,r,i)=>{e&&(t=Pr(t,e));var n=["name"];r&&(n=r);let a=(s,o)=>i?s instanceof te?new _e([s,new te({fill:o,label_props:i})],{}):new _e([s,new Z({fill:o,label_props:i})],{}):s;return[{dataLayer:"places",symbolizer:a(new Z({label_props:n,fill:t.countryLabel,lineHeight:1.5,font:(s,o)=>s<6?"200 14px sans-serif":"200 20px sans-serif",textTransform:"uppercase"}),t.countryLabel),filter:(s,o)=>o.props["pmap:kind"]=="country"},{dataLayer:"places",symbolizer:a(new Z({label_props:n,fill:t.stateLabel,font:"300 16px sans-serif"}),t.stateLabel),filter:(s,o)=>o.props["pmap:kind"]=="state"},{id:"cities_high",dataLayer:"places",filter:(s,o)=>o.props["pmap:kind"]=="city",minzoom:7,symbolizer:a(new Z({label_props:n,fill:t.cityLabel,font:(s,o)=>o.props["pmap:rank"]==1?s>8?"600 20px sans-serif":"600 12px sans-serif":s>8?"600 16px sans-serif":"600 10px sans-serif"}),t.cityLabel),sort:(s,o)=>s["pmap:rank"]-o["pmap:rank"]},{id:"cities_low",dataLayer:"places",filter:(s,o)=>o.props["pmap:kind"]=="city",maxzoom:6,symbolizer:new Fe([new J({radius:2,fill:t.cityLabel}),a(new te({label_props:n,fill:t.cityLabel,offset:2,font:(s,o)=>o.props["pmap:rank"]==1?s>8?"600 20px sans-serif":"600 12px sans-serif":s>8?"600 16px sans-serif":"600 10px sans-serif"}),t.cityLabel)]),sort:(s,o)=>s["pmap:rank"]-o["pmap:rank"]},{id:"neighbourhood",dataLayer:"places",symbolizer:a(new Z({label_props:n,fill:t.neighbourhoodLabel,font:"500 10px sans-serif",textTransform:"uppercase"}),t.neighbourhoodLabel),filter:(s,o)=>o.props["pmap:kind"]=="neighbourhood"},{dataLayer:"landuse",symbolizer:a(new de({label_props:n,fill:t.landuseLabel,font:"300 12px sans-serif"}),t.landuseLabel)},{dataLayer:"water",symbolizer:a(new de({label_props:n,fill:t.waterLabel,font:"italic 600 12px sans-serif"}),t.waterLabel)},{dataLayer:"natural",symbolizer:a(new de({label_props:n,fill:t.naturalLabel,font:"italic 300 12px sans-serif"}),t.naturalLabel)},{dataLayer:"roads",symbolizer:a(new fe({label_props:n,fill:t.roadsLabel,font:"500 12px sans-serif"}),t.roadsLabel),minzoom:12},{dataLayer:"roads",symbolizer:new Ye({label_props:["ref"],font:"600 9px sans-serif",background:t.highway,padding:2,fill:t.neighbourhoodLabel}),filter:(s,o)=>o.props["pmap:kind"]=="highway"},{dataLayer:"pois",symbolizer:new Fe([new J({radius:2,fill:t.poisLabel}),a(new te({label_props:n,fill:t.poisLabel,offset:2,font:"300 10px sans-serif"}),t.poisLabel)])}]};var ie=256,Wi=t=>new Promise((e,r)=>{setTimeout(()=>{e()},t)}),Ui=t=>t.then(e=>({status:"fulfilled",value:e}),e=>({status:"rejected",reason:e})),Zi=t=>{class e extends L.GridLayer{constructor(i){i.noWrap&&!i.bounds&&(i.bounds=[[-90,-180],[90,180]]),i.attribution==null&&(i.attribution='Protomaps \xA9 OpenStreetMap');super(i);let n=i.dark?Ue:We;this.paint_rules=i.paint_rules||Ze(n,i.shade),this.label_rules=i.label_rules||Oe(n,i.shade,i.language1,i.language2),this.backgroundColor=i.backgroundColor,this.lastRequestedZ=void 0,this.xray=i.xray,this.tasks=i.tasks||[],this.views=ft(i),this.debug=i.debug;let a=document.createElement("canvas").getContext("2d");this.scratch=a,this.onTilesInvalidated=s=>{s.forEach(o=>{this.rerenderTile(o)})},this.labelers=new ke(this.scratch,this.label_rules,16,this.onTilesInvalidated),this.tile_size=ie*window.devicePixelRatio,this.tileDelay=i.tileDelay||3,this.lang=i.lang,this.inspector=this.inspect(this)}setDefaultStyle(i,n,a,s){let o=i?Ue:We;this.paint_rules=Ze(o,n),this.label_rules=Oe(o,n,a,s)}renderTile(i,n,a,s=()=>{}){return j(this,null,function*(){this.lastRequestedZ=i.z;let o=[];for(let[v,F]of this.views){let z=F.getDisplayTile(i);o.push({key:v,promise:z})}let l=yield Promise.all(o.map(v=>v.promise.then(F=>({status:"fulfilled",value:F,key:v.key}),F=>({status:"rejected",reason:F,key:v.key})))),u=new Map;for(let v of l)v.status==="fulfilled"&&u.set(v.key,v.value);if(n.key!=a||this.lastRequestedZ!==i.z||(yield Promise.all(this.tasks.map(Ui)),n.key!=a)||this.lastRequestedZ!==i.z)return;let h=this.labelers.add(i.z,u);if(n.key!=a||this.lastRequestedZ!==i.z)return;let c=this.labelers.getIndex(i.z);if(!this._map)return;let d=this._map.getCenter().wrap(),p=this._getTiledPixelBounds(d),w=this._pxBoundsToTileRange(p),_=w.getCenter(),f=i.distanceTo(_)*this.tileDelay;if(yield Wi(f),n.key!=a||this.lastRequestedZ!==i.z)return;let m=16,y={minX:256*i.x-m,minY:256*i.y-m,maxX:256*(i.x+1)+m,maxY:256*(i.y+1)+m},g=new Cr.default(256*i.x+.5,256*i.y+.5);n.width=this.tile_size,n.height=this.tile_size;let b=n.getContext("2d");b.setTransform(this.tile_size/ie,0,0,this.tile_size/ie,0,0),b.clearRect(0,0,ie,ie),this.backgroundColor&&(b.save(),b.fillStyle=this.backgroundColor,b.fillRect(0,0,ie,ie),b.restore());var x=0;if(x=ct(b,i.z,[u],c,this.paint_rules,y,g,!1,this.debug,this.xray),this.debug){if(b.save(),b.fillStyle=this.debug,b.font="600 12px sans-serif",b.fillText(i.z+" "+i.x+" "+i.y,4,14),u.size!==0){let[v]=u.values(),F=v.data_tile;b.font="200 12px sans-serif",b.fillText(F.z+" "+F.x+" "+F.y,4,28)}b.font="600 10px sans-serif",x>8&&b.fillText(x.toFixed()+" ms paint",4,42),h>8&&b.fillText(h.toFixed()+" ms layout",4,56),b.strokeStyle=this.debug,b.lineWidth=6,b.beginPath(),b.moveTo(0,0),b.lineTo(0,256),b.stroke(),b.lineWidth=6,b.beginPath(),b.moveTo(0,0),b.lineTo(256,0),b.stroke(),b.restore()}s()})}rerenderTile(i){for(let n in this._tiles){let a=this._wrapCoords(this._keyToTileCoords(n));i===this._tileCoordsToKey(a)&&this.renderTile(a,this._tiles[n].el,i)}}clearLayout(){this.labelers=new ke(this.scratch,this.label_rules,16,this.onTilesInvalidated)}rerenderTiles(){this.fire(U.RerenderStart);let i=[];for(let n in this._tiles){let a=this._wrapCoords(this._keyToTileCoords(n)),s=this._tileCoordsToKey(a);i.push(this.renderTile(a,this._tiles[n].el,s))}Promise.all(i).then(()=>this.fire(U.RerenderEnd))}createTile(i,n){let a=L.DomUtil.create("canvas","leaflet-tile");a.lang=this.lang;let s=this._tileCoordsToKey(i);return a.key=s,this.renderTile(i,a,s,()=>{n(null,a)}),a}_removeTile(i){let n=this._tiles[i];!n||(n.el.removed=!0,n.el.key=void 0,L.DomUtil.removeClass(n.el,"leaflet-tile-loaded"),n.el.width=n.el.height=0,L.DomUtil.remove(n.el),delete this._tiles[i],this.fire("tileunload",{tile:n.el,coords:this._keyToTileCoords(i)}))}queryFeatures(i,n){let a=new Map;for(var[s,o]of this.views)a.set(s,o.queryFeatures(i,n,this._map.getZoom()));return a}queryRenderedFeatures(i,n){let a=new Map;for(var[s,o]of this.views){let l=this._map.getZoom(),h=o.queryFeatures(i,n,l).reduce((d,p)=>(d[p.layerName]||(d[p.layerName]=[]),d[p.layerName].push(p),d),{}),c=[];for(let d of this.paint_rules){if(d.minzoom&&ld.maxzoom)continue;let p=h[d.dataLayer];if(!!p)if(d.filter)for(let w of p)d.filter(l,w.feature)&&c.push(w);else c.push(...p)}a.set(s,c)}return a}inspect(i){return n=>{let a=["\u25CE","\u27CD","\u25FB"],s=i._map.wrapLatLng(n.latlng),o=i.queryFeatures(s.lng,s.lat);var l="";let u=!0;for(var[h,c]of o)for(var d of c)if(!(this.xray&&this.xray!==!0&&!(this.xray.dataSource===h&&this.xray.dataLayer===d.layerName))){l=l+`
${a[d.feature.geomType-1]} ${h} ${h?"/":""} ${d.layerName} ${d.feature.id||""}
`;for(let p in d.feature.props)l=l+`
${p} = ${d.feature.props[p]}
`;u=!1}u&&(l="No features."),L.popup().setLatLng(n.latlng).setContent('
'+l+"
").openOn(i._map)}}addInspector(i){return i.on("click",this.inspector)}removeInspector(i){return i.off("click",this.inspector)}updateDataSources(i,n=!1){let a=[];this.paint_rules=this.paint_rules.filter(s=>!s.dataSource||s.dataSource===$),this.label_rules=this.label_rules.filter(s=>!s.dataSource||s.dataSource===$),this.views.forEach((s,o)=>{o!==$&&this.views.delete(o)}),i.forEach(s=>{s.name===$&&console.warn("Overwritting the basemap using updateDataSources will result in duplicated rules"),this.views.set(s.name,Le(s.options)),this.paint_rules=this.paint_rules.concat(s.paintRules),a.unshift(...s.labelRules)}),a.length!==0&&(this.label_rules=n?a.concat(this.label_rules):this.label_rules.concat(a))}subscribeChildEvents(){this.eventQueue.subscribe(U.TileFetchStart,this.fireEvent),this.eventQueue.subscribe(U.TileFetchEnd,this.fireEvent)}fireEvent(i){this.fire(i)}}return new e(t)};var Oi=t=>{let e=0,r=0;for(let o of t)e+=o.w*o.h,r=Math.max(r,o.w);t.sort((o,l)=>l.h-o.h);let i=Math.max(Math.ceil(Math.sqrt(e/.95)),r),n=[{x:0,y:0,w:i,h:1/0}],a=0,s=0;for(let o of t)for(let l=n.length-1;l>=0;l--){let u=n[l];if(!(o.w>u.w||o.h>u.h)){if(o.x=u.x,o.y=u.y,s=Math.max(s,o.y+o.h),a=Math.max(a,o.x+o.w),o.w===u.w&&o.h===u.h){let h=n.pop();lnew Promise((e,r)=>{let i=new Image;i.onload=()=>e(i),i.onerror=()=>r("Invalid SVG"),i.src=t}),Hi=` +var protomaps=(()=>{var Ar=Object.create;var ye=Object.defineProperty;var Xr=Object.getOwnPropertyDescriptor;var Rr=Object.getOwnPropertyNames,zt=Object.getOwnPropertySymbols,Yr=Object.getPrototypeOf,St=Object.prototype.hasOwnProperty,Er=Object.prototype.propertyIsEnumerable;var Lt=(t,e,r)=>e in t?ye(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kt=(t,e)=>{for(var r in e||(e={}))St.call(e,r)&&Lt(t,r,e[r]);if(zt)for(var r of zt(e))Er.call(e,r)&&Lt(t,r,e[r]);return t};var Mt=t=>ye(t,"__esModule",{value:!0});var q=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ir=(t,e)=>{Mt(t);for(var r in e)ye(t,r,{get:e[r],enumerable:!0})},Vr=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Rr(e))!St.call(t,i)&&i!=="default"&&ye(t,i,{get:()=>e[i],enumerable:!(r=Xr(e,i))||r.enumerable});return t},V=t=>Vr(Mt(ye(t!=null?Ar(Yr(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var j=(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 W=q((tn,Pt)=>{"use strict";Pt.exports=se;function se(t,e){this.x=t,this.y=e}se.prototype={clone:function(){return new se(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}};se.convert=function(t){return t instanceof se?t:Array.isArray(t)?new se(t[0],t[1]):t}});var Ge=q((nn,Ct)=>{"use strict";var Nr=W();Ct.exports=oe;function oe(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(qr,this,e)}function qr(t,e,r){t==1?e.id=r.readVarint():t==2?jr(r,e):t==3?e.type=r.readVarint():t==4&&(e._geometry=r.pos)}function jr(t,e){for(var r=t.readVarint()+t.pos;t.pos>3}if(i--,r===1||r===2)n+=t.readSVarint(),a+=t.readSVarint(),r===1&&(o&&s.push(o),o=[]),o.push(new Nr(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};oe.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>3}if(i--,r===1||r===2)n+=t.readSVarint(),a+=t.readSVarint(),no&&(o=n),au&&(u=a);else if(r!==7)throw new Error("unknown command "+r)}return[s,l,o,u]};oe.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=oe.types[this.type],l,u;function h(p){for(var w=0;w{"use strict";var Ur=Ge();Bt.exports=Tt;function Tt(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(Zr,this,e),this.length=this._features.length}function Zr(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(Or(r))}function Or(t){for(var e=null,r=t.readVarint()+t.pos;t.pos>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}Tt.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 Ur(this._pbf,e,this.extent,this._keys,this._values)}});var At=q((sn,Dt)=>{"use strict";var Hr=Qe();Dt.exports=Jr;function Jr(t,e){this.layers=t.readFields(Gr,{},e)}function Gr(t,e,r){if(t===3){var i=new Hr(r,r.readVarint()+r.pos);i.length&&(e[i.name]=i)}}});var Xt=q((on,Be)=>{Be.exports.VectorTile=At();Be.exports.VectorTileFeature=Ge();Be.exports.VectorTileLayer=Qe()});var Rt=q(Ke=>{Ke.read=function(t,e,r,i,n){var a,s,o=n*8-i-1,l=(1<>1,h=-7,c=r?n-1:0,d=r?-1:1,p=t[e+c];for(c+=d,a=p&(1<<-h)-1,p>>=-h,h+=o;h>0;a=a*256+t[e+c],c+=d,h-=8);for(s=a&(1<<-h)-1,a>>=-h,h+=i;h>0;s=s*256+t[e+c],c+=d,h-=8);if(a===0)a=1-u;else{if(a===l)return s?NaN:(p?-1:1)*(1/0);s=s+Math.pow(2,i),a=a-u}return(p?-1:1)*s*Math.pow(2,a-i)};Ke.write=function(t,e,r,i,n,a){var s,o,l,u=a*8-n-1,h=(1<>1,d=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:a-1,w=i?1:-1,_=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=h):(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>=h?(o=0,s=h):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+p]=o&255,p+=w,o/=256,n-=8);for(s=s<0;t[r+p]=s&255,p+=w,s/=256,u-=8);t[r+p-w]|=_*128}});var qt=q((un,Nt)=>{"use strict";Nt.exports=k;var De=Rt();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 et=(1<<16)*(1<<16),Yt=1/et,Qr=12,Et=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>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=Ae(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Vt(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Ae(this.buf,this.pos)+Ae(this.buf,this.pos+4)*et;return this.pos+=8,t},readSFixed64:function(){var t=Ae(this.buf,this.pos)+Vt(this.buf,this.pos+4)*et;return this.pos+=8,t},readFloat:function(){var t=De.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=De.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,Kr(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>=Qr&&Et?ci(this.buf,e,t):di(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=O(this);for(t=t||[];this.pos127;);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;e268435455||t<0){ei(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=mi(this.buf,t,this.pos);var r=this.pos-e;r>=128&&It(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),De.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),De.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=128&&It(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,ii,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,ni,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,oi,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,ai,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,si,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,li,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,ui,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,hi,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,fi,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 Kr(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 le(t,n,e);throw new Error("Expected varint not more than 10 bytes")}function O(t){return t.type===k.Bytes?t.readVarint()+t.pos:t.pos+1}function le(t,e,r){return r?e*4294967296+(t>>>0):(e>>>0)*4294967296+(t>>>0)}function ei(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),ti(r,i,e),ri(i,e)}function ti(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 ri(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 It(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 ii(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function Vt(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function di(t,e,r){for(var i="",n=e;n239?4:a>223?3:a>191?2:1;if(n+o>r)break;var l,u,h;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],h=t[n+3],(l&192)==128&&(u&192)==128&&(h&192)==128&&(s=(a&15)<<18|(l&63)<<12|(u&63)<<6|h&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 ci(t,e,r){return Et.decode(t.subarray(e,r))}function mi(t,e,r){for(var i=0,n,a;i55295&&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 Ut=q(()=>{});var Zt=q((tt,rt)=>{(function(t,e){typeof tt=="object"&&typeof rt!="undefined"?rt.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=0)break;a[i]=h,i=u}a[i]=l};function e(r,i){return ri?1:0}return t})});var Ht=q((cn,it)=>{"use strict";var Xe=Zt();Xe.default&&(Xe=Xe.default);it.exports=Ot;it.exports.default=Ot;function Ot(t,e,r){e=e||1;for(var i,n,a,s,o=0;oa)&&(a=l[0]),(!o||l[1]>s)&&(s=l[1])}var u=a-i,h=s-n,c=Math.min(u,h),d=c/2;if(c===0){var p=[i,n];return p.distance=0,p}for(var w=new Xe(void 0,gi),_=i;_m.d&&(m=y);for(var g=w.length;w.length;){var b=w.pop();b.d>m.d&&(m=b,r&&console.log("found best %d after %d probes",Math.round(1e4*b.d)/1e4,g)),!(b.max-m.d<=e)&&(d=b.h/2,w.push(new Q(b.x-d,b.y-d,d,t)),w.push(new Q(b.x+d,b.y-d,d,t)),w.push(new Q(b.x-d,b.y+d,d,t)),w.push(new Q(b.x+d,b.y+d,d,t)),g+=4)}r&&(console.log("num probes: "+g),console.log("best distance: "+m.d));var x=[m.x,m.y];return x.distance=m.d,x}function gi(t,e){return e.max-t.max}function Q(t,e,r,i){this.x=t,this.y=e,this.h=r,this.d=wi(t,e,i),this.max=this.d+this.h*Math.SQRT2}function wi(t,e,r){for(var i=!1,n=1/0,a=0;ae!=c[1]>e&&t<(c[0]-h[0])*(e-h[1])/(c[1]-h[1])+h[0]&&(i=!i),n=Math.min(n,_i(t,e,h,c))}return n===0?0:(i?1:-1)*Math.sqrt(n)}function vi(t){for(var e=0,r=0,i=0,n=t[0],a=0,s=n.length,o=s-1;a1?(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 _r=q((mt,pt)=>{(function(t,e){typeof mt=="object"&&typeof pt!="undefined"?pt.exports=e():typeof define=="function"&&define.amd?define(e):(t=t||self).RBush=e()})(mt,function(){"use strict";function t(f,m,y,g,b){(function x(v,F,z,S,D){for(;S>z;){if(S-z>600){var P=S-z+1,A=F-z+1,pe=Math.log(P),K=.5*Math.exp(2*pe/3),ne=.5*Math.sqrt(pe*K*(P-K)/P)*(A-P/2<0?-1:1),ae=Math.max(z,Math.floor(F-A*K/P+ne)),Dr=Math.min(S,Math.floor(F+(P-A)*K/P+ne));x(v,F,ae,Dr,D)}var Te=v[F],be=z,N=S;for(e(v,z,F),D(v[S],Te)>0&&e(v,z,S);be0;)N--}D(v[z],Te)===0?e(v,z,N):e(v,++N,S),N<=F&&(z=N+1),F<=N&&(S=N-1)}})(f,m,y||0,g||f.length-1,b||r)}function e(f,m,y){var g=f[m];f[m]=f[y],f[y]=g}function r(f,m){return fm?1:0}var i=function(f){f===void 0&&(f=9),this._maxEntries=Math.max(4,f),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function n(f,m,y){if(!y)return m.indexOf(f);for(var g=0;g=f.minX&&m.maxY>=f.minY}function w(f){return{children:f,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function _(f,m,y,g,b){for(var x=[m,y];x.length;)if(!((y=x.pop())-(m=x.pop())<=g)){var v=m+Math.ceil((y-m)/g/2)*g;t(f,v,m,y,b),x.push(m,v,v,y)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(f){var m=this.data,y=[];if(!p(f,m))return y;for(var g=this.toBBox,b=[];m;){for(var x=0;x=0&&b[m].children.length>this._maxEntries;)this._split(b,m),m--;this._adjustParentBBoxes(g,b,m)},i.prototype._split=function(f,m){var y=f[m],g=y.children.length,b=this._minEntries;this._chooseSplitAxis(y,b,g);var x=this._chooseSplitIndex(y,b,g),v=w(y.children.splice(x,y.children.length-x));v.height=y.height,v.leaf=y.leaf,a(y,this.toBBox),a(v,this.toBBox),m?f[m-1].children.push(v):this._splitRoot(y,v)},i.prototype._splitRoot=function(f,m){this.data=w([f,m]),this.data.height=f.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(f,m,y){for(var g,b,x,v,F,z,S,D=1/0,P=1/0,A=m;A<=y-m;A++){var pe=s(f,0,A,this.toBBox),K=s(f,A,y,this.toBBox),ne=(b=pe,x=K,v=void 0,F=void 0,z=void 0,S=void 0,v=Math.max(b.minX,x.minX),F=Math.max(b.minY,x.minY),z=Math.min(b.maxX,x.maxX),S=Math.min(b.maxY,x.maxY),Math.max(0,z-v)*Math.max(0,S-F)),ae=h(pe)+h(K);ne=m;D--){var P=f.children[D];o(v,f.leaf?b(P):P),F+=c(v)}return F},i.prototype._adjustParentBBoxes=function(f,m,y){for(var g=y;g>=0;g--)o(m[g],f)},i.prototype._condense=function(f){for(var m=f.length-1,y=void 0;m>=0;m--)f[m].children.length===0?m>0?(y=f[m-1].children).splice(y.indexOf(f[m]),1):this.clear():a(f[m],this.toBBox)},i})});var Ki={};Ir(Ki,{BasemapLayerSourceName:()=>$,CenteredSymbolizer:()=>st,CenteredTextSymbolizer:()=>Z,CircleSymbolizer:()=>J,DataDrivenOffsetSymbolizer:()=>Ft,DataDrivenOffsetTextSymbolizer:()=>Br,FlexSymbolizer:()=>_e,Font:()=>Ji,GeomType:()=>Y,GroupSymbolizer:()=>Fe,GroupedLineSymbolizer:()=>nr,GroupedPolygonSymbolizer:()=>er,IconSymbolizer:()=>ar,Index:()=>bt,Justify:()=>R,Labeler:()=>yt,Labelers:()=>ke,LineLabelPlacement:()=>he,LineLabelSymbolizer:()=>fe,LineSymbolizer:()=>X,MAX_VERTICES_PER_DRAW_CALL:()=>H,OffsetSymbolizer:()=>ot,OffsetTextSymbolizer:()=>te,PMTiles:()=>ge,Padding:()=>or,PmtilesSource:()=>ze,PolygonLabelSymbolizer:()=>de,PolygonSymbolizer:()=>B,ShieldSymbolizer:()=>Ye,Sprites:()=>Gi,TextPlacements:()=>M,TextSymbolizer:()=>ee,TileCache:()=>$e,View:()=>ht,ZxySource:()=>Ne,arr:()=>Li,covering:()=>Sr,createPattern:()=>Si,cubicBezier:()=>Pi,dark:()=>Ue,exp:()=>I,filterFn:()=>Ce,getFont:()=>vt,isCCW:()=>Ie,isInRing:()=>ut,json_style:()=>Qi,labelRules:()=>Oe,leafletLayer:()=>Zi,light:()=>We,linear:()=>Mi,numberFn:()=>Je,numberOrFn:()=>gt,paintRules:()=>Ze,painter:()=>ct,pointInPolygon:()=>yr,pointMinDistToLines:()=>gr,pointMinDistToPoints:()=>xr,sourceToView:()=>Le,sourcesToViews:()=>ft,step:()=>ki,toIndex:()=>G,transformGeom:()=>ce,widthFn:()=>wt,wrap:()=>Se});var Cr=V(W());var re=V(W());var U;(function(n){n.TileFetchStart="tile-fetch-start",n.TileFetchEnd="tile-fetch-end",n.RerenderStart="rerender-start",n.RerenderEnd="rerender-end"})(U||(U={}));var Ve=V(W()),dr=V(Xt()),cr=V(qt());var pi=Object.defineProperty,bi=(t,e,r)=>e in t?pi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xe=(t,e,r)=>(bi(t,typeof e!="symbol"?e+"":e,r),r),jt=(t,e)=>t*Math.pow(2,e),$t=(t,e)=>jt(t.getUint16(e+1,!0),8)+t.getUint8(e,!0),yi=(t,e)=>jt(t.getUint32(e+2,!0),16)+t.getUint16(e,!0),xi=t=>{var e=t.getUint16(0,!0);if(e!==19792)throw new Error('File header does not begin with "PM"');var r=t.getUint16(2,!0),i=t.getUint32(4,!0),n=t.getUint16(8,!0);return{version:r,json_size:i,root_entries:n}},Wt=t=>{let e=new Map;for(var r=0;r>7,s=$t(t,r+1),o=$t(t,r+4),l=yi(t,r+7),u=t.getUint32(r+13,!0);e.set(n+"_"+s+"_"+o,[l,u,a])}return e},ge=class{constructor(e){xe(this,"metadata",n=>new Promise((a,s)=>{this.root.then(o=>{a(o.metadata)})})),xe(this,"getLeaf",(n,a)=>new Promise((s,o)=>{this.leaves.has(n)?(this.leaves.get(n)[0]++,s(this.leaves.get(n)[1])):this.outstanding_requests.has(n)?this.outstanding_requests.get(n).push(s):(this.outstanding_requests.set(n,[]),fetch(this.url,{headers:{Range:"bytes="+n+"-"+(n+a-1)}}).then(l=>l.arrayBuffer()).then(l=>{var u=Wt(new DataView(l),a/17);if(this.leaves.size>32){var h=1/0,c=void 0;this.leaves.forEach((d,p)=>{d[0]d(u)),this.outstanding_requests.delete(n)}))})),xe(this,"getZxy",(n,a,s)=>{var o=n+"_"+a+"_"+s;return this.root.then(l=>{if(l.dir.has(o)&&l.dir.get(o)[2]==0)return l.dir.get(o);if(n>=7){var u=n-7,h=[7,Math.trunc(a/(1<p.has(o)?p.get(o):null)}}return null})}),xe(this,"transformRequest",(n,a,s,o)=>{if(n.endsWith(".pmtiles")&&o){var l=s.tileID.canonical,u=l.z+"_"+l.x+"_"+l.y;this.getZxy(l.z,l.x,l.y).then(h=>{h&&o({url:this.url,headers:{Range:"bytes="+h[0]+"-"+(h[0]+h[1]-1)}})})}return{url:n}}),xe(this,"leafletLayer",n=>{let a=this;var s=L.GridLayer.extend({createTile:function(o,l){var u=document.createElement("img"),h;return a.getZxy(o.z,o.x,o.y).then(c=>{c!==null&&fetch(a.url,{headers:{Range:"bytes="+c[0]+"-"+(c[0]+c[1]-1)}}).then(d=>d.arrayBuffer()).then(d=>{var p=new Blob([d],{type:"image/png"}),w=window.URL.createObjectURL(p);u.src=w,l(h,u)})}),u},_removeTile:function(o){var l=this._tiles[o];!l||(l.el.width=0,l.el.height=0,l.el.deleted=!0,L.DomUtil.remove(l.el),delete this._tiles[o],this.fire("tileunload",{tile:l.el,coords:this._keyToTileCoords(o)}))}});return new s(n)}),this.url=e;let r=new AbortController,i=r.signal;this.root=fetch(this.url,{signal:i,headers:{Range:"bytes=0-511999"}}).then(n=>(n.headers.get("Content-Length")!=512e3&&(console.error("Content-Length mismatch indicates byte serving not supported; aborting."),r.abort()),n.arrayBuffer())).then(n=>{let a=xi(new DataView(n,0,10));var s=new TextDecoder("utf-8");return{metadata:JSON.parse(s.decode(new DataView(n,10,a.json_size))),dir:Wt(new DataView(n,10+a.json_size,17*a.root_entries))}}),this.step=0,this.leaves=new Map,this.outstanding_requests=new Map}};var E=V(W()),Qt=V(Ut());var Kt=V(Ht());var T=class{constructor(e,r=""){this.str=e||r,this.per_feature=typeof this.str=="function"&&this.str.length==2}get(e,r){return typeof this.str=="function"?this.str(e,r):this.str}},C=class{constructor(e,r=1){this.value=e||r,this.per_feature=typeof this.value=="function"&&this.value.length==2}get(e,r){return typeof this.value=="function"?this.value(e,r):this.value}},we=class{constructor(e={}){this.label_props=e.label_props||["name"],this.textTransform=e.textTransform,this.value=e.value}get(e,r){var i;if(this.value)i=this.value(e,r);else{var n;typeof this.label_props=="function"?n=this.label_props(e,r):n=this.label_props;for(let s of n)if(r.props.hasOwnProperty(s)){i=r.props[s],typeof i=="number"&&(i=`${i}`);break}}let a;return typeof this.textTransform=="function"?a=this.textTransform(e,r):a=this.textTransform,i&&a==="uppercase"?i=i.toUpperCase():i&&a==="lowercase"?i=i.toLowerCase():i&&a==="capitalize"&&(i=i.toLowerCase().split(" ").map(l=>l[0].toUpperCase()+l.slice(1)).join(" ")),i}},ve=class{constructor(e){e.font?this.font=e.font:(this.family=e.fontFamily||"sans-serif",this.size=e.fontSize||12,this.weight=e.fontWeight,this.style=e.fontStyle)}get(e,r){if(this.font)return typeof this.font=="function"?this.font(e,r):this.font;var i="";this.style&&(typeof this.style=="function"?i=this.style(e,r)+" ":i=this.style+" ");var n="";this.weight&&(typeof this.weight=="function"?n=this.weight(e,r)+" ":n=this.weight+" ");var a;typeof this.size=="function"?a=this.size(e,r):a=this.size;var s;return typeof this.family=="function"?s=this.family(e,r):s=this.family,`${i}${n}${a}px ${s}`}},Re=class{constructor(e,r=[]){this.value=e||r,this.per_feature=typeof this.value=="function"&&this.value.length==2}get(e,r){return typeof this.value=="function"?this.value(e,r):this.value}};function nt(t,e){if(t.length<=e)return[t];let r=e-1,i=t.lastIndexOf(" ",r),n=t.indexOf(" ",r);if(i==-1&&n==-1)return[t];let a,s;return n==-1||i>=0&&r-i{var i=[],n,a,s,o=0,l=0,u=0,h=0,c=0,d=0,p=0,w=0,_=0,f=0,m=0,y=0;if(t.length<2)return[];if(t.length===2)return u=Math.sqrt(Math.pow(t[1].x-t[0].x,2)+Math.pow(t[1].y-t[0].y,2)),[{length:u,beginIndex:0,beginDistance:0,endIndex:2,endDistance:u}];for(h=Math.sqrt(Math.pow(t[1].x-t[0].x,2)+Math.pow(t[1].y-t[0].y,2)),o=1,l=t.length-1;oe||u-y>r)&&(i.push({length:u-y,beginDistance:y,beginIndex:m,endIndex:o+1,endDistance:u}),m=o,y=u),h=c;return o-m>0&&i.push({length:u-y+c,beginIndex:m,beginDistance:y,endIndex:o+1,endDistance:u+c}),i};function Jt(t,e,r,i){let n,a,s=0,o=[];var l=-1/0;for(let h of t){let c=zi(h,Math.PI/45,e);for(let d of c)if(d.length>=e+i){let p=new at.default(h[d.beginIndex].x,h[d.beginIndex].y),w=h[d.endIndex-1],_=new at.default((w.x-p.x)/d.length,(w.y-p.y)/d.length);for(var u=i;u{let i=document.createElement("canvas"),n=i.getContext("2d");return i.width=t,i.height=e,r(i,n),i},B=class{constructor(e){this.pattern=e.pattern,this.fill=new T(e.fill,"black"),this.opacity=new C(e.opacity,1),this.stroke=new T(e.stroke,"black"),this.width=new C(e.width,0),this.per_feature=this.fill.per_feature||this.opacity.per_feature||this.stroke.per_feature||this.width.per_feature||e.per_feature,this.do_stroke=!1}before(e,r){if(!this.per_feature){e.globalAlpha=this.opacity.get(r),e.fillStyle=this.fill.get(r),e.strokeStyle=this.stroke.get(r);let i=this.width.get(r);i>0&&(this.do_stroke=!0),e.lineWidth=i}this.pattern&&(e.fillStyle=e.createPattern(this.pattern,"repeat"))}draw(e,r,i,n){var a=!1;if(this.per_feature){e.globalAlpha=this.opacity.get(i,n),e.fillStyle=this.fill.get(i,n);var s=this.width.get(i,n);s&&(a=!0,e.strokeStyle=this.stroke.get(i,n),e.lineWidth=s)}let o=()=>{e.fill(),(a||this.do_stroke)&&e.stroke()};var l=0;e.beginPath();for(var u of r){l+u.length>H&&(o(),l=0,e.beginPath());for(var h=0;h0&&o()}},er=class{constructor(e){this.pattern=e.pattern,this.fill=new T(e.fill,"black"),this.opacity=new C(e.opacity,1),this.stroke=new T(e.stroke,"black"),this.width=new C(e.width,0),this.do_stroke=!1}before(e,r){e.globalAlpha=this.opacity.get(r),e.fillStyle=this.fill.get(r),e.strokeStyle=this.stroke.get(r);let i=this.width.get(r);i>0&&(this.do_stroke=!0),e.lineWidth=i,this.pattern&&(e.fillStyle=e.createPattern(this.pattern,"repeat"))}drawGrouped(e,r,i,n,a,s){let o=()=>{e.fill(),this.do_stroke&&e.stroke()},l=0;e.save(),e.beginPath();for(let u of i)n(u)&&s(u)&&a(u.geom).forEach(c=>{l+c.length>H&&(o(),e.beginPath(),l=0),e.moveTo(c[0].x,c[0].y);for(var d=1;d{let i=r-t;return i>=0&&i{if(e.length<1)return 0;if(r<=e[0][0])return e[0][1];if(r>=e[e.length-1][0])return e[e.length-1][1];let i=tr(r,e),n=ir(r,i,t,e);return rr(n,e[i][1],e[i+1][1])}}function ki(t,e){return r=>{if(e.length<1)return 0;let i=t;for(let n=0;n=e[n][0]&&(i=e[n][1]);return i}}function Mi(t){return I(1,t)}function Pi(t,e,r,i,n){return a=>{if(n.length<1)return 0;let s=new Qt.default(t,e,r,i),o=tr(a,n),l=s.solve(ir(a,o,1,n));return rr(l,n[o][1],n[o+1][1])}}var X=class{constructor(e){this.color=new T(e.color,"black"),this.width=new C(e.width),this.opacity=new C(e.opacity),this.dash=e.dash?new Re(e.dash):null,this.dashColor=new T(e.dashColor,"black"),this.dashWidth=new C(e.dashWidth,1),this.lineCap=new T(e.lineCap,"butt"),this.lineJoin=new T(e.lineJoin,"miter"),this.skip=!1,this.per_feature=this.dash||this.color.per_feature||this.opacity.per_feature||this.width.per_feature||this.lineCap.per_feature||this.lineJoin.per_feature||e.per_feature}before(e,r){this.per_feature||(e.strokeStyle=this.color.get(r),e.lineWidth=this.width.get(r),e.globalAlpha=this.opacity.get(r),e.lineCap=this.lineCap.get(r),e.lineJoin=this.lineJoin.get(r))}draw(e,r,i,n){if(this.skip)return;let a=()=>{this.per_feature&&(e.globalAlpha=this.opacity.get(i,n),e.lineCap=this.lineCap.get(i,n),e.lineJoin=this.lineJoin.get(i,n)),this.dash?(e.lineWidth=this.dashWidth.get(i,n),e.strokeStyle=this.dashColor.get(i,n),e.setLineDash(this.dash.get(i,n))):this.per_feature&&(e.lineWidth=this.width.get(i,n),e.strokeStyle=this.color.get(i,n))};var s=0;e.save(),e.beginPath(),a();for(var o of r){s+o.length>H&&(e.stroke(),s=0,e.beginPath()),e.moveTo(o[0].x,o[0].y);for(var l=1;l0&&e.stroke(),e.restore()}},nr=class{constructor(e){this.color=new T(e.color,"black"),this.width=new C(e.width),this.opacity=new C(e.opacity),this.dash=e.dash?new Re(e.dash):null,this.dashColor=new T(e.dashColor,"black"),this.dashWidth=new C(e.dashWidth,1),this.lineCap=new T(e.lineCap,"butt"),this.lineJoin=new T(e.lineJoin,"miter"),this.skip=!1,this.per_feature=!1}before(e,r){e.strokeStyle=this.color.get(r),e.lineWidth=this.width.get(r),e.globalAlpha=this.opacity.get(r),e.lineCap=this.lineCap.get(r),e.lineJoin=this.lineJoin.get(r)}drawGrouped(e,r,i,n,a,s){if(this.skip)return;let o=u=>{this.dash&&(e.lineWidth=this.dashWidth.get(u),e.strokeStyle=this.dashColor.get(u),e.setLineDash(this.dash.get(u)))},l=0;e.save(),o(r),e.beginPath();for(let u of i)n(u)&&s(u)&&a(u.geom).forEach(c=>{l+c.length>H&&(e.stroke(),e.beginPath(),l=0),e.moveTo(c[0].x,c[0].y);for(var d=1;d{l.globalAlpha=1;let u=this.sprites.get(this.name);l.drawImage(u.canvas,u.x,u.y,u.w,u.h,-8,-8,u.w,u.h)}}]}},J=class{constructor(e){this.radius=new C(e.radius,3),this.fill=new T(e.fill,"black"),this.stroke=new T(e.stroke,"white"),this.width=new C(e.width,0),this.opacity=new C(e.opacity)}draw(e,r,i,n){e.globalAlpha=this.opacity.get(i,n);let a=this.radius.get(i,n),s=this.width.get(i,n);s>0&&(e.fillStyle=this.stroke.get(i,n),e.beginPath(),e.arc(r[0][0].x,r[0][0].y,a+s,0,2*Math.PI),e.fill()),e.fillStyle=this.fill.get(i,n),e.beginPath(),e.arc(r[0][0].x,r[0][0].y,a,0,2*Math.PI),e.fill()}place(e,r,i){let n=r[0],a=new E.default(r[0][0].x,r[0][0].y),s=this.radius.get(e.zoom,i),o={minX:a.x-s,minY:a.y-s,maxX:a.x+s,maxY:a.y+s};return[{anchor:a,bboxes:[o],draw:u=>{this.draw(u,[[new E.default(0,0)]],e.zoom,i)}}]}},Ye=class{constructor(e){this.font=new ve(e),this.text=new we(e),this.fill=new T(e.fill,"black"),this.background=new T(e.background,"white"),this.padding=new C(e.padding,0)}place(e,r,i){let n=this.text.get(e.zoom,i);if(!n)return;let a=this.font.get(e.zoom,i);e.scratch.font=a;let s=e.scratch.measureText(n),o=s.width,l=s.actualBoundingBoxAscent,u=s.actualBoundingBoxDescent,h=r[0],c=new E.default(r[0][0].x,r[0][0].y),d=this.padding.get(e.zoom,i),p={minX:c.x-o/2-d,minY:c.y-l-d,maxX:c.x+o/2+d,maxY:c.y+u+d};return[{anchor:c,bboxes:[p],draw:_=>{_.globalAlpha=1,_.fillStyle=this.background.get(e.zoom,i),_.fillRect(-o/2-d,-l-d,o+2*d,l+u+2*d),_.fillStyle=this.fill.get(e.zoom,i),_.font=a,_.fillText(n,-o/2,0)}}]}},_e=class{constructor(e,r){this.list=e}place(e,r,i){var n=this.list[0].place(e,r,i);if(!n)return;var a=n[0];let s=a.anchor,o=a.bboxes[0],l=o.maxY-o.minY,u=[{draw:a.draw,translate:{x:0,y:0}}],h=[[{x:r[0][0].x,y:r[0][0].y+l}]];for(let d=1;d{for(let p of u)d.save(),d.translate(p.translate.x,p.translate.y),p.draw(d),d.restore()}}]}},sr=(t,e)=>({minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}),Fe=class{constructor(e){this.list=e}place(e,r,i){let n=this.list[0];if(!n)return;var a=n.place(e,r,i);if(!a)return;var s=a[0];let o=s.anchor,l=s.bboxes[0],u=[s.draw];for(let c=1;c{u.forEach(d=>d(c))}}]}},st=class{constructor(e){this.symbolizer=e}place(e,r,i){let n=r[0][0],a=this.symbolizer.place(e,[[new E.default(0,0)]],i);if(!a||a.length==0)return;let s=a[0],o=s.bboxes[0],l=o.maxX-o.minX,u=o.maxY-o.minY,h={minX:n.x-l/2,maxX:n.x+l/2,minY:n.y-u/2,maxY:n.y+u/2};return[{anchor:n,bboxes:[h],draw:d=>{d.translate(-l/2,u/2-o.maxY),s.draw(d,{justify:2})}}]}},or=class{constructor(e,r){this.padding=new C(e,0),this.symbolizer=r}place(e,r,i){let n=this.symbolizer.place(e,r,i);if(!n||n.length==0)return;let a=this.padding.get(e.zoom,i);for(var s of n)for(var o of s.bboxes)o.minX-=a,o.minY-=a,o.maxX+=a,o.maxY+=a;return n}},ee=class{constructor(e){this.font=new ve(e),this.text=new we(e),this.fill=new T(e.fill,"black"),this.stroke=new T(e.stroke,"black"),this.width=new C(e.width,0),this.lineHeight=new C(e.lineHeight,1),this.letterSpacing=new C(e.letterSpacing,0),this.maxLineCodeUnits=new C(e.maxLineChars,15),this.justify=e.justify}place(e,r,i){let n=this.text.get(e.zoom,i);if(!n)return;let a=this.font.get(e.zoom,i);e.scratch.font=a;let s=this.letterSpacing.get(e.zoom,i),o=nt(n,this.maxLineCodeUnits.get(e.zoom,i));var l,u=0;for(let y of o)y.length>u&&(u=y.length,l=y);let h=e.scratch.measureText(l),c=h.width+s*(u-1),d=h.actualBoundingBoxAscent,p=h.actualBoundingBoxDescent,w=(d+p)*this.lineHeight.get(e.zoom,i),_=new E.default(r[0][0].x,r[0][0].y),f={minX:_.x,minY:_.y-d,maxX:_.x+c,maxY:_.y+p+(o.length-1)*w};return[{anchor:_,bboxes:[f],draw:(y,g)=>{y.globalAlpha=1,y.font=a,y.fillStyle=this.fill.get(e.zoom,i);let b=this.width.get(e.zoom,i);var x=0;for(let S of o){var v=0;if(this.justify==2||g&&g.justify==2?v=(c-y.measureText(S).width)/2:(this.justify==3||g&&g.justify==3)&&(v=c-y.measureText(S).width),b)if(y.lineWidth=b*2,y.strokeStyle=this.stroke.get(e.zoom,i),s>0){var F=v;for(var z of S)y.strokeText(z,F,x),F+=y.measureText(z).width+s}else y.strokeText(S,v,x);if(s>0){var F=v;for(var z of S)y.fillText(z,F,x),F+=y.measureText(z).width+s}else y.fillText(S,v,x);x+=w}}}]}},Z=class{constructor(e){this.centered=new st(new ee(e))}place(e,r,i){return this.centered.place(e,r,i)}},ot=class{constructor(e,r){this.symbolizer=e,this.offset=new C(r.offset,0)}place(e,r,i){if(i.geomType!==Y.Point)return;let n=r[0][0],a=this.symbolizer.place(e,[[new E.default(0,0)]],i);if(!a||a.length==0)return;let s=a[0],o=s.bboxes[0],l=this.offset.get(e.zoom,i),u=(w,_)=>({minX:w.x+_.x+o.minX,minY:w.y+_.y+o.minY,maxX:w.x+_.x+o.maxX,maxY:w.y+_.y+o.maxY});var h=new E.default(l,-l),c;let d=w=>{w.translate(h.x,h.y),s.draw(w,{justify:c})};var p=u(n,h);if(c=1,!e.index.bboxCollides(p,e.order))return[{anchor:n,bboxes:[p],draw:d}];if(h=new E.default(-l-o.maxX,l-o.minY),p=u(n,h),c=3,!e.index.bboxCollides(p,e.order))return[{anchor:n,bboxes:[p],draw:d}];if(h=new E.default(-l-o.maxX,-l),p=u(n,h),c=3,!e.index.bboxCollides(p,e.order))return[{anchor:n,bboxes:[p],draw:d}];if(h=new E.default(-l-o.maxX,l-o.minY),p=u(n,h),c=1,!e.index.bboxCollides(p,e.order))return[{anchor:n,bboxes:[p],draw:d}]}},te=class{constructor(e){this.symbolizer=new ot(new ee(e),e)}place(e,r,i){return this.symbolizer.place(e,r,i)}},he;(function(i){i[i.Above=1]="Above",i[i.Center=2]="Center",i[i.Below=3]="Below"})(he||(he={}));var fe=class{constructor(e){this.font=new ve(e),this.text=new we(e),this.fill=new T(e.fill,"black"),this.stroke=new T(e.stroke,"black"),this.width=new C(e.width,0),this.offset=new C(e.offset,0),this.position=e.position||1,this.maxLabelCodeUnits=new C(e.maxLabelChars,40),this.repeatDistance=new C(e.repeatDistance,250)}place(e,r,i){let n=this.text.get(e.zoom,i);if(!n||n.length>this.maxLabelCodeUnits.get(e.zoom,i))return;let a=20,s=i.bbox;if(s.maxY-s.minY4&&(c*=1<({minX:x.x-d/2,minY:x.y-d/2,maxX:x.x+d/2,maxY:x.y+d/2})),b=x=>{x.globalAlpha=1;let v=0;this.position===3?v=h:this.position===2&&(v=h/2);let F=Math.atan2(-m,f);x.translate(Math.cos(F-Math.PI/2)*v,-Math.sin(F-Math.PI/2)*v),x.rotate(-F),f<0&&(x.scale(-1,-1),x.translate(-u,2*v)),x.translate(0,-this.offset.get(e.zoom,i)),x.font=o;let z=this.width.get(e.zoom,i);z&&(x.lineWidth=z,x.strokeStyle=this.stroke.get(e.zoom,i),x.strokeText(n,0,0)),x.fillStyle=this.fill.get(e.zoom,i),x.fillText(n,0,0)};w.push({anchor:_.start,bboxes:g,draw:b,deduplicationKey:n,deduplicationDistance:c})}return w}},de=class{constructor(e){this.symbolizer=new ee(e)}place(e,r,i){let n=i.bbox;if((n.maxY-n.minY)*(n.maxX-n.minX)<2e4)return;let s=this.symbolizer.place(e,[[new E.default(0,0)]],i);if(!s||s.length==0)return;let o=s[0],l=o.bboxes[0],u=r[0],h=(0,Kt.default)([u.map(w=>[w.x,w.y])]),c=new E.default(h[0],h[1]),d={minX:c.x-(l.maxX-l.minX)/2,minY:c.y-(l.maxY-l.minY)/2,maxX:c.x+(l.maxX-l.minX)/2,maxY:c.y+(l.maxY-l.minY)/2};return[{anchor:c,bboxes:[d],draw:w=>{w.translate(o.anchor.x-(l.maxX-l.minX)/2,o.anchor.y),o.draw(w)}}]}};var Ee=(t,e)=>t[1].area-e[1].area;function Ci(){var t={},e=[];t.push=function(){for(var n=0,a=arguments.length;n0;){var s=(n+1>>1)-1,o=e[s];if(Ee(a,o)>=0)break;e[o.index=n]=o,e[a.index=n=s]=a}}function i(n){for(var a=e[n];;){var s=(n+1)*2,o=s-1,l=n,u=e[l];if(oMath.abs((t[0].x-t[2].x)*(t[1].y-t[0].y)-(t[0].x-t[1].x)*(t[2].y-t[0].y)),ur=(t,e)=>{let r=[];for(let s of t){let o=Ti(s,e);r=r.concat(o)}if(e>=r.length)return t;r.sort(function(s,o){return o-s});let i=[],n=r[e],a=0;for(let s of t){let o=s.filter(function(l){return l.area>n});o.length>=3&&(i.push(o),a+=o.length)}return i},Ti=(t,e)=>{var r=0;let i=Ci();var n;let a=[];for(var s=1,o=t.length-1;s0?h.area:1/0});return u},hr=(t,e)=>{let r=[];var i=[];let n=0;for(let s of t){var a=s;s.length>e&&(console.log("LineString with length: ",s.length),a=ur(s,e)),i.length>0&&n+a.length>e&&(r.push(i),i=[],n=0),i.push(a),n+=s.length}return i.length>0&&r.push(i),r},Bi=t=>{var e=0;for(let r of t)e+=r.length;return e},fr=(t,e)=>{let r=[],i=[];for(let u of t)i.length>0&&!Ie(u)&&(r.push(i),i=[]),i.push(u);i.length>0&&r.push(i);let n=[];var a=[],s=0;for(let u of r){var o=u,l=Bi(u);l>e&&(o=ur(u,e),l=e),a.length>0&&s+l>e&&(n.push(a),a=[],s=0),a=a.concat(o),s+=l}return a.length>0&&n.push(a),n};var Y;(function(i){i[i.Point=1]="Point",i[i.Line=2]="Line",i[i.Polygon=3]="Polygon"})(Y||(Y={}));function G(t){return t.x+":"+t.y+":"+t.z}var Di=(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,h=1/0,c=-1/0,d=[],p;t.pos>3}if(a--,n===1||n===2)s+=t.readSVarint()*r,o+=t.readSVarint()*r,su&&(u=s),oc&&(c=o),n===1&&(p&&d.push(p),p=[]),p.push(new Ve.default(s,o));else if(n===7)p&&p.push(p[0].clone());else throw new Error("unknown command "+n)}return p&&d.push(p),{geom:d,bbox:{minX:l,minY:h,maxX:u,maxY:c}}};function mr(t,e){let r=new dr.VectorTile(new cr.default(t)),i=new Map;for(let[n,a]of Object.entries(r.layers)){let s=[],o=a;for(let l=0;lH&&o.feature(l).type!=1){o.feature(l).type==2?c=hr(u.geom,H):c=fr(u.geom,H);for(let d of c)s.push({id:o.feature(l).id,geomType:o.feature(l).type,geom:d,numVertices:h,bbox:u.bbox,props:o.feature(l).properties})}else s.push({id:o.feature(l).id,geomType:o.feature(l).type,geom:u.geom,numVertices:h,bbox:u.bbox,props:o.feature(l).properties})}i.set(n,s)}return i}var ze=class{constructor(e,r){e.url?this.p=e:this.p=new ge(e),this.controllers=[],this.shouldCancelZooms=r}get(e,r){return j(this,null,function*(){this.shouldCancelZooms&&(this.controllers=this.controllers.filter(s=>s[0]!=e.z?(s[1].abort(),!1):!0));let i=yield this.p.getZxy(e.z,e.x,e.y);if(!i)throw new Error(`Tile ${e.z} ${e.x} ${e.y} not found in archive`);let n=new AbortController;this.controllers.push([e.z,n]);let a=n.signal;return new Promise((s,o)=>{fetch(this.p.url,{headers:{Range:"bytes="+i[0]+"-"+(i[0]+i[1]-1)},signal:a}).then(l=>l.arrayBuffer()).then(l=>{let u=mr(l,r);s(u)}).catch(l=>{o(l)})})})}},Ne=class{constructor(e,r){this.url=e,this.controllers=[],this.shouldCancelZooms=r}get(e,r){return j(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=mr(l,r);s(u)}).catch(l=>{o(l)})})})}},lt=6378137,pr=85.0511287798,qe=lt*Math.PI,Ai=t=>{let e=Math.PI/180,r=Math.max(Math.min(pr,t[0]),-pr),i=Math.sin(r*e);return new Ve.default(lt*t[1]*e,lt*Math.log((1+i)/(1-i))/2)};function br(t){return t*t}function je(t,e){return br(t.x-e.x)+br(t.y-e.y)}function Xi(t,e,r){var i=je(e,r);if(i===0)return je(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)),je(t,{x:e.x+n*(r.x-e.x),y:e.y+n*(r.y-e.y)})}function ut(t,e){for(var r=!1,i=0,n=e.length-1;it.y!=l>t.y&&t.x<(o-a)*(t.y-s)/(l-s)+a;u&&(r=!r)}return r}function Ie(t){for(var e=0,r=0;r1&&(s.x=s.x-Math.floor(s.x));let o=s.mult(1<{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,h;this.cache.forEach((c,d)=>{c.used{let l=this.inflight.get(r);l&&l.forEach(u=>u[1](o)),this.inflight.delete(r),n(o)}))}})})}};var ce=(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},Se=(t,e)=>{let r=1<=r&&(t=t%r),t},ht=class{constructor(e,r,i,n){this.tileCache=e,this.maxDataLevel=r,this.levelDiff=i,this.eventQueue=n}dataTilesForBounds(e,r){let i=Math.pow(2,e)/Math.pow(2,Math.ceil(e)),n=[];var a=1,s=this.tileCache.tileSize;if(ethis.tileCache.get(o.data_tile)));return(s=this.eventQueue)==null||s.publish(U.TileFetchEnd),n.map((o,l)=>{let u=i[l];return{data:o,z:e,data_tile:u.data_tile,scale:u.scale,dim:u.dim,origin:u.origin}})})}getDisplayTile(e){return j(this,null,function*(){let r=this.dataTileForDisplayTile(e);return{data:yield this.tileCache.get(r.data_tile),z:e.z,data_tile:r.data_tile,scale:r.scale,origin:r.origin,dim:r.dim}})}queryFeatures(e,r,i){let n=Math.round(i),a=Math.min(n-this.levelDiff,this.maxDataLevel),s=16/(1<{let e=t.levelDiff===void 0?2:t.levelDiff,r=t.maxDataZoom===void 0?14:t.maxDataZoom,i;t.url.url?i=new ze(t.url,!0):t.url.endsWith(".pmtiles")?i=new ze(t.url,!0):i=new Ne(t.url,!0);let n=new $e(i,256*1<{let e=new Map;if(t.sources)for(let[r,i]of Object.entries(t.sources))e.set(r,Le(i));else e.set($,Le(t));return e};var dt=V(W());var wr=(t,e,r,i)=>{let n=t.bbox;return!(n.maxX*e+r.xi.maxX||n.minY*e+r.y>i.maxY||n.maxY*e+r.y[{dataSource:t,dataLayer:e,symbolizer:new J({opacity:.7,fill:r,radius:4}),filter:(i,n)=>n.geomType==Y.Point},{dataSource:t,dataLayer:e,symbolizer:new X({opacity:.5,color:r,width:2}),filter:(i,n)=>n.geomType==Y.Line},{dataSource:t,dataLayer:e,symbolizer:new B({opacity:.5,fill:r,stroke:r,width:1}),filter:(i,n)=>n.geomType==Y.Polygon}],Ri=(t,e)=>{var r=[];for(var[i,n]of t)for(var a of n.data.keys())i===e.dataSource&&a===e.dataLayer||(r=r.concat(vr(i,a,"#999")));return r=r.concat(vr(e.dataSource||"",e.dataLayer,"steelblue")),r};function ct(t,e,r,i,n,a,s,o,l,u){let h=performance.now();t.save(),t.miterLimit=2;for(var c of r){u&&(n=Ri(c,u));for(var d of n){if(d.minzoom&&ed.maxzoom)continue;let f=c.get(d.dataSource||$);if(!f)continue;var p=f.data.get(d.dataLayer);if(p===void 0)continue;d.symbolizer.before&&d.symbolizer.before(t,f.z),t.save();let m=f.origin,y=f.dim,g=f.scale;if(t.translate(m.x-s.x,m.y-s.y),d.symbolizer.drawGrouped)d.symbolizer.drawGrouped(t,f.z,p,b=>wr(b,g,m,a),g!=1?b=>ce(b,g,new dt.default(0,0)):b=>b,b=>d.filter?d.filter(f.z,b):!0);else if(d.symbolizer.draw)for(var w of p){let b=w.geom;!wr(w,g,m,a)||d.filter&&!d.filter(f.z,w)||(g!=1&&(b=ce(b,g,new dt.default(0,0))),d.symbolizer.draw(t,b,f.z,w))}t.restore()}}if(o&&(t.beginPath(),t.rect(a.minX-s.x,a.minY-s.y,a.maxX-a.minX,a.maxY-a.minY),t.clip()),i&&!u){let f=i.searchBbox(a,1/0);for(var _ of f)if(t.save(),t.translate(_.anchor.x-s.x,_.anchor.y-s.y),_.draw(t),t.restore(),l){t.lineWidth=.5,t.strokeStyle=l,t.fillStyle=l,t.globalAlpha=1,t.fillRect(_.anchor.x-s.x-2,_.anchor.y-s.y-2,4,4);for(let m of _.bboxes)t.strokeRect(m.minX-s.x,m.minY-s.y,m.maxX-m.minX,m.maxY-m.minY)}}return t.restore(),performance.now()-h}var Fr=V(W());var zr=V(_r()),Sr=(t,e,r)=>{let i=256,n=e/i,a=Math.floor(r.minX/i),s=Math.floor(r.minY/i),o=Math.floor(r.maxX/i),l=Math.floor(r.maxY/i),u=Math.log2(n),h=[];for(let c=a;c<=o;c++){let d=c%(1<this.dim&&(o=!0)}if(s||o){var u=s?this.dim:-this.dim,h=[];for(let p of e.bboxes)h.push({minX:p.minX+u,minY:p.minY,maxX:p.maxX+u,maxY:p.maxY});let c={anchor:new Fr.default(e.anchor.x+u,e.anchor.y),bboxes:h,draw:e.draw,order:r,tileKey:i},d=this.current.get(i);d&&d.add(c);for(let p of h){var l=p;l.indexed_label=c,this.tree.insert(l)}}}pruneOrNoop(e){let r=e.split(":"),i,n=0,a=0;for(var s of this.current.keys()){let o=s.split(":");if(o[3]===r[3]){a++;let l=Math.sqrt(Math.pow(+o[0]-+r[0],2)+Math.pow(+o[1]-+r[1],2));l>n&&(n=l,i=s)}i&&a>this.maxLabeledTiles&&this.pruneKey(i)}}pruneKey(e){let r=this.current.get(e);if(!r)return;let i=[];for(let n of this.tree.all())r.has(n.indexed_label)&&i.push(n);i.forEach(n=>{this.tree.remove(n)}),this.current.delete(e)}removeLabel(e){let r=[];for(let n of this.tree.all())e==n.indexed_label&&r.push(n);r.forEach(n=>{this.tree.remove(n)});let i=this.current.get(e.tileKey);i&&i.delete(e)}},yt=class{constructor(e,r,i,n,a){this.index=new bt(256*1<l.maxzoom)continue;let u=l.dataSource||$,h=e.get(u);if(!h)continue;let c=G(h.data_tile)+":"+u;if(!i.has(c))continue;let d=h.data.get(l.dataLayer);if(d===void 0)continue;let p=d;l.sort&&p.sort((_,f)=>l.sort?l.sort(_.props,f.props):0);let w={index:this.index,zoom:this.z,scratch:this.scratch,order:o,overzoom:this.z-h.data_tile.z};for(let _ of p){if(l.filter&&!l.filter(this.z,_))continue;let f=ce(_.geom,h.scale,h.origin),m=l.symbolizer.place(w,f,_);if(!!m)for(let y of m){var a=!1;if(!(y.deduplicationKey&&this.index.deduplicationCollides(y))){if(this.index.labelCollides(y,1/0)){if(!this.index.labelCollides(y,o)){let g=this.index.searchLabel(y,1/0);for(let b of g){this.index.removeLabel(b);for(let x of b.bboxes)this.findInvalidatedTiles(n,h.dim,x,c)}this.index.insert(y,o,c),a=!0}}else this.index.insert(y,o,c),a=!0;if(a)for(let g of y.bboxes)(g.maxX>h.origin.x+h.dim||g.minXh.origin.y+h.dim)&&this.findInvalidatedTiles(n,h.dim,g,c)}}}}for(var s of i)this.index.pruneOrNoop(s);return n.size>0&&this.callback&&this.callback(n),performance.now()-r}findInvalidatedTiles(e,r,i,n){let a=Sr(this.z,r,i);for(let s of a)s.key!=n&&this.index.has(s.key)&&e.add(s.display)}add(e){var r=!0;for(let[i,n]of e)this.index.has(G(n.data_tile)+":"+i)||(r=!1);return r?0:this.layout(e)}},ke=class{constructor(e,r,i,n){this.labelers=new Map,this.scratch=e,this.labelRules=r,this.maxLabeledTiles=i,this.callback=n}add(e,r){var i=this.labelers.get(e);return i||(i=new yt(e,this.scratch,this.labelRules,this.maxLabeledTiles,this.callback),this.labelers.set(e,i)),i.add(r)}getIndex(e){let r=this.labelers.get(e);if(r)return r.index}};var We={earth:"#FFFBF6",glacier:"#ffffff",residential:"#F4F4F8",hospital:"#FFF6F6",cemetery:"#EFF2EE",school:"#F7F6FF",industrial:"#FFF9EF",wood:"#F4F9EF",grass:"#EBF9E3",park:"#E5F9D5",water:"#B7DFF2",sand:"#ebebeb",buildings:"#F2EDE8",highwayCasing:"#FFC3C3",majorRoadCasing:"#FFB9B9",mediumRoadCasing:"#FFCE8E",minorRoadCasing:"#cccccc",highway:"#FFCEBB",majorRoad:"#FFE4B3",mediumRoad:"#FFF2C8",minorRoad:"#ffffff",boundaries:"#9e9e9e",mask:"#dddddd",countryLabel:"#aaaaaa",cityLabel:"#6C6C6C",stateLabel:"#999999",neighbourhoodLabel:"#888888",landuseLabel:"#898989",waterLabel:"#41ABDC",naturalLabel:"#4B8F14",roadsLabel:"#888888",poisLabel:"#606060"};var Ue={earth:"#151515",glacier:"#1c1c1c",residential:"#252B2F",hospital:"#3E2C2C",cemetery:"#36483D",school:"#2C3440",industrial:"#33312C",wood:"#3A3E38",grass:"#4E604D",park:"#2C4034",water:"#4D5B73",sand:"#777777",buildings:"#464545",highwayCasing:"#000000",majorRoadCasing:"#1C1B1B",mediumRoadCasing:"#3E3E3E",minorRoadCasing:"#000000",highway:"#5B5B5B",majorRoad:"#595959",mediumRoad:"#4F4F4F",minorRoad:"#393939",boundaries:"#666666",mask:"#dddddd",countryLabel:"#ffffff",cityLabel:"#FFFFFF",stateLabel:"#ffffff",neighbourhoodLabel:"#FDFDFD",landuseLabel:"#DDDDDD",waterLabel:"#707E95",naturalLabel:"#4c4c4c",roadsLabel:"#C4C4C4",poisLabel:"#959393"};function Me(t,e,r){return Math.min(Math.max(t,r),e)}var me=class extends Error{constructor(e){super(`Failed to parse color: "${e}"`)}};function Yi(t){if(typeof t!="string")throw new me(t);if(t.trim().toLowerCase()==="transparent")return[0,0,0,0];let e=t.trim();e=ji.test(t)?function(s){let o=s.toLowerCase().trim(),l=Ei[function(u){let h=5381,c=u.length;for(;c;)h=33*h^u.charCodeAt(--c);return(h>>>0)%2341}(o)];if(!l)throw new me(s);return`#${l}`}(t):t;let r=Ii.exec(e);if(r){let s=Array.from(r).slice(1);return[...s.slice(0,3).map(o=>parseInt(Pe(o,2),16)),parseInt(Pe(s[3]||"f",2),16)/255]}let i=Vi.exec(e);if(i){let s=Array.from(i).slice(1);return[...s.slice(0,3).map(o=>parseInt(o,16)),parseInt(s[3]||"ff",16)/255]}let n=Ni.exec(e);if(n){let s=Array.from(n).slice(1);return[...s.slice(0,3).map(o=>parseInt(o,10)),parseFloat(s[3]||"1")]}let a=qi.exec(e);if(a){let[s,o,l,u]=Array.from(a).slice(1).map(parseFloat);if(Me(0,100,o)!==o)throw new me(t);if(Me(0,100,l)!==l)throw new me(t);return[...$i(s,o,l),u||1]}throw new me(t)}var Lr=t=>parseInt(t.replace(/_/g,""),36),Ei="1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm".split(" ").reduce((t,e)=>{let r=Lr(e.substring(0,3)),i=Lr(e.substring(3)).toString(16),n="";for(let a=0;a<6-i.length;a++)n+="0";return t[r]=`${n}${i}`,t},{}),Pe=(t,e)=>Array.from(Array(e)).map(()=>t).join(""),Ii=new RegExp(`^#${Pe("([a-f0-9])",3)}([a-f0-9])?$`,"i"),Vi=new RegExp(`^#${Pe("([a-f0-9]{2})",3)}([a-f0-9]{2})?$`,"i"),Ni=new RegExp(`^rgba?\\(\\s*(\\d+)\\s*${Pe(",\\s*(\\d+)\\s*",2)}(?:,\\s*([\\d.]+))?\\s*\\)$`,"i"),qi=/^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i,ji=/^[a-z]+$/i,kr=t=>Math.round(255*t),$i=(t,e,r)=>{let i=r/100;if(e===0)return[i,i,i].map(kr);let n=(t%360+360)%360/60,a=(1-Math.abs(2*i-1))*(e/100),s=a*(1-Math.abs(n%2-1)),o=0,l=0,u=0;n>=0&&n<1?(o=a,l=s):n>=1&&n<2?(o=s,l=a):n>=2&&n<3?(l=a,u=s):n>=3&&n<4?(l=s,u=a):n>=4&&n<5?(o=s,u=a):n>=5&&n<6&&(o=a,u=s);let h=i-a/2;return[o+h,l+h,u+h].map(kr)};function xt(t){let[e,r,i,n]=Yi(t).map((u,h)=>h===3?u:u/255),a=Math.max(e,r,i),s=Math.min(e,r,i),o=(a+s)/2;if(a===s)return[0,0,o,n];let l=a-s;return[60*(e===a?(r-i)/l+(r.5?l/(2-a-s):l/(a+s),o,n]}function Mr(t,e,r,i){return`hsla(${(t%360).toFixed()}, ${Me(0,100,100*e).toFixed()}%, ${Me(0,100,100*r).toFixed()}%, ${parseFloat(Me(0,1,i).toFixed(3))})`}var Pr=(t,e)=>{let r=xt(e),i=kt({},t);for(let[n,a]of Object.entries(t)){let s=xt(a);i[n]=Mr(r[0],r[1],s[2],s[3])}return i},Ze=(t,e)=>(e&&(t=Pr(t,e)),[{dataLayer:"earth",symbolizer:new B({fill:t.earth})},{dataLayer:"natural",symbolizer:new B({fill:t.glacier}),filter:(r,i)=>i.props.natural=="glacier"},{dataLayer:"landuse",symbolizer:new B({fill:t.residential}),filter:(r,i)=>i.props.landuse=="residential"||i.props.place=="neighbourhood"},{dataLayer:"landuse",symbolizer:new B({fill:t.hospital}),filter:(r,i)=>i.props.amenity=="hospital"},{dataLayer:"landuse",symbolizer:new B({fill:t.cemetery}),filter:(r,i)=>i.props.landuse=="cemetery"},{dataLayer:"landuse",symbolizer:new B({fill:t.school}),filter:(r,i)=>i.props.amenity=="school"||i.props.amenity=="kindergarten"||i.props.amenity=="university"||i.props.amenity=="college"},{dataLayer:"landuse",symbolizer:new B({fill:t.industrial}),filter:(r,i)=>i.props.landuse=="industrial"},{dataLayer:"natural",symbolizer:new B({fill:t.wood}),filter:(r,i)=>i.props.natural=="wood"},{dataLayer:"landuse",symbolizer:new B({fill:t.grass}),filter:(r,i)=>i.props.landuse=="grass"},{dataLayer:"landuse",symbolizer:new B({fill:t.park}),filter:(r,i)=>i.props.leisure=="park"},{dataLayer:"water",symbolizer:new B({fill:t.water})},{dataLayer:"natural",symbolizer:new B({fill:t.sand}),filter:(r,i)=>i.props.natural=="sand"},{dataLayer:"buildings",symbolizer:new B({fill:t.buildings})},{dataLayer:"roads",symbolizer:new X({color:t.highwayCasing,width:I(1.4,[[5,1.5],[11,4],[16,9],[20,40]])}),filter:(r,i)=>i.props["pmap:kind"]=="highway"},{dataLayer:"roads",symbolizer:new X({color:t.majorRoadCasing,width:I(1.4,[[9,3],[12,4],[17,8],[20,22]])}),filter:(r,i)=>i.props["pmap:kind"]=="major_road"},{dataLayer:"roads",symbolizer:new X({color:t.mediumRoadCasing,width:I(1.4,[[13,3],[17,6],[20,18]])}),filter:(r,i)=>i.props["pmap:kind"]=="medium_road"},{dataLayer:"roads",symbolizer:new X({color:t.minorRoadCasing,width:I(1.4,[[14,2],[17,5],[20,15]])}),filter:(r,i)=>i.props["pmap:kind"]=="minor_road"},{dataLayer:"roads",symbolizer:new X({color:t.minorRoad,width:I(1.4,[[14,1],[17,3],[20,13]])}),filter:(r,i)=>i.props["pmap:kind"]=="minor_road"},{dataLayer:"roads",symbolizer:new X({color:t.mediumRoad,width:I(1.4,[[13,2],[17,4],[20,15]])}),filter:(r,i)=>i.props["pmap:kind"]=="medium_road"},{dataLayer:"roads",symbolizer:new X({color:t.majorRoad,width:I(1.4,[[9,2],[12,3],[17,6],[20,20]])}),filter:(r,i)=>i.props["pmap:kind"]=="major_road"},{dataLayer:"roads",symbolizer:new X({color:t.highway,width:I(1.4,[[5,.5],[11,2.5],[16,7],[20,30]])}),filter:(r,i)=>i.props["pmap:kind"]=="highway"},{dataLayer:"boundaries",symbolizer:new X({color:t.boundaries,width:2,opacity:.4})},{dataLayer:"mask",symbolizer:new B({fill:t.mask})}]),Oe=(t,e,r,i)=>{e&&(t=Pr(t,e));var n=["name"];r&&(n=r);let a=(s,o)=>i?s instanceof te?new _e([s,new te({fill:o,label_props:i})],{}):new _e([s,new Z({fill:o,label_props:i})],{}):s;return[{dataLayer:"places",symbolizer:a(new Z({label_props:n,fill:t.countryLabel,lineHeight:1.5,font:(s,o)=>s<6?"200 14px sans-serif":"200 20px sans-serif",textTransform:"uppercase"}),t.countryLabel),filter:(s,o)=>o.props["pmap:kind"]=="country"},{dataLayer:"places",symbolizer:a(new Z({label_props:n,fill:t.stateLabel,font:"300 16px sans-serif"}),t.stateLabel),filter:(s,o)=>o.props["pmap:kind"]=="state"},{id:"cities_high",dataLayer:"places",filter:(s,o)=>o.props["pmap:kind"]=="city",minzoom:7,symbolizer:a(new Z({label_props:n,fill:t.cityLabel,font:(s,o)=>o.props["pmap:rank"]==1?s>8?"600 20px sans-serif":"600 12px sans-serif":s>8?"600 16px sans-serif":"600 10px sans-serif"}),t.cityLabel),sort:(s,o)=>s["pmap:rank"]-o["pmap:rank"]},{id:"cities_low",dataLayer:"places",filter:(s,o)=>o.props["pmap:kind"]=="city",maxzoom:6,symbolizer:new Fe([new J({radius:2,fill:t.cityLabel}),a(new te({label_props:n,fill:t.cityLabel,offset:2,font:(s,o)=>o.props["pmap:rank"]==1?s>8?"600 20px sans-serif":"600 12px sans-serif":s>8?"600 16px sans-serif":"600 10px sans-serif"}),t.cityLabel)]),sort:(s,o)=>s["pmap:rank"]-o["pmap:rank"]},{id:"neighbourhood",dataLayer:"places",symbolizer:a(new Z({label_props:n,fill:t.neighbourhoodLabel,font:"500 10px sans-serif",textTransform:"uppercase"}),t.neighbourhoodLabel),filter:(s,o)=>o.props["pmap:kind"]=="neighbourhood"},{dataLayer:"landuse",symbolizer:a(new de({label_props:n,fill:t.landuseLabel,font:"300 12px sans-serif"}),t.landuseLabel)},{dataLayer:"water",symbolizer:a(new de({label_props:n,fill:t.waterLabel,font:"italic 600 12px sans-serif"}),t.waterLabel)},{dataLayer:"natural",symbolizer:a(new de({label_props:n,fill:t.naturalLabel,font:"italic 300 12px sans-serif"}),t.naturalLabel)},{dataLayer:"roads",symbolizer:a(new fe({label_props:n,fill:t.roadsLabel,font:"500 12px sans-serif"}),t.roadsLabel),minzoom:12},{dataLayer:"roads",symbolizer:new Ye({label_props:["ref"],font:"600 9px sans-serif",background:t.highway,padding:2,fill:t.neighbourhoodLabel}),filter:(s,o)=>o.props["pmap:kind"]=="highway"},{dataLayer:"pois",symbolizer:new Fe([new J({radius:2,fill:t.poisLabel}),a(new te({label_props:n,fill:t.poisLabel,offset:2,font:"300 10px sans-serif"}),t.poisLabel)])}]};var ie=256,Wi=t=>new Promise((e,r)=>{setTimeout(()=>{e()},t)}),Ui=t=>t.then(e=>({status:"fulfilled",value:e}),e=>({status:"rejected",reason:e})),Zi=t=>{class e extends L.GridLayer{constructor(i){i.noWrap&&!i.bounds&&(i.bounds=[[-90,-180],[90,180]]),i.attribution==null&&(i.attribution='Protomaps \xA9 OpenStreetMap');super(i);let n=i.dark?Ue:We;this.paint_rules=i.paint_rules||Ze(n,i.shade),this.label_rules=i.label_rules||Oe(n,i.shade,i.language1,i.language2),this.backgroundColor=i.backgroundColor,this.lastRequestedZ=void 0,this.xray=i.xray,this.tasks=i.tasks||[],this.views=ft(i),this.debug=i.debug;let a=document.createElement("canvas").getContext("2d");this.scratch=a,this.onTilesInvalidated=s=>{s.forEach(o=>{this.rerenderTile(o)})},this.labelers=new ke(this.scratch,this.label_rules,16,this.onTilesInvalidated),this.tile_size=ie*window.devicePixelRatio,this.tileDelay=i.tileDelay||3,this.lang=i.lang,this.inspector=this.inspect(this)}setDefaultStyle(i,n,a,s){let o=i?Ue:We;this.paint_rules=Ze(o,n),this.label_rules=Oe(o,n,a,s)}renderTile(i,n,a,s=()=>{}){return j(this,null,function*(){this.lastRequestedZ=i.z;let o=[];for(let[v,F]of this.views){let z=F.getDisplayTile(i);o.push({key:v,promise:z})}let l=yield Promise.all(o.map(v=>v.promise.then(F=>({status:"fulfilled",value:F,key:v.key}),F=>({status:"rejected",reason:F,key:v.key})))),u=new Map;for(let v of l)v.status==="fulfilled"&&u.set(v.key,v.value);if(n.key!=a||this.lastRequestedZ!==i.z||(yield Promise.all(this.tasks.map(Ui)),n.key!=a)||this.lastRequestedZ!==i.z)return;let h=this.labelers.add(i.z,u);if(n.key!=a||this.lastRequestedZ!==i.z)return;let c=this.labelers.getIndex(i.z);if(!this._map)return;let d=this._map.getCenter().wrap(),p=this._getTiledPixelBounds(d),w=this._pxBoundsToTileRange(p),_=w.getCenter(),f=i.distanceTo(_)*this.tileDelay;if(yield Wi(f),n.key!=a||this.lastRequestedZ!==i.z)return;let m=16,y={minX:256*i.x-m,minY:256*i.y-m,maxX:256*(i.x+1)+m,maxY:256*(i.y+1)+m},g=new Cr.default(256*i.x+.5,256*i.y+.5);n.width=this.tile_size,n.height=this.tile_size;let b=n.getContext("2d");b.setTransform(this.tile_size/ie,0,0,this.tile_size/ie,0,0),b.clearRect(0,0,ie,ie),this.backgroundColor&&(b.save(),b.fillStyle=this.backgroundColor,b.fillRect(0,0,ie,ie),b.restore());var x=0;if(x=ct(b,i.z,[u],c,this.paint_rules,y,g,!1,this.debug,this.xray),this.debug){if(b.save(),b.fillStyle=this.debug,b.font="600 12px sans-serif",b.fillText(i.z+" "+i.x+" "+i.y,4,14),u.size!==0){let[v]=u.values(),F=v.data_tile;b.font="200 12px sans-serif",b.fillText(F.z+" "+F.x+" "+F.y,4,28)}b.font="600 10px sans-serif",x>8&&b.fillText(x.toFixed()+" ms paint",4,42),h>8&&b.fillText(h.toFixed()+" ms layout",4,56),b.strokeStyle=this.debug,b.lineWidth=6,b.beginPath(),b.moveTo(0,0),b.lineTo(0,256),b.stroke(),b.lineWidth=6,b.beginPath(),b.moveTo(0,0),b.lineTo(256,0),b.stroke(),b.restore()}s()})}rerenderTile(i){for(let n in this._tiles){let a=this._wrapCoords(this._keyToTileCoords(n));i===this._tileCoordsToKey(a)&&this.renderTile(a,this._tiles[n].el,i)}}clearLayout(){this.labelers=new ke(this.scratch,this.label_rules,16,this.onTilesInvalidated)}rerenderTiles(){this.fire(U.RerenderStart);let i=[];for(let n in this._tiles){let a=this._wrapCoords(this._keyToTileCoords(n)),s=this._tileCoordsToKey(a);i.push(this.renderTile(a,this._tiles[n].el,s))}Promise.all(i).then(()=>this.fire(U.RerenderEnd))}createTile(i,n){let a=L.DomUtil.create("canvas","leaflet-tile");a.lang=this.lang;let s=this._tileCoordsToKey(i);return a.key=s,this.renderTile(i,a,s,()=>{n(null,a)}),a}_removeTile(i){let n=this._tiles[i];!n||(n.el.removed=!0,n.el.key=void 0,L.DomUtil.removeClass(n.el,"leaflet-tile-loaded"),n.el.width=n.el.height=0,L.DomUtil.remove(n.el),delete this._tiles[i],this.fire("tileunload",{tile:n.el,coords:this._keyToTileCoords(i)}))}queryFeatures(i,n){let a=new Map;for(var[s,o]of this.views)a.set(s,o.queryFeatures(i,n,this._map.getZoom()));return a}queryRenderedFeatures(i,n){let a=new Map;for(var[s,o]of this.views){let l=this._map.getZoom(),h=o.queryFeatures(i,n,l).reduce((d,p)=>(d[p.layerName]||(d[p.layerName]=[]),d[p.layerName].push(p),d),{}),c=[];for(let d of this.paint_rules){if(d.minzoom&&ld.maxzoom)continue;let p=h[d.dataLayer];if(!!p)if(d.filter)for(let w of p)d.filter(l,w.feature)&&c.push(w);else c.push(...p)}a.set(s,c)}return a}inspect(i){return n=>{let a=["\u25CE","\u27CD","\u25FB"],s=i._map.wrapLatLng(n.latlng),o=i.queryFeatures(s.lng,s.lat);var l="";let u=!0;for(var[h,c]of o)for(var d of c)if(!(this.xray&&this.xray!==!0&&!(this.xray.dataSource===h&&this.xray.dataLayer===d.layerName))){l=l+`
${a[d.feature.geomType-1]} ${h} ${h?"/":""} ${d.layerName} ${d.feature.id||""}
`;for(let p in d.feature.props)l=l+`
${p} = ${d.feature.props[p]}
`;u=!1}u&&(l="No features."),L.popup().setLatLng(n.latlng).setContent('
'+l+"
").openOn(i._map)}}addInspector(i){return i.on("click",this.inspector)}removeInspector(i){return i.off("click",this.inspector)}updateDataSources(i,n=!1){let a=[];this.paint_rules=this.paint_rules.filter(s=>!s.dataSource||s.dataSource===$),this.label_rules=this.label_rules.filter(s=>!s.dataSource||s.dataSource===$),this.views.forEach((s,o)=>{o!==$&&this.views.delete(o)}),i.forEach(s=>{s.name===$&&console.warn("Overwritting the basemap using updateDataSources will result in duplicated rules"),this.views.set(s.name,Le(s.options)),this.paint_rules=this.paint_rules.concat(s.paintRules),a.unshift(...s.labelRules)}),a.length!==0&&(this.label_rules=n?a.concat(this.label_rules):this.label_rules.concat(a))}subscribeChildEvents(){this.eventQueue.subscribe(U.TileFetchStart,this.fireEvent),this.eventQueue.subscribe(U.TileFetchEnd,this.fireEvent)}fireEvent(i){this.fire(i)}}return new e(t)};var Oi=t=>{let e=0,r=0;for(let o of t)e+=o.w*o.h,r=Math.max(r,o.w);t.sort((o,l)=>l.h-o.h);let i=Math.max(Math.ceil(Math.sqrt(e/.95)),r),n=[{x:0,y:0,w:i,h:1/0}],a=0,s=0;for(let o of t)for(let l=n.length-1;l>=0;l--){let u=n[l];if(!(o.w>u.w||o.h>u.h)){if(o.x=u.x,o.y=u.y,s=Math.max(s,o.y+o.h),a=Math.max(a,o.x+o.w),o.w===u.w&&o.h===u.h){let h=n.pop();lnew Promise((e,r)=>{let i=new Image;i.onload=()=>e(i),i.onerror=()=>r("Invalid SVG"),i.src=t}),Hi=` diff --git a/dist/protomaps.module.js b/dist/protomaps.module.js index bac1dd52..306c4d19 100644 --- a/dist/protomaps.module.js +++ b/dist/protomaps.module.js @@ -3393,19 +3393,29 @@ var TileCache = class { }; for (let [layer_name, layer_arr] of entry.data.entries()) { for (let feature of layer_arr) { + let intersectedFeature; if (feature.geomType == 1) { if (pointMinDistToPoints(center, feature.geom) < brushSize) { - retval.push({ feature, layerName: layer_name }); + intersectedFeature = feature; } } else if (feature.geomType == 2) { if (pointMinDistToLines(center, feature.geom) < brushSize) { - retval.push({ feature, layerName: layer_name }); + intersectedFeature = feature; } } else { if (pointInPolygon(center, feature.geom)) { - retval.push({ feature, layerName: layer_name }); + intersectedFeature = feature; } } + if (intersectedFeature) { + retval.push({ + feature: intersectedFeature, + layerName: layer_name, + tileX: tile_x, + tileY: tile_y, + zoom + }); + } } } } diff --git a/dist/tilecache.d.ts b/dist/tilecache.d.ts index ed47ed6b..a76d8b86 100644 --- a/dist/tilecache.d.ts +++ b/dist/tilecache.d.ts @@ -53,6 +53,9 @@ export declare function pointMinDistToLines(point: Point, geom: Point[][]): numb export interface PickedFeature { feature: Feature; layerName: string; + tileX: number; + tileY: number; + zoom: number; } export declare class TileCache { source: TileSource; diff --git a/dist/tilecache.js b/dist/tilecache.js index 188e7ab2..0e7931ef 100644 --- a/dist/tilecache.js +++ b/dist/tilecache.js @@ -315,21 +315,31 @@ export class TileCache { // if ((query_bbox.maxX >= feature.bbox.minX && feature.bbox.maxX >= query_bbox.minX) && // (query_bbox.maxY >= feature.bbox.minY && feature.bbox.maxY >= query_bbox.minY)) { // } + let intersectedFeature; if (feature.geomType == GeomType.Point) { if (pointMinDistToPoints(center, feature.geom) < brushSize) { - retval.push({ feature, layerName: layer_name }); + intersectedFeature = feature; } } else if (feature.geomType == GeomType.Line) { if (pointMinDistToLines(center, feature.geom) < brushSize) { - retval.push({ feature, layerName: layer_name }); + intersectedFeature = feature; } } else { if (pointInPolygon(center, feature.geom)) { - retval.push({ feature, layerName: layer_name }); + intersectedFeature = feature; } } + if (intersectedFeature) { + retval.push({ + feature: intersectedFeature, + layerName: layer_name, + tileX: tile_x, + tileY: tile_y, + zoom, + }); + } } } } diff --git a/src/tilecache.ts b/src/tilecache.ts index 61132cbd..35d8aab7 100644 --- a/src/tilecache.ts +++ b/src/tilecache.ts @@ -339,6 +339,9 @@ export function pointMinDistToLines(point: Point, geom: Point[][]): number { export interface PickedFeature { feature: Feature; layerName: string; + tileX: number; + tileY: number; + zoom: number; } export class TileCache { @@ -385,19 +388,29 @@ export class TileCache { // (query_bbox.maxY >= feature.bbox.minY && feature.bbox.maxY >= query_bbox.minY)) { // } + let intersectedFeature; if (feature.geomType == GeomType.Point) { if (pointMinDistToPoints(center, feature.geom) < brushSize) { - retval.push({ feature, layerName: layer_name }); + intersectedFeature = feature; } } else if (feature.geomType == GeomType.Line) { if (pointMinDistToLines(center, feature.geom) < brushSize) { - retval.push({ feature, layerName: layer_name }); + intersectedFeature = feature; } } else { if (pointInPolygon(center, feature.geom)) { - retval.push({ feature, layerName: layer_name }); + intersectedFeature = feature; } } + if (intersectedFeature) { + retval.push({ + feature: intersectedFeature, + layerName: layer_name, + tileX: tile_x, + tileY: tile_y, + zoom, + }); + } } } }