@loaders.gl/pmtiles 4.4.0-alpha.16 → 4.4.0-alpha.18

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.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 Bn=Object.create;var le=Object.defineProperty;var Sn=Object.getOwnPropertyDescriptor;var _n=Object.getOwnPropertyNames;var En=Object.getPrototypeOf,An=Object.prototype.hasOwnProperty;var Dn=(e,t,r)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var et=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Rt=(e,t)=>{for(var r in t)le(e,r,{get:t[r],enumerable:!0})},_e=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _n(t))!An.call(e,o)&&o!==r&&le(e,o,{get:()=>t[o],enumerable:!(n=Sn(t,o))||n.enumerable});return e},Ee=(e,t,r)=>(_e(e,t,"default"),r&&_e(r,t,"default")),Ht=(e,t,r)=>(r=e!=null?Bn(En(e)):{},_e(t||!e||!e.__esModule?le(r,"default",{value:e,enumerable:!0}):r,e)),Ln=e=>_e(le({},"__esModule",{value:!0}),e);var Ae=(e,t,r)=>(Dn(e,typeof t!="symbol"?t+"":t,r),r);var Zt=et((vs,Wt)=>{Wt.exports=globalThis.loaders});var Er=et(wt=>{wt.read=function(e,t,r,n,o){var i,s,a=o*8-n-1,l=(1<<a)-1,c=l>>1,f=-7,u=r?o-1:0,h=r?-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+=n;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,n),i=i-c}return(d?-1:1)*s*Math.pow(2,i-n)};wt.write=function(e,t,r,n,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=n?0:i-1,p=n?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[r+d]=a&255,d+=p,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[r+d]=s&255,d+=p,s/=256,c-=8);e[r+d-p]|=y*128}});var Cr=et((Ol,Vr)=>{"use strict";Vr.exports=x;var Re=Er();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 vt=(1<<16)*(1<<16),Ar=1/vt,si=12,Mr=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");x.prototype={destroy:function(){this.buf=null},readFields:function(e,t,r){for(r=r||this.length;this.pos<r;){var n=this.readVarint(),o=n>>3,i=this.pos;this.type=n&7,e(o,t,this),this.pos===i&&this.skip(n)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=He(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Lr(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=He(this.buf,this.pos)+He(this.buf,this.pos+4)*vt;return this.pos+=8,e},readSFixed64:function(){var e=He(this.buf,this.pos)+Lr(this.buf,this.pos+4)*vt;return this.pos+=8,e},readFloat:function(){var e=Re.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=Re.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t=this.buf,r,n;return n=t[this.pos++],r=n&127,n<128||(n=t[this.pos++],r|=(n&127)<<7,n<128)||(n=t[this.pos++],r|=(n&127)<<14,n<128)||(n=t[this.pos++],r|=(n&127)<<21,n<128)?r:(n=t[this.pos],r|=(n&15)<<28,ai(r,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>=si&&Mr?Ti(this.buf,t,e):vi(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 r=O(this);for(e=e||[];this.pos<r;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==x.Bytes)return e.push(this.readSVarint());var t=O(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=O(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=O(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=O(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=O(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=O(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=O(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=O(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 r=new Uint8Array(t);r.set(this.buf),this.buf=r,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),ne(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),ne(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),ne(this.buf,e&-1,this.pos),ne(this.buf,Math.floor(e*Ar),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),ne(this.buf,e&-1,this.pos),ne(this.buf,Math.floor(e*Ar),this.pos+4),this.pos+=8},writeVarint:function(e){if(e=+e||0,e>268435455||e<0){li(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=Fi(this.buf,e,this.pos);var r=this.pos-t;r>=128&&Dr(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r},writeFloat:function(e){this.realloc(4),Re.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),Re.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 r=0;r<t;r++)this.buf[this.pos++]=e[r]},writeRawMessage:function(e,t){this.pos++;var r=this.pos;e(t,this);var n=this.pos-r;n>=128&&Dr(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(e,t,r){this.writeTag(e,x.Bytes),this.writeRawMessage(t,r)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,ui,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,hi,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,gi,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,di,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,pi,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,mi,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,yi,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,xi,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,wi,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 ai(e,t,r){var n=r.buf,o,i;if(i=n[r.pos++],o=(i&112)>>4,i<128||(i=n[r.pos++],o|=(i&127)<<3,i<128)||(i=n[r.pos++],o|=(i&127)<<10,i<128)||(i=n[r.pos++],o|=(i&127)<<17,i<128)||(i=n[r.pos++],o|=(i&127)<<24,i<128)||(i=n[r.pos++],o|=(i&1)<<31,i<128))return re(e,o,t);throw new Error("Expected varint not more than 10 bytes")}function O(e){return e.type===x.Bytes?e.readVarint()+e.pos:e.pos+1}function re(e,t,r){return r?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function li(e,t){var r,n;if(e>=0?(r=e%4294967296|0,n=e/4294967296|0):(r=~(-e%4294967296),n=~(-e/4294967296),r^4294967295?r=r+1|0:(r=0,n=n+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),ci(r,n,t),fi(n,t)}function ci(e,t,r){r.buf[r.pos++]=e&127|128,e>>>=7,r.buf[r.pos++]=e&127|128,e>>>=7,r.buf[r.pos++]=e&127|128,e>>>=7,r.buf[r.pos++]=e&127|128,e>>>=7,r.buf[r.pos]=e&127}function fi(e,t){var r=(e&7)<<4;t.buf[t.pos++]|=r|((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 Dr(e,t,r){var n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));r.realloc(n);for(var o=r.pos-1;o>=e;o--)r.buf[o+n]=r.buf[o]}function ui(e,t){for(var r=0;r<e.length;r++)t.writeVarint(e[r])}function hi(e,t){for(var r=0;r<e.length;r++)t.writeSVarint(e[r])}function di(e,t){for(var r=0;r<e.length;r++)t.writeFloat(e[r])}function pi(e,t){for(var r=0;r<e.length;r++)t.writeDouble(e[r])}function gi(e,t){for(var r=0;r<e.length;r++)t.writeBoolean(e[r])}function mi(e,t){for(var r=0;r<e.length;r++)t.writeFixed32(e[r])}function yi(e,t){for(var r=0;r<e.length;r++)t.writeSFixed32(e[r])}function xi(e,t){for(var r=0;r<e.length;r++)t.writeFixed64(e[r])}function wi(e,t){for(var r=0;r<e.length;r++)t.writeSFixed64(e[r])}function He(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+e[t+3]*16777216}function ne(e,t,r){e[r]=t,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24}function Lr(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function vi(e,t,r){for(var n="",o=t;o<r;){var i=e[o],s=null,a=i>239?4:i>223?3:i>191?2:1;if(o+a>r)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,n+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),n+=String.fromCharCode(s),o+=a}return n}function Ti(e,t,r){return Mr.decode(e.subarray(t,r))}function Fi(e,t,r){for(var n=0,o,i;n<t.length;n++){if(o=t.charCodeAt(n),o>55295&&o<57344)if(i)if(o<56320){e[r++]=239,e[r++]=191,e[r++]=189,i=o;continue}else o=i-55296<<10|o-56320|65536,i=null;else{o>56319||n+1===t.length?(e[r++]=239,e[r++]=191,e[r++]=189):i=o;continue}else i&&(e[r++]=239,e[r++]=191,e[r++]=189,i=null);o<128?e[r++]=o:(o<2048?e[r++]=o>>6|192:(o<65536?e[r++]=o>>12|224:(e[r++]=o>>18|240,e[r++]=o>>12&63|128),e[r++]=o>>6&63|128),e[r++]=o&63|128)}return r}});var Be={};Rt(Be,{PMTilesSource:()=>Vt,PMTilesTileSource:()=>J,_PMTilesLoader:()=>vn});Ee(Be,Ht(Zt(),1));function ce(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var N={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Mn=N.self||N.window||N.global||{},Vn=N.window||N.self||N.global||{},Cn=N.global||N.self||N.window||{},Un=N.document||{};var tt=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var $t=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Nn=$t&&parseFloat($t[1])||0;var De=globalThis,kn=globalThis.document||{},Le=globalThis.process||{},Gn=globalThis.console,Is=globalThis.navigator||{};function Jt(e){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let t=typeof navigator<"u"&&navigator.userAgent,r=e||t;return Boolean(r&&r.indexOf("Electron")>=0)}function z(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Jt()}var rt="4.1.1";function X(e,t){if(!e)throw new Error(t||"Assertion failed")}function nt(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 X(Number.isFinite(t)&&t>=0),t}function Kt(e){let{logLevel:t,message:r}=e;e.logLevel=nt(t);let n=e.args?Array.from(e.args):[];for(;n.length&&n.shift()!==r;);switch(typeof t){case"string":case"function":r!==void 0&&n.unshift(r),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 X(o==="string"||o==="object"),Object.assign(e,{args:n},e.opts)}var R=()=>{},Me=class{constructor({level:t=0}={}){this.userData={},this._onceCache=new Set,this._level=t}set level(t){this.setLevel(t)}get level(){return this.getLevel()}setLevel(t){return this._level=t,this}getLevel(){return this._level}warn(t,...r){return this._log("warn",0,t,r,{once:!0})}error(t,...r){return this._log("error",0,t,r)}log(t,r,...n){return this._log("log",t,r,n)}info(t,r,...n){return this._log("info",t,r,n)}once(t,r,...n){return this._log("once",t,r,n,{once:!0})}_log(t,r,n,o,i={}){let s=Kt({logLevel:r,message:n,args:this._buildArgs(r,n,o),opts:i});return this._createLogFunction(t,s,i)}_buildArgs(t,r,n){return[t,r,...n]}_createLogFunction(t,r,n){if(!this._shouldLog(r.logLevel))return R;let o=this._getOnceTag(n.tag??r.tag??r.message);if((n.once||r.once)&&o!==void 0){if(this._onceCache.has(o))return R;this._onceCache.add(o)}return this._emit(t,r)}_shouldLog(t){return this.getLevel()>=nt(t)}_getOnceTag(t){if(t!==void 0)try{return typeof t=="string"?t:String(t)}catch{return}}};function jn(e){try{let t=window[e],r="__storage_test__";return t.setItem(r,r),t.removeItem(r),t}catch{return null}}var Ve=class{constructor(t,r,n="sessionStorage"){this.storage=jn(n),this.id=t,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){if(Object.assign(this.config,t),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let t={};if(this.storage){let r=this.storage.getItem(this.id);t=r?JSON.parse(r):{}}return Object.assign(this.config,t),this}};function Yt(e){let t;return e<10?t=`${e.toFixed(2)}ms`:e<100?t=`${e.toFixed(1)}ms`:e<1e3?t=`${e.toFixed(0)}ms`:t=`${(e/1e3).toFixed(2)}s`,t}function Xt(e,t=8){let r=Math.max(t-e.length,0);return`${" ".repeat(r)}${e}`}var Ce;(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"})(Ce||(Ce={}));var zn=10;function Qt(e){return typeof e!="string"?e:(e=e.toUpperCase(),Ce[e]||Ce.WHITE)}function qt(e,t,r){return!z&&typeof e=="string"&&(t&&(e=`\x1B[${Qt(t)}m${e}\x1B[39m`),r&&(e=`\x1B[${Qt(r)+zn}m${e}\x1B[49m`)),e}function er(e,t=["constructor"]){let r=Object.getPrototypeOf(e),n=Object.getOwnPropertyNames(r),o=e;for(let i of n){let s=o[i];typeof s=="function"&&(t.find(a=>i===a)||(o[i]=s.bind(e)))}}function Q(){let e;if(z()&&De.performance)e=De?.performance?.now?.();else if("hrtime"in Le){let t=Le?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var q={debug:z()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},ot={enabled:!0,level:0},G=class extends Me{constructor({id:t}={id:""}){super({level:0}),this.VERSION=rt,this._startTs=Q(),this._deltaTs=Q(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=t,this.userData={},this._storage=new Ve(`__probe-${this.id}__`,{[this.id]:ot}),this.timeStamp(`${this.id} started`),er(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Q()-this._startTs).toPrecision(10))}getDelta(){return Number((Q()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(t=!0){return this._updateConfiguration({enabled:t}),this}setLevel(t){return this._updateConfiguration({level:t}),this}get(t){return this._getConfiguration()[t]}set(t,r){this._updateConfiguration({[t]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,r){if(!t)throw new Error(r||"Assertion failed")}warn(t,...r){return this._log("warn",0,t,r,{method:q.warn,once:!0})}error(t,...r){return this._log("error",0,t,r,{method:q.error})}deprecated(t,r){return this.warn(`\`${t}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(t,r){return this.error(`\`${t}\` has been removed. Use \`${r}\` instead`)}probe(t,r,...n){return this._log("log",t,r,n,{method:q.log,time:!0,once:!0})}log(t,r,...n){return this._log("log",t,r,n,{method:q.debug})}info(t,r,...n){return this._log("info",t,r,n,{method:console.info})}once(t,r,...n){return this._log("once",t,r,n,{method:q.debug||q.info,once:!0})}table(t,r,n){return r?this._log("table",t,r,n&&[n]||[],{method:console.table||R,tag:Hn(r)}):R}time(t,r){return this._log("time",t,r,[],{method:console.time?console.time:console.info})}timeEnd(t,r){return this._log("time",t,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(t,r){return this._log("time",t,r,[],{method:console.timeStamp||R})}group(t,r,n={collapsed:!1}){let o=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",t,r,[],{method:o})}groupCollapsed(t,r,n={}){return this.group(t,r,Object.assign({},n,{collapsed:!0}))}groupEnd(t){return this._log("groupEnd",t,"",[],{method:console.groupEnd||R})}withGroup(t,r,n){this.group(t,r)();try{n()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&super._shouldLog(t)}_emit(t,r){let n=r.method;X(n),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Q();let o=Rn(this.id,r.message,r);return n.bind(console,o,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(ot),this._storage.config[this.id]}_updateConfiguration(t){let r=this._storage.config[this.id]||{...ot};this._storage.setConfiguration({[this.id]:{...r,...t}})}};G.VERSION=rt;function Rn(e,t,r){if(typeof t=="string"){let n=r.time?Xt(Yt(r.total)):"";t=r.time?`${e}: ${n} ${t}`:`${e}: ${t}`,t=qt(t,r.color,r.background)}return t}function Hn(e){for(let t in e)for(let r in e[t])return r||"untitled";return"empty"}globalThis.probe={};var qs=new G({id:"@probe.gl/log"});var it="4.4.0-alpha.16",Wn=it[0]>="0"&&it[0]<="9"?`v${it}`:"";function Zn(){let e=new G({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=e,globalThis.loaders.version=Wn,globalThis.probe||={},globalThis.probe.loaders=e,e}var st=Zn();function tr(e,t){return rr(e||{},t)}function rr(e,t,r=0){if(r>3)return t;let n={...e};for(let[o,i]of Object.entries(t))i&&typeof i=="object"&&!Array.isArray(i)?n[o]=rr(n[o]||{},t[o],r+1):n[o]=t[o];return n}var $n="",nr={};function fe(e){for(let t in nr)if(e.startsWith(t)){let r=nr[t];e=e.replace(t,r)}return!e.startsWith("http://")&&!e.startsWith("https://")&&(e=`${$n}${e}`),e}var ue=class{handle;size;bigsize;url;constructor(t){this.handle=t instanceof ArrayBuffer?new Blob([t]):t,this.size=t instanceof ArrayBuffer?t.byteLength:t.size,this.bigsize=BigInt(this.size),this.url=t instanceof File?t.name:""}async close(){}async stat(){return{size:this.handle.size,bigsize:BigInt(this.handle.size),isDirectory:!1}}async read(t,r){return await this.handle.slice(Number(t),Number(t)+Number(r)).arrayBuffer()}};var at=class{optionsType;options;data;url;loadOptions;fetch;_needsRefresh=!0;constructor(t,r,n){n?this.options=tr({...n,core:at.defaultOptions},r):this.options={...r},this.data=t,this.url=typeof t=="string"?fe(t):"",this.loadOptions={...this.options.core?.loadOptions},this.fetch=Jn(this.loadOptions)}setProps(t){this.options=Object.assign(this.options,t),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(t=!0){let r=this._needsRefresh;return t&&(this._needsRefresh=!1),r}},ee=at;Ae(ee,"defaultOptions",{core:{type:"auto",attributions:[],loadOptions:{},loaders:[]}});function Jn(e){let t=e?.core?.fetch;if(t&&typeof t=="function")return(n,o)=>t(n,o);let r=e?.fetch;return r&&typeof r!="function"?n=>fetch(n,r):n=>fetch(n)}var or="4.4.0-alpha.16";var Kn=globalThis.loaders?.parseImageNode,lt=typeof Image<"u",ct=typeof ImageBitmap<"u",Yn=Boolean(Kn),ft=tt?!0:Yn;function ir(e){switch(e){case"auto":return ct||lt||ft;case"imagebitmap":return ct;case"image":return lt;case"data":return ft;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function sr(){if(ct)return"imagebitmap";if(lt)return"image";if(ft)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function Xn(e){let t=Qn(e);if(!t)throw new Error("Not an image");return t}function ar(e){switch(Xn(e)){case"data":return e;case"image":case"imagebitmap":let t=document.createElement("canvas"),r=t.getContext("2d");if(!r)throw new Error("getImageData");return t.width=e.width,t.height=e.height,r.drawImage(e,0,0),r.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}function Qn(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 qn=/^data:image\/svg\+xml/,eo=/\.svg((\?|#).*)?$/;function Ue(e){return e&&(qn.test(e)||eo.test(e))}function lr(e,t){if(Ue(t)){let n=new TextDecoder().decode(e);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(n=unescape(encodeURIComponent(n)))}catch(i){throw new Error(i.message)}return`data:image/svg+xml;base64,${btoa(n)}`}return ut(e,t)}function ut(e,t){if(Ue(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function Ne(e,t,r){let n=lr(e,r),o=self.URL||self.webkitURL,i=typeof n!="string"&&o.createObjectURL(n);try{return await to(i||n,t)}finally{i&&o.revokeObjectURL(i)}}async function to(e,t){let r=new Image;return r.src=e,t.image&&t.image.decode&&r.decode?(await r.decode(),r):await new Promise((n,o)=>{try{r.onload=()=>n(r),r.onerror=i=>{let s=i instanceof Error?i.message:"error";o(new Error(s))}}catch(i){o(i)}})}var cr=!0;async function fr(e,t,r){let n;Ue(r)?n=await Ne(e,t,r):n=ut(e,r);let o=t&&t.imagebitmap;return await ro(n,o)}async function ro(e,t=null){if((no(t)||!cr)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(r){console.warn(r),cr=!1}return await createImageBitmap(e)}function no(e){if(!e)return!0;for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function ur(e){return!ao(e,"ftyp",4)||!(e[8]&96)?null:oo(e)}function oo(e){switch(io(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function io(e,t,r){return String.fromCharCode(...e.slice(t,r))}function so(e){return[...e].map(t=>t.charCodeAt(0))}function ao(e,t,r=0){let n=so(t);for(let o=0;o<n.length;++o)if(n[o]!==e[o+r])return!1;return!0}var k=!1,he=!0;function ke(e){let t=de(e);return co(t)||ho(t)||fo(t)||uo(t)||lo(t)}function lo(e){let t=new Uint8Array(e instanceof DataView?e.buffer:e),r=ur(t);return r?{mimeType:r.mimeType,width:0,height:0}:null}function co(e){let t=de(e);return t.byteLength>=24&&t.getUint32(0,k)===2303741511?{mimeType:"image/png",width:t.getUint32(16,k),height:t.getUint32(20,k)}:null}function fo(e){let t=de(e);return t.byteLength>=10&&t.getUint32(0,k)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,he),height:t.getUint16(8,he)}:null}function uo(e){let t=de(e);return t.byteLength>=14&&t.getUint16(0,k)===16973&&t.getUint32(2,he)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,he),height:t.getUint32(22,he)}:null}function ho(e){let t=de(e);if(!(t.byteLength>=3&&t.getUint16(0,k)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:n,sofMarkers:o}=po(),i=2;for(;i+9<t.byteLength;){let s=t.getUint16(i,k);if(o.has(s))return{mimeType:"image/jpeg",height:t.getUint16(i+5,k),width:t.getUint16(i+7,k)};if(!n.has(s))return null;i+=2,i+=t.getUint16(i,k)}return null}function po(){let e=new Set([65499,65476,65484,65501,65534]);for(let r=65504;r<65520;++r)e.add(r);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function de(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 hr(e,t){let{mimeType:r}=ke(e)||{},n=globalThis.loaders?.parseImageNode;return ce(n),await n(e,r)}async function dr(e,t,r){t=t||{};let o=(t.image||{}).type||"auto",{url:i}=r||{},s=go(o),a;switch(s){case"imagebitmap":a=await fr(e,t,i);break;case"image":a=await Ne(e,t,i);break;case"data":a=await hr(e,t);break;default:ce(!1)}return o==="data"&&(a=ar(a)),a}function go(e){switch(e){case"auto":case"data":return sr();default:return ir(e),e}}var mo=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],yo=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],xo={image:{type:"auto",decode:!0}},ht={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:or,mimeTypes:yo,extensions:mo,parse:dr,tests:[e=>Boolean(ke(new DataView(e)))],options:xo};function pr(e){let t=[];if(e.fields)for(let r of e.fields)t.push({name:r.name,type:vo(r),metadata:To(r)});return{metadata:wo(e),fields:t}}function wo(e){let t={};for(let[r,n]of Object.entries(e))r!=="fields"&&n&&(t[r]=JSON.stringify(n));return t}function vo(e){switch(e.type.toLowerCase()){case"float32":return"float32";case"number":case"float64":return"float64";case"string":case"utf8":return"utf8";case"boolean":return"bool";default:return"null"}}function To(e){let t={};for(let[r,n]of Object.entries(e))r!=="name"&&n&&(t[r]=JSON.stringify(n));return t}var xr=e=>e!==null&&typeof e=="object";function dt(e,t){if(!e||!xr(e))return null;let r={name:e.name||"",description:e.description||""};if(typeof e.generator=="string"&&(r.generator=e.generator),typeof e.generator_options=="string"&&(r.generatorOptions=e.generator_options),r.boundingBox=gr(e.bounds)||gr(e.antimeridian_adjusted_bounds),r.center=So(e.center),r.maxZoom=mr(e.maxzoom),r.minZoom=mr(e.minzoom),typeof e?.json=="string")try{r.metaJson=JSON.parse(e.json)}catch(a){console.warn("Failed to parse tilejson.json field",a)}let n=e.tilestats||r.metaJson?.tilestats,o=Po(n,t),i=Fo(e.vector_layers),s=Bo(i,o);return r={...r,layers:s},r.maxZoom===null&&s.length>0&&(r.maxZoom=s[0].maxZoom||null),r.minZoom===null&&s.length>0&&(r.minZoom=s[0].minZoom||null),r}function Fo(e){return Array.isArray(e)?e.map(t=>Io(t)):[]}function Io(e){let t=Object.entries(e.fields||[]).map(([n,o])=>({name:n,...Fr(String(o))})),r={...e};return delete r.fields,{name:e.id||"",...r,fields:t}}function Po(e,t){return xr(e)&&Array.isArray(e.layers)?e.layers.map(r=>bo(r,t)):[]}function bo(e,t){let r=[],n={},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];n[a]=n[a]||[],n[a].push(i),console.warn("ignoring tilestats indexed field",a)}else r[s]||r.push(Eo(i,t))}return{name:e.layer||"",dominantGeometry:e.geometry,fields:r}}function Bo(e,t){return e.map(r=>{let n=t.find(s=>s.name===r.name),o=n?.fields||r.fields||[],i={...r,...n,fields:o};return i.schema=pr(i),i})}function gr(e){let t=Tr(e);if(Array.isArray(t)&&t.length===4&&[t[0],t[2]].every(vr)&&[t[1],t[3]].every(wr))return[[t[0],t[1]],[t[2],t[3]]]}function So(e){let t=Tr(e);return Array.isArray(t)&&t.length===3&&vr(t[0])&&wr(t[1])&&_o(t[2])?t:null}function mr(e){let t=typeof e=="string"?parseFloat(e):typeof e=="number"?e:null;return t===null||isNaN(t)?null:t}function wr(e){return Number.isFinite(e)&&e<=90&&e>=-90}function vr(e){return Number.isFinite(e)&&e<=180&&e>=-180}function _o(e){return Number.isFinite(e)&&e>=0&&e<=22}function Tr(e){return typeof e=="string"?e.split(",").map(parseFloat):Array.isArray(e)?e:null}var yr={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 Eo(e={},t){let r=Fr(e.type),n={name:e.attribute,...r};return typeof e.min=="number"&&(n.min=e.min),typeof e.max=="number"&&(n.max=e.max),typeof e.count=="number"&&(n.uniqueValueCount=e.count),e.values&&(n.values=e.values),n.values&&typeof t.maxValues=="number"&&(n.values=n.values?.slice(0,t.maxValues)),n}function Fr(e){let t=e.toLowerCase();return!t||yr[t],yr[t]||{type:"string"}}var Ao="4.4.0-alpha.16",pe={dataType:null,batchType:null,name:"TileJSON",id:"tilejson",module:"pmtiles",version:Ao,worker:!0,extensions:["json"],mimeTypes:["application/json"],text:!0,options:{tilejson:{maxValues:void 0}},parse:async(e,t)=>{let r=new TextDecoder().decode(e),n=JSON.parse(r),o={...pe.options.tilejson,...t?.tilejson};return dt(n,o)},parseTextSync:(e,t)=>{let r=JSON.parse(e),n={...pe.options.tilejson,...t?.tilejson};return dt(r,n)}};var ge={x:0,y:1,z:2};function H(e,t={}){let{start:r=0,end:n=e.length,plane:o="xy"}=t,i=t.size||2,s=0,a=ge[o[0]],l=ge[o[1]];for(let c=r,f=n-i;c<n;c+=i)s+=(e[c+a]-e[f+a])*(e[c+l]+e[f+l]),f=c;return s/2}function gt(e,t,r=2,n,o="xy"){let i=t&&t.length,s=i?t[0]*r:e.length,a=Pr(e,0,s,r,!0,n&&n[0],o),l=[];if(!a||a.next===a.prev)return l;let c,f,u,h,d,p,y;if(i&&(a=No(e,t,a,r,n,o)),e.length>80*r){h=f=e[0],d=u=e[1];for(let I=r;I<s;I+=r)p=e[I],y=e[I+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,r,h,d,c,0),l}function Pr(e,t,r,n,o,i,s){let a,l;i===void 0&&(i=H(e,{start:t,end:r,size:n,plane:s}));let c=ge[s[0]],f=ge[s[1]];if(o===i<0)for(a=t;a<r;a+=n)l=Ir(a,e[a+c],e[a+f],l);else for(a=r-n;a>=t;a-=n)l=Ir(a,e[a+c],e[a+f],l);return l&&je(l,l.next)&&(xe(l),l=l.next),l}function W(e,t){if(!e)return e;t||(t=e);let r=e,n;do if(n=!1,!r.steiner&&(je(r,r.next)||T(r.prev,r,r.next)===0)){if(xe(r),r=t=r.prev,r===r.next)break;n=!0}else r=r.next;while(n||r!==t);return t}function me(e,t,r,n,o,i,s){if(!e)return;!s&&i&&zo(e,n,o,i);let a=e,l,c;for(;e.prev!==e.next;){if(l=e.prev,c=e.next,i?Vo(e,n,o,i):Mo(e)){t.push(l.i/r|0),t.push(e.i/r|0),t.push(c.i/r|0),xe(e),e=c.next,a=c.next;continue}if(e=c,e===a){s?s===1?(e=Co(W(e),t,r),me(e,t,r,n,o,i,2)):s===2&&Uo(e,t,r,n,o,i):me(W(e),t,r,n,o,i,1);break}}}function Mo(e){let t=e.prev,r=e,n=e.next;if(T(t,r,n)>=0)return!1;let o=t.x,i=r.x,s=n.x,a=t.y,l=r.y,c=n.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=n.next;for(;p!==t;){if(p.x>=f&&p.x<=h&&p.y>=u&&p.y<=d&&te(o,a,i,l,s,c,p.x,p.y)&&T(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Vo(e,t,r,n){let o=e.prev,i=e,s=e.next;if(T(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,I=f>u?f>h?f:h:u>h?u:h,D=pt(d,p,t,r,n),v=pt(y,I,t,r,n),m=e.prevZ,g=e.nextZ;for(;m&&m.z>=D&&g&&g.z<=v;){if(m.x>=d&&m.x<=y&&m.y>=p&&m.y<=I&&m!==o&&m!==s&&te(a,f,l,u,c,h,m.x,m.y)&&T(m.prev,m,m.next)>=0||(m=m.prevZ,g.x>=d&&g.x<=y&&g.y>=p&&g.y<=I&&g!==o&&g!==s&&te(a,f,l,u,c,h,g.x,g.y)&&T(g.prev,g,g.next)>=0))return!1;g=g.nextZ}for(;m&&m.z>=D;){if(m.x>=d&&m.x<=y&&m.y>=p&&m.y<=I&&m!==o&&m!==s&&te(a,f,l,u,c,h,m.x,m.y)&&T(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<=I&&g!==o&&g!==s&&te(a,f,l,u,c,h,g.x,g.y)&&T(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function Co(e,t,r){let n=e;do{let o=n.prev,i=n.next.next;!je(o,i)&&br(o,n,n.next,i)&&ye(o,i)&&ye(i,o)&&(t.push(o.i/r|0),t.push(n.i/r|0),t.push(i.i/r|0),xe(n),xe(n.next),n=e=i),n=n.next}while(n!==e);return W(n)}function Uo(e,t,r,n,o,i){let s=e;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&Wo(s,a)){let l=Br(s,a);s=W(s,s.next),l=W(l,l.next),me(s,t,r,n,o,i,0),me(l,t,r,n,o,i,0);return}a=a.next}s=s.next}while(s!==e)}function No(e,t,r,n,o,i){let s=[],a,l,c,f,u;for(a=0,l=t.length;a<l;a++)c=t[a]*n,f=a<l-1?t[a+1]*n:e.length,u=Pr(e,c,f,n,!1,o&&o[a+1],i),u===u.next&&(u.steiner=!0),s.push(Ho(u));for(s.sort(ko),a=0;a<s.length;a++)r=Go(s[a],r);return r}function ko(e,t){return e.x-t.x}function Go(e,t){let r=Oo(e,t);if(!r)return t;let n=Br(r,e);return W(n,n.next),W(r,r.next)}function Oo(e,t){let r=t,n=e.x,o=e.y,i=-1/0,s;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){let h=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(h<=n&&h>i&&(i=h,s=r.x<r.next.x?r:r.next,h===n))return s}r=r.next}while(r!==t);if(!s)return null;let a=s,l=s.x,c=s.y,f=1/0,u;r=s;do n>=r.x&&r.x>=l&&n!==r.x&&te(o<c?n:i,o,l,c,o<c?i:n,o,r.x,r.y)&&(u=Math.abs(o-r.y)/(n-r.x),ye(r,e)&&(u<f||u===f&&(r.x>s.x||r.x===s.x&&jo(s,r)))&&(s=r,f=u)),r=r.next;while(r!==a);return s}function jo(e,t){return T(e.prev,e,t.prev)<0&&T(t.next,e,e.next)<0}function zo(e,t,r,n){let o=e;do o.z===0&&(o.z=pt(o.x,o.y,t,r,n)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next;while(o!==e);o.prevZ.nextZ=null,o.prevZ=null,Ro(o)}function Ro(e){let t,r,n=1,o,i,s,a,l,c;do{for(i=e,e=null,c=null,o=0;i;){for(o++,a=i,s=0,r=0;r<n&&(s++,a=a.nextZ,!!a);r++);for(l=n;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,n*=2}while(o>1);return e}function pt(e,t,r,n,o){return e=(e-r)*o|0,t=(t-n)*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 Ho(e){let t=e,r=e;do(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next;while(t!==e);return r}function te(e,t,r,n,o,i,s,a){return(o-s)*(t-a)>=(e-s)*(i-a)&&(e-s)*(n-a)>=(r-s)*(t-a)&&(r-s)*(i-a)>=(o-s)*(n-a)}function Wo(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Zo(e,t)&&(ye(e,t)&&ye(t,e)&&$o(e,t)&&(T(e.prev,e,t.prev)||T(e,t.prev,t))||je(e,t)&&T(e.prev,e,e.next)>0&&T(t.prev,t,t.next)>0)}function T(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function je(e,t){return e.x===t.x&&e.y===t.y}function br(e,t,r,n){let o=Oe(T(e,t,r)),i=Oe(T(e,t,n)),s=Oe(T(r,n,e)),a=Oe(T(r,n,t));return!!(o!==i&&s!==a||o===0&&Ge(e,r,t)||i===0&&Ge(e,n,t)||s===0&&Ge(r,e,n)||a===0&&Ge(r,t,n))}function Ge(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function Oe(e){return e>0?1:e<0?-1:0}function Zo(e,t){let r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&br(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}function ye(e,t){return T(e.prev,e,e.next)<0?T(e,t,e.next)>=0&&T(e,e.prev,t)>=0:T(e,t,e.prev)<0||T(e,e.next,t)<0}function $o(e,t){let r=e,n=!1,o=(e.x+t.x)/2,i=(e.y+t.y)/2;do r.y>i!=r.next.y>i&&r.next.y!==r.y&&o<(r.next.x-r.x)*(i-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;while(r!==e);return n}function Br(e,t){let r=new we(e.i,e.x,e.y),n=new we(t.i,t.x,t.y),o=e.next,i=t.prev;return e.next=t,t.prev=e,r.next=o,o.prev=r,n.next=r,r.prev=n,i.next=n,n.prev=i,n}function Ir(e,t,r,n){let o=new we(e,t,r);return n?(o.next=n.next,o.prev=n,n.next.prev=o,n.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,r,n){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=t,this.x=r,this.y=n}};function ze(e,t,r){let n=Qo(e),o=Object.keys(n).filter(i=>n[i]!==Array);return qo(e,{propArrayTypes:n,...t},{numericPropKeys:r&&r.numericPropKeys||o,PositionDataType:r?r.PositionDataType:Float32Array,triangulate:r?r.triangulate:!0})}function Qo(e){let t={};for(let r of e)if(r.properties)for(let n in r.properties){let o=r.properties[n];t[n]=ii(o,t[n])}return t}function qo(e,t,r){let{pointPositionsCount:n,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:I=!0}=r,D=e[0]&&"id"in e[0],v=e.length>65535?Uint32Array:Uint16Array,m={type:"Point",positions:new y(n*d),globalFeatureIds:new v(n),featureIds:o>65535?new Uint32Array(n):new Uint16Array(n),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:[]},S={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:[]};I&&(S.triangles=[]);for(let M of[m,g,S])for(let P of p){let _=h[P];M.numericProps[P]=new _(M.positions.length/d)}g.pathIndices[s]=i,S.polygonIndices[c]=l,S.primitivePolygonIndices[f]=l;let U={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let M of e){let P=M.geometry,_=M.properties||{};switch(P.type){case"Point":ei(P,m,U,d,_),m.properties.push(yt(_,p)),D&&m.fields.push({id:M.id}),U.pointFeature++;break;case"LineString":ti(P,g,U,d,_),g.properties.push(yt(_,p)),D&&g.fields.push({id:M.id}),U.lineFeature++;break;case"Polygon":ri(P,S,U,d,_),S.properties.push(yt(_,p)),D&&S.fields.push({id:M.id}),U.polygonFeature++;break;default:throw new Error("Invalid geometry type")}U.feature++}return oi(m,g,S,d)}function ei(e,t,r,n,o){t.positions.set(e.data,r.pointPosition*n);let i=e.data.length/n;xt(t,o,r.pointPosition,i),t.globalFeatureIds.fill(r.feature,r.pointPosition,r.pointPosition+i),t.featureIds.fill(r.pointFeature,r.pointPosition,r.pointPosition+i),r.pointPosition+=i}function ti(e,t,r,n,o){t.positions.set(e.data,r.linePosition*n);let i=e.data.length/n;xt(t,o,r.linePosition,i),t.globalFeatureIds.fill(r.feature,r.linePosition,r.linePosition+i),t.featureIds.fill(r.lineFeature,r.linePosition,r.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[r.linePath++]=r.linePosition,r.linePosition+=(c-l)/n}}function ri(e,t,r,n,o){t.positions.set(e.data,r.polygonPosition*n);let i=e.data.length/n;xt(t,o,r.polygonPosition,i),t.globalFeatureIds.fill(r.feature,r.polygonPosition,r.polygonPosition+i),t.featureIds.fill(r.polygonFeature,r.polygonPosition,r.polygonPosition+i);for(let s=0,a=e.indices.length;s<a;++s){let l=r.polygonPosition;t.polygonIndices[r.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],I=d===p-1?u===void 0?e.data.length:u[0]:f[d+1];t.primitivePolygonIndices[r.polygonRing++]=r.polygonPosition,r.polygonPosition+=(I-y)/n}let h=r.polygonPosition;ni(t,c,f,{startPosition:l,endPosition:h,coordLength:n})}}function ni(e,t,r,{startPosition:n,endPosition:o,coordLength:i}){if(!e.triangles)return;let s=n*i,a=o*i,l=e.positions.subarray(s,a),c=r[0],f=r.slice(1).map(h=>(h-c)/i),u=gt(l,f,i,t);for(let h=0,d=u.length;h<d;++h)e.triangles.push(n+u[h])}function mt(e,t){let r={};for(let n in e)r[n]={value:e[n],size:t};return r}function oi(e,t,r,n){let o={shape:"binary-feature-collection",points:{...e,positions:{value:e.positions,size:n},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:mt(e.numericProps,1)},lines:{...t,positions:{value:t.positions,size:n},pathIndices:{value:t.pathIndices,size:1},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:mt(t.numericProps,1)},polygons:{...r,positions:{value:r.positions,size:n},polygonIndices:{value:r.polygonIndices,size:1},primitivePolygonIndices:{value:r.primitivePolygonIndices,size:1},globalFeatureIds:{value:r.globalFeatureIds,size:1},featureIds:{value:r.featureIds,size:1},numericProps:mt(r.numericProps,1)}};return o.polygons&&r.triangles&&(o.polygons.triangles={value:new Uint32Array(r.triangles),size:1}),o}function xt(e,t,r,n){for(let o in e.numericProps)if(o in t){let i=t[o];e.numericProps[o].fill(i,r,r+n)}}function yt(e,t){let r={};for(let n in e)t.includes(n)||(r[n]=e[n]);return r}function ii(e,t){return t===Array||!Number.isFinite(e)?Array:t===Float64Array||Math.fround(e)!==e?Float64Array:Float32Array}var Pt=Ht(Cr(),1);function Ii(e){let t=0;for(let r=0,n=e.length-1,o,i;r<e.length;n=r++)o=e[r],i=e[n],t+=(i[0]-o[0])*(o[1]+i[1]);return t}function Tt(e,t){if(Array.isArray(e[0])){for(let n of e)Tt(n,t);return}let r=e;r[0]/=t,r[1]/=t}function Ur(e,t){for(let r=0;r<e.length;++r)e[r]/=t}function Ft(e,t,r){if(typeof e[0][0]!="number"){for(let s of e)Ft(s,t,r);return}let n=r*Math.pow(2,t.z),o=r*t.x,i=r*t.y;for(let s=0;s<e.length;s++){let a=e[s];a[0]=(a[0]+o)*360/n-180;let l=180-(a[1]+i)*360/n;a[1]=360/Math.PI*Math.atan(Math.exp(l*Math.PI/180))-90}}function Nr(e,t,r){let{x:n,y:o,z:i}=t,s=r*Math.pow(2,i),a=r*n,l=r*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 kr(e){let t=e.length;if(t<=1)return[e];let r=[],n,o;for(let i=0;i<t;i++){let s=Ii(e[i]);s!==0&&(o===void 0&&(o=s<0),o===s<0?(n&&r.push(n),n=[e[i]]):n&&n.push(e[i]))}return n&&r.push(n),r}function Gr(e){let t=e.indices.length,r="Polygon";if(t<=1)return{type:r,data:e.data,areas:[[H(e.data)]],indices:[e.indices]};let n=[],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=H(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&&(n.push(i),o.push(s)),s=[u],i=[d]):(i.push(d),s.push(u))}return i&&n.push(i),s.length&&o.push(s),{type:r,areas:n,indices:o,data:e.data}}var Z=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;constructor(t,r,n,o,i,s){this.properties={},this.extent=n,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=o,this._values=i,this._geometryInfo=s,t.readFields(Pi,this,r)}toGeoJSONFeature(t,r){let n=this.loadGeometry();switch(t){case"wgs84":return Or(this,n,o=>Ft(o,r,this.extent));default:return Or(this,n,Tt)}}toBinaryFeature(t,r){let n=this.loadFlatGeometry();switch(t){case"wgs84":return this._toBinaryCoordinates(n,o=>Nr(o,r,this.extent));default:return this._toBinaryCoordinates(n,Ur)}}bbox(){let t=this._pbf;t.pos=this._geometry;let r=t.readVarint()+t.pos,n=1,o=0,i=0,s=0,a=1/0,l=-1/0,c=1/0,f=-1/0;for(;t.pos<r;){if(o<=0){let u=t.readVarint();n=u&7,o=u>>3}if(o--,n===1||n===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(n!==7)throw new Error(`unknown command ${n}`)}return[a,c,l,f]}_toBinaryCoordinates(t,r){let n;r(t.data,this.extent);let o=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=t.indices.length,n={type:"Point",...t};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=t.indices.length,this._geometryInfo.linePositionsCount+=t.data.length/o,n={type:"LineString",...t};break;case 3:n=Gr(t),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=n.indices.length;for(let s of n.indices)this._geometryInfo.polygonRingsCount+=s.length;this._geometryInfo.polygonPositionsCount+=n.data.length/o;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let i={type:"Feature",geometry:n,properties:this.properties};return this.id!==null&&(i.id=this.id),i}loadGeometry(){let t=this._pbf;t.pos=this._geometry;let r=t.readVarint()+t.pos,n=1,o=0,i=0,s=0,a=[],l;for(;t.pos<r;){if(o<=0){let c=t.readVarint();n=c&7,o=c>>3}switch(o--,n){case 1:case 2:i+=t.readSVarint(),s+=t.readSVarint(),n===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 ${n}`)}}return l&&a.push(l),a}loadFlatGeometry(){let t=this._pbf;t.pos=this._geometry;let r=t.readVarint()+t.pos,n=1,o,i=0,s=0,a=0,l=0,c=[],f=[];for(;t.pos<r;)if(i<=0&&(o=t.readVarint(),n=o&7,i=o>>3),i--,n===1||n===2)s+=t.readSVarint(),a+=t.readSVarint(),n===1&&c.push(l),f.push(s,a),l+=2;else if(n===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 ${n}`);return{data:f,indices:c}}};Ae(Z,"types",["Unknown","Point","LineString","Polygon"]);function Or(e,t,r){let n=Z.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,r(s,e.extent);break;case 2:for(s=t,o=0;o<s.length;o++)r(s[o],e.extent);break;case 3:for(s=kr(t),o=0;o<s.length;o++)for(i=0;i<s[o].length;i++)r(s[o][i],e.extent);break;default:throw new Error("illegal vector tile type")}s.length===1?s=s[0]:n=`Multi${n}`;let a={type:"Feature",geometry:{type:n,coordinates:s},properties:e.properties};return e.id!==null&&(a.properties||={},a.properties.id=e.id),a}function Pi(e,t,r){t&&r&&(e===1?t.id=r.readVarint():e===2?bi(r,t):e===3?t.type=r.readVarint():e===4&&(t._geometry=r.pos))}function bi(e,t){let r=e.readVarint()+e.pos;for(;e.pos<r;){let n=t._keys[e.readVarint()],o=t._values[e.readVarint()];t.properties[n]=o}}var We=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(t,r){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Bi,this,r),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 r=this._pbf.readVarint()+this._pbf.pos;return new Z(this._pbf,r,this.extent,this._keys,this._values)}getBinaryFeature(t,r){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 Z(this._pbf,n,this.extent,this._keys,this._values,r)}};function Bi(e,t,r){t&&r&&(e===15?t.version=r.readVarint():e===1?t.name=r.readString():e===5?t.extent=r.readVarint():e===2?t._features.push(r.pos):e===3?t._keys.push(r.readString()):e===4&&t._values.push(Si(r)))}function Si(e){let t=null,r=e.readVarint()+e.pos;for(;e.pos<r;){let n=e.readVarint()>>3;t=n===1?e.readString():n===2?e.readFloat():n===3?e.readDouble():n===4?e.readVarint64():n===5?e.readVarint():n===6?e.readSVarint():n===7?e.readBoolean():null}return t}var ve=class{layers;constructor(t,r){this.layers=t.readFields(_i,{},r)}};function _i(e,t,r){if(e===3&&r){let n=new We(r,r.readVarint()+r.pos);n.length&&t&&(t[n.name]=n)}}function bt(e,t){let r=Ai(t),n=t?.gis?.format||t?.mvt?.shape||t?.shape;switch(n){case"columnar-table":return{shape:"columnar-table",data:It(e,r)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:jr(e,r)};case"geojson":return jr(e,r);case"binary-geometry":return It(e,r);case"binary":return It(e,r);default:throw new Error(n||"undefined shape")}}function It(e,t){let[r,n]=Ei(e,t),o=ze(r,n);return o.byteLength=e.byteLength,o}function Ei(e,t){let r=[],n={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[r,n];let o=new ve(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,n),f=Li(c,t,s);r.push(f)}}),[r,n]}function jr(e,t){if(e.byteLength<=0)return[];let r=[],n=new ve(new Pt.default(e));return(Array.isArray(t.layers)?t.layers:Object.keys(n.layers)).forEach(i=>{let s=n.layers[i];if(s)for(let a=0;a<s.length;a++){let l=s.getGeoJSONFeature(a),c=Di(l,t,i);r.push(c)}}),r}function Ai(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&&st.warn('MVTLoader: "options.gis" is deprecated, use "options.mvt.shape" instead')(),e.mvt}function Di(e,t,r){let n=e.toGeoJSONFeature(t.coordinates||"local",t.tileIndex);return t.layerProperty&&(n.properties||={},n.properties[t.layerProperty]=r),n}function Li(e,t,r){let n=e.toBinaryFeature(t.coordinates||"local",t.tileIndex);return t.layerProperty&&n.properties&&(n.properties[t.layerProperty]=r),n}var zr={name:"Mapbox Vector Tile",id:"mvt",module:"mvt",extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],category:"geometry"};var Mi="4.4.0-alpha.16",Rr={...zr,dataType:null,batchType:null,version:Mi,worker:!0,options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:void 0}}},Bt={...Rr,parse:async(e,t)=>bt(e,t),parseSync:bt,binary:!0};var Ze={name:"PMTiles",id:"pmtiles",module:"pmtiles",extensions:["pmtiles"],mimeTypes:["application/octet-stream"],tests:["PMTiles"]};var Pe={};Rt(Pe,{Compression:()=>an,EtagMismatch:()=>Je,FetchSource:()=>un,FileSource:()=>ds,PMTiles:()=>Dt,Protocol:()=>as,ResolvedValueCache:()=>gs,SharedPromiseCache:()=>mn,TileType:()=>ln,bytesToHeader:()=>hn,findTile:()=>fn,getUint64:()=>A,leafletRasterLayer:()=>is,readVarint:()=>ie,tileIdToZxy:()=>us,tileTypeExt:()=>cn,zxyToTileId:()=>sn});var $=Math.pow,F=(e,t,r)=>new Promise((n,o)=>{var i=l=>{try{a(r.next(l))}catch(c){o(c)}},s=l=>{try{a(r.throw(l))}catch(c){o(c)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(i,s);a((r=r.apply(e,t)).next())}),B=Uint8Array,se=Uint16Array,Vi=Int32Array,Zr=new B([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]),$r=new B([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]),Ci=new B([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Jr=function(e,t){for(var r=new se(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];for(var o=new Vi(r[30]),n=1;n<30;++n)for(var i=r[n];i<r[n+1];++i)o[i]=i-r[n]<<5|n;return{b:r,r:o}},Kr=Jr(Zr,2),Yr=Kr.b,Ui=Kr.r;Yr[28]=258,Ui[258]=28;var Xr=Jr($r,0),Ni=Xr.b,lc=Xr.r,Et=new se(32768);for(w=0;w<32768;++w)j=(w&43690)>>1|(w&21845)<<1,j=(j&52428)>>2|(j&13107)<<2,j=(j&61680)>>4|(j&3855)<<4,Et[w]=((j&65280)>>8|(j&255)<<8)>>1;var j,w,Fe=function(e,t,r){for(var n=e.length,o=0,i=new se(t);o<n;++o)e[o]&&++i[e[o]-1];var s=new se(t);for(o=1;o<t;++o)s[o]=s[o-1]+i[o-1]<<1;var a;if(r){a=new se(1<<t);var l=15-t;for(o=0;o<n;++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[Et[u]>>l]=c}else for(a=new se(n),o=0;o<n;++o)e[o]&&(a[o]=Et[s[e[o]-1]++]>>15-e[o]);return a},Ie=new B(288);for(w=0;w<144;++w)Ie[w]=8;var w;for(w=144;w<256;++w)Ie[w]=9;var w;for(w=256;w<280;++w)Ie[w]=7;var w;for(w=280;w<288;++w)Ie[w]=8;var w,Qr=new B(32);for(w=0;w<32;++w)Qr[w]=5;var w,ki=Fe(Ie,9,1),Gi=Fe(Qr,5,1),St=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},C=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(t&7)&r},_t=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(t&7)},Oi=function(e){return(e+7)/8|0},ji=function(e,t,r){(t==null||t<0)&&(t=0),(r==null||r>e.length)&&(r=e.length);var n=new B(r-t);return n.set(e.subarray(t,r)),n},zi=["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"],b=function(e,t,r){var n=new Error(t||zi[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,b),!r)throw n;return n},Lt=function(e,t,r,n){var o=e.length,i=n?n.length:0;if(!o||t.f&&!t.l)return r||new B(0);var s=!r||t.i!=2,a=t.i;r||(r=new B(o*3));var l=function(Ot){var jt=r.length;if(Ot>jt){var zt=new B(Math.max(jt*2,Ot));zt.set(r),r=zt}},c=t.f||0,f=t.p||0,u=t.b||0,h=t.l,d=t.d,p=t.m,y=t.n,I=o*8;do{if(!h){c=C(e,f,1);var D=C(e,f+1,3);if(f+=3,D)if(D==1)h=ki,d=Gi,p=9,y=5;else if(D==2){var S=C(e,f,31)+257,U=C(e,f+10,15)+4,M=S+C(e,f+5,31)+1;f+=14;for(var P=new B(M),_=new B(19),E=0;E<U;++E)_[Ci[E]]=C(e,f+E*3,7);f+=U*3;for(var Ct=St(_),Tn=(1<<Ct)-1,Fn=Fe(_,Ct,1),E=0;E<M;){var Ut=Fn[C(e,f,Tn)];f+=Ut&15;var v=Ut>>4;if(v<16)P[E++]=v;else{var K=0,Se=0;for(v==16?(Se=3+C(e,f,3),f+=2,K=P[E-1]):v==17?(Se=3+C(e,f,7),f+=3):v==18&&(Se=11+C(e,f,127),f+=7);Se--;)P[E++]=K}}var Nt=P.subarray(0,S),V=P.subarray(S);p=St(Nt),y=St(V),h=Fe(Nt,p,1),d=Fe(V,y,1)}else b(1);else{var v=Oi(f)+4,m=e[v-4]|e[v-3]<<8,g=v+m;if(g>o){a&&b(0);break}s&&l(u+m),r.set(e.subarray(v,g),u),t.b=u+=m,t.p=f=g*8,t.f=c;continue}if(f>I){a&&b(0);break}}s&&l(u+131072);for(var In=(1<<p)-1,Pn=(1<<y)-1,Ye=f;;Ye=f){var K=h[_t(e,f)&In],Y=K>>4;if(f+=K&15,f>I){a&&b(0);break}if(K||b(2),Y<256)r[u++]=Y;else if(Y==256){Ye=f,h=null;break}else{var kt=Y-254;if(Y>264){var E=Y-257,ae=Zr[E];kt=C(e,f,(1<<ae)-1)+Yr[E],f+=ae}var Xe=d[_t(e,f)&Pn],Qe=Xe>>4;Xe||b(3),f+=Xe&15;var V=Ni[Qe];if(Qe>3){var ae=$r[Qe];V+=_t(e,f)&(1<<ae)-1,f+=ae}if(f>I){a&&b(0);break}s&&l(u+131072);var qe=u+kt;if(u<V){var Gt=i-V,bn=Math.min(V,qe);for(Gt+u<0&&b(3);u<bn;++u)r[u]=n[Gt+u]}for(;u<qe;u+=4)r[u]=r[u-V],r[u+1]=r[u+1-V],r[u+2]=r[u+2-V],r[u+3]=r[u+3-V];u=qe}}t.l=h,t.p=Ye,t.b=u,t.f=c,h&&(c=1,t.m=p,t.d=d,t.n=y)}while(!c);return u==r.length?r:ji(r,0,u)},Ri=new B(0),Hi=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&b(6,"invalid gzip data");var t=e[3],r=10;t&4&&(r+=(e[10]|e[11]<<8)+2);for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[r++]);return r+(t&2)},Wi=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)&&b(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&b(6,"invalid zlib data: "+(e[1]&32?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function $i(e,t){return Lt(e,{i:2},t&&t.out,t&&t.dictionary)}function Ji(e,t){var r=Hi(e);return r+8>e.length&&b(6,"invalid gzip data"),Lt(e.subarray(r,-8),{i:2},t&&t.out||new B(Wi(e)),t&&t.dictionary)}function Ki(e,t){return Lt(e.subarray(Zi(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}function At(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?$i(e,t):Ki(e,t)}var Yi=typeof TextDecoder<"u"&&new TextDecoder,Xi=0;try{Yi.decode(Ri,{stream:!0}),Xi=1}catch{}var qr=(e,t)=>e*$(2,t),Te=(e,t)=>Math.floor(e/$(2,t)),$e=(e,t)=>qr(e.getUint16(t+1,!0),8)+e.getUint8(t),en=(e,t)=>qr(e.getUint32(t+2,!0),16)+e.getUint16(t,!0),Qi=(e,t,r,n,o)=>{if(e!==n.getUint8(o))return e-n.getUint8(o);let i=$e(n,o+1);if(t!==i)return t-i;let s=$e(n,o+4);return r!==s?r-s:0},qi=(e,t,r,n)=>{let o=tn(e,t|128,r,n);return o?{z:t,x:r,y:n,offset:o[0],length:o[1],isDir:!0}:null},Hr=(e,t,r,n)=>{let o=tn(e,t,r,n);return o?{z:t,x:r,y:n,offset:o[0],length:o[1],isDir:!1}:null},tn=(e,t,r,n)=>{let o=0,i=e.byteLength/17-1;for(;o<=i;){let s=i+o>>1,a=Qi(t,r,n,e,s*17);if(a>0)o=s+1;else if(a<0)i=s-1;else return[en(e,s*17+7),e.getUint32(s*17+13,!0)]}return null},es=(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,rn=(e,t)=>{let r=e.getUint8(t*17);return{z:r&127,x:$e(e,t*17+1),y:$e(e,t*17+4),offset:en(e,t*17+7),length:e.getUint32(t*17+13,!0),isDir:r>>7===1}},Wr=e=>{let t=[],r=new DataView(e);for(let n=0;n<r.byteLength/17;n++)t.push(rn(r,n));return ts(t)},ts=e=>{e.sort(es);let t=new ArrayBuffer(17*e.length),r=new Uint8Array(t);for(let n=0;n<e.length;n++){let o=e[n],i=o.z;o.isDir&&(i=i|128),r[n*17]=i,r[n*17+1]=o.x&255,r[n*17+2]=o.x>>8&255,r[n*17+3]=o.x>>16&255,r[n*17+4]=o.y&255,r[n*17+5]=o.y>>8&255,r[n*17+6]=o.y>>16&255,r[n*17+7]=o.offset&255,r[n*17+8]=Te(o.offset,8)&255,r[n*17+9]=Te(o.offset,16)&255,r[n*17+10]=Te(o.offset,24)&255,r[n*17+11]=Te(o.offset,32)&255,r[n*17+12]=Te(o.offset,48)&255,r[n*17+13]=o.length&255,r[n*17+14]=o.length>>8&255,r[n*17+15]=o.length>>16&255,r[n*17+16]=o.length>>24&255}return t},rs=(e,t)=>{if(e.byteLength<17)return null;let r=e.byteLength/17,n=rn(e,r-1);if(n.isDir){let o=n.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 ns(e){return F(this,null,function*(){let t=yield e.getBytes(0,512e3),r=new DataView(t.data),n=r.getUint32(4,!0),o=r.getUint16(8,!0),i=new TextDecoder("utf-8"),s=JSON.parse(i.decode(new DataView(t.data,10,n))),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,I=85;if(s.bounds){let v=s.bounds.split(",");d=+v[0],p=+v[1],y=+v[2],I=+v[3]}if(s.center){let v=s.center.split(",");f=+v[0],u=+v[1],h=+v[2]}return{specVersion:r.getUint16(2,!0),rootDirectoryOffset:10+n,rootDirectoryLength:o*17,jsonMetadataOffset:10,jsonMetadataLength:n,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:I,centerZoom:h,centerLon:f,centerLat:u,etag:t.etag}})}function os(e,t,r,n,o,i,s){return F(this,null,function*(){let a=yield r.getArrayBuffer(t,e.rootDirectoryOffset,e.rootDirectoryLength,e);e.specVersion===1&&(a=Wr(a));let l=Hr(new DataView(a),n,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=At(new Uint8Array(u))),{data:u}}let c=rs(new DataView(a),{z:n,x:o,y:i});if(c){let f=qi(new DataView(a),c.z,c.x,c.y);if(f){let u=yield r.getArrayBuffer(t,f.offset,f.length,e);e.specVersion===1&&(u=Wr(u));let h=Hr(new DataView(u),n,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=At(new Uint8Array(p))),{data:p}}}}})}var nn={getHeader:ns,getZxy:os},is=(e,t)=>{let r=!1,n="",o=L.GridLayer.extend({createTile:(i,s)=>{let a=document.createElement("img"),l=new AbortController,c=l.signal;return a.cancel=()=>{l.abort()},r||(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?n="image/png":f.tileType===3?n="image/jpeg":f.tileType===4?n="image/webp":f.tileType===5&&(n="image/avif")}),r=!0),e.getZxy(i.z,i.x,i.y,c).then(f=>{if(f){let u=new Blob([f.data],{type:n}),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)},ss=e=>(t,r)=>{if(r instanceof AbortController)return e(t,r);let n=new AbortController;return e(t,n).then(o=>r(void 0,o.data,o.cacheControl||"",o.expires||""),o=>r(o)).catch(o=>r(o)),{cancel:()=>n.abort()}},as=class{constructor(e){this.tilev4=(t,r)=>F(this,null,function*(){if(t.type==="json"){let h=t.url.substr(10),d=this.tiles.get(h);if(d||(d=new Dt(h),this.tiles.set(h,d)),this.metadata)return{data:yield d.getTileJson(t.url)};let p=yield d.getHeader();return{data:{tiles:[`${t.url}/{z}/{x}/{y}`],minzoom:p.minZoom,maxzoom:p.maxZoom,bounds:[p.minLon,p.minLat,p.maxLon,p.maxLat]}}}let n=new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/),o=t.url.match(n);if(!o)throw new Error("Invalid PMTiles protocol URL");let i=o[1],s=this.tiles.get(i);s||(s=new Dt(i),this.tiles.set(i,s));let a=o[2],l=o[3],c=o[4],f=yield s.getHeader(),u=yield s?.getZxy(+a,+l,+c,r.signal);return u?{data:new Uint8Array(u.data),cacheControl:u.cacheControl,expires:u.expires}:f.tileType===1?{data:new Uint8Array}:{data:null}}),this.tile=ss(this.tilev4),this.tiles=new Map,this.metadata=e?.metadata||!1}add(e){this.tiles.set(e.source.getKey(),e)}get(e){return this.tiles.get(e)}};function oe(e,t){return(t>>>0)*4294967296+(e>>>0)}function ls(e,t){let r=t.buf,n=r[t.pos++],o=(n&112)>>4;if(n<128||(n=r[t.pos++],o|=(n&127)<<3,n<128)||(n=r[t.pos++],o|=(n&127)<<10,n<128)||(n=r[t.pos++],o|=(n&127)<<17,n<128)||(n=r[t.pos++],o|=(n&127)<<24,n<128)||(n=r[t.pos++],o|=(n&1)<<31,n<128))return oe(e,o);throw new Error("Expected varint not more than 10 bytes")}function ie(e){let t=e.buf,r=t[e.pos++],n=r&127;return r<128||(r=t[e.pos++],n|=(r&127)<<7,r<128)||(r=t[e.pos++],n|=(r&127)<<14,r<128)||(r=t[e.pos++],n|=(r&127)<<21,r<128)?n:(r=t[e.pos],n|=(r&15)<<28,ls(n,e))}function on(e,t,r,n){if(n===0){r===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 cs(e,t){let r=$(2,e),n=t,o=t,i=t,s=[0,0],a=1;for(;a<r;)n=1&i/2,o=1&(i^n),on(a,s,n,o),s[0]+=a*n,s[1]+=a*o,i=i/4,a*=2;return[e,s[0],s[1]]}var fs=[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 sn(e,t,r){if(e>26)throw Error("Tile zoom level exceeds max safe number limit (26)");if(t>$(2,e)-1||r>$(2,e)-1)throw Error("tile x/y outside zoom level bounds");let n=fs[e],o=$(2,e),i=0,s=0,a=0,l=[t,r],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),on(c,l,i,s),c=c/2;return n+a}function us(e){let t=0,r=0;for(let n=0;n<27;n++){let o=(1<<n)*(1<<n);if(t+o>e)return cs(n,e-t);t+=o}throw Error("Tile zoom level exceeds max safe number limit (26)")}var an=(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))(an||{});function Mt(e,t){return F(this,null,function*(){if(t===1||t===0)return e;if(t===2){if(typeof globalThis.DecompressionStream>"u")return At(new Uint8Array(e));let r=new Response(e).body;if(!r)throw Error("Failed to read response stream");let n=r.pipeThrough(new globalThis.DecompressionStream("gzip"));return new Response(n).arrayBuffer()}throw Error("Compression method not supported")})}var ln=(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))(ln||{});function cn(e){return e===1?".mvt":e===2?".png":e===3?".jpg":e===4?".webp":e===5?".avif":""}var hs=127;function fn(e,t){let r=0,n=e.length-1;for(;r<=n;){let o=n+r>>1,i=t-e[o].tileId;if(i>0)r=o+1;else if(i<0)n=o-1;else return e[o]}return n>=0&&(e[n].runLength===0||t-e[n].tileId<e[n].runLength)?e[n]:null}var ds=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()}})}},un=class{constructor(e,t=new Headers){this.url=e,this.customHeaders=t,this.mustReload=!1;let r="";"navigator"in globalThis&&(r=globalThis.navigator.userAgent||"");let n=r.indexOf("Windows")>-1,o=/Chrome|Chromium|Edg|OPR|Brave/.test(r);this.chromeWindowsNoCache=!1,n&&o&&(this.chromeWindowsNoCache=!0)}getKey(){return this.url}setHeaders(e){this.customHeaders=e}getBytes(e,t,r,n){return F(this,null,function*(){let o,i;r?i=r:(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":this.chromeWindowsNoCache&&(a="no-store");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||n&&c&&c!==n)throw this.mustReload=!0,new Je(`Server returned non-matching ETag ${n} after one retry. Check browser extensions and servers for issues that may affect correct ETag headers.`);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 A(e,t){let r=e.getUint32(t+4,!0),n=e.getUint32(t+0,!0);return r*$(2,32)+n}function hn(e,t){let r=new DataView(e),n=r.getUint8(7);if(n>3)throw Error(`Archive is spec version ${n} but this library supports up to spec version 3`);return{specVersion:n,rootDirectoryOffset:A(r,8),rootDirectoryLength:A(r,16),jsonMetadataOffset:A(r,24),jsonMetadataLength:A(r,32),leafDirectoryOffset:A(r,40),leafDirectoryLength:A(r,48),tileDataOffset:A(r,56),tileDataLength:A(r,64),numAddressedTiles:A(r,72),numTileEntries:A(r,80),numTileContents:A(r,88),clustered:r.getUint8(96)===1,internalCompression:r.getUint8(97),tileCompression:r.getUint8(98),tileType:r.getUint8(99),minZoom:r.getUint8(100),maxZoom:r.getUint8(101),minLon:r.getInt32(102,!0)/1e7,minLat:r.getInt32(106,!0)/1e7,maxLon:r.getInt32(110,!0)/1e7,maxLat:r.getInt32(114,!0)/1e7,centerZoom:r.getUint8(118),centerLon:r.getInt32(119,!0)/1e7,centerLat:r.getInt32(123,!0)/1e7,etag:t}}function dn(e){let t={buf:new Uint8Array(e),pos:0},r=ie(t),n=[],o=0;for(let i=0;i<r;i++){let s=ie(t);n.push({tileId:o+s,offset:0,length:0,runLength:1}),o+=s}for(let i=0;i<r;i++)n[i].runLength=ie(t);for(let i=0;i<r;i++)n[i].length=ie(t);for(let i=0;i<r;i++){let s=ie(t);s===0&&i>0?n[i].offset=n[i-1].offset+n[i-1].length:n[i].offset=s-1}return n}function ps(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 Je=class extends Error{};function pn(e,t){return F(this,null,function*(){let r=yield e.getBytes(0,16384);if(new DataView(r.data).getUint16(0,!0)!==19792)throw new Error("Wrong magic number for PMTiles archive");if(ps(r.data)<3)return[yield nn.getHeader(e)];let o=r.data.slice(0,hs),i=hn(o,r.etag),s=r.data.slice(i.rootDirectoryOffset,i.rootDirectoryOffset+i.rootDirectoryLength),a=`${e.getKey()}|${i.etag||""}|${i.rootDirectoryOffset}|${i.rootDirectoryLength}`,l=dn(yield t(s,i.internalCompression));return[i,[a,l.length,l]]})}function gn(e,t,r,n,o){return F(this,null,function*(){let i=yield e.getBytes(r,n,void 0,o.etag),s=yield t(i.data,o.internalCompression),a=dn(s);if(a.length===0)throw new Error("Empty directory is invalid");return a})}var gs=class{constructor(e=100,t=!0,r=Mt){this.cache=new Map,this.maxCacheEntries=e,this.counter=1,this.decompress=r}getHeader(e){return F(this,null,function*(){let t=e.getKey(),r=this.cache.get(t);if(r)return r.lastUsed=this.counter++,r.data;let n=yield pn(e,this.decompress);return n[1]&&this.cache.set(n[1][0],{lastUsed:this.counter++,data:n[1][2]}),this.cache.set(t,{lastUsed:this.counter++,data:n[0]}),this.prune(),n[0]})}getDirectory(e,t,r,n){return F(this,null,function*(){let o=`${e.getKey()}|${n.etag||""}|${t}|${r}`,i=this.cache.get(o);if(i)return i.lastUsed=this.counter++,i.data;let s=yield gn(e,this.decompress,t,r,n);return this.cache.set(o,{lastUsed:this.counter++,data:s}),this.prune(),s})}getArrayBuffer(e,t,r,n){return F(this,null,function*(){let o=`${e.getKey()}|${n.etag||""}|${t}|${r}`,i=this.cache.get(o);if(i)return i.lastUsed=this.counter++,yield i.data;let s=yield e.getBytes(t,r,void 0,n.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((r,n)=>{r.lastUsed<e&&(e=r.lastUsed,t=n)}),t&&this.cache.delete(t)}}invalidate(e){return F(this,null,function*(){this.cache.delete(e.getKey())})}},mn=class{constructor(e=100,t=!0,r=Mt){this.cache=new Map,this.invalidations=new Map,this.maxCacheEntries=e,this.counter=1,this.decompress=r}getHeader(e){return F(this,null,function*(){let t=e.getKey(),r=this.cache.get(t);if(r)return r.lastUsed=this.counter++,yield r.data;let n=new Promise((o,i)=>{pn(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:n}),n})}getDirectory(e,t,r,n){return F(this,null,function*(){let o=`${e.getKey()}|${n.etag||""}|${t}|${r}`,i=this.cache.get(o);if(i)return i.lastUsed=this.counter++,yield i.data;let s=new Promise((a,l)=>{gn(e,this.decompress,t,r,n).then(c=>{a(c),this.prune()}).catch(c=>{l(c)})});return this.cache.set(o,{lastUsed:this.counter++,data:s}),s})}getArrayBuffer(e,t,r,n){return F(this,null,function*(){let o=`${e.getKey()}|${n.etag||""}|${t}|${r}`,i=this.cache.get(o);if(i)return i.lastUsed=this.counter++,yield i.data;let s=new Promise((a,l)=>{e.getBytes(t,r,void 0,n.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((r,n)=>{r.lastUsed<e&&(e=r.lastUsed,t=n)}),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 r=new Promise((n,o)=>{this.getHeader(e).then(i=>{n(),this.invalidations.delete(t)}).catch(i=>{o(i)})});this.invalidations.set(t,r)})}},Dt=class{constructor(e,t,r){typeof e=="string"?this.source=new un(e):this.source=e,r?this.decompress=r:this.decompress=Mt,t?this.cache=t:this.cache=new mn}getHeader(){return F(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(e,t,r,n){return F(this,null,function*(){let o=sn(e,t,r),i=yield this.cache.getHeader(this.source);if(i.specVersion<3)return nn.getZxy(i,this.source,this.cache,e,t,r,n);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=fn(c,o);if(f){if(f.runLength>0){let u=yield this.source.getBytes(i.tileDataOffset+f.offset,f.length,n,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,r,n){return F(this,null,function*(){try{return yield this.getZxyAttempt(e,t,r,n)}catch(o){if(o instanceof Je)return this.cache.invalidate(this.source),yield this.getZxyAttempt(e,t,r,n);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),r=yield this.decompress(t.data,e.internalCompression),n=new TextDecoder("utf-8");return JSON.parse(n.decode(r))})}getMetadata(){return F(this,null,function*(){try{return yield this.getMetadataAttempt()}catch(e){if(e instanceof Je)return this.cache.invalidate(this.source),yield this.getMetadataAttempt();throw e}})}getTileJson(e){return F(this,null,function*(){let t=yield this.getHeader(),r=yield this.getMetadata(),n=cn(t.tileType);return{tilejson:"3.0.0",scheme:"xyz",tiles:[`${e}/{z}/{x}/{y}${n}`],vector_layers:r.vector_layers,attribution:r.attribution,description:r.description,name:r.name,version:r.version,bounds:[t.minLon,t.minLat,t.maxLon,t.maxLat],center:[t.centerLon,t.centerLat,t.centerZoom],minzoom:t.minZoom,maxzoom:t.maxZoom}})}};var{TileType:be}=Pe;function yn(e,t,r,n){let o=null;if(t)try{let a=JSON.stringify(t);o=pe.parseTextSync?.(a,n)||null}catch(a){console.warn("PMTiles metadata could not be interpreted as TileJSON",a)}let i={};typeof o?.name=="string"&&(i.name=o.name),typeof o?.htmlAttribution=="string"&&(i.attributions=[o.htmlAttribution]);let s={...i,format:"pmtiles",formatVersion:e.specVersion,attributions:[],tileMIMEType:ms(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 o&&(s.tilejson=o),r?.includeFormatHeader&&(s.formatHeader=e,s.formatMetadata=s),s}function ms(e){switch(e){case be.Mvt:return"application/vnd.mapbox-vector-tile";case be.Png:return"image/png";case be.Jpeg:return"image/jpeg";case be.Webp:return"image/webp";case be.Avif:return"image/avif";default:return"application/octet-stream"}}var Ke=class{blob;key;constructor(t,r){this.blob=t,this.key=r}getKey(){return this.blob.url||""}async getBytes(t,r,n){return{data:await this.blob.slice(t,t+r).arrayBuffer()}}};var{PMTiles:ys}=Pe,xs="1.0.0",Vt={...Ze,version:xs,type:"pmtiles",fromUrl:!0,fromBlob:!0,defaultOptions:{pmtiles:{}},testURL:e=>e.endsWith(".pmtiles"),createDataSource:(e,t)=>new J(e,t)},J=class extends ee{mimeType=null;pmtiles;metadata;constructor(t,r){super(t,r,Vt.defaultOptions);let n=typeof t=="string"?fe(t):new Ke(t,"pmtiles");this.pmtiles=new ys(n),this.getTileData=this.getTileData.bind(this),this.metadata=this.getMetadata()}async getSchema(){return{fields:[],metadata:{}}}async getMetadata(){let t=await this.pmtiles.getHeader(),r=await this.pmtiles.getMetadata()||{},n=yn(t,r,{includeFormatHeader:!1},this.loadOptions);return this.options.attributions&&(n.attributions=[...this.options.core?.attributions||[],...n.attributions||[]]),n?.tileMIMEType&&(this.mimeType=n?.tileMIMEType),n}async getTile(t){let{x:r,y:n,z:o}=t,s=(await this.pmtiles.getZxy(o,r,n))?.data;return s||null}async getTileData(t){let{x:r,y:n,z:o}=t.index;switch((await this.metadata).tileMIMEType){case"application/vnd.mapbox-vector-tile":return await this.getVectorTile({x:r,y:n,z:o,layers:[]});default:return await this.getImageTile({x:r,y:n,z:o,layers:[]})}}async getImageTile(t){let r=await this.getTile(t);return r?await ht.parse(r,this.loadOptions):null}async getVectorTile(t){let r=await this.getTile(t),n={mvt:{shape:"geojson-table",coordinates:"wgs84",tileIndex:{x:t.x,y:t.y,z:t.z},...this.loadOptions?.mvt},...this.loadOptions};return r?await Bt.parse(r,n):null}};var xn="4.4.0-alpha.16";var vn={...Ze,version:xn,options:{pmtiles:{}},parse:async(e,t)=>wn(new ue(new Blob([e])),t),parseFile:wn};async function wn(e,t){let n=await new J(e.handle,{pmtiles:t?.pmtiles||{}}).getMetadata(),{tileMIMEType:o,tilejson:i={}}=n,{layers:s=[]}=i;switch(o){case"application/vnd.mapbox-vector-tile":return{shape:"vector-source",layers:s.map(a=>({name:a.name,schema:a.schema})),tables:[],formatSpecificMetadata:n};case"image/png":case"image/jpeg":return{shape:"image-source",formatSpecificMetadata:n};default:throw new Error(`PMTilesLoader: Unsupported tile MIME type ${o}`)}}return Ln(Be);})();
7
+ "use strict";var __exports__=(()=>{var Bn=Object.create;var le=Object.defineProperty;var Sn=Object.getOwnPropertyDescriptor;var _n=Object.getOwnPropertyNames;var En=Object.getPrototypeOf,An=Object.prototype.hasOwnProperty;var Dn=(e,t,r)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var et=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Rt=(e,t)=>{for(var r in t)le(e,r,{get:t[r],enumerable:!0})},_e=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _n(t))!An.call(e,o)&&o!==r&&le(e,o,{get:()=>t[o],enumerable:!(n=Sn(t,o))||n.enumerable});return e},Ee=(e,t,r)=>(_e(e,t,"default"),r&&_e(r,t,"default")),Ht=(e,t,r)=>(r=e!=null?Bn(En(e)):{},_e(t||!e||!e.__esModule?le(r,"default",{value:e,enumerable:!0}):r,e)),Ln=e=>_e(le({},"__esModule",{value:!0}),e);var Ae=(e,t,r)=>(Dn(e,typeof t!="symbol"?t+"":t,r),r);var Zt=et((vs,Wt)=>{Wt.exports=globalThis.loaders});var Er=et(wt=>{wt.read=function(e,t,r,n,o){var i,s,a=o*8-n-1,l=(1<<a)-1,c=l>>1,f=-7,u=r?o-1:0,h=r?-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+=n;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,n),i=i-c}return(d?-1:1)*s*Math.pow(2,i-n)};wt.write=function(e,t,r,n,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=n?0:i-1,p=n?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[r+d]=a&255,d+=p,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[r+d]=s&255,d+=p,s/=256,c-=8);e[r+d-p]|=y*128}});var Cr=et((Ol,Vr)=>{"use strict";Vr.exports=x;var Re=Er();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 vt=(1<<16)*(1<<16),Ar=1/vt,si=12,Mr=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");x.prototype={destroy:function(){this.buf=null},readFields:function(e,t,r){for(r=r||this.length;this.pos<r;){var n=this.readVarint(),o=n>>3,i=this.pos;this.type=n&7,e(o,t,this),this.pos===i&&this.skip(n)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=He(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Lr(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=He(this.buf,this.pos)+He(this.buf,this.pos+4)*vt;return this.pos+=8,e},readSFixed64:function(){var e=He(this.buf,this.pos)+Lr(this.buf,this.pos+4)*vt;return this.pos+=8,e},readFloat:function(){var e=Re.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=Re.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t=this.buf,r,n;return n=t[this.pos++],r=n&127,n<128||(n=t[this.pos++],r|=(n&127)<<7,n<128)||(n=t[this.pos++],r|=(n&127)<<14,n<128)||(n=t[this.pos++],r|=(n&127)<<21,n<128)?r:(n=t[this.pos],r|=(n&15)<<28,ai(r,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>=si&&Mr?Ti(this.buf,t,e):vi(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 r=O(this);for(e=e||[];this.pos<r;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==x.Bytes)return e.push(this.readSVarint());var t=O(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=O(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=O(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=O(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=O(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=O(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=O(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=O(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 r=new Uint8Array(t);r.set(this.buf),this.buf=r,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),ne(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),ne(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),ne(this.buf,e&-1,this.pos),ne(this.buf,Math.floor(e*Ar),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),ne(this.buf,e&-1,this.pos),ne(this.buf,Math.floor(e*Ar),this.pos+4),this.pos+=8},writeVarint:function(e){if(e=+e||0,e>268435455||e<0){li(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=Fi(this.buf,e,this.pos);var r=this.pos-t;r>=128&&Dr(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r},writeFloat:function(e){this.realloc(4),Re.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),Re.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 r=0;r<t;r++)this.buf[this.pos++]=e[r]},writeRawMessage:function(e,t){this.pos++;var r=this.pos;e(t,this);var n=this.pos-r;n>=128&&Dr(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(e,t,r){this.writeTag(e,x.Bytes),this.writeRawMessage(t,r)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,ui,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,hi,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,gi,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,di,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,pi,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,mi,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,yi,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,xi,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,wi,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 ai(e,t,r){var n=r.buf,o,i;if(i=n[r.pos++],o=(i&112)>>4,i<128||(i=n[r.pos++],o|=(i&127)<<3,i<128)||(i=n[r.pos++],o|=(i&127)<<10,i<128)||(i=n[r.pos++],o|=(i&127)<<17,i<128)||(i=n[r.pos++],o|=(i&127)<<24,i<128)||(i=n[r.pos++],o|=(i&1)<<31,i<128))return re(e,o,t);throw new Error("Expected varint not more than 10 bytes")}function O(e){return e.type===x.Bytes?e.readVarint()+e.pos:e.pos+1}function re(e,t,r){return r?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function li(e,t){var r,n;if(e>=0?(r=e%4294967296|0,n=e/4294967296|0):(r=~(-e%4294967296),n=~(-e/4294967296),r^4294967295?r=r+1|0:(r=0,n=n+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),ci(r,n,t),fi(n,t)}function ci(e,t,r){r.buf[r.pos++]=e&127|128,e>>>=7,r.buf[r.pos++]=e&127|128,e>>>=7,r.buf[r.pos++]=e&127|128,e>>>=7,r.buf[r.pos++]=e&127|128,e>>>=7,r.buf[r.pos]=e&127}function fi(e,t){var r=(e&7)<<4;t.buf[t.pos++]|=r|((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 Dr(e,t,r){var n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));r.realloc(n);for(var o=r.pos-1;o>=e;o--)r.buf[o+n]=r.buf[o]}function ui(e,t){for(var r=0;r<e.length;r++)t.writeVarint(e[r])}function hi(e,t){for(var r=0;r<e.length;r++)t.writeSVarint(e[r])}function di(e,t){for(var r=0;r<e.length;r++)t.writeFloat(e[r])}function pi(e,t){for(var r=0;r<e.length;r++)t.writeDouble(e[r])}function gi(e,t){for(var r=0;r<e.length;r++)t.writeBoolean(e[r])}function mi(e,t){for(var r=0;r<e.length;r++)t.writeFixed32(e[r])}function yi(e,t){for(var r=0;r<e.length;r++)t.writeSFixed32(e[r])}function xi(e,t){for(var r=0;r<e.length;r++)t.writeFixed64(e[r])}function wi(e,t){for(var r=0;r<e.length;r++)t.writeSFixed64(e[r])}function He(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+e[t+3]*16777216}function ne(e,t,r){e[r]=t,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24}function Lr(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function vi(e,t,r){for(var n="",o=t;o<r;){var i=e[o],s=null,a=i>239?4:i>223?3:i>191?2:1;if(o+a>r)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,n+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),n+=String.fromCharCode(s),o+=a}return n}function Ti(e,t,r){return Mr.decode(e.subarray(t,r))}function Fi(e,t,r){for(var n=0,o,i;n<t.length;n++){if(o=t.charCodeAt(n),o>55295&&o<57344)if(i)if(o<56320){e[r++]=239,e[r++]=191,e[r++]=189,i=o;continue}else o=i-55296<<10|o-56320|65536,i=null;else{o>56319||n+1===t.length?(e[r++]=239,e[r++]=191,e[r++]=189):i=o;continue}else i&&(e[r++]=239,e[r++]=191,e[r++]=189,i=null);o<128?e[r++]=o:(o<2048?e[r++]=o>>6|192:(o<65536?e[r++]=o>>12|224:(e[r++]=o>>18|240,e[r++]=o>>12&63|128),e[r++]=o>>6&63|128),e[r++]=o&63|128)}return r}});var Be={};Rt(Be,{PMTilesSource:()=>Vt,PMTilesTileSource:()=>J,_PMTilesLoader:()=>vn});Ee(Be,Ht(Zt(),1));function ce(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var N={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Mn=N.self||N.window||N.global||{},Vn=N.window||N.self||N.global||{},Cn=N.global||N.self||N.window||{},Un=N.document||{};var tt=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var $t=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Nn=$t&&parseFloat($t[1])||0;var De=globalThis,kn=globalThis.document||{},Le=globalThis.process||{},Gn=globalThis.console,Is=globalThis.navigator||{};function Jt(e){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let t=typeof navigator<"u"&&navigator.userAgent,r=e||t;return Boolean(r&&r.indexOf("Electron")>=0)}function z(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Jt()}var rt="4.1.1";function X(e,t){if(!e)throw new Error(t||"Assertion failed")}function nt(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 X(Number.isFinite(t)&&t>=0),t}function Kt(e){let{logLevel:t,message:r}=e;e.logLevel=nt(t);let n=e.args?Array.from(e.args):[];for(;n.length&&n.shift()!==r;);switch(typeof t){case"string":case"function":r!==void 0&&n.unshift(r),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 X(o==="string"||o==="object"),Object.assign(e,{args:n},e.opts)}var R=()=>{},Me=class{constructor({level:t=0}={}){this.userData={},this._onceCache=new Set,this._level=t}set level(t){this.setLevel(t)}get level(){return this.getLevel()}setLevel(t){return this._level=t,this}getLevel(){return this._level}warn(t,...r){return this._log("warn",0,t,r,{once:!0})}error(t,...r){return this._log("error",0,t,r)}log(t,r,...n){return this._log("log",t,r,n)}info(t,r,...n){return this._log("info",t,r,n)}once(t,r,...n){return this._log("once",t,r,n,{once:!0})}_log(t,r,n,o,i={}){let s=Kt({logLevel:r,message:n,args:this._buildArgs(r,n,o),opts:i});return this._createLogFunction(t,s,i)}_buildArgs(t,r,n){return[t,r,...n]}_createLogFunction(t,r,n){if(!this._shouldLog(r.logLevel))return R;let o=this._getOnceTag(n.tag??r.tag??r.message);if((n.once||r.once)&&o!==void 0){if(this._onceCache.has(o))return R;this._onceCache.add(o)}return this._emit(t,r)}_shouldLog(t){return this.getLevel()>=nt(t)}_getOnceTag(t){if(t!==void 0)try{return typeof t=="string"?t:String(t)}catch{return}}};function jn(e){try{let t=window[e],r="__storage_test__";return t.setItem(r,r),t.removeItem(r),t}catch{return null}}var Ve=class{constructor(t,r,n="sessionStorage"){this.storage=jn(n),this.id=t,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){if(Object.assign(this.config,t),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let t={};if(this.storage){let r=this.storage.getItem(this.id);t=r?JSON.parse(r):{}}return Object.assign(this.config,t),this}};function Yt(e){let t;return e<10?t=`${e.toFixed(2)}ms`:e<100?t=`${e.toFixed(1)}ms`:e<1e3?t=`${e.toFixed(0)}ms`:t=`${(e/1e3).toFixed(2)}s`,t}function Xt(e,t=8){let r=Math.max(t-e.length,0);return`${" ".repeat(r)}${e}`}var Ce;(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"})(Ce||(Ce={}));var zn=10;function Qt(e){return typeof e!="string"?e:(e=e.toUpperCase(),Ce[e]||Ce.WHITE)}function qt(e,t,r){return!z&&typeof e=="string"&&(t&&(e=`\x1B[${Qt(t)}m${e}\x1B[39m`),r&&(e=`\x1B[${Qt(r)+zn}m${e}\x1B[49m`)),e}function er(e,t=["constructor"]){let r=Object.getPrototypeOf(e),n=Object.getOwnPropertyNames(r),o=e;for(let i of n){let s=o[i];typeof s=="function"&&(t.find(a=>i===a)||(o[i]=s.bind(e)))}}function Q(){let e;if(z()&&De.performance)e=De?.performance?.now?.();else if("hrtime"in Le){let t=Le?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var q={debug:z()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},ot={enabled:!0,level:0},G=class extends Me{constructor({id:t}={id:""}){super({level:0}),this.VERSION=rt,this._startTs=Q(),this._deltaTs=Q(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=t,this.userData={},this._storage=new Ve(`__probe-${this.id}__`,{[this.id]:ot}),this.timeStamp(`${this.id} started`),er(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Q()-this._startTs).toPrecision(10))}getDelta(){return Number((Q()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(t=!0){return this._updateConfiguration({enabled:t}),this}setLevel(t){return this._updateConfiguration({level:t}),this}get(t){return this._getConfiguration()[t]}set(t,r){this._updateConfiguration({[t]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,r){if(!t)throw new Error(r||"Assertion failed")}warn(t,...r){return this._log("warn",0,t,r,{method:q.warn,once:!0})}error(t,...r){return this._log("error",0,t,r,{method:q.error})}deprecated(t,r){return this.warn(`\`${t}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(t,r){return this.error(`\`${t}\` has been removed. Use \`${r}\` instead`)}probe(t,r,...n){return this._log("log",t,r,n,{method:q.log,time:!0,once:!0})}log(t,r,...n){return this._log("log",t,r,n,{method:q.debug})}info(t,r,...n){return this._log("info",t,r,n,{method:console.info})}once(t,r,...n){return this._log("once",t,r,n,{method:q.debug||q.info,once:!0})}table(t,r,n){return r?this._log("table",t,r,n&&[n]||[],{method:console.table||R,tag:Hn(r)}):R}time(t,r){return this._log("time",t,r,[],{method:console.time?console.time:console.info})}timeEnd(t,r){return this._log("time",t,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(t,r){return this._log("time",t,r,[],{method:console.timeStamp||R})}group(t,r,n={collapsed:!1}){let o=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",t,r,[],{method:o})}groupCollapsed(t,r,n={}){return this.group(t,r,Object.assign({},n,{collapsed:!0}))}groupEnd(t){return this._log("groupEnd",t,"",[],{method:console.groupEnd||R})}withGroup(t,r,n){this.group(t,r)();try{n()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&super._shouldLog(t)}_emit(t,r){let n=r.method;X(n),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Q();let o=Rn(this.id,r.message,r);return n.bind(console,o,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(ot),this._storage.config[this.id]}_updateConfiguration(t){let r=this._storage.config[this.id]||{...ot};this._storage.setConfiguration({[this.id]:{...r,...t}})}};G.VERSION=rt;function Rn(e,t,r){if(typeof t=="string"){let n=r.time?Xt(Yt(r.total)):"";t=r.time?`${e}: ${n} ${t}`:`${e}: ${t}`,t=qt(t,r.color,r.background)}return t}function Hn(e){for(let t in e)for(let r in e[t])return r||"untitled";return"empty"}globalThis.probe={};var qs=new G({id:"@probe.gl/log"});var it="4.4.0-alpha.18",Wn=it[0]>="0"&&it[0]<="9"?`v${it}`:"";function Zn(){let e=new G({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=e,globalThis.loaders.version=Wn,globalThis.probe||={},globalThis.probe.loaders=e,e}var st=Zn();function tr(e,t){return rr(e||{},t)}function rr(e,t,r=0){if(r>3)return t;let n={...e};for(let[o,i]of Object.entries(t))i&&typeof i=="object"&&!Array.isArray(i)?n[o]=rr(n[o]||{},t[o],r+1):n[o]=t[o];return n}var $n="",nr={};function fe(e){for(let t in nr)if(e.startsWith(t)){let r=nr[t];e=e.replace(t,r)}return!e.startsWith("http://")&&!e.startsWith("https://")&&(e=`${$n}${e}`),e}var ue=class{handle;size;bigsize;url;constructor(t){this.handle=t instanceof ArrayBuffer?new Blob([t]):t,this.size=t instanceof ArrayBuffer?t.byteLength:t.size,this.bigsize=BigInt(this.size),this.url=t instanceof File?t.name:""}async close(){}async stat(){return{size:this.handle.size,bigsize:BigInt(this.handle.size),isDirectory:!1}}async read(t,r){return await this.handle.slice(Number(t),Number(t)+Number(r)).arrayBuffer()}};var at=class{optionsType;options;data;url;loadOptions;fetch;_needsRefresh=!0;constructor(t,r,n){n?this.options=tr({...n,core:at.defaultOptions},r):this.options={...r},this.data=t,this.url=typeof t=="string"?fe(t):"",this.loadOptions={...this.options.core?.loadOptions},this.fetch=Jn(this.loadOptions)}setProps(t){this.options=Object.assign(this.options,t),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(t=!0){let r=this._needsRefresh;return t&&(this._needsRefresh=!1),r}},ee=at;Ae(ee,"defaultOptions",{core:{type:"auto",attributions:[],loadOptions:{},loaders:[]}});function Jn(e){let t=e?.core?.fetch;if(t&&typeof t=="function")return(n,o)=>t(n,o);let r=e?.fetch;return r&&typeof r!="function"?n=>fetch(n,r):n=>fetch(n)}var or="4.4.0-alpha.18";var Kn=globalThis.loaders?.parseImageNode,lt=typeof Image<"u",ct=typeof ImageBitmap<"u",Yn=Boolean(Kn),ft=tt?!0:Yn;function ir(e){switch(e){case"auto":return ct||lt||ft;case"imagebitmap":return ct;case"image":return lt;case"data":return ft;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function sr(){if(ct)return"imagebitmap";if(lt)return"image";if(ft)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function Xn(e){let t=Qn(e);if(!t)throw new Error("Not an image");return t}function ar(e){switch(Xn(e)){case"data":return e;case"image":case"imagebitmap":let t=document.createElement("canvas"),r=t.getContext("2d");if(!r)throw new Error("getImageData");return t.width=e.width,t.height=e.height,r.drawImage(e,0,0),r.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}function Qn(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 qn=/^data:image\/svg\+xml/,eo=/\.svg((\?|#).*)?$/;function Ue(e){return e&&(qn.test(e)||eo.test(e))}function lr(e,t){if(Ue(t)){let n=new TextDecoder().decode(e);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(n=unescape(encodeURIComponent(n)))}catch(i){throw new Error(i.message)}return`data:image/svg+xml;base64,${btoa(n)}`}return ut(e,t)}function ut(e,t){if(Ue(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function Ne(e,t,r){let n=lr(e,r),o=self.URL||self.webkitURL,i=typeof n!="string"&&o.createObjectURL(n);try{return await to(i||n,t)}finally{i&&o.revokeObjectURL(i)}}async function to(e,t){let r=new Image;return r.src=e,t.image&&t.image.decode&&r.decode?(await r.decode(),r):await new Promise((n,o)=>{try{r.onload=()=>n(r),r.onerror=i=>{let s=i instanceof Error?i.message:"error";o(new Error(s))}}catch(i){o(i)}})}var cr=!0;async function fr(e,t,r){let n;Ue(r)?n=await Ne(e,t,r):n=ut(e,r);let o=t&&t.imagebitmap;return await ro(n,o)}async function ro(e,t=null){if((no(t)||!cr)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(r){console.warn(r),cr=!1}return await createImageBitmap(e)}function no(e){if(!e)return!0;for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function ur(e){return!ao(e,"ftyp",4)||!(e[8]&96)?null:oo(e)}function oo(e){switch(io(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function io(e,t,r){return String.fromCharCode(...e.slice(t,r))}function so(e){return[...e].map(t=>t.charCodeAt(0))}function ao(e,t,r=0){let n=so(t);for(let o=0;o<n.length;++o)if(n[o]!==e[o+r])return!1;return!0}var k=!1,he=!0;function ke(e){let t=de(e);return co(t)||ho(t)||fo(t)||uo(t)||lo(t)}function lo(e){let t=new Uint8Array(e instanceof DataView?e.buffer:e),r=ur(t);return r?{mimeType:r.mimeType,width:0,height:0}:null}function co(e){let t=de(e);return t.byteLength>=24&&t.getUint32(0,k)===2303741511?{mimeType:"image/png",width:t.getUint32(16,k),height:t.getUint32(20,k)}:null}function fo(e){let t=de(e);return t.byteLength>=10&&t.getUint32(0,k)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,he),height:t.getUint16(8,he)}:null}function uo(e){let t=de(e);return t.byteLength>=14&&t.getUint16(0,k)===16973&&t.getUint32(2,he)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,he),height:t.getUint32(22,he)}:null}function ho(e){let t=de(e);if(!(t.byteLength>=3&&t.getUint16(0,k)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:n,sofMarkers:o}=po(),i=2;for(;i+9<t.byteLength;){let s=t.getUint16(i,k);if(o.has(s))return{mimeType:"image/jpeg",height:t.getUint16(i+5,k),width:t.getUint16(i+7,k)};if(!n.has(s))return null;i+=2,i+=t.getUint16(i,k)}return null}function po(){let e=new Set([65499,65476,65484,65501,65534]);for(let r=65504;r<65520;++r)e.add(r);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function de(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 hr(e,t){let{mimeType:r}=ke(e)||{},n=globalThis.loaders?.parseImageNode;return ce(n),await n(e,r)}async function dr(e,t,r){t=t||{};let o=(t.image||{}).type||"auto",{url:i}=r||{},s=go(o),a;switch(s){case"imagebitmap":a=await fr(e,t,i);break;case"image":a=await Ne(e,t,i);break;case"data":a=await hr(e,t);break;default:ce(!1)}return o==="data"&&(a=ar(a)),a}function go(e){switch(e){case"auto":case"data":return sr();default:return ir(e),e}}var mo=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],yo=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],xo={image:{type:"auto",decode:!0}},ht={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:or,mimeTypes:yo,extensions:mo,parse:dr,tests:[e=>Boolean(ke(new DataView(e)))],options:xo};function pr(e){let t=[];if(e.fields)for(let r of e.fields)t.push({name:r.name,type:vo(r),metadata:To(r)});return{metadata:wo(e),fields:t}}function wo(e){let t={};for(let[r,n]of Object.entries(e))r!=="fields"&&n&&(t[r]=JSON.stringify(n));return t}function vo(e){switch(e.type.toLowerCase()){case"float32":return"float32";case"number":case"float64":return"float64";case"string":case"utf8":return"utf8";case"boolean":return"bool";default:return"null"}}function To(e){let t={};for(let[r,n]of Object.entries(e))r!=="name"&&n&&(t[r]=JSON.stringify(n));return t}var xr=e=>e!==null&&typeof e=="object";function dt(e,t){if(!e||!xr(e))return null;let r={name:e.name||"",description:e.description||""};if(typeof e.generator=="string"&&(r.generator=e.generator),typeof e.generator_options=="string"&&(r.generatorOptions=e.generator_options),r.boundingBox=gr(e.bounds)||gr(e.antimeridian_adjusted_bounds),r.center=So(e.center),r.maxZoom=mr(e.maxzoom),r.minZoom=mr(e.minzoom),typeof e?.json=="string")try{r.metaJson=JSON.parse(e.json)}catch(a){console.warn("Failed to parse tilejson.json field",a)}let n=e.tilestats||r.metaJson?.tilestats,o=Po(n,t),i=Fo(e.vector_layers),s=Bo(i,o);return r={...r,layers:s},r.maxZoom===null&&s.length>0&&(r.maxZoom=s[0].maxZoom||null),r.minZoom===null&&s.length>0&&(r.minZoom=s[0].minZoom||null),r}function Fo(e){return Array.isArray(e)?e.map(t=>Io(t)):[]}function Io(e){let t=Object.entries(e.fields||[]).map(([n,o])=>({name:n,...Fr(String(o))})),r={...e};return delete r.fields,{name:e.id||"",...r,fields:t}}function Po(e,t){return xr(e)&&Array.isArray(e.layers)?e.layers.map(r=>bo(r,t)):[]}function bo(e,t){let r=[],n={},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];n[a]=n[a]||[],n[a].push(i),console.warn("ignoring tilestats indexed field",a)}else r[s]||r.push(Eo(i,t))}return{name:e.layer||"",dominantGeometry:e.geometry,fields:r}}function Bo(e,t){return e.map(r=>{let n=t.find(s=>s.name===r.name),o=n?.fields||r.fields||[],i={...r,...n,fields:o};return i.schema=pr(i),i})}function gr(e){let t=Tr(e);if(Array.isArray(t)&&t.length===4&&[t[0],t[2]].every(vr)&&[t[1],t[3]].every(wr))return[[t[0],t[1]],[t[2],t[3]]]}function So(e){let t=Tr(e);return Array.isArray(t)&&t.length===3&&vr(t[0])&&wr(t[1])&&_o(t[2])?t:null}function mr(e){let t=typeof e=="string"?parseFloat(e):typeof e=="number"?e:null;return t===null||isNaN(t)?null:t}function wr(e){return Number.isFinite(e)&&e<=90&&e>=-90}function vr(e){return Number.isFinite(e)&&e<=180&&e>=-180}function _o(e){return Number.isFinite(e)&&e>=0&&e<=22}function Tr(e){return typeof e=="string"?e.split(",").map(parseFloat):Array.isArray(e)?e:null}var yr={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 Eo(e={},t){let r=Fr(e.type),n={name:e.attribute,...r};return typeof e.min=="number"&&(n.min=e.min),typeof e.max=="number"&&(n.max=e.max),typeof e.count=="number"&&(n.uniqueValueCount=e.count),e.values&&(n.values=e.values),n.values&&typeof t.maxValues=="number"&&(n.values=n.values?.slice(0,t.maxValues)),n}function Fr(e){let t=e.toLowerCase();return!t||yr[t],yr[t]||{type:"string"}}var Ao="4.4.0-alpha.18",pe={dataType:null,batchType:null,name:"TileJSON",id:"tilejson",module:"pmtiles",version:Ao,worker:!0,extensions:["json"],mimeTypes:["application/json"],text:!0,options:{tilejson:{maxValues:void 0}},parse:async(e,t)=>{let r=new TextDecoder().decode(e),n=JSON.parse(r),o={...pe.options.tilejson,...t?.tilejson};return dt(n,o)},parseTextSync:(e,t)=>{let r=JSON.parse(e),n={...pe.options.tilejson,...t?.tilejson};return dt(r,n)}};var ge={x:0,y:1,z:2};function H(e,t={}){let{start:r=0,end:n=e.length,plane:o="xy"}=t,i=t.size||2,s=0,a=ge[o[0]],l=ge[o[1]];for(let c=r,f=n-i;c<n;c+=i)s+=(e[c+a]-e[f+a])*(e[c+l]+e[f+l]),f=c;return s/2}function gt(e,t,r=2,n,o="xy"){let i=t&&t.length,s=i?t[0]*r:e.length,a=Pr(e,0,s,r,!0,n&&n[0],o),l=[];if(!a||a.next===a.prev)return l;let c,f,u,h,d,p,y;if(i&&(a=No(e,t,a,r,n,o)),e.length>80*r){h=f=e[0],d=u=e[1];for(let I=r;I<s;I+=r)p=e[I],y=e[I+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,r,h,d,c,0),l}function Pr(e,t,r,n,o,i,s){let a,l;i===void 0&&(i=H(e,{start:t,end:r,size:n,plane:s}));let c=ge[s[0]],f=ge[s[1]];if(o===i<0)for(a=t;a<r;a+=n)l=Ir(a,e[a+c],e[a+f],l);else for(a=r-n;a>=t;a-=n)l=Ir(a,e[a+c],e[a+f],l);return l&&je(l,l.next)&&(xe(l),l=l.next),l}function W(e,t){if(!e)return e;t||(t=e);let r=e,n;do if(n=!1,!r.steiner&&(je(r,r.next)||T(r.prev,r,r.next)===0)){if(xe(r),r=t=r.prev,r===r.next)break;n=!0}else r=r.next;while(n||r!==t);return t}function me(e,t,r,n,o,i,s){if(!e)return;!s&&i&&zo(e,n,o,i);let a=e,l,c;for(;e.prev!==e.next;){if(l=e.prev,c=e.next,i?Vo(e,n,o,i):Mo(e)){t.push(l.i/r|0),t.push(e.i/r|0),t.push(c.i/r|0),xe(e),e=c.next,a=c.next;continue}if(e=c,e===a){s?s===1?(e=Co(W(e),t,r),me(e,t,r,n,o,i,2)):s===2&&Uo(e,t,r,n,o,i):me(W(e),t,r,n,o,i,1);break}}}function Mo(e){let t=e.prev,r=e,n=e.next;if(T(t,r,n)>=0)return!1;let o=t.x,i=r.x,s=n.x,a=t.y,l=r.y,c=n.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=n.next;for(;p!==t;){if(p.x>=f&&p.x<=h&&p.y>=u&&p.y<=d&&te(o,a,i,l,s,c,p.x,p.y)&&T(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Vo(e,t,r,n){let o=e.prev,i=e,s=e.next;if(T(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,I=f>u?f>h?f:h:u>h?u:h,D=pt(d,p,t,r,n),v=pt(y,I,t,r,n),m=e.prevZ,g=e.nextZ;for(;m&&m.z>=D&&g&&g.z<=v;){if(m.x>=d&&m.x<=y&&m.y>=p&&m.y<=I&&m!==o&&m!==s&&te(a,f,l,u,c,h,m.x,m.y)&&T(m.prev,m,m.next)>=0||(m=m.prevZ,g.x>=d&&g.x<=y&&g.y>=p&&g.y<=I&&g!==o&&g!==s&&te(a,f,l,u,c,h,g.x,g.y)&&T(g.prev,g,g.next)>=0))return!1;g=g.nextZ}for(;m&&m.z>=D;){if(m.x>=d&&m.x<=y&&m.y>=p&&m.y<=I&&m!==o&&m!==s&&te(a,f,l,u,c,h,m.x,m.y)&&T(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<=I&&g!==o&&g!==s&&te(a,f,l,u,c,h,g.x,g.y)&&T(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function Co(e,t,r){let n=e;do{let o=n.prev,i=n.next.next;!je(o,i)&&br(o,n,n.next,i)&&ye(o,i)&&ye(i,o)&&(t.push(o.i/r|0),t.push(n.i/r|0),t.push(i.i/r|0),xe(n),xe(n.next),n=e=i),n=n.next}while(n!==e);return W(n)}function Uo(e,t,r,n,o,i){let s=e;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&Wo(s,a)){let l=Br(s,a);s=W(s,s.next),l=W(l,l.next),me(s,t,r,n,o,i,0),me(l,t,r,n,o,i,0);return}a=a.next}s=s.next}while(s!==e)}function No(e,t,r,n,o,i){let s=[],a,l,c,f,u;for(a=0,l=t.length;a<l;a++)c=t[a]*n,f=a<l-1?t[a+1]*n:e.length,u=Pr(e,c,f,n,!1,o&&o[a+1],i),u===u.next&&(u.steiner=!0),s.push(Ho(u));for(s.sort(ko),a=0;a<s.length;a++)r=Go(s[a],r);return r}function ko(e,t){return e.x-t.x}function Go(e,t){let r=Oo(e,t);if(!r)return t;let n=Br(r,e);return W(n,n.next),W(r,r.next)}function Oo(e,t){let r=t,n=e.x,o=e.y,i=-1/0,s;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){let h=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(h<=n&&h>i&&(i=h,s=r.x<r.next.x?r:r.next,h===n))return s}r=r.next}while(r!==t);if(!s)return null;let a=s,l=s.x,c=s.y,f=1/0,u;r=s;do n>=r.x&&r.x>=l&&n!==r.x&&te(o<c?n:i,o,l,c,o<c?i:n,o,r.x,r.y)&&(u=Math.abs(o-r.y)/(n-r.x),ye(r,e)&&(u<f||u===f&&(r.x>s.x||r.x===s.x&&jo(s,r)))&&(s=r,f=u)),r=r.next;while(r!==a);return s}function jo(e,t){return T(e.prev,e,t.prev)<0&&T(t.next,e,e.next)<0}function zo(e,t,r,n){let o=e;do o.z===0&&(o.z=pt(o.x,o.y,t,r,n)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next;while(o!==e);o.prevZ.nextZ=null,o.prevZ=null,Ro(o)}function Ro(e){let t,r,n=1,o,i,s,a,l,c;do{for(i=e,e=null,c=null,o=0;i;){for(o++,a=i,s=0,r=0;r<n&&(s++,a=a.nextZ,!!a);r++);for(l=n;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,n*=2}while(o>1);return e}function pt(e,t,r,n,o){return e=(e-r)*o|0,t=(t-n)*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 Ho(e){let t=e,r=e;do(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next;while(t!==e);return r}function te(e,t,r,n,o,i,s,a){return(o-s)*(t-a)>=(e-s)*(i-a)&&(e-s)*(n-a)>=(r-s)*(t-a)&&(r-s)*(i-a)>=(o-s)*(n-a)}function Wo(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Zo(e,t)&&(ye(e,t)&&ye(t,e)&&$o(e,t)&&(T(e.prev,e,t.prev)||T(e,t.prev,t))||je(e,t)&&T(e.prev,e,e.next)>0&&T(t.prev,t,t.next)>0)}function T(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function je(e,t){return e.x===t.x&&e.y===t.y}function br(e,t,r,n){let o=Oe(T(e,t,r)),i=Oe(T(e,t,n)),s=Oe(T(r,n,e)),a=Oe(T(r,n,t));return!!(o!==i&&s!==a||o===0&&Ge(e,r,t)||i===0&&Ge(e,n,t)||s===0&&Ge(r,e,n)||a===0&&Ge(r,t,n))}function Ge(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function Oe(e){return e>0?1:e<0?-1:0}function Zo(e,t){let r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&br(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}function ye(e,t){return T(e.prev,e,e.next)<0?T(e,t,e.next)>=0&&T(e,e.prev,t)>=0:T(e,t,e.prev)<0||T(e,e.next,t)<0}function $o(e,t){let r=e,n=!1,o=(e.x+t.x)/2,i=(e.y+t.y)/2;do r.y>i!=r.next.y>i&&r.next.y!==r.y&&o<(r.next.x-r.x)*(i-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;while(r!==e);return n}function Br(e,t){let r=new we(e.i,e.x,e.y),n=new we(t.i,t.x,t.y),o=e.next,i=t.prev;return e.next=t,t.prev=e,r.next=o,o.prev=r,n.next=r,r.prev=n,i.next=n,n.prev=i,n}function Ir(e,t,r,n){let o=new we(e,t,r);return n?(o.next=n.next,o.prev=n,n.next.prev=o,n.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,r,n){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=t,this.x=r,this.y=n}};function ze(e,t,r){let n=Qo(e),o=Object.keys(n).filter(i=>n[i]!==Array);return qo(e,{propArrayTypes:n,...t},{numericPropKeys:r&&r.numericPropKeys||o,PositionDataType:r?r.PositionDataType:Float32Array,triangulate:r?r.triangulate:!0})}function Qo(e){let t={};for(let r of e)if(r.properties)for(let n in r.properties){let o=r.properties[n];t[n]=ii(o,t[n])}return t}function qo(e,t,r){let{pointPositionsCount:n,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:I=!0}=r,D=e[0]&&"id"in e[0],v=e.length>65535?Uint32Array:Uint16Array,m={type:"Point",positions:new y(n*d),globalFeatureIds:new v(n),featureIds:o>65535?new Uint32Array(n):new Uint16Array(n),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:[]},S={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:[]};I&&(S.triangles=[]);for(let M of[m,g,S])for(let P of p){let _=h[P];M.numericProps[P]=new _(M.positions.length/d)}g.pathIndices[s]=i,S.polygonIndices[c]=l,S.primitivePolygonIndices[f]=l;let U={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let M of e){let P=M.geometry,_=M.properties||{};switch(P.type){case"Point":ei(P,m,U,d,_),m.properties.push(yt(_,p)),D&&m.fields.push({id:M.id}),U.pointFeature++;break;case"LineString":ti(P,g,U,d,_),g.properties.push(yt(_,p)),D&&g.fields.push({id:M.id}),U.lineFeature++;break;case"Polygon":ri(P,S,U,d,_),S.properties.push(yt(_,p)),D&&S.fields.push({id:M.id}),U.polygonFeature++;break;default:throw new Error("Invalid geometry type")}U.feature++}return oi(m,g,S,d)}function ei(e,t,r,n,o){t.positions.set(e.data,r.pointPosition*n);let i=e.data.length/n;xt(t,o,r.pointPosition,i),t.globalFeatureIds.fill(r.feature,r.pointPosition,r.pointPosition+i),t.featureIds.fill(r.pointFeature,r.pointPosition,r.pointPosition+i),r.pointPosition+=i}function ti(e,t,r,n,o){t.positions.set(e.data,r.linePosition*n);let i=e.data.length/n;xt(t,o,r.linePosition,i),t.globalFeatureIds.fill(r.feature,r.linePosition,r.linePosition+i),t.featureIds.fill(r.lineFeature,r.linePosition,r.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[r.linePath++]=r.linePosition,r.linePosition+=(c-l)/n}}function ri(e,t,r,n,o){t.positions.set(e.data,r.polygonPosition*n);let i=e.data.length/n;xt(t,o,r.polygonPosition,i),t.globalFeatureIds.fill(r.feature,r.polygonPosition,r.polygonPosition+i),t.featureIds.fill(r.polygonFeature,r.polygonPosition,r.polygonPosition+i);for(let s=0,a=e.indices.length;s<a;++s){let l=r.polygonPosition;t.polygonIndices[r.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],I=d===p-1?u===void 0?e.data.length:u[0]:f[d+1];t.primitivePolygonIndices[r.polygonRing++]=r.polygonPosition,r.polygonPosition+=(I-y)/n}let h=r.polygonPosition;ni(t,c,f,{startPosition:l,endPosition:h,coordLength:n})}}function ni(e,t,r,{startPosition:n,endPosition:o,coordLength:i}){if(!e.triangles)return;let s=n*i,a=o*i,l=e.positions.subarray(s,a),c=r[0],f=r.slice(1).map(h=>(h-c)/i),u=gt(l,f,i,t);for(let h=0,d=u.length;h<d;++h)e.triangles.push(n+u[h])}function mt(e,t){let r={};for(let n in e)r[n]={value:e[n],size:t};return r}function oi(e,t,r,n){let o={shape:"binary-feature-collection",points:{...e,positions:{value:e.positions,size:n},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:mt(e.numericProps,1)},lines:{...t,positions:{value:t.positions,size:n},pathIndices:{value:t.pathIndices,size:1},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:mt(t.numericProps,1)},polygons:{...r,positions:{value:r.positions,size:n},polygonIndices:{value:r.polygonIndices,size:1},primitivePolygonIndices:{value:r.primitivePolygonIndices,size:1},globalFeatureIds:{value:r.globalFeatureIds,size:1},featureIds:{value:r.featureIds,size:1},numericProps:mt(r.numericProps,1)}};return o.polygons&&r.triangles&&(o.polygons.triangles={value:new Uint32Array(r.triangles),size:1}),o}function xt(e,t,r,n){for(let o in e.numericProps)if(o in t){let i=t[o];e.numericProps[o].fill(i,r,r+n)}}function yt(e,t){let r={};for(let n in e)t.includes(n)||(r[n]=e[n]);return r}function ii(e,t){return t===Array||!Number.isFinite(e)?Array:t===Float64Array||Math.fround(e)!==e?Float64Array:Float32Array}var Pt=Ht(Cr(),1);function Ii(e){let t=0;for(let r=0,n=e.length-1,o,i;r<e.length;n=r++)o=e[r],i=e[n],t+=(i[0]-o[0])*(o[1]+i[1]);return t}function Tt(e,t){if(Array.isArray(e[0])){for(let n of e)Tt(n,t);return}let r=e;r[0]/=t,r[1]/=t}function Ur(e,t){for(let r=0;r<e.length;++r)e[r]/=t}function Ft(e,t,r){if(typeof e[0][0]!="number"){for(let s of e)Ft(s,t,r);return}let n=r*Math.pow(2,t.z),o=r*t.x,i=r*t.y;for(let s=0;s<e.length;s++){let a=e[s];a[0]=(a[0]+o)*360/n-180;let l=180-(a[1]+i)*360/n;a[1]=360/Math.PI*Math.atan(Math.exp(l*Math.PI/180))-90}}function Nr(e,t,r){let{x:n,y:o,z:i}=t,s=r*Math.pow(2,i),a=r*n,l=r*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 kr(e){let t=e.length;if(t<=1)return[e];let r=[],n,o;for(let i=0;i<t;i++){let s=Ii(e[i]);s!==0&&(o===void 0&&(o=s<0),o===s<0?(n&&r.push(n),n=[e[i]]):n&&n.push(e[i]))}return n&&r.push(n),r}function Gr(e){let t=e.indices.length,r="Polygon";if(t<=1)return{type:r,data:e.data,areas:[[H(e.data)]],indices:[e.indices]};let n=[],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=H(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&&(n.push(i),o.push(s)),s=[u],i=[d]):(i.push(d),s.push(u))}return i&&n.push(i),s.length&&o.push(s),{type:r,areas:n,indices:o,data:e.data}}var Z=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;constructor(t,r,n,o,i,s){this.properties={},this.extent=n,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=o,this._values=i,this._geometryInfo=s,t.readFields(Pi,this,r)}toGeoJSONFeature(t,r){let n=this.loadGeometry();switch(t){case"wgs84":return Or(this,n,o=>Ft(o,r,this.extent));default:return Or(this,n,Tt)}}toBinaryFeature(t,r){let n=this.loadFlatGeometry();switch(t){case"wgs84":return this._toBinaryCoordinates(n,o=>Nr(o,r,this.extent));default:return this._toBinaryCoordinates(n,Ur)}}bbox(){let t=this._pbf;t.pos=this._geometry;let r=t.readVarint()+t.pos,n=1,o=0,i=0,s=0,a=1/0,l=-1/0,c=1/0,f=-1/0;for(;t.pos<r;){if(o<=0){let u=t.readVarint();n=u&7,o=u>>3}if(o--,n===1||n===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(n!==7)throw new Error(`unknown command ${n}`)}return[a,c,l,f]}_toBinaryCoordinates(t,r){let n;r(t.data,this.extent);let o=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=t.indices.length,n={type:"Point",...t};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=t.indices.length,this._geometryInfo.linePositionsCount+=t.data.length/o,n={type:"LineString",...t};break;case 3:n=Gr(t),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=n.indices.length;for(let s of n.indices)this._geometryInfo.polygonRingsCount+=s.length;this._geometryInfo.polygonPositionsCount+=n.data.length/o;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let i={type:"Feature",geometry:n,properties:this.properties};return this.id!==null&&(i.id=this.id),i}loadGeometry(){let t=this._pbf;t.pos=this._geometry;let r=t.readVarint()+t.pos,n=1,o=0,i=0,s=0,a=[],l;for(;t.pos<r;){if(o<=0){let c=t.readVarint();n=c&7,o=c>>3}switch(o--,n){case 1:case 2:i+=t.readSVarint(),s+=t.readSVarint(),n===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 ${n}`)}}return l&&a.push(l),a}loadFlatGeometry(){let t=this._pbf;t.pos=this._geometry;let r=t.readVarint()+t.pos,n=1,o,i=0,s=0,a=0,l=0,c=[],f=[];for(;t.pos<r;)if(i<=0&&(o=t.readVarint(),n=o&7,i=o>>3),i--,n===1||n===2)s+=t.readSVarint(),a+=t.readSVarint(),n===1&&c.push(l),f.push(s,a),l+=2;else if(n===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 ${n}`);return{data:f,indices:c}}};Ae(Z,"types",["Unknown","Point","LineString","Polygon"]);function Or(e,t,r){let n=Z.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,r(s,e.extent);break;case 2:for(s=t,o=0;o<s.length;o++)r(s[o],e.extent);break;case 3:for(s=kr(t),o=0;o<s.length;o++)for(i=0;i<s[o].length;i++)r(s[o][i],e.extent);break;default:throw new Error("illegal vector tile type")}s.length===1?s=s[0]:n=`Multi${n}`;let a={type:"Feature",geometry:{type:n,coordinates:s},properties:e.properties};return e.id!==null&&(a.properties||={},a.properties.id=e.id),a}function Pi(e,t,r){t&&r&&(e===1?t.id=r.readVarint():e===2?bi(r,t):e===3?t.type=r.readVarint():e===4&&(t._geometry=r.pos))}function bi(e,t){let r=e.readVarint()+e.pos;for(;e.pos<r;){let n=t._keys[e.readVarint()],o=t._values[e.readVarint()];t.properties[n]=o}}var We=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(t,r){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Bi,this,r),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 r=this._pbf.readVarint()+this._pbf.pos;return new Z(this._pbf,r,this.extent,this._keys,this._values)}getBinaryFeature(t,r){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 Z(this._pbf,n,this.extent,this._keys,this._values,r)}};function Bi(e,t,r){t&&r&&(e===15?t.version=r.readVarint():e===1?t.name=r.readString():e===5?t.extent=r.readVarint():e===2?t._features.push(r.pos):e===3?t._keys.push(r.readString()):e===4&&t._values.push(Si(r)))}function Si(e){let t=null,r=e.readVarint()+e.pos;for(;e.pos<r;){let n=e.readVarint()>>3;t=n===1?e.readString():n===2?e.readFloat():n===3?e.readDouble():n===4?e.readVarint64():n===5?e.readVarint():n===6?e.readSVarint():n===7?e.readBoolean():null}return t}var ve=class{layers;constructor(t,r){this.layers=t.readFields(_i,{},r)}};function _i(e,t,r){if(e===3&&r){let n=new We(r,r.readVarint()+r.pos);n.length&&t&&(t[n.name]=n)}}function bt(e,t){let r=Ai(t),n=t?.gis?.format||t?.mvt?.shape||t?.shape;switch(n){case"columnar-table":return{shape:"columnar-table",data:It(e,r)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:jr(e,r)};case"geojson":return jr(e,r);case"binary-geometry":return It(e,r);case"binary":return It(e,r);default:throw new Error(n||"undefined shape")}}function It(e,t){let[r,n]=Ei(e,t),o=ze(r,n);return o.byteLength=e.byteLength,o}function Ei(e,t){let r=[],n={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[r,n];let o=new ve(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,n),f=Li(c,t,s);r.push(f)}}),[r,n]}function jr(e,t){if(e.byteLength<=0)return[];let r=[],n=new ve(new Pt.default(e));return(Array.isArray(t.layers)?t.layers:Object.keys(n.layers)).forEach(i=>{let s=n.layers[i];if(s)for(let a=0;a<s.length;a++){let l=s.getGeoJSONFeature(a),c=Di(l,t,i);r.push(c)}}),r}function Ai(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&&st.warn('MVTLoader: "options.gis" is deprecated, use "options.mvt.shape" instead')(),e.mvt}function Di(e,t,r){let n=e.toGeoJSONFeature(t.coordinates||"local",t.tileIndex);return t.layerProperty&&(n.properties||={},n.properties[t.layerProperty]=r),n}function Li(e,t,r){let n=e.toBinaryFeature(t.coordinates||"local",t.tileIndex);return t.layerProperty&&n.properties&&(n.properties[t.layerProperty]=r),n}var zr={name:"Mapbox Vector Tile",id:"mvt",module:"mvt",extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],category:"geometry"};var Mi="4.4.0-alpha.18",Rr={...zr,dataType:null,batchType:null,version:Mi,worker:!0,options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:void 0}}},Bt={...Rr,parse:async(e,t)=>bt(e,t),parseSync:bt,binary:!0};var Ze={name:"PMTiles",id:"pmtiles",module:"pmtiles",extensions:["pmtiles"],mimeTypes:["application/octet-stream"],tests:["PMTiles"]};var Pe={};Rt(Pe,{Compression:()=>an,EtagMismatch:()=>Je,FetchSource:()=>un,FileSource:()=>ds,PMTiles:()=>Dt,Protocol:()=>as,ResolvedValueCache:()=>gs,SharedPromiseCache:()=>mn,TileType:()=>ln,bytesToHeader:()=>hn,findTile:()=>fn,getUint64:()=>A,leafletRasterLayer:()=>is,readVarint:()=>ie,tileIdToZxy:()=>us,tileTypeExt:()=>cn,zxyToTileId:()=>sn});var $=Math.pow,F=(e,t,r)=>new Promise((n,o)=>{var i=l=>{try{a(r.next(l))}catch(c){o(c)}},s=l=>{try{a(r.throw(l))}catch(c){o(c)}},a=l=>l.done?n(l.value):Promise.resolve(l.value).then(i,s);a((r=r.apply(e,t)).next())}),B=Uint8Array,se=Uint16Array,Vi=Int32Array,Zr=new B([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]),$r=new B([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]),Ci=new B([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Jr=function(e,t){for(var r=new se(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];for(var o=new Vi(r[30]),n=1;n<30;++n)for(var i=r[n];i<r[n+1];++i)o[i]=i-r[n]<<5|n;return{b:r,r:o}},Kr=Jr(Zr,2),Yr=Kr.b,Ui=Kr.r;Yr[28]=258,Ui[258]=28;var Xr=Jr($r,0),Ni=Xr.b,lc=Xr.r,Et=new se(32768);for(w=0;w<32768;++w)j=(w&43690)>>1|(w&21845)<<1,j=(j&52428)>>2|(j&13107)<<2,j=(j&61680)>>4|(j&3855)<<4,Et[w]=((j&65280)>>8|(j&255)<<8)>>1;var j,w,Fe=function(e,t,r){for(var n=e.length,o=0,i=new se(t);o<n;++o)e[o]&&++i[e[o]-1];var s=new se(t);for(o=1;o<t;++o)s[o]=s[o-1]+i[o-1]<<1;var a;if(r){a=new se(1<<t);var l=15-t;for(o=0;o<n;++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[Et[u]>>l]=c}else for(a=new se(n),o=0;o<n;++o)e[o]&&(a[o]=Et[s[e[o]-1]++]>>15-e[o]);return a},Ie=new B(288);for(w=0;w<144;++w)Ie[w]=8;var w;for(w=144;w<256;++w)Ie[w]=9;var w;for(w=256;w<280;++w)Ie[w]=7;var w;for(w=280;w<288;++w)Ie[w]=8;var w,Qr=new B(32);for(w=0;w<32;++w)Qr[w]=5;var w,ki=Fe(Ie,9,1),Gi=Fe(Qr,5,1),St=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},C=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(t&7)&r},_t=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(t&7)},Oi=function(e){return(e+7)/8|0},ji=function(e,t,r){(t==null||t<0)&&(t=0),(r==null||r>e.length)&&(r=e.length);var n=new B(r-t);return n.set(e.subarray(t,r)),n},zi=["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"],b=function(e,t,r){var n=new Error(t||zi[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,b),!r)throw n;return n},Lt=function(e,t,r,n){var o=e.length,i=n?n.length:0;if(!o||t.f&&!t.l)return r||new B(0);var s=!r||t.i!=2,a=t.i;r||(r=new B(o*3));var l=function(Ot){var jt=r.length;if(Ot>jt){var zt=new B(Math.max(jt*2,Ot));zt.set(r),r=zt}},c=t.f||0,f=t.p||0,u=t.b||0,h=t.l,d=t.d,p=t.m,y=t.n,I=o*8;do{if(!h){c=C(e,f,1);var D=C(e,f+1,3);if(f+=3,D)if(D==1)h=ki,d=Gi,p=9,y=5;else if(D==2){var S=C(e,f,31)+257,U=C(e,f+10,15)+4,M=S+C(e,f+5,31)+1;f+=14;for(var P=new B(M),_=new B(19),E=0;E<U;++E)_[Ci[E]]=C(e,f+E*3,7);f+=U*3;for(var Ct=St(_),Tn=(1<<Ct)-1,Fn=Fe(_,Ct,1),E=0;E<M;){var Ut=Fn[C(e,f,Tn)];f+=Ut&15;var v=Ut>>4;if(v<16)P[E++]=v;else{var K=0,Se=0;for(v==16?(Se=3+C(e,f,3),f+=2,K=P[E-1]):v==17?(Se=3+C(e,f,7),f+=3):v==18&&(Se=11+C(e,f,127),f+=7);Se--;)P[E++]=K}}var Nt=P.subarray(0,S),V=P.subarray(S);p=St(Nt),y=St(V),h=Fe(Nt,p,1),d=Fe(V,y,1)}else b(1);else{var v=Oi(f)+4,m=e[v-4]|e[v-3]<<8,g=v+m;if(g>o){a&&b(0);break}s&&l(u+m),r.set(e.subarray(v,g),u),t.b=u+=m,t.p=f=g*8,t.f=c;continue}if(f>I){a&&b(0);break}}s&&l(u+131072);for(var In=(1<<p)-1,Pn=(1<<y)-1,Ye=f;;Ye=f){var K=h[_t(e,f)&In],Y=K>>4;if(f+=K&15,f>I){a&&b(0);break}if(K||b(2),Y<256)r[u++]=Y;else if(Y==256){Ye=f,h=null;break}else{var kt=Y-254;if(Y>264){var E=Y-257,ae=Zr[E];kt=C(e,f,(1<<ae)-1)+Yr[E],f+=ae}var Xe=d[_t(e,f)&Pn],Qe=Xe>>4;Xe||b(3),f+=Xe&15;var V=Ni[Qe];if(Qe>3){var ae=$r[Qe];V+=_t(e,f)&(1<<ae)-1,f+=ae}if(f>I){a&&b(0);break}s&&l(u+131072);var qe=u+kt;if(u<V){var Gt=i-V,bn=Math.min(V,qe);for(Gt+u<0&&b(3);u<bn;++u)r[u]=n[Gt+u]}for(;u<qe;u+=4)r[u]=r[u-V],r[u+1]=r[u+1-V],r[u+2]=r[u+2-V],r[u+3]=r[u+3-V];u=qe}}t.l=h,t.p=Ye,t.b=u,t.f=c,h&&(c=1,t.m=p,t.d=d,t.n=y)}while(!c);return u==r.length?r:ji(r,0,u)},Ri=new B(0),Hi=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&b(6,"invalid gzip data");var t=e[3],r=10;t&4&&(r+=(e[10]|e[11]<<8)+2);for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[r++]);return r+(t&2)},Wi=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)&&b(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&b(6,"invalid zlib data: "+(e[1]&32?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function $i(e,t){return Lt(e,{i:2},t&&t.out,t&&t.dictionary)}function Ji(e,t){var r=Hi(e);return r+8>e.length&&b(6,"invalid gzip data"),Lt(e.subarray(r,-8),{i:2},t&&t.out||new B(Wi(e)),t&&t.dictionary)}function Ki(e,t){return Lt(e.subarray(Zi(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}function At(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?$i(e,t):Ki(e,t)}var Yi=typeof TextDecoder<"u"&&new TextDecoder,Xi=0;try{Yi.decode(Ri,{stream:!0}),Xi=1}catch{}var qr=(e,t)=>e*$(2,t),Te=(e,t)=>Math.floor(e/$(2,t)),$e=(e,t)=>qr(e.getUint16(t+1,!0),8)+e.getUint8(t),en=(e,t)=>qr(e.getUint32(t+2,!0),16)+e.getUint16(t,!0),Qi=(e,t,r,n,o)=>{if(e!==n.getUint8(o))return e-n.getUint8(o);let i=$e(n,o+1);if(t!==i)return t-i;let s=$e(n,o+4);return r!==s?r-s:0},qi=(e,t,r,n)=>{let o=tn(e,t|128,r,n);return o?{z:t,x:r,y:n,offset:o[0],length:o[1],isDir:!0}:null},Hr=(e,t,r,n)=>{let o=tn(e,t,r,n);return o?{z:t,x:r,y:n,offset:o[0],length:o[1],isDir:!1}:null},tn=(e,t,r,n)=>{let o=0,i=e.byteLength/17-1;for(;o<=i;){let s=i+o>>1,a=Qi(t,r,n,e,s*17);if(a>0)o=s+1;else if(a<0)i=s-1;else return[en(e,s*17+7),e.getUint32(s*17+13,!0)]}return null},es=(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,rn=(e,t)=>{let r=e.getUint8(t*17);return{z:r&127,x:$e(e,t*17+1),y:$e(e,t*17+4),offset:en(e,t*17+7),length:e.getUint32(t*17+13,!0),isDir:r>>7===1}},Wr=e=>{let t=[],r=new DataView(e);for(let n=0;n<r.byteLength/17;n++)t.push(rn(r,n));return ts(t)},ts=e=>{e.sort(es);let t=new ArrayBuffer(17*e.length),r=new Uint8Array(t);for(let n=0;n<e.length;n++){let o=e[n],i=o.z;o.isDir&&(i=i|128),r[n*17]=i,r[n*17+1]=o.x&255,r[n*17+2]=o.x>>8&255,r[n*17+3]=o.x>>16&255,r[n*17+4]=o.y&255,r[n*17+5]=o.y>>8&255,r[n*17+6]=o.y>>16&255,r[n*17+7]=o.offset&255,r[n*17+8]=Te(o.offset,8)&255,r[n*17+9]=Te(o.offset,16)&255,r[n*17+10]=Te(o.offset,24)&255,r[n*17+11]=Te(o.offset,32)&255,r[n*17+12]=Te(o.offset,48)&255,r[n*17+13]=o.length&255,r[n*17+14]=o.length>>8&255,r[n*17+15]=o.length>>16&255,r[n*17+16]=o.length>>24&255}return t},rs=(e,t)=>{if(e.byteLength<17)return null;let r=e.byteLength/17,n=rn(e,r-1);if(n.isDir){let o=n.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 ns(e){return F(this,null,function*(){let t=yield e.getBytes(0,512e3),r=new DataView(t.data),n=r.getUint32(4,!0),o=r.getUint16(8,!0),i=new TextDecoder("utf-8"),s=JSON.parse(i.decode(new DataView(t.data,10,n))),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,I=85;if(s.bounds){let v=s.bounds.split(",");d=+v[0],p=+v[1],y=+v[2],I=+v[3]}if(s.center){let v=s.center.split(",");f=+v[0],u=+v[1],h=+v[2]}return{specVersion:r.getUint16(2,!0),rootDirectoryOffset:10+n,rootDirectoryLength:o*17,jsonMetadataOffset:10,jsonMetadataLength:n,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:I,centerZoom:h,centerLon:f,centerLat:u,etag:t.etag}})}function os(e,t,r,n,o,i,s){return F(this,null,function*(){let a=yield r.getArrayBuffer(t,e.rootDirectoryOffset,e.rootDirectoryLength,e);e.specVersion===1&&(a=Wr(a));let l=Hr(new DataView(a),n,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=At(new Uint8Array(u))),{data:u}}let c=rs(new DataView(a),{z:n,x:o,y:i});if(c){let f=qi(new DataView(a),c.z,c.x,c.y);if(f){let u=yield r.getArrayBuffer(t,f.offset,f.length,e);e.specVersion===1&&(u=Wr(u));let h=Hr(new DataView(u),n,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=At(new Uint8Array(p))),{data:p}}}}})}var nn={getHeader:ns,getZxy:os},is=(e,t)=>{let r=!1,n="",o=L.GridLayer.extend({createTile:(i,s)=>{let a=document.createElement("img"),l=new AbortController,c=l.signal;return a.cancel=()=>{l.abort()},r||(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?n="image/png":f.tileType===3?n="image/jpeg":f.tileType===4?n="image/webp":f.tileType===5&&(n="image/avif")}),r=!0),e.getZxy(i.z,i.x,i.y,c).then(f=>{if(f){let u=new Blob([f.data],{type:n}),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)},ss=e=>(t,r)=>{if(r instanceof AbortController)return e(t,r);let n=new AbortController;return e(t,n).then(o=>r(void 0,o.data,o.cacheControl||"",o.expires||""),o=>r(o)).catch(o=>r(o)),{cancel:()=>n.abort()}},as=class{constructor(e){this.tilev4=(t,r)=>F(this,null,function*(){if(t.type==="json"){let h=t.url.substr(10),d=this.tiles.get(h);if(d||(d=new Dt(h),this.tiles.set(h,d)),this.metadata)return{data:yield d.getTileJson(t.url)};let p=yield d.getHeader();return{data:{tiles:[`${t.url}/{z}/{x}/{y}`],minzoom:p.minZoom,maxzoom:p.maxZoom,bounds:[p.minLon,p.minLat,p.maxLon,p.maxLat]}}}let n=new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/),o=t.url.match(n);if(!o)throw new Error("Invalid PMTiles protocol URL");let i=o[1],s=this.tiles.get(i);s||(s=new Dt(i),this.tiles.set(i,s));let a=o[2],l=o[3],c=o[4],f=yield s.getHeader(),u=yield s?.getZxy(+a,+l,+c,r.signal);return u?{data:new Uint8Array(u.data),cacheControl:u.cacheControl,expires:u.expires}:f.tileType===1?{data:new Uint8Array}:{data:null}}),this.tile=ss(this.tilev4),this.tiles=new Map,this.metadata=e?.metadata||!1}add(e){this.tiles.set(e.source.getKey(),e)}get(e){return this.tiles.get(e)}};function oe(e,t){return(t>>>0)*4294967296+(e>>>0)}function ls(e,t){let r=t.buf,n=r[t.pos++],o=(n&112)>>4;if(n<128||(n=r[t.pos++],o|=(n&127)<<3,n<128)||(n=r[t.pos++],o|=(n&127)<<10,n<128)||(n=r[t.pos++],o|=(n&127)<<17,n<128)||(n=r[t.pos++],o|=(n&127)<<24,n<128)||(n=r[t.pos++],o|=(n&1)<<31,n<128))return oe(e,o);throw new Error("Expected varint not more than 10 bytes")}function ie(e){let t=e.buf,r=t[e.pos++],n=r&127;return r<128||(r=t[e.pos++],n|=(r&127)<<7,r<128)||(r=t[e.pos++],n|=(r&127)<<14,r<128)||(r=t[e.pos++],n|=(r&127)<<21,r<128)?n:(r=t[e.pos],n|=(r&15)<<28,ls(n,e))}function on(e,t,r,n){if(n===0){r===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 cs(e,t){let r=$(2,e),n=t,o=t,i=t,s=[0,0],a=1;for(;a<r;)n=1&i/2,o=1&(i^n),on(a,s,n,o),s[0]+=a*n,s[1]+=a*o,i=i/4,a*=2;return[e,s[0],s[1]]}var fs=[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 sn(e,t,r){if(e>26)throw Error("Tile zoom level exceeds max safe number limit (26)");if(t>$(2,e)-1||r>$(2,e)-1)throw Error("tile x/y outside zoom level bounds");let n=fs[e],o=$(2,e),i=0,s=0,a=0,l=[t,r],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),on(c,l,i,s),c=c/2;return n+a}function us(e){let t=0,r=0;for(let n=0;n<27;n++){let o=(1<<n)*(1<<n);if(t+o>e)return cs(n,e-t);t+=o}throw Error("Tile zoom level exceeds max safe number limit (26)")}var an=(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))(an||{});function Mt(e,t){return F(this,null,function*(){if(t===1||t===0)return e;if(t===2){if(typeof globalThis.DecompressionStream>"u")return At(new Uint8Array(e));let r=new Response(e).body;if(!r)throw Error("Failed to read response stream");let n=r.pipeThrough(new globalThis.DecompressionStream("gzip"));return new Response(n).arrayBuffer()}throw Error("Compression method not supported")})}var ln=(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))(ln||{});function cn(e){return e===1?".mvt":e===2?".png":e===3?".jpg":e===4?".webp":e===5?".avif":""}var hs=127;function fn(e,t){let r=0,n=e.length-1;for(;r<=n;){let o=n+r>>1,i=t-e[o].tileId;if(i>0)r=o+1;else if(i<0)n=o-1;else return e[o]}return n>=0&&(e[n].runLength===0||t-e[n].tileId<e[n].runLength)?e[n]:null}var ds=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()}})}},un=class{constructor(e,t=new Headers){this.url=e,this.customHeaders=t,this.mustReload=!1;let r="";"navigator"in globalThis&&(r=globalThis.navigator.userAgent||"");let n=r.indexOf("Windows")>-1,o=/Chrome|Chromium|Edg|OPR|Brave/.test(r);this.chromeWindowsNoCache=!1,n&&o&&(this.chromeWindowsNoCache=!0)}getKey(){return this.url}setHeaders(e){this.customHeaders=e}getBytes(e,t,r,n){return F(this,null,function*(){let o,i;r?i=r:(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":this.chromeWindowsNoCache&&(a="no-store");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||n&&c&&c!==n)throw this.mustReload=!0,new Je(`Server returned non-matching ETag ${n} after one retry. Check browser extensions and servers for issues that may affect correct ETag headers.`);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 A(e,t){let r=e.getUint32(t+4,!0),n=e.getUint32(t+0,!0);return r*$(2,32)+n}function hn(e,t){let r=new DataView(e),n=r.getUint8(7);if(n>3)throw Error(`Archive is spec version ${n} but this library supports up to spec version 3`);return{specVersion:n,rootDirectoryOffset:A(r,8),rootDirectoryLength:A(r,16),jsonMetadataOffset:A(r,24),jsonMetadataLength:A(r,32),leafDirectoryOffset:A(r,40),leafDirectoryLength:A(r,48),tileDataOffset:A(r,56),tileDataLength:A(r,64),numAddressedTiles:A(r,72),numTileEntries:A(r,80),numTileContents:A(r,88),clustered:r.getUint8(96)===1,internalCompression:r.getUint8(97),tileCompression:r.getUint8(98),tileType:r.getUint8(99),minZoom:r.getUint8(100),maxZoom:r.getUint8(101),minLon:r.getInt32(102,!0)/1e7,minLat:r.getInt32(106,!0)/1e7,maxLon:r.getInt32(110,!0)/1e7,maxLat:r.getInt32(114,!0)/1e7,centerZoom:r.getUint8(118),centerLon:r.getInt32(119,!0)/1e7,centerLat:r.getInt32(123,!0)/1e7,etag:t}}function dn(e){let t={buf:new Uint8Array(e),pos:0},r=ie(t),n=[],o=0;for(let i=0;i<r;i++){let s=ie(t);n.push({tileId:o+s,offset:0,length:0,runLength:1}),o+=s}for(let i=0;i<r;i++)n[i].runLength=ie(t);for(let i=0;i<r;i++)n[i].length=ie(t);for(let i=0;i<r;i++){let s=ie(t);s===0&&i>0?n[i].offset=n[i-1].offset+n[i-1].length:n[i].offset=s-1}return n}function ps(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 Je=class extends Error{};function pn(e,t){return F(this,null,function*(){let r=yield e.getBytes(0,16384);if(new DataView(r.data).getUint16(0,!0)!==19792)throw new Error("Wrong magic number for PMTiles archive");if(ps(r.data)<3)return[yield nn.getHeader(e)];let o=r.data.slice(0,hs),i=hn(o,r.etag),s=r.data.slice(i.rootDirectoryOffset,i.rootDirectoryOffset+i.rootDirectoryLength),a=`${e.getKey()}|${i.etag||""}|${i.rootDirectoryOffset}|${i.rootDirectoryLength}`,l=dn(yield t(s,i.internalCompression));return[i,[a,l.length,l]]})}function gn(e,t,r,n,o){return F(this,null,function*(){let i=yield e.getBytes(r,n,void 0,o.etag),s=yield t(i.data,o.internalCompression),a=dn(s);if(a.length===0)throw new Error("Empty directory is invalid");return a})}var gs=class{constructor(e=100,t=!0,r=Mt){this.cache=new Map,this.maxCacheEntries=e,this.counter=1,this.decompress=r}getHeader(e){return F(this,null,function*(){let t=e.getKey(),r=this.cache.get(t);if(r)return r.lastUsed=this.counter++,r.data;let n=yield pn(e,this.decompress);return n[1]&&this.cache.set(n[1][0],{lastUsed:this.counter++,data:n[1][2]}),this.cache.set(t,{lastUsed:this.counter++,data:n[0]}),this.prune(),n[0]})}getDirectory(e,t,r,n){return F(this,null,function*(){let o=`${e.getKey()}|${n.etag||""}|${t}|${r}`,i=this.cache.get(o);if(i)return i.lastUsed=this.counter++,i.data;let s=yield gn(e,this.decompress,t,r,n);return this.cache.set(o,{lastUsed:this.counter++,data:s}),this.prune(),s})}getArrayBuffer(e,t,r,n){return F(this,null,function*(){let o=`${e.getKey()}|${n.etag||""}|${t}|${r}`,i=this.cache.get(o);if(i)return i.lastUsed=this.counter++,yield i.data;let s=yield e.getBytes(t,r,void 0,n.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((r,n)=>{r.lastUsed<e&&(e=r.lastUsed,t=n)}),t&&this.cache.delete(t)}}invalidate(e){return F(this,null,function*(){this.cache.delete(e.getKey())})}},mn=class{constructor(e=100,t=!0,r=Mt){this.cache=new Map,this.invalidations=new Map,this.maxCacheEntries=e,this.counter=1,this.decompress=r}getHeader(e){return F(this,null,function*(){let t=e.getKey(),r=this.cache.get(t);if(r)return r.lastUsed=this.counter++,yield r.data;let n=new Promise((o,i)=>{pn(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:n}),n})}getDirectory(e,t,r,n){return F(this,null,function*(){let o=`${e.getKey()}|${n.etag||""}|${t}|${r}`,i=this.cache.get(o);if(i)return i.lastUsed=this.counter++,yield i.data;let s=new Promise((a,l)=>{gn(e,this.decompress,t,r,n).then(c=>{a(c),this.prune()}).catch(c=>{l(c)})});return this.cache.set(o,{lastUsed:this.counter++,data:s}),s})}getArrayBuffer(e,t,r,n){return F(this,null,function*(){let o=`${e.getKey()}|${n.etag||""}|${t}|${r}`,i=this.cache.get(o);if(i)return i.lastUsed=this.counter++,yield i.data;let s=new Promise((a,l)=>{e.getBytes(t,r,void 0,n.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((r,n)=>{r.lastUsed<e&&(e=r.lastUsed,t=n)}),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 r=new Promise((n,o)=>{this.getHeader(e).then(i=>{n(),this.invalidations.delete(t)}).catch(i=>{o(i)})});this.invalidations.set(t,r)})}},Dt=class{constructor(e,t,r){typeof e=="string"?this.source=new un(e):this.source=e,r?this.decompress=r:this.decompress=Mt,t?this.cache=t:this.cache=new mn}getHeader(){return F(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(e,t,r,n){return F(this,null,function*(){let o=sn(e,t,r),i=yield this.cache.getHeader(this.source);if(i.specVersion<3)return nn.getZxy(i,this.source,this.cache,e,t,r,n);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=fn(c,o);if(f){if(f.runLength>0){let u=yield this.source.getBytes(i.tileDataOffset+f.offset,f.length,n,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,r,n){return F(this,null,function*(){try{return yield this.getZxyAttempt(e,t,r,n)}catch(o){if(o instanceof Je)return this.cache.invalidate(this.source),yield this.getZxyAttempt(e,t,r,n);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),r=yield this.decompress(t.data,e.internalCompression),n=new TextDecoder("utf-8");return JSON.parse(n.decode(r))})}getMetadata(){return F(this,null,function*(){try{return yield this.getMetadataAttempt()}catch(e){if(e instanceof Je)return this.cache.invalidate(this.source),yield this.getMetadataAttempt();throw e}})}getTileJson(e){return F(this,null,function*(){let t=yield this.getHeader(),r=yield this.getMetadata(),n=cn(t.tileType);return{tilejson:"3.0.0",scheme:"xyz",tiles:[`${e}/{z}/{x}/{y}${n}`],vector_layers:r.vector_layers,attribution:r.attribution,description:r.description,name:r.name,version:r.version,bounds:[t.minLon,t.minLat,t.maxLon,t.maxLat],center:[t.centerLon,t.centerLat,t.centerZoom],minzoom:t.minZoom,maxzoom:t.maxZoom}})}};var{TileType:be}=Pe;function yn(e,t,r,n){let o=null;if(t)try{let a=JSON.stringify(t);o=pe.parseTextSync?.(a,n)||null}catch(a){console.warn("PMTiles metadata could not be interpreted as TileJSON",a)}let i={};typeof o?.name=="string"&&(i.name=o.name),typeof o?.htmlAttribution=="string"&&(i.attributions=[o.htmlAttribution]);let s={...i,format:"pmtiles",formatVersion:e.specVersion,attributions:[],tileMIMEType:ms(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 o&&(s.tilejson=o),r?.includeFormatHeader&&(s.formatHeader=e,s.formatMetadata=s),s}function ms(e){switch(e){case be.Mvt:return"application/vnd.mapbox-vector-tile";case be.Png:return"image/png";case be.Jpeg:return"image/jpeg";case be.Webp:return"image/webp";case be.Avif:return"image/avif";default:return"application/octet-stream"}}var Ke=class{blob;key;constructor(t,r){this.blob=t,this.key=r}getKey(){return this.blob.url||""}async getBytes(t,r,n){return{data:await this.blob.slice(t,t+r).arrayBuffer()}}};var{PMTiles:ys}=Pe,xs="1.0.0",Vt={...Ze,version:xs,type:"pmtiles",fromUrl:!0,fromBlob:!0,defaultOptions:{pmtiles:{}},testURL:e=>e.endsWith(".pmtiles"),createDataSource:(e,t)=>new J(e,t)},J=class extends ee{mimeType=null;pmtiles;metadata;constructor(t,r){super(t,r,Vt.defaultOptions);let n=typeof t=="string"?fe(t):new Ke(t,"pmtiles");this.pmtiles=new ys(n),this.getTileData=this.getTileData.bind(this),this.metadata=this.getMetadata()}async getSchema(){return{fields:[],metadata:{}}}async getMetadata(){let t=await this.pmtiles.getHeader(),r=await this.pmtiles.getMetadata()||{},n=yn(t,r,{includeFormatHeader:!1},this.loadOptions);return this.options.attributions&&(n.attributions=[...this.options.core?.attributions||[],...n.attributions||[]]),n?.tileMIMEType&&(this.mimeType=n?.tileMIMEType),n}async getTile(t){let{x:r,y:n,z:o}=t,s=(await this.pmtiles.getZxy(o,r,n))?.data;return s||null}async getTileData(t){let{x:r,y:n,z:o}=t.index;switch((await this.metadata).tileMIMEType){case"application/vnd.mapbox-vector-tile":return await this.getVectorTile({x:r,y:n,z:o,layers:[]});default:return await this.getImageTile({x:r,y:n,z:o,layers:[]})}}async getImageTile(t){let r=await this.getTile(t);return r?await ht.parse(r,this.loadOptions):null}async getVectorTile(t){let r=await this.getTile(t),n={mvt:{shape:"geojson-table",coordinates:"wgs84",tileIndex:{x:t.x,y:t.y,z:t.z},...this.loadOptions?.mvt},...this.loadOptions};return r?await Bt.parse(r,n):null}};var xn="4.4.0-alpha.18";var vn={...Ze,version:xn,options:{pmtiles:{}},parse:async(e,t)=>wn(new ue(new Blob([e])),t),parseFile:wn};async function wn(e,t){let n=await new J(e.handle,{pmtiles:t?.pmtiles||{}}).getMetadata(),{tileMIMEType:o,tilejson:i={}}=n,{layers:s=[]}=i;switch(o){case"application/vnd.mapbox-vector-tile":return{shape:"vector-source",layers:s.map(a=>({name:a.name,schema:a.schema})),tables:[],formatSpecificMetadata:n};case"image/png":case"image/jpeg":return{shape:"image-source",formatSpecificMetadata:n};default:throw new Error(`PMTilesLoader: Unsupported tile MIME type ${o}`)}}return Ln(Be);})();
8
8
  /*! Bundled license information:
9
9
 
10
10
  ieee754/index.js:
package/dist/index.cjs CHANGED
@@ -234,7 +234,7 @@ var PMTilesTileSource = class extends import_loader_utils.DataSource {
234
234
  var import_loader_utils2 = require("@loaders.gl/loader-utils");
235
235
 
236
236
  // dist/lib/version.js
237
- var VERSION2 = true ? "4.4.0-alpha.16" : "latest";
237
+ var VERSION2 = true ? "4.4.0-alpha.18" : "latest";
238
238
 
239
239
  // dist/pmtiles-loader.js
240
240
  var PMTilesLoader = {
@@ -4,5 +4,5 @@
4
4
  // Version constant cannot be imported, it needs to correspond to the build version of **this** module.
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- export const VERSION = typeof "4.4.0-alpha.16" !== 'undefined' ? "4.4.0-alpha.16" : 'latest';
7
+ export const VERSION = typeof "4.4.0-alpha.18" !== 'undefined' ? "4.4.0-alpha.18" : 'latest';
8
8
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/pmtiles",
3
- "version": "4.4.0-alpha.16",
3
+ "version": "4.4.0-alpha.18",
4
4
  "description": "Framework-independent loader for the pmtiles format",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -46,14 +46,14 @@
46
46
  "build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
47
47
  },
48
48
  "dependencies": {
49
- "@loaders.gl/images": "4.4.0-alpha.16",
50
- "@loaders.gl/loader-utils": "4.4.0-alpha.16",
51
- "@loaders.gl/mvt": "4.4.0-alpha.16",
52
- "@loaders.gl/schema": "4.4.0-alpha.16",
49
+ "@loaders.gl/images": "4.4.0-alpha.18",
50
+ "@loaders.gl/loader-utils": "4.4.0-alpha.18",
51
+ "@loaders.gl/mvt": "4.4.0-alpha.18",
52
+ "@loaders.gl/schema": "4.4.0-alpha.18",
53
53
  "pmtiles": "^3.0.4"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@loaders.gl/core": "4.4.0-alpha.1"
57
57
  },
58
- "gitHead": "d0f42c97a91c1e63727089ec43ed9e229acfe0d6"
58
+ "gitHead": "6f37278ba24a83a68a1a081389eaef2ffac1ff09"
59
59
  }