@loaders.gl/pmtiles 4.3.0-alpha.2 → 4.3.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +258 -242
- package/dist/dist.min.js +1 -1
- package/dist/index.cjs +20 -4
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/pmtiles-source.d.ts +29 -23
- package/dist/pmtiles-source.d.ts.map +1 -1
- package/dist/pmtiles-source.js +13 -8
- package/package.json +6 -6
- package/src/index.ts +4 -2
- package/src/pmtiles-source.ts +30 -33
package/dist/dist.min.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['loaders'] = factory();
|
|
6
6
|
else root['loaders'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var wr=Object.create;var fe=Object.defineProperty;var vr=Object.getOwnPropertyDescriptor;var Tr=Object.getOwnPropertyNames;var Ir=Object.getPrototypeOf,Pr=Object.prototype.hasOwnProperty;var Fr=(e,t,n)=>t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Qe=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),zt=(e,t)=>{for(var n in t)fe(e,n,{get:t[n],enumerable:!0})},Be=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Tr(t))!Pr.call(e,o)&&o!==n&&fe(e,o,{get:()=>t[o],enumerable:!(r=vr(t,o))||r.enumerable});return e},Ae=(e,t,n)=>(Be(e,t,"default"),n&&Be(n,t,"default")),jt=(e,t,n)=>(n=e!=null?wr(Ir(e)):{},Be(t||!e||!e.__esModule?fe(n,"default",{value:e,enumerable:!0}):n,e)),br=e=>Be(fe({},"__esModule",{value:!0}),e);var Rt=(e,t,n)=>(Fr(e,typeof t!="symbol"?t+"":t,n),n);var Zt=Qe((ds,Ht)=>{Ht.exports=globalThis.loaders});var vn=Qe(yt=>{yt.read=function(e,t,n,r,o){var i,s,a=o*8-r-1,l=(1<<a)-1,c=l>>1,f=-7,u=n?o-1:0,h=n?-1:1,d=e[t+u];for(u+=h,i=d&(1<<-f)-1,d>>=-f,f+=a;f>0;i=i*256+e[t+u],u+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=r;f>0;s=s*256+e[t+u],u+=h,f-=8);if(i===0)i=1-c;else{if(i===l)return s?NaN:(d?-1:1)*(1/0);s=s+Math.pow(2,r),i=i-c}return(d?-1:1)*s*Math.pow(2,i-r)};yt.write=function(e,t,n,r,o,i){var s,a,l,c=i*8-o-1,f=(1<<c)-1,u=f>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,p=r?1:-1,y=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+u>=1?t+=h/l:t+=h*Math.pow(2,1-u),t*l>=2&&(s++,l/=2),s+u>=f?(a=0,s=f):s+u>=1?(a=(t*l-1)*Math.pow(2,o),s=s+u):(a=t*Math.pow(2,u-1)*Math.pow(2,o),s=0));o>=8;e[n+d]=a&255,d+=p,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[n+d]=s&255,d+=p,s/=256,c-=8);e[n+d-p]|=y*128}});var En=Qe((Ml,bn)=>{"use strict";bn.exports=x;var ze=vn();function x(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}x.Varint=0;x.Fixed64=1;x.Bytes=2;x.Fixed32=5;var xt=(1<<16)*(1<<16),Tn=1/xt,Zo=12,Fn=typeof TextDecoder>"u"?null:new TextDecoder("utf8");x.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos<n;){var r=this.readVarint(),o=r>>3,i=this.pos;this.type=r&7,e(o,t,this),this.pos===i&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=je(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Pn(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=je(this.buf,this.pos)+je(this.buf,this.pos+4)*xt;return this.pos+=8,e},readSFixed64:function(){var e=je(this.buf,this.pos)+Pn(this.buf,this.pos+4)*xt;return this.pos+=8,e},readFloat:function(){var e=ze.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=ze.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t=this.buf,n,r;return r=t[this.pos++],n=r&127,r<128||(r=t[this.pos++],n|=(r&127)<<7,r<128)||(r=t[this.pos++],n|=(r&127)<<14,r<128)||(r=t[this.pos++],n|=(r&127)<<21,r<128)?n:(r=t[this.pos],n|=(r&15)<<28,Wo(n,e,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2===1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=Zo&&Fn?si(this.buf,t,e):ii(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==x.Bytes)return e.push(this.readVarint(t));var n=j(this);for(e=e||[];this.pos<n;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==x.Bytes)return e.push(this.readSVarint());var t=j(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==x.Bytes)return e.push(this.readBoolean());var t=j(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==x.Bytes)return e.push(this.readFloat());var t=j(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==x.Bytes)return e.push(this.readDouble());var t=j(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==x.Bytes)return e.push(this.readFixed32());var t=j(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==x.Bytes)return e.push(this.readSFixed32());var t=j(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==x.Bytes)return e.push(this.readFixed64());var t=j(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==x.Bytes)return e.push(this.readSFixed64());var t=j(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=e&7;if(t===x.Varint)for(;this.buf[this.pos++]>127;);else if(t===x.Bytes)this.pos=this.readVarint()+this.pos;else if(t===x.Fixed32)this.pos+=4;else if(t===x.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+t)},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var n=new Uint8Array(t);n.set(this.buf),this.buf=n,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),ie(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),ie(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),ie(this.buf,e&-1,this.pos),ie(this.buf,Math.floor(e*Tn),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),ie(this.buf,e&-1,this.pos),ie(this.buf,Math.floor(e*Tn),this.pos+4),this.pos+=8},writeVarint:function(e){if(e=+e||0,e>268435455||e<0){Jo(e,this);return}this.realloc(4),this.buf[this.pos++]=e&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=e>>>7&127)))},writeSVarint:function(e){this.writeVarint(e<0?-e*2-1:e*2)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(e.length*4),this.pos++;var t=this.pos;this.pos=ai(this.buf,e,this.pos);var n=this.pos-t;n>=128&&In(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),ze.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),ze.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n<t;n++)this.buf[this.pos++]=e[n]},writeRawMessage:function(e,t){this.pos++;var n=this.pos;e(t,this);var r=this.pos-n;r>=128&&In(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,n){this.writeTag(e,x.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,Yo,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,Xo,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,ei,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,Qo,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,qo,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,ti,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,ni,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,ri,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,oi,t)},writeBytesField:function(e,t){this.writeTag(e,x.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,x.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,x.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,x.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,x.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,x.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,x.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,x.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,x.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,x.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};function Wo(e,t,n){var r=n.buf,o,i;if(i=r[n.pos++],o=(i&112)>>4,i<128||(i=r[n.pos++],o|=(i&127)<<3,i<128)||(i=r[n.pos++],o|=(i&127)<<10,i<128)||(i=r[n.pos++],o|=(i&127)<<17,i<128)||(i=r[n.pos++],o|=(i&127)<<24,i<128)||(i=r[n.pos++],o|=(i&1)<<31,i<128))return oe(e,o,t);throw new Error("Expected varint not more than 10 bytes")}function j(e){return e.type===x.Bytes?e.readVarint()+e.pos:e.pos+1}function oe(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function Jo(e,t){var n,r;if(e>=0?(n=e%4294967296|0,r=e/4294967296|0):(n=~(-e%4294967296),r=~(-e/4294967296),n^4294967295?n=n+1|0:(n=0,r=r+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),Ko(n,r,t),$o(r,t)}function Ko(e,t,n){n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos]=e&127}function $o(e,t){var n=(e&7)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127)))))}function In(e,t,n){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));n.realloc(r);for(var o=n.pos-1;o>=e;o--)n.buf[o+r]=n.buf[o]}function Yo(e,t){for(var n=0;n<e.length;n++)t.writeVarint(e[n])}function Xo(e,t){for(var n=0;n<e.length;n++)t.writeSVarint(e[n])}function Qo(e,t){for(var n=0;n<e.length;n++)t.writeFloat(e[n])}function qo(e,t){for(var n=0;n<e.length;n++)t.writeDouble(e[n])}function ei(e,t){for(var n=0;n<e.length;n++)t.writeBoolean(e[n])}function ti(e,t){for(var n=0;n<e.length;n++)t.writeFixed32(e[n])}function ni(e,t){for(var n=0;n<e.length;n++)t.writeSFixed32(e[n])}function ri(e,t){for(var n=0;n<e.length;n++)t.writeFixed64(e[n])}function oi(e,t){for(var n=0;n<e.length;n++)t.writeSFixed64(e[n])}function je(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+e[t+3]*16777216}function ie(e,t,n){e[n]=t,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function Pn(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function ii(e,t,n){for(var r="",o=t;o<n;){var i=e[o],s=null,a=i>239?4:i>223?3:i>191?2:1;if(o+a>n)break;var l,c,f;a===1?i<128&&(s=i):a===2?(l=e[o+1],(l&192)===128&&(s=(i&31)<<6|l&63,s<=127&&(s=null))):a===3?(l=e[o+1],c=e[o+2],(l&192)===128&&(c&192)===128&&(s=(i&15)<<12|(l&63)<<6|c&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):a===4&&(l=e[o+1],c=e[o+2],f=e[o+3],(l&192)===128&&(c&192)===128&&(f&192)===128&&(s=(i&15)<<18|(l&63)<<12|(c&63)<<6|f&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,a=1):s>65535&&(s-=65536,r+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),r+=String.fromCharCode(s),o+=a}return r}function si(e,t,n){return Fn.decode(e.subarray(t,n))}function ai(e,t,n){for(var r=0,o,i;r<t.length;r++){if(o=t.charCodeAt(r),o>55295&&o<57344)if(i)if(o<56320){e[n++]=239,e[n++]=191,e[n++]=189,i=o;continue}else o=i-55296<<10|o-56320|65536,i=null;else{o>56319||r+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):i=o;continue}else i&&(e[n++]=239,e[n++]=191,e[n++]=189,i=null);o<128?e[n++]=o:(o<2048?e[n++]=o>>6|192:(o<65536?e[n++]=o>>12|224:(e[n++]=o>>18|240,e[n++]=o>>12&63|128),e[n++]=o>>6&63|128),e[n++]=o&63|128)}return n}});var Se={};zt(Se,{PMTilesSource:()=>Je});Ae(Se,jt(Zt(),1));function ue(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var G={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Er=G.self||G.window||G.global||{},Sr=G.window||G.self||G.global||{},_r=G.global||G.self||G.window||{},Br=G.document||{};var qe=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var Wt=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Ar=Wt&&parseFloat(Wt[1])||0;function H(e){return H=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},H(e)}function et(e,t){if(H(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(H(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function tt(e){var t=et(e,"string");return H(t)==="symbol"?t:String(t)}function T(e,t,n){return t=tt(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nt(e){if(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&Boolean(process.versions.electron))return!0;let t=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,n=e||t;return!!(n&&n.indexOf("Electron")>=0)}function N(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||nt()}var Dr=globalThis.self||globalThis.window||globalThis.global,ee=globalThis.window||globalThis.self||globalThis.global,Lr=globalThis.document||{},W=globalThis.process||{},Vr=globalThis.console,Ss=globalThis.navigator||{};var De=typeof __VERSION__<"u"?__VERSION__:"untranspiled source",As=N();function Mr(e){try{let t=window[e],n="__storage_test__";return t.setItem(n,n),t.removeItem(n),t}catch{return null}}var Le=class{constructor(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"sessionStorage";T(this,"storage",void 0),T(this,"id",void 0),T(this,"config",void 0),this.storage=Mr(r),this.id=t,this.config=n,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){if(Object.assign(this.config,t),this.storage){let n=JSON.stringify(this.config);this.storage.setItem(this.id,n)}}_loadConfiguration(){let t={};if(this.storage){let n=this.storage.getItem(this.id);t=n?JSON.parse(n):{}}return Object.assign(this.config,t),this}};function Jt(e){let t;return e<10?t="".concat(e.toFixed(2),"ms"):e<100?t="".concat(e.toFixed(1),"ms"):e<1e3?t="".concat(e.toFixed(0),"ms"):t="".concat((e/1e3).toFixed(2),"s"),t}function Kt(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8,n=Math.max(t-e.length,0);return"".concat(" ".repeat(n)).concat(e)}function Ve(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:600,o=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>r&&(n=Math.min(n,r/e.width));let i=e.width*n,s=e.height*n,a=["font-size:1px;","padding:".concat(Math.floor(s/2),"px ").concat(Math.floor(i/2),"px;"),"line-height:".concat(s,"px;"),"background:url(".concat(o,");"),"background-size:".concat(i,"px ").concat(s,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),a]}var Me;(function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Me||(Me={}));var Ur=10;function $t(e){return typeof e!="string"?e:(e=e.toUpperCase(),Me[e]||Me.WHITE)}function Yt(e,t,n){if(!N&&typeof e=="string"){if(t){let r=$t(t);e="\x1B[".concat(r,"m").concat(e,"\x1B[39m")}if(n){let r=$t(n);e="\x1B[".concat(r+Ur,"m").concat(e,"\x1B[49m")}}return e}function Xt(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:["constructor"],n=Object.getPrototypeOf(e),r=Object.getOwnPropertyNames(n),o=e;for(let i of r){let s=o[i];typeof s=="function"&&(t.find(a=>i===a)||(o[i]=s.bind(e)))}}function te(e,t){if(!e)throw new Error(t||"Assertion failed")}function J(){let e;if(N()&&ee.performance){var t,n;e=ee===null||ee===void 0||(t=ee.performance)===null||t===void 0||(n=t.now)===null||n===void 0?void 0:n.call(t)}else if("hrtime"in W){var r;let o=W===null||W===void 0||(r=W.hrtime)===null||r===void 0?void 0:r.call(W);e=o[0]*1e3+o[1]/1e6}else e=Date.now();return e}var ne={debug:N()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},kr={enabled:!0,level:0};function D(){}var Qt={},qt={once:!0},Z=class{constructor(){let{id:t}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{id:""};T(this,"id",void 0),T(this,"VERSION",De),T(this,"_startTs",J()),T(this,"_deltaTs",J()),T(this,"_storage",void 0),T(this,"userData",{}),T(this,"LOG_THROTTLE_TIMEOUT",0),this.id=t,this.userData={},this._storage=new Le("__probe-".concat(this.id,"__"),kr),this.timeStamp("".concat(this.id," started")),Xt(this),Object.seal(this)}set level(t){this.setLevel(t)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((J()-this._startTs).toPrecision(10))}getDelta(){return Number((J()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return this._storage.setConfiguration({enabled:t}),this}setLevel(t){return this._storage.setConfiguration({level:t}),this}get(t){return this._storage.config[t]}set(t,n){this._storage.setConfiguration({[t]:n})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,n){te(t,n)}warn(t){return this._getLogFunction(0,t,ne.warn,arguments,qt)}error(t){return this._getLogFunction(0,t,ne.error,arguments)}deprecated(t,n){return this.warn("`".concat(t,"` is deprecated and will be removed in a later version. Use `").concat(n,"` instead"))}removed(t,n){return this.error("`".concat(t,"` has been removed. Use `").concat(n,"` instead"))}probe(t,n){return this._getLogFunction(t,n,ne.log,arguments,{time:!0,once:!0})}log(t,n){return this._getLogFunction(t,n,ne.debug,arguments)}info(t,n){return this._getLogFunction(t,n,console.info,arguments)}once(t,n){return this._getLogFunction(t,n,ne.debug||ne.info,arguments,qt)}table(t,n,r){return n?this._getLogFunction(t,n,console.table||D,r&&[r],{tag:Gr(n)}):D}image(t){let{logLevel:n,priority:r,image:o,message:i="",scale:s=1}=t;return this._shouldLog(n||r)?N()?Or({image:o,message:i,scale:s}):Cr({image:o,message:i,scale:s}):D}time(t,n){return this._getLogFunction(t,n,console.time?console.time:console.info)}timeEnd(t,n){return this._getLogFunction(t,n,console.timeEnd?console.timeEnd:console.info)}timeStamp(t,n){return this._getLogFunction(t,n,console.timeStamp||D)}group(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{collapsed:!1},o=en({logLevel:t,message:n,opts:r}),{collapsed:i}=r;return o.method=(i?console.groupCollapsed:console.group)||console.info,this._getLogFunction(o)}groupCollapsed(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.group(t,n,Object.assign({},r,{collapsed:!0}))}groupEnd(t){return this._getLogFunction(t,"",console.groupEnd||D)}withGroup(t,n,r){this.group(t,n)();try{r()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&this.getLevel()>=tn(t)}_getLogFunction(t,n,r,o,i){if(this._shouldLog(t)){i=en({logLevel:t,message:n,args:o,opts:i}),r=r||i.method,te(r),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=J();let s=i.tag||i.message;if(i.once&&s)if(!Qt[s])Qt[s]=J();else return D;return n=Nr(this.id,i.message,i),r.bind(console,n,...i.args)}return D}};T(Z,"VERSION",De);function tn(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return te(Number.isFinite(t)&&t>=0),t}function en(e){let{logLevel:t,message:n}=e;e.logLevel=tn(t);let r=e.args?Array.from(e.args):[];for(;r.length&&r.shift()!==n;);switch(typeof t){case"string":case"function":n!==void 0&&r.unshift(n),e.message=t;break;case"object":Object.assign(e,t);break;default:}typeof e.message=="function"&&(e.message=e.message());let o=typeof e.message;return te(o==="string"||o==="object"),Object.assign(e,{args:r},e.opts)}function Nr(e,t,n){if(typeof t=="string"){let r=n.time?Kt(Jt(n.total)):"";t=n.time?"".concat(e,": ").concat(r," ").concat(t):"".concat(e,": ").concat(t),t=Yt(t,n.color,n.background)}return t}function Cr(e){let{image:t,message:n="",scale:r=1}=e;return console.warn("removed"),D}function Or(e){let{image:t,message:n="",scale:r=1}=e;if(typeof t=="string"){let i=new Image;return i.onload=()=>{let s=Ve(i,n,r);console.log(...s)},i.src=t,D}let o=t.nodeName||"";if(o.toLowerCase()==="img")return console.log(...Ve(t,n,r)),D;if(o.toLowerCase()==="canvas"){let i=new Image;return i.onload=()=>console.log(...Ve(i,n,r)),i.src=t.toDataURL(),D}return D}function Gr(e){for(let t in e)for(let n in e[t])return n||"untitled";return"empty"}var ra=new Z({id:"@probe.gl/log"});var rt="4.3.0-alpha.1",zr=rt[0]>="0"&&rt[0]<="9"?`v${rt}`:"";function jr(){let e=new Z({id:"loaders.gl"});return globalThis.loaders=globalThis.loaders||{},globalThis.loaders.log=e,globalThis.loaders.version=zr,globalThis.probe=globalThis.probe||{},globalThis.probe.loaders=e,e}var ot=jr();var Rr="",nn={};function it(e){for(let t in nn)if(e.startsWith(t)){let n=nn[t];e=e.replace(t,n)}return!e.startsWith("http://")&&!e.startsWith("https://")&&(e=`${Rr}${e}`),e}var he=class{fetch;loadOptions;_needsRefresh=!0;props;constructor(t){this.props={...t},this.loadOptions={...t.loadOptions},this.fetch=Hr(this.loadOptions)}setProps(t){this.props=Object.assign(this.props,t),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(t=!0){let n=this._needsRefresh;return t&&(this._needsRefresh=!1),n}};function Hr(e){let t=e?.fetch;if(t&&typeof t=="function")return(r,o)=>t(r,o);let n=e?.fetch;return n&&typeof n!="function"?r=>fetch(r,n):r=>fetch(r)}var rn="4.3.0-alpha.1";var Zr=globalThis.loaders?.parseImageNode,st=typeof Image<"u",at=typeof ImageBitmap<"u",Wr=Boolean(Zr),lt=qe?!0:Wr;function on(e){switch(e){case"auto":return at||st||lt;case"imagebitmap":return at;case"image":return st;case"data":return lt;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function sn(){if(at)return"imagebitmap";if(st)return"image";if(lt)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function Jr(e){let t=Kr(e);if(!t)throw new Error("Not an image");return t}function an(e){switch(Jr(e)){case"data":return e;case"image":case"imagebitmap":let t=document.createElement("canvas"),n=t.getContext("2d");if(!n)throw new Error("getImageData");return t.width=e.width,t.height=e.height,n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}function Kr(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&e instanceof Image?"image":e&&typeof e=="object"&&e.data&&e.width&&e.height?"data":null}var $r=/^data:image\/svg\+xml/,Yr=/\.svg((\?|#).*)?$/;function Ue(e){return e&&($r.test(e)||Yr.test(e))}function ln(e,t){if(Ue(t)){let r=new TextDecoder().decode(e);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(r=unescape(encodeURIComponent(r)))}catch(i){throw new Error(i.message)}return`data:image/svg+xml;base64,${btoa(r)}`}return ct(e,t)}function ct(e,t){if(Ue(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function ke(e,t,n){let r=ln(e,n),o=self.URL||self.webkitURL,i=typeof r!="string"&&o.createObjectURL(r);try{return await Xr(i||r,t)}finally{i&&o.revokeObjectURL(i)}}async function Xr(e,t){let n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((r,o)=>{try{n.onload=()=>r(n),n.onerror=i=>{let s=i instanceof Error?i.message:"error";o(new Error(s))}}catch(i){o(i)}})}var Qr={},cn=!0;async function fn(e,t,n){let r;Ue(n)?r=await ke(e,t,n):r=ct(e,n);let o=t&&t.imagebitmap;return await qr(r,o)}async function qr(e,t=null){if((eo(t)||!cn)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(n){console.warn(n),cn=!1}return await createImageBitmap(e)}function eo(e){for(let t in e||Qr)return!1;return!0}function un(e){return!oo(e,"ftyp",4)||!(e[8]&96)?null:to(e)}function to(e){switch(no(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function no(e,t,n){return String.fromCharCode(...e.slice(t,n))}function ro(e){return[...e].map(t=>t.charCodeAt(0))}function oo(e,t,n=0){let r=ro(t);for(let o=0;o<r.length;++o)if(r[o]!==e[o+n])return!1;return!0}var z=!1,de=!0;function Ne(e){let t=pe(e);return so(t)||co(t)||ao(t)||lo(t)||io(t)}function io(e){let t=new Uint8Array(e instanceof DataView?e.buffer:e),n=un(t);return n?{mimeType:n.mimeType,width:0,height:0}:null}function so(e){let t=pe(e);return t.byteLength>=24&&t.getUint32(0,z)===2303741511?{mimeType:"image/png",width:t.getUint32(16,z),height:t.getUint32(20,z)}:null}function ao(e){let t=pe(e);return t.byteLength>=10&&t.getUint32(0,z)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,de),height:t.getUint16(8,de)}:null}function lo(e){let t=pe(e);return t.byteLength>=14&&t.getUint16(0,z)===16973&&t.getUint32(2,de)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,de),height:t.getUint32(22,de)}:null}function co(e){let t=pe(e);if(!(t.byteLength>=3&&t.getUint16(0,z)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:r,sofMarkers:o}=fo(),i=2;for(;i+9<t.byteLength;){let s=t.getUint16(i,z);if(o.has(s))return{mimeType:"image/jpeg",height:t.getUint16(i+5,z),width:t.getUint16(i+7,z)};if(!r.has(s))return null;i+=2,i+=t.getUint16(i,z)}return null}function fo(){let e=new Set([65499,65476,65484,65501,65534]);for(let n=65504;n<65520;++n)e.add(n);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function pe(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}async function hn(e,t){let{mimeType:n}=Ne(e)||{},r=globalThis.loaders?.parseImageNode;return ue(r),await r(e,n)}async function dn(e,t,n){t=t||{};let o=(t.image||{}).type||"auto",{url:i}=n||{},s=uo(o),a;switch(s){case"imagebitmap":a=await fn(e,t,i);break;case"image":a=await ke(e,t,i);break;case"data":a=await hn(e,t);break;default:ue(!1)}return o==="data"&&(a=an(a)),a}function uo(e){switch(e){case"auto":case"data":return sn();default:return on(e),e}}var ho=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],po=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],go={image:{type:"auto",decode:!0}},ft={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:rn,mimeTypes:po,extensions:ho,parse:dn,tests:[e=>Boolean(Ne(new DataView(e)))],options:go};var ge={x:0,y:1,z:2};function K(e,t={}){let{start:n=0,end:r=e.length,plane:o="xy"}=t,i=t.size||2,s=0,a=ge[o[0]],l=ge[o[1]];for(let c=n,f=r-i;c<r;c+=i)s+=(e[c+a]-e[f+a])*(e[c+l]+e[f+l]),f=c;return s/2}function ht(e,t,n=2,r,o="xy"){let i=t&&t.length,s=i?t[0]*n:e.length,a=gn(e,0,s,n,!0,r&&r[0],o),l=[];if(!a||a.next===a.prev)return l;let c,f,u,h,d,p,y;if(i&&(a=Io(e,t,a,n,r,o)),e.length>80*n){h=f=e[0],d=u=e[1];for(let P=n;P<s;P+=n)p=e[P],y=e[P+1],p<h&&(h=p),y<d&&(d=y),p>f&&(f=p),y>u&&(u=y);c=Math.max(f-h,u-d),c=c!==0?32767/c:0}return me(a,l,n,h,d,c,0),l}function gn(e,t,n,r,o,i,s){let a,l;i===void 0&&(i=K(e,{start:t,end:n,size:r,plane:s}));let c=ge[s[0]],f=ge[s[1]];if(o===i<0)for(a=t;a<n;a+=r)l=pn(a,e[a+c],e[a+f],l);else for(a=n-r;a>=t;a-=r)l=pn(a,e[a+c],e[a+f],l);return l&&Ge(l,l.next)&&(xe(l),l=l.next),l}function $(e,t){if(!e)return e;t||(t=e);let n=e,r;do if(r=!1,!n.steiner&&(Ge(n,n.next)||I(n.prev,n,n.next)===0)){if(xe(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function me(e,t,n,r,o,i,s){if(!e)return;!s&&i&&So(e,r,o,i);let a=e,l,c;for(;e.prev!==e.next;){if(l=e.prev,c=e.next,i?wo(e,r,o,i):xo(e)){t.push(l.i/n|0),t.push(e.i/n|0),t.push(c.i/n|0),xe(e),e=c.next,a=c.next;continue}if(e=c,e===a){s?s===1?(e=vo($(e),t,n),me(e,t,n,r,o,i,2)):s===2&&To(e,t,n,r,o,i):me($(e),t,n,r,o,i,1);break}}}function xo(e){let t=e.prev,n=e,r=e.next;if(I(t,n,r)>=0)return!1;let o=t.x,i=n.x,s=r.x,a=t.y,l=n.y,c=r.y,f=o<i?o<s?o:s:i<s?i:s,u=a<l?a<c?a:c:l<c?l:c,h=o>i?o>s?o:s:i>s?i:s,d=a>l?a>c?a:c:l>c?l:c,p=r.next;for(;p!==t;){if(p.x>=f&&p.x<=h&&p.y>=u&&p.y<=d&&re(o,a,i,l,s,c,p.x,p.y)&&I(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function wo(e,t,n,r){let o=e.prev,i=e,s=e.next;if(I(o,i,s)>=0)return!1;let a=o.x,l=i.x,c=s.x,f=o.y,u=i.y,h=s.y,d=a<l?a<c?a:c:l<c?l:c,p=f<u?f<h?f:h:u<h?u:h,y=a>l?a>c?a:c:l>c?l:c,P=f>u?f>h?f:h:u>h?u:h,M=ut(d,p,t,n,r),v=ut(y,P,t,n,r),m=e.prevZ,g=e.nextZ;for(;m&&m.z>=M&&g&&g.z<=v;){if(m.x>=d&&m.x<=y&&m.y>=p&&m.y<=P&&m!==o&&m!==s&&re(a,f,l,u,c,h,m.x,m.y)&&I(m.prev,m,m.next)>=0||(m=m.prevZ,g.x>=d&&g.x<=y&&g.y>=p&&g.y<=P&&g!==o&&g!==s&&re(a,f,l,u,c,h,g.x,g.y)&&I(g.prev,g,g.next)>=0))return!1;g=g.nextZ}for(;m&&m.z>=M;){if(m.x>=d&&m.x<=y&&m.y>=p&&m.y<=P&&m!==o&&m!==s&&re(a,f,l,u,c,h,m.x,m.y)&&I(m.prev,m,m.next)>=0)return!1;m=m.prevZ}for(;g&&g.z<=v;){if(g.x>=d&&g.x<=y&&g.y>=p&&g.y<=P&&g!==o&&g!==s&&re(a,f,l,u,c,h,g.x,g.y)&&I(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function vo(e,t,n){let r=e;do{let o=r.prev,i=r.next.next;!Ge(o,i)&&mn(o,r,r.next,i)&&ye(o,i)&&ye(i,o)&&(t.push(o.i/n|0),t.push(r.i/n|0),t.push(i.i/n|0),xe(r),xe(r.next),r=e=i),r=r.next}while(r!==e);return $(r)}function To(e,t,n,r,o,i){let s=e;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&Ao(s,a)){let l=yn(s,a);s=$(s,s.next),l=$(l,l.next),me(s,t,n,r,o,i,0),me(l,t,n,r,o,i,0);return}a=a.next}s=s.next}while(s!==e)}function Io(e,t,n,r,o,i){let s=[],a,l,c,f,u;for(a=0,l=t.length;a<l;a++)c=t[a]*r,f=a<l-1?t[a+1]*r:e.length,u=gn(e,c,f,r,!1,o&&o[a+1],i),u===u.next&&(u.steiner=!0),s.push(Bo(u));for(s.sort(Po),a=0;a<s.length;a++)n=Fo(s[a],n);return n}function Po(e,t){return e.x-t.x}function Fo(e,t){let n=bo(e,t);if(!n)return t;let r=yn(n,e);return $(r,r.next),$(n,n.next)}function bo(e,t){let n=t,r=e.x,o=e.y,i=-1/0,s;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){let h=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(h<=r&&h>i&&(i=h,s=n.x<n.next.x?n:n.next,h===r))return s}n=n.next}while(n!==t);if(!s)return null;let a=s,l=s.x,c=s.y,f=1/0,u;n=s;do r>=n.x&&n.x>=l&&r!==n.x&&re(o<c?r:i,o,l,c,o<c?i:r,o,n.x,n.y)&&(u=Math.abs(o-n.y)/(r-n.x),ye(n,e)&&(u<f||u===f&&(n.x>s.x||n.x===s.x&&Eo(s,n)))&&(s=n,f=u)),n=n.next;while(n!==a);return s}function Eo(e,t){return I(e.prev,e,t.prev)<0&&I(t.next,e,e.next)<0}function So(e,t,n,r){let o=e;do o.z===0&&(o.z=ut(o.x,o.y,t,n,r)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next;while(o!==e);o.prevZ.nextZ=null,o.prevZ=null,_o(o)}function _o(e){let t,n,r=1,o,i,s,a,l,c;do{for(i=e,e=null,c=null,o=0;i;){for(o++,a=i,s=0,n=0;n<r&&(s++,a=a.nextZ,!!a);n++);for(l=r;s>0||l>0&&a;)s!==0&&(l===0||!a||i.z<=a.z)?(t=i,i=i.nextZ,s--):(t=a,a=a.nextZ,l--),c?c.nextZ=t:e=t,t.prevZ=c,c=t;i=a}c.nextZ=null,r*=2}while(o>1);return e}function ut(e,t,n,r,o){return e=(e-n)*o|0,t=(t-r)*o|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function Bo(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function re(e,t,n,r,o,i,s,a){return(o-s)*(t-a)>=(e-s)*(i-a)&&(e-s)*(r-a)>=(n-s)*(t-a)&&(n-s)*(i-a)>=(o-s)*(r-a)}function Ao(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Do(e,t)&&(ye(e,t)&&ye(t,e)&&Lo(e,t)&&(I(e.prev,e,t.prev)||I(e,t.prev,t))||Ge(e,t)&&I(e.prev,e,e.next)>0&&I(t.prev,t,t.next)>0)}function I(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Ge(e,t){return e.x===t.x&&e.y===t.y}function mn(e,t,n,r){let o=Oe(I(e,t,n)),i=Oe(I(e,t,r)),s=Oe(I(n,r,e)),a=Oe(I(n,r,t));return!!(o!==i&&s!==a||o===0&&Ce(e,n,t)||i===0&&Ce(e,r,t)||s===0&&Ce(n,e,r)||a===0&&Ce(n,t,r))}function Ce(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Oe(e){return e>0?1:e<0?-1:0}function Do(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&mn(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function ye(e,t){return I(e.prev,e,e.next)<0?I(e,t,e.next)>=0&&I(e,e.prev,t)>=0:I(e,t,e.prev)<0||I(e,e.next,t)<0}function Lo(e,t){let n=e,r=!1,o=(e.x+t.x)/2,i=(e.y+t.y)/2;do n.y>i!=n.next.y>i&&n.next.y!==n.y&&o<(n.next.x-n.x)*(i-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function yn(e,t){let n=new we(e.i,e.x,e.y),r=new we(t.i,t.x,t.y),o=e.next,i=t.prev;return e.next=t,t.prev=e,n.next=o,o.prev=n,r.next=n,n.prev=r,i.next=r,r.prev=i,r}function pn(e,t,n,r){let o=new we(e,t,n);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o}function xe(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}var we=class{constructor(t,n,r){T(this,"i",void 0),T(this,"x",void 0),T(this,"y",void 0),T(this,"prev",null),T(this,"next",null),T(this,"z",0),T(this,"prevZ",null),T(this,"nextZ",null),T(this,"steiner",!1),this.i=t,this.x=n,this.y=r}};function gt(e,t,n){let r=No(e),o=Object.keys(r).filter(i=>r[i]!==Array);return Co(e,{propArrayTypes:r,...t},{numericPropKeys:n&&n.numericPropKeys||o,PositionDataType:n?n.PositionDataType:Float32Array,triangulate:n?n.triangulate:!0})}function No(e){let t={};for(let n of e)if(n.properties)for(let r in n.properties){let o=n.properties[r];t[r]=Ho(o,t[r])}return t}function Co(e,t,n){let{pointPositionsCount:r,pointFeaturesCount:o,linePositionsCount:i,linePathsCount:s,lineFeaturesCount:a,polygonPositionsCount:l,polygonObjectsCount:c,polygonRingsCount:f,polygonFeaturesCount:u,propArrayTypes:h,coordLength:d}=t,{numericPropKeys:p=[],PositionDataType:y=Float32Array,triangulate:P=!0}=n,M=e[0]&&"id"in e[0],v=e.length>65535?Uint32Array:Uint16Array,m={type:"Point",positions:new y(r*d),globalFeatureIds:new v(r),featureIds:o>65535?new Uint32Array(r):new Uint16Array(r),numericProps:{},properties:[],fields:[]},g={type:"LineString",pathIndices:i>65535?new Uint32Array(s+1):new Uint16Array(s+1),positions:new y(i*d),globalFeatureIds:new v(i),featureIds:a>65535?new Uint32Array(i):new Uint16Array(i),numericProps:{},properties:[],fields:[]},_={type:"Polygon",polygonIndices:l>65535?new Uint32Array(c+1):new Uint16Array(c+1),primitivePolygonIndices:l>65535?new Uint32Array(f+1):new Uint16Array(f+1),positions:new y(l*d),globalFeatureIds:new v(l),featureIds:u>65535?new Uint32Array(l):new Uint16Array(l),numericProps:{},properties:[],fields:[]};P&&(_.triangles=[]);for(let U of[m,g,_])for(let b of p){let B=h[b];U.numericProps[b]=new B(U.positions.length/d)}g.pathIndices[s]=i,_.polygonIndices[c]=l,_.primitivePolygonIndices[f]=l;let O={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let U of e){let b=U.geometry,B=U.properties||{};switch(b.type){case"Point":Oo(b,m,O,d,B),m.properties.push(pt(B,p)),M&&m.fields.push({id:U.id}),O.pointFeature++;break;case"LineString":Go(b,g,O,d,B),g.properties.push(pt(B,p)),M&&g.fields.push({id:U.id}),O.lineFeature++;break;case"Polygon":zo(b,_,O,d,B),_.properties.push(pt(B,p)),M&&_.fields.push({id:U.id}),O.polygonFeature++;break;default:throw new Error("Invalid geometry type")}O.feature++}return Ro(m,g,_,d)}function Oo(e,t,n,r,o){t.positions.set(e.data,n.pointPosition*r);let i=e.data.length/r;mt(t,o,n.pointPosition,i),t.globalFeatureIds.fill(n.feature,n.pointPosition,n.pointPosition+i),t.featureIds.fill(n.pointFeature,n.pointPosition,n.pointPosition+i),n.pointPosition+=i}function Go(e,t,n,r,o){t.positions.set(e.data,n.linePosition*r);let i=e.data.length/r;mt(t,o,n.linePosition,i),t.globalFeatureIds.fill(n.feature,n.linePosition,n.linePosition+i),t.featureIds.fill(n.lineFeature,n.linePosition,n.linePosition+i);for(let s=0,a=e.indices.length;s<a;++s){let l=e.indices[s],c=s===a-1?e.data.length:e.indices[s+1];t.pathIndices[n.linePath++]=n.linePosition,n.linePosition+=(c-l)/r}}function zo(e,t,n,r,o){t.positions.set(e.data,n.polygonPosition*r);let i=e.data.length/r;mt(t,o,n.polygonPosition,i),t.globalFeatureIds.fill(n.feature,n.polygonPosition,n.polygonPosition+i),t.featureIds.fill(n.polygonFeature,n.polygonPosition,n.polygonPosition+i);for(let s=0,a=e.indices.length;s<a;++s){let l=n.polygonPosition;t.polygonIndices[n.polygonObject++]=l;let c=e.areas[s],f=e.indices[s],u=e.indices[s+1];for(let d=0,p=f.length;d<p;++d){let y=f[d],P=d===p-1?u===void 0?e.data.length:u[0]:f[d+1];t.primitivePolygonIndices[n.polygonRing++]=n.polygonPosition,n.polygonPosition+=(P-y)/r}let h=n.polygonPosition;jo(t,c,f,{startPosition:l,endPosition:h,coordLength:r})}}function jo(e,t,n,{startPosition:r,endPosition:o,coordLength:i}){if(!e.triangles)return;let s=r*i,a=o*i,l=e.positions.subarray(s,a),c=n[0],f=n.slice(1).map(h=>(h-c)/i),u=ht(l,f,i,t);for(let h=0,d=u.length;h<d;++h)e.triangles.push(r+u[h])}function dt(e,t){let n={};for(let r in e)n[r]={value:e[r],size:t};return n}function Ro(e,t,n,r){let o={shape:"binary-feature-collection",points:{...e,positions:{value:e.positions,size:r},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:dt(e.numericProps,1)},lines:{...t,positions:{value:t.positions,size:r},pathIndices:{value:t.pathIndices,size:1},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:dt(t.numericProps,1)},polygons:{...n,positions:{value:n.positions,size:r},polygonIndices:{value:n.polygonIndices,size:1},primitivePolygonIndices:{value:n.primitivePolygonIndices,size:1},globalFeatureIds:{value:n.globalFeatureIds,size:1},featureIds:{value:n.featureIds,size:1},numericProps:dt(n.numericProps,1)}};return o.polygons&&n.triangles&&(o.polygons.triangles={value:new Uint32Array(n.triangles),size:1}),o}function mt(e,t,n,r){for(let o in e.numericProps)if(o in t){let i=t[o];e.numericProps[o].fill(i,n,n+r)}}function pt(e,t){let n={};for(let r in e)t.includes(r)||(n[r]=e[r]);return n}function Ho(e,t){return t===Array||!Number.isFinite(e)?Array:t===Float64Array||Math.fround(e)!==e?Float64Array:Float32Array}var It=jt(En(),1);function li(e){let t=0;for(let n=0,r=e.length-1,o,i;n<e.length;r=n++)o=e[n],i=e[r],t+=(i[0]-o[0])*(o[1]+i[1]);return t}function wt(e,t){if(Array.isArray(e[0])){for(let r of e)wt(r,t);return}let n=e;n[0]/=t,n[1]/=t}function Sn(e,t){for(let n=0,r=e.length;n<r;++n)e[n]/=t}function vt(e,t,n){if(typeof e[0][0]!="number"){for(let s of e)vt(s,t,n);return}let r=n*Math.pow(2,t.z),o=n*t.x,i=n*t.y;for(let s=0;s<e.length;s++){let a=e[s];a[0]=(a[0]+o)*360/r-180;let l=180-(a[1]+i)*360/r;a[1]=360/Math.PI*Math.atan(Math.exp(l*Math.PI/180))-90}}function _n(e,t,n){let{x:r,y:o,z:i}=t,s=n*Math.pow(2,i),a=n*r,l=n*o;for(let c=0,f=e.length;c<f;c+=2){e[c]=(e[c]+a)*360/s-180;let u=180-(e[c+1]+l)*360/s;e[c+1]=360/Math.PI*Math.atan(Math.exp(u*Math.PI/180))-90}}function Bn(e){let t=e.length;if(t<=1)return[e];let n=[],r,o;for(let i=0;i<t;i++){let s=li(e[i]);s!==0&&(o===void 0&&(o=s<0),o===s<0?(r&&n.push(r),r=[e[i]]):r&&r.push(e[i]))}return r&&n.push(r),n}function An(e){let t=e.indices.length,n="Polygon";if(t<=1)return{type:n,data:e.data,areas:[[K(e.data)]],indices:[e.indices]};let r=[],o=[],i=[],s=[],a,l=0;for(let c,f=0,u;f<t;f++){u=e.indices[f]-l,c=e.indices[f+1]-l||e.data.length;let h=e.data.slice(u,c),d=K(h);if(d===0){let p=e.data.slice(0,u),y=e.data.slice(c);e.data=p.concat(y),l+=c-u;continue}a===void 0&&(a=d<0),a===d<0?(s.length&&(r.push(i),o.push(s)),s=[u],i=[d]):(i.push(d),s.push(u))}return i&&r.push(i),s.length&&o.push(s),{type:n,areas:r,indices:o,data:e.data}}var Y=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;constructor(t,n,r,o,i,s){this.properties={},this.extent=r,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=o,this._values=i,this._geometryInfo=s,t.readFields(ci,this,n)}toGeoJSONFeature(t,n){let r=this.loadGeometry();switch(t){case"wgs84":return Dn(this,r,o=>vt(o,n,this.extent));default:return Dn(this,r,wt)}}toBinaryFeature(t,n){let r=this.loadFlatGeometry();switch(t){case"wgs84":return this._toBinaryCoordinates(r,o=>_n(o,n,this.extent));default:return this._toBinaryCoordinates(r,Sn)}}bbox(){let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,r=1,o=0,i=0,s=0,a=1/0,l=-1/0,c=1/0,f=-1/0;for(;t.pos<n;){if(o<=0){let u=t.readVarint();r=u&7,o=u>>3}if(o--,r===1||r===2)i+=t.readSVarint(),s+=t.readSVarint(),i<a&&(a=i),i>l&&(l=i),s<c&&(c=s),s>f&&(f=s);else if(r!==7)throw new Error(`unknown command ${r}`)}return[a,c,l,f]}_toBinaryCoordinates(t,n){let r;n(t.data,this.extent);let o=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=t.indices.length,r={type:"Point",...t};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=t.indices.length,this._geometryInfo.linePositionsCount+=t.data.length/o,r={type:"LineString",...t};break;case 3:r=An(t),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=r.indices.length;for(let s of r.indices)this._geometryInfo.polygonRingsCount+=s.length;this._geometryInfo.polygonPositionsCount+=r.data.length/o;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let i={type:"Feature",geometry:r,properties:this.properties};return this.id!==null&&(i.id=this.id),i}loadGeometry(){let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,r=1,o=0,i=0,s=0,a=[],l;for(;t.pos<n;){if(o<=0){let c=t.readVarint();r=c&7,o=c>>3}switch(o--,r){case 1:case 2:i+=t.readSVarint(),s+=t.readSVarint(),r===1&&(l&&a.push(l),l=[]),l&&l.push([i,s]);break;case 7:l&&l.push(l[0].slice());break;default:throw new Error(`unknown command ${r}`)}}return l&&a.push(l),a}loadFlatGeometry(){let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,r=1,o,i=0,s=0,a=0,l=0,c=[],f=[];for(;t.pos<n;)if(i<=0&&(o=t.readVarint(),r=o&7,i=o>>3),i--,r===1||r===2)s+=t.readSVarint(),a+=t.readSVarint(),r===1&&c.push(l),f.push(s,a),l+=2;else if(r===7){if(l>0){let u=c[c.length-1];f.push(f[u],f[u+1]),l+=2}}else throw new Error(`unknown command ${r}`);return{data:f,indices:c}}};Rt(Y,"types",["Unknown","Point","LineString","Polygon"]);function Dn(e,t,n){let r=Y.types[e.type],o,i,s;switch(e.type){case 1:let l=[];for(o=0;o<t.length;o++)l[o]=t[o][0];s=l,n(s,e.extent);break;case 2:for(s=t,o=0;o<s.length;o++)n(s[o],e.extent);break;case 3:for(s=Bn(t),o=0;o<s.length;o++)for(i=0;i<s[o].length;i++)n(s[o][i],e.extent);break;default:throw new Error("illegal vector tile type")}s.length===1?s=s[0]:r=`Multi${r}`;let a={type:"Feature",geometry:{type:r,coordinates:s},properties:e.properties};return e.id!==null&&(a.properties||={},a.properties.id=e.id),a}function ci(e,t,n){t&&n&&(e===1?t.id=n.readVarint():e===2?fi(n,t):e===3?t.type=n.readVarint():e===4&&(t._geometry=n.pos))}function fi(e,t){let n=e.readVarint()+e.pos;for(;e.pos<n;){let r=t._keys[e.readVarint()],o=t._values[e.readVarint()];t.properties[r]=o}}var Re=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(t,n){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(ui,this,n),this.length=this._features.length}getGeoJSONFeature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];let n=this._pbf.readVarint()+this._pbf.pos;return new Y(this._pbf,n,this.extent,this._keys,this._values)}getBinaryFeature(t,n){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];let r=this._pbf.readVarint()+this._pbf.pos;return new Y(this._pbf,r,this.extent,this._keys,this._values,n)}};function ui(e,t,n){t&&n&&(e===15?t.version=n.readVarint():e===1?t.name=n.readString():e===5?t.extent=n.readVarint():e===2?t._features.push(n.pos):e===3?t._keys.push(n.readString()):e===4&&t._values.push(hi(n)))}function hi(e){let t=null,n=e.readVarint()+e.pos;for(;e.pos<n;){let r=e.readVarint()>>3;t=r===1?e.readString():r===2?e.readFloat():r===3?e.readDouble():r===4?e.readVarint64():r===5?e.readVarint():r===6?e.readSVarint():r===7?e.readBoolean():null}return t}var ve=class{layers;constructor(t,n){this.layers=t.readFields(di,{},n)}};function di(e,t,n){if(e===3&&n){let r=new Re(n,n.readVarint()+n.pos);r.length&&t&&(t[r.name]=r)}}function Pt(e,t){let n=gi(t),r=t?.gis?.format||t?.mvt?.shape||t?.shape;switch(r){case"columnar-table":return{shape:"columnar-table",data:Tt(e,n)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:Ln(e,n)};case"geojson":return Ln(e,n);case"binary-geometry":return Tt(e,n);case"binary":return Tt(e,n);default:throw new Error(r||"undefined shape")}}function Tt(e,t){let[n,r]=pi(e,t),o=gt(n,r);return o.byteLength=e.byteLength,o}function pi(e,t){let n=[],r={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(e.byteLength<=0)return[n,r];let o=new ve(new It.default(e));return(t&&Array.isArray(t.layers)?t.layers:Object.keys(o.layers)).forEach(s=>{let a=o.layers[s];if(a)for(let l=0;l<a.length;l++){let c=a.getBinaryFeature(l,r),f=yi(c,t,s);n.push(f)}}),[n,r]}function Ln(e,t){if(e.byteLength<=0)return[];let n=[],r=new ve(new It.default(e));return(Array.isArray(t.layers)?t.layers:Object.keys(r.layers)).forEach(i=>{let s=r.layers[i];if(s)for(let a=0;a<s.length;a++){let l=s.getGeoJSONFeature(a),c=mi(l,t,i);n.push(c)}}),n}function gi(e){if(!e?.mvt)throw new Error("mvt options required");if(e.mvt?.coordinates==="wgs84"&&!e.mvt.tileIndex)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");return e.gis&&ot.warn('MVTLoader: "options.gis" is deprecated, use "options.mvt.shape" instead')(),e.mvt}function mi(e,t,n){let r=e.toGeoJSONFeature(t.coordinates||"local",t.tileIndex);return t.layerProperty&&(r.properties||={},r.properties[t.layerProperty]=n),r}function yi(e,t,n){let r=e.toBinaryFeature(t.coordinates||"local",t.tileIndex);return t.layerProperty&&r.properties&&(r.properties[t.layerProperty]=n),r}var xi="4.3.0-alpha.1",Vn={dataType:null,batchType:null,name:"Mapbox Vector Tile",id:"mvt",module:"mvt",version:xi,extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],worker:!0,category:"geometry",options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:void 0}}},Ft={...Vn,parse:async(e,t)=>Pt(e,t),parseSync:Pt,binary:!0};var Nn=e=>e!==null&&typeof e=="object";function bt(e,t){if(!e||!Nn(e))return null;let n={name:e.name||"",description:e.description||""};if(typeof e.generator=="string"&&(n.generator=e.generator),typeof e.generator_options=="string"&&(n.generatorOptions=e.generator_options),n.boundingBox=Mn(e.bounds)||Mn(e.antimeridian_adjusted_bounds),n.center=Fi(e.center),n.maxZoom=Un(e.maxzoom),n.minZoom=Un(e.minzoom),typeof e?.json=="string")try{n.metaJson=JSON.parse(e.json)}catch(a){console.warn("Failed to parse tilejson.json field",a)}let r=e.tilestats||n.metaJson?.tilestats,o=Ti(r,t),i=wi(e.vector_layers),s=Pi(i,o);return n={...n,layers:s},n.maxZoom===null&&s.length>0&&(n.maxZoom=s[0].maxZoom||null),n.minZoom===null&&s.length>0&&(n.minZoom=s[0].minZoom||null),n}function wi(e){return Array.isArray(e)?e.map(t=>vi(t)):[]}function vi(e){let t=Object.entries(e.fields||[]).map(([r,o])=>({name:r,...zn(String(o))})),n={...e};return delete n.fields,{name:e.id||"",...n,fields:t}}function Ti(e,t){return Nn(e)&&Array.isArray(e.layers)?e.layers.map(n=>Ii(n,t)):[]}function Ii(e,t){let n=[],r={},o=e.attributes||[];for(let i of o){let s=i.attribute;if(typeof s=="string")if(s.split("|").length>1){let a=s.split("|")[0];r[a]=r[a]||[],r[a].push(i),console.warn("ignoring tilestats indexed field",a)}else n[s]||n.push(Ei(i,t))}return{name:e.layer||"",dominantGeometry:e.geometry,fields:n}}function Pi(e,t){return e.map(n=>{let r=t.find(s=>s.name===n.name),o=r?.fields||[],i={...n};return delete i.fields,{...i,...r,fields:o}})}function Mn(e){let t=Gn(e);if(Array.isArray(t)&&t.length===4&&[t[0],t[2]].every(On)&&[t[1],t[3]].every(Cn))return[[t[0],t[1]],[t[2],t[3]]]}function Fi(e){let t=Gn(e);return Array.isArray(t)&&t.length===3&&On(t[0])&&Cn(t[1])&&bi(t[2])?t:null}function Un(e){let t=typeof e=="string"?parseFloat(e):typeof e=="number"?e:null;return t===null||isNaN(t)?null:t}function Cn(e){return Number.isFinite(e)&&e<=90&&e>=-90}function On(e){return Number.isFinite(e)&&e<=180&&e>=-180}function bi(e){return Number.isFinite(e)&&e>=0&&e<=22}function Gn(e){return typeof e=="string"?e.split(",").map(parseFloat):Array.isArray(e)?e:null}var kn={number:{type:"float32"},numeric:{type:"float32"},string:{type:"utf8"},vachar:{type:"utf8"},float:{type:"float32"},int:{type:"int32"},int4:{type:"int32"},boolean:{type:"boolean"},bool:{type:"boolean"}};function Ei(e={},t){let n=zn(e.type),r={name:e.attribute,...n};return typeof e.min=="number"&&(r.min=e.min),typeof e.max=="number"&&(r.max=e.max),typeof e.count=="number"&&(r.uniqueValueCount=e.count),e.values&&(r.values=e.values),r.values&&typeof t.maxValues=="number"&&(r.values=r.values?.slice(0,t.maxValues)),r}function zn(e){let t=e.toLowerCase();return!t||kn[t],kn[t]||{type:"string"}}var Si="4.3.0-alpha.1",Te={dataType:null,batchType:null,name:"TileJSON",id:"tilejson",module:"pmtiles",version:Si,worker:!0,extensions:["json"],mimeTypes:["application/json"],text:!0,options:{tilejson:{maxValues:void 0}},parse:async(e,t)=>{let n=new TextDecoder().decode(e),r=JSON.parse(n),o={...Te.options.tilejson,...t?.tilejson};return bt(r,o)},parseTextSync:(e,t)=>{let n=JSON.parse(e),r={...Te.options.tilejson,...t?.tilejson};return bt(n,r)}};var be={};zt(be,{Compression:()=>or,EtagMismatch:()=>Ze,FetchSource:()=>ar,FileSource:()=>as,PMTiles:()=>At,Protocol:()=>ts,ResolvedValueCache:()=>cs,SharedPromiseCache:()=>hr,TileType:()=>ir,bytesToHeader:()=>lr,findTile:()=>sr,getUint64:()=>V,leafletRasterLayer:()=>qi,readVarint:()=>ae,tileIdToZxy:()=>is,zxyToTileId:()=>rr});var X=Math.pow,F=(e,t,n)=>new Promise((r,o)=>{var i=l=>{try{a(n.next(l))}catch(c){o(c)}},s=l=>{try{a(n.throw(l))}catch(c){o(c)}},a=l=>l.done?r(l.value):Promise.resolve(l.value).then(i,s);a((n=n.apply(e,t)).next())}),S=Uint8Array,le=Uint16Array,_i=Int32Array,Hn=new S([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Zn=new S([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Bi=new S([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Wn=function(e,t){for(var n=new le(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var o=new _i(n[30]),r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)o[i]=i-n[r]<<5|r;return{b:n,r:o}},Jn=Wn(Hn,2),Kn=Jn.b,Ai=Jn.r;Kn[28]=258,Ai[258]=28;var $n=Wn(Zn,0),Di=$n.b,oc=$n.r,_t=new le(32768);for(w=0;w<32768;++w)R=(w&43690)>>1|(w&21845)<<1,R=(R&52428)>>2|(R&13107)<<2,R=(R&61680)>>4|(R&3855)<<4,_t[w]=((R&65280)>>8|(R&255)<<8)>>1;var R,w,Pe=function(e,t,n){for(var r=e.length,o=0,i=new le(t);o<r;++o)e[o]&&++i[e[o]-1];var s=new le(t);for(o=1;o<t;++o)s[o]=s[o-1]+i[o-1]<<1;var a;if(n){a=new le(1<<t);var l=15-t;for(o=0;o<r;++o)if(e[o])for(var c=o<<4|e[o],f=t-e[o],u=s[e[o]-1]++<<f,h=u|(1<<f)-1;u<=h;++u)a[_t[u]>>l]=c}else for(a=new le(r),o=0;o<r;++o)e[o]&&(a[o]=_t[s[e[o]-1]++]>>15-e[o]);return a},Fe=new S(288);for(w=0;w<144;++w)Fe[w]=8;var w;for(w=144;w<256;++w)Fe[w]=9;var w;for(w=256;w<280;++w)Fe[w]=7;var w;for(w=280;w<288;++w)Fe[w]=8;var w,Yn=new S(32);for(w=0;w<32;++w)Yn[w]=5;var w,Li=Pe(Fe,9,1),Vi=Pe(Yn,5,1),Et=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},C=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},St=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Mi=function(e){return(e+7)/8|0},Ui=function(e,t,n){(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length);var r=new S(n-t);return r.set(e.subarray(t,n)),r},ki=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],E=function(e,t,n){var r=new Error(t||ki[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,E),!n)throw r;return r},Dt=function(e,t,n,r){var o=e.length,i=r?r.length:0;if(!o||t.f&&!t.l)return n||new S(0);var s=!n||t.i!=2,a=t.i;n||(n=new S(o*3));var l=function(Ct){var Ot=n.length;if(Ct>Ot){var Gt=new S(Math.max(Ot*2,Ct));Gt.set(n),n=Gt}},c=t.f||0,f=t.p||0,u=t.b||0,h=t.l,d=t.d,p=t.m,y=t.n,P=o*8;do{if(!h){c=C(e,f,1);var M=C(e,f+1,3);if(f+=3,M)if(M==1)h=Li,d=Vi,p=9,y=5;else if(M==2){var _=C(e,f,31)+257,O=C(e,f+10,15)+4,U=_+C(e,f+5,31)+1;f+=14;for(var b=new S(U),B=new S(19),A=0;A<O;++A)B[Bi[A]]=C(e,f+A*3,7);f+=O*3;for(var Vt=Et(B),pr=(1<<Vt)-1,gr=Pe(B,Vt,1),A=0;A<U;){var Mt=gr[C(e,f,pr)];f+=Mt&15;var v=Mt>>4;if(v<16)b[A++]=v;else{var Q=0,_e=0;for(v==16?(_e=3+C(e,f,3),f+=2,Q=b[A-1]):v==17?(_e=3+C(e,f,7),f+=3):v==18&&(_e=11+C(e,f,127),f+=7);_e--;)b[A++]=Q}}var Ut=b.subarray(0,_),k=b.subarray(_);p=Et(Ut),y=Et(k),h=Pe(Ut,p,1),d=Pe(k,y,1)}else E(1);else{var v=Mi(f)+4,m=e[v-4]|e[v-3]<<8,g=v+m;if(g>o){a&&E(0);break}s&&l(u+m),n.set(e.subarray(v,g),u),t.b=u+=m,t.p=f=g*8,t.f=c;continue}if(f>P){a&&E(0);break}}s&&l(u+131072);for(var mr=(1<<p)-1,yr=(1<<y)-1,Ke=f;;Ke=f){var Q=h[St(e,f)&mr],q=Q>>4;if(f+=Q&15,f>P){a&&E(0);break}if(Q||E(2),q<256)n[u++]=q;else if(q==256){Ke=f,h=null;break}else{var kt=q-254;if(q>264){var A=q-257,ce=Hn[A];kt=C(e,f,(1<<ce)-1)+Kn[A],f+=ce}var $e=d[St(e,f)&yr],Ye=$e>>4;$e||E(3),f+=$e&15;var k=Di[Ye];if(Ye>3){var ce=Zn[Ye];k+=St(e,f)&(1<<ce)-1,f+=ce}if(f>P){a&&E(0);break}s&&l(u+131072);var Xe=u+kt;if(u<k){var Nt=i-k,xr=Math.min(k,Xe);for(Nt+u<0&&E(3);u<xr;++u)n[u]=r[Nt+u]}for(;u<Xe;u+=4)n[u]=n[u-k],n[u+1]=n[u+1-k],n[u+2]=n[u+2-k],n[u+3]=n[u+3-k];u=Xe}}t.l=h,t.p=Ke,t.b=u,t.f=c,h&&(c=1,t.m=p,t.d=d,t.n=y)}while(!c);return u==n.length?n:Ui(n,0,u)},Ni=new S(0),Ci=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&E(6,"invalid gzip data");var t=e[3],n=10;t&4&&(n+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(t&2)},Oi=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},Gi=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&E(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&E(6,"invalid zlib data: "+(e[1]&32?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function zi(e,t){return Dt(e,{i:2},t&&t.out,t&&t.dictionary)}function ji(e,t){var n=Ci(e);return n+8>e.length&&E(6,"invalid gzip data"),Dt(e.subarray(n,-8),{i:2},t&&t.out||new S(Oi(e)),t&&t.dictionary)}function Ri(e,t){return Dt(e.subarray(Gi(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}function Bt(e,t){return e[0]==31&&e[1]==139&&e[2]==8?ji(e,t):(e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31?zi(e,t):Ri(e,t)}var Hi=typeof TextDecoder<"u"&&new TextDecoder,Zi=0;try{Hi.decode(Ni,{stream:!0}),Zi=1}catch{}var Xn=(e,t)=>e*X(2,t),Ie=(e,t)=>Math.floor(e/X(2,t)),He=(e,t)=>Xn(e.getUint16(t+1,!0),8)+e.getUint8(t),Qn=(e,t)=>Xn(e.getUint32(t+2,!0),16)+e.getUint16(t,!0),Wi=(e,t,n,r,o)=>{if(e!==r.getUint8(o))return e-r.getUint8(o);let i=He(r,o+1);if(t!==i)return t-i;let s=He(r,o+4);return n!==s?n-s:0},Ji=(e,t,n,r)=>{let o=qn(e,t|128,n,r);return o?{z:t,x:n,y:r,offset:o[0],length:o[1],isDir:!0}:null},jn=(e,t,n,r)=>{let o=qn(e,t,n,r);return o?{z:t,x:n,y:r,offset:o[0],length:o[1],isDir:!1}:null},qn=(e,t,n,r)=>{let o=0,i=e.byteLength/17-1;for(;o<=i;){let s=i+o>>1,a=Wi(t,n,r,e,s*17);if(a>0)o=s+1;else if(a<0)i=s-1;else return[Qn(e,s*17+7),e.getUint32(s*17+13,!0)]}return null},Ki=(e,t)=>e.isDir&&!t.isDir?1:!e.isDir&&t.isDir?-1:e.z!==t.z?e.z-t.z:e.x!==t.x?e.x-t.x:e.y-t.y,er=(e,t)=>{let n=e.getUint8(t*17);return{z:n&127,x:He(e,t*17+1),y:He(e,t*17+4),offset:Qn(e,t*17+7),length:e.getUint32(t*17+13,!0),isDir:n>>7===1}},Rn=e=>{let t=[],n=new DataView(e);for(let r=0;r<n.byteLength/17;r++)t.push(er(n,r));return $i(t)},$i=e=>{e.sort(Ki);let t=new ArrayBuffer(17*e.length),n=new Uint8Array(t);for(let r=0;r<e.length;r++){let o=e[r],i=o.z;o.isDir&&(i=i|128),n[r*17]=i,n[r*17+1]=o.x&255,n[r*17+2]=o.x>>8&255,n[r*17+3]=o.x>>16&255,n[r*17+4]=o.y&255,n[r*17+5]=o.y>>8&255,n[r*17+6]=o.y>>16&255,n[r*17+7]=o.offset&255,n[r*17+8]=Ie(o.offset,8)&255,n[r*17+9]=Ie(o.offset,16)&255,n[r*17+10]=Ie(o.offset,24)&255,n[r*17+11]=Ie(o.offset,32)&255,n[r*17+12]=Ie(o.offset,48)&255,n[r*17+13]=o.length&255,n[r*17+14]=o.length>>8&255,n[r*17+15]=o.length>>16&255,n[r*17+16]=o.length>>24&255}return t},Yi=(e,t)=>{if(e.byteLength<17)return null;let n=e.byteLength/17,r=er(e,n-1);if(r.isDir){let o=r.z,i=t.z-o,s=Math.trunc(t.x/(1<<i)),a=Math.trunc(t.y/(1<<i));return{z:o,x:s,y:a}}return null};function Xi(e){return F(this,null,function*(){let t=yield e.getBytes(0,512e3),n=new DataView(t.data),r=n.getUint32(4,!0),o=n.getUint16(8,!0),i=new TextDecoder("utf-8"),s=JSON.parse(i.decode(new DataView(t.data,10,r))),a=0;s.compression==="gzip"&&(a=2);let l=0;"minzoom"in s&&(l=+s.minzoom);let c=0;"maxzoom"in s&&(c=+s.maxzoom);let f=0,u=0,h=0,d=-180,p=-85,y=180,P=85;if(s.bounds){let v=s.bounds.split(",");d=+v[0],p=+v[1],y=+v[2],P=+v[3]}if(s.center){let v=s.center.split(",");f=+v[0],u=+v[1],h=+v[2]}return{specVersion:n.getUint16(2,!0),rootDirectoryOffset:10+r,rootDirectoryLength:o*17,jsonMetadataOffset:10,jsonMetadataLength:r,leafDirectoryOffset:0,leafDirectoryLength:void 0,tileDataOffset:0,tileDataLength:void 0,numAddressedTiles:0,numTileEntries:0,numTileContents:0,clustered:!1,internalCompression:1,tileCompression:a,tileType:1,minZoom:l,maxZoom:c,minLon:d,minLat:p,maxLon:y,maxLat:P,centerZoom:h,centerLon:f,centerLat:u,etag:t.etag}})}function Qi(e,t,n,r,o,i,s){return F(this,null,function*(){let a=yield n.getArrayBuffer(t,e.rootDirectoryOffset,e.rootDirectoryLength,e);e.specVersion===1&&(a=Rn(a));let l=jn(new DataView(a),r,o,i);if(l){let u=(yield t.getBytes(l.offset,l.length,s)).data,h=new DataView(u);return h.getUint8(0)===31&&h.getUint8(1)===139&&(u=Bt(new Uint8Array(u))),{data:u}}let c=Yi(new DataView(a),{z:r,x:o,y:i});if(c){let f=Ji(new DataView(a),c.z,c.x,c.y);if(f){let u=yield n.getArrayBuffer(t,f.offset,f.length,e);e.specVersion===1&&(u=Rn(u));let h=jn(new DataView(u),r,o,i);if(h){let p=(yield t.getBytes(h.offset,h.length,s)).data,y=new DataView(p);return y.getUint8(0)===31&&y.getUint8(1)===139&&(p=Bt(new Uint8Array(p))),{data:p}}}}})}var tr={getHeader:Xi,getZxy:Qi},qi=(e,t)=>{let n=!1,r="",o=L.GridLayer.extend({createTile:(i,s)=>{let a=document.createElement("img"),l=new AbortController,c=l.signal;return a.cancel=()=>{l.abort()},n||(e.getHeader().then(f=>{f.tileType===1?console.error("Error: archive contains MVT vector tiles, but leafletRasterLayer is for displaying raster tiles. See https://github.com/protomaps/PMTiles/tree/main/js for details."):f.tileType===2?r="image/png":f.tileType===3?r="image/jpeg":f.tileType===4?r="image/webp":f.tileType===5&&(r="image/avif")}),n=!0),e.getZxy(i.z,i.x,i.y,c).then(f=>{if(f){let u=new Blob([f.data],{type:r}),h=window.URL.createObjectURL(u);a.src=h,a.cancel=void 0,s(void 0,a)}}).catch(f=>{if(f.name!=="AbortError")throw f}),a},_removeTile:function(i){let s=this._tiles[i];s&&(s.el.cancel&&s.el.cancel(),s.el.width=0,s.el.height=0,s.el.deleted=!0,L.DomUtil.remove(s.el),delete this._tiles[i],this.fire("tileunload",{tile:s.el,coords:this._keyToTileCoords(i)}))}});return new o(t)},es=e=>(t,n)=>{if(n instanceof AbortController)return e(t,n);let r=new AbortController;return e(t,r).then(o=>n(void 0,o.data,o.cacheControl||"",o.expires||""),o=>n(o)).catch(o=>n(o)),{cancel:()=>r.abort()}},ts=class{constructor(){this.tilev4=(e,t)=>F(this,null,function*(){if(e.type==="json"){let u=e.url.substr(10),h=this.tiles.get(u);h||(h=new At(u),this.tiles.set(u,h));let d=yield h.getHeader();return{data:{tiles:[`${e.url}/{z}/{x}/{y}`],minzoom:d.minZoom,maxzoom:d.maxZoom,bounds:[d.minLon,d.minLat,d.maxLon,d.maxLat]}}}let n=new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/),r=e.url.match(n);if(!r)throw new Error("Invalid PMTiles protocol URL");let o=r[1],i=this.tiles.get(o);i||(i=new At(o),this.tiles.set(o,i));let s=r[2],a=r[3],l=r[4],c=yield i.getHeader(),f=yield i?.getZxy(+s,+a,+l,t.signal);return f?{data:new Uint8Array(f.data),cacheControl:f.cacheControl,expires:f.expires}:c.tileType===1?{data:new Uint8Array}:{data:null}}),this.tile=es(this.tilev4),this.tiles=new Map}add(e){this.tiles.set(e.source.getKey(),e)}get(e){return this.tiles.get(e)}};function se(e,t){return(t>>>0)*4294967296+(e>>>0)}function ns(e,t){let n=t.buf,r=n[t.pos++],o=(r&112)>>4;if(r<128||(r=n[t.pos++],o|=(r&127)<<3,r<128)||(r=n[t.pos++],o|=(r&127)<<10,r<128)||(r=n[t.pos++],o|=(r&127)<<17,r<128)||(r=n[t.pos++],o|=(r&127)<<24,r<128)||(r=n[t.pos++],o|=(r&1)<<31,r<128))return se(e,o);throw new Error("Expected varint not more than 10 bytes")}function ae(e){let t=e.buf,n=t[e.pos++],r=n&127;return n<128||(n=t[e.pos++],r|=(n&127)<<7,n<128)||(n=t[e.pos++],r|=(n&127)<<14,n<128)||(n=t[e.pos++],r|=(n&127)<<21,n<128)?r:(n=t[e.pos],r|=(n&15)<<28,ns(r,e))}function nr(e,t,n,r){if(r===0){n===1&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);let o=t[0];t[0]=t[1],t[1]=o}}function rs(e,t){let n=X(2,e),r=t,o=t,i=t,s=[0,0],a=1;for(;a<n;)r=1&i/2,o=1&(i^r),nr(a,s,r,o),s[0]+=a*r,s[1]+=a*o,i=i/4,a*=2;return[e,s[0],s[1]]}var os=[0,1,5,21,85,341,1365,5461,21845,87381,349525,1398101,5592405,22369621,89478485,357913941,1431655765,5726623061,22906492245,91625968981,366503875925,1466015503701,5864062014805,23456248059221,93824992236885,375299968947541,0x5555555555555];function rr(e,t,n){if(e>26)throw Error("Tile zoom level exceeds max safe number limit (26)");if(t>X(2,e)-1||n>X(2,e)-1)throw Error("tile x/y outside zoom level bounds");let r=os[e],o=X(2,e),i=0,s=0,a=0,l=[t,n],c=o/2;for(;c>0;)i=(l[0]&c)>0?1:0,s=(l[1]&c)>0?1:0,a+=c*c*(3*i^s),nr(c,l,i,s),c=c/2;return r+a}function is(e){let t=0,n=0;for(let r=0;r<27;r++){let o=(1<<r)*(1<<r);if(t+o>e)return rs(r,e-t);t+=o}throw Error("Tile zoom level exceeds max safe number limit (26)")}var or=(e=>(e[e.Unknown=0]="Unknown",e[e.None=1]="None",e[e.Gzip=2]="Gzip",e[e.Brotli=3]="Brotli",e[e.Zstd=4]="Zstd",e))(or||{});function Lt(e,t){return F(this,null,function*(){if(t===1||t===0)return e;if(t===2){if(typeof globalThis.DecompressionStream>"u")return Bt(new Uint8Array(e));let n=new Response(e).body;if(!n)throw Error("Failed to read response stream");let r=n.pipeThrough(new globalThis.DecompressionStream("gzip"));return new Response(r).arrayBuffer()}throw Error("Compression method not supported")})}var ir=(e=>(e[e.Unknown=0]="Unknown",e[e.Mvt=1]="Mvt",e[e.Png=2]="Png",e[e.Jpeg=3]="Jpeg",e[e.Webp=4]="Webp",e[e.Avif=5]="Avif",e))(ir||{}),ss=127;function sr(e,t){let n=0,r=e.length-1;for(;n<=r;){let o=r+n>>1,i=t-e[o].tileId;if(i>0)n=o+1;else if(i<0)r=o-1;else return e[o]}return r>=0&&(e[r].runLength===0||t-e[r].tileId<e[r].runLength)?e[r]:null}var as=class{constructor(e){this.file=e}getKey(){return this.file.name}getBytes(e,t){return F(this,null,function*(){return{data:yield this.file.slice(e,e+t).arrayBuffer()}})}},ar=class{constructor(e,t=new Headers){this.url=e,this.customHeaders=t,this.mustReload=!1}getKey(){return this.url}setHeaders(e){this.customHeaders=e}getBytes(e,t,n,r){return F(this,null,function*(){let o,i;n?i=n:(o=new AbortController,i=o.signal);let s=new Headers(this.customHeaders);s.set("range",`bytes=${e}-${e+t-1}`);let a;this.mustReload&&(a="reload");let l=yield fetch(this.url,{signal:i,cache:a,headers:s});if(e===0&&l.status===416){let h=l.headers.get("Content-Range");if(!h||!h.startsWith("bytes */"))throw Error("Missing content-length on 416 response");let d=+h.substr(8);l=yield fetch(this.url,{signal:i,cache:"reload",headers:{range:`bytes=0-${d-1}`}})}let c=l.headers.get("Etag");if(c?.startsWith("W/")&&(c=null),l.status===416||r&&c&&c!==r)throw this.mustReload=!0,new Ze(r);if(l.status>=300)throw Error(`Bad response code: ${l.status}`);let f=l.headers.get("Content-Length");if(l.status===200&&(!f||+f>t))throw o&&o.abort(),Error("Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.");return{data:yield l.arrayBuffer(),etag:c||void 0,cacheControl:l.headers.get("Cache-Control")||void 0,expires:l.headers.get("Expires")||void 0}})}};function V(e,t){let n=e.getUint32(t+4,!0),r=e.getUint32(t+0,!0);return n*X(2,32)+r}function lr(e,t){let n=new DataView(e),r=n.getUint8(7);if(r>3)throw Error(`Archive is spec version ${r} but this library supports up to spec version 3`);return{specVersion:r,rootDirectoryOffset:V(n,8),rootDirectoryLength:V(n,16),jsonMetadataOffset:V(n,24),jsonMetadataLength:V(n,32),leafDirectoryOffset:V(n,40),leafDirectoryLength:V(n,48),tileDataOffset:V(n,56),tileDataLength:V(n,64),numAddressedTiles:V(n,72),numTileEntries:V(n,80),numTileContents:V(n,88),clustered:n.getUint8(96)===1,internalCompression:n.getUint8(97),tileCompression:n.getUint8(98),tileType:n.getUint8(99),minZoom:n.getUint8(100),maxZoom:n.getUint8(101),minLon:n.getInt32(102,!0)/1e7,minLat:n.getInt32(106,!0)/1e7,maxLon:n.getInt32(110,!0)/1e7,maxLat:n.getInt32(114,!0)/1e7,centerZoom:n.getUint8(118),centerLon:n.getInt32(119,!0)/1e7,centerLat:n.getInt32(123,!0)/1e7,etag:t}}function cr(e){let t={buf:new Uint8Array(e),pos:0},n=ae(t),r=[],o=0;for(let i=0;i<n;i++){let s=ae(t);r.push({tileId:o+s,offset:0,length:0,runLength:1}),o+=s}for(let i=0;i<n;i++)r[i].runLength=ae(t);for(let i=0;i<n;i++)r[i].length=ae(t);for(let i=0;i<n;i++){let s=ae(t);s===0&&i>0?r[i].offset=r[i-1].offset+r[i-1].length:r[i].offset=s-1}return r}function ls(e){let t=new DataView(e);return t.getUint16(2,!0)===2?(console.warn("PMTiles spec version 2 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade"),2):t.getUint16(2,!0)===1?(console.warn("PMTiles spec version 1 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade"),1):3}var Ze=class extends Error{};function fr(e,t){return F(this,null,function*(){let n=yield e.getBytes(0,16384);if(new DataView(n.data).getUint16(0,!0)!==19792)throw new Error("Wrong magic number for PMTiles archive");if(ls(n.data)<3)return[yield tr.getHeader(e)];let o=n.data.slice(0,ss),i=lr(o,n.etag),s=n.data.slice(i.rootDirectoryOffset,i.rootDirectoryOffset+i.rootDirectoryLength),a=`${e.getKey()}|${i.etag||""}|${i.rootDirectoryOffset}|${i.rootDirectoryLength}`,l=cr(yield t(s,i.internalCompression));return[i,[a,l.length,l]]})}function ur(e,t,n,r,o){return F(this,null,function*(){let i=yield e.getBytes(n,r,void 0,o.etag),s=yield t(i.data,o.internalCompression),a=cr(s);if(a.length===0)throw new Error("Empty directory is invalid");return a})}var cs=class{constructor(e=100,t=!0,n=Lt){this.cache=new Map,this.maxCacheEntries=e,this.counter=1,this.decompress=n}getHeader(e){return F(this,null,function*(){let t=e.getKey(),n=this.cache.get(t);if(n)return n.lastUsed=this.counter++,n.data;let r=yield fr(e,this.decompress);return r[1]&&this.cache.set(r[1][0],{lastUsed:this.counter++,data:r[1][2]}),this.cache.set(t,{lastUsed:this.counter++,data:r[0]}),this.prune(),r[0]})}getDirectory(e,t,n,r){return F(this,null,function*(){let o=`${e.getKey()}|${r.etag||""}|${t}|${n}`,i=this.cache.get(o);if(i)return i.lastUsed=this.counter++,i.data;let s=yield ur(e,this.decompress,t,n,r);return this.cache.set(o,{lastUsed:this.counter++,data:s}),this.prune(),s})}getArrayBuffer(e,t,n,r){return F(this,null,function*(){let o=`${e.getKey()}|${r.etag||""}|${t}|${n}`,i=this.cache.get(o);if(i)return i.lastUsed=this.counter++,yield i.data;let s=yield e.getBytes(t,n,void 0,r.etag);return this.cache.set(o,{lastUsed:this.counter++,data:s.data}),this.prune(),s.data})}prune(){if(this.cache.size>this.maxCacheEntries){let e=1/0,t;this.cache.forEach((n,r)=>{n.lastUsed<e&&(e=n.lastUsed,t=r)}),t&&this.cache.delete(t)}}invalidate(e){return F(this,null,function*(){this.cache.delete(e.getKey())})}},hr=class{constructor(e=100,t=!0,n=Lt){this.cache=new Map,this.invalidations=new Map,this.maxCacheEntries=e,this.counter=1,this.decompress=n}getHeader(e){return F(this,null,function*(){let t=e.getKey(),n=this.cache.get(t);if(n)return n.lastUsed=this.counter++,yield n.data;let r=new Promise((o,i)=>{fr(e,this.decompress).then(s=>{s[1]&&this.cache.set(s[1][0],{lastUsed:this.counter++,data:Promise.resolve(s[1][2])}),o(s[0]),this.prune()}).catch(s=>{i(s)})});return this.cache.set(t,{lastUsed:this.counter++,data:r}),r})}getDirectory(e,t,n,r){return F(this,null,function*(){let o=`${e.getKey()}|${r.etag||""}|${t}|${n}`,i=this.cache.get(o);if(i)return i.lastUsed=this.counter++,yield i.data;let s=new Promise((a,l)=>{ur(e,this.decompress,t,n,r).then(c=>{a(c),this.prune()}).catch(c=>{l(c)})});return this.cache.set(o,{lastUsed:this.counter++,data:s}),s})}getArrayBuffer(e,t,n,r){return F(this,null,function*(){let o=`${e.getKey()}|${r.etag||""}|${t}|${n}`,i=this.cache.get(o);if(i)return i.lastUsed=this.counter++,yield i.data;let s=new Promise((a,l)=>{e.getBytes(t,n,void 0,r.etag).then(c=>{a(c.data),this.cache.has(o),this.prune()}).catch(c=>{l(c)})});return this.cache.set(o,{lastUsed:this.counter++,data:s}),s})}prune(){if(this.cache.size>=this.maxCacheEntries){let e=1/0,t;this.cache.forEach((n,r)=>{n.lastUsed<e&&(e=n.lastUsed,t=r)}),t&&this.cache.delete(t)}}invalidate(e){return F(this,null,function*(){let t=e.getKey();if(this.invalidations.get(t))return yield this.invalidations.get(t);this.cache.delete(e.getKey());let n=new Promise((r,o)=>{this.getHeader(e).then(i=>{r(),this.invalidations.delete(t)}).catch(i=>{o(i)})});this.invalidations.set(t,n)})}},At=class{constructor(e,t,n){typeof e=="string"?this.source=new ar(e):this.source=e,n?this.decompress=n:this.decompress=Lt,t?this.cache=t:this.cache=new hr}getHeader(){return F(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(e,t,n,r){return F(this,null,function*(){let o=rr(e,t,n),i=yield this.cache.getHeader(this.source);if(i.specVersion<3)return tr.getZxy(i,this.source,this.cache,e,t,n,r);if(e<i.minZoom||e>i.maxZoom)return;let s=i.rootDirectoryOffset,a=i.rootDirectoryLength;for(let l=0;l<=3;l++){let c=yield this.cache.getDirectory(this.source,s,a,i),f=sr(c,o);if(f){if(f.runLength>0){let u=yield this.source.getBytes(i.tileDataOffset+f.offset,f.length,r,i.etag);return{data:yield this.decompress(u.data,i.tileCompression),cacheControl:u.cacheControl,expires:u.expires}}s=i.leafDirectoryOffset+f.offset,a=f.length}else return}throw Error("Maximum directory depth exceeded")})}getZxy(e,t,n,r){return F(this,null,function*(){try{return yield this.getZxyAttempt(e,t,n,r)}catch(o){if(o instanceof Ze)return this.cache.invalidate(this.source),yield this.getZxyAttempt(e,t,n,r);throw o}})}getMetadataAttempt(){return F(this,null,function*(){let e=yield this.cache.getHeader(this.source),t=yield this.source.getBytes(e.jsonMetadataOffset,e.jsonMetadataLength,void 0,e.etag),n=yield this.decompress(t.data,e.internalCompression),r=new TextDecoder("utf-8");return JSON.parse(r.decode(n))})}getMetadata(){return F(this,null,function*(){try{return yield this.getMetadataAttempt()}catch(e){if(e instanceof Ze)return this.cache.invalidate(this.source),yield this.getMetadataAttempt();throw e}})}};var{TileType:Ee}=be;function dr(e,t,n,r){let o=t,i=null;if(o)try{let l=JSON.stringify(o);i=Te.parseTextSync?.(l,r)||null}catch(l){console.warn("PMTiles metadata could not be interpreted as TileJSON",l)}let s={};typeof i?.name=="string"&&(s.name=i.name),typeof i?.htmlAttribution=="string"&&(s.attributions=[i.htmlAttribution]);let a={...s,format:"pmtiles",formatVersion:e.specVersion,attributions:[],tileMIMEType:fs(e.tileType),minZoom:e.minZoom,maxZoom:e.maxZoom,boundingBox:[[e.minLon,e.minLat],[e.maxLon,e.maxLat]],center:[e.centerLon,e.centerLat],centerZoom:e.centerZoom,etag:e.etag};return i&&(a.tilejson=i),n?.includeFormatHeader&&(a.formatHeader=e,a.formatMetadata=a),a}function fs(e){switch(e){case Ee.Mvt:return"application/vnd.mapbox-vector-tile";case Ee.Png:return"image/png";case Ee.Jpeg:return"image/jpeg";case Ee.Webp:return"image/webp";case Ee.Avif:return"image/avif";default:return"application/octet-stream"}}var We=class{blob;key;constructor(t,n){this.blob=t,this.key=n}getKey(){return this.blob.url||""}async getBytes(t,n,r){return{data:await this.blob.slice(t,t+n).arrayBuffer()}}};var{PMTiles:us}=be;var Je=class extends he{data;props;mimeType=null;pmtiles;metadata;constructor(t){super(t),this.props=t;let n=typeof t.url=="string"?it(t.url):new We(t.url,"pmtiles");this.data=t.url,this.pmtiles=new us(n),this.getTileData=this.getTileData.bind(this),this.metadata=this.getMetadata()}async getSchema(){return{fields:[],metadata:{}}}async getMetadata(){let t=await this.pmtiles.getHeader(),n=await this.pmtiles.getMetadata(),r=dr(t,n,{includeFormatHeader:!1},this.loadOptions);return this.props.attributions&&(r.attributions=[...this.props.attributions,...r.attributions||[]]),r?.tileMIMEType&&(this.mimeType=r?.tileMIMEType),r}async getTile(t){let{x:n,y:r,z:o}=t,s=(await this.pmtiles.getZxy(o,n,r))?.data;return s||null}async getTileData(t){let{x:n,y:r,z:o}=t.index;switch((await this.metadata).tileMIMEType){case"application/vnd.mapbox-vector-tile":return await this.getVectorTile({x:n,y:r,z:o,layers:[]});default:return await this.getImageTile({x:n,y:r,z:o,layers:[]})}}async getImageTile(t){let n=await this.getTile(t);return n?await ft.parse(n,this.loadOptions):null}async getVectorTile(t){let n=await this.getTile(t),r={shape:"geojson-table",mvt:{coordinates:"wgs84",tileIndex:{x:t.x,y:t.y,z:t.z},...this.loadOptions?.mvt},...this.loadOptions};return n?await Ft.parse(n,r):null}};return br(Se);})();
|
|
7
|
+
"use strict";var __exports__=(()=>{var vr=Object.create;var fe=Object.defineProperty;var Tr=Object.getOwnPropertyDescriptor;var Ir=Object.getOwnPropertyNames;var Pr=Object.getPrototypeOf,Fr=Object.prototype.hasOwnProperty;var br=(e,t,n)=>t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Qe=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),zt=(e,t)=>{for(var n in t)fe(e,n,{get:t[n],enumerable:!0})},Ae=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ir(t))!Fr.call(e,o)&&o!==n&&fe(e,o,{get:()=>t[o],enumerable:!(r=Tr(t,o))||r.enumerable});return e},De=(e,t,n)=>(Ae(e,t,"default"),n&&Ae(n,t,"default")),jt=(e,t,n)=>(n=e!=null?vr(Pr(e)):{},Ae(t||!e||!e.__esModule?fe(n,"default",{value:e,enumerable:!0}):n,e)),Sr=e=>Ae(fe({},"__esModule",{value:!0}),e);var Rt=(e,t,n)=>(br(e,typeof t!="symbol"?t+"":t,n),n);var Zt=Qe((gs,Ht)=>{Ht.exports=globalThis.loaders});var _n=Qe(xt=>{xt.read=function(e,t,n,r,o){var i,s,a=o*8-r-1,l=(1<<a)-1,c=l>>1,f=-7,u=n?o-1:0,h=n?-1:1,d=e[t+u];for(u+=h,i=d&(1<<-f)-1,d>>=-f,f+=a;f>0;i=i*256+e[t+u],u+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=r;f>0;s=s*256+e[t+u],u+=h,f-=8);if(i===0)i=1-c;else{if(i===l)return s?NaN:(d?-1:1)*(1/0);s=s+Math.pow(2,r),i=i-c}return(d?-1:1)*s*Math.pow(2,i-r)};xt.write=function(e,t,n,r,o,i){var s,a,l,c=i*8-o-1,f=(1<<c)-1,u=f>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,p=r?1:-1,y=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+u>=1?t+=h/l:t+=h*Math.pow(2,1-u),t*l>=2&&(s++,l/=2),s+u>=f?(a=0,s=f):s+u>=1?(a=(t*l-1)*Math.pow(2,o),s=s+u):(a=t*Math.pow(2,u-1)*Math.pow(2,o),s=0));o>=8;e[n+d]=a&255,d+=p,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[n+d]=s&255,d+=p,s/=256,c-=8);e[n+d-p]|=y*128}});var Mn=Qe((Ol,Vn)=>{"use strict";Vn.exports=x;var je=_n();function x(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}x.Varint=0;x.Fixed64=1;x.Bytes=2;x.Fixed32=5;var wt=(1<<16)*(1<<16),Bn=1/wt,ti=12,Ln=typeof TextDecoder>"u"?null:new TextDecoder("utf8");x.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos<n;){var r=this.readVarint(),o=r>>3,i=this.pos;this.type=r&7,e(o,t,this),this.pos===i&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Re(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Dn(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Re(this.buf,this.pos)+Re(this.buf,this.pos+4)*wt;return this.pos+=8,e},readSFixed64:function(){var e=Re(this.buf,this.pos)+Dn(this.buf,this.pos+4)*wt;return this.pos+=8,e},readFloat:function(){var e=je.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=je.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t=this.buf,n,r;return r=t[this.pos++],n=r&127,r<128||(r=t[this.pos++],n|=(r&127)<<7,r<128)||(r=t[this.pos++],n|=(r&127)<<14,r<128)||(r=t[this.pos++],n|=(r&127)<<21,r<128)?n:(r=t[this.pos],n|=(r&15)<<28,ni(n,e,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2===1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=ti&&Ln?mi(this.buf,t,e):gi(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==x.Bytes)return e.push(this.readVarint(t));var n=j(this);for(e=e||[];this.pos<n;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==x.Bytes)return e.push(this.readSVarint());var t=j(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==x.Bytes)return e.push(this.readBoolean());var t=j(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==x.Bytes)return e.push(this.readFloat());var t=j(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==x.Bytes)return e.push(this.readDouble());var t=j(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==x.Bytes)return e.push(this.readFixed32());var t=j(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==x.Bytes)return e.push(this.readSFixed32());var t=j(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==x.Bytes)return e.push(this.readFixed64());var t=j(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==x.Bytes)return e.push(this.readSFixed64());var t=j(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=e&7;if(t===x.Varint)for(;this.buf[this.pos++]>127;);else if(t===x.Bytes)this.pos=this.readVarint()+this.pos;else if(t===x.Fixed32)this.pos+=4;else if(t===x.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+t)},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var n=new Uint8Array(t);n.set(this.buf),this.buf=n,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),ie(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),ie(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),ie(this.buf,e&-1,this.pos),ie(this.buf,Math.floor(e*Bn),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),ie(this.buf,e&-1,this.pos),ie(this.buf,Math.floor(e*Bn),this.pos+4),this.pos+=8},writeVarint:function(e){if(e=+e||0,e>268435455||e<0){ri(e,this);return}this.realloc(4),this.buf[this.pos++]=e&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=e>>>7&127)))},writeSVarint:function(e){this.writeVarint(e<0?-e*2-1:e*2)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(e.length*4),this.pos++;var t=this.pos;this.pos=yi(this.buf,e,this.pos);var n=this.pos-t;n>=128&&An(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),je.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),je.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n<t;n++)this.buf[this.pos++]=e[n]},writeRawMessage:function(e,t){this.pos++;var n=this.pos;e(t,this);var r=this.pos-n;r>=128&&An(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,n){this.writeTag(e,x.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,si,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,ai,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,fi,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,li,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,ci,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,ui,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,hi,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,di,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,pi,t)},writeBytesField:function(e,t){this.writeTag(e,x.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,x.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,x.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,x.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,x.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,x.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,x.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,x.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,x.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,x.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};function ni(e,t,n){var r=n.buf,o,i;if(i=r[n.pos++],o=(i&112)>>4,i<128||(i=r[n.pos++],o|=(i&127)<<3,i<128)||(i=r[n.pos++],o|=(i&127)<<10,i<128)||(i=r[n.pos++],o|=(i&127)<<17,i<128)||(i=r[n.pos++],o|=(i&127)<<24,i<128)||(i=r[n.pos++],o|=(i&1)<<31,i<128))return oe(e,o,t);throw new Error("Expected varint not more than 10 bytes")}function j(e){return e.type===x.Bytes?e.readVarint()+e.pos:e.pos+1}function oe(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function ri(e,t){var n,r;if(e>=0?(n=e%4294967296|0,r=e/4294967296|0):(n=~(-e%4294967296),r=~(-e/4294967296),n^4294967295?n=n+1|0:(n=0,r=r+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),oi(n,r,t),ii(r,t)}function oi(e,t,n){n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos]=e&127}function ii(e,t){var n=(e&7)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127)))))}function An(e,t,n){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));n.realloc(r);for(var o=n.pos-1;o>=e;o--)n.buf[o+r]=n.buf[o]}function si(e,t){for(var n=0;n<e.length;n++)t.writeVarint(e[n])}function ai(e,t){for(var n=0;n<e.length;n++)t.writeSVarint(e[n])}function li(e,t){for(var n=0;n<e.length;n++)t.writeFloat(e[n])}function ci(e,t){for(var n=0;n<e.length;n++)t.writeDouble(e[n])}function fi(e,t){for(var n=0;n<e.length;n++)t.writeBoolean(e[n])}function ui(e,t){for(var n=0;n<e.length;n++)t.writeFixed32(e[n])}function hi(e,t){for(var n=0;n<e.length;n++)t.writeSFixed32(e[n])}function di(e,t){for(var n=0;n<e.length;n++)t.writeFixed64(e[n])}function pi(e,t){for(var n=0;n<e.length;n++)t.writeSFixed64(e[n])}function Re(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+e[t+3]*16777216}function ie(e,t,n){e[n]=t,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function Dn(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function gi(e,t,n){for(var r="",o=t;o<n;){var i=e[o],s=null,a=i>239?4:i>223?3:i>191?2:1;if(o+a>n)break;var l,c,f;a===1?i<128&&(s=i):a===2?(l=e[o+1],(l&192)===128&&(s=(i&31)<<6|l&63,s<=127&&(s=null))):a===3?(l=e[o+1],c=e[o+2],(l&192)===128&&(c&192)===128&&(s=(i&15)<<12|(l&63)<<6|c&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):a===4&&(l=e[o+1],c=e[o+2],f=e[o+3],(l&192)===128&&(c&192)===128&&(f&192)===128&&(s=(i&15)<<18|(l&63)<<12|(c&63)<<6|f&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,a=1):s>65535&&(s-=65536,r+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),r+=String.fromCharCode(s),o+=a}return r}function mi(e,t,n){return Ln.decode(e.subarray(t,n))}function yi(e,t,n){for(var r=0,o,i;r<t.length;r++){if(o=t.charCodeAt(r),o>55295&&o<57344)if(i)if(o<56320){e[n++]=239,e[n++]=191,e[n++]=189,i=o;continue}else o=i-55296<<10|o-56320|65536,i=null;else{o>56319||r+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):i=o;continue}else i&&(e[n++]=239,e[n++]=191,e[n++]=189,i=null);o<128?e[n++]=o:(o<2048?e[n++]=o>>6|192:(o<65536?e[n++]=o>>12|224:(e[n++]=o>>18|240,e[n++]=o>>12&63|128),e[n++]=o>>6&63|128),e[n++]=o&63|128)}return n}});var _e={};zt(_e,{PMTilesSource:()=>pr,PMTilesTileSource:()=>Ee});De(_e,jt(Zt(),1));function ue(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var G={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Er=G.self||G.window||G.global||{},_r=G.window||G.self||G.global||{},Br=G.global||G.self||G.window||{},Ar=G.document||{};var qe=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var Wt=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Dr=Wt&&parseFloat(Wt[1])||0;function H(e){return H=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},H(e)}function et(e,t){if(H(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(H(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function tt(e){var t=et(e,"string");return H(t)==="symbol"?t:String(t)}function T(e,t,n){return t=tt(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nt(e){if(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&Boolean(process.versions.electron))return!0;let t=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,n=e||t;return!!(n&&n.indexOf("Electron")>=0)}function N(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||nt()}var Lr=globalThis.self||globalThis.window||globalThis.global,ee=globalThis.window||globalThis.self||globalThis.global,Vr=globalThis.document||{},W=globalThis.process||{},Mr=globalThis.console,Bs=globalThis.navigator||{};var Le=typeof __VERSION__<"u"?__VERSION__:"untranspiled source",Ls=N();function Ur(e){try{let t=window[e],n="__storage_test__";return t.setItem(n,n),t.removeItem(n),t}catch{return null}}var Ve=class{constructor(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"sessionStorage";T(this,"storage",void 0),T(this,"id",void 0),T(this,"config",void 0),this.storage=Ur(r),this.id=t,this.config=n,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){if(Object.assign(this.config,t),this.storage){let n=JSON.stringify(this.config);this.storage.setItem(this.id,n)}}_loadConfiguration(){let t={};if(this.storage){let n=this.storage.getItem(this.id);t=n?JSON.parse(n):{}}return Object.assign(this.config,t),this}};function Jt(e){let t;return e<10?t="".concat(e.toFixed(2),"ms"):e<100?t="".concat(e.toFixed(1),"ms"):e<1e3?t="".concat(e.toFixed(0),"ms"):t="".concat((e/1e3).toFixed(2),"s"),t}function Kt(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8,n=Math.max(t-e.length,0);return"".concat(" ".repeat(n)).concat(e)}function Me(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:600,o=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>r&&(n=Math.min(n,r/e.width));let i=e.width*n,s=e.height*n,a=["font-size:1px;","padding:".concat(Math.floor(s/2),"px ").concat(Math.floor(i/2),"px;"),"line-height:".concat(s,"px;"),"background:url(".concat(o,");"),"background-size:".concat(i,"px ").concat(s,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),a]}var Ue;(function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Ue||(Ue={}));var kr=10;function $t(e){return typeof e!="string"?e:(e=e.toUpperCase(),Ue[e]||Ue.WHITE)}function Yt(e,t,n){if(!N&&typeof e=="string"){if(t){let r=$t(t);e="\x1B[".concat(r,"m").concat(e,"\x1B[39m")}if(n){let r=$t(n);e="\x1B[".concat(r+kr,"m").concat(e,"\x1B[49m")}}return e}function Xt(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:["constructor"],n=Object.getPrototypeOf(e),r=Object.getOwnPropertyNames(n),o=e;for(let i of r){let s=o[i];typeof s=="function"&&(t.find(a=>i===a)||(o[i]=s.bind(e)))}}function te(e,t){if(!e)throw new Error(t||"Assertion failed")}function J(){let e;if(N()&&ee.performance){var t,n;e=ee===null||ee===void 0||(t=ee.performance)===null||t===void 0||(n=t.now)===null||n===void 0?void 0:n.call(t)}else if("hrtime"in W){var r;let o=W===null||W===void 0||(r=W.hrtime)===null||r===void 0?void 0:r.call(W);e=o[0]*1e3+o[1]/1e6}else e=Date.now();return e}var ne={debug:N()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Nr={enabled:!0,level:0};function D(){}var Qt={},qt={once:!0},Z=class{constructor(){let{id:t}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{id:""};T(this,"id",void 0),T(this,"VERSION",Le),T(this,"_startTs",J()),T(this,"_deltaTs",J()),T(this,"_storage",void 0),T(this,"userData",{}),T(this,"LOG_THROTTLE_TIMEOUT",0),this.id=t,this.userData={},this._storage=new Ve("__probe-".concat(this.id,"__"),Nr),this.timeStamp("".concat(this.id," started")),Xt(this),Object.seal(this)}set level(t){this.setLevel(t)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((J()-this._startTs).toPrecision(10))}getDelta(){return Number((J()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return this._storage.setConfiguration({enabled:t}),this}setLevel(t){return this._storage.setConfiguration({level:t}),this}get(t){return this._storage.config[t]}set(t,n){this._storage.setConfiguration({[t]:n})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,n){te(t,n)}warn(t){return this._getLogFunction(0,t,ne.warn,arguments,qt)}error(t){return this._getLogFunction(0,t,ne.error,arguments)}deprecated(t,n){return this.warn("`".concat(t,"` is deprecated and will be removed in a later version. Use `").concat(n,"` instead"))}removed(t,n){return this.error("`".concat(t,"` has been removed. Use `").concat(n,"` instead"))}probe(t,n){return this._getLogFunction(t,n,ne.log,arguments,{time:!0,once:!0})}log(t,n){return this._getLogFunction(t,n,ne.debug,arguments)}info(t,n){return this._getLogFunction(t,n,console.info,arguments)}once(t,n){return this._getLogFunction(t,n,ne.debug||ne.info,arguments,qt)}table(t,n,r){return n?this._getLogFunction(t,n,console.table||D,r&&[r],{tag:zr(n)}):D}image(t){let{logLevel:n,priority:r,image:o,message:i="",scale:s=1}=t;return this._shouldLog(n||r)?N()?Gr({image:o,message:i,scale:s}):Or({image:o,message:i,scale:s}):D}time(t,n){return this._getLogFunction(t,n,console.time?console.time:console.info)}timeEnd(t,n){return this._getLogFunction(t,n,console.timeEnd?console.timeEnd:console.info)}timeStamp(t,n){return this._getLogFunction(t,n,console.timeStamp||D)}group(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{collapsed:!1},o=en({logLevel:t,message:n,opts:r}),{collapsed:i}=r;return o.method=(i?console.groupCollapsed:console.group)||console.info,this._getLogFunction(o)}groupCollapsed(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.group(t,n,Object.assign({},r,{collapsed:!0}))}groupEnd(t){return this._getLogFunction(t,"",console.groupEnd||D)}withGroup(t,n,r){this.group(t,n)();try{r()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&this.getLevel()>=tn(t)}_getLogFunction(t,n,r,o,i){if(this._shouldLog(t)){i=en({logLevel:t,message:n,args:o,opts:i}),r=r||i.method,te(r),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=J();let s=i.tag||i.message;if(i.once&&s)if(!Qt[s])Qt[s]=J();else return D;return n=Cr(this.id,i.message,i),r.bind(console,n,...i.args)}return D}};T(Z,"VERSION",Le);function tn(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return te(Number.isFinite(t)&&t>=0),t}function en(e){let{logLevel:t,message:n}=e;e.logLevel=tn(t);let r=e.args?Array.from(e.args):[];for(;r.length&&r.shift()!==n;);switch(typeof t){case"string":case"function":n!==void 0&&r.unshift(n),e.message=t;break;case"object":Object.assign(e,t);break;default:}typeof e.message=="function"&&(e.message=e.message());let o=typeof e.message;return te(o==="string"||o==="object"),Object.assign(e,{args:r},e.opts)}function Cr(e,t,n){if(typeof t=="string"){let r=n.time?Kt(Jt(n.total)):"";t=n.time?"".concat(e,": ").concat(r," ").concat(t):"".concat(e,": ").concat(t),t=Yt(t,n.color,n.background)}return t}function Or(e){let{image:t,message:n="",scale:r=1}=e;return console.warn("removed"),D}function Gr(e){let{image:t,message:n="",scale:r=1}=e;if(typeof t=="string"){let i=new Image;return i.onload=()=>{let s=Me(i,n,r);console.log(...s)},i.src=t,D}let o=t.nodeName||"";if(o.toLowerCase()==="img")return console.log(...Me(t,n,r)),D;if(o.toLowerCase()==="canvas"){let i=new Image;return i.onload=()=>console.log(...Me(i,n,r)),i.src=t.toDataURL(),D}return D}function zr(e){for(let t in e)for(let n in e[t])return n||"untitled";return"empty"}var ia=new Z({id:"@probe.gl/log"});var rt="4.3.0-alpha.2",jr=rt[0]>="0"&&rt[0]<="9"?`v${rt}`:"";function Rr(){let e=new Z({id:"loaders.gl"});return globalThis.loaders=globalThis.loaders||{},globalThis.loaders.log=e,globalThis.loaders.version=jr,globalThis.probe=globalThis.probe||{},globalThis.probe.loaders=e,e}var ot=Rr();var Hr="",nn={};function it(e){for(let t in nn)if(e.startsWith(t)){let n=nn[t];e=e.replace(t,n)}return!e.startsWith("http://")&&!e.startsWith("https://")&&(e=`${Hr}${e}`),e}var he=class{fetch;loadOptions;_needsRefresh=!0;props;constructor(t){this.props={...t},this.loadOptions={...t.loadOptions},this.fetch=Zr(this.loadOptions)}setProps(t){this.props=Object.assign(this.props,t),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(t=!0){let n=this._needsRefresh;return t&&(this._needsRefresh=!1),n}};function Zr(e){let t=e?.fetch;if(t&&typeof t=="function")return(r,o)=>t(r,o);let n=e?.fetch;return n&&typeof n!="function"?r=>fetch(r,n):r=>fetch(r)}var rn="4.3.0-alpha.2";var Wr=globalThis.loaders?.parseImageNode,st=typeof Image<"u",at=typeof ImageBitmap<"u",Jr=Boolean(Wr),lt=qe?!0:Jr;function on(e){switch(e){case"auto":return at||st||lt;case"imagebitmap":return at;case"image":return st;case"data":return lt;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function sn(){if(at)return"imagebitmap";if(st)return"image";if(lt)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function Kr(e){let t=$r(e);if(!t)throw new Error("Not an image");return t}function an(e){switch(Kr(e)){case"data":return e;case"image":case"imagebitmap":let t=document.createElement("canvas"),n=t.getContext("2d");if(!n)throw new Error("getImageData");return t.width=e.width,t.height=e.height,n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}function $r(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&e instanceof Image?"image":e&&typeof e=="object"&&e.data&&e.width&&e.height?"data":null}var Yr=/^data:image\/svg\+xml/,Xr=/\.svg((\?|#).*)?$/;function ke(e){return e&&(Yr.test(e)||Xr.test(e))}function ln(e,t){if(ke(t)){let r=new TextDecoder().decode(e);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(r=unescape(encodeURIComponent(r)))}catch(i){throw new Error(i.message)}return`data:image/svg+xml;base64,${btoa(r)}`}return ct(e,t)}function ct(e,t){if(ke(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function Ne(e,t,n){let r=ln(e,n),o=self.URL||self.webkitURL,i=typeof r!="string"&&o.createObjectURL(r);try{return await Qr(i||r,t)}finally{i&&o.revokeObjectURL(i)}}async function Qr(e,t){let n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((r,o)=>{try{n.onload=()=>r(n),n.onerror=i=>{let s=i instanceof Error?i.message:"error";o(new Error(s))}}catch(i){o(i)}})}var qr={},cn=!0;async function fn(e,t,n){let r;ke(n)?r=await Ne(e,t,n):r=ct(e,n);let o=t&&t.imagebitmap;return await eo(r,o)}async function eo(e,t=null){if((to(t)||!cn)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(n){console.warn(n),cn=!1}return await createImageBitmap(e)}function to(e){for(let t in e||qr)return!1;return!0}function un(e){return!io(e,"ftyp",4)||!(e[8]&96)?null:no(e)}function no(e){switch(ro(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function ro(e,t,n){return String.fromCharCode(...e.slice(t,n))}function oo(e){return[...e].map(t=>t.charCodeAt(0))}function io(e,t,n=0){let r=oo(t);for(let o=0;o<r.length;++o)if(r[o]!==e[o+n])return!1;return!0}var z=!1,de=!0;function Ce(e){let t=pe(e);return ao(t)||fo(t)||lo(t)||co(t)||so(t)}function so(e){let t=new Uint8Array(e instanceof DataView?e.buffer:e),n=un(t);return n?{mimeType:n.mimeType,width:0,height:0}:null}function ao(e){let t=pe(e);return t.byteLength>=24&&t.getUint32(0,z)===2303741511?{mimeType:"image/png",width:t.getUint32(16,z),height:t.getUint32(20,z)}:null}function lo(e){let t=pe(e);return t.byteLength>=10&&t.getUint32(0,z)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,de),height:t.getUint16(8,de)}:null}function co(e){let t=pe(e);return t.byteLength>=14&&t.getUint16(0,z)===16973&&t.getUint32(2,de)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,de),height:t.getUint32(22,de)}:null}function fo(e){let t=pe(e);if(!(t.byteLength>=3&&t.getUint16(0,z)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:r,sofMarkers:o}=uo(),i=2;for(;i+9<t.byteLength;){let s=t.getUint16(i,z);if(o.has(s))return{mimeType:"image/jpeg",height:t.getUint16(i+5,z),width:t.getUint16(i+7,z)};if(!r.has(s))return null;i+=2,i+=t.getUint16(i,z)}return null}function uo(){let e=new Set([65499,65476,65484,65501,65534]);for(let n=65504;n<65520;++n)e.add(n);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function pe(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}async function hn(e,t){let{mimeType:n}=Ce(e)||{},r=globalThis.loaders?.parseImageNode;return ue(r),await r(e,n)}async function dn(e,t,n){t=t||{};let o=(t.image||{}).type||"auto",{url:i}=n||{},s=ho(o),a;switch(s){case"imagebitmap":a=await fn(e,t,i);break;case"image":a=await Ne(e,t,i);break;case"data":a=await hn(e,t);break;default:ue(!1)}return o==="data"&&(a=an(a)),a}function ho(e){switch(e){case"auto":case"data":return sn();default:return on(e),e}}var po=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],go=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],mo={image:{type:"auto",decode:!0}},ft={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:rn,mimeTypes:go,extensions:po,parse:dn,tests:[e=>Boolean(Ce(new DataView(e)))],options:mo};var yn=e=>e!==null&&typeof e=="object";function ut(e,t){if(!e||!yn(e))return null;let n={name:e.name||"",description:e.description||""};if(typeof e.generator=="string"&&(n.generator=e.generator),typeof e.generator_options=="string"&&(n.generatorOptions=e.generator_options),n.boundingBox=pn(e.bounds)||pn(e.antimeridian_adjusted_bounds),n.center=Io(e.center),n.maxZoom=gn(e.maxzoom),n.minZoom=gn(e.minzoom),typeof e?.json=="string")try{n.metaJson=JSON.parse(e.json)}catch(a){console.warn("Failed to parse tilejson.json field",a)}let r=e.tilestats||n.metaJson?.tilestats,o=wo(r,t),i=yo(e.vector_layers),s=To(i,o);return n={...n,layers:s},n.maxZoom===null&&s.length>0&&(n.maxZoom=s[0].maxZoom||null),n.minZoom===null&&s.length>0&&(n.minZoom=s[0].minZoom||null),n}function yo(e){return Array.isArray(e)?e.map(t=>xo(t)):[]}function xo(e){let t=Object.entries(e.fields||[]).map(([r,o])=>({name:r,...Tn(String(o))})),n={...e};return delete n.fields,{name:e.id||"",...n,fields:t}}function wo(e,t){return yn(e)&&Array.isArray(e.layers)?e.layers.map(n=>vo(n,t)):[]}function vo(e,t){let n=[],r={},o=e.attributes||[];for(let i of o){let s=i.attribute;if(typeof s=="string")if(s.split("|").length>1){let a=s.split("|")[0];r[a]=r[a]||[],r[a].push(i),console.warn("ignoring tilestats indexed field",a)}else n[s]||n.push(Fo(i,t))}return{name:e.layer||"",dominantGeometry:e.geometry,fields:n}}function To(e,t){return e.map(n=>{let r=t.find(s=>s.name===n.name),o=r?.fields||[],i={...n};return delete i.fields,{...i,...r,fields:o}})}function pn(e){let t=vn(e);if(Array.isArray(t)&&t.length===4&&[t[0],t[2]].every(wn)&&[t[1],t[3]].every(xn))return[[t[0],t[1]],[t[2],t[3]]]}function Io(e){let t=vn(e);return Array.isArray(t)&&t.length===3&&wn(t[0])&&xn(t[1])&&Po(t[2])?t:null}function gn(e){let t=typeof e=="string"?parseFloat(e):typeof e=="number"?e:null;return t===null||isNaN(t)?null:t}function xn(e){return Number.isFinite(e)&&e<=90&&e>=-90}function wn(e){return Number.isFinite(e)&&e<=180&&e>=-180}function Po(e){return Number.isFinite(e)&&e>=0&&e<=22}function vn(e){return typeof e=="string"?e.split(",").map(parseFloat):Array.isArray(e)?e:null}var mn={number:{type:"float32"},numeric:{type:"float32"},string:{type:"utf8"},vachar:{type:"utf8"},float:{type:"float32"},int:{type:"int32"},int4:{type:"int32"},boolean:{type:"boolean"},bool:{type:"boolean"}};function Fo(e={},t){let n=Tn(e.type),r={name:e.attribute,...n};return typeof e.min=="number"&&(r.min=e.min),typeof e.max=="number"&&(r.max=e.max),typeof e.count=="number"&&(r.uniqueValueCount=e.count),e.values&&(r.values=e.values),r.values&&typeof t.maxValues=="number"&&(r.values=r.values?.slice(0,t.maxValues)),r}function Tn(e){let t=e.toLowerCase();return!t||mn[t],mn[t]||{type:"string"}}var bo="4.3.0-alpha.2",ge={dataType:null,batchType:null,name:"TileJSON",id:"tilejson",module:"pmtiles",version:bo,worker:!0,extensions:["json"],mimeTypes:["application/json"],text:!0,options:{tilejson:{maxValues:void 0}},parse:async(e,t)=>{let n=new TextDecoder().decode(e),r=JSON.parse(n),o={...ge.options.tilejson,...t?.tilejson};return ut(r,o)},parseTextSync:(e,t)=>{let n=JSON.parse(e),r={...ge.options.tilejson,...t?.tilejson};return ut(n,r)}};var me={x:0,y:1,z:2};function K(e,t={}){let{start:n=0,end:r=e.length,plane:o="xy"}=t,i=t.size||2,s=0,a=me[o[0]],l=me[o[1]];for(let c=n,f=r-i;c<r;c+=i)s+=(e[c+a]-e[f+a])*(e[c+l]+e[f+l]),f=c;return s/2}function dt(e,t,n=2,r,o="xy"){let i=t&&t.length,s=i?t[0]*n:e.length,a=Pn(e,0,s,n,!0,r&&r[0],o),l=[];if(!a||a.next===a.prev)return l;let c,f,u,h,d,p,y;if(i&&(a=Lo(e,t,a,n,r,o)),e.length>80*n){h=f=e[0],d=u=e[1];for(let P=n;P<s;P+=n)p=e[P],y=e[P+1],p<h&&(h=p),y<d&&(d=y),p>f&&(f=p),y>u&&(u=y);c=Math.max(f-h,u-d),c=c!==0?32767/c:0}return ye(a,l,n,h,d,c,0),l}function Pn(e,t,n,r,o,i,s){let a,l;i===void 0&&(i=K(e,{start:t,end:n,size:r,plane:s}));let c=me[s[0]],f=me[s[1]];if(o===i<0)for(a=t;a<n;a+=r)l=In(a,e[a+c],e[a+f],l);else for(a=n-r;a>=t;a-=r)l=In(a,e[a+c],e[a+f],l);return l&&ze(l,l.next)&&(we(l),l=l.next),l}function $(e,t){if(!e)return e;t||(t=e);let n=e,r;do if(r=!1,!n.steiner&&(ze(n,n.next)||I(n.prev,n,n.next)===0)){if(we(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function ye(e,t,n,r,o,i,s){if(!e)return;!s&&i&&No(e,r,o,i);let a=e,l,c;for(;e.prev!==e.next;){if(l=e.prev,c=e.next,i?Bo(e,r,o,i):_o(e)){t.push(l.i/n|0),t.push(e.i/n|0),t.push(c.i/n|0),we(e),e=c.next,a=c.next;continue}if(e=c,e===a){s?s===1?(e=Ao($(e),t,n),ye(e,t,n,r,o,i,2)):s===2&&Do(e,t,n,r,o,i):ye($(e),t,n,r,o,i,1);break}}}function _o(e){let t=e.prev,n=e,r=e.next;if(I(t,n,r)>=0)return!1;let o=t.x,i=n.x,s=r.x,a=t.y,l=n.y,c=r.y,f=o<i?o<s?o:s:i<s?i:s,u=a<l?a<c?a:c:l<c?l:c,h=o>i?o>s?o:s:i>s?i:s,d=a>l?a>c?a:c:l>c?l:c,p=r.next;for(;p!==t;){if(p.x>=f&&p.x<=h&&p.y>=u&&p.y<=d&&re(o,a,i,l,s,c,p.x,p.y)&&I(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Bo(e,t,n,r){let o=e.prev,i=e,s=e.next;if(I(o,i,s)>=0)return!1;let a=o.x,l=i.x,c=s.x,f=o.y,u=i.y,h=s.y,d=a<l?a<c?a:c:l<c?l:c,p=f<u?f<h?f:h:u<h?u:h,y=a>l?a>c?a:c:l>c?l:c,P=f>u?f>h?f:h:u>h?u:h,M=ht(d,p,t,n,r),v=ht(y,P,t,n,r),m=e.prevZ,g=e.nextZ;for(;m&&m.z>=M&&g&&g.z<=v;){if(m.x>=d&&m.x<=y&&m.y>=p&&m.y<=P&&m!==o&&m!==s&&re(a,f,l,u,c,h,m.x,m.y)&&I(m.prev,m,m.next)>=0||(m=m.prevZ,g.x>=d&&g.x<=y&&g.y>=p&&g.y<=P&&g!==o&&g!==s&&re(a,f,l,u,c,h,g.x,g.y)&&I(g.prev,g,g.next)>=0))return!1;g=g.nextZ}for(;m&&m.z>=M;){if(m.x>=d&&m.x<=y&&m.y>=p&&m.y<=P&&m!==o&&m!==s&&re(a,f,l,u,c,h,m.x,m.y)&&I(m.prev,m,m.next)>=0)return!1;m=m.prevZ}for(;g&&g.z<=v;){if(g.x>=d&&g.x<=y&&g.y>=p&&g.y<=P&&g!==o&&g!==s&&re(a,f,l,u,c,h,g.x,g.y)&&I(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function Ao(e,t,n){let r=e;do{let o=r.prev,i=r.next.next;!ze(o,i)&&Fn(o,r,r.next,i)&&xe(o,i)&&xe(i,o)&&(t.push(o.i/n|0),t.push(r.i/n|0),t.push(i.i/n|0),we(r),we(r.next),r=e=i),r=r.next}while(r!==e);return $(r)}function Do(e,t,n,r,o,i){let s=e;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&Go(s,a)){let l=bn(s,a);s=$(s,s.next),l=$(l,l.next),ye(s,t,n,r,o,i,0),ye(l,t,n,r,o,i,0);return}a=a.next}s=s.next}while(s!==e)}function Lo(e,t,n,r,o,i){let s=[],a,l,c,f,u;for(a=0,l=t.length;a<l;a++)c=t[a]*r,f=a<l-1?t[a+1]*r:e.length,u=Pn(e,c,f,r,!1,o&&o[a+1],i),u===u.next&&(u.steiner=!0),s.push(Oo(u));for(s.sort(Vo),a=0;a<s.length;a++)n=Mo(s[a],n);return n}function Vo(e,t){return e.x-t.x}function Mo(e,t){let n=Uo(e,t);if(!n)return t;let r=bn(n,e);return $(r,r.next),$(n,n.next)}function Uo(e,t){let n=t,r=e.x,o=e.y,i=-1/0,s;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){let h=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(h<=r&&h>i&&(i=h,s=n.x<n.next.x?n:n.next,h===r))return s}n=n.next}while(n!==t);if(!s)return null;let a=s,l=s.x,c=s.y,f=1/0,u;n=s;do r>=n.x&&n.x>=l&&r!==n.x&&re(o<c?r:i,o,l,c,o<c?i:r,o,n.x,n.y)&&(u=Math.abs(o-n.y)/(r-n.x),xe(n,e)&&(u<f||u===f&&(n.x>s.x||n.x===s.x&&ko(s,n)))&&(s=n,f=u)),n=n.next;while(n!==a);return s}function ko(e,t){return I(e.prev,e,t.prev)<0&&I(t.next,e,e.next)<0}function No(e,t,n,r){let o=e;do o.z===0&&(o.z=ht(o.x,o.y,t,n,r)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next;while(o!==e);o.prevZ.nextZ=null,o.prevZ=null,Co(o)}function Co(e){let t,n,r=1,o,i,s,a,l,c;do{for(i=e,e=null,c=null,o=0;i;){for(o++,a=i,s=0,n=0;n<r&&(s++,a=a.nextZ,!!a);n++);for(l=r;s>0||l>0&&a;)s!==0&&(l===0||!a||i.z<=a.z)?(t=i,i=i.nextZ,s--):(t=a,a=a.nextZ,l--),c?c.nextZ=t:e=t,t.prevZ=c,c=t;i=a}c.nextZ=null,r*=2}while(o>1);return e}function ht(e,t,n,r,o){return e=(e-n)*o|0,t=(t-r)*o|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function Oo(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function re(e,t,n,r,o,i,s,a){return(o-s)*(t-a)>=(e-s)*(i-a)&&(e-s)*(r-a)>=(n-s)*(t-a)&&(n-s)*(i-a)>=(o-s)*(r-a)}function Go(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!zo(e,t)&&(xe(e,t)&&xe(t,e)&&jo(e,t)&&(I(e.prev,e,t.prev)||I(e,t.prev,t))||ze(e,t)&&I(e.prev,e,e.next)>0&&I(t.prev,t,t.next)>0)}function I(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function ze(e,t){return e.x===t.x&&e.y===t.y}function Fn(e,t,n,r){let o=Ge(I(e,t,n)),i=Ge(I(e,t,r)),s=Ge(I(n,r,e)),a=Ge(I(n,r,t));return!!(o!==i&&s!==a||o===0&&Oe(e,n,t)||i===0&&Oe(e,r,t)||s===0&&Oe(n,e,r)||a===0&&Oe(n,t,r))}function Oe(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Ge(e){return e>0?1:e<0?-1:0}function zo(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Fn(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function xe(e,t){return I(e.prev,e,e.next)<0?I(e,t,e.next)>=0&&I(e,e.prev,t)>=0:I(e,t,e.prev)<0||I(e,e.next,t)<0}function jo(e,t){let n=e,r=!1,o=(e.x+t.x)/2,i=(e.y+t.y)/2;do n.y>i!=n.next.y>i&&n.next.y!==n.y&&o<(n.next.x-n.x)*(i-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function bn(e,t){let n=new ve(e.i,e.x,e.y),r=new ve(t.i,t.x,t.y),o=e.next,i=t.prev;return e.next=t,t.prev=e,n.next=o,o.prev=n,r.next=n,n.prev=r,i.next=r,r.prev=i,r}function In(e,t,n,r){let o=new ve(e,t,n);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o}function we(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}var ve=class{constructor(t,n,r){T(this,"i",void 0),T(this,"x",void 0),T(this,"y",void 0),T(this,"prev",null),T(this,"next",null),T(this,"z",0),T(this,"prevZ",null),T(this,"nextZ",null),T(this,"steiner",!1),this.i=t,this.x=n,this.y=r}};function mt(e,t,n){let r=Jo(e),o=Object.keys(r).filter(i=>r[i]!==Array);return Ko(e,{propArrayTypes:r,...t},{numericPropKeys:n&&n.numericPropKeys||o,PositionDataType:n?n.PositionDataType:Float32Array,triangulate:n?n.triangulate:!0})}function Jo(e){let t={};for(let n of e)if(n.properties)for(let r in n.properties){let o=n.properties[r];t[r]=ei(o,t[r])}return t}function Ko(e,t,n){let{pointPositionsCount:r,pointFeaturesCount:o,linePositionsCount:i,linePathsCount:s,lineFeaturesCount:a,polygonPositionsCount:l,polygonObjectsCount:c,polygonRingsCount:f,polygonFeaturesCount:u,propArrayTypes:h,coordLength:d}=t,{numericPropKeys:p=[],PositionDataType:y=Float32Array,triangulate:P=!0}=n,M=e[0]&&"id"in e[0],v=e.length>65535?Uint32Array:Uint16Array,m={type:"Point",positions:new y(r*d),globalFeatureIds:new v(r),featureIds:o>65535?new Uint32Array(r):new Uint16Array(r),numericProps:{},properties:[],fields:[]},g={type:"LineString",pathIndices:i>65535?new Uint32Array(s+1):new Uint16Array(s+1),positions:new y(i*d),globalFeatureIds:new v(i),featureIds:a>65535?new Uint32Array(i):new Uint16Array(i),numericProps:{},properties:[],fields:[]},_={type:"Polygon",polygonIndices:l>65535?new Uint32Array(c+1):new Uint16Array(c+1),primitivePolygonIndices:l>65535?new Uint32Array(f+1):new Uint16Array(f+1),positions:new y(l*d),globalFeatureIds:new v(l),featureIds:u>65535?new Uint32Array(l):new Uint16Array(l),numericProps:{},properties:[],fields:[]};P&&(_.triangles=[]);for(let U of[m,g,_])for(let b of p){let B=h[b];U.numericProps[b]=new B(U.positions.length/d)}g.pathIndices[s]=i,_.polygonIndices[c]=l,_.primitivePolygonIndices[f]=l;let O={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let U of e){let b=U.geometry,B=U.properties||{};switch(b.type){case"Point":$o(b,m,O,d,B),m.properties.push(gt(B,p)),M&&m.fields.push({id:U.id}),O.pointFeature++;break;case"LineString":Yo(b,g,O,d,B),g.properties.push(gt(B,p)),M&&g.fields.push({id:U.id}),O.lineFeature++;break;case"Polygon":Xo(b,_,O,d,B),_.properties.push(gt(B,p)),M&&_.fields.push({id:U.id}),O.polygonFeature++;break;default:throw new Error("Invalid geometry type")}O.feature++}return qo(m,g,_,d)}function $o(e,t,n,r,o){t.positions.set(e.data,n.pointPosition*r);let i=e.data.length/r;yt(t,o,n.pointPosition,i),t.globalFeatureIds.fill(n.feature,n.pointPosition,n.pointPosition+i),t.featureIds.fill(n.pointFeature,n.pointPosition,n.pointPosition+i),n.pointPosition+=i}function Yo(e,t,n,r,o){t.positions.set(e.data,n.linePosition*r);let i=e.data.length/r;yt(t,o,n.linePosition,i),t.globalFeatureIds.fill(n.feature,n.linePosition,n.linePosition+i),t.featureIds.fill(n.lineFeature,n.linePosition,n.linePosition+i);for(let s=0,a=e.indices.length;s<a;++s){let l=e.indices[s],c=s===a-1?e.data.length:e.indices[s+1];t.pathIndices[n.linePath++]=n.linePosition,n.linePosition+=(c-l)/r}}function Xo(e,t,n,r,o){t.positions.set(e.data,n.polygonPosition*r);let i=e.data.length/r;yt(t,o,n.polygonPosition,i),t.globalFeatureIds.fill(n.feature,n.polygonPosition,n.polygonPosition+i),t.featureIds.fill(n.polygonFeature,n.polygonPosition,n.polygonPosition+i);for(let s=0,a=e.indices.length;s<a;++s){let l=n.polygonPosition;t.polygonIndices[n.polygonObject++]=l;let c=e.areas[s],f=e.indices[s],u=e.indices[s+1];for(let d=0,p=f.length;d<p;++d){let y=f[d],P=d===p-1?u===void 0?e.data.length:u[0]:f[d+1];t.primitivePolygonIndices[n.polygonRing++]=n.polygonPosition,n.polygonPosition+=(P-y)/r}let h=n.polygonPosition;Qo(t,c,f,{startPosition:l,endPosition:h,coordLength:r})}}function Qo(e,t,n,{startPosition:r,endPosition:o,coordLength:i}){if(!e.triangles)return;let s=r*i,a=o*i,l=e.positions.subarray(s,a),c=n[0],f=n.slice(1).map(h=>(h-c)/i),u=dt(l,f,i,t);for(let h=0,d=u.length;h<d;++h)e.triangles.push(r+u[h])}function pt(e,t){let n={};for(let r in e)n[r]={value:e[r],size:t};return n}function qo(e,t,n,r){let o={shape:"binary-feature-collection",points:{...e,positions:{value:e.positions,size:r},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:pt(e.numericProps,1)},lines:{...t,positions:{value:t.positions,size:r},pathIndices:{value:t.pathIndices,size:1},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:pt(t.numericProps,1)},polygons:{...n,positions:{value:n.positions,size:r},polygonIndices:{value:n.polygonIndices,size:1},primitivePolygonIndices:{value:n.primitivePolygonIndices,size:1},globalFeatureIds:{value:n.globalFeatureIds,size:1},featureIds:{value:n.featureIds,size:1},numericProps:pt(n.numericProps,1)}};return o.polygons&&n.triangles&&(o.polygons.triangles={value:new Uint32Array(n.triangles),size:1}),o}function yt(e,t,n,r){for(let o in e.numericProps)if(o in t){let i=t[o];e.numericProps[o].fill(i,n,n+r)}}function gt(e,t){let n={};for(let r in e)t.includes(r)||(n[r]=e[r]);return n}function ei(e,t){return t===Array||!Number.isFinite(e)?Array:t===Float64Array||Math.fround(e)!==e?Float64Array:Float32Array}var Pt=jt(Mn(),1);function xi(e){let t=0;for(let n=0,r=e.length-1,o,i;n<e.length;r=n++)o=e[n],i=e[r],t+=(i[0]-o[0])*(o[1]+i[1]);return t}function vt(e,t){if(Array.isArray(e[0])){for(let r of e)vt(r,t);return}let n=e;n[0]/=t,n[1]/=t}function Un(e,t){for(let n=0;n<e.length;++n)e[n]/=t}function Tt(e,t,n){if(typeof e[0][0]!="number"){for(let s of e)Tt(s,t,n);return}let r=n*Math.pow(2,t.z),o=n*t.x,i=n*t.y;for(let s=0;s<e.length;s++){let a=e[s];a[0]=(a[0]+o)*360/r-180;let l=180-(a[1]+i)*360/r;a[1]=360/Math.PI*Math.atan(Math.exp(l*Math.PI/180))-90}}function kn(e,t,n){let{x:r,y:o,z:i}=t,s=n*Math.pow(2,i),a=n*r,l=n*o;for(let c=0,f=e.length;c<f;c+=2){e[c]=(e[c]+a)*360/s-180;let u=180-(e[c+1]+l)*360/s;e[c+1]=360/Math.PI*Math.atan(Math.exp(u*Math.PI/180))-90}}function Nn(e){let t=e.length;if(t<=1)return[e];let n=[],r,o;for(let i=0;i<t;i++){let s=xi(e[i]);s!==0&&(o===void 0&&(o=s<0),o===s<0?(r&&n.push(r),r=[e[i]]):r&&r.push(e[i]))}return r&&n.push(r),n}function Cn(e){let t=e.indices.length,n="Polygon";if(t<=1)return{type:n,data:e.data,areas:[[K(e.data)]],indices:[e.indices]};let r=[],o=[],i=[],s=[],a,l=0;for(let c,f=0,u;f<t;f++){u=e.indices[f]-l,c=e.indices[f+1]-l||e.data.length;let h=e.data.slice(u,c),d=K(h);if(d===0){let p=e.data.slice(0,u),y=e.data.slice(c);e.data=p.concat(y),l+=c-u;continue}a===void 0&&(a=d<0),a===d<0?(s.length&&(r.push(i),o.push(s)),s=[u],i=[d]):(i.push(d),s.push(u))}return i&&r.push(i),s.length&&o.push(s),{type:n,areas:r,indices:o,data:e.data}}var Y=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;constructor(t,n,r,o,i,s){this.properties={},this.extent=r,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=o,this._values=i,this._geometryInfo=s,t.readFields(wi,this,n)}toGeoJSONFeature(t,n){let r=this.loadGeometry();switch(t){case"wgs84":return On(this,r,o=>Tt(o,n,this.extent));default:return On(this,r,vt)}}toBinaryFeature(t,n){let r=this.loadFlatGeometry();switch(t){case"wgs84":return this._toBinaryCoordinates(r,o=>kn(o,n,this.extent));default:return this._toBinaryCoordinates(r,Un)}}bbox(){let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,r=1,o=0,i=0,s=0,a=1/0,l=-1/0,c=1/0,f=-1/0;for(;t.pos<n;){if(o<=0){let u=t.readVarint();r=u&7,o=u>>3}if(o--,r===1||r===2)i+=t.readSVarint(),s+=t.readSVarint(),i<a&&(a=i),i>l&&(l=i),s<c&&(c=s),s>f&&(f=s);else if(r!==7)throw new Error(`unknown command ${r}`)}return[a,c,l,f]}_toBinaryCoordinates(t,n){let r;n(t.data,this.extent);let o=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=t.indices.length,r={type:"Point",...t};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=t.indices.length,this._geometryInfo.linePositionsCount+=t.data.length/o,r={type:"LineString",...t};break;case 3:r=Cn(t),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=r.indices.length;for(let s of r.indices)this._geometryInfo.polygonRingsCount+=s.length;this._geometryInfo.polygonPositionsCount+=r.data.length/o;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let i={type:"Feature",geometry:r,properties:this.properties};return this.id!==null&&(i.id=this.id),i}loadGeometry(){let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,r=1,o=0,i=0,s=0,a=[],l;for(;t.pos<n;){if(o<=0){let c=t.readVarint();r=c&7,o=c>>3}switch(o--,r){case 1:case 2:i+=t.readSVarint(),s+=t.readSVarint(),r===1&&(l&&a.push(l),l=[]),l&&l.push([i,s]);break;case 7:l&&l.push(l[0].slice());break;default:throw new Error(`unknown command ${r}`)}}return l&&a.push(l),a}loadFlatGeometry(){let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,r=1,o,i=0,s=0,a=0,l=0,c=[],f=[];for(;t.pos<n;)if(i<=0&&(o=t.readVarint(),r=o&7,i=o>>3),i--,r===1||r===2)s+=t.readSVarint(),a+=t.readSVarint(),r===1&&c.push(l),f.push(s,a),l+=2;else if(r===7){if(l>0){let u=c[c.length-1];f.push(f[u],f[u+1]),l+=2}}else throw new Error(`unknown command ${r}`);return{data:f,indices:c}}};Rt(Y,"types",["Unknown","Point","LineString","Polygon"]);function On(e,t,n){let r=Y.types[e.type],o,i,s;switch(e.type){case 1:let l=[];for(o=0;o<t.length;o++)l[o]=t[o][0];s=l,n(s,e.extent);break;case 2:for(s=t,o=0;o<s.length;o++)n(s[o],e.extent);break;case 3:for(s=Nn(t),o=0;o<s.length;o++)for(i=0;i<s[o].length;i++)n(s[o][i],e.extent);break;default:throw new Error("illegal vector tile type")}s.length===1?s=s[0]:r=`Multi${r}`;let a={type:"Feature",geometry:{type:r,coordinates:s},properties:e.properties};return e.id!==null&&(a.properties||={},a.properties.id=e.id),a}function wi(e,t,n){t&&n&&(e===1?t.id=n.readVarint():e===2?vi(n,t):e===3?t.type=n.readVarint():e===4&&(t._geometry=n.pos))}function vi(e,t){let n=e.readVarint()+e.pos;for(;e.pos<n;){let r=t._keys[e.readVarint()],o=t._values[e.readVarint()];t.properties[r]=o}}var He=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(t,n){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Ti,this,n),this.length=this._features.length}getGeoJSONFeature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];let n=this._pbf.readVarint()+this._pbf.pos;return new Y(this._pbf,n,this.extent,this._keys,this._values)}getBinaryFeature(t,n){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];let r=this._pbf.readVarint()+this._pbf.pos;return new Y(this._pbf,r,this.extent,this._keys,this._values,n)}};function Ti(e,t,n){t&&n&&(e===15?t.version=n.readVarint():e===1?t.name=n.readString():e===5?t.extent=n.readVarint():e===2?t._features.push(n.pos):e===3?t._keys.push(n.readString()):e===4&&t._values.push(Ii(n)))}function Ii(e){let t=null,n=e.readVarint()+e.pos;for(;e.pos<n;){let r=e.readVarint()>>3;t=r===1?e.readString():r===2?e.readFloat():r===3?e.readDouble():r===4?e.readVarint64():r===5?e.readVarint():r===6?e.readSVarint():r===7?e.readBoolean():null}return t}var Te=class{layers;constructor(t,n){this.layers=t.readFields(Pi,{},n)}};function Pi(e,t,n){if(e===3&&n){let r=new He(n,n.readVarint()+n.pos);r.length&&t&&(t[r.name]=r)}}function Ft(e,t){let n=bi(t),r=t?.gis?.format||t?.mvt?.shape||t?.shape;switch(r){case"columnar-table":return{shape:"columnar-table",data:It(e,n)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:Gn(e,n)};case"geojson":return Gn(e,n);case"binary-geometry":return It(e,n);case"binary":return It(e,n);default:throw new Error(r||"undefined shape")}}function It(e,t){let[n,r]=Fi(e,t),o=mt(n,r);return o.byteLength=e.byteLength,o}function Fi(e,t){let n=[],r={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(e.byteLength<=0)return[n,r];let o=new Te(new Pt.default(e));return(t&&Array.isArray(t.layers)?t.layers:Object.keys(o.layers)).forEach(s=>{let a=o.layers[s];if(a)for(let l=0;l<a.length;l++){let c=a.getBinaryFeature(l,r),f=Ei(c,t,s);n.push(f)}}),[n,r]}function Gn(e,t){if(e.byteLength<=0)return[];let n=[],r=new Te(new Pt.default(e));return(Array.isArray(t.layers)?t.layers:Object.keys(r.layers)).forEach(i=>{let s=r.layers[i];if(s)for(let a=0;a<s.length;a++){let l=s.getGeoJSONFeature(a),c=Si(l,t,i);n.push(c)}}),n}function bi(e){if(!e?.mvt)throw new Error("mvt options required");if(e.mvt?.coordinates==="wgs84"&&!e.mvt.tileIndex)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");return e.gis&&ot.warn('MVTLoader: "options.gis" is deprecated, use "options.mvt.shape" instead')(),e.mvt}function Si(e,t,n){let r=e.toGeoJSONFeature(t.coordinates||"local",t.tileIndex);return t.layerProperty&&(r.properties||={},r.properties[t.layerProperty]=n),r}function Ei(e,t,n){let r=e.toBinaryFeature(t.coordinates||"local",t.tileIndex);return t.layerProperty&&r.properties&&(r.properties[t.layerProperty]=n),r}var _i="4.3.0-alpha.2",zn={dataType:null,batchType:null,name:"Mapbox Vector Tile",id:"mvt",module:"mvt",version:_i,extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],worker:!0,category:"geometry",options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:void 0}}},bt={...zn,parse:async(e,t)=>Ft(e,t),parseSync:Ft,binary:!0};var be={};zt(be,{Compression:()=>or,EtagMismatch:()=>We,FetchSource:()=>ar,FileSource:()=>ls,PMTiles:()=>At,Protocol:()=>ns,ResolvedValueCache:()=>fs,SharedPromiseCache:()=>hr,TileType:()=>ir,bytesToHeader:()=>lr,findTile:()=>sr,getUint64:()=>V,leafletRasterLayer:()=>es,readVarint:()=>ae,tileIdToZxy:()=>ss,zxyToTileId:()=>rr});var X=Math.pow,F=(e,t,n)=>new Promise((r,o)=>{var i=l=>{try{a(n.next(l))}catch(c){o(c)}},s=l=>{try{a(n.throw(l))}catch(c){o(c)}},a=l=>l.done?r(l.value):Promise.resolve(l.value).then(i,s);a((n=n.apply(e,t)).next())}),E=Uint8Array,le=Uint16Array,Bi=Int32Array,Hn=new E([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Zn=new E([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ai=new E([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Wn=function(e,t){for(var n=new le(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var o=new Bi(n[30]),r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)o[i]=i-n[r]<<5|r;return{b:n,r:o}},Jn=Wn(Hn,2),Kn=Jn.b,Di=Jn.r;Kn[28]=258,Di[258]=28;var $n=Wn(Zn,0),Li=$n.b,sc=$n.r,_t=new le(32768);for(w=0;w<32768;++w)R=(w&43690)>>1|(w&21845)<<1,R=(R&52428)>>2|(R&13107)<<2,R=(R&61680)>>4|(R&3855)<<4,_t[w]=((R&65280)>>8|(R&255)<<8)>>1;var R,w,Pe=function(e,t,n){for(var r=e.length,o=0,i=new le(t);o<r;++o)e[o]&&++i[e[o]-1];var s=new le(t);for(o=1;o<t;++o)s[o]=s[o-1]+i[o-1]<<1;var a;if(n){a=new le(1<<t);var l=15-t;for(o=0;o<r;++o)if(e[o])for(var c=o<<4|e[o],f=t-e[o],u=s[e[o]-1]++<<f,h=u|(1<<f)-1;u<=h;++u)a[_t[u]>>l]=c}else for(a=new le(r),o=0;o<r;++o)e[o]&&(a[o]=_t[s[e[o]-1]++]>>15-e[o]);return a},Fe=new E(288);for(w=0;w<144;++w)Fe[w]=8;var w;for(w=144;w<256;++w)Fe[w]=9;var w;for(w=256;w<280;++w)Fe[w]=7;var w;for(w=280;w<288;++w)Fe[w]=8;var w,Yn=new E(32);for(w=0;w<32;++w)Yn[w]=5;var w,Vi=Pe(Fe,9,1),Mi=Pe(Yn,5,1),St=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},C=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Et=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Ui=function(e){return(e+7)/8|0},ki=function(e,t,n){(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length);var r=new E(n-t);return r.set(e.subarray(t,n)),r},Ni=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],S=function(e,t,n){var r=new Error(t||Ni[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,S),!n)throw r;return r},Dt=function(e,t,n,r){var o=e.length,i=r?r.length:0;if(!o||t.f&&!t.l)return n||new E(0);var s=!n||t.i!=2,a=t.i;n||(n=new E(o*3));var l=function(Ct){var Ot=n.length;if(Ct>Ot){var Gt=new E(Math.max(Ot*2,Ct));Gt.set(n),n=Gt}},c=t.f||0,f=t.p||0,u=t.b||0,h=t.l,d=t.d,p=t.m,y=t.n,P=o*8;do{if(!h){c=C(e,f,1);var M=C(e,f+1,3);if(f+=3,M)if(M==1)h=Vi,d=Mi,p=9,y=5;else if(M==2){var _=C(e,f,31)+257,O=C(e,f+10,15)+4,U=_+C(e,f+5,31)+1;f+=14;for(var b=new E(U),B=new E(19),A=0;A<O;++A)B[Ai[A]]=C(e,f+A*3,7);f+=O*3;for(var Vt=St(B),gr=(1<<Vt)-1,mr=Pe(B,Vt,1),A=0;A<U;){var Mt=mr[C(e,f,gr)];f+=Mt&15;var v=Mt>>4;if(v<16)b[A++]=v;else{var Q=0,Be=0;for(v==16?(Be=3+C(e,f,3),f+=2,Q=b[A-1]):v==17?(Be=3+C(e,f,7),f+=3):v==18&&(Be=11+C(e,f,127),f+=7);Be--;)b[A++]=Q}}var Ut=b.subarray(0,_),k=b.subarray(_);p=St(Ut),y=St(k),h=Pe(Ut,p,1),d=Pe(k,y,1)}else S(1);else{var v=Ui(f)+4,m=e[v-4]|e[v-3]<<8,g=v+m;if(g>o){a&&S(0);break}s&&l(u+m),n.set(e.subarray(v,g),u),t.b=u+=m,t.p=f=g*8,t.f=c;continue}if(f>P){a&&S(0);break}}s&&l(u+131072);for(var yr=(1<<p)-1,xr=(1<<y)-1,Ke=f;;Ke=f){var Q=h[Et(e,f)&yr],q=Q>>4;if(f+=Q&15,f>P){a&&S(0);break}if(Q||S(2),q<256)n[u++]=q;else if(q==256){Ke=f,h=null;break}else{var kt=q-254;if(q>264){var A=q-257,ce=Hn[A];kt=C(e,f,(1<<ce)-1)+Kn[A],f+=ce}var $e=d[Et(e,f)&xr],Ye=$e>>4;$e||S(3),f+=$e&15;var k=Li[Ye];if(Ye>3){var ce=Zn[Ye];k+=Et(e,f)&(1<<ce)-1,f+=ce}if(f>P){a&&S(0);break}s&&l(u+131072);var Xe=u+kt;if(u<k){var Nt=i-k,wr=Math.min(k,Xe);for(Nt+u<0&&S(3);u<wr;++u)n[u]=r[Nt+u]}for(;u<Xe;u+=4)n[u]=n[u-k],n[u+1]=n[u+1-k],n[u+2]=n[u+2-k],n[u+3]=n[u+3-k];u=Xe}}t.l=h,t.p=Ke,t.b=u,t.f=c,h&&(c=1,t.m=p,t.d=d,t.n=y)}while(!c);return u==n.length?n:ki(n,0,u)},Ci=new E(0),Oi=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&S(6,"invalid gzip data");var t=e[3],n=10;t&4&&(n+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(t&2)},Gi=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},zi=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&S(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&S(6,"invalid zlib data: "+(e[1]&32?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function ji(e,t){return Dt(e,{i:2},t&&t.out,t&&t.dictionary)}function Ri(e,t){var n=Oi(e);return n+8>e.length&&S(6,"invalid gzip data"),Dt(e.subarray(n,-8),{i:2},t&&t.out||new E(Gi(e)),t&&t.dictionary)}function Hi(e,t){return Dt(e.subarray(zi(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}function Bt(e,t){return e[0]==31&&e[1]==139&&e[2]==8?Ri(e,t):(e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31?ji(e,t):Hi(e,t)}var Zi=typeof TextDecoder<"u"&&new TextDecoder,Wi=0;try{Zi.decode(Ci,{stream:!0}),Wi=1}catch{}var Xn=(e,t)=>e*X(2,t),Ie=(e,t)=>Math.floor(e/X(2,t)),Ze=(e,t)=>Xn(e.getUint16(t+1,!0),8)+e.getUint8(t),Qn=(e,t)=>Xn(e.getUint32(t+2,!0),16)+e.getUint16(t,!0),Ji=(e,t,n,r,o)=>{if(e!==r.getUint8(o))return e-r.getUint8(o);let i=Ze(r,o+1);if(t!==i)return t-i;let s=Ze(r,o+4);return n!==s?n-s:0},Ki=(e,t,n,r)=>{let o=qn(e,t|128,n,r);return o?{z:t,x:n,y:r,offset:o[0],length:o[1],isDir:!0}:null},jn=(e,t,n,r)=>{let o=qn(e,t,n,r);return o?{z:t,x:n,y:r,offset:o[0],length:o[1],isDir:!1}:null},qn=(e,t,n,r)=>{let o=0,i=e.byteLength/17-1;for(;o<=i;){let s=i+o>>1,a=Ji(t,n,r,e,s*17);if(a>0)o=s+1;else if(a<0)i=s-1;else return[Qn(e,s*17+7),e.getUint32(s*17+13,!0)]}return null},$i=(e,t)=>e.isDir&&!t.isDir?1:!e.isDir&&t.isDir?-1:e.z!==t.z?e.z-t.z:e.x!==t.x?e.x-t.x:e.y-t.y,er=(e,t)=>{let n=e.getUint8(t*17);return{z:n&127,x:Ze(e,t*17+1),y:Ze(e,t*17+4),offset:Qn(e,t*17+7),length:e.getUint32(t*17+13,!0),isDir:n>>7===1}},Rn=e=>{let t=[],n=new DataView(e);for(let r=0;r<n.byteLength/17;r++)t.push(er(n,r));return Yi(t)},Yi=e=>{e.sort($i);let t=new ArrayBuffer(17*e.length),n=new Uint8Array(t);for(let r=0;r<e.length;r++){let o=e[r],i=o.z;o.isDir&&(i=i|128),n[r*17]=i,n[r*17+1]=o.x&255,n[r*17+2]=o.x>>8&255,n[r*17+3]=o.x>>16&255,n[r*17+4]=o.y&255,n[r*17+5]=o.y>>8&255,n[r*17+6]=o.y>>16&255,n[r*17+7]=o.offset&255,n[r*17+8]=Ie(o.offset,8)&255,n[r*17+9]=Ie(o.offset,16)&255,n[r*17+10]=Ie(o.offset,24)&255,n[r*17+11]=Ie(o.offset,32)&255,n[r*17+12]=Ie(o.offset,48)&255,n[r*17+13]=o.length&255,n[r*17+14]=o.length>>8&255,n[r*17+15]=o.length>>16&255,n[r*17+16]=o.length>>24&255}return t},Xi=(e,t)=>{if(e.byteLength<17)return null;let n=e.byteLength/17,r=er(e,n-1);if(r.isDir){let o=r.z,i=t.z-o,s=Math.trunc(t.x/(1<<i)),a=Math.trunc(t.y/(1<<i));return{z:o,x:s,y:a}}return null};function Qi(e){return F(this,null,function*(){let t=yield e.getBytes(0,512e3),n=new DataView(t.data),r=n.getUint32(4,!0),o=n.getUint16(8,!0),i=new TextDecoder("utf-8"),s=JSON.parse(i.decode(new DataView(t.data,10,r))),a=0;s.compression==="gzip"&&(a=2);let l=0;"minzoom"in s&&(l=+s.minzoom);let c=0;"maxzoom"in s&&(c=+s.maxzoom);let f=0,u=0,h=0,d=-180,p=-85,y=180,P=85;if(s.bounds){let v=s.bounds.split(",");d=+v[0],p=+v[1],y=+v[2],P=+v[3]}if(s.center){let v=s.center.split(",");f=+v[0],u=+v[1],h=+v[2]}return{specVersion:n.getUint16(2,!0),rootDirectoryOffset:10+r,rootDirectoryLength:o*17,jsonMetadataOffset:10,jsonMetadataLength:r,leafDirectoryOffset:0,leafDirectoryLength:void 0,tileDataOffset:0,tileDataLength:void 0,numAddressedTiles:0,numTileEntries:0,numTileContents:0,clustered:!1,internalCompression:1,tileCompression:a,tileType:1,minZoom:l,maxZoom:c,minLon:d,minLat:p,maxLon:y,maxLat:P,centerZoom:h,centerLon:f,centerLat:u,etag:t.etag}})}function qi(e,t,n,r,o,i,s){return F(this,null,function*(){let a=yield n.getArrayBuffer(t,e.rootDirectoryOffset,e.rootDirectoryLength,e);e.specVersion===1&&(a=Rn(a));let l=jn(new DataView(a),r,o,i);if(l){let u=(yield t.getBytes(l.offset,l.length,s)).data,h=new DataView(u);return h.getUint8(0)===31&&h.getUint8(1)===139&&(u=Bt(new Uint8Array(u))),{data:u}}let c=Xi(new DataView(a),{z:r,x:o,y:i});if(c){let f=Ki(new DataView(a),c.z,c.x,c.y);if(f){let u=yield n.getArrayBuffer(t,f.offset,f.length,e);e.specVersion===1&&(u=Rn(u));let h=jn(new DataView(u),r,o,i);if(h){let p=(yield t.getBytes(h.offset,h.length,s)).data,y=new DataView(p);return y.getUint8(0)===31&&y.getUint8(1)===139&&(p=Bt(new Uint8Array(p))),{data:p}}}}})}var tr={getHeader:Qi,getZxy:qi},es=(e,t)=>{let n=!1,r="",o=L.GridLayer.extend({createTile:(i,s)=>{let a=document.createElement("img"),l=new AbortController,c=l.signal;return a.cancel=()=>{l.abort()},n||(e.getHeader().then(f=>{f.tileType===1?console.error("Error: archive contains MVT vector tiles, but leafletRasterLayer is for displaying raster tiles. See https://github.com/protomaps/PMTiles/tree/main/js for details."):f.tileType===2?r="image/png":f.tileType===3?r="image/jpeg":f.tileType===4?r="image/webp":f.tileType===5&&(r="image/avif")}),n=!0),e.getZxy(i.z,i.x,i.y,c).then(f=>{if(f){let u=new Blob([f.data],{type:r}),h=window.URL.createObjectURL(u);a.src=h,a.cancel=void 0,s(void 0,a)}}).catch(f=>{if(f.name!=="AbortError")throw f}),a},_removeTile:function(i){let s=this._tiles[i];s&&(s.el.cancel&&s.el.cancel(),s.el.width=0,s.el.height=0,s.el.deleted=!0,L.DomUtil.remove(s.el),delete this._tiles[i],this.fire("tileunload",{tile:s.el,coords:this._keyToTileCoords(i)}))}});return new o(t)},ts=e=>(t,n)=>{if(n instanceof AbortController)return e(t,n);let r=new AbortController;return e(t,r).then(o=>n(void 0,o.data,o.cacheControl||"",o.expires||""),o=>n(o)).catch(o=>n(o)),{cancel:()=>r.abort()}},ns=class{constructor(){this.tilev4=(e,t)=>F(this,null,function*(){if(e.type==="json"){let u=e.url.substr(10),h=this.tiles.get(u);h||(h=new At(u),this.tiles.set(u,h));let d=yield h.getHeader();return{data:{tiles:[`${e.url}/{z}/{x}/{y}`],minzoom:d.minZoom,maxzoom:d.maxZoom,bounds:[d.minLon,d.minLat,d.maxLon,d.maxLat]}}}let n=new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/),r=e.url.match(n);if(!r)throw new Error("Invalid PMTiles protocol URL");let o=r[1],i=this.tiles.get(o);i||(i=new At(o),this.tiles.set(o,i));let s=r[2],a=r[3],l=r[4],c=yield i.getHeader(),f=yield i?.getZxy(+s,+a,+l,t.signal);return f?{data:new Uint8Array(f.data),cacheControl:f.cacheControl,expires:f.expires}:c.tileType===1?{data:new Uint8Array}:{data:null}}),this.tile=ts(this.tilev4),this.tiles=new Map}add(e){this.tiles.set(e.source.getKey(),e)}get(e){return this.tiles.get(e)}};function se(e,t){return(t>>>0)*4294967296+(e>>>0)}function rs(e,t){let n=t.buf,r=n[t.pos++],o=(r&112)>>4;if(r<128||(r=n[t.pos++],o|=(r&127)<<3,r<128)||(r=n[t.pos++],o|=(r&127)<<10,r<128)||(r=n[t.pos++],o|=(r&127)<<17,r<128)||(r=n[t.pos++],o|=(r&127)<<24,r<128)||(r=n[t.pos++],o|=(r&1)<<31,r<128))return se(e,o);throw new Error("Expected varint not more than 10 bytes")}function ae(e){let t=e.buf,n=t[e.pos++],r=n&127;return n<128||(n=t[e.pos++],r|=(n&127)<<7,n<128)||(n=t[e.pos++],r|=(n&127)<<14,n<128)||(n=t[e.pos++],r|=(n&127)<<21,n<128)?r:(n=t[e.pos],r|=(n&15)<<28,rs(r,e))}function nr(e,t,n,r){if(r===0){n===1&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);let o=t[0];t[0]=t[1],t[1]=o}}function os(e,t){let n=X(2,e),r=t,o=t,i=t,s=[0,0],a=1;for(;a<n;)r=1&i/2,o=1&(i^r),nr(a,s,r,o),s[0]+=a*r,s[1]+=a*o,i=i/4,a*=2;return[e,s[0],s[1]]}var is=[0,1,5,21,85,341,1365,5461,21845,87381,349525,1398101,5592405,22369621,89478485,357913941,1431655765,5726623061,22906492245,91625968981,366503875925,1466015503701,5864062014805,23456248059221,93824992236885,375299968947541,0x5555555555555];function rr(e,t,n){if(e>26)throw Error("Tile zoom level exceeds max safe number limit (26)");if(t>X(2,e)-1||n>X(2,e)-1)throw Error("tile x/y outside zoom level bounds");let r=is[e],o=X(2,e),i=0,s=0,a=0,l=[t,n],c=o/2;for(;c>0;)i=(l[0]&c)>0?1:0,s=(l[1]&c)>0?1:0,a+=c*c*(3*i^s),nr(c,l,i,s),c=c/2;return r+a}function ss(e){let t=0,n=0;for(let r=0;r<27;r++){let o=(1<<r)*(1<<r);if(t+o>e)return os(r,e-t);t+=o}throw Error("Tile zoom level exceeds max safe number limit (26)")}var or=(e=>(e[e.Unknown=0]="Unknown",e[e.None=1]="None",e[e.Gzip=2]="Gzip",e[e.Brotli=3]="Brotli",e[e.Zstd=4]="Zstd",e))(or||{});function Lt(e,t){return F(this,null,function*(){if(t===1||t===0)return e;if(t===2){if(typeof globalThis.DecompressionStream>"u")return Bt(new Uint8Array(e));let n=new Response(e).body;if(!n)throw Error("Failed to read response stream");let r=n.pipeThrough(new globalThis.DecompressionStream("gzip"));return new Response(r).arrayBuffer()}throw Error("Compression method not supported")})}var ir=(e=>(e[e.Unknown=0]="Unknown",e[e.Mvt=1]="Mvt",e[e.Png=2]="Png",e[e.Jpeg=3]="Jpeg",e[e.Webp=4]="Webp",e[e.Avif=5]="Avif",e))(ir||{}),as=127;function sr(e,t){let n=0,r=e.length-1;for(;n<=r;){let o=r+n>>1,i=t-e[o].tileId;if(i>0)n=o+1;else if(i<0)r=o-1;else return e[o]}return r>=0&&(e[r].runLength===0||t-e[r].tileId<e[r].runLength)?e[r]:null}var ls=class{constructor(e){this.file=e}getKey(){return this.file.name}getBytes(e,t){return F(this,null,function*(){return{data:yield this.file.slice(e,e+t).arrayBuffer()}})}},ar=class{constructor(e,t=new Headers){this.url=e,this.customHeaders=t,this.mustReload=!1}getKey(){return this.url}setHeaders(e){this.customHeaders=e}getBytes(e,t,n,r){return F(this,null,function*(){let o,i;n?i=n:(o=new AbortController,i=o.signal);let s=new Headers(this.customHeaders);s.set("range",`bytes=${e}-${e+t-1}`);let a;this.mustReload&&(a="reload");let l=yield fetch(this.url,{signal:i,cache:a,headers:s});if(e===0&&l.status===416){let h=l.headers.get("Content-Range");if(!h||!h.startsWith("bytes */"))throw Error("Missing content-length on 416 response");let d=+h.substr(8);l=yield fetch(this.url,{signal:i,cache:"reload",headers:{range:`bytes=0-${d-1}`}})}let c=l.headers.get("Etag");if(c?.startsWith("W/")&&(c=null),l.status===416||r&&c&&c!==r)throw this.mustReload=!0,new We(r);if(l.status>=300)throw Error(`Bad response code: ${l.status}`);let f=l.headers.get("Content-Length");if(l.status===200&&(!f||+f>t))throw o&&o.abort(),Error("Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.");return{data:yield l.arrayBuffer(),etag:c||void 0,cacheControl:l.headers.get("Cache-Control")||void 0,expires:l.headers.get("Expires")||void 0}})}};function V(e,t){let n=e.getUint32(t+4,!0),r=e.getUint32(t+0,!0);return n*X(2,32)+r}function lr(e,t){let n=new DataView(e),r=n.getUint8(7);if(r>3)throw Error(`Archive is spec version ${r} but this library supports up to spec version 3`);return{specVersion:r,rootDirectoryOffset:V(n,8),rootDirectoryLength:V(n,16),jsonMetadataOffset:V(n,24),jsonMetadataLength:V(n,32),leafDirectoryOffset:V(n,40),leafDirectoryLength:V(n,48),tileDataOffset:V(n,56),tileDataLength:V(n,64),numAddressedTiles:V(n,72),numTileEntries:V(n,80),numTileContents:V(n,88),clustered:n.getUint8(96)===1,internalCompression:n.getUint8(97),tileCompression:n.getUint8(98),tileType:n.getUint8(99),minZoom:n.getUint8(100),maxZoom:n.getUint8(101),minLon:n.getInt32(102,!0)/1e7,minLat:n.getInt32(106,!0)/1e7,maxLon:n.getInt32(110,!0)/1e7,maxLat:n.getInt32(114,!0)/1e7,centerZoom:n.getUint8(118),centerLon:n.getInt32(119,!0)/1e7,centerLat:n.getInt32(123,!0)/1e7,etag:t}}function cr(e){let t={buf:new Uint8Array(e),pos:0},n=ae(t),r=[],o=0;for(let i=0;i<n;i++){let s=ae(t);r.push({tileId:o+s,offset:0,length:0,runLength:1}),o+=s}for(let i=0;i<n;i++)r[i].runLength=ae(t);for(let i=0;i<n;i++)r[i].length=ae(t);for(let i=0;i<n;i++){let s=ae(t);s===0&&i>0?r[i].offset=r[i-1].offset+r[i-1].length:r[i].offset=s-1}return r}function cs(e){let t=new DataView(e);return t.getUint16(2,!0)===2?(console.warn("PMTiles spec version 2 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade"),2):t.getUint16(2,!0)===1?(console.warn("PMTiles spec version 1 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade"),1):3}var We=class extends Error{};function fr(e,t){return F(this,null,function*(){let n=yield e.getBytes(0,16384);if(new DataView(n.data).getUint16(0,!0)!==19792)throw new Error("Wrong magic number for PMTiles archive");if(cs(n.data)<3)return[yield tr.getHeader(e)];let o=n.data.slice(0,as),i=lr(o,n.etag),s=n.data.slice(i.rootDirectoryOffset,i.rootDirectoryOffset+i.rootDirectoryLength),a=`${e.getKey()}|${i.etag||""}|${i.rootDirectoryOffset}|${i.rootDirectoryLength}`,l=cr(yield t(s,i.internalCompression));return[i,[a,l.length,l]]})}function ur(e,t,n,r,o){return F(this,null,function*(){let i=yield e.getBytes(n,r,void 0,o.etag),s=yield t(i.data,o.internalCompression),a=cr(s);if(a.length===0)throw new Error("Empty directory is invalid");return a})}var fs=class{constructor(e=100,t=!0,n=Lt){this.cache=new Map,this.maxCacheEntries=e,this.counter=1,this.decompress=n}getHeader(e){return F(this,null,function*(){let t=e.getKey(),n=this.cache.get(t);if(n)return n.lastUsed=this.counter++,n.data;let r=yield fr(e,this.decompress);return r[1]&&this.cache.set(r[1][0],{lastUsed:this.counter++,data:r[1][2]}),this.cache.set(t,{lastUsed:this.counter++,data:r[0]}),this.prune(),r[0]})}getDirectory(e,t,n,r){return F(this,null,function*(){let o=`${e.getKey()}|${r.etag||""}|${t}|${n}`,i=this.cache.get(o);if(i)return i.lastUsed=this.counter++,i.data;let s=yield ur(e,this.decompress,t,n,r);return this.cache.set(o,{lastUsed:this.counter++,data:s}),this.prune(),s})}getArrayBuffer(e,t,n,r){return F(this,null,function*(){let o=`${e.getKey()}|${r.etag||""}|${t}|${n}`,i=this.cache.get(o);if(i)return i.lastUsed=this.counter++,yield i.data;let s=yield e.getBytes(t,n,void 0,r.etag);return this.cache.set(o,{lastUsed:this.counter++,data:s.data}),this.prune(),s.data})}prune(){if(this.cache.size>this.maxCacheEntries){let e=1/0,t;this.cache.forEach((n,r)=>{n.lastUsed<e&&(e=n.lastUsed,t=r)}),t&&this.cache.delete(t)}}invalidate(e){return F(this,null,function*(){this.cache.delete(e.getKey())})}},hr=class{constructor(e=100,t=!0,n=Lt){this.cache=new Map,this.invalidations=new Map,this.maxCacheEntries=e,this.counter=1,this.decompress=n}getHeader(e){return F(this,null,function*(){let t=e.getKey(),n=this.cache.get(t);if(n)return n.lastUsed=this.counter++,yield n.data;let r=new Promise((o,i)=>{fr(e,this.decompress).then(s=>{s[1]&&this.cache.set(s[1][0],{lastUsed:this.counter++,data:Promise.resolve(s[1][2])}),o(s[0]),this.prune()}).catch(s=>{i(s)})});return this.cache.set(t,{lastUsed:this.counter++,data:r}),r})}getDirectory(e,t,n,r){return F(this,null,function*(){let o=`${e.getKey()}|${r.etag||""}|${t}|${n}`,i=this.cache.get(o);if(i)return i.lastUsed=this.counter++,yield i.data;let s=new Promise((a,l)=>{ur(e,this.decompress,t,n,r).then(c=>{a(c),this.prune()}).catch(c=>{l(c)})});return this.cache.set(o,{lastUsed:this.counter++,data:s}),s})}getArrayBuffer(e,t,n,r){return F(this,null,function*(){let o=`${e.getKey()}|${r.etag||""}|${t}|${n}`,i=this.cache.get(o);if(i)return i.lastUsed=this.counter++,yield i.data;let s=new Promise((a,l)=>{e.getBytes(t,n,void 0,r.etag).then(c=>{a(c.data),this.cache.has(o),this.prune()}).catch(c=>{l(c)})});return this.cache.set(o,{lastUsed:this.counter++,data:s}),s})}prune(){if(this.cache.size>=this.maxCacheEntries){let e=1/0,t;this.cache.forEach((n,r)=>{n.lastUsed<e&&(e=n.lastUsed,t=r)}),t&&this.cache.delete(t)}}invalidate(e){return F(this,null,function*(){let t=e.getKey();if(this.invalidations.get(t))return yield this.invalidations.get(t);this.cache.delete(e.getKey());let n=new Promise((r,o)=>{this.getHeader(e).then(i=>{r(),this.invalidations.delete(t)}).catch(i=>{o(i)})});this.invalidations.set(t,n)})}},At=class{constructor(e,t,n){typeof e=="string"?this.source=new ar(e):this.source=e,n?this.decompress=n:this.decompress=Lt,t?this.cache=t:this.cache=new hr}getHeader(){return F(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(e,t,n,r){return F(this,null,function*(){let o=rr(e,t,n),i=yield this.cache.getHeader(this.source);if(i.specVersion<3)return tr.getZxy(i,this.source,this.cache,e,t,n,r);if(e<i.minZoom||e>i.maxZoom)return;let s=i.rootDirectoryOffset,a=i.rootDirectoryLength;for(let l=0;l<=3;l++){let c=yield this.cache.getDirectory(this.source,s,a,i),f=sr(c,o);if(f){if(f.runLength>0){let u=yield this.source.getBytes(i.tileDataOffset+f.offset,f.length,r,i.etag);return{data:yield this.decompress(u.data,i.tileCompression),cacheControl:u.cacheControl,expires:u.expires}}s=i.leafDirectoryOffset+f.offset,a=f.length}else return}throw Error("Maximum directory depth exceeded")})}getZxy(e,t,n,r){return F(this,null,function*(){try{return yield this.getZxyAttempt(e,t,n,r)}catch(o){if(o instanceof We)return this.cache.invalidate(this.source),yield this.getZxyAttempt(e,t,n,r);throw o}})}getMetadataAttempt(){return F(this,null,function*(){let e=yield this.cache.getHeader(this.source),t=yield this.source.getBytes(e.jsonMetadataOffset,e.jsonMetadataLength,void 0,e.etag),n=yield this.decompress(t.data,e.internalCompression),r=new TextDecoder("utf-8");return JSON.parse(r.decode(n))})}getMetadata(){return F(this,null,function*(){try{return yield this.getMetadataAttempt()}catch(e){if(e instanceof We)return this.cache.invalidate(this.source),yield this.getMetadataAttempt();throw e}})}};var{TileType:Se}=be;function dr(e,t,n,r){let o=t,i=null;if(o)try{let l=JSON.stringify(o);i=ge.parseTextSync?.(l,r)||null}catch(l){console.warn("PMTiles metadata could not be interpreted as TileJSON",l)}let s={};typeof i?.name=="string"&&(s.name=i.name),typeof i?.htmlAttribution=="string"&&(s.attributions=[i.htmlAttribution]);let a={...s,format:"pmtiles",formatVersion:e.specVersion,attributions:[],tileMIMEType:us(e.tileType),minZoom:e.minZoom,maxZoom:e.maxZoom,boundingBox:[[e.minLon,e.minLat],[e.maxLon,e.maxLat]],center:[e.centerLon,e.centerLat],centerZoom:e.centerZoom,etag:e.etag};return i&&(a.tilejson=i),n?.includeFormatHeader&&(a.formatHeader=e,a.formatMetadata=a),a}function us(e){switch(e){case Se.Mvt:return"application/vnd.mapbox-vector-tile";case Se.Png:return"image/png";case Se.Jpeg:return"image/jpeg";case Se.Webp:return"image/webp";case Se.Avif:return"image/avif";default:return"application/octet-stream"}}var Je=class{blob;key;constructor(t,n){this.blob=t,this.key=n}getKey(){return this.blob.url||""}async getBytes(t,n,r){return{data:await this.blob.slice(t,t+n).arrayBuffer()}}};var{PMTiles:hs}=be,ds="1.0.0",pr={name:"PMTiles",id:"pmtiles",module:"pmtiles",version:ds,extensions:["pmtiles"],mimeTypes:["application/octet-stream"],options:{url:void 0,pmtiles:{}},type:"pmtiles",fromUrl:!0,fromBlob:!0,testURL:e=>e.endsWith(".pmtiles"),createDataSource:(e,t)=>new Ee(e,t)},Ee=class extends he{data;props;mimeType=null;pmtiles;metadata;constructor(t,n){super(n),this.props=n;let r=typeof t=="string"?it(t):new Je(t,"pmtiles");this.data=n.url,this.pmtiles=new hs(r),this.getTileData=this.getTileData.bind(this),this.metadata=this.getMetadata()}async getSchema(){return{fields:[],metadata:{}}}async getMetadata(){let t=await this.pmtiles.getHeader(),n=await this.pmtiles.getMetadata(),r=dr(t,n,{includeFormatHeader:!1},this.loadOptions);return this.props.attributions&&(r.attributions=[...this.props.attributions,...r.attributions||[]]),r?.tileMIMEType&&(this.mimeType=r?.tileMIMEType),r}async getTile(t){let{x:n,y:r,z:o}=t,s=(await this.pmtiles.getZxy(o,n,r))?.data;return s||null}async getTileData(t){let{x:n,y:r,z:o}=t.index;switch((await this.metadata).tileMIMEType){case"application/vnd.mapbox-vector-tile":return await this.getVectorTile({x:n,y:r,z:o,layers:[]});default:return await this.getImageTile({x:n,y:r,z:o,layers:[]})}}async getImageTile(t){let n=await this.getTile(t);return n?await ft.parse(n,this.loadOptions):null}async getVectorTile(t){let n=await this.getTile(t),r={shape:"geojson-table",mvt:{coordinates:"wgs84",tileIndex:{x:t.x,y:t.y,z:t.z},...this.loadOptions?.mvt},...this.loadOptions};return n?await bt.parse(n,r):null}};return Sr(_e);})();
|
|
8
8
|
/*! Bundled license information:
|
|
9
9
|
|
|
10
10
|
ieee754/index.js:
|
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// dist/index.js
|
|
31
31
|
var dist_exports = {};
|
|
32
32
|
__export(dist_exports, {
|
|
33
|
-
PMTilesSource: () => PMTilesSource
|
|
33
|
+
PMTilesSource: () => PMTilesSource,
|
|
34
|
+
PMTilesTileSource: () => PMTilesTileSource
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(dist_exports);
|
|
36
37
|
|
|
@@ -131,16 +132,31 @@ var BlobSource = class {
|
|
|
131
132
|
|
|
132
133
|
// dist/pmtiles-source.js
|
|
133
134
|
var { PMTiles } = pmtiles2;
|
|
134
|
-
var
|
|
135
|
+
var VERSION = "1.0.0";
|
|
136
|
+
var PMTilesSource = {
|
|
137
|
+
name: "PMTiles",
|
|
138
|
+
id: "pmtiles",
|
|
139
|
+
module: "pmtiles",
|
|
140
|
+
version: VERSION,
|
|
141
|
+
extensions: ["pmtiles"],
|
|
142
|
+
mimeTypes: ["application/octet-stream"],
|
|
143
|
+
options: { url: void 0, pmtiles: {} },
|
|
144
|
+
type: "pmtiles",
|
|
145
|
+
fromUrl: true,
|
|
146
|
+
fromBlob: true,
|
|
147
|
+
testURL: (url) => url.endsWith(".pmtiles"),
|
|
148
|
+
createDataSource: (url, props) => new PMTilesTileSource(url, props)
|
|
149
|
+
};
|
|
150
|
+
var PMTilesTileSource = class extends import_loader_utils.DataSource {
|
|
135
151
|
data;
|
|
136
152
|
props;
|
|
137
153
|
mimeType = null;
|
|
138
154
|
pmtiles;
|
|
139
155
|
metadata;
|
|
140
|
-
constructor(props) {
|
|
156
|
+
constructor(data, props) {
|
|
141
157
|
super(props);
|
|
142
158
|
this.props = props;
|
|
143
|
-
const url = typeof
|
|
159
|
+
const url = typeof data === "string" ? (0, import_loader_utils.resolvePath)(data) : new BlobSource(data, "pmtiles");
|
|
144
160
|
this.data = props.url;
|
|
145
161
|
this.pmtiles = new PMTiles(url);
|
|
146
162
|
this.getTileData = this.getTileData.bind(this);
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.js", "pmtiles-source.js", "lib/parse-pmtiles.js", "lib/blob-source.js"],
|
|
4
|
-
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { PMTilesSource } from \"./pmtiles-source.js\";\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { DataSource, resolvePath } from '@loaders.gl/loader-utils';\nimport { ImageLoader } from '@loaders.gl/images';\nimport { MVTLoader } from '@loaders.gl/mvt';\nimport * as pmtiles from 'pmtiles';\nconst { PMTiles } = pmtiles;\nimport { parsePMTilesHeader } from \"./lib/parse-pmtiles.js\";\nimport { BlobSource } from \"./lib/blob-source.js\";\nconst VERSION = '1.0.0';\nexport const
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,0BAAwC;AACxC,oBAA4B;AAC5B,IAAAA,cAA0B;AAC1B,IAAAC,WAAyB;;;ACHzB,iBAA+B;AAE/B,cAAyB;AACzB,IAAM,EAAE,SAAS,IAAI;AASd,SAAS,mBAAmB,QAAQ,YAAY,SAAS,aAAa;AAf7E;AAgBI,QAAM,kBAAkB;AAIxB,MAAI,WAAW;AACf,MAAI,iBAAiB;AACjB,QAAI;AACA,YAAM,SAAS,KAAK,UAAU,eAAe;AAC7C,mBAAW,sCAAe,kBAAf,4BAA+B,QAAQ,iBAAgB;AAAA,IACtE,SACO,OAAP;AAEI,cAAQ,KAAK,yDAAyD,KAAK;AAAA,IAC/E;AAAA,EACJ;AACA,QAAM,kBAAkB,CAAC;AACzB,MAAI,QAAO,qCAAU,UAAS,UAAU;AACpC,oBAAgB,OAAO,SAAS;AAAA,EACpC;AACA,MAAI,QAAO,qCAAU,qBAAoB,UAAU;AAC/C,oBAAgB,eAAe,CAAC,SAAS,eAAe;AAAA,EAC5D;AACA,QAAM,WAAW;AAAA,IACb,GAAG;AAAA,IACH,QAAQ;AAAA,IACR,eAAe,OAAO;AAAA,IACtB,cAAc,CAAC;AAAA,IACf,cAAc,eAAe,OAAO,QAAQ;AAAA,IAC5C,SAAS,OAAO;AAAA,IAChB,SAAS,OAAO;AAAA,IAChB,aAAa;AAAA,MACT,CAAC,OAAO,QAAQ,OAAO,MAAM;AAAA,MAC7B,CAAC,OAAO,QAAQ,OAAO,MAAM;AAAA,IACjC;AAAA,IACA,QAAQ,CAAC,OAAO,WAAW,OAAO,SAAS;AAAA,IAC3C,YAAY,OAAO;AAAA,IACnB,MAAM,OAAO;AAAA,EACjB;AACA,MAAI,UAAU;AACV,aAAS,WAAW;AAAA,EACxB;AAEA,MAAI,mCAAS,qBAAqB;AAC9B,aAAS,eAAe;AACxB,aAAS,iBAAiB;AAAA,EAC9B;AACA,SAAO;AACX;AAEA,SAAS,eAAe,UAAU;AAC9B,UAAQ,UAAU;AAAA,IACd,KAAK,SAAS;AACV,aAAO;AAAA,IACX,KAAK,SAAS;AACV,aAAO;AAAA,IACX,KAAK,SAAS;AACV,aAAO;AAAA,IACX,KAAK,SAAS;AACV,aAAO;AAAA,IACX,KAAK,SAAS;AACV,aAAO;AAAA,IACX;AACI,aAAO;AAAA,EACf;AACJ;;;ACxEO,IAAM,aAAN,MAAiB;AAAA,EACpB;AAAA,EACA;AAAA,EACA,YAAY,MAAM,KAAK;AACnB,SAAK,OAAO;AACZ,SAAK,MAAM;AAAA,EACf;AAAA;AAAA,EAEA,SAAS;AAEL,WAAO,KAAK,KAAK,OAAO;AAAA,EAC5B;AAAA,EACA,MAAM,SAAS,QAAQ,QAAQ,QAAQ;AACnC,UAAM,QAAQ,KAAK,KAAK,MAAM,QAAQ,SAAS,MAAM;AACrD,UAAM,OAAO,MAAM,MAAM,YAAY;AACrC,WAAO;AAAA,MACH;AAAA;AAAA;AAAA;AAAA,IAIJ;AAAA,EACJ;AACJ;;;AFvBA,IAAM,EAAE,QAAQ,IAAIC;
|
|
4
|
+
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { PMTilesSource } from \"./pmtiles-source.js\";\nexport { PMTilesTileSource } from \"./pmtiles-source.js\";\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { DataSource, resolvePath } from '@loaders.gl/loader-utils';\nimport { ImageLoader } from '@loaders.gl/images';\nimport { MVTLoader } from '@loaders.gl/mvt';\nimport * as pmtiles from 'pmtiles';\nconst { PMTiles } = pmtiles;\nimport { parsePMTilesHeader } from \"./lib/parse-pmtiles.js\";\nimport { BlobSource } from \"./lib/blob-source.js\";\nconst VERSION = '1.0.0';\n/**\n * Creates vector tile data sources for PMTiles urls or blobs\n */\nexport const PMTilesSource = {\n name: 'PMTiles',\n id: 'pmtiles',\n module: 'pmtiles',\n version: VERSION,\n extensions: ['pmtiles'],\n mimeTypes: ['application/octet-stream'],\n options: { url: undefined, pmtiles: {} },\n type: 'pmtiles',\n fromUrl: true,\n fromBlob: true,\n testURL: (url) => url.endsWith('.pmtiles'),\n createDataSource: (url, props) => new PMTilesTileSource(url, props)\n};\n/**\n * A PMTiles data source\n * @note Can be either a raster or vector tile source depending on the contents of the PMTiles file.\n */\nexport class PMTilesTileSource extends DataSource {\n data;\n props;\n mimeType = null;\n pmtiles;\n metadata;\n constructor(data, props) {\n super(props);\n this.props = props;\n const url = typeof data === 'string' ? resolvePath(data) : new BlobSource(data, 'pmtiles');\n this.data = props.url;\n this.pmtiles = new PMTiles(url);\n this.getTileData = this.getTileData.bind(this);\n this.metadata = this.getMetadata();\n }\n async getSchema() {\n return { fields: [], metadata: {} };\n }\n async getMetadata() {\n const pmtilesHeader = await this.pmtiles.getHeader();\n const pmtilesMetadata = await this.pmtiles.getMetadata();\n const metadata = parsePMTilesHeader(pmtilesHeader, pmtilesMetadata, { includeFormatHeader: false }, this.loadOptions);\n // Add additional attribution if necessary\n if (this.props.attributions) {\n metadata.attributions = [...this.props.attributions, ...(metadata.attributions || [])];\n }\n if (metadata?.tileMIMEType) {\n this.mimeType = metadata?.tileMIMEType;\n }\n // TODO - do we need to allow tileSize to be overridden? Some PMTiles examples seem to suggest it.\n return metadata;\n }\n async getTile(tileParams) {\n const { x, y, z } = tileParams;\n const rangeResponse = await this.pmtiles.getZxy(z, x, y);\n const arrayBuffer = rangeResponse?.data;\n if (!arrayBuffer) {\n // console.error('No arrayBuffer', tileParams);\n return null;\n }\n return arrayBuffer;\n }\n // Tile Source interface implementation: deck.gl compatible API\n // TODO - currently only handles image tiles, not vector tiles\n async getTileData(tileParams) {\n const { x, y, z } = tileParams.index;\n const metadata = await this.metadata;\n switch (metadata.tileMIMEType) {\n case 'application/vnd.mapbox-vector-tile':\n return await this.getVectorTile({ x, y, z, layers: [] });\n default:\n return await this.getImageTile({ x, y, z, layers: [] });\n }\n }\n // ImageTileSource interface implementation\n async getImageTile(tileParams) {\n const arrayBuffer = await this.getTile(tileParams);\n return arrayBuffer ? await ImageLoader.parse(arrayBuffer, this.loadOptions) : null;\n }\n // VectorTileSource interface implementation\n async getVectorTile(tileParams) {\n const arrayBuffer = await this.getTile(tileParams);\n const loadOptions = {\n shape: 'geojson-table',\n mvt: {\n coordinates: 'wgs84',\n tileIndex: { x: tileParams.x, y: tileParams.y, z: tileParams.z },\n ...this.loadOptions?.mvt\n },\n ...this.loadOptions\n };\n return arrayBuffer ? await MVTLoader.parse(arrayBuffer, loadOptions) : null;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { TileJSONLoader } from '@loaders.gl/mvt';\n// import {Source, PMTiles, Header, TileType} from 'pmtiles';\nimport * as pmtiles from 'pmtiles';\nconst { TileType } = pmtiles;\n/**\n * Parse PMTiles metdata from a PMTiles file\n * @param header\n * @param tilejsonMetadata\n * @param options\n * @param loadOptions\n * @returns\n */\nexport function parsePMTilesHeader(header, pmmetadata, options, loadOptions) {\n const pmtilesMetadata = pmmetadata;\n // Ironically, to use the TileJSON loader we need to stringify the metadata again.\n // This is the price of integrating with the existing pmtiles library.\n // TODO - provide a non-standard TileJSONLoader parsers that accepts a JSON object?\n let tilejson = null;\n if (pmtilesMetadata) {\n try {\n const string = JSON.stringify(pmtilesMetadata);\n tilejson = TileJSONLoader.parseTextSync?.(string, loadOptions) || null;\n }\n catch (error) {\n // eslint-disable-next-line no-console\n console.warn('PMTiles metadata could not be interpreted as TileJSON', error);\n }\n }\n const partialMetadata = {};\n if (typeof tilejson?.name === 'string') {\n partialMetadata.name = tilejson.name;\n }\n if (typeof tilejson?.htmlAttribution === 'string') {\n partialMetadata.attributions = [tilejson.htmlAttribution];\n }\n const metadata = {\n ...partialMetadata,\n format: 'pmtiles',\n formatVersion: header.specVersion,\n attributions: [],\n tileMIMEType: decodeTileType(header.tileType),\n minZoom: header.minZoom,\n maxZoom: header.maxZoom,\n boundingBox: [\n [header.minLon, header.minLat],\n [header.maxLon, header.maxLat]\n ],\n center: [header.centerLon, header.centerLat],\n centerZoom: header.centerZoom,\n etag: header.etag\n };\n if (tilejson) {\n metadata.tilejson = tilejson;\n }\n // Application can optionally include the raw header and metadata.\n if (options?.includeFormatHeader) {\n metadata.formatHeader = header;\n metadata.formatMetadata = metadata;\n }\n return metadata;\n}\n/** Extract a MIME type for tiles from vector tile header */\nfunction decodeTileType(tileType) {\n switch (tileType) {\n case TileType.Mvt:\n return 'application/vnd.mapbox-vector-tile';\n case TileType.Png:\n return 'image/png';\n case TileType.Jpeg:\n return 'image/jpeg';\n case TileType.Webp:\n return 'image/webp';\n case TileType.Avif:\n return 'image/avif';\n default:\n return 'application/octet-stream';\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/**\n * A PMTiles library compatible source that reads from blobs\n * @deprecated TODO - reimplement as ReadableFileSource\n * Use loaders.gl HTTP range requests instead\n */\nexport class BlobSource {\n blob;\n key;\n constructor(blob, key) {\n this.blob = blob;\n this.key = key;\n }\n // TODO - how is this used?\n getKey() {\n // @ts-expect-error url is only defined on File subclass\n return this.blob.url || '';\n }\n async getBytes(offset, length, signal) {\n const slice = this.blob.slice(offset, offset + length);\n const data = await slice.arrayBuffer();\n return {\n data\n // etag: response.headers.get('ETag') || undefined,\n // cacheControl: response.headers.get('Cache-Control') || undefined,\n // expires: response.headers.get('Expires') || undefined\n };\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,0BAAwC;AACxC,oBAA4B;AAC5B,IAAAA,cAA0B;AAC1B,IAAAC,WAAyB;;;ACHzB,iBAA+B;AAE/B,cAAyB;AACzB,IAAM,EAAE,SAAS,IAAI;AASd,SAAS,mBAAmB,QAAQ,YAAY,SAAS,aAAa;AAf7E;AAgBI,QAAM,kBAAkB;AAIxB,MAAI,WAAW;AACf,MAAI,iBAAiB;AACjB,QAAI;AACA,YAAM,SAAS,KAAK,UAAU,eAAe;AAC7C,mBAAW,sCAAe,kBAAf,4BAA+B,QAAQ,iBAAgB;AAAA,IACtE,SACO,OAAP;AAEI,cAAQ,KAAK,yDAAyD,KAAK;AAAA,IAC/E;AAAA,EACJ;AACA,QAAM,kBAAkB,CAAC;AACzB,MAAI,QAAO,qCAAU,UAAS,UAAU;AACpC,oBAAgB,OAAO,SAAS;AAAA,EACpC;AACA,MAAI,QAAO,qCAAU,qBAAoB,UAAU;AAC/C,oBAAgB,eAAe,CAAC,SAAS,eAAe;AAAA,EAC5D;AACA,QAAM,WAAW;AAAA,IACb,GAAG;AAAA,IACH,QAAQ;AAAA,IACR,eAAe,OAAO;AAAA,IACtB,cAAc,CAAC;AAAA,IACf,cAAc,eAAe,OAAO,QAAQ;AAAA,IAC5C,SAAS,OAAO;AAAA,IAChB,SAAS,OAAO;AAAA,IAChB,aAAa;AAAA,MACT,CAAC,OAAO,QAAQ,OAAO,MAAM;AAAA,MAC7B,CAAC,OAAO,QAAQ,OAAO,MAAM;AAAA,IACjC;AAAA,IACA,QAAQ,CAAC,OAAO,WAAW,OAAO,SAAS;AAAA,IAC3C,YAAY,OAAO;AAAA,IACnB,MAAM,OAAO;AAAA,EACjB;AACA,MAAI,UAAU;AACV,aAAS,WAAW;AAAA,EACxB;AAEA,MAAI,mCAAS,qBAAqB;AAC9B,aAAS,eAAe;AACxB,aAAS,iBAAiB;AAAA,EAC9B;AACA,SAAO;AACX;AAEA,SAAS,eAAe,UAAU;AAC9B,UAAQ,UAAU;AAAA,IACd,KAAK,SAAS;AACV,aAAO;AAAA,IACX,KAAK,SAAS;AACV,aAAO;AAAA,IACX,KAAK,SAAS;AACV,aAAO;AAAA,IACX,KAAK,SAAS;AACV,aAAO;AAAA,IACX,KAAK,SAAS;AACV,aAAO;AAAA,IACX;AACI,aAAO;AAAA,EACf;AACJ;;;ACxEO,IAAM,aAAN,MAAiB;AAAA,EACpB;AAAA,EACA;AAAA,EACA,YAAY,MAAM,KAAK;AACnB,SAAK,OAAO;AACZ,SAAK,MAAM;AAAA,EACf;AAAA;AAAA,EAEA,SAAS;AAEL,WAAO,KAAK,KAAK,OAAO;AAAA,EAC5B;AAAA,EACA,MAAM,SAAS,QAAQ,QAAQ,QAAQ;AACnC,UAAM,QAAQ,KAAK,KAAK,MAAM,QAAQ,SAAS,MAAM;AACrD,UAAM,OAAO,MAAM,MAAM,YAAY;AACrC,WAAO;AAAA,MACH;AAAA;AAAA;AAAA;AAAA,IAIJ;AAAA,EACJ;AACJ;;;AFvBA,IAAM,EAAE,QAAQ,IAAIC;AAGpB,IAAM,UAAU;AAIT,IAAM,gBAAgB;AAAA,EACzB,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,YAAY,CAAC,SAAS;AAAA,EACtB,WAAW,CAAC,0BAA0B;AAAA,EACtC,SAAS,EAAE,KAAK,QAAW,SAAS,CAAC,EAAE;AAAA,EACvC,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU;AAAA,EACV,SAAS,CAAC,QAAQ,IAAI,SAAS,UAAU;AAAA,EACzC,kBAAkB,CAAC,KAAK,UAAU,IAAI,kBAAkB,KAAK,KAAK;AACtE;AAKO,IAAM,oBAAN,cAAgC,+BAAW;AAAA,EAC9C;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA,YAAY,MAAM,OAAO;AACrB,UAAM,KAAK;AACX,SAAK,QAAQ;AACb,UAAM,MAAM,OAAO,SAAS,eAAW,iCAAY,IAAI,IAAI,IAAI,WAAW,MAAM,SAAS;AACzF,SAAK,OAAO,MAAM;AAClB,SAAK,UAAU,IAAI,QAAQ,GAAG;AAC9B,SAAK,cAAc,KAAK,YAAY,KAAK,IAAI;AAC7C,SAAK,WAAW,KAAK,YAAY;AAAA,EACrC;AAAA,EACA,MAAM,YAAY;AACd,WAAO,EAAE,QAAQ,CAAC,GAAG,UAAU,CAAC,EAAE;AAAA,EACtC;AAAA,EACA,MAAM,cAAc;AAChB,UAAM,gBAAgB,MAAM,KAAK,QAAQ,UAAU;AACnD,UAAM,kBAAkB,MAAM,KAAK,QAAQ,YAAY;AACvD,UAAM,WAAW,mBAAmB,eAAe,iBAAiB,EAAE,qBAAqB,MAAM,GAAG,KAAK,WAAW;AAEpH,QAAI,KAAK,MAAM,cAAc;AACzB,eAAS,eAAe,CAAC,GAAG,KAAK,MAAM,cAAc,GAAI,SAAS,gBAAgB,CAAC,CAAE;AAAA,IACzF;AACA,QAAI,qCAAU,cAAc;AACxB,WAAK,WAAW,qCAAU;AAAA,IAC9B;AAEA,WAAO;AAAA,EACX;AAAA,EACA,MAAM,QAAQ,YAAY;AACtB,UAAM,EAAE,GAAG,GAAG,EAAE,IAAI;AACpB,UAAM,gBAAgB,MAAM,KAAK,QAAQ,OAAO,GAAG,GAAG,CAAC;AACvD,UAAM,cAAc,+CAAe;AACnC,QAAI,CAAC,aAAa;AAEd,aAAO;AAAA,IACX;AACA,WAAO;AAAA,EACX;AAAA;AAAA;AAAA,EAGA,MAAM,YAAY,YAAY;AAC1B,UAAM,EAAE,GAAG,GAAG,EAAE,IAAI,WAAW;AAC/B,UAAM,WAAW,MAAM,KAAK;AAC5B,YAAQ,SAAS,cAAc;AAAA,MAC3B,KAAK;AACD,eAAO,MAAM,KAAK,cAAc,EAAE,GAAG,GAAG,GAAG,QAAQ,CAAC,EAAE,CAAC;AAAA,MAC3D;AACI,eAAO,MAAM,KAAK,aAAa,EAAE,GAAG,GAAG,GAAG,QAAQ,CAAC,EAAE,CAAC;AAAA,IAC9D;AAAA,EACJ;AAAA;AAAA,EAEA,MAAM,aAAa,YAAY;AAC3B,UAAM,cAAc,MAAM,KAAK,QAAQ,UAAU;AACjD,WAAO,cAAc,MAAM,0BAAY,MAAM,aAAa,KAAK,WAAW,IAAI;AAAA,EAClF;AAAA;AAAA,EAEA,MAAM,cAAc,YAAY;AA5FpC;AA6FQ,UAAM,cAAc,MAAM,KAAK,QAAQ,UAAU;AACjD,UAAM,cAAc;AAAA,MAChB,OAAO;AAAA,MACP,KAAK;AAAA,QACD,aAAa;AAAA,QACb,WAAW,EAAE,GAAG,WAAW,GAAG,GAAG,WAAW,GAAG,GAAG,WAAW,EAAE;AAAA,QAC/D,IAAG,UAAK,gBAAL,mBAAkB;AAAA,MACzB;AAAA,MACA,GAAG,KAAK;AAAA,IACZ;AACA,WAAO,cAAc,MAAM,sBAAU,MAAM,aAAa,WAAW,IAAI;AAAA,EAC3E;AACJ;",
|
|
6
6
|
"names": ["import_mvt", "pmtiles", "pmtiles"]
|
|
7
7
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export type { PMTilesMetadata } from "./lib/parse-pmtiles.js";
|
|
2
|
-
export type { PMTilesSourceProps } from "./pmtiles-source.js";
|
|
3
1
|
export { PMTilesSource } from "./pmtiles-source.js";
|
|
2
|
+
export type { PMTilesMetadata } from "./lib/parse-pmtiles.js";
|
|
3
|
+
export type { PMTilesTileSourceProps } from "./pmtiles-source.js";
|
|
4
|
+
export { PMTilesTileSource } from "./pmtiles-source.js";
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,YAAY,EAAC,eAAe,EAAC,+BAA4B;AACzD,YAAY,EAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,aAAa,EAAC,4BAAyB;AAE/C,YAAY,EAAC,eAAe,EAAC,+BAA4B;AACzD,YAAY,EAAC,sBAAsB,EAAC,4BAAyB;AAC7D,OAAO,EAAC,iBAAiB,EAAC,4BAAyB"}
|
package/dist/index.js
CHANGED
package/dist/pmtiles-source.d.ts
CHANGED
|
@@ -1,43 +1,49 @@
|
|
|
1
1
|
import type { Schema } from '@loaders.gl/schema';
|
|
2
|
-
import type { GetTileParameters, GetTileDataParameters } from '@loaders.gl/loader-utils';
|
|
3
|
-
import type {
|
|
4
|
-
import
|
|
5
|
-
import { DataSource } from '@loaders.gl/loader-utils';
|
|
2
|
+
import type { VectorTileSource, GetTileParameters, GetTileDataParameters } from '@loaders.gl/loader-utils';
|
|
3
|
+
import type { ImageTileSource, ImageType } from '@loaders.gl/loader-utils';
|
|
4
|
+
import { DataSource, DataSourceProps } from '@loaders.gl/loader-utils';
|
|
6
5
|
import { ImageLoaderOptions } from '@loaders.gl/images';
|
|
7
6
|
import { MVTLoaderOptions, TileJSONLoaderOptions } from '@loaders.gl/mvt';
|
|
8
7
|
import * as pmtiles from 'pmtiles';
|
|
9
8
|
import type { PMTilesMetadata } from "./lib/parse-pmtiles.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Creates vector tile data sources for PMTiles urls or blobs
|
|
11
|
+
*/
|
|
12
|
+
export declare const PMTilesSource: {
|
|
13
|
+
readonly name: "PMTiles";
|
|
14
|
+
readonly id: "pmtiles";
|
|
15
|
+
readonly module: "pmtiles";
|
|
16
|
+
readonly version: "1.0.0";
|
|
17
|
+
readonly extensions: ["pmtiles"];
|
|
18
|
+
readonly mimeTypes: ["application/octet-stream"];
|
|
19
|
+
readonly options: {
|
|
20
|
+
readonly url: never;
|
|
21
|
+
readonly pmtiles: {};
|
|
22
|
+
};
|
|
23
|
+
readonly type: "pmtiles";
|
|
24
|
+
readonly fromUrl: true;
|
|
25
|
+
readonly fromBlob: true;
|
|
26
|
+
readonly testURL: (url: string) => boolean;
|
|
27
|
+
readonly createDataSource: (url: string | Blob, props: PMTilesTileSourceProps) => PMTilesTileSource;
|
|
23
28
|
};
|
|
24
|
-
export
|
|
25
|
-
export type PMTilesSourceProps = DataSourceProps & {
|
|
29
|
+
export type PMTilesTileSourceProps = DataSourceProps & {
|
|
26
30
|
url: string | Blob;
|
|
27
31
|
attributions?: string[];
|
|
28
|
-
|
|
32
|
+
pmtiles?: {
|
|
33
|
+
loadOptions?: TileJSONLoaderOptions & MVTLoaderOptions & ImageLoaderOptions;
|
|
34
|
+
};
|
|
29
35
|
};
|
|
30
36
|
/**
|
|
31
37
|
* A PMTiles data source
|
|
32
38
|
* @note Can be either a raster or vector tile source depending on the contents of the PMTiles file.
|
|
33
39
|
*/
|
|
34
|
-
export declare class
|
|
40
|
+
export declare class PMTilesTileSource extends DataSource implements ImageTileSource, VectorTileSource {
|
|
35
41
|
data: string | Blob;
|
|
36
|
-
props:
|
|
42
|
+
props: PMTilesTileSourceProps;
|
|
37
43
|
mimeType: string | null;
|
|
38
44
|
pmtiles: pmtiles.PMTiles;
|
|
39
45
|
metadata: Promise<PMTilesMetadata>;
|
|
40
|
-
constructor(props:
|
|
46
|
+
constructor(data: string | Blob, props: PMTilesTileSourceProps);
|
|
41
47
|
getSchema(): Promise<Schema>;
|
|
42
48
|
getMetadata(): Promise<PMTilesMetadata>;
|
|
43
49
|
getTile(tileParams: GetTileParameters): Promise<ArrayBuffer | null>;
|