locar-tiler 0.0.2 → 0.1.2

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/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # locar-tiler
2
+
3
+ Tiled download system for geodata, particularly useful for augmented reality applications.
4
+
5
+ ## Introduction
6
+
7
+ In many geographically-aware applications, including (but not limited to) location-based augmented reality applications, it is useful to be able to download new data as we move around and then store it on the device for later use.
8
+
9
+ `locar-tiler`'s approach is to download data by *tiles*. It works out which tile corresponds to your current latitude and longitude, and then downloads all data for that tile. The tiling system is the Spherical Mercator-based system used by many web maps, such as Google Maps or OpenStreetMap (see [OGC](https://tiles.developer.ogc.org/background.html)). Each tile has an `x` (west-east), `y` (north-south) and `z` (zoom) coordinate.
10
+
11
+ This tiling system is normally used for rendered 2D maps but can also be used for pure data tiles. `locar-tiler` uses it, with a default zoom level of 13 (though this can be changed).
12
+
13
+ Consequently `locar-tiler` needs to be provided with a server URL which accepts `x`, `y` and `z` parameters and serves data fro that tile.
14
+
15
+ Note that `locar-tiler` does not include any mechanism to cache the tiled data - this is up to the developer to do. It merely downloads the tiled data when needed (i.e. the user moves into a new area) and holds it in memory so the data for that tile isn't downloaded if the user revisits that tile in the same session.
16
+
17
+ ## Overview of classes
18
+
19
+ Full API documentation not yet present, but an outline is provided here. Further information can be obtained through the source code.
20
+
21
+ ### LonLat and EastNorth
22
+
23
+ `locar-tiler` includes simple `LonLat` and `EastNorth` classes to represent longitude/latitude and Spherical Mercator coordinates, respectively. The former has `lon` and `lat` attributes, and the latter, `e` and `n` attributes.
24
+
25
+ ### Tile
26
+
27
+ Represents a single xyz tile. Includes these methods:
28
+
29
+ - The constructor takes x, y and z parameters.
30
+ - `getMetresInTile()` - returns the number of Spherical Mercator "metres" in the tile for its zoom level.
31
+ - `getBottomLeft()` - returns the bottom left of the tile in Spherical Mercator coordinates (type `EastNorth`)
32
+ - `getTopRight()` - returns the top right of the tile in Spherical Mercator coordinates (type `EastNorth`).
33
+ - `getIndex()` - returns an index for the tile (a string) in format `z/x/y`.
34
+
35
+ ### DataTile
36
+
37
+ Represents the association of a `Tile` and its data. Interface conaining a `tile` property (type `Tile`) and a `data` property (`any` or `null` for maximum flexibility on the type of data).
38
+
39
+ ### Tiler
40
+
41
+ The `Tiler` class is in charge of downloading tiles when needed and storing them in memory. It is an abstract class so needs to be overridden in concrete implementations. Includes these methods:
42
+
43
+ - The constructor takes the URL of the tile server as a string. You should include the placeholders `{x}`, `{y}` and `{z}` in the URL.
44
+ - `setZoom(z: number)` - updates the zoom.
45
+ - `lonLatToSphMerc(lonLat: LonLat)` - converts a `LonLat` object to an `EastNorth` representing Spherical Mercator coordinates.
46
+ - `getTile(sphMercPos: EastNorth, zoom: number)` - returns the `Tile` containing a given Spherical Mercator position at a given zoom.
47
+ - `update(pos: EastNorth)` - performs an update, downloading new data if necessary. Returns a promise resolving with an array of `DataTile` objects representing the *new* tiles that were loaded. Existing tiles are not returned, making this a good place to implement caching logic.
48
+ - `updateByLonLat(lonLat: LonLat)` - as above but takes a `LonLat` rather than an `EastNorth` as a parameter.
49
+ - `getCurrentTiles()` - returns an array of `DataTile` objects representing the current tile and the eight surrounding tiles.
50
+ - `updateTile(pos: EastNorth)` - returns a new `Tile` object if we move into a new tile, otherwise `null`.
51
+ - `loadTile(tile: Tile)` - loads data associated with a given tile. Returns a promise resolving with a `DataTile` object containing the data associated with that tile.
52
+ - `readTile(url: string)` - *abstract method* to load the data associated with a given tile. The URL will already have `x`, `y` and `z` filled in (it's called from `loadTile()`). Should be overridden in subclasses of `Tiler`.
53
+ - `rawTileToStoredTile(tile: Tile, data: any)`. Converts the raw data downloaded from a tile server into a custom format, returning the result as a `DataTile`. Can be used if we wish to store the tile's data in a format other than the raw format provided by the server. Overridden in `DemTiler` to allow each tile to be stored as a `DEM` object.
54
+
55
+ ### JsonTiler
56
+
57
+ Subclass of `Tiler` to load data from a JSON tile server. It overridden `readTile()` returns a promise resolving with the JSON data downloaded from the server.
58
+
59
+ ### DemTiler
60
+
61
+ Subclass of `Tiler` to load data from a Terrarium PNG-based DEM server. Initially loads the data as raw PNG data but then converts it into a `DEM` object (see below). Overrides `rawTileToStoredTile()` to allow this. Also contains a couple of useful methods:
62
+ - `getElevation(sphMercPos: EastNorth)` - returns the elevation in metres at the given Spherical Mercator coordinates.
63
+ - `getElevationFromLonLat(lonLat: LonLat)` - returns the elevation in metres at the given longitude and latitude.
64
+
65
+ ### DEM
66
+
67
+ Class to represent a Digital Elevation Model. When using `DemTile` the `data` property of the `DataTile`s returned contain a `DEM` object. When using the `DemTiler` the `DEM` objects are created for you, and similarly the `getElevation()` and `getElevationFromLonLat()` methods allow you to obtain the elevation at a given latitude/longitude.
68
+
69
+ Attributes of `DEM` include:
70
+ - `elevs` (an array of the raw elevations. A one-dimensional array, arranged northernmost row to southernmost row).
71
+ - `ptWidth` and `ptHeight` (number of points in the DEM in the horizontal and vertical direction);
72
+ - `xSpacing` and `ySpacing` (the spacing in Spherical Mercator units between points);
73
+ - `bottomLeft` (an `EastNorth` representing the bottom left of the DEM).
74
+
75
+ Methods include:
76
+ - `constructor(elevs: number[], bottomLeft: EastNorth, ptWidth: number, ptHeight: number, xSpacing: number, ySpacing: number)` - call to create a DEM. Initialises the attributes above.
77
+ - `getElevation(x: number, y: number)` - get the elevation at a given Spherical Mercator coordinate, using bilinear interpolation.
78
+
79
+
80
+ ## Based on
81
+
82
+ `locar-tiler` is based on [jsfreemaplib](https://gitlab.com/nickw1/jsfreemaplib), converted to TypeScript and with some API changes made. As author of `jsfreemaplib` I have re-licensed `locar-tiler` under the MIT License to be consistent with other AR.js code.
@@ -16,7 +16,7 @@ export declare class DEM {
16
16
  ySpacing: number;
17
17
  elevs: number[];
18
18
  constructor(elevs: number[], bottomLeft: EastNorth, ptWidth: number, ptHeight: number, xSpacing: number, ySpacing: number);
19
- getHeight(x: number, y: number): number;
19
+ getElevation(x: number, y: number): number;
20
20
  }
21
21
 
22
22
  export declare class DemTiler extends Tiler {
@@ -112,7 +112,7 @@ class ee {
112
112
  const n = await this.readTile(
113
113
  this.url.replace("{x}", e.x.toString()).replace("{y}", e.y.toString()).replace("{z}", e.z.toString())
114
114
  );
115
- return this.dataTiles[t] = n, this.dataTiles[t];
115
+ return this.dataTiles[t] = this.rawTileToStoredTile(e, n), this.dataTiles[t];
116
116
  }
117
117
  return null;
118
118
  }
@@ -642,23 +642,23 @@ class wt {
642
642
  this.offset > this.lastWrittenByte && (this.lastWrittenByte = this.offset);
643
643
  }
644
644
  }
645
- function H(i) {
645
+ function F(i) {
646
646
  let e = i.length;
647
647
  for (; --e >= 0; )
648
648
  i[e] = 0;
649
649
  }
650
650
  const Ce = 3, Ne = 258, ie = 29, De = 256, Me = De + 1 + ie, ne = 30, Le = 512, Be = new Array((Me + 2) * 2);
651
- H(Be);
651
+ F(Be);
652
652
  const $e = new Array(ne * 2);
653
- H($e);
654
- const He = new Array(Le);
655
- H(He);
656
- const Fe = new Array(Ne - Ce + 1);
657
- H(Fe);
653
+ F($e);
654
+ const Fe = new Array(Le);
655
+ F(Fe);
656
+ const He = new Array(Ne - Ce + 1);
657
+ F(He);
658
658
  const We = new Array(ie);
659
- H(We);
659
+ F(We);
660
660
  const Ze = new Array(ne);
661
- H(Ze);
661
+ F(Ze);
662
662
  const ze = (i, e, t, n) => {
663
663
  let a = i & 65535 | 0, s = i >>> 16 & 65535 | 0, l = 0;
664
664
  for (; t !== 0; ) {
@@ -1093,7 +1093,7 @@ const $ = 15, xt = 852, yt = 592, kt = 0, it = 1, Et = 2, si = new Uint16Array([
1093
1093
  }
1094
1094
  return T !== 0 && (a[p + T] = r - U << 24 | 64 << 16 | 0), h.bits = f, 0;
1095
1095
  };
1096
- var F = hi;
1096
+ var H = hi;
1097
1097
  const fi = 0, oe = 1, he = 2, {
1098
1098
  Z_FINISH: At,
1099
1099
  Z_BLOCK: li,
@@ -1106,7 +1106,7 @@ const fi = 0, oe = 1, he = 2, {
1106
1106
  Z_MEM_ERROR: le,
1107
1107
  Z_BUF_ERROR: ui,
1108
1108
  Z_DEFLATED: Tt
1109
- } = se, tt = 16180, mt = 16181, vt = 16182, Ut = 16183, St = 16184, It = 16185, Ot = 16186, Rt = 16187, Ct = 16188, Nt = 16189, Q = 16190, C = 16191, nt = 16192, Dt = 16193, st = 16194, Mt = 16195, Lt = 16196, Bt = 16197, $t = 16198, X = 16199, j = 16200, Ht = 16201, Ft = 16202, Wt = 16203, Zt = 16204, zt = 16205, at = 16206, Pt = 16207, Gt = 16208, v = 16209, ce = 16210, de = 16211, _i = 852, pi = 592, wi = 15, gi = wi, Kt = (i) => (i >>> 24 & 255) + (i >>> 8 & 65280) + ((i & 65280) << 8) + ((i & 255) << 24);
1109
+ } = se, tt = 16180, mt = 16181, vt = 16182, Ut = 16183, St = 16184, It = 16185, Ot = 16186, Rt = 16187, Ct = 16188, Nt = 16189, Q = 16190, C = 16191, nt = 16192, Dt = 16193, st = 16194, Mt = 16195, Lt = 16196, Bt = 16197, $t = 16198, X = 16199, j = 16200, Ft = 16201, Ht = 16202, Wt = 16203, Zt = 16204, zt = 16205, at = 16206, Pt = 16207, Gt = 16208, v = 16209, ce = 16210, de = 16211, _i = 852, pi = 592, wi = 15, gi = wi, Kt = (i) => (i >>> 24 & 255) + (i >>> 8 & 65280) + ((i & 65280) << 8) + ((i & 255) << 24);
1110
1110
  function bi() {
1111
1111
  this.strm = null, this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new Uint16Array(320), this.work = new Uint16Array(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0;
1112
1112
  }
@@ -1152,9 +1152,9 @@ const yi = (i) => {
1152
1152
  i.lens[e++] = 7;
1153
1153
  for (; e < 288; )
1154
1154
  i.lens[e++] = 8;
1155
- for (F(oe, i.lens, 0, 288, rt, 0, i.work, { bits: 9 }), e = 0; e < 32; )
1155
+ for (H(oe, i.lens, 0, 288, rt, 0, i.work, { bits: 9 }), e = 0; e < 32; )
1156
1156
  i.lens[e++] = 5;
1157
- F(he, i.lens, 0, 32, ot, 0, i.work, { bits: 5 }), Yt = !1;
1157
+ H(he, i.lens, 0, 32, ot, 0, i.work, { bits: 5 }), Yt = !1;
1158
1158
  }
1159
1159
  i.lencode = rt, i.lenbits = 9, i.distcode = ot, i.distbits = 5;
1160
1160
  }, ge = (i, e, t, n) => {
@@ -1395,7 +1395,7 @@ const yi = (i) => {
1395
1395
  }
1396
1396
  for (; t.have < 19; )
1397
1397
  t.lens[M[t.have++]] = 0;
1398
- if (t.lencode = t.lendyn, t.lenbits = 7, b = { bits: t.lenbits }, m = F(fi, t.lens, 0, 19, t.lencode, 0, t.work, b), t.lenbits = b.bits, m) {
1398
+ if (t.lencode = t.lendyn, t.lenbits = 7, b = { bits: t.lenbits }, m = H(fi, t.lens, 0, 19, t.lencode, 0, t.work, b), t.lenbits = b.bits, m) {
1399
1399
  i.msg = "invalid code lengths set", t.mode = v;
1400
1400
  break;
1401
1401
  }
@@ -1451,11 +1451,11 @@ const yi = (i) => {
1451
1451
  i.msg = "invalid code -- missing end-of-block", t.mode = v;
1452
1452
  break;
1453
1453
  }
1454
- if (t.lenbits = 9, b = { bits: t.lenbits }, m = F(oe, t.lens, 0, t.nlen, t.lencode, 0, t.work, b), t.lenbits = b.bits, m) {
1454
+ if (t.lenbits = 9, b = { bits: t.lenbits }, m = H(oe, t.lens, 0, t.nlen, t.lencode, 0, t.work, b), t.lenbits = b.bits, m) {
1455
1455
  i.msg = "invalid literal/lengths set", t.mode = v;
1456
1456
  break;
1457
1457
  }
1458
- if (t.distbits = 6, t.distcode = t.distdyn, b = { bits: t.distbits }, m = F(he, t.lens, t.nlen, t.ndist, t.distcode, 0, t.work, b), t.distbits = b.bits, m) {
1458
+ if (t.distbits = 6, t.distcode = t.distdyn, b = { bits: t.distbits }, m = H(he, t.lens, t.nlen, t.ndist, t.distcode, 0, t.work, b), t.distbits = b.bits, m) {
1459
1459
  i.msg = "invalid distances set", t.mode = v;
1460
1460
  break;
1461
1461
  }
@@ -1495,9 +1495,9 @@ const yi = (i) => {
1495
1495
  i.msg = "invalid literal/length code", t.mode = v;
1496
1496
  break;
1497
1497
  }
1498
- t.extra = T & 15, t.mode = Ht;
1498
+ t.extra = T & 15, t.mode = Ft;
1499
1499
  /* falls through */
1500
- case Ht:
1500
+ case Ft:
1501
1501
  if (t.extra) {
1502
1502
  for (k = t.extra; o < k; ) {
1503
1503
  if (h === 0)
@@ -1506,9 +1506,9 @@ const yi = (i) => {
1506
1506
  }
1507
1507
  t.length += r & (1 << t.extra) - 1, r >>>= t.extra, o -= t.extra, t.back += t.extra;
1508
1508
  }
1509
- t.was = t.length, t.mode = Ft;
1509
+ t.was = t.length, t.mode = Ht;
1510
1510
  /* falls through */
1511
- case Ft:
1511
+ case Ht:
1512
1512
  for (; x = t.distcode[r & (1 << t.distbits) - 1], g = x >>> 24, T = x >>> 16 & 255, y = x & 65535, !(g <= o); ) {
1513
1513
  if (h === 0)
1514
1514
  break t;
@@ -1648,9 +1648,9 @@ const be = Object.prototype.toString, {
1648
1648
  Z_OK: Z,
1649
1649
  Z_STREAM_END: ht,
1650
1650
  Z_NEED_DICT: ft,
1651
- Z_STREAM_ERROR: Hi,
1651
+ Z_STREAM_ERROR: Fi,
1652
1652
  Z_DATA_ERROR: Xt,
1653
- Z_MEM_ERROR: Fi
1653
+ Z_MEM_ERROR: Hi
1654
1654
  } = se;
1655
1655
  function z(i) {
1656
1656
  this.options = ae.assign({
@@ -1677,10 +1677,10 @@ z.prototype.push = function(i, e) {
1677
1677
  for (t.avail_out === 0 && (t.output = new Uint8Array(n), t.next_out = 0, t.avail_out = n), s = D.inflate(t, l), s === ft && a && (s = D.inflateSetDictionary(t, a), s === Z ? s = D.inflate(t, l) : s === Xt && (s = ft)); t.avail_in > 0 && s === ht && t.state.wrap > 0 && i[t.next_in] !== 0; )
1678
1678
  D.inflateReset(t), s = D.inflate(t, l);
1679
1679
  switch (s) {
1680
- case Hi:
1680
+ case Fi:
1681
1681
  case Xt:
1682
1682
  case ft:
1683
- case Fi:
1683
+ case Hi:
1684
1684
  return this.onEnd(s), this.ended = !0, !1;
1685
1685
  }
1686
1686
  if (h = t.avail_out, t.next_out && (t.avail_out === 0 || s === ht))
@@ -2342,7 +2342,7 @@ class yn {
2342
2342
  // Based on Footnav code
2343
2343
  // x,y must be in projection of the geometry with scaling factor
2344
2344
  // already applied
2345
- getHeight(e, t) {
2345
+ getElevation(e, t) {
2346
2346
  let n = [e, t], a = Math.floor((n[0] - this.bottomLeft.e) / this.xSpacing), s = this.ptHeight - Math.ceil((n[1] - this.bottomLeft.n) / this.ySpacing), l, h, _, r, o, w, d, f = Number.NEGATIVE_INFINITY;
2347
2347
  if (a >= 0 && s >= 0 && a < this.ptWidth - 1 && s < this.ptHeight - 1) {
2348
2348
  r = this.elevs[s * this.ptWidth + a], o = this.elevs[s * this.ptWidth + a + 1], w = this.elevs[s * this.ptWidth + a + this.ptWidth], d = this.elevs[s * this.ptWidth + a + this.ptWidth + 1], l = this.bottomLeft[0] + a * this.xSpacing, l + this.xSpacing, h = this.bottomLeft[1] + (this.ptHeight - 1 - s) * this.ySpacing, _ = h - this.ySpacing;
@@ -2367,7 +2367,7 @@ class kn extends ee {
2367
2367
  }
2368
2368
  getElevation(e) {
2369
2369
  const t = this.getTile(e, this.tile.z), n = this.dataTiles[`${t.z}/${t.x}/${t.y}`];
2370
- return n ? n.getHeight(e[0], e[1]) : Number.NEGATIVE_INFINITY;
2370
+ return n ? n.getElevation(e[0], e[1]) : Number.NEGATIVE_INFINITY;
2371
2371
  }
2372
2372
  getElevationFromLonLat(e) {
2373
2373
  return this.getElevation(this.sphMerc.project(e));
@@ -1 +1 @@
1
- (function(I,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(I=typeof globalThis<"u"?globalThis:I||self,O(I["locar-tiler"]={}))})(this,(function(I){"use strict";class O{static EARTH=4007501668e-2;static HALF_EARTH=2003750834e-2}class W{x;y;z;constructor(e,t,n){this.x=e,this.y=t,this.z=n}getMetresInTile(){return O.EARTH/Math.pow(2,this.z)}getBottomLeft(){var e=this.getMetresInTile();return{e:this.x*e-O.HALF_EARTH,n:O.HALF_EARTH-(this.y+1)*e}}getTopRight(){var e=this.getBottomLeft(),t=this.getMetresInTile();return e.e+=t,e.n+=t,e}getIndex(){return`${this.z}/${this.x}/${this.y}`}}class xt{project(e){return{e:this.#t(e.lon),n:this.#e(e.lat)}}unproject(e){return{lon:this.#i(e[0]),lat:this.#n(e[1])}}#t(e){return e/180*O.HALF_EARTH}#e(e){var t=Math.log(Math.tan((90+e)*Math.PI/360))/(Math.PI/180);return t*O.HALF_EARTH/180}#i(e){return e/O.HALF_EARTH*180}#n(e){var t=e/O.HALF_EARTH*180;return t=180/Math.PI*(2*Math.atan(Math.exp(t*Math.PI/180))-Math.PI/2),t}getTile(e,t){var n=new W(-1,-1,t),a=n.getMetresInTile();return n.x=Math.floor((O.HALF_EARTH+e.e)/a),n.y=Math.floor((O.HALF_EARTH-e.n)/a),n}getTileFromLonLat(e,t){return this.getTile(this.project(e),t)}getID(){return"epsg:3857"}}class it{tile;url;sphMerc;dataTiles;constructor(e){this.tile=new W(0,0,13),this.url=e,this.sphMerc=new xt,this.dataTiles=new Map}setZoom(e){this.tile.z=e}lonLatToSphMerc(e){return this.sphMerc.project(e)}getTile(e,t){return this.sphMerc.getTile(e,t)}async update(e){const t=[];let n=null;if(n=this.updateTile(e)){this.tile=n;const a=[n.x,n.x-1,n.x+1],s=[n.y,n.y-1,n.y+1];for(let l=0;l<a.length;l++)for(let h=0;h<s.length;h++){const _=new W(a[l],s[h],n.z),r=await this.loadTile(_);r!==null&&t.push({data:r.data,tile:_})}}return t}async updateByLonLat(e){return this.update(this.lonLatToSphMerc(e))}getCurrentTiles(){const e=[],t=[this.tile.x,this.tile.x-1,this.tile.x+1],n=[this.tile.y,this.tile.y-1,this.tile.y+1];for(let a=0;a<t.length;a++)for(let s=0;s<n.length;s++){const l=new W(t[a],n[s],this.tile.z),h=this.dataTiles[l.getIndex()];h!==null&&e.push({data:h,tile:l})}return e}updateTile(e){if(this.tile){const t=this.sphMerc.getTile(e,this.tile.z);return t.x!=this.tile.x||t.y!=this.tile.y?t:null}return null}async loadTile(e){const t=e.getIndex();if(this.dataTiles[t]===void 0){const n=await this.readTile(this.url.replace("{x}",e.x.toString()).replace("{y}",e.y.toString()).replace("{z}",e.z.toString()));return this.dataTiles[t]=n,this.dataTiles[t]}return null}async getData(e,t=13){await this.update(e);const n=this.sphMerc.getTile(e,t);return this.dataTiles[`${t}/${n.x}/${n.y}`]}rawTileToStoredTile(e,t){return{tile:e,data:t}}}function yt(i,e="utf8"){return new TextDecoder(e).decode(i)}const Oe=new TextEncoder;function Re(i){return Oe.encode(i)}const Ce=1024*8,Ne=(()=>{const i=new Uint8Array(4),e=new Uint32Array(i.buffer);return!((e[0]=1)&i[0])})(),nt={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array};class st{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(e=Ce,t={}){let n=!1;typeof e=="number"?e=new ArrayBuffer(e):(n=!0,this.lastWrittenByte=e.byteLength);const a=t.offset?t.offset>>>0:0,s=e.byteLength-a;let l=a;(ArrayBuffer.isView(e)||e instanceof st)&&(e.byteLength!==e.buffer.byteLength&&(l=e.byteOffset+a),e=e.buffer),n?this.lastWrittenByte=s:this.lastWrittenByte=0,this.buffer=e,this.length=s,this.byteLength=s,this.byteOffset=l,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,l,s),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const e=this._marks.pop();if(e===void 0)throw new Error("Mark stack empty");return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){const n=(this.offset+e)*2,a=new Uint8Array(n);a.set(new Uint8Array(this.buffer)),this.buffer=a.buffer,this.length=n,this.byteLength=n,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){return this.readArray(e,"uint8")}readArray(e,t){const n=nt[t].BYTES_PER_ELEMENT*e,a=this.byteOffset+this.offset,s=this.buffer.slice(a,a+n);if(this.littleEndian===Ne&&t!=="uint8"&&t!=="int8"){const h=new Uint8Array(this.buffer.slice(a,a+n));h.reverse();const _=new nt[t](h.buffer);return this.offset+=n,_.reverse(),_}const l=new nt[t](s);return this.offset+=n,l}readInt16(){const e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){const e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){const e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){const e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){const e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){const e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){const e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){const e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let t="";for(let n=0;n<e;n++)t+=this.readChar();return t}readUtf8(e=1){return yt(this.readBytes(e))}decodeText(e=1,t="utf8"){return yt(this.readBytes(e),t)}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let t=0;t<e.length;t++)this._data.setUint8(this.offset++,e[t]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(e){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(e){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let t=0;t<e.length;t++)this.writeUint8(e.charCodeAt(t));return this}writeUtf8(e){return this.writeBytes(Re(e))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}function H(i){let e=i.length;for(;--e>=0;)i[e]=0}const De=3,Me=258,kt=29,Le=256+1+kt,Et=30,Be=512,$e=new Array((Le+2)*2);H($e);const He=new Array(Et*2);H(He);const Fe=new Array(Be);H(Fe);const We=new Array(Me-De+1);H(We);const Ze=new Array(kt);H(Ze);const ze=new Array(Et);H(ze);var at=(i,e,t,n)=>{let a=i&65535|0,s=i>>>16&65535|0,l=0;for(;t!==0;){l=t>2e3?2e3:t,t-=l;do a=a+e[n++]|0,s=s+a|0;while(--l);a%=65521,s%=65521}return a|s<<16|0};const Pe=()=>{let i,e=[];for(var t=0;t<256;t++){i=t;for(var n=0;n<8;n++)i=i&1?3988292384^i>>>1:i>>>1;e[t]=i}return e},Ge=new Uint32Array(Pe());var N=(i,e,t,n)=>{const a=Ge,s=n+t;i^=-1;for(let l=n;l<s;l++)i=i>>>8^a[(i^e[l])&255];return i^-1},rt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},At={Z_NO_FLUSH:0,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFLATED:8};const Ke=(i,e)=>Object.prototype.hasOwnProperty.call(i,e);var Ye=function(i){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const t=e.shift();if(t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(const n in t)Ke(t,n)&&(i[n]=t[n])}}return i},Xe=i=>{let e=0;for(let n=0,a=i.length;n<a;n++)e+=i[n].length;const t=new Uint8Array(e);for(let n=0,a=0,s=i.length;n<s;n++){let l=i[n];t.set(l,a),a+=l.length}return t},Tt={assign:Ye,flattenChunks:Xe};let mt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{mt=!1}const Z=new Uint8Array(256);for(let i=0;i<256;i++)Z[i]=i>=252?6:i>=248?5:i>=240?4:i>=224?3:i>=192?2:1;Z[254]=Z[254]=1;var je=i=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(i);let e,t,n,a,s,l=i.length,h=0;for(a=0;a<l;a++)t=i.charCodeAt(a),(t&64512)===55296&&a+1<l&&(n=i.charCodeAt(a+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),a++)),h+=t<128?1:t<2048?2:t<65536?3:4;for(e=new Uint8Array(h),s=0,a=0;s<h;a++)t=i.charCodeAt(a),(t&64512)===55296&&a+1<l&&(n=i.charCodeAt(a+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),a++)),t<128?e[s++]=t:t<2048?(e[s++]=192|t>>>6,e[s++]=128|t&63):t<65536?(e[s++]=224|t>>>12,e[s++]=128|t>>>6&63,e[s++]=128|t&63):(e[s++]=240|t>>>18,e[s++]=128|t>>>12&63,e[s++]=128|t>>>6&63,e[s++]=128|t&63);return e};const Ve=(i,e)=>{if(e<65534&&i.subarray&&mt)return String.fromCharCode.apply(null,i.length===e?i:i.subarray(0,e));let t="";for(let n=0;n<e;n++)t+=String.fromCharCode(i[n]);return t};var qe=(i,e)=>{const t=e||i.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(i.subarray(0,e));let n,a;const s=new Array(t*2);for(a=0,n=0;n<t;){let l=i[n++];if(l<128){s[a++]=l;continue}let h=Z[l];if(h>4){s[a++]=65533,n+=h-1;continue}for(l&=h===2?31:h===3?15:7;h>1&&n<t;)l=l<<6|i[n++]&63,h--;if(h>1){s[a++]=65533;continue}l<65536?s[a++]=l:(l-=65536,s[a++]=55296|l>>10&1023,s[a++]=56320|l&1023)}return Ve(s,a)},Je=(i,e)=>{e=e||i.length,e>i.length&&(e=i.length);let t=e-1;for(;t>=0&&(i[t]&192)===128;)t--;return t<0||t===0?e:t+Z[i[t]]>e?t:e},ot={string2buf:je,buf2string:qe,utf8border:Je};function Qe(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var ti=Qe;const K=16209,ei=16191;var ii=function(e,t){let n,a,s,l,h,_,r,o,w,d,f,u,U,x,g,T,y,c,E,S,p,m,A,b;const k=e.state;n=e.next_in,A=e.input,a=n+(e.avail_in-5),s=e.next_out,b=e.output,l=s-(t-e.avail_out),h=s+(e.avail_out-257),_=k.dmax,r=k.wsize,o=k.whave,w=k.wnext,d=k.window,f=k.hold,u=k.bits,U=k.lencode,x=k.distcode,g=(1<<k.lenbits)-1,T=(1<<k.distbits)-1;t:do{u<15&&(f+=A[n++]<<u,u+=8,f+=A[n++]<<u,u+=8),y=U[f&g];e:for(;;){if(c=y>>>24,f>>>=c,u-=c,c=y>>>16&255,c===0)b[s++]=y&65535;else if(c&16){E=y&65535,c&=15,c&&(u<c&&(f+=A[n++]<<u,u+=8),E+=f&(1<<c)-1,f>>>=c,u-=c),u<15&&(f+=A[n++]<<u,u+=8,f+=A[n++]<<u,u+=8),y=x[f&T];i:for(;;){if(c=y>>>24,f>>>=c,u-=c,c=y>>>16&255,c&16){if(S=y&65535,c&=15,u<c&&(f+=A[n++]<<u,u+=8,u<c&&(f+=A[n++]<<u,u+=8)),S+=f&(1<<c)-1,S>_){e.msg="invalid distance too far back",k.mode=K;break t}if(f>>>=c,u-=c,c=s-l,S>c){if(c=S-c,c>o&&k.sane){e.msg="invalid distance too far back",k.mode=K;break t}if(p=0,m=d,w===0){if(p+=r-c,c<E){E-=c;do b[s++]=d[p++];while(--c);p=s-S,m=b}}else if(w<c){if(p+=r+w-c,c-=w,c<E){E-=c;do b[s++]=d[p++];while(--c);if(p=0,w<E){c=w,E-=c;do b[s++]=d[p++];while(--c);p=s-S,m=b}}}else if(p+=w-c,c<E){E-=c;do b[s++]=d[p++];while(--c);p=s-S,m=b}for(;E>2;)b[s++]=m[p++],b[s++]=m[p++],b[s++]=m[p++],E-=3;E&&(b[s++]=m[p++],E>1&&(b[s++]=m[p++]))}else{p=s-S;do b[s++]=b[p++],b[s++]=b[p++],b[s++]=b[p++],E-=3;while(E>2);E&&(b[s++]=b[p++],E>1&&(b[s++]=b[p++]))}}else if((c&64)===0){y=x[(y&65535)+(f&(1<<c)-1)];continue i}else{e.msg="invalid distance code",k.mode=K;break t}break}}else if((c&64)===0){y=U[(y&65535)+(f&(1<<c)-1)];continue e}else if(c&32){k.mode=ei;break t}else{e.msg="invalid literal/length code",k.mode=K;break t}break}}while(n<a&&s<h);E=u>>3,n-=E,u-=E<<3,f&=(1<<u)-1,e.next_in=n,e.next_out=s,e.avail_in=n<a?5+(a-n):5-(n-a),e.avail_out=s<h?257+(h-s):257-(s-h),k.hold=f,k.bits=u};const F=15,vt=852,Ut=592,St=0,ht=1,It=2,ni=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),si=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),ai=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),ri=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var z=(i,e,t,n,a,s,l,h)=>{const _=h.bits;let r=0,o=0,w=0,d=0,f=0,u=0,U=0,x=0,g=0,T=0,y,c,E,S,p,m=null,A;const b=new Uint16Array(F+1),k=new Uint16Array(F+1);let $=null,Ie,tt,et;for(r=0;r<=F;r++)b[r]=0;for(o=0;o<n;o++)b[e[t+o]]++;for(f=_,d=F;d>=1&&b[d]===0;d--);if(f>d&&(f=d),d===0)return a[s++]=1<<24|64<<16|0,a[s++]=1<<24|64<<16|0,h.bits=1,0;for(w=1;w<d&&b[w]===0;w++);for(f<w&&(f=w),x=1,r=1;r<=F;r++)if(x<<=1,x-=b[r],x<0)return-1;if(x>0&&(i===St||d!==1))return-1;for(k[1]=0,r=1;r<F;r++)k[r+1]=k[r]+b[r];for(o=0;o<n;o++)e[t+o]!==0&&(l[k[e[t+o]]++]=o);if(i===St?(m=$=l,A=20):i===ht?(m=ni,$=si,A=257):(m=ai,$=ri,A=0),T=0,o=0,r=w,p=s,u=f,U=0,E=-1,g=1<<f,S=g-1,i===ht&&g>vt||i===It&&g>Ut)return 1;for(;;){Ie=r-U,l[o]+1<A?(tt=0,et=l[o]):l[o]>=A?(tt=$[l[o]-A],et=m[l[o]-A]):(tt=96,et=0),y=1<<r-U,c=1<<u,w=c;do c-=y,a[p+(T>>U)+c]=Ie<<24|tt<<16|et|0;while(c!==0);for(y=1<<r-1;T&y;)y>>=1;if(y!==0?(T&=y-1,T+=y):T=0,o++,--b[r]===0){if(r===d)break;r=e[t+l[o]]}if(r>f&&(T&S)!==E){for(U===0&&(U=f),p+=w,u=r-U,x=1<<u;u+U<d&&(x-=b[u+U],!(x<=0));)u++,x<<=1;if(g+=1<<u,i===ht&&g>vt||i===It&&g>Ut)return 1;E=T&S,a[E]=f<<24|u<<16|p-s|0}}return T!==0&&(a[p+T]=r-U<<24|64<<16|0),h.bits=f,0};const oi=0,Ot=1,Rt=2,{Z_FINISH:Ct,Z_BLOCK:hi,Z_TREES:Y,Z_OK:L,Z_STREAM_END:fi,Z_NEED_DICT:li,Z_STREAM_ERROR:C,Z_DATA_ERROR:Nt,Z_MEM_ERROR:Dt,Z_BUF_ERROR:ci,Z_DEFLATED:Mt}=At,X=16180,Lt=16181,Bt=16182,$t=16183,Ht=16184,Ft=16185,Wt=16186,Zt=16187,zt=16188,Pt=16189,j=16190,D=16191,ft=16192,Gt=16193,lt=16194,Kt=16195,Yt=16196,Xt=16197,jt=16198,V=16199,q=16200,Vt=16201,qt=16202,Jt=16203,Qt=16204,te=16205,ct=16206,ee=16207,ie=16208,v=16209,ne=16210,se=16211,di=852,ui=592,_i=15,ae=i=>(i>>>24&255)+(i>>>8&65280)+((i&65280)<<8)+((i&255)<<24);function pi(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const B=i=>{if(!i)return 1;const e=i.state;return!e||e.strm!==i||e.mode<X||e.mode>se?1:0},re=i=>{if(B(i))return C;const e=i.state;return i.total_in=i.total_out=e.total=0,i.msg="",e.wrap&&(i.adler=e.wrap&1),e.mode=X,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(di),e.distcode=e.distdyn=new Int32Array(ui),e.sane=1,e.back=-1,L},oe=i=>{if(B(i))return C;const e=i.state;return e.wsize=0,e.whave=0,e.wnext=0,re(i)},he=(i,e)=>{let t;if(B(i))return C;const n=i.state;return e<0?(t=0,e=-e):(t=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?C:(n.window!==null&&n.wbits!==e&&(n.window=null),n.wrap=t,n.wbits=e,oe(i))},fe=(i,e)=>{if(!i)return C;const t=new pi;i.state=t,t.strm=i,t.window=null,t.mode=X;const n=he(i,e);return n!==L&&(i.state=null),n},wi=i=>fe(i,_i);let le=!0,dt,ut;const gi=i=>{if(le){dt=new Int32Array(512),ut=new Int32Array(32);let e=0;for(;e<144;)i.lens[e++]=8;for(;e<256;)i.lens[e++]=9;for(;e<280;)i.lens[e++]=7;for(;e<288;)i.lens[e++]=8;for(z(Ot,i.lens,0,288,dt,0,i.work,{bits:9}),e=0;e<32;)i.lens[e++]=5;z(Rt,i.lens,0,32,ut,0,i.work,{bits:5}),le=!1}i.lencode=dt,i.lenbits=9,i.distcode=ut,i.distbits=5},ce=(i,e,t,n)=>{let a;const s=i.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(e.subarray(t-s.wsize,t),0),s.wnext=0,s.whave=s.wsize):(a=s.wsize-s.wnext,a>n&&(a=n),s.window.set(e.subarray(t-n,t-n+a),s.wnext),n-=a,n?(s.window.set(e.subarray(t-n,t),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=a,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=a))),0},bi=(i,e)=>{let t,n,a,s,l,h,_,r,o,w,d,f,u,U,x=0,g,T,y,c,E,S,p,m;const A=new Uint8Array(4);let b,k;const $=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(B(i)||!i.output||!i.input&&i.avail_in!==0)return C;t=i.state,t.mode===D&&(t.mode=ft),l=i.next_out,a=i.output,_=i.avail_out,s=i.next_in,n=i.input,h=i.avail_in,r=t.hold,o=t.bits,w=h,d=_,m=L;t:for(;;)switch(t.mode){case X:if(t.wrap===0){t.mode=ft;break}for(;o<16;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if(t.wrap&2&&r===35615){t.wbits===0&&(t.wbits=15),t.check=0,A[0]=r&255,A[1]=r>>>8&255,t.check=N(t.check,A,2,0),r=0,o=0,t.mode=Lt;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((r&255)<<8)+(r>>8))%31){i.msg="incorrect header check",t.mode=v;break}if((r&15)!==Mt){i.msg="unknown compression method",t.mode=v;break}if(r>>>=4,o-=4,p=(r&15)+8,t.wbits===0&&(t.wbits=p),p>15||p>t.wbits){i.msg="invalid window size",t.mode=v;break}t.dmax=1<<t.wbits,t.flags=0,i.adler=t.check=1,t.mode=r&512?Pt:D,r=0,o=0;break;case Lt:for(;o<16;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if(t.flags=r,(t.flags&255)!==Mt){i.msg="unknown compression method",t.mode=v;break}if(t.flags&57344){i.msg="unknown header flags set",t.mode=v;break}t.head&&(t.head.text=r>>8&1),t.flags&512&&t.wrap&4&&(A[0]=r&255,A[1]=r>>>8&255,t.check=N(t.check,A,2,0)),r=0,o=0,t.mode=Bt;case Bt:for(;o<32;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}t.head&&(t.head.time=r),t.flags&512&&t.wrap&4&&(A[0]=r&255,A[1]=r>>>8&255,A[2]=r>>>16&255,A[3]=r>>>24&255,t.check=N(t.check,A,4,0)),r=0,o=0,t.mode=$t;case $t:for(;o<16;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}t.head&&(t.head.xflags=r&255,t.head.os=r>>8),t.flags&512&&t.wrap&4&&(A[0]=r&255,A[1]=r>>>8&255,t.check=N(t.check,A,2,0)),r=0,o=0,t.mode=Ht;case Ht:if(t.flags&1024){for(;o<16;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}t.length=r,t.head&&(t.head.extra_len=r),t.flags&512&&t.wrap&4&&(A[0]=r&255,A[1]=r>>>8&255,t.check=N(t.check,A,2,0)),r=0,o=0}else t.head&&(t.head.extra=null);t.mode=Ft;case Ft:if(t.flags&1024&&(f=t.length,f>h&&(f=h),f&&(t.head&&(p=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(n.subarray(s,s+f),p)),t.flags&512&&t.wrap&4&&(t.check=N(t.check,n,f,s)),h-=f,s+=f,t.length-=f),t.length))break t;t.length=0,t.mode=Wt;case Wt:if(t.flags&2048){if(h===0)break t;f=0;do p=n[s+f++],t.head&&p&&t.length<65536&&(t.head.name+=String.fromCharCode(p));while(p&&f<h);if(t.flags&512&&t.wrap&4&&(t.check=N(t.check,n,f,s)),h-=f,s+=f,p)break t}else t.head&&(t.head.name=null);t.length=0,t.mode=Zt;case Zt:if(t.flags&4096){if(h===0)break t;f=0;do p=n[s+f++],t.head&&p&&t.length<65536&&(t.head.comment+=String.fromCharCode(p));while(p&&f<h);if(t.flags&512&&t.wrap&4&&(t.check=N(t.check,n,f,s)),h-=f,s+=f,p)break t}else t.head&&(t.head.comment=null);t.mode=zt;case zt:if(t.flags&512){for(;o<16;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if(t.wrap&4&&r!==(t.check&65535)){i.msg="header crc mismatch",t.mode=v;break}r=0,o=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),i.adler=t.check=0,t.mode=D;break;case Pt:for(;o<32;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}i.adler=t.check=ae(r),r=0,o=0,t.mode=j;case j:if(t.havedict===0)return i.next_out=l,i.avail_out=_,i.next_in=s,i.avail_in=h,t.hold=r,t.bits=o,li;i.adler=t.check=1,t.mode=D;case D:if(e===hi||e===Y)break t;case ft:if(t.last){r>>>=o&7,o-=o&7,t.mode=ct;break}for(;o<3;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}switch(t.last=r&1,r>>>=1,o-=1,r&3){case 0:t.mode=Gt;break;case 1:if(gi(t),t.mode=V,e===Y){r>>>=2,o-=2;break t}break;case 2:t.mode=Yt;break;case 3:i.msg="invalid block type",t.mode=v}r>>>=2,o-=2;break;case Gt:for(r>>>=o&7,o-=o&7;o<32;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if((r&65535)!==(r>>>16^65535)){i.msg="invalid stored block lengths",t.mode=v;break}if(t.length=r&65535,r=0,o=0,t.mode=lt,e===Y)break t;case lt:t.mode=Kt;case Kt:if(f=t.length,f){if(f>h&&(f=h),f>_&&(f=_),f===0)break t;a.set(n.subarray(s,s+f),l),h-=f,s+=f,_-=f,l+=f,t.length-=f;break}t.mode=D;break;case Yt:for(;o<14;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if(t.nlen=(r&31)+257,r>>>=5,o-=5,t.ndist=(r&31)+1,r>>>=5,o-=5,t.ncode=(r&15)+4,r>>>=4,o-=4,t.nlen>286||t.ndist>30){i.msg="too many length or distance symbols",t.mode=v;break}t.have=0,t.mode=Xt;case Xt:for(;t.have<t.ncode;){for(;o<3;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}t.lens[$[t.have++]]=r&7,r>>>=3,o-=3}for(;t.have<19;)t.lens[$[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,b={bits:t.lenbits},m=z(oi,t.lens,0,19,t.lencode,0,t.work,b),t.lenbits=b.bits,m){i.msg="invalid code lengths set",t.mode=v;break}t.have=0,t.mode=jt;case jt:for(;t.have<t.nlen+t.ndist;){for(;x=t.lencode[r&(1<<t.lenbits)-1],g=x>>>24,T=x>>>16&255,y=x&65535,!(g<=o);){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if(y<16)r>>>=g,o-=g,t.lens[t.have++]=y;else{if(y===16){for(k=g+2;o<k;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if(r>>>=g,o-=g,t.have===0){i.msg="invalid bit length repeat",t.mode=v;break}p=t.lens[t.have-1],f=3+(r&3),r>>>=2,o-=2}else if(y===17){for(k=g+3;o<k;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}r>>>=g,o-=g,p=0,f=3+(r&7),r>>>=3,o-=3}else{for(k=g+7;o<k;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}r>>>=g,o-=g,p=0,f=11+(r&127),r>>>=7,o-=7}if(t.have+f>t.nlen+t.ndist){i.msg="invalid bit length repeat",t.mode=v;break}for(;f--;)t.lens[t.have++]=p}}if(t.mode===v)break;if(t.lens[256]===0){i.msg="invalid code -- missing end-of-block",t.mode=v;break}if(t.lenbits=9,b={bits:t.lenbits},m=z(Ot,t.lens,0,t.nlen,t.lencode,0,t.work,b),t.lenbits=b.bits,m){i.msg="invalid literal/lengths set",t.mode=v;break}if(t.distbits=6,t.distcode=t.distdyn,b={bits:t.distbits},m=z(Rt,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,b),t.distbits=b.bits,m){i.msg="invalid distances set",t.mode=v;break}if(t.mode=V,e===Y)break t;case V:t.mode=q;case q:if(h>=6&&_>=258){i.next_out=l,i.avail_out=_,i.next_in=s,i.avail_in=h,t.hold=r,t.bits=o,ii(i,d),l=i.next_out,a=i.output,_=i.avail_out,s=i.next_in,n=i.input,h=i.avail_in,r=t.hold,o=t.bits,t.mode===D&&(t.back=-1);break}for(t.back=0;x=t.lencode[r&(1<<t.lenbits)-1],g=x>>>24,T=x>>>16&255,y=x&65535,!(g<=o);){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if(T&&(T&240)===0){for(c=g,E=T,S=y;x=t.lencode[S+((r&(1<<c+E)-1)>>c)],g=x>>>24,T=x>>>16&255,y=x&65535,!(c+g<=o);){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}r>>>=c,o-=c,t.back+=c}if(r>>>=g,o-=g,t.back+=g,t.length=y,T===0){t.mode=te;break}if(T&32){t.back=-1,t.mode=D;break}if(T&64){i.msg="invalid literal/length code",t.mode=v;break}t.extra=T&15,t.mode=Vt;case Vt:if(t.extra){for(k=t.extra;o<k;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}t.length+=r&(1<<t.extra)-1,r>>>=t.extra,o-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=qt;case qt:for(;x=t.distcode[r&(1<<t.distbits)-1],g=x>>>24,T=x>>>16&255,y=x&65535,!(g<=o);){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if((T&240)===0){for(c=g,E=T,S=y;x=t.distcode[S+((r&(1<<c+E)-1)>>c)],g=x>>>24,T=x>>>16&255,y=x&65535,!(c+g<=o);){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}r>>>=c,o-=c,t.back+=c}if(r>>>=g,o-=g,t.back+=g,T&64){i.msg="invalid distance code",t.mode=v;break}t.offset=y,t.extra=T&15,t.mode=Jt;case Jt:if(t.extra){for(k=t.extra;o<k;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}t.offset+=r&(1<<t.extra)-1,r>>>=t.extra,o-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){i.msg="invalid distance too far back",t.mode=v;break}t.mode=Qt;case Qt:if(_===0)break t;if(f=d-_,t.offset>f){if(f=t.offset-f,f>t.whave&&t.sane){i.msg="invalid distance too far back",t.mode=v;break}f>t.wnext?(f-=t.wnext,u=t.wsize-f):u=t.wnext-f,f>t.length&&(f=t.length),U=t.window}else U=a,u=l-t.offset,f=t.length;f>_&&(f=_),_-=f,t.length-=f;do a[l++]=U[u++];while(--f);t.length===0&&(t.mode=q);break;case te:if(_===0)break t;a[l++]=t.length,_--,t.mode=q;break;case ct:if(t.wrap){for(;o<32;){if(h===0)break t;h--,r|=n[s++]<<o,o+=8}if(d-=_,i.total_out+=d,t.total+=d,t.wrap&4&&d&&(i.adler=t.check=t.flags?N(t.check,a,d,l-d):at(t.check,a,d,l-d)),d=_,t.wrap&4&&(t.flags?r:ae(r))!==t.check){i.msg="incorrect data check",t.mode=v;break}r=0,o=0}t.mode=ee;case ee:if(t.wrap&&t.flags){for(;o<32;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if(t.wrap&4&&r!==(t.total&4294967295)){i.msg="incorrect length check",t.mode=v;break}r=0,o=0}t.mode=ie;case ie:m=fi;break t;case v:m=Nt;break t;case ne:return Dt;case se:default:return C}return i.next_out=l,i.avail_out=_,i.next_in=s,i.avail_in=h,t.hold=r,t.bits=o,(t.wsize||d!==i.avail_out&&t.mode<v&&(t.mode<ct||e!==Ct))&&ce(i,i.output,i.next_out,d-i.avail_out),w-=i.avail_in,d-=i.avail_out,i.total_in+=w,i.total_out+=d,t.total+=d,t.wrap&4&&d&&(i.adler=t.check=t.flags?N(t.check,a,d,i.next_out-d):at(t.check,a,d,i.next_out-d)),i.data_type=t.bits+(t.last?64:0)+(t.mode===D?128:0)+(t.mode===V||t.mode===lt?256:0),(w===0&&d===0||e===Ct)&&m===L&&(m=ci),m},xi=i=>{if(B(i))return C;let e=i.state;return e.window&&(e.window=null),i.state=null,L},yi=(i,e)=>{if(B(i))return C;const t=i.state;return(t.wrap&2)===0?C:(t.head=e,e.done=!1,L)},ki=(i,e)=>{const t=e.length;let n,a,s;return B(i)||(n=i.state,n.wrap!==0&&n.mode!==j)?C:n.mode===j&&(a=1,a=at(a,e,t,0),a!==n.check)?Nt:(s=ce(i,e,t,t),s?(n.mode=ne,Dt):(n.havedict=1,L))};var Ei=oe,Ai=he,Ti=re,mi=wi,vi=fe,Ui=bi,Si=xi,Ii=yi,Oi=ki,Ri="pako inflate (from Nodeca project)",M={inflateReset:Ei,inflateReset2:Ai,inflateResetKeep:Ti,inflateInit:mi,inflateInit2:vi,inflate:Ui,inflateEnd:Si,inflateGetHeader:Ii,inflateSetDictionary:Oi,inflateInfo:Ri};function Ci(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Ni=Ci;const de=Object.prototype.toString,{Z_NO_FLUSH:Di,Z_FINISH:Mi,Z_OK:P,Z_STREAM_END:_t,Z_NEED_DICT:pt,Z_STREAM_ERROR:Li,Z_DATA_ERROR:ue,Z_MEM_ERROR:Bi}=At;function G(i){this.options=Tt.assign({chunkSize:1024*64,windowBits:15,to:""},i||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(i&&i.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ti,this.strm.avail_out=0;let t=M.inflateInit2(this.strm,e.windowBits);if(t!==P)throw new Error(rt[t]);if(this.header=new Ni,M.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=ot.string2buf(e.dictionary):de.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=M.inflateSetDictionary(this.strm,e.dictionary),t!==P)))throw new Error(rt[t])}G.prototype.push=function(i,e){const t=this.strm,n=this.options.chunkSize,a=this.options.dictionary;let s,l,h;if(this.ended)return!1;for(e===~~e?l=e:l=e===!0?Mi:Di,de.call(i)==="[object ArrayBuffer]"?t.input=new Uint8Array(i):t.input=i,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(n),t.next_out=0,t.avail_out=n),s=M.inflate(t,l),s===pt&&a&&(s=M.inflateSetDictionary(t,a),s===P?s=M.inflate(t,l):s===ue&&(s=pt));t.avail_in>0&&s===_t&&t.state.wrap>0&&i[t.next_in]!==0;)M.inflateReset(t),s=M.inflate(t,l);switch(s){case Li:case ue:case pt:case Bi:return this.onEnd(s),this.ended=!0,!1}if(h=t.avail_out,t.next_out&&(t.avail_out===0||s===_t))if(this.options.to==="string"){let _=ot.utf8border(t.output,t.next_out),r=t.next_out-_,o=ot.buf2string(t.output,_);t.next_out=r,t.avail_out=n-r,r&&t.output.set(t.output.subarray(_,_+r),0),this.onData(o)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(s===P&&h===0)){if(s===_t)return s=M.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(t.avail_in===0)break}}return!0},G.prototype.onData=function(i){this.chunks.push(i)},G.prototype.onEnd=function(i){i===P&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Tt.flattenChunks(this.chunks)),this.chunks=[],this.err=i,this.msg=this.strm.msg};function $i(i,e){const t=new G(e);if(t.push(i),t.err)throw t.msg||rt[t.err];return t.result}var Hi=G,Fi=$i,Wi={Inflate:Hi,inflate:Fi};const{Inflate:Zi,inflate:zi}=Wi;var _e=Zi,Pi=zi;const pe=[];for(let i=0;i<256;i++){let e=i;for(let t=0;t<8;t++)e&1?e=3988292384^e>>>1:e=e>>>1;pe[i]=e}const we=4294967295;function Gi(i,e,t){let n=i;for(let a=0;a<t;a++)n=pe[(n^e[a])&255]^n>>>8;return n}function Ki(i,e){return(Gi(we,i,e)^we)>>>0}function ge(i,e,t){const n=i.readUint32(),a=Ki(new Uint8Array(i.buffer,i.byteOffset+i.offset-e-4,e),e);if(a!==n)throw new Error(`CRC mismatch for chunk ${t}. Expected ${n}, found ${a}`)}function be(i,e,t){for(let n=0;n<t;n++)e[n]=i[n]}function xe(i,e,t,n){let a=0;for(;a<n;a++)e[a]=i[a];for(;a<t;a++)e[a]=i[a]+e[a-n]&255}function ye(i,e,t,n){let a=0;if(t.length===0)for(;a<n;a++)e[a]=i[a];else for(;a<n;a++)e[a]=i[a]+t[a]&255}function ke(i,e,t,n,a){let s=0;if(t.length===0){for(;s<a;s++)e[s]=i[s];for(;s<n;s++)e[s]=i[s]+(e[s-a]>>1)&255}else{for(;s<a;s++)e[s]=i[s]+(t[s]>>1)&255;for(;s<n;s++)e[s]=i[s]+(e[s-a]+t[s]>>1)&255}}function Ee(i,e,t,n,a){let s=0;if(t.length===0){for(;s<a;s++)e[s]=i[s];for(;s<n;s++)e[s]=i[s]+e[s-a]&255}else{for(;s<a;s++)e[s]=i[s]+t[s]&255;for(;s<n;s++)e[s]=i[s]+Yi(e[s-a],t[s],t[s-a])&255}}function Yi(i,e,t){const n=i+e-t,a=Math.abs(n-i),s=Math.abs(n-e),l=Math.abs(n-t);return a<=s&&a<=l?i:s<=l?e:t}function Xi(i,e,t,n,a,s){switch(i){case 0:be(e,t,a);break;case 1:xe(e,t,a,s);break;case 2:ye(e,t,n,a);break;case 3:ke(e,t,n,a,s);break;case 4:Ee(e,t,n,a,s);break;default:throw new Error(`Unsupported filter: ${i}`)}}const ji=new Uint16Array([255]),Vi=new Uint8Array(ji.buffer)[0]===255;function qi(i){const{data:e,width:t,height:n,channels:a,depth:s}=i,l=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],h=Math.ceil(s/8)*a,_=new Uint8Array(n*t*h);let r=0;for(let o=0;o<7;o++){const w=l[o],d=Math.ceil((t-w.x)/w.xStep),f=Math.ceil((n-w.y)/w.yStep);if(d<=0||f<=0)continue;const u=d*h,U=new Uint8Array(u);for(let x=0;x<f;x++){const g=e[r++],T=e.subarray(r,r+u);r+=u;const y=new Uint8Array(u);Xi(g,T,y,U,u,h),U.set(y);for(let c=0;c<d;c++){const E=w.x+c*w.xStep,S=w.y+x*w.yStep;if(!(E>=t||S>=n))for(let p=0;p<h;p++)_[(S*t+E)*h+p]=y[c*h+p]}}}if(s===16){const o=new Uint16Array(_.buffer);if(Vi)for(let w=0;w<o.length;w++)o[w]=Ji(o[w]);return o}else return _}function Ji(i){return(i&255)<<8|i>>8&255}const Qi=new Uint16Array([255]),tn=new Uint8Array(Qi.buffer)[0]===255,en=new Uint8Array(0);function Ae(i){const{data:e,width:t,height:n,channels:a,depth:s}=i,l=Math.ceil(s/8)*a,h=Math.ceil(s/8*a*t),_=new Uint8Array(n*h);let r=en,o=0,w,d;for(let f=0;f<n;f++){switch(w=e.subarray(o+1,o+1+h),d=_.subarray(f*h,(f+1)*h),e[o]){case 0:be(w,d,h);break;case 1:xe(w,d,h,l);break;case 2:ye(w,d,r,h);break;case 3:ke(w,d,r,h,l);break;case 4:Ee(w,d,r,h,l);break;default:throw new Error(`Unsupported filter: ${e[o]}`)}r=d,o+=h+1}if(s===16){const f=new Uint16Array(_.buffer);if(tn)for(let u=0;u<f.length;u++)f[u]=nn(f[u]);return f}else return _}function nn(i){return(i&255)<<8|i>>8&255}const J=Uint8Array.of(137,80,78,71,13,10,26,10);function Te(i){if(!sn(i.readBytes(J.length)))throw new Error("wrong PNG signature")}function sn(i){if(i.length<J.length)return!1;for(let e=0;e<J.length;e++)if(i[e]!==J[e])return!1;return!0}const an="tEXt",rn=0,me=new TextDecoder("latin1");function on(i){if(fn(i),i.length===0||i.length>79)throw new Error("keyword length must be between 1 and 79")}const hn=/^[\u0000-\u00FF]*$/;function fn(i){if(!hn.test(i))throw new Error("invalid latin1 text")}function ln(i,e,t){const n=ve(e);i[n]=cn(e,t-n.length-1)}function ve(i){for(i.mark();i.readByte()!==rn;);const e=i.offset;i.reset();const t=me.decode(i.readBytes(e-i.offset-1));return i.skip(1),on(t),t}function cn(i,e){return me.decode(i.readBytes(e))}const R={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},wt={UNKNOWN:-1,DEFLATE:0},Ue={UNKNOWN:-1,ADAPTIVE:0},gt={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},Q={NONE:0,BACKGROUND:1,PREVIOUS:2},bt={SOURCE:0,OVER:1};class dn extends st{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;constructor(e,t={}){super(e);const{checkCrc:n=!1}=t;this._checkCrc=n,this._inflator=new _e,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array(0),this._compressionMethod=wt.UNKNOWN,this._filterMethod=Ue.UNKNOWN,this._interlaceMethod=gt.UNKNOWN,this._colorType=R.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(Te(this);!this._end;){const e=this.readUint32(),t=this.readChars(4);this.decodeChunk(e,t)}return this.decodeImage(),this._png}decodeApng(){for(Te(this);!this._end;){const e=this.readUint32(),t=this.readChars(4);this.decodeApngChunk(e,t)}return this.decodeApngImage(),this._apng}decodeChunk(e,t){const n=this.offset;switch(t){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(e);break;case"IDAT":this.decodeIDAT(e);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(e);break;case"iCCP":this.decodeiCCP(e);break;case an:ln(this._png.text,this,e);break;case"pHYs":this.decodepHYs();break;default:this.skip(e);break}if(this.offset-n!==e)throw new Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?ge(this,e+4,t):this.skip(4)}decodeApngChunk(e,t){const n=this.offset;switch(t!=="fdAT"&&t!=="IDAT"&&this._writingDataChunks&&this.pushDataToFrame(),t){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(e);break;default:this.decodeChunk(e,t),this.offset=n+e;break}if(this.offset-n!==e)throw new Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?ge(this,e+4,t):this.skip(4)}decodeIHDR(){const e=this._png;e.width=this.readUint32(),e.height=this.readUint32(),e.depth=un(this.readUint8());const t=this.readUint8();this._colorType=t;let n;switch(t){case R.GREYSCALE:n=1;break;case R.TRUECOLOUR:n=3;break;case R.INDEXED_COLOUR:n=1;break;case R.GREYSCALE_ALPHA:n=2;break;case R.TRUECOLOUR_ALPHA:n=4;break;case R.UNKNOWN:default:throw new Error(`Unknown color type: ${t}`)}if(this._png.channels=n,this._compressionMethod=this.readUint8(),this._compressionMethod!==wt.DEFLATE)throw new Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){const e={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array(0)};this._frames.push(e)}decodePLTE(e){if(e%3!==0)throw new RangeError(`PLTE field length must be a multiple of 3. Got ${e}`);const t=e/3;this._hasPalette=!0;const n=[];this._palette=n;for(let a=0;a<t;a++)n.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(e){this._writingDataChunks=!0;const t=e,n=this.offset+this.byteOffset;if(this._inflator.push(new Uint8Array(this.buffer,n,t)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(e)}decodeFDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;if(n+=4,t-=4,this._inflator.push(new Uint8Array(this.buffer,n,t)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(e)}decodetRNS(e){switch(this._colorType){case R.GREYSCALE:case R.TRUECOLOUR:{if(e%2!==0)throw new RangeError(`tRNS chunk length must be a multiple of 2. Got ${e}`);if(e/2>this._png.width*this._png.height)throw new Error(`tRNS chunk contains more alpha values than there are pixels (${e/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(e/2);for(let t=0;t<e/2;t++)this._transparency[t]=this.readUint16();break}case R.INDEXED_COLOUR:{if(e>this._palette.length)throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${e} vs ${this._palette.length})`);let t=0;for(;t<e;t++){const n=this.readByte();this._palette[t].push(n)}for(;t<this._palette.length;t++)this._palette[t].push(255);break}case R.UNKNOWN:case R.GREYSCALE_ALPHA:case R.TRUECOLOUR_ALPHA:default:throw new Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(e){const t=ve(this),n=this.readUint8();if(n!==wt.DEFLATE)throw new Error(`Unsupported iCCP compression method: ${n}`);const a=this.readBytes(e-t.length-2);this._png.iccEmbeddedProfile={name:t,profile:Pi(a)}}decodepHYs(){const e=this.readUint32(),t=this.readUint32(),n=this.readByte();this._png.resolution={x:e,y:t,unit:n}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let e=0;e<this._numberOfFrames;e++){const t={sequenceNumber:this._frames[e].sequenceNumber,delayNumber:this._frames[e].delayNumber,delayDenominator:this._frames[e].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},n=this._frames.at(e);if(n){if(n.data=Ae({data:n.data,width:n.width,height:n.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),e===0||n.xOffset===0&&n.yOffset===0&&n.width===this._png.width&&n.height===this._png.height)t.data=n.data;else{const a=this._apng.frames.at(e-1);this.disposeFrame(n,a,t),this.addFrameDataToCanvas(t,n)}this._apng.frames.push(t)}}return this._apng}disposeFrame(e,t,n){switch(e.disposeOp){case Q.NONE:break;case Q.BACKGROUND:for(let a=0;a<this._png.height;a++)for(let s=0;s<this._png.width;s++){const l=(a*e.width+s)*this._png.channels;for(let h=0;h<this._png.channels;h++)n.data[l+h]=0}break;case Q.PREVIOUS:n.data.set(t.data);break;default:throw new Error("Unknown disposeOp")}}addFrameDataToCanvas(e,t){const n=1<<this._png.depth,a=(s,l)=>{const h=((s+t.yOffset)*this._png.width+t.xOffset+l)*this._png.channels,_=(s*t.width+l)*this._png.channels;return{index:h,frameIndex:_}};switch(t.blendOp){case bt.SOURCE:for(let s=0;s<t.height;s++)for(let l=0;l<t.width;l++){const{index:h,frameIndex:_}=a(s,l);for(let r=0;r<this._png.channels;r++)e.data[h+r]=t.data[_+r]}break;case bt.OVER:for(let s=0;s<t.height;s++)for(let l=0;l<t.width;l++){const{index:h,frameIndex:_}=a(s,l);for(let r=0;r<this._png.channels;r++){const o=t.data[_+this._png.channels-1]/n,w=r%(this._png.channels-1)===0?1:t.data[_+r],d=Math.floor(o*w+(1-o)*e.data[h+r]);e.data[h+r]+=d}}break;default:throw new Error("Unknown blendOp")}}decodeImage(){if(this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);const e=this._isAnimated?(this._frames?.at(0)).data:this._inflator.result;if(this._filterMethod!==Ue.ADAPTIVE)throw new Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===gt.NO_INTERLACE)this._png.data=Ae({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===gt.ADAM7)this._png.data=qi({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw new Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){const e=this._inflator.result,t=this._frames.at(-1);t?t.data=e:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:Q.NONE,blendOp:bt.SOURCE,data:e}),this._inflator=new _e,this._writingDataChunks=!1}}function un(i){if(i!==1&&i!==2&&i!==4&&i!==8&&i!==16)throw new Error(`invalid bit depth: ${i}`);return i}function _n(i,e){return new dn(i,e).decode()}class Se{bottomLeft;ptWidth;ptHeight;xSpacing;ySpacing;elevs;constructor(e,t,n,a,s,l){this.bottomLeft=t,this.ptWidth=n,this.ptHeight=a,this.elevs=e,this.xSpacing=s,this.ySpacing=l}getHeight(e,t){let n=[e,t],a=Math.floor((n[0]-this.bottomLeft.e)/this.xSpacing),s=this.ptHeight-Math.ceil((n[1]-this.bottomLeft.n)/this.ySpacing),l,h,_,r,o,w,d,f=Number.NEGATIVE_INFINITY;if(a>=0&&s>=0&&a<this.ptWidth-1&&s<this.ptHeight-1){r=this.elevs[s*this.ptWidth+a],o=this.elevs[s*this.ptWidth+a+1],w=this.elevs[s*this.ptWidth+a+this.ptWidth],d=this.elevs[s*this.ptWidth+a+this.ptWidth+1],l=this.bottomLeft[0]+a*this.xSpacing,l+this.xSpacing,h=this.bottomLeft[1]+(this.ptHeight-1-s)*this.ySpacing,_=h-this.ySpacing;let u=(n[0]-l)/this.xSpacing,U=r*(1-u)+o*u,x=w*(1-u)+d*u,g=(n[1]-_)/this.ySpacing;f=x*(1-g)+U*g}return f}}class pn extends it{constructor(e){super(e)}async readTile(e){const n=await(await fetch(e)).arrayBuffer(),a=_n(n);let s,l=0;const h=new Array(a.width*a.height);for(let _=0;_<a.height;_++)for(let r=0;r<a.width;r++)s=(_*a.width+r)*a.channels,h[l++]=Math.round(a.data[s]*256+a.data[s+1]+a.data[s+2]/256-32768);return{w:a.width,h:a.height,elevs:h}}getElevation(e){const t=this.getTile(e,this.tile.z),n=this.dataTiles[`${t.z}/${t.x}/${t.y}`];return n?n.getHeight(e[0],e[1]):Number.NEGATIVE_INFINITY}getElevationFromLonLat(e){return this.getElevation(this.sphMerc.project(e))}rawTileToStoredTile(e,t){const n=e.getTopRight(),a=e.getBottomLeft(),s=(n.e-a.e)/(t.w-1),l=(n.n-a.n)/(t.h-1),h=new Se(t.elevs,a,t.w,t.h,s,l);return{tile:e,data:h}}}class wn extends it{constructor(e){super(e)}async readTile(e){return await(await fetch(e)).json()}}class gn{e;n;constructor(e,t){this.e=e,this.n=t}}class bn{lon;lat;constructor(e,t){this.lon=e,this.lat=t}}I.Constants=O,I.DEM=Se,I.DemTiler=pn,I.EastNorth=gn,I.JsonTiler=wn,I.LonLat=bn,I.SphMercProjection=xt,I.Tile=W,I.Tiler=it,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(I,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(I=typeof globalThis<"u"?globalThis:I||self,O(I["locar-tiler"]={}))})(this,(function(I){"use strict";class O{static EARTH=4007501668e-2;static HALF_EARTH=2003750834e-2}class W{x;y;z;constructor(e,t,n){this.x=e,this.y=t,this.z=n}getMetresInTile(){return O.EARTH/Math.pow(2,this.z)}getBottomLeft(){var e=this.getMetresInTile();return{e:this.x*e-O.HALF_EARTH,n:O.HALF_EARTH-(this.y+1)*e}}getTopRight(){var e=this.getBottomLeft(),t=this.getMetresInTile();return e.e+=t,e.n+=t,e}getIndex(){return`${this.z}/${this.x}/${this.y}`}}class xt{project(e){return{e:this.#t(e.lon),n:this.#e(e.lat)}}unproject(e){return{lon:this.#i(e[0]),lat:this.#n(e[1])}}#t(e){return e/180*O.HALF_EARTH}#e(e){var t=Math.log(Math.tan((90+e)*Math.PI/360))/(Math.PI/180);return t*O.HALF_EARTH/180}#i(e){return e/O.HALF_EARTH*180}#n(e){var t=e/O.HALF_EARTH*180;return t=180/Math.PI*(2*Math.atan(Math.exp(t*Math.PI/180))-Math.PI/2),t}getTile(e,t){var n=new W(-1,-1,t),a=n.getMetresInTile();return n.x=Math.floor((O.HALF_EARTH+e.e)/a),n.y=Math.floor((O.HALF_EARTH-e.n)/a),n}getTileFromLonLat(e,t){return this.getTile(this.project(e),t)}getID(){return"epsg:3857"}}class it{tile;url;sphMerc;dataTiles;constructor(e){this.tile=new W(0,0,13),this.url=e,this.sphMerc=new xt,this.dataTiles=new Map}setZoom(e){this.tile.z=e}lonLatToSphMerc(e){return this.sphMerc.project(e)}getTile(e,t){return this.sphMerc.getTile(e,t)}async update(e){const t=[];let n=null;if(n=this.updateTile(e)){this.tile=n;const a=[n.x,n.x-1,n.x+1],s=[n.y,n.y-1,n.y+1];for(let l=0;l<a.length;l++)for(let h=0;h<s.length;h++){const _=new W(a[l],s[h],n.z),r=await this.loadTile(_);r!==null&&t.push({data:r.data,tile:_})}}return t}async updateByLonLat(e){return this.update(this.lonLatToSphMerc(e))}getCurrentTiles(){const e=[],t=[this.tile.x,this.tile.x-1,this.tile.x+1],n=[this.tile.y,this.tile.y-1,this.tile.y+1];for(let a=0;a<t.length;a++)for(let s=0;s<n.length;s++){const l=new W(t[a],n[s],this.tile.z),h=this.dataTiles[l.getIndex()];h!==null&&e.push({data:h,tile:l})}return e}updateTile(e){if(this.tile){const t=this.sphMerc.getTile(e,this.tile.z);return t.x!=this.tile.x||t.y!=this.tile.y?t:null}return null}async loadTile(e){const t=e.getIndex();if(this.dataTiles[t]===void 0){const n=await this.readTile(this.url.replace("{x}",e.x.toString()).replace("{y}",e.y.toString()).replace("{z}",e.z.toString()));return this.dataTiles[t]=this.rawTileToStoredTile(e,n),this.dataTiles[t]}return null}async getData(e,t=13){await this.update(e);const n=this.sphMerc.getTile(e,t);return this.dataTiles[`${t}/${n.x}/${n.y}`]}rawTileToStoredTile(e,t){return{tile:e,data:t}}}function yt(i,e="utf8"){return new TextDecoder(e).decode(i)}const Oe=new TextEncoder;function Re(i){return Oe.encode(i)}const Ce=1024*8,Ne=(()=>{const i=new Uint8Array(4),e=new Uint32Array(i.buffer);return!((e[0]=1)&i[0])})(),nt={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array};class st{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(e=Ce,t={}){let n=!1;typeof e=="number"?e=new ArrayBuffer(e):(n=!0,this.lastWrittenByte=e.byteLength);const a=t.offset?t.offset>>>0:0,s=e.byteLength-a;let l=a;(ArrayBuffer.isView(e)||e instanceof st)&&(e.byteLength!==e.buffer.byteLength&&(l=e.byteOffset+a),e=e.buffer),n?this.lastWrittenByte=s:this.lastWrittenByte=0,this.buffer=e,this.length=s,this.byteLength=s,this.byteOffset=l,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,l,s),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const e=this._marks.pop();if(e===void 0)throw new Error("Mark stack empty");return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){const n=(this.offset+e)*2,a=new Uint8Array(n);a.set(new Uint8Array(this.buffer)),this.buffer=a.buffer,this.length=n,this.byteLength=n,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){return this.readArray(e,"uint8")}readArray(e,t){const n=nt[t].BYTES_PER_ELEMENT*e,a=this.byteOffset+this.offset,s=this.buffer.slice(a,a+n);if(this.littleEndian===Ne&&t!=="uint8"&&t!=="int8"){const h=new Uint8Array(this.buffer.slice(a,a+n));h.reverse();const _=new nt[t](h.buffer);return this.offset+=n,_.reverse(),_}const l=new nt[t](s);return this.offset+=n,l}readInt16(){const e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){const e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){const e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){const e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){const e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){const e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){const e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){const e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let t="";for(let n=0;n<e;n++)t+=this.readChar();return t}readUtf8(e=1){return yt(this.readBytes(e))}decodeText(e=1,t="utf8"){return yt(this.readBytes(e),t)}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let t=0;t<e.length;t++)this._data.setUint8(this.offset++,e[t]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(e){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(e){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let t=0;t<e.length;t++)this.writeUint8(e.charCodeAt(t));return this}writeUtf8(e){return this.writeBytes(Re(e))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}function F(i){let e=i.length;for(;--e>=0;)i[e]=0}const De=3,Me=258,kt=29,Le=256+1+kt,Et=30,Be=512,$e=new Array((Le+2)*2);F($e);const Fe=new Array(Et*2);F(Fe);const He=new Array(Be);F(He);const We=new Array(Me-De+1);F(We);const Ze=new Array(kt);F(Ze);const ze=new Array(Et);F(ze);var at=(i,e,t,n)=>{let a=i&65535|0,s=i>>>16&65535|0,l=0;for(;t!==0;){l=t>2e3?2e3:t,t-=l;do a=a+e[n++]|0,s=s+a|0;while(--l);a%=65521,s%=65521}return a|s<<16|0};const Pe=()=>{let i,e=[];for(var t=0;t<256;t++){i=t;for(var n=0;n<8;n++)i=i&1?3988292384^i>>>1:i>>>1;e[t]=i}return e},Ge=new Uint32Array(Pe());var N=(i,e,t,n)=>{const a=Ge,s=n+t;i^=-1;for(let l=n;l<s;l++)i=i>>>8^a[(i^e[l])&255];return i^-1},rt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},At={Z_NO_FLUSH:0,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFLATED:8};const Ke=(i,e)=>Object.prototype.hasOwnProperty.call(i,e);var Ye=function(i){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const t=e.shift();if(t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(const n in t)Ke(t,n)&&(i[n]=t[n])}}return i},Xe=i=>{let e=0;for(let n=0,a=i.length;n<a;n++)e+=i[n].length;const t=new Uint8Array(e);for(let n=0,a=0,s=i.length;n<s;n++){let l=i[n];t.set(l,a),a+=l.length}return t},Tt={assign:Ye,flattenChunks:Xe};let mt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{mt=!1}const Z=new Uint8Array(256);for(let i=0;i<256;i++)Z[i]=i>=252?6:i>=248?5:i>=240?4:i>=224?3:i>=192?2:1;Z[254]=Z[254]=1;var je=i=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(i);let e,t,n,a,s,l=i.length,h=0;for(a=0;a<l;a++)t=i.charCodeAt(a),(t&64512)===55296&&a+1<l&&(n=i.charCodeAt(a+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),a++)),h+=t<128?1:t<2048?2:t<65536?3:4;for(e=new Uint8Array(h),s=0,a=0;s<h;a++)t=i.charCodeAt(a),(t&64512)===55296&&a+1<l&&(n=i.charCodeAt(a+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),a++)),t<128?e[s++]=t:t<2048?(e[s++]=192|t>>>6,e[s++]=128|t&63):t<65536?(e[s++]=224|t>>>12,e[s++]=128|t>>>6&63,e[s++]=128|t&63):(e[s++]=240|t>>>18,e[s++]=128|t>>>12&63,e[s++]=128|t>>>6&63,e[s++]=128|t&63);return e};const Ve=(i,e)=>{if(e<65534&&i.subarray&&mt)return String.fromCharCode.apply(null,i.length===e?i:i.subarray(0,e));let t="";for(let n=0;n<e;n++)t+=String.fromCharCode(i[n]);return t};var qe=(i,e)=>{const t=e||i.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(i.subarray(0,e));let n,a;const s=new Array(t*2);for(a=0,n=0;n<t;){let l=i[n++];if(l<128){s[a++]=l;continue}let h=Z[l];if(h>4){s[a++]=65533,n+=h-1;continue}for(l&=h===2?31:h===3?15:7;h>1&&n<t;)l=l<<6|i[n++]&63,h--;if(h>1){s[a++]=65533;continue}l<65536?s[a++]=l:(l-=65536,s[a++]=55296|l>>10&1023,s[a++]=56320|l&1023)}return Ve(s,a)},Je=(i,e)=>{e=e||i.length,e>i.length&&(e=i.length);let t=e-1;for(;t>=0&&(i[t]&192)===128;)t--;return t<0||t===0?e:t+Z[i[t]]>e?t:e},ot={string2buf:je,buf2string:qe,utf8border:Je};function Qe(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var ti=Qe;const K=16209,ei=16191;var ii=function(e,t){let n,a,s,l,h,_,r,o,w,d,f,u,U,x,g,T,y,c,E,S,p,m,A,b;const k=e.state;n=e.next_in,A=e.input,a=n+(e.avail_in-5),s=e.next_out,b=e.output,l=s-(t-e.avail_out),h=s+(e.avail_out-257),_=k.dmax,r=k.wsize,o=k.whave,w=k.wnext,d=k.window,f=k.hold,u=k.bits,U=k.lencode,x=k.distcode,g=(1<<k.lenbits)-1,T=(1<<k.distbits)-1;t:do{u<15&&(f+=A[n++]<<u,u+=8,f+=A[n++]<<u,u+=8),y=U[f&g];e:for(;;){if(c=y>>>24,f>>>=c,u-=c,c=y>>>16&255,c===0)b[s++]=y&65535;else if(c&16){E=y&65535,c&=15,c&&(u<c&&(f+=A[n++]<<u,u+=8),E+=f&(1<<c)-1,f>>>=c,u-=c),u<15&&(f+=A[n++]<<u,u+=8,f+=A[n++]<<u,u+=8),y=x[f&T];i:for(;;){if(c=y>>>24,f>>>=c,u-=c,c=y>>>16&255,c&16){if(S=y&65535,c&=15,u<c&&(f+=A[n++]<<u,u+=8,u<c&&(f+=A[n++]<<u,u+=8)),S+=f&(1<<c)-1,S>_){e.msg="invalid distance too far back",k.mode=K;break t}if(f>>>=c,u-=c,c=s-l,S>c){if(c=S-c,c>o&&k.sane){e.msg="invalid distance too far back",k.mode=K;break t}if(p=0,m=d,w===0){if(p+=r-c,c<E){E-=c;do b[s++]=d[p++];while(--c);p=s-S,m=b}}else if(w<c){if(p+=r+w-c,c-=w,c<E){E-=c;do b[s++]=d[p++];while(--c);if(p=0,w<E){c=w,E-=c;do b[s++]=d[p++];while(--c);p=s-S,m=b}}}else if(p+=w-c,c<E){E-=c;do b[s++]=d[p++];while(--c);p=s-S,m=b}for(;E>2;)b[s++]=m[p++],b[s++]=m[p++],b[s++]=m[p++],E-=3;E&&(b[s++]=m[p++],E>1&&(b[s++]=m[p++]))}else{p=s-S;do b[s++]=b[p++],b[s++]=b[p++],b[s++]=b[p++],E-=3;while(E>2);E&&(b[s++]=b[p++],E>1&&(b[s++]=b[p++]))}}else if((c&64)===0){y=x[(y&65535)+(f&(1<<c)-1)];continue i}else{e.msg="invalid distance code",k.mode=K;break t}break}}else if((c&64)===0){y=U[(y&65535)+(f&(1<<c)-1)];continue e}else if(c&32){k.mode=ei;break t}else{e.msg="invalid literal/length code",k.mode=K;break t}break}}while(n<a&&s<h);E=u>>3,n-=E,u-=E<<3,f&=(1<<u)-1,e.next_in=n,e.next_out=s,e.avail_in=n<a?5+(a-n):5-(n-a),e.avail_out=s<h?257+(h-s):257-(s-h),k.hold=f,k.bits=u};const H=15,vt=852,Ut=592,St=0,ht=1,It=2,ni=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),si=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),ai=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),ri=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var z=(i,e,t,n,a,s,l,h)=>{const _=h.bits;let r=0,o=0,w=0,d=0,f=0,u=0,U=0,x=0,g=0,T=0,y,c,E,S,p,m=null,A;const b=new Uint16Array(H+1),k=new Uint16Array(H+1);let $=null,Ie,tt,et;for(r=0;r<=H;r++)b[r]=0;for(o=0;o<n;o++)b[e[t+o]]++;for(f=_,d=H;d>=1&&b[d]===0;d--);if(f>d&&(f=d),d===0)return a[s++]=1<<24|64<<16|0,a[s++]=1<<24|64<<16|0,h.bits=1,0;for(w=1;w<d&&b[w]===0;w++);for(f<w&&(f=w),x=1,r=1;r<=H;r++)if(x<<=1,x-=b[r],x<0)return-1;if(x>0&&(i===St||d!==1))return-1;for(k[1]=0,r=1;r<H;r++)k[r+1]=k[r]+b[r];for(o=0;o<n;o++)e[t+o]!==0&&(l[k[e[t+o]]++]=o);if(i===St?(m=$=l,A=20):i===ht?(m=ni,$=si,A=257):(m=ai,$=ri,A=0),T=0,o=0,r=w,p=s,u=f,U=0,E=-1,g=1<<f,S=g-1,i===ht&&g>vt||i===It&&g>Ut)return 1;for(;;){Ie=r-U,l[o]+1<A?(tt=0,et=l[o]):l[o]>=A?(tt=$[l[o]-A],et=m[l[o]-A]):(tt=96,et=0),y=1<<r-U,c=1<<u,w=c;do c-=y,a[p+(T>>U)+c]=Ie<<24|tt<<16|et|0;while(c!==0);for(y=1<<r-1;T&y;)y>>=1;if(y!==0?(T&=y-1,T+=y):T=0,o++,--b[r]===0){if(r===d)break;r=e[t+l[o]]}if(r>f&&(T&S)!==E){for(U===0&&(U=f),p+=w,u=r-U,x=1<<u;u+U<d&&(x-=b[u+U],!(x<=0));)u++,x<<=1;if(g+=1<<u,i===ht&&g>vt||i===It&&g>Ut)return 1;E=T&S,a[E]=f<<24|u<<16|p-s|0}}return T!==0&&(a[p+T]=r-U<<24|64<<16|0),h.bits=f,0};const oi=0,Ot=1,Rt=2,{Z_FINISH:Ct,Z_BLOCK:hi,Z_TREES:Y,Z_OK:L,Z_STREAM_END:fi,Z_NEED_DICT:li,Z_STREAM_ERROR:C,Z_DATA_ERROR:Nt,Z_MEM_ERROR:Dt,Z_BUF_ERROR:ci,Z_DEFLATED:Mt}=At,X=16180,Lt=16181,Bt=16182,$t=16183,Ft=16184,Ht=16185,Wt=16186,Zt=16187,zt=16188,Pt=16189,j=16190,D=16191,ft=16192,Gt=16193,lt=16194,Kt=16195,Yt=16196,Xt=16197,jt=16198,V=16199,q=16200,Vt=16201,qt=16202,Jt=16203,Qt=16204,te=16205,ct=16206,ee=16207,ie=16208,v=16209,ne=16210,se=16211,di=852,ui=592,_i=15,ae=i=>(i>>>24&255)+(i>>>8&65280)+((i&65280)<<8)+((i&255)<<24);function pi(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const B=i=>{if(!i)return 1;const e=i.state;return!e||e.strm!==i||e.mode<X||e.mode>se?1:0},re=i=>{if(B(i))return C;const e=i.state;return i.total_in=i.total_out=e.total=0,i.msg="",e.wrap&&(i.adler=e.wrap&1),e.mode=X,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(di),e.distcode=e.distdyn=new Int32Array(ui),e.sane=1,e.back=-1,L},oe=i=>{if(B(i))return C;const e=i.state;return e.wsize=0,e.whave=0,e.wnext=0,re(i)},he=(i,e)=>{let t;if(B(i))return C;const n=i.state;return e<0?(t=0,e=-e):(t=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?C:(n.window!==null&&n.wbits!==e&&(n.window=null),n.wrap=t,n.wbits=e,oe(i))},fe=(i,e)=>{if(!i)return C;const t=new pi;i.state=t,t.strm=i,t.window=null,t.mode=X;const n=he(i,e);return n!==L&&(i.state=null),n},wi=i=>fe(i,_i);let le=!0,dt,ut;const gi=i=>{if(le){dt=new Int32Array(512),ut=new Int32Array(32);let e=0;for(;e<144;)i.lens[e++]=8;for(;e<256;)i.lens[e++]=9;for(;e<280;)i.lens[e++]=7;for(;e<288;)i.lens[e++]=8;for(z(Ot,i.lens,0,288,dt,0,i.work,{bits:9}),e=0;e<32;)i.lens[e++]=5;z(Rt,i.lens,0,32,ut,0,i.work,{bits:5}),le=!1}i.lencode=dt,i.lenbits=9,i.distcode=ut,i.distbits=5},ce=(i,e,t,n)=>{let a;const s=i.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(e.subarray(t-s.wsize,t),0),s.wnext=0,s.whave=s.wsize):(a=s.wsize-s.wnext,a>n&&(a=n),s.window.set(e.subarray(t-n,t-n+a),s.wnext),n-=a,n?(s.window.set(e.subarray(t-n,t),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=a,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=a))),0},bi=(i,e)=>{let t,n,a,s,l,h,_,r,o,w,d,f,u,U,x=0,g,T,y,c,E,S,p,m;const A=new Uint8Array(4);let b,k;const $=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(B(i)||!i.output||!i.input&&i.avail_in!==0)return C;t=i.state,t.mode===D&&(t.mode=ft),l=i.next_out,a=i.output,_=i.avail_out,s=i.next_in,n=i.input,h=i.avail_in,r=t.hold,o=t.bits,w=h,d=_,m=L;t:for(;;)switch(t.mode){case X:if(t.wrap===0){t.mode=ft;break}for(;o<16;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if(t.wrap&2&&r===35615){t.wbits===0&&(t.wbits=15),t.check=0,A[0]=r&255,A[1]=r>>>8&255,t.check=N(t.check,A,2,0),r=0,o=0,t.mode=Lt;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((r&255)<<8)+(r>>8))%31){i.msg="incorrect header check",t.mode=v;break}if((r&15)!==Mt){i.msg="unknown compression method",t.mode=v;break}if(r>>>=4,o-=4,p=(r&15)+8,t.wbits===0&&(t.wbits=p),p>15||p>t.wbits){i.msg="invalid window size",t.mode=v;break}t.dmax=1<<t.wbits,t.flags=0,i.adler=t.check=1,t.mode=r&512?Pt:D,r=0,o=0;break;case Lt:for(;o<16;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if(t.flags=r,(t.flags&255)!==Mt){i.msg="unknown compression method",t.mode=v;break}if(t.flags&57344){i.msg="unknown header flags set",t.mode=v;break}t.head&&(t.head.text=r>>8&1),t.flags&512&&t.wrap&4&&(A[0]=r&255,A[1]=r>>>8&255,t.check=N(t.check,A,2,0)),r=0,o=0,t.mode=Bt;case Bt:for(;o<32;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}t.head&&(t.head.time=r),t.flags&512&&t.wrap&4&&(A[0]=r&255,A[1]=r>>>8&255,A[2]=r>>>16&255,A[3]=r>>>24&255,t.check=N(t.check,A,4,0)),r=0,o=0,t.mode=$t;case $t:for(;o<16;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}t.head&&(t.head.xflags=r&255,t.head.os=r>>8),t.flags&512&&t.wrap&4&&(A[0]=r&255,A[1]=r>>>8&255,t.check=N(t.check,A,2,0)),r=0,o=0,t.mode=Ft;case Ft:if(t.flags&1024){for(;o<16;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}t.length=r,t.head&&(t.head.extra_len=r),t.flags&512&&t.wrap&4&&(A[0]=r&255,A[1]=r>>>8&255,t.check=N(t.check,A,2,0)),r=0,o=0}else t.head&&(t.head.extra=null);t.mode=Ht;case Ht:if(t.flags&1024&&(f=t.length,f>h&&(f=h),f&&(t.head&&(p=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(n.subarray(s,s+f),p)),t.flags&512&&t.wrap&4&&(t.check=N(t.check,n,f,s)),h-=f,s+=f,t.length-=f),t.length))break t;t.length=0,t.mode=Wt;case Wt:if(t.flags&2048){if(h===0)break t;f=0;do p=n[s+f++],t.head&&p&&t.length<65536&&(t.head.name+=String.fromCharCode(p));while(p&&f<h);if(t.flags&512&&t.wrap&4&&(t.check=N(t.check,n,f,s)),h-=f,s+=f,p)break t}else t.head&&(t.head.name=null);t.length=0,t.mode=Zt;case Zt:if(t.flags&4096){if(h===0)break t;f=0;do p=n[s+f++],t.head&&p&&t.length<65536&&(t.head.comment+=String.fromCharCode(p));while(p&&f<h);if(t.flags&512&&t.wrap&4&&(t.check=N(t.check,n,f,s)),h-=f,s+=f,p)break t}else t.head&&(t.head.comment=null);t.mode=zt;case zt:if(t.flags&512){for(;o<16;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if(t.wrap&4&&r!==(t.check&65535)){i.msg="header crc mismatch",t.mode=v;break}r=0,o=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),i.adler=t.check=0,t.mode=D;break;case Pt:for(;o<32;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}i.adler=t.check=ae(r),r=0,o=0,t.mode=j;case j:if(t.havedict===0)return i.next_out=l,i.avail_out=_,i.next_in=s,i.avail_in=h,t.hold=r,t.bits=o,li;i.adler=t.check=1,t.mode=D;case D:if(e===hi||e===Y)break t;case ft:if(t.last){r>>>=o&7,o-=o&7,t.mode=ct;break}for(;o<3;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}switch(t.last=r&1,r>>>=1,o-=1,r&3){case 0:t.mode=Gt;break;case 1:if(gi(t),t.mode=V,e===Y){r>>>=2,o-=2;break t}break;case 2:t.mode=Yt;break;case 3:i.msg="invalid block type",t.mode=v}r>>>=2,o-=2;break;case Gt:for(r>>>=o&7,o-=o&7;o<32;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if((r&65535)!==(r>>>16^65535)){i.msg="invalid stored block lengths",t.mode=v;break}if(t.length=r&65535,r=0,o=0,t.mode=lt,e===Y)break t;case lt:t.mode=Kt;case Kt:if(f=t.length,f){if(f>h&&(f=h),f>_&&(f=_),f===0)break t;a.set(n.subarray(s,s+f),l),h-=f,s+=f,_-=f,l+=f,t.length-=f;break}t.mode=D;break;case Yt:for(;o<14;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if(t.nlen=(r&31)+257,r>>>=5,o-=5,t.ndist=(r&31)+1,r>>>=5,o-=5,t.ncode=(r&15)+4,r>>>=4,o-=4,t.nlen>286||t.ndist>30){i.msg="too many length or distance symbols",t.mode=v;break}t.have=0,t.mode=Xt;case Xt:for(;t.have<t.ncode;){for(;o<3;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}t.lens[$[t.have++]]=r&7,r>>>=3,o-=3}for(;t.have<19;)t.lens[$[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,b={bits:t.lenbits},m=z(oi,t.lens,0,19,t.lencode,0,t.work,b),t.lenbits=b.bits,m){i.msg="invalid code lengths set",t.mode=v;break}t.have=0,t.mode=jt;case jt:for(;t.have<t.nlen+t.ndist;){for(;x=t.lencode[r&(1<<t.lenbits)-1],g=x>>>24,T=x>>>16&255,y=x&65535,!(g<=o);){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if(y<16)r>>>=g,o-=g,t.lens[t.have++]=y;else{if(y===16){for(k=g+2;o<k;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if(r>>>=g,o-=g,t.have===0){i.msg="invalid bit length repeat",t.mode=v;break}p=t.lens[t.have-1],f=3+(r&3),r>>>=2,o-=2}else if(y===17){for(k=g+3;o<k;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}r>>>=g,o-=g,p=0,f=3+(r&7),r>>>=3,o-=3}else{for(k=g+7;o<k;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}r>>>=g,o-=g,p=0,f=11+(r&127),r>>>=7,o-=7}if(t.have+f>t.nlen+t.ndist){i.msg="invalid bit length repeat",t.mode=v;break}for(;f--;)t.lens[t.have++]=p}}if(t.mode===v)break;if(t.lens[256]===0){i.msg="invalid code -- missing end-of-block",t.mode=v;break}if(t.lenbits=9,b={bits:t.lenbits},m=z(Ot,t.lens,0,t.nlen,t.lencode,0,t.work,b),t.lenbits=b.bits,m){i.msg="invalid literal/lengths set",t.mode=v;break}if(t.distbits=6,t.distcode=t.distdyn,b={bits:t.distbits},m=z(Rt,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,b),t.distbits=b.bits,m){i.msg="invalid distances set",t.mode=v;break}if(t.mode=V,e===Y)break t;case V:t.mode=q;case q:if(h>=6&&_>=258){i.next_out=l,i.avail_out=_,i.next_in=s,i.avail_in=h,t.hold=r,t.bits=o,ii(i,d),l=i.next_out,a=i.output,_=i.avail_out,s=i.next_in,n=i.input,h=i.avail_in,r=t.hold,o=t.bits,t.mode===D&&(t.back=-1);break}for(t.back=0;x=t.lencode[r&(1<<t.lenbits)-1],g=x>>>24,T=x>>>16&255,y=x&65535,!(g<=o);){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if(T&&(T&240)===0){for(c=g,E=T,S=y;x=t.lencode[S+((r&(1<<c+E)-1)>>c)],g=x>>>24,T=x>>>16&255,y=x&65535,!(c+g<=o);){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}r>>>=c,o-=c,t.back+=c}if(r>>>=g,o-=g,t.back+=g,t.length=y,T===0){t.mode=te;break}if(T&32){t.back=-1,t.mode=D;break}if(T&64){i.msg="invalid literal/length code",t.mode=v;break}t.extra=T&15,t.mode=Vt;case Vt:if(t.extra){for(k=t.extra;o<k;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}t.length+=r&(1<<t.extra)-1,r>>>=t.extra,o-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=qt;case qt:for(;x=t.distcode[r&(1<<t.distbits)-1],g=x>>>24,T=x>>>16&255,y=x&65535,!(g<=o);){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if((T&240)===0){for(c=g,E=T,S=y;x=t.distcode[S+((r&(1<<c+E)-1)>>c)],g=x>>>24,T=x>>>16&255,y=x&65535,!(c+g<=o);){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}r>>>=c,o-=c,t.back+=c}if(r>>>=g,o-=g,t.back+=g,T&64){i.msg="invalid distance code",t.mode=v;break}t.offset=y,t.extra=T&15,t.mode=Jt;case Jt:if(t.extra){for(k=t.extra;o<k;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}t.offset+=r&(1<<t.extra)-1,r>>>=t.extra,o-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){i.msg="invalid distance too far back",t.mode=v;break}t.mode=Qt;case Qt:if(_===0)break t;if(f=d-_,t.offset>f){if(f=t.offset-f,f>t.whave&&t.sane){i.msg="invalid distance too far back",t.mode=v;break}f>t.wnext?(f-=t.wnext,u=t.wsize-f):u=t.wnext-f,f>t.length&&(f=t.length),U=t.window}else U=a,u=l-t.offset,f=t.length;f>_&&(f=_),_-=f,t.length-=f;do a[l++]=U[u++];while(--f);t.length===0&&(t.mode=q);break;case te:if(_===0)break t;a[l++]=t.length,_--,t.mode=q;break;case ct:if(t.wrap){for(;o<32;){if(h===0)break t;h--,r|=n[s++]<<o,o+=8}if(d-=_,i.total_out+=d,t.total+=d,t.wrap&4&&d&&(i.adler=t.check=t.flags?N(t.check,a,d,l-d):at(t.check,a,d,l-d)),d=_,t.wrap&4&&(t.flags?r:ae(r))!==t.check){i.msg="incorrect data check",t.mode=v;break}r=0,o=0}t.mode=ee;case ee:if(t.wrap&&t.flags){for(;o<32;){if(h===0)break t;h--,r+=n[s++]<<o,o+=8}if(t.wrap&4&&r!==(t.total&4294967295)){i.msg="incorrect length check",t.mode=v;break}r=0,o=0}t.mode=ie;case ie:m=fi;break t;case v:m=Nt;break t;case ne:return Dt;case se:default:return C}return i.next_out=l,i.avail_out=_,i.next_in=s,i.avail_in=h,t.hold=r,t.bits=o,(t.wsize||d!==i.avail_out&&t.mode<v&&(t.mode<ct||e!==Ct))&&ce(i,i.output,i.next_out,d-i.avail_out),w-=i.avail_in,d-=i.avail_out,i.total_in+=w,i.total_out+=d,t.total+=d,t.wrap&4&&d&&(i.adler=t.check=t.flags?N(t.check,a,d,i.next_out-d):at(t.check,a,d,i.next_out-d)),i.data_type=t.bits+(t.last?64:0)+(t.mode===D?128:0)+(t.mode===V||t.mode===lt?256:0),(w===0&&d===0||e===Ct)&&m===L&&(m=ci),m},xi=i=>{if(B(i))return C;let e=i.state;return e.window&&(e.window=null),i.state=null,L},yi=(i,e)=>{if(B(i))return C;const t=i.state;return(t.wrap&2)===0?C:(t.head=e,e.done=!1,L)},ki=(i,e)=>{const t=e.length;let n,a,s;return B(i)||(n=i.state,n.wrap!==0&&n.mode!==j)?C:n.mode===j&&(a=1,a=at(a,e,t,0),a!==n.check)?Nt:(s=ce(i,e,t,t),s?(n.mode=ne,Dt):(n.havedict=1,L))};var Ei=oe,Ai=he,Ti=re,mi=wi,vi=fe,Ui=bi,Si=xi,Ii=yi,Oi=ki,Ri="pako inflate (from Nodeca project)",M={inflateReset:Ei,inflateReset2:Ai,inflateResetKeep:Ti,inflateInit:mi,inflateInit2:vi,inflate:Ui,inflateEnd:Si,inflateGetHeader:Ii,inflateSetDictionary:Oi,inflateInfo:Ri};function Ci(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Ni=Ci;const de=Object.prototype.toString,{Z_NO_FLUSH:Di,Z_FINISH:Mi,Z_OK:P,Z_STREAM_END:_t,Z_NEED_DICT:pt,Z_STREAM_ERROR:Li,Z_DATA_ERROR:ue,Z_MEM_ERROR:Bi}=At;function G(i){this.options=Tt.assign({chunkSize:1024*64,windowBits:15,to:""},i||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(i&&i.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ti,this.strm.avail_out=0;let t=M.inflateInit2(this.strm,e.windowBits);if(t!==P)throw new Error(rt[t]);if(this.header=new Ni,M.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=ot.string2buf(e.dictionary):de.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=M.inflateSetDictionary(this.strm,e.dictionary),t!==P)))throw new Error(rt[t])}G.prototype.push=function(i,e){const t=this.strm,n=this.options.chunkSize,a=this.options.dictionary;let s,l,h;if(this.ended)return!1;for(e===~~e?l=e:l=e===!0?Mi:Di,de.call(i)==="[object ArrayBuffer]"?t.input=new Uint8Array(i):t.input=i,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(n),t.next_out=0,t.avail_out=n),s=M.inflate(t,l),s===pt&&a&&(s=M.inflateSetDictionary(t,a),s===P?s=M.inflate(t,l):s===ue&&(s=pt));t.avail_in>0&&s===_t&&t.state.wrap>0&&i[t.next_in]!==0;)M.inflateReset(t),s=M.inflate(t,l);switch(s){case Li:case ue:case pt:case Bi:return this.onEnd(s),this.ended=!0,!1}if(h=t.avail_out,t.next_out&&(t.avail_out===0||s===_t))if(this.options.to==="string"){let _=ot.utf8border(t.output,t.next_out),r=t.next_out-_,o=ot.buf2string(t.output,_);t.next_out=r,t.avail_out=n-r,r&&t.output.set(t.output.subarray(_,_+r),0),this.onData(o)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(s===P&&h===0)){if(s===_t)return s=M.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(t.avail_in===0)break}}return!0},G.prototype.onData=function(i){this.chunks.push(i)},G.prototype.onEnd=function(i){i===P&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Tt.flattenChunks(this.chunks)),this.chunks=[],this.err=i,this.msg=this.strm.msg};function $i(i,e){const t=new G(e);if(t.push(i),t.err)throw t.msg||rt[t.err];return t.result}var Fi=G,Hi=$i,Wi={Inflate:Fi,inflate:Hi};const{Inflate:Zi,inflate:zi}=Wi;var _e=Zi,Pi=zi;const pe=[];for(let i=0;i<256;i++){let e=i;for(let t=0;t<8;t++)e&1?e=3988292384^e>>>1:e=e>>>1;pe[i]=e}const we=4294967295;function Gi(i,e,t){let n=i;for(let a=0;a<t;a++)n=pe[(n^e[a])&255]^n>>>8;return n}function Ki(i,e){return(Gi(we,i,e)^we)>>>0}function ge(i,e,t){const n=i.readUint32(),a=Ki(new Uint8Array(i.buffer,i.byteOffset+i.offset-e-4,e),e);if(a!==n)throw new Error(`CRC mismatch for chunk ${t}. Expected ${n}, found ${a}`)}function be(i,e,t){for(let n=0;n<t;n++)e[n]=i[n]}function xe(i,e,t,n){let a=0;for(;a<n;a++)e[a]=i[a];for(;a<t;a++)e[a]=i[a]+e[a-n]&255}function ye(i,e,t,n){let a=0;if(t.length===0)for(;a<n;a++)e[a]=i[a];else for(;a<n;a++)e[a]=i[a]+t[a]&255}function ke(i,e,t,n,a){let s=0;if(t.length===0){for(;s<a;s++)e[s]=i[s];for(;s<n;s++)e[s]=i[s]+(e[s-a]>>1)&255}else{for(;s<a;s++)e[s]=i[s]+(t[s]>>1)&255;for(;s<n;s++)e[s]=i[s]+(e[s-a]+t[s]>>1)&255}}function Ee(i,e,t,n,a){let s=0;if(t.length===0){for(;s<a;s++)e[s]=i[s];for(;s<n;s++)e[s]=i[s]+e[s-a]&255}else{for(;s<a;s++)e[s]=i[s]+t[s]&255;for(;s<n;s++)e[s]=i[s]+Yi(e[s-a],t[s],t[s-a])&255}}function Yi(i,e,t){const n=i+e-t,a=Math.abs(n-i),s=Math.abs(n-e),l=Math.abs(n-t);return a<=s&&a<=l?i:s<=l?e:t}function Xi(i,e,t,n,a,s){switch(i){case 0:be(e,t,a);break;case 1:xe(e,t,a,s);break;case 2:ye(e,t,n,a);break;case 3:ke(e,t,n,a,s);break;case 4:Ee(e,t,n,a,s);break;default:throw new Error(`Unsupported filter: ${i}`)}}const ji=new Uint16Array([255]),Vi=new Uint8Array(ji.buffer)[0]===255;function qi(i){const{data:e,width:t,height:n,channels:a,depth:s}=i,l=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],h=Math.ceil(s/8)*a,_=new Uint8Array(n*t*h);let r=0;for(let o=0;o<7;o++){const w=l[o],d=Math.ceil((t-w.x)/w.xStep),f=Math.ceil((n-w.y)/w.yStep);if(d<=0||f<=0)continue;const u=d*h,U=new Uint8Array(u);for(let x=0;x<f;x++){const g=e[r++],T=e.subarray(r,r+u);r+=u;const y=new Uint8Array(u);Xi(g,T,y,U,u,h),U.set(y);for(let c=0;c<d;c++){const E=w.x+c*w.xStep,S=w.y+x*w.yStep;if(!(E>=t||S>=n))for(let p=0;p<h;p++)_[(S*t+E)*h+p]=y[c*h+p]}}}if(s===16){const o=new Uint16Array(_.buffer);if(Vi)for(let w=0;w<o.length;w++)o[w]=Ji(o[w]);return o}else return _}function Ji(i){return(i&255)<<8|i>>8&255}const Qi=new Uint16Array([255]),tn=new Uint8Array(Qi.buffer)[0]===255,en=new Uint8Array(0);function Ae(i){const{data:e,width:t,height:n,channels:a,depth:s}=i,l=Math.ceil(s/8)*a,h=Math.ceil(s/8*a*t),_=new Uint8Array(n*h);let r=en,o=0,w,d;for(let f=0;f<n;f++){switch(w=e.subarray(o+1,o+1+h),d=_.subarray(f*h,(f+1)*h),e[o]){case 0:be(w,d,h);break;case 1:xe(w,d,h,l);break;case 2:ye(w,d,r,h);break;case 3:ke(w,d,r,h,l);break;case 4:Ee(w,d,r,h,l);break;default:throw new Error(`Unsupported filter: ${e[o]}`)}r=d,o+=h+1}if(s===16){const f=new Uint16Array(_.buffer);if(tn)for(let u=0;u<f.length;u++)f[u]=nn(f[u]);return f}else return _}function nn(i){return(i&255)<<8|i>>8&255}const J=Uint8Array.of(137,80,78,71,13,10,26,10);function Te(i){if(!sn(i.readBytes(J.length)))throw new Error("wrong PNG signature")}function sn(i){if(i.length<J.length)return!1;for(let e=0;e<J.length;e++)if(i[e]!==J[e])return!1;return!0}const an="tEXt",rn=0,me=new TextDecoder("latin1");function on(i){if(fn(i),i.length===0||i.length>79)throw new Error("keyword length must be between 1 and 79")}const hn=/^[\u0000-\u00FF]*$/;function fn(i){if(!hn.test(i))throw new Error("invalid latin1 text")}function ln(i,e,t){const n=ve(e);i[n]=cn(e,t-n.length-1)}function ve(i){for(i.mark();i.readByte()!==rn;);const e=i.offset;i.reset();const t=me.decode(i.readBytes(e-i.offset-1));return i.skip(1),on(t),t}function cn(i,e){return me.decode(i.readBytes(e))}const R={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},wt={UNKNOWN:-1,DEFLATE:0},Ue={UNKNOWN:-1,ADAPTIVE:0},gt={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},Q={NONE:0,BACKGROUND:1,PREVIOUS:2},bt={SOURCE:0,OVER:1};class dn extends st{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;constructor(e,t={}){super(e);const{checkCrc:n=!1}=t;this._checkCrc=n,this._inflator=new _e,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array(0),this._compressionMethod=wt.UNKNOWN,this._filterMethod=Ue.UNKNOWN,this._interlaceMethod=gt.UNKNOWN,this._colorType=R.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(Te(this);!this._end;){const e=this.readUint32(),t=this.readChars(4);this.decodeChunk(e,t)}return this.decodeImage(),this._png}decodeApng(){for(Te(this);!this._end;){const e=this.readUint32(),t=this.readChars(4);this.decodeApngChunk(e,t)}return this.decodeApngImage(),this._apng}decodeChunk(e,t){const n=this.offset;switch(t){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(e);break;case"IDAT":this.decodeIDAT(e);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(e);break;case"iCCP":this.decodeiCCP(e);break;case an:ln(this._png.text,this,e);break;case"pHYs":this.decodepHYs();break;default:this.skip(e);break}if(this.offset-n!==e)throw new Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?ge(this,e+4,t):this.skip(4)}decodeApngChunk(e,t){const n=this.offset;switch(t!=="fdAT"&&t!=="IDAT"&&this._writingDataChunks&&this.pushDataToFrame(),t){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(e);break;default:this.decodeChunk(e,t),this.offset=n+e;break}if(this.offset-n!==e)throw new Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?ge(this,e+4,t):this.skip(4)}decodeIHDR(){const e=this._png;e.width=this.readUint32(),e.height=this.readUint32(),e.depth=un(this.readUint8());const t=this.readUint8();this._colorType=t;let n;switch(t){case R.GREYSCALE:n=1;break;case R.TRUECOLOUR:n=3;break;case R.INDEXED_COLOUR:n=1;break;case R.GREYSCALE_ALPHA:n=2;break;case R.TRUECOLOUR_ALPHA:n=4;break;case R.UNKNOWN:default:throw new Error(`Unknown color type: ${t}`)}if(this._png.channels=n,this._compressionMethod=this.readUint8(),this._compressionMethod!==wt.DEFLATE)throw new Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){const e={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array(0)};this._frames.push(e)}decodePLTE(e){if(e%3!==0)throw new RangeError(`PLTE field length must be a multiple of 3. Got ${e}`);const t=e/3;this._hasPalette=!0;const n=[];this._palette=n;for(let a=0;a<t;a++)n.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(e){this._writingDataChunks=!0;const t=e,n=this.offset+this.byteOffset;if(this._inflator.push(new Uint8Array(this.buffer,n,t)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(e)}decodeFDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;if(n+=4,t-=4,this._inflator.push(new Uint8Array(this.buffer,n,t)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(e)}decodetRNS(e){switch(this._colorType){case R.GREYSCALE:case R.TRUECOLOUR:{if(e%2!==0)throw new RangeError(`tRNS chunk length must be a multiple of 2. Got ${e}`);if(e/2>this._png.width*this._png.height)throw new Error(`tRNS chunk contains more alpha values than there are pixels (${e/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(e/2);for(let t=0;t<e/2;t++)this._transparency[t]=this.readUint16();break}case R.INDEXED_COLOUR:{if(e>this._palette.length)throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${e} vs ${this._palette.length})`);let t=0;for(;t<e;t++){const n=this.readByte();this._palette[t].push(n)}for(;t<this._palette.length;t++)this._palette[t].push(255);break}case R.UNKNOWN:case R.GREYSCALE_ALPHA:case R.TRUECOLOUR_ALPHA:default:throw new Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(e){const t=ve(this),n=this.readUint8();if(n!==wt.DEFLATE)throw new Error(`Unsupported iCCP compression method: ${n}`);const a=this.readBytes(e-t.length-2);this._png.iccEmbeddedProfile={name:t,profile:Pi(a)}}decodepHYs(){const e=this.readUint32(),t=this.readUint32(),n=this.readByte();this._png.resolution={x:e,y:t,unit:n}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let e=0;e<this._numberOfFrames;e++){const t={sequenceNumber:this._frames[e].sequenceNumber,delayNumber:this._frames[e].delayNumber,delayDenominator:this._frames[e].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},n=this._frames.at(e);if(n){if(n.data=Ae({data:n.data,width:n.width,height:n.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),e===0||n.xOffset===0&&n.yOffset===0&&n.width===this._png.width&&n.height===this._png.height)t.data=n.data;else{const a=this._apng.frames.at(e-1);this.disposeFrame(n,a,t),this.addFrameDataToCanvas(t,n)}this._apng.frames.push(t)}}return this._apng}disposeFrame(e,t,n){switch(e.disposeOp){case Q.NONE:break;case Q.BACKGROUND:for(let a=0;a<this._png.height;a++)for(let s=0;s<this._png.width;s++){const l=(a*e.width+s)*this._png.channels;for(let h=0;h<this._png.channels;h++)n.data[l+h]=0}break;case Q.PREVIOUS:n.data.set(t.data);break;default:throw new Error("Unknown disposeOp")}}addFrameDataToCanvas(e,t){const n=1<<this._png.depth,a=(s,l)=>{const h=((s+t.yOffset)*this._png.width+t.xOffset+l)*this._png.channels,_=(s*t.width+l)*this._png.channels;return{index:h,frameIndex:_}};switch(t.blendOp){case bt.SOURCE:for(let s=0;s<t.height;s++)for(let l=0;l<t.width;l++){const{index:h,frameIndex:_}=a(s,l);for(let r=0;r<this._png.channels;r++)e.data[h+r]=t.data[_+r]}break;case bt.OVER:for(let s=0;s<t.height;s++)for(let l=0;l<t.width;l++){const{index:h,frameIndex:_}=a(s,l);for(let r=0;r<this._png.channels;r++){const o=t.data[_+this._png.channels-1]/n,w=r%(this._png.channels-1)===0?1:t.data[_+r],d=Math.floor(o*w+(1-o)*e.data[h+r]);e.data[h+r]+=d}}break;default:throw new Error("Unknown blendOp")}}decodeImage(){if(this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);const e=this._isAnimated?(this._frames?.at(0)).data:this._inflator.result;if(this._filterMethod!==Ue.ADAPTIVE)throw new Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===gt.NO_INTERLACE)this._png.data=Ae({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===gt.ADAM7)this._png.data=qi({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw new Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){const e=this._inflator.result,t=this._frames.at(-1);t?t.data=e:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:Q.NONE,blendOp:bt.SOURCE,data:e}),this._inflator=new _e,this._writingDataChunks=!1}}function un(i){if(i!==1&&i!==2&&i!==4&&i!==8&&i!==16)throw new Error(`invalid bit depth: ${i}`);return i}function _n(i,e){return new dn(i,e).decode()}class Se{bottomLeft;ptWidth;ptHeight;xSpacing;ySpacing;elevs;constructor(e,t,n,a,s,l){this.bottomLeft=t,this.ptWidth=n,this.ptHeight=a,this.elevs=e,this.xSpacing=s,this.ySpacing=l}getElevation(e,t){let n=[e,t],a=Math.floor((n[0]-this.bottomLeft.e)/this.xSpacing),s=this.ptHeight-Math.ceil((n[1]-this.bottomLeft.n)/this.ySpacing),l,h,_,r,o,w,d,f=Number.NEGATIVE_INFINITY;if(a>=0&&s>=0&&a<this.ptWidth-1&&s<this.ptHeight-1){r=this.elevs[s*this.ptWidth+a],o=this.elevs[s*this.ptWidth+a+1],w=this.elevs[s*this.ptWidth+a+this.ptWidth],d=this.elevs[s*this.ptWidth+a+this.ptWidth+1],l=this.bottomLeft[0]+a*this.xSpacing,l+this.xSpacing,h=this.bottomLeft[1]+(this.ptHeight-1-s)*this.ySpacing,_=h-this.ySpacing;let u=(n[0]-l)/this.xSpacing,U=r*(1-u)+o*u,x=w*(1-u)+d*u,g=(n[1]-_)/this.ySpacing;f=x*(1-g)+U*g}return f}}class pn extends it{constructor(e){super(e)}async readTile(e){const n=await(await fetch(e)).arrayBuffer(),a=_n(n);let s,l=0;const h=new Array(a.width*a.height);for(let _=0;_<a.height;_++)for(let r=0;r<a.width;r++)s=(_*a.width+r)*a.channels,h[l++]=Math.round(a.data[s]*256+a.data[s+1]+a.data[s+2]/256-32768);return{w:a.width,h:a.height,elevs:h}}getElevation(e){const t=this.getTile(e,this.tile.z),n=this.dataTiles[`${t.z}/${t.x}/${t.y}`];return n?n.getElevation(e[0],e[1]):Number.NEGATIVE_INFINITY}getElevationFromLonLat(e){return this.getElevation(this.sphMerc.project(e))}rawTileToStoredTile(e,t){const n=e.getTopRight(),a=e.getBottomLeft(),s=(n.e-a.e)/(t.w-1),l=(n.n-a.n)/(t.h-1),h=new Se(t.elevs,a,t.w,t.h,s,l);return{tile:e,data:h}}}class wn extends it{constructor(e){super(e)}async readTile(e){return await(await fetch(e)).json()}}class gn{e;n;constructor(e,t){this.e=e,this.n=t}}class bn{lon;lat;constructor(e,t){this.lon=e,this.lat=t}}I.Constants=O,I.DEM=Se,I.DemTiler=pn,I.EastNorth=gn,I.JsonTiler=wn,I.LonLat=bn,I.SphMercProjection=xt,I.Tile=W,I.Tiler=it,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "locar-tiler",
3
- "version": "0.0.2",
3
+ "version": "0.1.2",
4
+ "description": "Tiling system for downloading geodata from APIs by Spherical Mercator XYZ tile. Particularly useful for location-based augmented reality applications as it comes with JSON and Digital Elevation Model (Terrarium DEM) support by default; works nicely with LocAR.js.",
4
5
  "dependencies": {
5
6
  "fast-png": "^7.0.1",
6
7
  "tsx": "^4.21.0",
@@ -10,15 +11,18 @@
10
11
  "dist"
11
12
  ],
12
13
  "main": "./dist/locar-tiler.umd.js",
13
- "module": "./dist/locar-tiler.es.js",
14
+ "module": "./dist/locar-tiler.mjs",
14
15
  "types": "./dist/locar-tiler.d.ts",
15
16
  "exports": {
16
17
  ".": {
17
18
  "types" : "./dist/locar-tiler.d.ts",
18
- "import" : "./dist/locar-tiler.es.js",
19
+ "import" : "./dist/locar-tiler.mjs",
19
20
  "require" : "./dist/locar-tiler.umd.js"
20
21
  }
21
22
  },
23
+ "repository": {
24
+ "url": "https://github.com/AR-js-org/locar-tiler"
25
+ },
22
26
  "scripts": {
23
27
  "build": "tsc && vite build && npm pack",
24
28
  "start": "tsc && tsx demo/demo.ts"