@openheart/tavio-renderer 2.3.1-withWasm → 2.3.2-with-wasm
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/build/esm/index.js +24 -28
- package/build/esm/types/wasm-bindings/wasm-pkg-base-url.d.ts +6 -0
- package/build/esm/wasm/pkg/no-thread/tavio.js +98 -98
- package/build/esm/wasm/pkg/no-thread/tavio_bg.wasm +0 -0
- package/build/esm/wasm/pkg/thread/tavio.d.ts +3 -3
- package/build/esm/wasm/pkg/thread/tavio.js +142 -142
- package/build/esm/wasm/pkg/thread/tavio_bg.wasm +0 -0
- package/build/esm/wasm/pkg/thread/tavio_bg.wasm.d.ts +3 -3
- package/build/esm/wasm-worker-CEuC2YyS.js +117 -0
- package/package.json +2 -1
package/build/esm/index.js
CHANGED
|
@@ -36835,7 +36835,19 @@ class StreamLoader extends EventEmitter {
|
|
|
36835
36835
|
if (response.status !== 200) {
|
|
36836
36836
|
throw new Error(`failed to load: [ ${response.status} ]`);
|
|
36837
36837
|
}
|
|
36838
|
-
const
|
|
36838
|
+
const clHeader = response.headers.get("content-length");
|
|
36839
|
+
const parsed = clHeader != null ? +clHeader : NaN;
|
|
36840
|
+
const hasKnownLength = Number.isFinite(parsed) && parsed > 0;
|
|
36841
|
+
if (!hasKnownLength) {
|
|
36842
|
+
const ab = await response.arrayBuffer();
|
|
36843
|
+
const contentLength2 = ab.byteLength;
|
|
36844
|
+
this.emit("getcontentbytelength", contentLength2);
|
|
36845
|
+
this.emit("read", new Uint8Array(ab));
|
|
36846
|
+
this.emit("load", void 0);
|
|
36847
|
+
resolve();
|
|
36848
|
+
return;
|
|
36849
|
+
}
|
|
36850
|
+
const contentLength = parsed;
|
|
36839
36851
|
this.emit("getcontentbytelength", contentLength);
|
|
36840
36852
|
const readableStreamReader = response.body.getReader();
|
|
36841
36853
|
while (true) {
|
|
@@ -37426,12 +37438,12 @@ const main$3 = "uniform float size;\nuniform float scale;\nuniform float effectD
|
|
|
37426
37438
|
const main$2 = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float temperature;\nuniform float tint;\nuniform float contrastIntensity;\nuniform vec3 hsv;\nuniform vec3 rgb;\n\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying float vAlpha;\nvarying float vColorEffectFactor; // 色エフェクトの係数(0.0~1.0)\nvarying float vSonarFactor; // ソナーエフェクトの係数(0.0~1.0)\nvarying vec3 vWorldPosition; // ワールド座標(角度計算用)\nuniform vec3 worldOrigin;\nuniform float effectSonar; // ソナーエフェクト(歪みの回転に使用)\n\nconst float EPS = 1.0e-8;\nconst float DIV = 10.0 / 6.0;\nconst mat3 LIN_2_LMS_MAT = mat3(\n 3.90405e-1, 5.49941e-1, 8.92632e-3,\n 7.08416e-2, 9.63172e-1, 1.35775e-3,\n 2.31082e-2, 1.28021e-1, 9.36245e-1\n);\nconst mat3 LMS_2_LIN_MAT = mat3(\n 2.85847e+0, -1.62879e+0, -2.48910e-2,\n -2.10182e-1, 1.15820e+0, 3.24281e-4,\n -4.18120e-2, -1.18169e-1, 1.06867e+0\n);\n\nvec3 whiteBalance(vec3 diffuse, float te, float ti) {\n // Range ~[-1.67 : 1.67] works best\n float t1 = te * DIV;\n float t2 = ti * DIV;\n float x = 0.31271 - t1 * (t1 < 0.0 ? 0.1 : 0.05);\n float standardIlluminantY = 2.87 * x - 3.0 * x * x - 0.27509507;\n float y = standardIlluminantY + t2 * 0.05;\n vec3 w1 = vec3(0.949237, 1.03542, 1.08728);\n\n // CIExyToLMS\n float X = x / y;\n float Z = (1.0 - x - y) / y;\n float L = 0.7328 * X + 0.4296 - 0.1624 * Z;\n float M = -0.7036 * X + 1.6975 + 0.0061 * Z;\n float S = 0.0030 * X + 0.0136 + 0.9834 * Z;\n vec3 w2 = vec3(L, M, S);\n\n vec3 balance = vec3(w1.x / w2.x, w1.y / w2.y, w1.z / w2.z);\n vec3 lms = LIN_2_LMS_MAT * diffuse;\n lms *= balance;\n return LMS_2_LIN_MAT * lms;\n}\n\nvec3 RGB2HSV(vec3 color) {\n vec3 c = min(color, 1.0);\n vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n\n float d = q.x - min(q.w, q.y);\n return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + EPS)), d / (q.x + EPS), q.x);\n}\n\nvec3 HSV2RGB(vec3 color) {\n vec3 c = min(color, 1.0);\n vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n\nvec3 contrast(vec3 color, float base) {\n float b = (base * 2.0 - 1.0) * 0.5;\n return color + vec3(\n atan((color.r * 2.0 - 1.0) * b),\n atan((color.g * 2.0 - 1.0) * b),\n atan((color.b * 2.0 - 1.0) * b)\n );\n}\n\nvec3 grading(vec3 color) {\n vec3 balanced = whiteBalance(color, temperature, tint);\n vec3 contrasted = contrast(balanced, contrastIntensity);\n vec3 hsvColor = RGB2HSV(contrasted);\n hsvColor.x = fract(hsvColor.x + hsv.x);\n hsvColor.y = clamp(hsvColor.y + hsv.y, 0.0, 1.0);\n hsvColor.z = clamp(hsvColor.z + hsv.z, 0.0, 1.0);\n vec3 rgbAdjusted = HSV2RGB(hsvColor);\n rgbAdjusted.r = clamp(rgbAdjusted.r + rgb.r, 0.0, 1.0);\n rgbAdjusted.g = clamp(rgbAdjusted.g + rgb.g, 0.0, 1.0);\n rgbAdjusted.b = clamp(rgbAdjusted.b + rgb.b, 0.0, 1.0);\n return rgbAdjusted;\n}\n\nvoid main() {\n\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n\n vec3 outgoingLight = vec3( 0.0 );\n\n #include <logdepthbuf_fragment>\n #include <map_particle_fragment>\n #include <color_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n\n // 距離係数に基づいてHSV/RGBの影響を制御\n // color_fragmentの後、diffuseColorには頂点カラーが適用された値が含まれている\n vec3 originalColor = diffuseColor.rgb;\n vec3 gradedColor = grading(originalColor);\n vec3 finalColor = mix(originalColor, gradedColor, vColorEffectFactor);\n\n // ソナーエフェクト:範囲内を白で強調\n // vSonarFactor: 外側で1.0、内側で0.0の係数\n if (vSonarFactor > 0.0) {\n float sonarStrength = 2.0; // 強度\n vec3 sonarColor = finalColor;\n\n // 白エリアの処理\n float whiteAreaFactor = smoothstep(0.25, 1.0, vSonarFactor);\n vec3 whiteColor = sonarColor;\n whiteColor.rgb += whiteAreaFactor * sonarStrength * 0.4;\n\n // 色をクランプ\n whiteColor = clamp(whiteColor, 0.0, 1.0);\n\n // エフェクト範囲内でのみ適用\n finalColor = mix(finalColor, whiteColor, vSonarFactor);\n }\n\n outgoingLight = finalColor;\n\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n\n gl_FragColor.a *= vAlpha;\n}";
|
|
37427
37439
|
const main$1 = "// #version 300 es\nin vec3 position;\nvoid main() {\n gl_Position = vec4(position, 1.0);\n}\n";
|
|
37428
37440
|
const main = "// #version 300 es\nprecision highp float;\nprecision highp int;\n\nuniform vec3 viewOrigin;\nuniform uint vertexCount;\n// splats (position, scale, rotation... etc.)\nuniform highp usampler2D splatTexture;\n// general (selection etc.)\nuniform highp usampler2D generalTexture;\n// transform (position, scale, rotation)\nuniform highp usampler2D transformTexture;\n// transform texture width\nuniform uint transformTextureWidth;\n\nout vec4 fragColor;\n\nconst uint TEXTURE_WIDTH = 1024u;\nconst float INV_255 = 1.0 / 255.0;\nconst float INF = 1.0 / 0.0;\n\nivec2 getSplatCoord(uint indices) {\n uint u = indices & 0x3ffu;\n uint v = indices >> 10;\n return ivec2(u, v);\n}\nvec3 getPosition(uvec4 packed) {\n return vec4(\n unpackHalf2x16(packed.x),\n unpackHalf2x16(packed.y & 0xffffu)\n ).xyz;\n}\nmat3 generateRotationScaleMatrix(vec4 q, float s) {\n float x = q.x;\n float y = q.y;\n float z = q.z;\n float w = q.w;\n float xx = x * x;\n float yy = y * y;\n float zz = z * z;\n float xy = x * y;\n float xz = x * z;\n float yz = y * z;\n float wx = w * x;\n float wy = w * y;\n float wz = w * z;\n return mat3(\n 1.0 - 2.0 * (yy + zz), 2.0 * (xy + wz), 2.0 * (xz - wy),\n 2.0 * (xy - wz), 1.0 - 2.0 * (xx + zz), 2.0 * (yz + wx),\n 2.0 * (xz + wy), 2.0 * (yz - wx), 1.0 - 2.0 * (xx + yy)\n ) * s;\n}\nvoid restoreTransform(in uint index, in uint width, out vec3 t, out float s, out vec4 q) {\n uint u = index % width;\n uint v = uint(floor(float(index) / float(width)));\n uvec4 transform = texelFetch(transformTexture, ivec2(u, v), 0);\n vec2 r = unpackHalf2x16(transform.x);\n vec2 g = unpackHalf2x16(transform.y);\n vec2 b = unpackHalf2x16(transform.z);\n vec2 a = unpackHalf2x16(transform.w);\n t = vec3(-r, g.x);\n s = g.y;\n q = vec4(b, a);\n}\nvoid unpack4to8(in uint packed, out uint high, out uint low) {\n high = (packed >> 4u) & 0xFu;\n low = packed & 0xFu;\n}\nfloat getDistance(uint indices) {\n if (indices >= vertexCount) {\n return INF;\n }\n ivec2 uv = getSplatCoord(indices);\n uvec4 packed = texelFetch(splatTexture, uv, 0);\n uvec4 general = texelFetch(generalTexture, uv, 0);\n vec3 tPosition = vec3(0.0);\n float tScale = 1.0;\n vec4 tRotation = vec4(0.0);\n uint high, low;\n unpack4to8(general.a, high, low);\n restoreTransform(low, transformTextureWidth, tPosition, tScale, tRotation);\n mat3 mm = generateRotationScaleMatrix(tRotation, tScale);\n vec3 position = getPosition(packed);\n position = mm * position + tPosition;\n return length(position - viewOrigin);\n}\n\nvoid main () {\n uvec2 u = uvec2(gl_FragCoord.st);\n uint indices = (u.s + u.t * TEXTURE_WIDTH) * 2u;\n float distance1 = getDistance(indices);\n float distance2 = getDistance(indices + 1u);\n\n vec2 combine = vec2(distance1, distance2);\n uint packedUint = packHalf2x16(combine);\n uvec4 rgba = uvec4(\n packedUint & 0xffu,\n (packedUint >> 8u) & 0xffu,\n (packedUint >> 16u) & 0xffu,\n (packedUint >> 24u) & 0xffu\n );\n fragColor = vec4(rgba) * INV_255;\n}\n";
|
|
37429
|
-
const jsContent$1 = 'function zero$1(buf) {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n}\nconst MIN_MATCH$1 = 3;\nconst MAX_MATCH$1 = 258;\nconst LENGTH_CODES$1 = 29;\nconst LITERALS$1 = 256;\nconst L_CODES$1 = LITERALS$1 + 1 + LENGTH_CODES$1;\nconst D_CODES$1 = 30;\nconst DIST_CODE_LEN = 512;\nconst static_ltree = new Array((L_CODES$1 + 2) * 2);\nzero$1(static_ltree);\nconst static_dtree = new Array(D_CODES$1 * 2);\nzero$1(static_dtree);\nconst _dist_code = new Array(DIST_CODE_LEN);\nzero$1(_dist_code);\nconst _length_code = new Array(MAX_MATCH$1 - MIN_MATCH$1 + 1);\nzero$1(_length_code);\nconst base_length = new Array(LENGTH_CODES$1);\nzero$1(base_length);\nconst base_dist = new Array(D_CODES$1);\nzero$1(base_dist);\nconst adler32 = (adler, buf, len, pos) => {\n let s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;\n while (len !== 0) {\n n = len > 2e3 ? 2e3 : len;\n len -= n;\n do {\n s1 = s1 + buf[pos++] | 0;\n s2 = s2 + s1 | 0;\n } while (--n);\n s1 %= 65521;\n s2 %= 65521;\n }\n return s1 | s2 << 16 | 0;\n};\nvar adler32_1$1 = adler32;\nconst makeTable = () => {\n let c, table = [];\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;\n }\n table[n] = c;\n }\n return table;\n};\nconst crcTable = new Uint32Array(makeTable());\nconst crc32$1 = (crc, buf, len, pos) => {\n const t = crcTable;\n const end = pos + len;\n crc ^= -1;\n for (let i = pos; i < end; i++) {\n crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];\n }\n return crc ^ -1;\n};\nvar crc32_1$1 = crc32$1;\nvar messages$1 = {\n 2: "need dictionary",\n /* Z_NEED_DICT 2 */\n 1: "stream end",\n /* Z_STREAM_END 1 */\n 0: "",\n /* Z_OK 0 */\n "-1": "file error",\n /* Z_ERRNO (-1) */\n "-2": "stream error",\n /* Z_STREAM_ERROR (-2) */\n "-3": "data error",\n /* Z_DATA_ERROR (-3) */\n "-4": "insufficient memory",\n /* Z_MEM_ERROR (-4) */\n "-5": "buffer error",\n /* Z_BUF_ERROR (-5) */\n "-6": "incompatible version"\n /* Z_VERSION_ERROR (-6) */\n};\nvar constants$2 = {\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n};\nconst _has = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n};\nvar assign = function(obj) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) {\n continue;\n }\n if (typeof source !== "object") {\n throw new TypeError(source + "must be non-object");\n }\n for (const p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n return obj;\n};\nvar flattenChunks = (chunks) => {\n let len = 0;\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n const result = new Uint8Array(len);\n for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n let chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n return result;\n};\nvar common$1 = {\n assign,\n flattenChunks\n};\nlet STR_APPLY_UIA_OK = true;\ntry {\n String.fromCharCode.apply(null, new Uint8Array(1));\n} catch (__) {\n STR_APPLY_UIA_OK = false;\n}\nconst _utf8len = new Uint8Array(256);\nfor (let q = 0; q < 256; q++) {\n _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;\n}\n_utf8len[254] = _utf8len[254] = 1;\nvar string2buf = (str) => {\n if (typeof TextEncoder === "function" && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;\n }\n buf = new Uint8Array(buf_len);\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n if (c < 128) {\n buf[i++] = c;\n } else if (c < 2048) {\n buf[i++] = 192 | c >>> 6;\n buf[i++] = 128 | c & 63;\n } else if (c < 65536) {\n buf[i++] = 224 | c >>> 12;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n } else {\n buf[i++] = 240 | c >>> 18;\n buf[i++] = 128 | c >>> 12 & 63;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n }\n }\n return buf;\n};\nconst buf2binstring = (buf, len) => {\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n }\n }\n let result = "";\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n};\nvar buf2string = (buf, max) => {\n const len = max || buf.length;\n if (typeof TextDecoder === "function" && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n let i, out;\n const utf16buf = new Array(len * 2);\n for (out = 0, i = 0; i < len; ) {\n let c = buf[i++];\n if (c < 128) {\n utf16buf[out++] = c;\n continue;\n }\n let c_len = _utf8len[c];\n if (c_len > 4) {\n utf16buf[out++] = 65533;\n i += c_len - 1;\n continue;\n }\n c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;\n while (c_len > 1 && i < len) {\n c = c << 6 | buf[i++] & 63;\n c_len--;\n }\n if (c_len > 1) {\n utf16buf[out++] = 65533;\n continue;\n }\n if (c < 65536) {\n utf16buf[out++] = c;\n } else {\n c -= 65536;\n utf16buf[out++] = 55296 | c >> 10 & 1023;\n utf16buf[out++] = 56320 | c & 1023;\n }\n }\n return buf2binstring(utf16buf, out);\n};\nvar utf8border = (buf, max) => {\n max = max || buf.length;\n if (max > buf.length) {\n max = buf.length;\n }\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 192) === 128) {\n pos--;\n }\n if (pos < 0) {\n return max;\n }\n if (pos === 0) {\n return max;\n }\n return pos + _utf8len[buf[pos]] > max ? pos : max;\n};\nvar strings$1 = {\n string2buf,\n buf2string,\n utf8border\n};\nfunction ZStream() {\n this.input = null;\n this.next_in = 0;\n this.avail_in = 0;\n this.total_in = 0;\n this.output = null;\n this.next_out = 0;\n this.avail_out = 0;\n this.total_out = 0;\n this.msg = "";\n this.state = null;\n this.data_type = 2;\n this.adler = 0;\n}\nvar zstream$1 = ZStream;\nconst BAD$1 = 16209;\nconst TYPE$1 = 16191;\nvar inffast$1 = function inflate_fast(strm, start) {\n let _in;\n let last;\n let _out;\n let beg;\n let end;\n let dmax;\n let wsize;\n let whave;\n let wnext;\n let s_window;\n let hold;\n let bits;\n let lcode;\n let dcode;\n let lmask;\n let dmask;\n let here;\n let op;\n let len;\n let dist;\n let from;\n let from_source;\n let input, output;\n const state = strm.state;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n dmax = state.dmax;\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = lcode[hold & lmask];\n dolen:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op === 0) {\n output[_out++] = here & 65535;\n } else if (op & 16) {\n len = here & 65535;\n op &= 15;\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & (1 << op) - 1;\n hold >>>= op;\n bits -= op;\n }\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n dodist:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op & 16) {\n dist = here & 65535;\n op &= 15;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & (1 << op) - 1;\n if (dist > dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD$1;\n break top;\n }\n hold >>>= op;\n bits -= op;\n op = _out - beg;\n if (dist > op) {\n op = dist - op;\n if (op > whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD$1;\n break top;\n }\n }\n from = 0;\n from_source = s_window;\n if (wnext === 0) {\n from += wsize - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n } else if (wnext < op) {\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) {\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n } else {\n from += wnext - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n } else {\n from = _out - dist;\n do {\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n } else if ((op & 64) === 0) {\n here = dcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dodist;\n } else {\n strm.msg = "invalid distance code";\n state.mode = BAD$1;\n break top;\n }\n break;\n }\n } else if ((op & 64) === 0) {\n here = lcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dolen;\n } else if (op & 32) {\n state.mode = TYPE$1;\n break top;\n } else {\n strm.msg = "invalid literal/length code";\n state.mode = BAD$1;\n break top;\n }\n break;\n }\n } while (_in < last && _out < end);\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);\n strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);\n state.hold = hold;\n state.bits = bits;\n return;\n};\nconst MAXBITS = 15;\nconst ENOUGH_LENS$1 = 852;\nconst ENOUGH_DISTS$1 = 592;\nconst CODES$1 = 0;\nconst LENS$1 = 1;\nconst DISTS$1 = 2;\nconst lbase = new Uint16Array([\n /* Length codes 257..285 base */\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 13,\n 15,\n 17,\n 19,\n 23,\n 27,\n 31,\n 35,\n 43,\n 51,\n 59,\n 67,\n 83,\n 99,\n 115,\n 131,\n 163,\n 195,\n 227,\n 258,\n 0,\n 0\n]);\nconst lext = new Uint8Array([\n /* Length codes 257..285 extra */\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 17,\n 17,\n 18,\n 18,\n 18,\n 18,\n 19,\n 19,\n 19,\n 19,\n 20,\n 20,\n 20,\n 20,\n 21,\n 21,\n 21,\n 21,\n 16,\n 72,\n 78\n]);\nconst dbase = new Uint16Array([\n /* Distance codes 0..29 base */\n 1,\n 2,\n 3,\n 4,\n 5,\n 7,\n 9,\n 13,\n 17,\n 25,\n 33,\n 49,\n 65,\n 97,\n 129,\n 193,\n 257,\n 385,\n 513,\n 769,\n 1025,\n 1537,\n 2049,\n 3073,\n 4097,\n 6145,\n 8193,\n 12289,\n 16385,\n 24577,\n 0,\n 0\n]);\nconst dext = new Uint8Array([\n /* Distance codes 0..29 extra */\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 18,\n 18,\n 19,\n 19,\n 20,\n 20,\n 21,\n 21,\n 22,\n 22,\n 23,\n 23,\n 24,\n 24,\n 25,\n 25,\n 26,\n 26,\n 27,\n 27,\n 28,\n 28,\n 29,\n 29,\n 64,\n 64\n]);\nconst inflate_table = (type, lens, lens_index, codes, table, table_index, work, opts) => {\n const bits = opts.bits;\n let len = 0;\n let sym = 0;\n let min = 0, max = 0;\n let root = 0;\n let curr = 0;\n let drop = 0;\n let left = 0;\n let used = 0;\n let huff = 0;\n let incr;\n let fill;\n let low;\n let mask;\n let next;\n let base = null;\n let match;\n const count = new Uint16Array(MAXBITS + 1);\n const offs = new Uint16Array(MAXBITS + 1);\n let extra = null;\n let here_bits, here_op, here_val;\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) {\n break;\n }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) {\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n opts.bits = 1;\n return 0;\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) {\n break;\n }\n }\n if (root < min) {\n root = min;\n }\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n }\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1;\n }\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n if (type === CODES$1) {\n base = extra = work;\n match = 20;\n } else if (type === LENS$1) {\n base = lbase;\n extra = lext;\n match = 257;\n } else {\n base = dbase;\n extra = dext;\n match = 0;\n }\n huff = 0;\n sym = 0;\n len = min;\n next = table_index;\n curr = root;\n drop = 0;\n low = -1;\n used = 1 << root;\n mask = used - 1;\n if (type === LENS$1 && used > ENOUGH_LENS$1 || type === DISTS$1 && used > ENOUGH_DISTS$1) {\n return 1;\n }\n for (; ; ) {\n here_bits = len - drop;\n if (work[sym] + 1 < match) {\n here_op = 0;\n here_val = work[sym];\n } else if (work[sym] >= match) {\n here_op = extra[work[sym] - match];\n here_val = base[work[sym] - match];\n } else {\n here_op = 32 + 64;\n here_val = 0;\n }\n incr = 1 << len - drop;\n fill = 1 << curr;\n min = fill;\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;\n } while (fill !== 0);\n incr = 1 << len - 1;\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n sym++;\n if (--count[len] === 0) {\n if (len === max) {\n break;\n }\n len = lens[lens_index + work[sym]];\n }\n if (len > root && (huff & mask) !== low) {\n if (drop === 0) {\n drop = root;\n }\n next += min;\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) {\n break;\n }\n curr++;\n left <<= 1;\n }\n used += 1 << curr;\n if (type === LENS$1 && used > ENOUGH_LENS$1 || type === DISTS$1 && used > ENOUGH_DISTS$1) {\n return 1;\n }\n low = huff & mask;\n table[low] = root << 24 | curr << 16 | next - table_index | 0;\n }\n }\n if (huff !== 0) {\n table[next + huff] = len - drop << 24 | 64 << 16 | 0;\n }\n opts.bits = root;\n return 0;\n};\nvar inftrees$1 = inflate_table;\nconst CODES = 0;\nconst LENS = 1;\nconst DISTS = 2;\nconst {\n Z_FINISH: Z_FINISH$1,\n Z_BLOCK,\n Z_TREES,\n Z_OK: Z_OK$1,\n Z_STREAM_END: Z_STREAM_END$1,\n Z_NEED_DICT: Z_NEED_DICT$1,\n Z_STREAM_ERROR: Z_STREAM_ERROR$1,\n Z_DATA_ERROR: Z_DATA_ERROR$1,\n Z_MEM_ERROR: Z_MEM_ERROR$1,\n Z_BUF_ERROR,\n Z_DEFLATED\n} = constants$2;\nconst HEAD = 16180;\nconst FLAGS = 16181;\nconst TIME = 16182;\nconst OS = 16183;\nconst EXLEN = 16184;\nconst EXTRA = 16185;\nconst NAME = 16186;\nconst COMMENT = 16187;\nconst HCRC = 16188;\nconst DICTID = 16189;\nconst DICT = 16190;\nconst TYPE = 16191;\nconst TYPEDO = 16192;\nconst STORED = 16193;\nconst COPY_ = 16194;\nconst COPY = 16195;\nconst TABLE = 16196;\nconst LENLENS = 16197;\nconst CODELENS = 16198;\nconst LEN_ = 16199;\nconst LEN = 16200;\nconst LENEXT = 16201;\nconst DIST = 16202;\nconst DISTEXT = 16203;\nconst MATCH = 16204;\nconst LIT = 16205;\nconst CHECK = 16206;\nconst LENGTH = 16207;\nconst DONE = 16208;\nconst BAD = 16209;\nconst MEM = 16210;\nconst SYNC = 16211;\nconst ENOUGH_LENS = 852;\nconst ENOUGH_DISTS = 592;\nconst MAX_WBITS = 15;\nconst DEF_WBITS = MAX_WBITS;\nconst zswap32 = (q) => {\n return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);\n};\nfunction InflateState() {\n this.strm = null;\n this.mode = 0;\n this.last = false;\n this.wrap = 0;\n this.havedict = false;\n this.flags = 0;\n this.dmax = 0;\n this.check = 0;\n this.total = 0;\n this.head = null;\n this.wbits = 0;\n this.wsize = 0;\n this.whave = 0;\n this.wnext = 0;\n this.window = null;\n this.hold = 0;\n this.bits = 0;\n this.length = 0;\n this.offset = 0;\n this.extra = 0;\n this.lencode = null;\n this.distcode = null;\n this.lenbits = 0;\n this.distbits = 0;\n this.ncode = 0;\n this.nlen = 0;\n this.ndist = 0;\n this.have = 0;\n this.next = null;\n this.lens = new Uint16Array(320);\n this.work = new Uint16Array(288);\n this.lendyn = null;\n this.distdyn = null;\n this.sane = 0;\n this.back = 0;\n this.was = 0;\n}\nconst inflateStateCheck = (strm) => {\n if (!strm) {\n return 1;\n }\n const state = strm.state;\n if (!state || state.strm !== strm || state.mode < HEAD || state.mode > SYNC) {\n return 1;\n }\n return 0;\n};\nconst inflateResetKeep = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = "";\n if (state.wrap) {\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.flags = -1;\n state.dmax = 32768;\n state.head = null;\n state.hold = 0;\n state.bits = 0;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n state.sane = 1;\n state.back = -1;\n return Z_OK$1;\n};\nconst inflateReset = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n};\nconst inflateReset2 = (strm, windowBits) => {\n let wrap;\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else {\n wrap = (windowBits >> 4) + 5;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR$1;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n};\nconst inflateInit2 = (strm, windowBits) => {\n if (!strm) {\n return Z_STREAM_ERROR$1;\n }\n const state = new InflateState();\n strm.state = state;\n state.strm = strm;\n state.window = null;\n state.mode = HEAD;\n const ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK$1) {\n strm.state = null;\n }\n return ret;\n};\nconst inflateInit = (strm) => {\n return inflateInit2(strm, DEF_WBITS);\n};\nlet virgin = true;\nlet lenfix, distfix;\nconst fixedtables = (state) => {\n if (virgin) {\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n let sym = 0;\n while (sym < 144) {\n state.lens[sym++] = 8;\n }\n while (sym < 256) {\n state.lens[sym++] = 9;\n }\n while (sym < 280) {\n state.lens[sym++] = 7;\n }\n while (sym < 288) {\n state.lens[sym++] = 8;\n }\n inftrees$1(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n sym = 0;\n while (sym < 32) {\n state.lens[sym++] = 5;\n }\n inftrees$1(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n virgin = false;\n }\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n};\nconst updatewindow = (strm, src, end, copy) => {\n let dist;\n const state = strm.state;\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n state.window = new Uint8Array(state.wsize);\n }\n if (copy >= state.wsize) {\n state.window.set(src.subarray(end - state.wsize, end), 0);\n state.wnext = 0;\n state.whave = state.wsize;\n } else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n } else {\n state.wnext += dist;\n if (state.wnext === state.wsize) {\n state.wnext = 0;\n }\n if (state.whave < state.wsize) {\n state.whave += dist;\n }\n }\n }\n return 0;\n};\nconst inflate$2 = (strm, flush) => {\n let state;\n let input, output;\n let next;\n let put;\n let have, left;\n let hold;\n let bits;\n let _in, _out;\n let copy;\n let from;\n let from_source;\n let here = 0;\n let here_bits, here_op, here_val;\n let last_bits, last_op, last_val;\n let len;\n let ret;\n const hbuf = new Uint8Array(4);\n let opts;\n let n;\n const order = (\n /* permutation of code lengths */\n new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])\n );\n if (inflateStateCheck(strm) || !strm.output || !strm.input && strm.avail_in !== 0) {\n return Z_STREAM_ERROR$1;\n }\n state = strm.state;\n if (state.mode === TYPE) {\n state.mode = TYPEDO;\n }\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n _in = have;\n _out = left;\n ret = Z_OK$1;\n inf_leave:\n for (; ; ) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 2 && hold === 35615) {\n if (state.wbits === 0) {\n state.wbits = 15;\n }\n state.check = 0;\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n hold = 0;\n bits = 0;\n state.mode = FLAGS;\n break;\n }\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 255) << 8) + (hold >> 8)) % 31) {\n strm.msg = "incorrect header check";\n state.mode = BAD;\n break;\n }\n if ((hold & 15) !== Z_DEFLATED) {\n strm.msg = "unknown compression method";\n state.mode = BAD;\n break;\n }\n hold >>>= 4;\n bits -= 4;\n len = (hold & 15) + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n if (len > 15 || len > state.wbits) {\n strm.msg = "invalid window size";\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << state.wbits;\n state.flags = 0;\n strm.adler = state.check = 1;\n state.mode = hold & 512 ? DICTID : TYPE;\n hold = 0;\n bits = 0;\n break;\n case FLAGS:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.flags = hold;\n if ((state.flags & 255) !== Z_DEFLATED) {\n strm.msg = "unknown compression method";\n state.mode = BAD;\n break;\n }\n if (state.flags & 57344) {\n strm.msg = "unknown header flags set";\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = hold >> 8 & 1;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = TIME;\n /* falls through */\n case TIME:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n hbuf[2] = hold >>> 16 & 255;\n hbuf[3] = hold >>> 24 & 255;\n state.check = crc32_1$1(state.check, hbuf, 4, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = OS;\n /* falls through */\n case OS:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.xflags = hold & 255;\n state.head.os = hold >> 8;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 1024) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n } else if (state.head) {\n state.head.extra = null;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 1024) {\n copy = state.length;\n if (copy > have) {\n copy = have;\n }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n state.head.extra = new Uint8Array(state.head.extra_len);\n }\n state.head.extra.set(\n input.subarray(\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n next + copy\n ),\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n }\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) {\n break inf_leave;\n }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 2048) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 4096) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 512) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.check & 65535)) {\n strm.msg = "header crc mismatch";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n if (state.head) {\n state.head.hcrc = state.flags >> 9 & 1;\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n strm.adler = state.check = zswap32(hold);\n hold = 0;\n bits = 0;\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n return Z_NEED_DICT$1;\n }\n strm.adler = state.check = 1;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n hold >>>= bits & 7;\n bits -= bits & 7;\n state.mode = CHECK;\n break;\n }\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.last = hold & 1;\n hold >>>= 1;\n bits -= 1;\n switch (hold & 3) {\n case 0:\n state.mode = STORED;\n break;\n case 1:\n fixedtables(state);\n state.mode = LEN_;\n if (flush === Z_TREES) {\n hold >>>= 2;\n bits -= 2;\n break inf_leave;\n }\n break;\n case 2:\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = "invalid block type";\n state.mode = BAD;\n }\n hold >>>= 2;\n bits -= 2;\n break;\n case STORED:\n hold >>>= bits & 7;\n bits -= bits & 7;\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {\n strm.msg = "invalid stored block lengths";\n state.mode = BAD;\n break;\n }\n state.length = hold & 65535;\n hold = 0;\n bits = 0;\n state.mode = COPY_;\n if (flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) {\n copy = have;\n }\n if (copy > left) {\n copy = left;\n }\n if (copy === 0) {\n break inf_leave;\n }\n output.set(input.subarray(next, next + copy), put);\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n state.mode = TYPE;\n break;\n case TABLE:\n while (bits < 14) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.nlen = (hold & 31) + 257;\n hold >>>= 5;\n bits -= 5;\n state.ndist = (hold & 31) + 1;\n hold >>>= 5;\n bits -= 5;\n state.ncode = (hold & 15) + 4;\n hold >>>= 4;\n bits -= 4;\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = "too many length or distance symbols";\n state.mode = BAD;\n break;\n }\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.lens[order[state.have++]] = hold & 7;\n hold >>>= 3;\n bits -= 3;\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n state.lencode = state.lendyn;\n state.lenbits = 7;\n opts = { bits: state.lenbits };\n ret = inftrees$1(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid code lengths set";\n state.mode = BAD;\n break;\n }\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_val < 16) {\n hold >>>= here_bits;\n bits -= here_bits;\n state.lens[state.have++] = here_val;\n } else {\n if (here_val === 16) {\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n if (state.have === 0) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 3);\n hold >>>= 2;\n bits -= 2;\n } else if (here_val === 17) {\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 3 + (hold & 7);\n hold >>>= 3;\n bits -= 3;\n } else {\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 11 + (hold & 127);\n hold >>>= 7;\n bits -= 7;\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n if (state.mode === BAD) {\n break;\n }\n if (state.lens[256] === 0) {\n strm.msg = "invalid code -- missing end-of-block";\n state.mode = BAD;\n break;\n }\n state.lenbits = 9;\n opts = { bits: state.lenbits };\n ret = inftrees$1(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid literal/lengths set";\n state.mode = BAD;\n break;\n }\n state.distbits = 6;\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inftrees$1(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n state.distbits = opts.bits;\n if (ret) {\n strm.msg = "invalid distances set";\n state.mode = BAD;\n break;\n }\n state.mode = LEN_;\n if (flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n inffast$1(strm, _out);\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_op && (here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = "invalid literal/length code";\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (; ; ) {\n here = state.distcode[hold & (1 << state.distbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = "invalid distance code";\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = here_op & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.offset += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n if (state.offset > state.dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD;\n break;\n }\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) {\n break inf_leave;\n }\n copy = _out - left;\n if (state.offset > copy) {\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD;\n break;\n }\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n } else {\n from = state.wnext - copy;\n }\n if (copy > state.length) {\n copy = state.length;\n }\n from_source = state.window;\n } else {\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) {\n copy = left;\n }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) {\n state.mode = LEN;\n }\n break;\n case LIT:\n if (left === 0) {\n break inf_leave;\n }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold |= input[next++] << bits;\n bits += 8;\n }\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/\n state.flags ? crc32_1$1(state.check, output, _out, put - _out) : adler32_1$1(state.check, output, _out, put - _out);\n }\n _out = left;\n if (state.wrap & 4 && (state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = "incorrect data check";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.total & 4294967295)) {\n strm.msg = "incorrect length check";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END$1;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR$1;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR$1;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR$1;\n }\n }\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH$1)) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/\n state.flags ? crc32_1$1(state.check, output, _out, strm.next_out - _out) : adler32_1$1(state.check, output, _out, strm.next_out - _out);\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if ((_in === 0 && _out === 0 || flush === Z_FINISH$1) && ret === Z_OK$1) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n};\nconst inflateEnd = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK$1;\n};\nconst inflateGetHeader = (strm, head) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n if ((state.wrap & 2) === 0) {\n return Z_STREAM_ERROR$1;\n }\n state.head = head;\n head.done = false;\n return Z_OK$1;\n};\nconst inflateSetDictionary = (strm, dictionary) => {\n const dictLength = dictionary.length;\n let state;\n let dictid;\n let ret;\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n state = strm.state;\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR$1;\n }\n if (state.mode === DICT) {\n dictid = 1;\n dictid = adler32_1$1(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR$1;\n }\n }\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR$1;\n }\n state.havedict = 1;\n return Z_OK$1;\n};\nvar inflateReset_1 = inflateReset;\nvar inflateReset2_1 = inflateReset2;\nvar inflateResetKeep_1 = inflateResetKeep;\nvar inflateInit_1 = inflateInit;\nvar inflateInit2_1 = inflateInit2;\nvar inflate_2$1 = inflate$2;\nvar inflateEnd_1 = inflateEnd;\nvar inflateGetHeader_1 = inflateGetHeader;\nvar inflateSetDictionary_1 = inflateSetDictionary;\nvar inflateInfo = "pako inflate (from Nodeca project)";\nvar inflate_1$2 = {\n inflateReset: inflateReset_1,\n inflateReset2: inflateReset2_1,\n inflateResetKeep: inflateResetKeep_1,\n inflateInit: inflateInit_1,\n inflateInit2: inflateInit2_1,\n inflate: inflate_2$1,\n inflateEnd: inflateEnd_1,\n inflateGetHeader: inflateGetHeader_1,\n inflateSetDictionary: inflateSetDictionary_1,\n inflateInfo\n};\nfunction GZheader() {\n this.text = 0;\n this.time = 0;\n this.xflags = 0;\n this.os = 0;\n this.extra = null;\n this.extra_len = 0;\n this.name = "";\n this.comment = "";\n this.hcrc = 0;\n this.done = false;\n}\nvar gzheader$1 = GZheader;\nconst toString = Object.prototype.toString;\nconst {\n Z_NO_FLUSH,\n Z_FINISH,\n Z_OK,\n Z_STREAM_END,\n Z_NEED_DICT,\n Z_STREAM_ERROR,\n Z_DATA_ERROR,\n Z_MEM_ERROR\n} = constants$2;\nfunction Inflate$1(options) {\n this.options = common$1.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ""\n }, options || {});\n const opt = this.options;\n if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) {\n opt.windowBits = -15;\n }\n }\n if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n if (opt.windowBits > 15 && opt.windowBits < 48) {\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new zstream$1();\n this.strm.avail_out = 0;\n let status = inflate_1$2.inflateInit2(\n this.strm,\n opt.windowBits\n );\n if (status !== Z_OK) {\n throw new Error(messages$1[status]);\n }\n this.header = new gzheader$1();\n inflate_1$2.inflateGetHeader(this.strm, this.header);\n if (opt.dictionary) {\n if (typeof opt.dictionary === "string") {\n opt.dictionary = strings$1.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) {\n status = inflate_1$2.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK) {\n throw new Error(messages$1[status]);\n }\n }\n }\n}\nInflate$1.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n const dictionary = this.options.dictionary;\n let status, _flush_mode, last_avail_out;\n if (this.ended) return false;\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH : Z_NO_FLUSH;\n if (toString.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n for (; ; ) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = inflate_1$2.inflate(strm, _flush_mode);\n if (status === Z_NEED_DICT && dictionary) {\n status = inflate_1$2.inflateSetDictionary(strm, dictionary);\n if (status === Z_OK) {\n status = inflate_1$2.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR) {\n status = Z_NEED_DICT;\n }\n }\n while (strm.avail_in > 0 && status === Z_STREAM_END && strm.state.wrap > 0 && data[strm.next_in] !== 0) {\n inflate_1$2.inflateReset(strm);\n status = inflate_1$2.inflate(strm, _flush_mode);\n }\n switch (status) {\n case Z_STREAM_ERROR:\n case Z_DATA_ERROR:\n case Z_NEED_DICT:\n case Z_MEM_ERROR:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n last_avail_out = strm.avail_out;\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END) {\n if (this.options.to === "string") {\n let next_out_utf8 = strings$1.utf8border(strm.output, strm.next_out);\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings$1.buf2string(strm.output, next_out_utf8);\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);\n this.onData(utf8str);\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n if (status === Z_OK && last_avail_out === 0) continue;\n if (status === Z_STREAM_END) {\n status = inflate_1$2.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n};\nInflate$1.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n};\nInflate$1.prototype.onEnd = function(status) {\n if (status === Z_OK) {\n if (this.options.to === "string") {\n this.result = this.chunks.join("");\n } else {\n this.result = common$1.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\nfunction inflate$1$1(input, options) {\n const inflator = new Inflate$1(options);\n inflator.push(input);\n if (inflator.err) throw inflator.msg || messages$1[inflator.err];\n return inflator.result;\n}\nvar inflate_2 = inflate$1$1;\nvar inflate_1$1 = {\n inflate: inflate_2\n};\nconst { inflate: inflate$3 } = inflate_1$1;\nvar inflate_1 = inflate$3;\nvar png = {};\nvar assert$1 = {};\nvar hasRequiredAssert$1;\nfunction requireAssert$1() {\n if (hasRequiredAssert$1) return assert$1;\n hasRequiredAssert$1 = 1;\n Object.defineProperty(assert$1, "__esModule", { value: true });\n assert$1.handleWarning = assert$1.DecodeWarning = assert$1.createChunkDecodeWarning = assert$1.DecodeError = assert$1.createChunkDecodeError = assert$1.assertChunkCompressionMethod = assert$1.assertChunkMutualExclusion = assert$1.assertChunkFollows = assert$1.assertChunkPrecedes = assert$1.assertChunkDataLengthGte = assert$1.assertChunkDataLengthEquals = assert$1.assertChunkSinglular = void 0;\n function assertChunkSinglular(ctx, chunk) {\n if (ctx.parsedChunks.has(chunk.type)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Multiple ${chunk.type} chunks not allowed`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkSinglular = assertChunkSinglular;\n function assertChunkDataLengthEquals(ctx, chunk, expected) {\n if (chunk.dataLength !== expected) {\n const error = createChunkDecodeWarning(chunk, `Invalid data length: ${chunk.dataLength} !== ${expected}`, chunk.offset);\n if (chunk.dataLength > expected) {\n handleWarning(ctx, error);\n } else {\n throw error;\n }\n }\n }\n assert$1.assertChunkDataLengthEquals = assertChunkDataLengthEquals;\n function assertChunkDataLengthGte(ctx, chunk, expected) {\n if (chunk.dataLength < expected) {\n throw createChunkDecodeError(ctx, chunk, `Invalid data length: ${chunk.dataLength} < ${expected}`, chunk.offset);\n }\n }\n assert$1.assertChunkDataLengthGte = assertChunkDataLengthGte;\n function assertChunkPrecedes(ctx, chunk, typeAfter) {\n if (ctx.parsedChunks.has(typeAfter)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Must precede ${typeAfter}`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkPrecedes = assertChunkPrecedes;\n function assertChunkFollows(ctx, chunk, typeAfter) {\n if (!ctx.parsedChunks.has(typeAfter)) {\n throw createChunkDecodeError(ctx, chunk, `Must follow ${typeAfter}`, chunk.offset + 4);\n }\n }\n assert$1.assertChunkFollows = assertChunkFollows;\n function assertChunkMutualExclusion(ctx, chunk, otherType) {\n if (ctx.parsedChunks.has(otherType)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Should not be present alongside ${otherType}`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkMutualExclusion = assertChunkMutualExclusion;\n function assertChunkCompressionMethod(ctx, chunk, compressionMethod, offset) {\n if (compressionMethod !== 0) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Unknown compression method "${compressionMethod}"`, offset));\n }\n }\n assert$1.assertChunkCompressionMethod = assertChunkCompressionMethod;\n function createChunkDecodeError(ctx, chunk, message, offset) {\n return new DecodeError(ctx, `${chunk.type}: ${message}`, offset);\n }\n assert$1.createChunkDecodeError = createChunkDecodeError;\n class DecodeError extends Error {\n constructor(ctx, message, offset) {\n super(message);\n this.offset = offset;\n this.partiallyDecodedImage = {\n details: "header" in ctx && ctx.header ? {\n width: ctx.header.width,\n height: ctx.header.height,\n bitDepth: ctx.header.bitDepth,\n colorType: ctx.header.colorType,\n interlaceMethod: ctx.header.interlaceMethod\n } : void 0,\n info: ctx.info,\n metadata: ctx.metadata,\n rawChunks: ctx.rawChunks,\n warnings: ctx.warnings\n };\n }\n }\n assert$1.DecodeError = DecodeError;\n function createChunkDecodeWarning(chunk, message, offset) {\n return new DecodeWarning(`${chunk.type}: ${message}`, offset);\n }\n assert$1.createChunkDecodeWarning = createChunkDecodeWarning;\n class DecodeWarning extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert$1.DecodeWarning = DecodeWarning;\n function handleWarning(ctx, warning) {\n if (ctx.options.strictMode) {\n throw warning;\n }\n ctx.warnings.push(warning);\n }\n assert$1.handleWarning = handleWarning;\n return assert$1;\n}\nvar assert = {};\nvar hasRequiredAssert;\nfunction requireAssert() {\n if (hasRequiredAssert) return assert;\n hasRequiredAssert = 1;\n Object.defineProperty(assert, "__esModule", { value: true });\n assert.handleWarning = assert.EncodeWarning = assert.EncodeError = void 0;\n class EncodeError extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert.EncodeError = EncodeError;\n class EncodeWarning extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert.EncodeWarning = EncodeWarning;\n function handleWarning(ctx, warning) {\n if (ctx.options.strictMode) {\n throw warning;\n }\n ctx.warnings.push(warning);\n }\n assert.handleWarning = handleWarning;\n return assert;\n}\nvar decoder = {};\nvar array = {};\nvar hasRequiredArray;\nfunction requireArray() {\n if (hasRequiredArray) return array;\n hasRequiredArray = 1;\n Object.defineProperty(array, "__esModule", { value: true });\n array.convert16BitTo8BitData = void 0;\n function convert16BitTo8BitData(data) {\n const view8Bit = new Uint8Array(data.buffer);\n const result = new Uint8Array(data.length);\n for (let i = 0; i < result.length; i++) {\n result[i] = view8Bit[i * 2 + 1];\n }\n return result;\n }\n array.convert16BitTo8BitData = convert16BitTo8BitData;\n return array;\n}\nvar chunk_IDAT = {};\nvar pako = {};\nvar deflate$1 = {};\nvar deflate = {};\nvar trees = {};\nvar hasRequiredTrees;\nfunction requireTrees() {\n if (hasRequiredTrees) return trees;\n hasRequiredTrees = 1;\n const Z_FIXED = 4;\n const Z_BINARY = 0;\n const Z_TEXT = 1;\n const Z_UNKNOWN = 2;\n function zero(buf) {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n }\n const STORED_BLOCK = 0;\n const STATIC_TREES = 1;\n const DYN_TREES = 2;\n const MIN_MATCH = 3;\n const MAX_MATCH = 258;\n const LENGTH_CODES = 29;\n const LITERALS = 256;\n const L_CODES = LITERALS + 1 + LENGTH_CODES;\n const D_CODES = 30;\n const BL_CODES = 19;\n const HEAP_SIZE = 2 * L_CODES + 1;\n const MAX_BITS = 15;\n const Buf_size = 16;\n const MAX_BL_BITS = 7;\n const END_BLOCK = 256;\n const REP_3_6 = 16;\n const REPZ_3_10 = 17;\n const REPZ_11_138 = 18;\n const extra_lbits = (\n /* extra bits for each length code */\n new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0])\n );\n const extra_dbits = (\n /* extra bits for each distance code */\n new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13])\n );\n const extra_blbits = (\n /* extra bits for each bit length code */\n new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7])\n );\n const bl_order = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n const DIST_CODE_LEN2 = 512;\n const static_ltree2 = new Array((L_CODES + 2) * 2);\n zero(static_ltree2);\n const static_dtree2 = new Array(D_CODES * 2);\n zero(static_dtree2);\n const _dist_code2 = new Array(DIST_CODE_LEN2);\n zero(_dist_code2);\n const _length_code2 = new Array(MAX_MATCH - MIN_MATCH + 1);\n zero(_length_code2);\n const base_length2 = new Array(LENGTH_CODES);\n zero(base_length2);\n const base_dist2 = new Array(D_CODES);\n zero(base_dist2);\n function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n this.static_tree = static_tree;\n this.extra_bits = extra_bits;\n this.extra_base = extra_base;\n this.elems = elems;\n this.max_length = max_length;\n this.has_stree = static_tree && static_tree.length;\n }\n let static_l_desc;\n let static_d_desc;\n let static_bl_desc;\n function TreeDesc(dyn_tree, stat_desc) {\n this.dyn_tree = dyn_tree;\n this.max_code = 0;\n this.stat_desc = stat_desc;\n }\n const d_code = (dist) => {\n return dist < 256 ? _dist_code2[dist] : _dist_code2[256 + (dist >>> 7)];\n };\n const put_short = (s, w) => {\n s.pending_buf[s.pending++] = w & 255;\n s.pending_buf[s.pending++] = w >>> 8 & 255;\n };\n const send_bits = (s, value, length) => {\n if (s.bi_valid > Buf_size - length) {\n s.bi_buf |= value << s.bi_valid & 65535;\n put_short(s, s.bi_buf);\n s.bi_buf = value >> Buf_size - s.bi_valid;\n s.bi_valid += length - Buf_size;\n } else {\n s.bi_buf |= value << s.bi_valid & 65535;\n s.bi_valid += length;\n }\n };\n const send_code = (s, c, tree) => {\n send_bits(\n s,\n tree[c * 2],\n tree[c * 2 + 1]\n /*.Len*/\n );\n };\n const bi_reverse = (code, len) => {\n let res = 0;\n do {\n res |= code & 1;\n code >>>= 1;\n res <<= 1;\n } while (--len > 0);\n return res >>> 1;\n };\n const bi_flush = (s) => {\n if (s.bi_valid === 16) {\n put_short(s, s.bi_buf);\n s.bi_buf = 0;\n s.bi_valid = 0;\n } else if (s.bi_valid >= 8) {\n s.pending_buf[s.pending++] = s.bi_buf & 255;\n s.bi_buf >>= 8;\n s.bi_valid -= 8;\n }\n };\n const gen_bitlen = (s, desc) => {\n const tree = desc.dyn_tree;\n const max_code = desc.max_code;\n const stree = desc.stat_desc.static_tree;\n const has_stree = desc.stat_desc.has_stree;\n const extra = desc.stat_desc.extra_bits;\n const base = desc.stat_desc.extra_base;\n const max_length = desc.stat_desc.max_length;\n let h;\n let n, m;\n let bits;\n let xbits;\n let f;\n let overflow = 0;\n for (bits = 0; bits <= MAX_BITS; bits++) {\n s.bl_count[bits] = 0;\n }\n tree[s.heap[s.heap_max] * 2 + 1] = 0;\n for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {\n n = s.heap[h];\n bits = tree[tree[n * 2 + 1] * 2 + 1] + 1;\n if (bits > max_length) {\n bits = max_length;\n overflow++;\n }\n tree[n * 2 + 1] = bits;\n if (n > max_code) {\n continue;\n }\n s.bl_count[bits]++;\n xbits = 0;\n if (n >= base) {\n xbits = extra[n - base];\n }\n f = tree[n * 2];\n s.opt_len += f * (bits + xbits);\n if (has_stree) {\n s.static_len += f * (stree[n * 2 + 1] + xbits);\n }\n }\n if (overflow === 0) {\n return;\n }\n do {\n bits = max_length - 1;\n while (s.bl_count[bits] === 0) {\n bits--;\n }\n s.bl_count[bits]--;\n s.bl_count[bits + 1] += 2;\n s.bl_count[max_length]--;\n overflow -= 2;\n } while (overflow > 0);\n for (bits = max_length; bits !== 0; bits--) {\n n = s.bl_count[bits];\n while (n !== 0) {\n m = s.heap[--h];\n if (m > max_code) {\n continue;\n }\n if (tree[m * 2 + 1] !== bits) {\n s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2];\n tree[m * 2 + 1] = bits;\n }\n n--;\n }\n }\n };\n const gen_codes = (tree, max_code, bl_count) => {\n const next_code = new Array(MAX_BITS + 1);\n let code = 0;\n let bits;\n let n;\n for (bits = 1; bits <= MAX_BITS; bits++) {\n code = code + bl_count[bits - 1] << 1;\n next_code[bits] = code;\n }\n for (n = 0; n <= max_code; n++) {\n let len = tree[n * 2 + 1];\n if (len === 0) {\n continue;\n }\n tree[n * 2] = bi_reverse(next_code[len]++, len);\n }\n };\n const tr_static_init = () => {\n let n;\n let bits;\n let length;\n let code;\n let dist;\n const bl_count = new Array(MAX_BITS + 1);\n length = 0;\n for (code = 0; code < LENGTH_CODES - 1; code++) {\n base_length2[code] = length;\n for (n = 0; n < 1 << extra_lbits[code]; n++) {\n _length_code2[length++] = code;\n }\n }\n _length_code2[length - 1] = code;\n dist = 0;\n for (code = 0; code < 16; code++) {\n base_dist2[code] = dist;\n for (n = 0; n < 1 << extra_dbits[code]; n++) {\n _dist_code2[dist++] = code;\n }\n }\n dist >>= 7;\n for (; code < D_CODES; code++) {\n base_dist2[code] = dist << 7;\n for (n = 0; n < 1 << extra_dbits[code] - 7; n++) {\n _dist_code2[256 + dist++] = code;\n }\n }\n for (bits = 0; bits <= MAX_BITS; bits++) {\n bl_count[bits] = 0;\n }\n n = 0;\n while (n <= 143) {\n static_ltree2[n * 2 + 1] = 8;\n n++;\n bl_count[8]++;\n }\n while (n <= 255) {\n static_ltree2[n * 2 + 1] = 9;\n n++;\n bl_count[9]++;\n }\n while (n <= 279) {\n static_ltree2[n * 2 + 1] = 7;\n n++;\n bl_count[7]++;\n }\n while (n <= 287) {\n static_ltree2[n * 2 + 1] = 8;\n n++;\n bl_count[8]++;\n }\n gen_codes(static_ltree2, L_CODES + 1, bl_count);\n for (n = 0; n < D_CODES; n++) {\n static_dtree2[n * 2 + 1] = 5;\n static_dtree2[n * 2] = bi_reverse(n, 5);\n }\n static_l_desc = new StaticTreeDesc(static_ltree2, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);\n static_d_desc = new StaticTreeDesc(static_dtree2, extra_dbits, 0, D_CODES, MAX_BITS);\n static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);\n };\n const init_block = (s) => {\n let n;\n for (n = 0; n < L_CODES; n++) {\n s.dyn_ltree[n * 2] = 0;\n }\n for (n = 0; n < D_CODES; n++) {\n s.dyn_dtree[n * 2] = 0;\n }\n for (n = 0; n < BL_CODES; n++) {\n s.bl_tree[n * 2] = 0;\n }\n s.dyn_ltree[END_BLOCK * 2] = 1;\n s.opt_len = s.static_len = 0;\n s.sym_next = s.matches = 0;\n };\n const bi_windup = (s) => {\n if (s.bi_valid > 8) {\n put_short(s, s.bi_buf);\n } else if (s.bi_valid > 0) {\n s.pending_buf[s.pending++] = s.bi_buf;\n }\n s.bi_buf = 0;\n s.bi_valid = 0;\n };\n const smaller = (tree, n, m, depth) => {\n const _n2 = n * 2;\n const _m2 = m * 2;\n return tree[_n2] < tree[_m2] || tree[_n2] === tree[_m2] && depth[n] <= depth[m];\n };\n const pqdownheap = (s, tree, k) => {\n const v = s.heap[k];\n let j = k << 1;\n while (j <= s.heap_len) {\n if (j < s.heap_len && smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n j++;\n }\n if (smaller(tree, v, s.heap[j], s.depth)) {\n break;\n }\n s.heap[k] = s.heap[j];\n k = j;\n j <<= 1;\n }\n s.heap[k] = v;\n };\n const compress_block = (s, ltree, dtree) => {\n let dist;\n let lc;\n let sx = 0;\n let code;\n let extra;\n if (s.sym_next !== 0) {\n do {\n dist = s.pending_buf[s.sym_buf + sx++] & 255;\n dist += (s.pending_buf[s.sym_buf + sx++] & 255) << 8;\n lc = s.pending_buf[s.sym_buf + sx++];\n if (dist === 0) {\n send_code(s, lc, ltree);\n } else {\n code = _length_code2[lc];\n send_code(s, code + LITERALS + 1, ltree);\n extra = extra_lbits[code];\n if (extra !== 0) {\n lc -= base_length2[code];\n send_bits(s, lc, extra);\n }\n dist--;\n code = d_code(dist);\n send_code(s, code, dtree);\n extra = extra_dbits[code];\n if (extra !== 0) {\n dist -= base_dist2[code];\n send_bits(s, dist, extra);\n }\n }\n } while (sx < s.sym_next);\n }\n send_code(s, END_BLOCK, ltree);\n };\n const build_tree = (s, desc) => {\n const tree = desc.dyn_tree;\n const stree = desc.stat_desc.static_tree;\n const has_stree = desc.stat_desc.has_stree;\n const elems = desc.stat_desc.elems;\n let n, m;\n let max_code = -1;\n let node;\n s.heap_len = 0;\n s.heap_max = HEAP_SIZE;\n for (n = 0; n < elems; n++) {\n if (tree[n * 2] !== 0) {\n s.heap[++s.heap_len] = max_code = n;\n s.depth[n] = 0;\n } else {\n tree[n * 2 + 1] = 0;\n }\n }\n while (s.heap_len < 2) {\n node = s.heap[++s.heap_len] = max_code < 2 ? ++max_code : 0;\n tree[node * 2] = 1;\n s.depth[node] = 0;\n s.opt_len--;\n if (has_stree) {\n s.static_len -= stree[node * 2 + 1];\n }\n }\n desc.max_code = max_code;\n for (n = s.heap_len >> 1; n >= 1; n--) {\n pqdownheap(s, tree, n);\n }\n node = elems;\n do {\n n = s.heap[\n 1\n /*SMALLEST*/\n ];\n s.heap[\n 1\n /*SMALLEST*/\n ] = s.heap[s.heap_len--];\n pqdownheap(\n s,\n tree,\n 1\n /*SMALLEST*/\n );\n m = s.heap[\n 1\n /*SMALLEST*/\n ];\n s.heap[--s.heap_max] = n;\n s.heap[--s.heap_max] = m;\n tree[node * 2] = tree[n * 2] + tree[m * 2];\n s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n tree[n * 2 + 1] = tree[m * 2 + 1] = node;\n s.heap[\n 1\n /*SMALLEST*/\n ] = node++;\n pqdownheap(\n s,\n tree,\n 1\n /*SMALLEST*/\n );\n } while (s.heap_len >= 2);\n s.heap[--s.heap_max] = s.heap[\n 1\n /*SMALLEST*/\n ];\n gen_bitlen(s, desc);\n gen_codes(tree, max_code, s.bl_count);\n };\n const scan_tree = (s, tree, max_code) => {\n let n;\n let prevlen = -1;\n let curlen;\n let nextlen = tree[0 * 2 + 1];\n let count = 0;\n let max_count = 7;\n let min_count = 4;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n tree[(max_code + 1) * 2 + 1] = 65535;\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1];\n if (++count < max_count && curlen === nextlen) {\n continue;\n } else if (count < min_count) {\n s.bl_tree[curlen * 2] += count;\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n s.bl_tree[curlen * 2]++;\n }\n s.bl_tree[REP_3_6 * 2]++;\n } else if (count <= 10) {\n s.bl_tree[REPZ_3_10 * 2]++;\n } else {\n s.bl_tree[REPZ_11_138 * 2]++;\n }\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n };\n const send_tree = (s, tree, max_code) => {\n let n;\n let prevlen = -1;\n let curlen;\n let nextlen = tree[0 * 2 + 1];\n let count = 0;\n let max_count = 7;\n let min_count = 4;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1];\n if (++count < max_count && curlen === nextlen) {\n continue;\n } else if (count < min_count) {\n do {\n send_code(s, curlen, s.bl_tree);\n } while (--count !== 0);\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n send_code(s, curlen, s.bl_tree);\n count--;\n }\n send_code(s, REP_3_6, s.bl_tree);\n send_bits(s, count - 3, 2);\n } else if (count <= 10) {\n send_code(s, REPZ_3_10, s.bl_tree);\n send_bits(s, count - 3, 3);\n } else {\n send_code(s, REPZ_11_138, s.bl_tree);\n send_bits(s, count - 11, 7);\n }\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n };\n const build_bl_tree = (s) => {\n let max_blindex;\n scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n build_tree(s, s.bl_desc);\n for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {\n if (s.bl_tree[bl_order[max_blindex] * 2 + 1] !== 0) {\n break;\n }\n }\n s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n return max_blindex;\n };\n const send_all_trees = (s, lcodes, dcodes, blcodes) => {\n let rank;\n send_bits(s, lcodes - 257, 5);\n send_bits(s, dcodes - 1, 5);\n send_bits(s, blcodes - 4, 4);\n for (rank = 0; rank < blcodes; rank++) {\n send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1], 3);\n }\n send_tree(s, s.dyn_ltree, lcodes - 1);\n send_tree(s, s.dyn_dtree, dcodes - 1);\n };\n const detect_data_type = (s) => {\n let block_mask = 4093624447;\n let n;\n for (n = 0; n <= 31; n++, block_mask >>>= 1) {\n if (block_mask & 1 && s.dyn_ltree[n * 2] !== 0) {\n return Z_BINARY;\n }\n }\n if (s.dyn_ltree[9 * 2] !== 0 || s.dyn_ltree[10 * 2] !== 0 || s.dyn_ltree[13 * 2] !== 0) {\n return Z_TEXT;\n }\n for (n = 32; n < LITERALS; n++) {\n if (s.dyn_ltree[n * 2] !== 0) {\n return Z_TEXT;\n }\n }\n return Z_BINARY;\n };\n let static_init_done = false;\n const _tr_init = (s) => {\n if (!static_init_done) {\n tr_static_init();\n static_init_done = true;\n }\n s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);\n s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);\n s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n s.bi_buf = 0;\n s.bi_valid = 0;\n init_block(s);\n };\n const _tr_stored_block = (s, buf, stored_len, last) => {\n send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3);\n bi_windup(s);\n put_short(s, stored_len);\n put_short(s, ~stored_len);\n if (stored_len) {\n s.pending_buf.set(s.window.subarray(buf, buf + stored_len), s.pending);\n }\n s.pending += stored_len;\n };\n const _tr_align = (s) => {\n send_bits(s, STATIC_TREES << 1, 3);\n send_code(s, END_BLOCK, static_ltree2);\n bi_flush(s);\n };\n const _tr_flush_block = (s, buf, stored_len, last) => {\n let opt_lenb, static_lenb;\n let max_blindex = 0;\n if (s.level > 0) {\n if (s.strm.data_type === Z_UNKNOWN) {\n s.strm.data_type = detect_data_type(s);\n }\n build_tree(s, s.l_desc);\n build_tree(s, s.d_desc);\n max_blindex = build_bl_tree(s);\n opt_lenb = s.opt_len + 3 + 7 >>> 3;\n static_lenb = s.static_len + 3 + 7 >>> 3;\n if (static_lenb <= opt_lenb) {\n opt_lenb = static_lenb;\n }\n } else {\n opt_lenb = static_lenb = stored_len + 5;\n }\n if (stored_len + 4 <= opt_lenb && buf !== -1) {\n _tr_stored_block(s, buf, stored_len, last);\n } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {\n send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n compress_block(s, static_ltree2, static_dtree2);\n } else {\n send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n compress_block(s, s.dyn_ltree, s.dyn_dtree);\n }\n init_block(s);\n if (last) {\n bi_windup(s);\n }\n };\n const _tr_tally = (s, dist, lc) => {\n s.pending_buf[s.sym_buf + s.sym_next++] = dist;\n s.pending_buf[s.sym_buf + s.sym_next++] = dist >> 8;\n s.pending_buf[s.sym_buf + s.sym_next++] = lc;\n if (dist === 0) {\n s.dyn_ltree[lc * 2]++;\n } else {\n s.matches++;\n dist--;\n s.dyn_ltree[(_length_code2[lc] + LITERALS + 1) * 2]++;\n s.dyn_dtree[d_code(dist) * 2]++;\n }\n return s.sym_next === s.sym_end;\n };\n trees._tr_init = _tr_init;\n trees._tr_stored_block = _tr_stored_block;\n trees._tr_flush_block = _tr_flush_block;\n trees._tr_tally = _tr_tally;\n trees._tr_align = _tr_align;\n return trees;\n}\nvar adler32_1;\nvar hasRequiredAdler32;\nfunction requireAdler32() {\n if (hasRequiredAdler32) return adler32_1;\n hasRequiredAdler32 = 1;\n const adler322 = (adler, buf, len, pos) => {\n let s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;\n while (len !== 0) {\n n = len > 2e3 ? 2e3 : len;\n len -= n;\n do {\n s1 = s1 + buf[pos++] | 0;\n s2 = s2 + s1 | 0;\n } while (--n);\n s1 %= 65521;\n s2 %= 65521;\n }\n return s1 | s2 << 16 | 0;\n };\n adler32_1 = adler322;\n return adler32_1;\n}\nvar crc32_1;\nvar hasRequiredCrc32$1;\nfunction requireCrc32$1() {\n if (hasRequiredCrc32$1) return crc32_1;\n hasRequiredCrc32$1 = 1;\n const makeTable2 = () => {\n let c, table = [];\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;\n }\n table[n] = c;\n }\n return table;\n };\n const crcTable2 = new Uint32Array(makeTable2());\n const crc322 = (crc, buf, len, pos) => {\n const t = crcTable2;\n const end = pos + len;\n crc ^= -1;\n for (let i = pos; i < end; i++) {\n crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];\n }\n return crc ^ -1;\n };\n crc32_1 = crc322;\n return crc32_1;\n}\nvar messages;\nvar hasRequiredMessages;\nfunction requireMessages() {\n if (hasRequiredMessages) return messages;\n hasRequiredMessages = 1;\n messages = {\n 2: "need dictionary",\n /* Z_NEED_DICT 2 */\n 1: "stream end",\n /* Z_STREAM_END 1 */\n 0: "",\n /* Z_OK 0 */\n "-1": "file error",\n /* Z_ERRNO (-1) */\n "-2": "stream error",\n /* Z_STREAM_ERROR (-2) */\n "-3": "data error",\n /* Z_DATA_ERROR (-3) */\n "-4": "insufficient memory",\n /* Z_MEM_ERROR (-4) */\n "-5": "buffer error",\n /* Z_BUF_ERROR (-5) */\n "-6": "incompatible version"\n /* Z_VERSION_ERROR (-6) */\n };\n return messages;\n}\nvar constants;\nvar hasRequiredConstants;\nfunction requireConstants() {\n if (hasRequiredConstants) return constants;\n hasRequiredConstants = 1;\n constants = {\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n };\n return constants;\n}\nvar hasRequiredDeflate$1;\nfunction requireDeflate$1() {\n if (hasRequiredDeflate$1) return deflate;\n hasRequiredDeflate$1 = 1;\n const { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = requireTrees();\n const adler322 = requireAdler32();\n const crc322 = requireCrc32$1();\n const msg = requireMessages();\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_PARTIAL_FLUSH,\n Z_FULL_FLUSH,\n Z_FINISH: Z_FINISH2,\n Z_BLOCK: Z_BLOCK2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_BUF_ERROR: Z_BUF_ERROR2,\n Z_DEFAULT_COMPRESSION,\n Z_FILTERED,\n Z_HUFFMAN_ONLY,\n Z_RLE,\n Z_FIXED,\n Z_DEFAULT_STRATEGY,\n Z_UNKNOWN,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n const MAX_MEM_LEVEL = 9;\n const MAX_WBITS2 = 15;\n const DEF_MEM_LEVEL = 8;\n const LENGTH_CODES = 29;\n const LITERALS = 256;\n const L_CODES = LITERALS + 1 + LENGTH_CODES;\n const D_CODES = 30;\n const BL_CODES = 19;\n const HEAP_SIZE = 2 * L_CODES + 1;\n const MAX_BITS = 15;\n const MIN_MATCH = 3;\n const MAX_MATCH = 258;\n const MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1;\n const PRESET_DICT = 32;\n const INIT_STATE = 42;\n const GZIP_STATE = 57;\n const EXTRA_STATE = 69;\n const NAME_STATE = 73;\n const COMMENT_STATE = 91;\n const HCRC_STATE = 103;\n const BUSY_STATE = 113;\n const FINISH_STATE = 666;\n const BS_NEED_MORE = 1;\n const BS_BLOCK_DONE = 2;\n const BS_FINISH_STARTED = 3;\n const BS_FINISH_DONE = 4;\n const OS_CODE = 3;\n const err = (strm, errorCode) => {\n strm.msg = msg[errorCode];\n return errorCode;\n };\n const rank = (f) => {\n return f * 2 - (f > 4 ? 9 : 0);\n };\n const zero = (buf) => {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n };\n const slide_hash = (s) => {\n let n, m;\n let p;\n let wsize = s.w_size;\n n = s.hash_size;\n p = n;\n do {\n m = s.head[--p];\n s.head[p] = m >= wsize ? m - wsize : 0;\n } while (--n);\n n = wsize;\n p = n;\n do {\n m = s.prev[--p];\n s.prev[p] = m >= wsize ? m - wsize : 0;\n } while (--n);\n };\n let HASH_ZLIB = (s, prev, data) => (prev << s.hash_shift ^ data) & s.hash_mask;\n let HASH = HASH_ZLIB;\n const flush_pending = (strm) => {\n const s = strm.state;\n let len = s.pending;\n if (len > strm.avail_out) {\n len = strm.avail_out;\n }\n if (len === 0) {\n return;\n }\n strm.output.set(s.pending_buf.subarray(s.pending_out, s.pending_out + len), strm.next_out);\n strm.next_out += len;\n s.pending_out += len;\n strm.total_out += len;\n strm.avail_out -= len;\n s.pending -= len;\n if (s.pending === 0) {\n s.pending_out = 0;\n }\n };\n const flush_block_only = (s, last) => {\n _tr_flush_block(s, s.block_start >= 0 ? s.block_start : -1, s.strstart - s.block_start, last);\n s.block_start = s.strstart;\n flush_pending(s.strm);\n };\n const put_byte = (s, b) => {\n s.pending_buf[s.pending++] = b;\n };\n const putShortMSB = (s, b) => {\n s.pending_buf[s.pending++] = b >>> 8 & 255;\n s.pending_buf[s.pending++] = b & 255;\n };\n const read_buf = (strm, buf, start, size) => {\n let len = strm.avail_in;\n if (len > size) {\n len = size;\n }\n if (len === 0) {\n return 0;\n }\n strm.avail_in -= len;\n buf.set(strm.input.subarray(strm.next_in, strm.next_in + len), start);\n if (strm.state.wrap === 1) {\n strm.adler = adler322(strm.adler, buf, len, start);\n } else if (strm.state.wrap === 2) {\n strm.adler = crc322(strm.adler, buf, len, start);\n }\n strm.next_in += len;\n strm.total_in += len;\n return len;\n };\n const longest_match = (s, cur_match) => {\n let chain_length = s.max_chain_length;\n let scan = s.strstart;\n let match;\n let len;\n let best_len = s.prev_length;\n let nice_match = s.nice_match;\n const limit = s.strstart > s.w_size - MIN_LOOKAHEAD ? s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0;\n const _win = s.window;\n const wmask = s.w_mask;\n const prev = s.prev;\n const strend = s.strstart + MAX_MATCH;\n let scan_end1 = _win[scan + best_len - 1];\n let scan_end = _win[scan + best_len];\n if (s.prev_length >= s.good_match) {\n chain_length >>= 2;\n }\n if (nice_match > s.lookahead) {\n nice_match = s.lookahead;\n }\n do {\n match = cur_match;\n if (_win[match + best_len] !== scan_end || _win[match + best_len - 1] !== scan_end1 || _win[match] !== _win[scan] || _win[++match] !== _win[scan + 1]) {\n continue;\n }\n scan += 2;\n match++;\n do {\n } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend);\n len = MAX_MATCH - (strend - scan);\n scan = strend - MAX_MATCH;\n if (len > best_len) {\n s.match_start = cur_match;\n best_len = len;\n if (len >= nice_match) {\n break;\n }\n scan_end1 = _win[scan + best_len - 1];\n scan_end = _win[scan + best_len];\n }\n } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n if (best_len <= s.lookahead) {\n return best_len;\n }\n return s.lookahead;\n };\n const fill_window = (s) => {\n const _w_size = s.w_size;\n let n, more, str;\n do {\n more = s.window_size - s.lookahead - s.strstart;\n if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n s.window.set(s.window.subarray(_w_size, _w_size + _w_size - more), 0);\n s.match_start -= _w_size;\n s.strstart -= _w_size;\n s.block_start -= _w_size;\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n slide_hash(s);\n more += _w_size;\n }\n if (s.strm.avail_in === 0) {\n break;\n }\n n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n s.lookahead += n;\n if (s.lookahead + s.insert >= MIN_MATCH) {\n str = s.strstart - s.insert;\n s.ins_h = s.window[str];\n s.ins_h = HASH(s, s.ins_h, s.window[str + 1]);\n while (s.insert) {\n s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n s.insert--;\n if (s.lookahead + s.insert < MIN_MATCH) {\n break;\n }\n }\n }\n } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n };\n const deflate_stored = (s, flush) => {\n let min_block = s.pending_buf_size - 5 > s.w_size ? s.w_size : s.pending_buf_size - 5;\n let len, left, have, last = 0;\n let used = s.strm.avail_in;\n do {\n len = 65535;\n have = s.bi_valid + 42 >> 3;\n if (s.strm.avail_out < have) {\n break;\n }\n have = s.strm.avail_out - have;\n left = s.strstart - s.block_start;\n if (len > left + s.strm.avail_in) {\n len = left + s.strm.avail_in;\n }\n if (len > have) {\n len = have;\n }\n if (len < min_block && (len === 0 && flush !== Z_FINISH2 || flush === Z_NO_FLUSH2 || len !== left + s.strm.avail_in)) {\n break;\n }\n last = flush === Z_FINISH2 && len === left + s.strm.avail_in ? 1 : 0;\n _tr_stored_block(s, 0, 0, last);\n s.pending_buf[s.pending - 4] = len;\n s.pending_buf[s.pending - 3] = len >> 8;\n s.pending_buf[s.pending - 2] = ~len;\n s.pending_buf[s.pending - 1] = ~len >> 8;\n flush_pending(s.strm);\n if (left) {\n if (left > len) {\n left = len;\n }\n s.strm.output.set(s.window.subarray(s.block_start, s.block_start + left), s.strm.next_out);\n s.strm.next_out += left;\n s.strm.avail_out -= left;\n s.strm.total_out += left;\n s.block_start += left;\n len -= left;\n }\n if (len) {\n read_buf(s.strm, s.strm.output, s.strm.next_out, len);\n s.strm.next_out += len;\n s.strm.avail_out -= len;\n s.strm.total_out += len;\n }\n } while (last === 0);\n used -= s.strm.avail_in;\n if (used) {\n if (used >= s.w_size) {\n s.matches = 2;\n s.window.set(s.strm.input.subarray(s.strm.next_in - s.w_size, s.strm.next_in), 0);\n s.strstart = s.w_size;\n s.insert = s.strstart;\n } else {\n if (s.window_size - s.strstart <= used) {\n s.strstart -= s.w_size;\n s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0);\n if (s.matches < 2) {\n s.matches++;\n }\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n }\n s.window.set(s.strm.input.subarray(s.strm.next_in - used, s.strm.next_in), s.strstart);\n s.strstart += used;\n s.insert += used > s.w_size - s.insert ? s.w_size - s.insert : used;\n }\n s.block_start = s.strstart;\n }\n if (s.high_water < s.strstart) {\n s.high_water = s.strstart;\n }\n if (last) {\n return BS_FINISH_DONE;\n }\n if (flush !== Z_NO_FLUSH2 && flush !== Z_FINISH2 && s.strm.avail_in === 0 && s.strstart === s.block_start) {\n return BS_BLOCK_DONE;\n }\n have = s.window_size - s.strstart;\n if (s.strm.avail_in > have && s.block_start >= s.w_size) {\n s.block_start -= s.w_size;\n s.strstart -= s.w_size;\n s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0);\n if (s.matches < 2) {\n s.matches++;\n }\n have += s.w_size;\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n }\n if (have > s.strm.avail_in) {\n have = s.strm.avail_in;\n }\n if (have) {\n read_buf(s.strm, s.window, s.strstart, have);\n s.strstart += have;\n s.insert += have > s.w_size - s.insert ? s.w_size - s.insert : have;\n }\n if (s.high_water < s.strstart) {\n s.high_water = s.strstart;\n }\n have = s.bi_valid + 42 >> 3;\n have = s.pending_buf_size - have > 65535 ? 65535 : s.pending_buf_size - have;\n min_block = have > s.w_size ? s.w_size : have;\n left = s.strstart - s.block_start;\n if (left >= min_block || (left || flush === Z_FINISH2) && flush !== Z_NO_FLUSH2 && s.strm.avail_in === 0 && left <= have) {\n len = left > have ? have : left;\n last = flush === Z_FINISH2 && s.strm.avail_in === 0 && len === left ? 1 : 0;\n _tr_stored_block(s, s.block_start, len, last);\n s.block_start += len;\n flush_pending(s.strm);\n }\n return last ? BS_FINISH_STARTED : BS_NEED_MORE;\n };\n const deflate_fast = (s, flush) => {\n let hash_head;\n let bflush;\n for (; ; ) {\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n hash_head = 0;\n if (s.lookahead >= MIN_MATCH) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n if (hash_head !== 0 && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {\n s.match_length = longest_match(s, hash_head);\n }\n if (s.match_length >= MIN_MATCH) {\n bflush = _tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n s.lookahead -= s.match_length;\n if (s.match_length <= s.max_lazy_match && s.lookahead >= MIN_MATCH) {\n s.match_length--;\n do {\n s.strstart++;\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n } while (--s.match_length !== 0);\n s.strstart++;\n } else {\n s.strstart += s.match_length;\n s.match_length = 0;\n s.ins_h = s.window[s.strstart];\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + 1]);\n }\n } else {\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_slow = (s, flush) => {\n let hash_head;\n let bflush;\n let max_insert;\n for (; ; ) {\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n hash_head = 0;\n if (s.lookahead >= MIN_MATCH) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n s.prev_length = s.match_length;\n s.prev_match = s.match_start;\n s.match_length = MIN_MATCH - 1;\n if (hash_head !== 0 && s.prev_length < s.max_lazy_match && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {\n s.match_length = longest_match(s, hash_head);\n if (s.match_length <= 5 && (s.strategy === Z_FILTERED || s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096)) {\n s.match_length = MIN_MATCH - 1;\n }\n }\n if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n max_insert = s.strstart + s.lookahead - MIN_MATCH;\n bflush = _tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n s.lookahead -= s.prev_length - 1;\n s.prev_length -= 2;\n do {\n if (++s.strstart <= max_insert) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n } while (--s.prev_length !== 0);\n s.match_available = 0;\n s.match_length = MIN_MATCH - 1;\n s.strstart++;\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n } else if (s.match_available) {\n bflush = _tr_tally(s, 0, s.window[s.strstart - 1]);\n if (bflush) {\n flush_block_only(s, false);\n }\n s.strstart++;\n s.lookahead--;\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n } else {\n s.match_available = 1;\n s.strstart++;\n s.lookahead--;\n }\n }\n if (s.match_available) {\n bflush = _tr_tally(s, 0, s.window[s.strstart - 1]);\n s.match_available = 0;\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_rle = (s, flush) => {\n let bflush;\n let prev;\n let scan, strend;\n const _win = s.window;\n for (; ; ) {\n if (s.lookahead <= MAX_MATCH) {\n fill_window(s);\n if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n s.match_length = 0;\n if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n scan = s.strstart - 1;\n prev = _win[scan];\n if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n strend = s.strstart + MAX_MATCH;\n do {\n } while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend);\n s.match_length = MAX_MATCH - (strend - scan);\n if (s.match_length > s.lookahead) {\n s.match_length = s.lookahead;\n }\n }\n }\n if (s.match_length >= MIN_MATCH) {\n bflush = _tr_tally(s, 1, s.match_length - MIN_MATCH);\n s.lookahead -= s.match_length;\n s.strstart += s.match_length;\n s.match_length = 0;\n } else {\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_huff = (s, flush) => {\n let bflush;\n for (; ; ) {\n if (s.lookahead === 0) {\n fill_window(s);\n if (s.lookahead === 0) {\n if (flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n break;\n }\n }\n s.match_length = 0;\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n function Config(good_length, max_lazy, nice_length, max_chain, func) {\n this.good_length = good_length;\n this.max_lazy = max_lazy;\n this.nice_length = nice_length;\n this.max_chain = max_chain;\n this.func = func;\n }\n const configuration_table = [\n /* good lazy nice chain */\n new Config(0, 0, 0, 0, deflate_stored),\n /* 0 store only */\n new Config(4, 4, 8, 4, deflate_fast),\n /* 1 max speed, no lazy matches */\n new Config(4, 5, 16, 8, deflate_fast),\n /* 2 */\n new Config(4, 6, 32, 32, deflate_fast),\n /* 3 */\n new Config(4, 4, 16, 16, deflate_slow),\n /* 4 lazy matches */\n new Config(8, 16, 32, 32, deflate_slow),\n /* 5 */\n new Config(8, 16, 128, 128, deflate_slow),\n /* 6 */\n new Config(8, 32, 128, 256, deflate_slow),\n /* 7 */\n new Config(32, 128, 258, 1024, deflate_slow),\n /* 8 */\n new Config(32, 258, 258, 4096, deflate_slow)\n /* 9 max compression */\n ];\n const lm_init = (s) => {\n s.window_size = 2 * s.w_size;\n zero(s.head);\n s.max_lazy_match = configuration_table[s.level].max_lazy;\n s.good_match = configuration_table[s.level].good_length;\n s.nice_match = configuration_table[s.level].nice_length;\n s.max_chain_length = configuration_table[s.level].max_chain;\n s.strstart = 0;\n s.block_start = 0;\n s.lookahead = 0;\n s.insert = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n s.ins_h = 0;\n };\n function DeflateState() {\n this.strm = null;\n this.status = 0;\n this.pending_buf = null;\n this.pending_buf_size = 0;\n this.pending_out = 0;\n this.pending = 0;\n this.wrap = 0;\n this.gzhead = null;\n this.gzindex = 0;\n this.method = Z_DEFLATED2;\n this.last_flush = -1;\n this.w_size = 0;\n this.w_bits = 0;\n this.w_mask = 0;\n this.window = null;\n this.window_size = 0;\n this.prev = null;\n this.head = null;\n this.ins_h = 0;\n this.hash_size = 0;\n this.hash_bits = 0;\n this.hash_mask = 0;\n this.hash_shift = 0;\n this.block_start = 0;\n this.match_length = 0;\n this.prev_match = 0;\n this.match_available = 0;\n this.strstart = 0;\n this.match_start = 0;\n this.lookahead = 0;\n this.prev_length = 0;\n this.max_chain_length = 0;\n this.max_lazy_match = 0;\n this.level = 0;\n this.strategy = 0;\n this.good_match = 0;\n this.nice_match = 0;\n this.dyn_ltree = new Uint16Array(HEAP_SIZE * 2);\n this.dyn_dtree = new Uint16Array((2 * D_CODES + 1) * 2);\n this.bl_tree = new Uint16Array((2 * BL_CODES + 1) * 2);\n zero(this.dyn_ltree);\n zero(this.dyn_dtree);\n zero(this.bl_tree);\n this.l_desc = null;\n this.d_desc = null;\n this.bl_desc = null;\n this.bl_count = new Uint16Array(MAX_BITS + 1);\n this.heap = new Uint16Array(2 * L_CODES + 1);\n zero(this.heap);\n this.heap_len = 0;\n this.heap_max = 0;\n this.depth = new Uint16Array(2 * L_CODES + 1);\n zero(this.depth);\n this.sym_buf = 0;\n this.lit_bufsize = 0;\n this.sym_next = 0;\n this.sym_end = 0;\n this.opt_len = 0;\n this.static_len = 0;\n this.matches = 0;\n this.insert = 0;\n this.bi_buf = 0;\n this.bi_valid = 0;\n }\n const deflateStateCheck = (strm) => {\n if (!strm) {\n return 1;\n }\n const s = strm.state;\n if (!s || s.strm !== strm || s.status !== INIT_STATE && //#ifdef GZIP\n s.status !== GZIP_STATE && //#endif\n s.status !== EXTRA_STATE && s.status !== NAME_STATE && s.status !== COMMENT_STATE && s.status !== HCRC_STATE && s.status !== BUSY_STATE && s.status !== FINISH_STATE) {\n return 1;\n }\n return 0;\n };\n const deflateResetKeep = (strm) => {\n if (deflateStateCheck(strm)) {\n return err(strm, Z_STREAM_ERROR2);\n }\n strm.total_in = strm.total_out = 0;\n strm.data_type = Z_UNKNOWN;\n const s = strm.state;\n s.pending = 0;\n s.pending_out = 0;\n if (s.wrap < 0) {\n s.wrap = -s.wrap;\n }\n s.status = //#ifdef GZIP\n s.wrap === 2 ? GZIP_STATE : (\n //#endif\n s.wrap ? INIT_STATE : BUSY_STATE\n );\n strm.adler = s.wrap === 2 ? 0 : 1;\n s.last_flush = -2;\n _tr_init(s);\n return Z_OK2;\n };\n const deflateReset = (strm) => {\n const ret = deflateResetKeep(strm);\n if (ret === Z_OK2) {\n lm_init(strm.state);\n }\n return ret;\n };\n const deflateSetHeader = (strm, head) => {\n if (deflateStateCheck(strm) || strm.state.wrap !== 2) {\n return Z_STREAM_ERROR2;\n }\n strm.state.gzhead = head;\n return Z_OK2;\n };\n const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {\n if (!strm) {\n return Z_STREAM_ERROR2;\n }\n let wrap = 1;\n if (level === Z_DEFAULT_COMPRESSION) {\n level = 6;\n }\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else if (windowBits > 15) {\n wrap = 2;\n windowBits -= 16;\n }\n if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED2 || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED || windowBits === 8 && wrap !== 1) {\n return err(strm, Z_STREAM_ERROR2);\n }\n if (windowBits === 8) {\n windowBits = 9;\n }\n const s = new DeflateState();\n strm.state = s;\n s.strm = strm;\n s.status = INIT_STATE;\n s.wrap = wrap;\n s.gzhead = null;\n s.w_bits = windowBits;\n s.w_size = 1 << s.w_bits;\n s.w_mask = s.w_size - 1;\n s.hash_bits = memLevel + 7;\n s.hash_size = 1 << s.hash_bits;\n s.hash_mask = s.hash_size - 1;\n s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n s.window = new Uint8Array(s.w_size * 2);\n s.head = new Uint16Array(s.hash_size);\n s.prev = new Uint16Array(s.w_size);\n s.lit_bufsize = 1 << memLevel + 6;\n s.pending_buf_size = s.lit_bufsize * 4;\n s.pending_buf = new Uint8Array(s.pending_buf_size);\n s.sym_buf = s.lit_bufsize;\n s.sym_end = (s.lit_bufsize - 1) * 3;\n s.level = level;\n s.strategy = strategy;\n s.method = method;\n return deflateReset(strm);\n };\n const deflateInit = (strm, level) => {\n return deflateInit2(strm, level, Z_DEFLATED2, MAX_WBITS2, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n };\n const deflate$12 = (strm, flush) => {\n if (deflateStateCheck(strm) || flush > Z_BLOCK2 || flush < 0) {\n return strm ? err(strm, Z_STREAM_ERROR2) : Z_STREAM_ERROR2;\n }\n const s = strm.state;\n if (!strm.output || strm.avail_in !== 0 && !strm.input || s.status === FINISH_STATE && flush !== Z_FINISH2) {\n return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR2 : Z_STREAM_ERROR2);\n }\n const old_flush = s.last_flush;\n s.last_flush = flush;\n if (s.pending !== 0) {\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH2) {\n return err(strm, Z_BUF_ERROR2);\n }\n if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n return err(strm, Z_BUF_ERROR2);\n }\n if (s.status === INIT_STATE && s.wrap === 0) {\n s.status = BUSY_STATE;\n }\n if (s.status === INIT_STATE) {\n let header = Z_DEFLATED2 + (s.w_bits - 8 << 4) << 8;\n let level_flags = -1;\n if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n level_flags = 0;\n } else if (s.level < 6) {\n level_flags = 1;\n } else if (s.level === 6) {\n level_flags = 2;\n } else {\n level_flags = 3;\n }\n header |= level_flags << 6;\n if (s.strstart !== 0) {\n header |= PRESET_DICT;\n }\n header += 31 - header % 31;\n putShortMSB(s, header);\n if (s.strstart !== 0) {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 65535);\n }\n strm.adler = 1;\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n if (s.status === GZIP_STATE) {\n strm.adler = 0;\n put_byte(s, 31);\n put_byte(s, 139);\n put_byte(s, 8);\n if (!s.gzhead) {\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);\n put_byte(s, OS_CODE);\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n } else {\n put_byte(\n s,\n (s.gzhead.text ? 1 : 0) + (s.gzhead.hcrc ? 2 : 0) + (!s.gzhead.extra ? 0 : 4) + (!s.gzhead.name ? 0 : 8) + (!s.gzhead.comment ? 0 : 16)\n );\n put_byte(s, s.gzhead.time & 255);\n put_byte(s, s.gzhead.time >> 8 & 255);\n put_byte(s, s.gzhead.time >> 16 & 255);\n put_byte(s, s.gzhead.time >> 24 & 255);\n put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);\n put_byte(s, s.gzhead.os & 255);\n if (s.gzhead.extra && s.gzhead.extra.length) {\n put_byte(s, s.gzhead.extra.length & 255);\n put_byte(s, s.gzhead.extra.length >> 8 & 255);\n }\n if (s.gzhead.hcrc) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending, 0);\n }\n s.gzindex = 0;\n s.status = EXTRA_STATE;\n }\n }\n if (s.status === EXTRA_STATE) {\n if (s.gzhead.extra) {\n let beg = s.pending;\n let left = (s.gzhead.extra.length & 65535) - s.gzindex;\n while (s.pending + left > s.pending_buf_size) {\n let copy = s.pending_buf_size - s.pending;\n s.pending_buf.set(s.gzhead.extra.subarray(s.gzindex, s.gzindex + copy), s.pending);\n s.pending = s.pending_buf_size;\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex += copy;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n left -= copy;\n }\n let gzhead_extra = new Uint8Array(s.gzhead.extra);\n s.pending_buf.set(gzhead_extra.subarray(s.gzindex, s.gzindex + left), s.pending);\n s.pending += left;\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex = 0;\n }\n s.status = NAME_STATE;\n }\n if (s.status === NAME_STATE) {\n if (s.gzhead.name) {\n let beg = s.pending;\n let val;\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n }\n if (s.gzindex < s.gzhead.name.length) {\n val = s.gzhead.name.charCodeAt(s.gzindex++) & 255;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex = 0;\n }\n s.status = COMMENT_STATE;\n }\n if (s.status === COMMENT_STATE) {\n if (s.gzhead.comment) {\n let beg = s.pending;\n let val;\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n }\n if (s.gzindex < s.gzhead.comment.length) {\n val = s.gzhead.comment.charCodeAt(s.gzindex++) & 255;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n }\n s.status = HCRC_STATE;\n }\n if (s.status === HCRC_STATE) {\n if (s.gzhead.hcrc) {\n if (s.pending + 2 > s.pending_buf_size) {\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n put_byte(s, strm.adler & 255);\n put_byte(s, strm.adler >> 8 & 255);\n strm.adler = 0;\n }\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH2 && s.status !== FINISH_STATE) {\n let bstate = s.level === 0 ? deflate_stored(s, flush) : s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s.strategy === Z_RLE ? deflate_rle(s, flush) : configuration_table[s.level].func(s, flush);\n if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n s.status = FINISH_STATE;\n }\n if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n }\n return Z_OK2;\n }\n if (bstate === BS_BLOCK_DONE) {\n if (flush === Z_PARTIAL_FLUSH) {\n _tr_align(s);\n } else if (flush !== Z_BLOCK2) {\n _tr_stored_block(s, 0, 0, false);\n if (flush === Z_FULL_FLUSH) {\n zero(s.head);\n if (s.lookahead === 0) {\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n }\n }\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n }\n if (flush !== Z_FINISH2) {\n return Z_OK2;\n }\n if (s.wrap <= 0) {\n return Z_STREAM_END2;\n }\n if (s.wrap === 2) {\n put_byte(s, strm.adler & 255);\n put_byte(s, strm.adler >> 8 & 255);\n put_byte(s, strm.adler >> 16 & 255);\n put_byte(s, strm.adler >> 24 & 255);\n put_byte(s, strm.total_in & 255);\n put_byte(s, strm.total_in >> 8 & 255);\n put_byte(s, strm.total_in >> 16 & 255);\n put_byte(s, strm.total_in >> 24 & 255);\n } else {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 65535);\n }\n flush_pending(strm);\n if (s.wrap > 0) {\n s.wrap = -s.wrap;\n }\n return s.pending !== 0 ? Z_OK2 : Z_STREAM_END2;\n };\n const deflateEnd = (strm) => {\n if (deflateStateCheck(strm)) {\n return Z_STREAM_ERROR2;\n }\n const status = strm.state.status;\n strm.state = null;\n return status === BUSY_STATE ? err(strm, Z_DATA_ERROR2) : Z_OK2;\n };\n const deflateSetDictionary = (strm, dictionary) => {\n let dictLength = dictionary.length;\n if (deflateStateCheck(strm)) {\n return Z_STREAM_ERROR2;\n }\n const s = strm.state;\n const wrap = s.wrap;\n if (wrap === 2 || wrap === 1 && s.status !== INIT_STATE || s.lookahead) {\n return Z_STREAM_ERROR2;\n }\n if (wrap === 1) {\n strm.adler = adler322(strm.adler, dictionary, dictLength, 0);\n }\n s.wrap = 0;\n if (dictLength >= s.w_size) {\n if (wrap === 0) {\n zero(s.head);\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n let tmpDict = new Uint8Array(s.w_size);\n tmpDict.set(dictionary.subarray(dictLength - s.w_size, dictLength), 0);\n dictionary = tmpDict;\n dictLength = s.w_size;\n }\n const avail = strm.avail_in;\n const next = strm.next_in;\n const input = strm.input;\n strm.avail_in = dictLength;\n strm.next_in = 0;\n strm.input = dictionary;\n fill_window(s);\n while (s.lookahead >= MIN_MATCH) {\n let str = s.strstart;\n let n = s.lookahead - (MIN_MATCH - 1);\n do {\n s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n } while (--n);\n s.strstart = str;\n s.lookahead = MIN_MATCH - 1;\n fill_window(s);\n }\n s.strstart += s.lookahead;\n s.block_start = s.strstart;\n s.insert = s.lookahead;\n s.lookahead = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n strm.next_in = next;\n strm.input = input;\n strm.avail_in = avail;\n s.wrap = wrap;\n return Z_OK2;\n };\n deflate.deflateInit = deflateInit;\n deflate.deflateInit2 = deflateInit2;\n deflate.deflateReset = deflateReset;\n deflate.deflateResetKeep = deflateResetKeep;\n deflate.deflateSetHeader = deflateSetHeader;\n deflate.deflate = deflate$12;\n deflate.deflateEnd = deflateEnd;\n deflate.deflateSetDictionary = deflateSetDictionary;\n deflate.deflateInfo = "pako deflate (from Nodeca project)";\n return deflate;\n}\nvar common = {};\nvar hasRequiredCommon;\nfunction requireCommon() {\n if (hasRequiredCommon) return common;\n hasRequiredCommon = 1;\n const _has2 = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n };\n common.assign = function(obj) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) {\n continue;\n }\n if (typeof source !== "object") {\n throw new TypeError(source + "must be non-object");\n }\n for (const p in source) {\n if (_has2(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n return obj;\n };\n common.flattenChunks = (chunks) => {\n let len = 0;\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n const result = new Uint8Array(len);\n for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n let chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n return result;\n };\n return common;\n}\nvar strings = {};\nvar hasRequiredStrings;\nfunction requireStrings() {\n if (hasRequiredStrings) return strings;\n hasRequiredStrings = 1;\n let STR_APPLY_UIA_OK2 = true;\n try {\n String.fromCharCode.apply(null, new Uint8Array(1));\n } catch (__) {\n STR_APPLY_UIA_OK2 = false;\n }\n const _utf8len2 = new Uint8Array(256);\n for (let q = 0; q < 256; q++) {\n _utf8len2[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;\n }\n _utf8len2[254] = _utf8len2[254] = 1;\n strings.string2buf = (str) => {\n if (typeof TextEncoder === "function" && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;\n }\n buf = new Uint8Array(buf_len);\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n if (c < 128) {\n buf[i++] = c;\n } else if (c < 2048) {\n buf[i++] = 192 | c >>> 6;\n buf[i++] = 128 | c & 63;\n } else if (c < 65536) {\n buf[i++] = 224 | c >>> 12;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n } else {\n buf[i++] = 240 | c >>> 18;\n buf[i++] = 128 | c >>> 12 & 63;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n }\n }\n return buf;\n };\n const buf2binstring2 = (buf, len) => {\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK2) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n }\n }\n let result = "";\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n };\n strings.buf2string = (buf, max) => {\n const len = max || buf.length;\n if (typeof TextDecoder === "function" && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n let i, out;\n const utf16buf = new Array(len * 2);\n for (out = 0, i = 0; i < len; ) {\n let c = buf[i++];\n if (c < 128) {\n utf16buf[out++] = c;\n continue;\n }\n let c_len = _utf8len2[c];\n if (c_len > 4) {\n utf16buf[out++] = 65533;\n i += c_len - 1;\n continue;\n }\n c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;\n while (c_len > 1 && i < len) {\n c = c << 6 | buf[i++] & 63;\n c_len--;\n }\n if (c_len > 1) {\n utf16buf[out++] = 65533;\n continue;\n }\n if (c < 65536) {\n utf16buf[out++] = c;\n } else {\n c -= 65536;\n utf16buf[out++] = 55296 | c >> 10 & 1023;\n utf16buf[out++] = 56320 | c & 1023;\n }\n }\n return buf2binstring2(utf16buf, out);\n };\n strings.utf8border = (buf, max) => {\n max = max || buf.length;\n if (max > buf.length) {\n max = buf.length;\n }\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 192) === 128) {\n pos--;\n }\n if (pos < 0) {\n return max;\n }\n if (pos === 0) {\n return max;\n }\n return pos + _utf8len2[buf[pos]] > max ? pos : max;\n };\n return strings;\n}\nvar zstream;\nvar hasRequiredZstream;\nfunction requireZstream() {\n if (hasRequiredZstream) return zstream;\n hasRequiredZstream = 1;\n function ZStream2() {\n this.input = null;\n this.next_in = 0;\n this.avail_in = 0;\n this.total_in = 0;\n this.output = null;\n this.next_out = 0;\n this.avail_out = 0;\n this.total_out = 0;\n this.msg = "";\n this.state = null;\n this.data_type = 2;\n this.adler = 0;\n }\n zstream = ZStream2;\n return zstream;\n}\nvar hasRequiredDeflate;\nfunction requireDeflate() {\n if (hasRequiredDeflate) return deflate$1;\n hasRequiredDeflate = 1;\n const zlib_deflate = requireDeflate$1();\n const utils = requireCommon();\n const strings2 = requireStrings();\n const msg = requireMessages();\n const ZStream2 = requireZstream();\n const toString2 = Object.prototype.toString;\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_SYNC_FLUSH,\n Z_FULL_FLUSH,\n Z_FINISH: Z_FINISH2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_DEFAULT_COMPRESSION,\n Z_DEFAULT_STRATEGY,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n function Deflate(options) {\n this.options = utils.assign({\n level: Z_DEFAULT_COMPRESSION,\n method: Z_DEFLATED2,\n chunkSize: 16384,\n windowBits: 15,\n memLevel: 8,\n strategy: Z_DEFAULT_STRATEGY\n }, options || {});\n let opt = this.options;\n if (opt.raw && opt.windowBits > 0) {\n opt.windowBits = -opt.windowBits;\n } else if (opt.gzip && opt.windowBits > 0 && opt.windowBits < 16) {\n opt.windowBits += 16;\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new ZStream2();\n this.strm.avail_out = 0;\n let status = zlib_deflate.deflateInit2(\n this.strm,\n opt.level,\n opt.method,\n opt.windowBits,\n opt.memLevel,\n opt.strategy\n );\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n if (opt.header) {\n zlib_deflate.deflateSetHeader(this.strm, opt.header);\n }\n if (opt.dictionary) {\n let dict;\n if (typeof opt.dictionary === "string") {\n dict = strings2.string2buf(opt.dictionary);\n } else if (toString2.call(opt.dictionary) === "[object ArrayBuffer]") {\n dict = new Uint8Array(opt.dictionary);\n } else {\n dict = opt.dictionary;\n }\n status = zlib_deflate.deflateSetDictionary(this.strm, dict);\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n this._dict_set = true;\n }\n }\n Deflate.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n let status, _flush_mode;\n if (this.ended) {\n return false;\n }\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH2 : Z_NO_FLUSH2;\n if (typeof data === "string") {\n strm.input = strings2.string2buf(data);\n } else if (toString2.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n for (; ; ) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n if ((_flush_mode === Z_SYNC_FLUSH || _flush_mode === Z_FULL_FLUSH) && strm.avail_out <= 6) {\n this.onData(strm.output.subarray(0, strm.next_out));\n strm.avail_out = 0;\n continue;\n }\n status = zlib_deflate.deflate(strm, _flush_mode);\n if (status === Z_STREAM_END2) {\n if (strm.next_out > 0) {\n this.onData(strm.output.subarray(0, strm.next_out));\n }\n status = zlib_deflate.deflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK2;\n }\n if (strm.avail_out === 0) {\n this.onData(strm.output);\n continue;\n }\n if (_flush_mode > 0 && strm.next_out > 0) {\n this.onData(strm.output.subarray(0, strm.next_out));\n strm.avail_out = 0;\n continue;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n };\n Deflate.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n };\n Deflate.prototype.onEnd = function(status) {\n if (status === Z_OK2) {\n this.result = utils.flattenChunks(this.chunks);\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n function deflate2(input, options) {\n const deflator = new Deflate(options);\n deflator.push(input, true);\n if (deflator.err) {\n throw deflator.msg || msg[deflator.err];\n }\n return deflator.result;\n }\n function deflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return deflate2(input, options);\n }\n function gzip(input, options) {\n options = options || {};\n options.gzip = true;\n return deflate2(input, options);\n }\n deflate$1.Deflate = Deflate;\n deflate$1.deflate = deflate2;\n deflate$1.deflateRaw = deflateRaw;\n deflate$1.gzip = gzip;\n deflate$1.constants = requireConstants();\n return deflate$1;\n}\nvar inflate$1 = {};\nvar inflate = {};\nvar inffast;\nvar hasRequiredInffast;\nfunction requireInffast() {\n if (hasRequiredInffast) return inffast;\n hasRequiredInffast = 1;\n const BAD2 = 16209;\n const TYPE2 = 16191;\n inffast = function inflate_fast2(strm, start) {\n let _in;\n let last;\n let _out;\n let beg;\n let end;\n let dmax;\n let wsize;\n let whave;\n let wnext;\n let s_window;\n let hold;\n let bits;\n let lcode;\n let dcode;\n let lmask;\n let dmask;\n let here;\n let op;\n let len;\n let dist;\n let from;\n let from_source;\n let input, output;\n const state = strm.state;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n dmax = state.dmax;\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = lcode[hold & lmask];\n dolen:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op === 0) {\n output[_out++] = here & 65535;\n } else if (op & 16) {\n len = here & 65535;\n op &= 15;\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & (1 << op) - 1;\n hold >>>= op;\n bits -= op;\n }\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n dodist:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op & 16) {\n dist = here & 65535;\n op &= 15;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & (1 << op) - 1;\n if (dist > dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break top;\n }\n hold >>>= op;\n bits -= op;\n op = _out - beg;\n if (dist > op) {\n op = dist - op;\n if (op > whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break top;\n }\n }\n from = 0;\n from_source = s_window;\n if (wnext === 0) {\n from += wsize - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n } else if (wnext < op) {\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) {\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n } else {\n from += wnext - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n } else {\n from = _out - dist;\n do {\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n } else if ((op & 64) === 0) {\n here = dcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dodist;\n } else {\n strm.msg = "invalid distance code";\n state.mode = BAD2;\n break top;\n }\n break;\n }\n } else if ((op & 64) === 0) {\n here = lcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dolen;\n } else if (op & 32) {\n state.mode = TYPE2;\n break top;\n } else {\n strm.msg = "invalid literal/length code";\n state.mode = BAD2;\n break top;\n }\n break;\n }\n } while (_in < last && _out < end);\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);\n strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);\n state.hold = hold;\n state.bits = bits;\n return;\n };\n return inffast;\n}\nvar inftrees;\nvar hasRequiredInftrees;\nfunction requireInftrees() {\n if (hasRequiredInftrees) return inftrees;\n hasRequiredInftrees = 1;\n const MAXBITS2 = 15;\n const ENOUGH_LENS2 = 852;\n const ENOUGH_DISTS2 = 592;\n const CODES2 = 0;\n const LENS2 = 1;\n const DISTS2 = 2;\n const lbase2 = new Uint16Array([\n /* Length codes 257..285 base */\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 13,\n 15,\n 17,\n 19,\n 23,\n 27,\n 31,\n 35,\n 43,\n 51,\n 59,\n 67,\n 83,\n 99,\n 115,\n 131,\n 163,\n 195,\n 227,\n 258,\n 0,\n 0\n ]);\n const lext2 = new Uint8Array([\n /* Length codes 257..285 extra */\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 17,\n 17,\n 18,\n 18,\n 18,\n 18,\n 19,\n 19,\n 19,\n 19,\n 20,\n 20,\n 20,\n 20,\n 21,\n 21,\n 21,\n 21,\n 16,\n 72,\n 78\n ]);\n const dbase2 = new Uint16Array([\n /* Distance codes 0..29 base */\n 1,\n 2,\n 3,\n 4,\n 5,\n 7,\n 9,\n 13,\n 17,\n 25,\n 33,\n 49,\n 65,\n 97,\n 129,\n 193,\n 257,\n 385,\n 513,\n 769,\n 1025,\n 1537,\n 2049,\n 3073,\n 4097,\n 6145,\n 8193,\n 12289,\n 16385,\n 24577,\n 0,\n 0\n ]);\n const dext2 = new Uint8Array([\n /* Distance codes 0..29 extra */\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 18,\n 18,\n 19,\n 19,\n 20,\n 20,\n 21,\n 21,\n 22,\n 22,\n 23,\n 23,\n 24,\n 24,\n 25,\n 25,\n 26,\n 26,\n 27,\n 27,\n 28,\n 28,\n 29,\n 29,\n 64,\n 64\n ]);\n const inflate_table2 = (type, lens, lens_index, codes, table, table_index, work, opts) => {\n const bits = opts.bits;\n let len = 0;\n let sym = 0;\n let min = 0, max = 0;\n let root = 0;\n let curr = 0;\n let drop = 0;\n let left = 0;\n let used = 0;\n let huff = 0;\n let incr;\n let fill;\n let low;\n let mask;\n let next;\n let base = null;\n let match;\n const count = new Uint16Array(MAXBITS2 + 1);\n const offs = new Uint16Array(MAXBITS2 + 1);\n let extra = null;\n let here_bits, here_op, here_val;\n for (len = 0; len <= MAXBITS2; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n root = bits;\n for (max = MAXBITS2; max >= 1; max--) {\n if (count[max] !== 0) {\n break;\n }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) {\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n opts.bits = 1;\n return 0;\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) {\n break;\n }\n }\n if (root < min) {\n root = min;\n }\n left = 1;\n for (len = 1; len <= MAXBITS2; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n }\n }\n if (left > 0 && (type === CODES2 || max !== 1)) {\n return -1;\n }\n offs[1] = 0;\n for (len = 1; len < MAXBITS2; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n if (type === CODES2) {\n base = extra = work;\n match = 20;\n } else if (type === LENS2) {\n base = lbase2;\n extra = lext2;\n match = 257;\n } else {\n base = dbase2;\n extra = dext2;\n match = 0;\n }\n huff = 0;\n sym = 0;\n len = min;\n next = table_index;\n curr = root;\n drop = 0;\n low = -1;\n used = 1 << root;\n mask = used - 1;\n if (type === LENS2 && used > ENOUGH_LENS2 || type === DISTS2 && used > ENOUGH_DISTS2) {\n return 1;\n }\n for (; ; ) {\n here_bits = len - drop;\n if (work[sym] + 1 < match) {\n here_op = 0;\n here_val = work[sym];\n } else if (work[sym] >= match) {\n here_op = extra[work[sym] - match];\n here_val = base[work[sym] - match];\n } else {\n here_op = 32 + 64;\n here_val = 0;\n }\n incr = 1 << len - drop;\n fill = 1 << curr;\n min = fill;\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;\n } while (fill !== 0);\n incr = 1 << len - 1;\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n sym++;\n if (--count[len] === 0) {\n if (len === max) {\n break;\n }\n len = lens[lens_index + work[sym]];\n }\n if (len > root && (huff & mask) !== low) {\n if (drop === 0) {\n drop = root;\n }\n next += min;\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) {\n break;\n }\n curr++;\n left <<= 1;\n }\n used += 1 << curr;\n if (type === LENS2 && used > ENOUGH_LENS2 || type === DISTS2 && used > ENOUGH_DISTS2) {\n return 1;\n }\n low = huff & mask;\n table[low] = root << 24 | curr << 16 | next - table_index | 0;\n }\n }\n if (huff !== 0) {\n table[next + huff] = len - drop << 24 | 64 << 16 | 0;\n }\n opts.bits = root;\n return 0;\n };\n inftrees = inflate_table2;\n return inftrees;\n}\nvar hasRequiredInflate$1;\nfunction requireInflate$1() {\n if (hasRequiredInflate$1) return inflate;\n hasRequiredInflate$1 = 1;\n const adler322 = requireAdler32();\n const crc322 = requireCrc32$1();\n const inflate_fast2 = requireInffast();\n const inflate_table2 = requireInftrees();\n const CODES2 = 0;\n const LENS2 = 1;\n const DISTS2 = 2;\n const {\n Z_FINISH: Z_FINISH2,\n Z_BLOCK: Z_BLOCK2,\n Z_TREES: Z_TREES2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_NEED_DICT: Z_NEED_DICT2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_MEM_ERROR: Z_MEM_ERROR2,\n Z_BUF_ERROR: Z_BUF_ERROR2,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n const HEAD2 = 16180;\n const FLAGS2 = 16181;\n const TIME2 = 16182;\n const OS2 = 16183;\n const EXLEN2 = 16184;\n const EXTRA2 = 16185;\n const NAME2 = 16186;\n const COMMENT2 = 16187;\n const HCRC2 = 16188;\n const DICTID2 = 16189;\n const DICT2 = 16190;\n const TYPE2 = 16191;\n const TYPEDO2 = 16192;\n const STORED2 = 16193;\n const COPY_2 = 16194;\n const COPY2 = 16195;\n const TABLE2 = 16196;\n const LENLENS2 = 16197;\n const CODELENS2 = 16198;\n const LEN_2 = 16199;\n const LEN2 = 16200;\n const LENEXT2 = 16201;\n const DIST2 = 16202;\n const DISTEXT2 = 16203;\n const MATCH2 = 16204;\n const LIT2 = 16205;\n const CHECK2 = 16206;\n const LENGTH2 = 16207;\n const DONE2 = 16208;\n const BAD2 = 16209;\n const MEM2 = 16210;\n const SYNC2 = 16211;\n const ENOUGH_LENS2 = 852;\n const ENOUGH_DISTS2 = 592;\n const MAX_WBITS2 = 15;\n const DEF_WBITS2 = MAX_WBITS2;\n const zswap322 = (q) => {\n return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);\n };\n function InflateState2() {\n this.strm = null;\n this.mode = 0;\n this.last = false;\n this.wrap = 0;\n this.havedict = false;\n this.flags = 0;\n this.dmax = 0;\n this.check = 0;\n this.total = 0;\n this.head = null;\n this.wbits = 0;\n this.wsize = 0;\n this.whave = 0;\n this.wnext = 0;\n this.window = null;\n this.hold = 0;\n this.bits = 0;\n this.length = 0;\n this.offset = 0;\n this.extra = 0;\n this.lencode = null;\n this.distcode = null;\n this.lenbits = 0;\n this.distbits = 0;\n this.ncode = 0;\n this.nlen = 0;\n this.ndist = 0;\n this.have = 0;\n this.next = null;\n this.lens = new Uint16Array(320);\n this.work = new Uint16Array(288);\n this.lendyn = null;\n this.distdyn = null;\n this.sane = 0;\n this.back = 0;\n this.was = 0;\n }\n const inflateStateCheck2 = (strm) => {\n if (!strm) {\n return 1;\n }\n const state = strm.state;\n if (!state || state.strm !== strm || state.mode < HEAD2 || state.mode > SYNC2) {\n return 1;\n }\n return 0;\n };\n const inflateResetKeep2 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = "";\n if (state.wrap) {\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD2;\n state.last = 0;\n state.havedict = 0;\n state.flags = -1;\n state.dmax = 32768;\n state.head = null;\n state.hold = 0;\n state.bits = 0;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS2);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS2);\n state.sane = 1;\n state.back = -1;\n return Z_OK2;\n };\n const inflateReset3 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep2(strm);\n };\n const inflateReset22 = (strm, windowBits) => {\n let wrap;\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else {\n wrap = (windowBits >> 4) + 5;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR2;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset3(strm);\n };\n const inflateInit22 = (strm, windowBits) => {\n if (!strm) {\n return Z_STREAM_ERROR2;\n }\n const state = new InflateState2();\n strm.state = state;\n state.strm = strm;\n state.window = null;\n state.mode = HEAD2;\n const ret = inflateReset22(strm, windowBits);\n if (ret !== Z_OK2) {\n strm.state = null;\n }\n return ret;\n };\n const inflateInit3 = (strm) => {\n return inflateInit22(strm, DEF_WBITS2);\n };\n let virgin2 = true;\n let lenfix2, distfix2;\n const fixedtables2 = (state) => {\n if (virgin2) {\n lenfix2 = new Int32Array(512);\n distfix2 = new Int32Array(32);\n let sym = 0;\n while (sym < 144) {\n state.lens[sym++] = 8;\n }\n while (sym < 256) {\n state.lens[sym++] = 9;\n }\n while (sym < 280) {\n state.lens[sym++] = 7;\n }\n while (sym < 288) {\n state.lens[sym++] = 8;\n }\n inflate_table2(LENS2, state.lens, 0, 288, lenfix2, 0, state.work, { bits: 9 });\n sym = 0;\n while (sym < 32) {\n state.lens[sym++] = 5;\n }\n inflate_table2(DISTS2, state.lens, 0, 32, distfix2, 0, state.work, { bits: 5 });\n virgin2 = false;\n }\n state.lencode = lenfix2;\n state.lenbits = 9;\n state.distcode = distfix2;\n state.distbits = 5;\n };\n const updatewindow2 = (strm, src, end, copy) => {\n let dist;\n const state = strm.state;\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n state.window = new Uint8Array(state.wsize);\n }\n if (copy >= state.wsize) {\n state.window.set(src.subarray(end - state.wsize, end), 0);\n state.wnext = 0;\n state.whave = state.wsize;\n } else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n } else {\n state.wnext += dist;\n if (state.wnext === state.wsize) {\n state.wnext = 0;\n }\n if (state.whave < state.wsize) {\n state.whave += dist;\n }\n }\n }\n return 0;\n };\n const inflate$12 = (strm, flush) => {\n let state;\n let input, output;\n let next;\n let put;\n let have, left;\n let hold;\n let bits;\n let _in, _out;\n let copy;\n let from;\n let from_source;\n let here = 0;\n let here_bits, here_op, here_val;\n let last_bits, last_op, last_val;\n let len;\n let ret;\n const hbuf = new Uint8Array(4);\n let opts;\n let n;\n const order = (\n /* permutation of code lengths */\n new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])\n );\n if (inflateStateCheck2(strm) || !strm.output || !strm.input && strm.avail_in !== 0) {\n return Z_STREAM_ERROR2;\n }\n state = strm.state;\n if (state.mode === TYPE2) {\n state.mode = TYPEDO2;\n }\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n _in = have;\n _out = left;\n ret = Z_OK2;\n inf_leave:\n for (; ; ) {\n switch (state.mode) {\n case HEAD2:\n if (state.wrap === 0) {\n state.mode = TYPEDO2;\n break;\n }\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 2 && hold === 35615) {\n if (state.wbits === 0) {\n state.wbits = 15;\n }\n state.check = 0;\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n hold = 0;\n bits = 0;\n state.mode = FLAGS2;\n break;\n }\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 255) << 8) + (hold >> 8)) % 31) {\n strm.msg = "incorrect header check";\n state.mode = BAD2;\n break;\n }\n if ((hold & 15) !== Z_DEFLATED2) {\n strm.msg = "unknown compression method";\n state.mode = BAD2;\n break;\n }\n hold >>>= 4;\n bits -= 4;\n len = (hold & 15) + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n if (len > 15 || len > state.wbits) {\n strm.msg = "invalid window size";\n state.mode = BAD2;\n break;\n }\n state.dmax = 1 << state.wbits;\n state.flags = 0;\n strm.adler = state.check = 1;\n state.mode = hold & 512 ? DICTID2 : TYPE2;\n hold = 0;\n bits = 0;\n break;\n case FLAGS2:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.flags = hold;\n if ((state.flags & 255) !== Z_DEFLATED2) {\n strm.msg = "unknown compression method";\n state.mode = BAD2;\n break;\n }\n if (state.flags & 57344) {\n strm.msg = "unknown header flags set";\n state.mode = BAD2;\n break;\n }\n if (state.head) {\n state.head.text = hold >> 8 & 1;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = TIME2;\n /* falls through */\n case TIME2:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n hbuf[2] = hold >>> 16 & 255;\n hbuf[3] = hold >>> 24 & 255;\n state.check = crc322(state.check, hbuf, 4, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = OS2;\n /* falls through */\n case OS2:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.xflags = hold & 255;\n state.head.os = hold >> 8;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = EXLEN2;\n /* falls through */\n case EXLEN2:\n if (state.flags & 1024) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n } else if (state.head) {\n state.head.extra = null;\n }\n state.mode = EXTRA2;\n /* falls through */\n case EXTRA2:\n if (state.flags & 1024) {\n copy = state.length;\n if (copy > have) {\n copy = have;\n }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n state.head.extra = new Uint8Array(state.head.extra_len);\n }\n state.head.extra.set(\n input.subarray(\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n next + copy\n ),\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n }\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) {\n break inf_leave;\n }\n }\n state.length = 0;\n state.mode = NAME2;\n /* falls through */\n case NAME2:\n if (state.flags & 2048) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT2;\n /* falls through */\n case COMMENT2:\n if (state.flags & 4096) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC2;\n /* falls through */\n case HCRC2:\n if (state.flags & 512) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.check & 65535)) {\n strm.msg = "header crc mismatch";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n if (state.head) {\n state.head.hcrc = state.flags >> 9 & 1;\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE2;\n break;\n case DICTID2:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n strm.adler = state.check = zswap322(hold);\n hold = 0;\n bits = 0;\n state.mode = DICT2;\n /* falls through */\n case DICT2:\n if (state.havedict === 0) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n return Z_NEED_DICT2;\n }\n strm.adler = state.check = 1;\n state.mode = TYPE2;\n /* falls through */\n case TYPE2:\n if (flush === Z_BLOCK2 || flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case TYPEDO2:\n if (state.last) {\n hold >>>= bits & 7;\n bits -= bits & 7;\n state.mode = CHECK2;\n break;\n }\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.last = hold & 1;\n hold >>>= 1;\n bits -= 1;\n switch (hold & 3) {\n case 0:\n state.mode = STORED2;\n break;\n case 1:\n fixedtables2(state);\n state.mode = LEN_2;\n if (flush === Z_TREES2) {\n hold >>>= 2;\n bits -= 2;\n break inf_leave;\n }\n break;\n case 2:\n state.mode = TABLE2;\n break;\n case 3:\n strm.msg = "invalid block type";\n state.mode = BAD2;\n }\n hold >>>= 2;\n bits -= 2;\n break;\n case STORED2:\n hold >>>= bits & 7;\n bits -= bits & 7;\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {\n strm.msg = "invalid stored block lengths";\n state.mode = BAD2;\n break;\n }\n state.length = hold & 65535;\n hold = 0;\n bits = 0;\n state.mode = COPY_2;\n if (flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case COPY_2:\n state.mode = COPY2;\n /* falls through */\n case COPY2:\n copy = state.length;\n if (copy) {\n if (copy > have) {\n copy = have;\n }\n if (copy > left) {\n copy = left;\n }\n if (copy === 0) {\n break inf_leave;\n }\n output.set(input.subarray(next, next + copy), put);\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n state.mode = TYPE2;\n break;\n case TABLE2:\n while (bits < 14) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.nlen = (hold & 31) + 257;\n hold >>>= 5;\n bits -= 5;\n state.ndist = (hold & 31) + 1;\n hold >>>= 5;\n bits -= 5;\n state.ncode = (hold & 15) + 4;\n hold >>>= 4;\n bits -= 4;\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = "too many length or distance symbols";\n state.mode = BAD2;\n break;\n }\n state.have = 0;\n state.mode = LENLENS2;\n /* falls through */\n case LENLENS2:\n while (state.have < state.ncode) {\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.lens[order[state.have++]] = hold & 7;\n hold >>>= 3;\n bits -= 3;\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n state.lencode = state.lendyn;\n state.lenbits = 7;\n opts = { bits: state.lenbits };\n ret = inflate_table2(CODES2, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid code lengths set";\n state.mode = BAD2;\n break;\n }\n state.have = 0;\n state.mode = CODELENS2;\n /* falls through */\n case CODELENS2:\n while (state.have < state.nlen + state.ndist) {\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_val < 16) {\n hold >>>= here_bits;\n bits -= here_bits;\n state.lens[state.have++] = here_val;\n } else {\n if (here_val === 16) {\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n if (state.have === 0) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD2;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 3);\n hold >>>= 2;\n bits -= 2;\n } else if (here_val === 17) {\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 3 + (hold & 7);\n hold >>>= 3;\n bits -= 3;\n } else {\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 11 + (hold & 127);\n hold >>>= 7;\n bits -= 7;\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD2;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n if (state.mode === BAD2) {\n break;\n }\n if (state.lens[256] === 0) {\n strm.msg = "invalid code -- missing end-of-block";\n state.mode = BAD2;\n break;\n }\n state.lenbits = 9;\n opts = { bits: state.lenbits };\n ret = inflate_table2(LENS2, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid literal/lengths set";\n state.mode = BAD2;\n break;\n }\n state.distbits = 6;\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table2(DISTS2, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n state.distbits = opts.bits;\n if (ret) {\n strm.msg = "invalid distances set";\n state.mode = BAD2;\n break;\n }\n state.mode = LEN_2;\n if (flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case LEN_2:\n state.mode = LEN2;\n /* falls through */\n case LEN2:\n if (have >= 6 && left >= 258) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n inflate_fast2(strm, _out);\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n if (state.mode === TYPE2) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_op && (here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n state.mode = LIT2;\n break;\n }\n if (here_op & 32) {\n state.back = -1;\n state.mode = TYPE2;\n break;\n }\n if (here_op & 64) {\n strm.msg = "invalid literal/length code";\n state.mode = BAD2;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT2;\n /* falls through */\n case LENEXT2:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n state.was = state.length;\n state.mode = DIST2;\n /* falls through */\n case DIST2:\n for (; ; ) {\n here = state.distcode[hold & (1 << state.distbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = "invalid distance code";\n state.mode = BAD2;\n break;\n }\n state.offset = here_val;\n state.extra = here_op & 15;\n state.mode = DISTEXT2;\n /* falls through */\n case DISTEXT2:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.offset += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n if (state.offset > state.dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break;\n }\n state.mode = MATCH2;\n /* falls through */\n case MATCH2:\n if (left === 0) {\n break inf_leave;\n }\n copy = _out - left;\n if (state.offset > copy) {\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break;\n }\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n } else {\n from = state.wnext - copy;\n }\n if (copy > state.length) {\n copy = state.length;\n }\n from_source = state.window;\n } else {\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) {\n copy = left;\n }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) {\n state.mode = LEN2;\n }\n break;\n case LIT2:\n if (left === 0) {\n break inf_leave;\n }\n output[put++] = state.length;\n left--;\n state.mode = LEN2;\n break;\n case CHECK2:\n if (state.wrap) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold |= input[next++] << bits;\n bits += 8;\n }\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/\n state.flags ? crc322(state.check, output, _out, put - _out) : adler322(state.check, output, _out, put - _out);\n }\n _out = left;\n if (state.wrap & 4 && (state.flags ? hold : zswap322(hold)) !== state.check) {\n strm.msg = "incorrect data check";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = LENGTH2;\n /* falls through */\n case LENGTH2:\n if (state.wrap && state.flags) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.total & 4294967295)) {\n strm.msg = "incorrect length check";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = DONE2;\n /* falls through */\n case DONE2:\n ret = Z_STREAM_END2;\n break inf_leave;\n case BAD2:\n ret = Z_DATA_ERROR2;\n break inf_leave;\n case MEM2:\n return Z_MEM_ERROR2;\n case SYNC2:\n /* falls through */\n default:\n return Z_STREAM_ERROR2;\n }\n }\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n if (state.wsize || _out !== strm.avail_out && state.mode < BAD2 && (state.mode < CHECK2 || flush !== Z_FINISH2)) {\n if (updatewindow2(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/\n state.flags ? crc322(state.check, output, _out, strm.next_out - _out) : adler322(state.check, output, _out, strm.next_out - _out);\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE2 ? 128 : 0) + (state.mode === LEN_2 || state.mode === COPY_2 ? 256 : 0);\n if ((_in === 0 && _out === 0 || flush === Z_FINISH2) && ret === Z_OK2) {\n ret = Z_BUF_ERROR2;\n }\n return ret;\n };\n const inflateEnd2 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK2;\n };\n const inflateGetHeader2 = (strm, head) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n if ((state.wrap & 2) === 0) {\n return Z_STREAM_ERROR2;\n }\n state.head = head;\n head.done = false;\n return Z_OK2;\n };\n const inflateSetDictionary2 = (strm, dictionary) => {\n const dictLength = dictionary.length;\n let state;\n let dictid;\n let ret;\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n state = strm.state;\n if (state.wrap !== 0 && state.mode !== DICT2) {\n return Z_STREAM_ERROR2;\n }\n if (state.mode === DICT2) {\n dictid = 1;\n dictid = adler322(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR2;\n }\n }\n ret = updatewindow2(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM2;\n return Z_MEM_ERROR2;\n }\n state.havedict = 1;\n return Z_OK2;\n };\n inflate.inflateReset = inflateReset3;\n inflate.inflateReset2 = inflateReset22;\n inflate.inflateResetKeep = inflateResetKeep2;\n inflate.inflateInit = inflateInit3;\n inflate.inflateInit2 = inflateInit22;\n inflate.inflate = inflate$12;\n inflate.inflateEnd = inflateEnd2;\n inflate.inflateGetHeader = inflateGetHeader2;\n inflate.inflateSetDictionary = inflateSetDictionary2;\n inflate.inflateInfo = "pako inflate (from Nodeca project)";\n return inflate;\n}\nvar gzheader;\nvar hasRequiredGzheader;\nfunction requireGzheader() {\n if (hasRequiredGzheader) return gzheader;\n hasRequiredGzheader = 1;\n function GZheader2() {\n this.text = 0;\n this.time = 0;\n this.xflags = 0;\n this.os = 0;\n this.extra = null;\n this.extra_len = 0;\n this.name = "";\n this.comment = "";\n this.hcrc = 0;\n this.done = false;\n }\n gzheader = GZheader2;\n return gzheader;\n}\nvar hasRequiredInflate;\nfunction requireInflate() {\n if (hasRequiredInflate) return inflate$1;\n hasRequiredInflate = 1;\n const zlib_inflate = requireInflate$1();\n const utils = requireCommon();\n const strings2 = requireStrings();\n const msg = requireMessages();\n const ZStream2 = requireZstream();\n const GZheader2 = requireGzheader();\n const toString2 = Object.prototype.toString;\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_FINISH: Z_FINISH2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_NEED_DICT: Z_NEED_DICT2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_MEM_ERROR: Z_MEM_ERROR2\n } = requireConstants();\n function Inflate(options) {\n this.options = utils.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ""\n }, options || {});\n const opt = this.options;\n if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) {\n opt.windowBits = -15;\n }\n }\n if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n if (opt.windowBits > 15 && opt.windowBits < 48) {\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new ZStream2();\n this.strm.avail_out = 0;\n let status = zlib_inflate.inflateInit2(\n this.strm,\n opt.windowBits\n );\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n this.header = new GZheader2();\n zlib_inflate.inflateGetHeader(this.strm, this.header);\n if (opt.dictionary) {\n if (typeof opt.dictionary === "string") {\n opt.dictionary = strings2.string2buf(opt.dictionary);\n } else if (toString2.call(opt.dictionary) === "[object ArrayBuffer]") {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) {\n status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n }\n }\n }\n Inflate.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n const dictionary = this.options.dictionary;\n let status, _flush_mode, last_avail_out;\n if (this.ended) return false;\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH2 : Z_NO_FLUSH2;\n if (toString2.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n for (; ; ) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = zlib_inflate.inflate(strm, _flush_mode);\n if (status === Z_NEED_DICT2 && dictionary) {\n status = zlib_inflate.inflateSetDictionary(strm, dictionary);\n if (status === Z_OK2) {\n status = zlib_inflate.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR2) {\n status = Z_NEED_DICT2;\n }\n }\n while (strm.avail_in > 0 && status === Z_STREAM_END2 && strm.state.wrap > 0 && data[strm.next_in] !== 0) {\n zlib_inflate.inflateReset(strm);\n status = zlib_inflate.inflate(strm, _flush_mode);\n }\n switch (status) {\n case Z_STREAM_ERROR2:\n case Z_DATA_ERROR2:\n case Z_NEED_DICT2:\n case Z_MEM_ERROR2:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n last_avail_out = strm.avail_out;\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END2) {\n if (this.options.to === "string") {\n let next_out_utf8 = strings2.utf8border(strm.output, strm.next_out);\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings2.buf2string(strm.output, next_out_utf8);\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);\n this.onData(utf8str);\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n if (status === Z_OK2 && last_avail_out === 0) continue;\n if (status === Z_STREAM_END2) {\n status = zlib_inflate.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n };\n Inflate.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n };\n Inflate.prototype.onEnd = function(status) {\n if (status === Z_OK2) {\n if (this.options.to === "string") {\n this.result = this.chunks.join("");\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n function inflate2(input, options) {\n const inflator = new Inflate(options);\n inflator.push(input);\n if (inflator.err) throw inflator.msg || msg[inflator.err];\n return inflator.result;\n }\n function inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate2(input, options);\n }\n inflate$1.Inflate = Inflate;\n inflate$1.inflate = inflate2;\n inflate$1.inflateRaw = inflateRaw;\n inflate$1.ungzip = inflate2;\n inflate$1.constants = requireConstants();\n return inflate$1;\n}\nvar hasRequiredPako;\nfunction requirePako() {\n if (hasRequiredPako) return pako;\n hasRequiredPako = 1;\n const { Deflate, deflate: deflate2, deflateRaw, gzip } = requireDeflate();\n const { Inflate, inflate: inflate2, inflateRaw, ungzip } = requireInflate();\n const constants2 = requireConstants();\n pako.Deflate = Deflate;\n pako.deflate = deflate2;\n pako.deflateRaw = deflateRaw;\n pako.gzip = gzip;\n pako.Inflate = Inflate;\n pako.inflate = inflate2;\n pako.inflateRaw = inflateRaw;\n pako.ungzip = ungzip;\n pako.constants = constants2;\n return pako;\n}\nvar paeth = {};\nvar hasRequiredPaeth;\nfunction requirePaeth() {\n if (hasRequiredPaeth) return paeth;\n hasRequiredPaeth = 1;\n Object.defineProperty(paeth, "__esModule", { value: true });\n paeth.paethPredicator = void 0;\n function paethPredicator(a, b, c) {\n const p = a + b - c;\n const pa = Math.abs(p - a);\n const pb = Math.abs(p - b);\n const pc = Math.abs(p - c);\n if (pa <= pb && pa <= pc) {\n return a;\n }\n if (pb <= pc) {\n return b;\n }\n return c;\n }\n paeth.paethPredicator = paethPredicator;\n return paeth;\n}\nvar hasRequiredChunk_IDAT;\nfunction requireChunk_IDAT() {\n if (hasRequiredChunk_IDAT) return chunk_IDAT;\n hasRequiredChunk_IDAT = 1;\n Object.defineProperty(chunk_IDAT, "__esModule", { value: true });\n chunk_IDAT.parseChunk = void 0;\n const pako2 = requirePako();\n const assert_js_1 = requireAssert$1();\n const paeth_js_1 = requirePaeth();\n function parseChunk(ctx, header, chunks) {\n const decompressed = decompress(ctx, chunks);\n let packed;\n if (header.interlaceMethod === 1) {\n packed = deinterlaceAdam7(ctx, header, decompressed);\n } else {\n packed = defilter(ctx, header, decompressed);\n }\n const trnsChunk = ctx.metadata.find((e) => e.type === "tRNS");\n const result = mapPackedDataToRgba(ctx, header, packed, ctx.palette, trnsChunk);\n if (trnsChunk && (header.colorType === 0 || header.colorType === 2)) {\n applyTransparency(header, result, trnsChunk);\n }\n return result;\n }\n chunk_IDAT.parseChunk = parseChunk;\n function decompress(ctx, chunks) {\n const inflator = new pako2.Inflate();\n let offset = 0;\n for (const chunk of chunks) {\n offset = chunk.offset + 4 + 4;\n inflator.push(ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + offset + chunk.dataLength));\n }\n if (inflator.err) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunks[0], `Inflate error: ${inflator.msg}`, chunks[0].offset);\n }\n if (inflator.result === void 0) {\n throw new assert_js_1.DecodeError(ctx, "IDAT: Failed to decompress data chunks", 0);\n }\n return inflator.result;\n }\n function defilter(ctx, header, decompressed, start = 0, width = header.width, height = header.height) {\n let i = 0;\n const bpp = getBytesPerPixel(header);\n const bppFloat = getBytesPerPixelFloat(header);\n const bpl = getBytesPerLine(header, width);\n const bplCeiled = Math.ceil(width * bppFloat);\n const result = new Uint8Array(height * bplCeiled);\n const filterFnCache = /* @__PURE__ */ new Map();\n for (let y = 0; y < height; y++) {\n let lineOffset = start + y * (bpl + 1);\n const filterType = decompressed[lineOffset++];\n if (!isValidFilterType) {\n throw new assert_js_1.DecodeError(ctx, `IDAT: Invalid filter type ${filterType}`, 0);\n }\n let filterFn = filterFnCache.get(filterType);\n if (!filterFn) {\n filterFn = buildDefilterFunction(bppFloat, bpl, width, filterType);\n filterFnCache.set(filterType, filterFn);\n }\n let pixel = 1;\n let x = 0;\n switch (filterType) {\n case 0:\n case 1: {\n for (; x < bpp; x++) {\n result[i] = decompressed[lineOffset + x];\n i++;\n }\n break;\n }\n case 3: {\n let bi = 0;\n for (; x < bpp; x++) {\n bi = i - width * bpp;\n result[i] = decompressed[lineOffset + x] + Math.floor(0 + (bi < 0 ? 0 : result[bi])) / 2;\n i++;\n }\n break;\n }\n case 2: {\n pixel = 0;\n break;\n }\n case 4: {\n for (; x < bpp; x++) {\n const bi = Math.floor(i - bpl);\n result[i] = (decompressed[lineOffset + x] + (0, paeth_js_1.paethPredicator)(0, bi < 0 ? 0 : result[bi], 0)) % 256;\n i++;\n }\n break;\n }\n }\n if (header.bitDepth >= 8) {\n for (; pixel < width; pixel++) {\n for (let x2 = 0; x2 < bpp; x2++) {\n result[i] = filterFn(decompressed, lineOffset + pixel * bpp + x2, result, i);\n i++;\n }\n }\n } else {\n if (pixel) {\n i -= pixel;\n }\n for (x = pixel; x < bpl; x++) {\n result[i + x] = filterFn(decompressed, lineOffset + x, result, i + x);\n }\n i += bpl;\n }\n }\n return result;\n }\n function isValidFilterType(filterType) {\n return filterType % 1 === 0 && filterType >= 0 && filterType <= 4;\n }\n function buildDefilterFunction(bpp, bpl, width, filterType) {\n let ai = 0, bi = 0, ci = 0;\n switch (filterType) {\n case 0:\n return (filt, filtX) => filt[filtX];\n case 1:\n return (filt, filtX, recon, reconX) => (filt[filtX] + recon[Math.floor(reconX - bpp)]) % 256;\n case 2:\n return (filt, filtX, recon, reconX) => {\n bi = Math.floor(reconX - width * bpp);\n return bi < 0 ? filt[filtX] : (filt[filtX] + recon[bi]) % 256;\n };\n case 3:\n return (filt, filtX, recon, reconX) => {\n ai = Math.floor(reconX - bpp);\n bi = Math.floor(reconX - width * bpp);\n return filt[filtX] + Math.floor((ai < 0 ? 0 : recon[ai]) + (bi < 0 ? 0 : recon[bi])) / 2;\n };\n case 4:\n return (filt, filtX, recon, reconX) => {\n ai = Math.floor(reconX - Math.ceil(bpp));\n bi = Math.floor(reconX - bpl);\n ci = Math.floor(reconX - bpl - Math.ceil(bpp));\n return (filt[filtX] + (0, paeth_js_1.paethPredicator)(ai < 0 ? 0 : recon[ai], bi < 0 ? 0 : recon[bi], ci < 0 ? 0 : recon[ci])) % 256;\n };\n }\n }\n function getBytesPerPixel(header) {\n return Math.ceil(getBytesPerPixelFloat(header));\n }\n function getBytesPerPixelFloat(header) {\n return getChannelCount(header.colorType) * header.bitDepth / 8;\n }\n function getBytesPerLine(header, width) {\n return Math.ceil(getChannelCount(header.colorType) * header.bitDepth * width / 8);\n }\n function getChannelCount(colorType) {\n switch (colorType) {\n case 0:\n return 1;\n case 2:\n return 3;\n case 3:\n return 1;\n case 4:\n return 2;\n case 6:\n return 4;\n }\n }\n function deinterlaceAdam7(ctx, header, decompressed) {\n const bppFloat = getBytesPerPixelFloat(header);\n const bplCeiled = Math.ceil(header.width * bppFloat);\n const result = new Uint8Array(bplCeiled * header.height);\n const bpp = getBytesPerPixel(header);\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const xStart = [0, 4, 0, 2, 0, 1, 0];\n const yStart = [0, 0, 4, 0, 2, 0, 1];\n const xGap = [8, 8, 4, 4, 2, 2, 1];\n const yGap = [8, 8, 8, 4, 4, 2, 2];\n let dataPointer = 0;\n for (let pass = 0; pass < 7; pass++) {\n const passXStart = xStart[pass];\n const passYStart = yStart[pass];\n const passXGap = xGap[pass];\n const passYGap = yGap[pass];\n const passWidth = Math.ceil((header.width - passXStart) / passXGap);\n const passHeight = Math.ceil((header.height - passYStart) / passYGap);\n const passBplCeiled = Math.ceil(bppFloat * passWidth);\n if (passWidth === 0 || passHeight === 0) {\n continue;\n }\n const passPacked = defilter(ctx, header, decompressed, dataPointer, passWidth, passHeight);\n let i = 0;\n for (let y = 0; y < passHeight; y++) {\n i = (passYStart + y * passYGap) * bplCeiled + passXStart * bppFloat;\n for (let x = 0; x < passWidth; x++) {\n if (header.bitDepth < 8) {\n let value = passPacked[y * passBplCeiled + Math.floor(x * bppFloat)];\n value >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n value &= maxValue;\n const resultPosition = (pixelsPerByte - 1 - i % 1 * pixelsPerByte) * header.bitDepth;\n value <<= resultPosition;\n result[Math.floor(i)] |= value;\n } else {\n for (let j = 0; j < bpp; j++) {\n result[i + j] = passPacked[(y * passWidth + x) * bpp + j];\n }\n }\n i += passXGap * bppFloat;\n }\n }\n dataPointer += passHeight * (1 + getBytesPerLine(header, passWidth));\n }\n return result;\n }\n function mapPackedDataToRgba(ctx, header, packed, palette, trnsChunk) {\n const result = new (header.bitDepth === 16 ? Uint16Array : Uint8Array)(header.width * header.height * 4);\n let i = 0;\n const bpp = getBytesPerPixel(header);\n const bppFloat = getBytesPerPixelFloat(header);\n const bplCeiled = Math.ceil(header.width * bppFloat);\n switch (header.colorType) {\n case 0: {\n switch (header.bitDepth) {\n case 1:\n case 2:\n case 4: {\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const bytesPerPixel = header.bitDepth / 8;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n result[i] = packed[y * bplCeiled + Math.floor(x * bytesPerPixel)];\n result[i] >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n result[i] &= maxValue;\n result[i] *= 255 / maxValue;\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n result[i + 3] = 255;\n }\n }\n break;\n }\n case 8:\n case 16: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n }\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n result[i + 3] = header.bitDepth === 16 ? 65535 : 255;\n }\n }\n break;\n }\n }\n break;\n }\n case 4: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n }\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n if (header.bitDepth === 16) {\n result[i + 3] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n } else {\n result[i + 3] = packed[(y * header.width + x) * bpp + 1];\n }\n }\n }\n break;\n }\n case 3: {\n if (!palette) {\n throw new assert_js_1.DecodeError(ctx, "IDAT: Cannot decode indexed color type without a palette", 0);\n }\n switch (header.bitDepth) {\n case 1:\n case 2:\n case 4: {\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const bytesPerPixel = header.bitDepth / 8;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n let colorId = packed[y * bplCeiled + Math.floor(x * bytesPerPixel)];\n colorId >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n colorId &= maxValue;\n palette.setRgba(result, i, colorId);\n if (trnsChunk && trnsChunk.transparency.length > colorId) {\n result[i + 3] = trnsChunk.transparency[colorId];\n }\n }\n }\n break;\n }\n case 8: {\n let colorId = 0;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n colorId = packed[y * header.width + x];\n palette.setRgba(result, i, colorId);\n if (trnsChunk && trnsChunk.transparency.length > colorId) {\n result[i + 3] = trnsChunk.transparency[colorId];\n }\n }\n }\n break;\n }\n }\n break;\n }\n case 2: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n result[i + 1] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n result[i + 2] = packed[(y * header.width + x) * bpp + 4] << 8 | packed[(y * header.width + x) * bpp + 5];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n result[i + 1] = packed[(y * header.width + x) * bpp + 1];\n result[i + 2] = packed[(y * header.width + x) * bpp + 2];\n }\n result[i + 3] = header.bitDepth === 16 ? 65535 : 255;\n }\n }\n break;\n }\n case 6: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n result[i + 1] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n result[i + 2] = packed[(y * header.width + x) * bpp + 4] << 8 | packed[(y * header.width + x) * bpp + 5];\n result[i + 3] = packed[(y * header.width + x) * bpp + 6] << 8 | packed[(y * header.width + x) * bpp + 7];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n result[i + 1] = packed[(y * header.width + x) * bpp + 1];\n result[i + 2] = packed[(y * header.width + x) * bpp + 2];\n result[i + 3] = packed[(y * header.width + x) * bpp + 3];\n }\n }\n }\n break;\n }\n }\n return result;\n }\n function applyTransparency(header, data, trnsChunk) {\n const maxEncodedValue = (1 << header.bitDepth) - 1;\n const maxDataValue = header.bitDepth === 16 ? 65535 : 255;\n if (header.colorType === 0) {\n const shade = maxDataValue / maxEncodedValue * trnsChunk.transparency;\n for (let i = 0; i < data.length; i += 4) {\n if (data[i] === shade) {\n data[i + 3] = 0;\n }\n }\n return;\n }\n if (header.colorType === 2) {\n const channels = [\n maxDataValue / maxEncodedValue * trnsChunk.transparency[0],\n maxDataValue / maxEncodedValue * trnsChunk.transparency[1],\n maxDataValue / maxEncodedValue * trnsChunk.transparency[2]\n ];\n for (let i = 0; i < data.length; i += 4) {\n if (data[i] === channels[0] && data[i + 1] === channels[1] && data[i + 2] === channels[2]) {\n data[i + 3] = 0;\n }\n }\n return;\n }\n }\n return chunk_IDAT;\n}\nvar chunk_IEND = {};\nvar hasRequiredChunk_IEND;\nfunction requireChunk_IEND() {\n if (hasRequiredChunk_IEND) return chunk_IEND;\n hasRequiredChunk_IEND = 1;\n Object.defineProperty(chunk_IEND, "__esModule", { value: true });\n chunk_IEND.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 0);\n }\n chunk_IEND.parseChunk = parseChunk;\n return chunk_IEND;\n}\nvar chunk_IHDR = {};\nvar validate = {};\nvar hasRequiredValidate;\nfunction requireValidate() {\n if (hasRequiredValidate) return validate;\n hasRequiredValidate = 1;\n Object.defineProperty(validate, "__esModule", { value: true });\n validate.isValidInterlaceMethod = validate.isValidFilterMethod = validate.isValidColorType = validate.isValidBitDepth = void 0;\n function isValidBitDepth(bitDepth) {\n return bitDepth === 1 || bitDepth === 2 || bitDepth === 4 || bitDepth === 8 || bitDepth === 16;\n }\n validate.isValidBitDepth = isValidBitDepth;\n function isValidColorType(colorType, bitDepth) {\n return colorType === 0 && bitDepth >= 1 && bitDepth <= 16 || colorType === 2 && bitDepth >= 8 && bitDepth <= 16 || colorType === 3 && bitDepth >= 1 && bitDepth <= 8 || colorType === 4 && bitDepth >= 8 && bitDepth <= 16 || colorType === 6 && bitDepth >= 8 && bitDepth <= 16;\n }\n validate.isValidColorType = isValidColorType;\n function isValidFilterMethod(filterMethod) {\n return filterMethod === 0;\n }\n validate.isValidFilterMethod = isValidFilterMethod;\n function isValidInterlaceMethod(interlaceMethod) {\n return interlaceMethod === 0 || interlaceMethod === 1;\n }\n validate.isValidInterlaceMethod = isValidInterlaceMethod;\n return validate;\n}\nvar hasRequiredChunk_IHDR;\nfunction requireChunk_IHDR() {\n if (hasRequiredChunk_IHDR) return chunk_IHDR;\n hasRequiredChunk_IHDR = 1;\n Object.defineProperty(chunk_IHDR, "__esModule", { value: true });\n chunk_IHDR.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const validate_js_1 = requireValidate();\n function parseChunk(ctx, chunk) {\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 13);\n let offset = chunk.offset + 4 + 4;\n const width = ctx.view.getUint32(offset);\n offset += 4;\n const height = ctx.view.getUint32(offset);\n offset += 4;\n const bitDepth = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidBitDepth)(bitDepth)) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunk, `Bit depth "${bitDepth}" is not valid`, offset);\n }\n offset++;\n const colorType = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidColorType)(colorType, bitDepth)) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunk, `Color type "${colorType}" is not valid with bit depth "${bitDepth}"`, offset);\n }\n offset++;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n let filterMethod = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidFilterMethod)(filterMethod)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Filter method "${filterMethod}" is not valid`, offset));\n filterMethod = 0;\n }\n offset++;\n let interlaceMethod = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidInterlaceMethod)(interlaceMethod)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Interlace method "${interlaceMethod}" is not valid`, offset));\n interlaceMethod = 0;\n }\n offset++;\n return {\n width,\n height,\n bitDepth,\n colorType,\n interlaceMethod\n };\n }\n chunk_IHDR.parseChunk = parseChunk;\n return chunk_IHDR;\n}\nvar crc32 = {};\nvar hasRequiredCrc32;\nfunction requireCrc32() {\n if (hasRequiredCrc32) return crc32;\n hasRequiredCrc32 = 1;\n Object.defineProperty(crc32, "__esModule", { value: true });\n crc32.crc32 = crc32.getCrcTable = void 0;\n let tableInternal;\n function getCrcTable() {\n if (tableInternal) {\n return tableInternal;\n }\n tableInternal = [];\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) {\n if (c & 1) {\n c = 3988292384 ^ c >>> 1;\n } else {\n c = c >>> 1;\n }\n }\n tableInternal[n] = c >>> 0;\n }\n return tableInternal;\n }\n crc32.getCrcTable = getCrcTable;\n function updateCrc(crc, dataView, offset, length) {\n const table = getCrcTable();\n let c = crc;\n for (let n = 0; n < length; n++) {\n c = table[(c ^ dataView.getUint8(offset + n)) & 255] ^ c >>> 8;\n }\n return c;\n }\n function crc32$12(dataView, offset, length) {\n return (updateCrc(4294967295, dataView, offset, length) ^ 4294967295) >>> 0;\n }\n crc32.crc32 = crc32$12;\n return crc32;\n}\nvar chunk_bKGD = {};\nvar hasRequiredChunk_bKGD;\nfunction requireChunk_bKGD() {\n if (hasRequiredChunk_bKGD) return chunk_bKGD;\n hasRequiredChunk_bKGD = 1;\n Object.defineProperty(chunk_bKGD, "__esModule", { value: true });\n chunk_bKGD.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const offset = chunk.offset + 4 + 4;\n let color;\n let expectedLength;\n switch (header.colorType) {\n case 0:\n case 4: {\n color = ctx.view.getUint16(offset);\n expectedLength = 2;\n break;\n }\n case 2:\n case 6: {\n color = [\n ctx.view.getUint16(offset),\n ctx.view.getUint16(offset + 2),\n ctx.view.getUint16(offset + 4)\n ];\n expectedLength = 6;\n break;\n }\n case 3: {\n color = ctx.view.getUint8(offset);\n expectedLength = 1;\n break;\n }\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Unrecognized color type "${header.colorType}"`, offset);\n }\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, expectedLength);\n return { type: "bKGD", color };\n }\n chunk_bKGD.parseChunk = parseChunk;\n return chunk_bKGD;\n}\nvar chunk_cHRM = {};\nvar hasRequiredChunk_cHRM;\nfunction requireChunk_cHRM() {\n if (hasRequiredChunk_cHRM) return chunk_cHRM;\n hasRequiredChunk_cHRM = 1;\n Object.defineProperty(chunk_cHRM, "__esModule", { value: true });\n chunk_cHRM.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 32);\n let offset = chunk.offset + 4 + 4;\n const whitePoint = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (whitePoint.x > 1 || whitePoint.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid white point (${whitePoint.x},${whitePoint.y})`, offset);\n }\n offset += 8;\n const red = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (red.x > 1 || red.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid red (${red.x},${red.y})`, offset);\n }\n offset += 8;\n const green = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (green.x > 1 || green.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid green (${green.x},${green.y})`, offset);\n }\n offset += 8;\n const blue = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (blue.x > 1 || blue.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid blue (${blue.x},${blue.y})`, offset);\n }\n return {\n type: "cHRM",\n whitePoint,\n red,\n green,\n blue\n };\n }\n chunk_cHRM.parseChunk = parseChunk;\n return chunk_cHRM;\n}\nvar chunk_eXIf = {};\nvar hasRequiredChunk_eXIf;\nfunction requireChunk_eXIf() {\n if (hasRequiredChunk_eXIf) return chunk_eXIf;\n hasRequiredChunk_eXIf = 1;\n Object.defineProperty(chunk_eXIf, "__esModule", { value: true });\n chunk_eXIf.parseChunk = void 0;\n function parseChunk(ctx, header, chunk) {\n const offset = chunk.offset + 4 + 4;\n return {\n type: "eXIf",\n value: ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + offset + chunk.dataLength)\n };\n }\n chunk_eXIf.parseChunk = parseChunk;\n return chunk_eXIf;\n}\nvar chunk_gAMA = {};\nvar hasRequiredChunk_gAMA;\nfunction requireChunk_gAMA() {\n if (hasRequiredChunk_gAMA) return chunk_gAMA;\n hasRequiredChunk_gAMA = 1;\n Object.defineProperty(chunk_gAMA, "__esModule", { value: true });\n chunk_gAMA.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 4);\n const offset = chunk.offset + 4 + 4;\n const value = ctx.view.getUint32(offset) / 1e5;\n if (value === 0) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, "A value of 0 is meaningless", offset));\n }\n return {\n type: "gAMA",\n value\n };\n }\n chunk_gAMA.parseChunk = parseChunk;\n return chunk_gAMA;\n}\nvar chunk_hIST = {};\nvar hasRequiredChunk_hIST;\nfunction requireChunk_hIST() {\n if (hasRequiredChunk_hIST) return chunk_hIST;\n hasRequiredChunk_hIST = 1;\n Object.defineProperty(chunk_hIST, "__esModule", { value: true });\n chunk_hIST.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, ctx.palette.size * 2);\n const offset = chunk.offset + 4 + 4;\n const frequency = [];\n for (let i = 0; i < ctx.palette.size * 2; i += 2) {\n frequency.push(ctx.view.getUint16(offset + i));\n }\n return {\n type: "hIST",\n frequency\n };\n }\n chunk_hIST.parseChunk = parseChunk;\n return chunk_hIST;\n}\nvar chunk_iCCP = {};\nvar text = {};\nvar hasRequiredText;\nfunction requireText() {\n if (hasRequiredText) return text;\n hasRequiredText = 1;\n Object.defineProperty(text, "__esModule", { value: true });\n text.readText = void 0;\n const pako2 = requirePako();\n const assert_js_1 = requireAssert$1();\n function readText(ctx, chunk, textDecoder, maxLength, offset, maxOffset, readTrailingNull, isCompressed) {\n const bytes = [];\n let current = 0;\n let i = 0;\n for (; maxLength === void 0 || i < maxLength; i++) {\n if (!readTrailingNull && offset === maxOffset) {\n break;\n }\n try {\n current = ctx.view.getUint8(offset);\n } catch (e) {\n if (e instanceof Error && e.message === "Offset is outside the bounds of the DataView") {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "EOF while reading text", offset);\n }\n throw e;\n }\n if (!isCompressed && current === 0) {\n break;\n }\n offset++;\n bytes.push(current);\n }\n if (readTrailingNull && ctx.view.getUint8(offset) !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "No null character after text", offset);\n }\n let typedArray = new Uint8Array(bytes);\n if (isCompressed) {\n const inflator = new pako2.Inflate();\n inflator.push(typedArray);\n if (inflator.err) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Inflate error: ${inflator.msg}`, offset);\n }\n typedArray = inflator.result;\n }\n return { text: textDecoder ? textDecoder.decode(typedArray) : String.fromCharCode(...bytes), bytesRead: i + 1 };\n }\n text.readText = readText;\n return text;\n}\nvar hasRequiredChunk_iCCP;\nfunction requireChunk_iCCP() {\n if (hasRequiredChunk_iCCP) return chunk_iCCP;\n hasRequiredChunk_iCCP = 1;\n Object.defineProperty(chunk_iCCP, "__esModule", { value: true });\n chunk_iCCP.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkMutualExclusion)(ctx, chunk, "sRGB");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 3);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const name = readResult.text;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n const data = new Uint8Array(ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + maxOffset));\n return {\n type: "iCCP",\n name,\n data\n };\n }\n chunk_iCCP.parseChunk = parseChunk;\n return chunk_iCCP;\n}\nvar chunk_iTXt = {};\nvar hasRequiredChunk_iTXt;\nfunction requireChunk_iTXt() {\n if (hasRequiredChunk_iTXt) return chunk_iTXt;\n hasRequiredChunk_iTXt = 1;\n Object.defineProperty(chunk_iTXt, "__esModule", { value: true });\n chunk_iTXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n let offset = chunk.offset + 4 + 4;\n const maxOffset = offset + chunk.dataLength;\n const textDecoder = new TextDecoder("utf8");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n const isCompressed = ctx.view.getUint8(offset++) === 1;\n const compressionMethod = ctx.view.getUint8(offset);\n if (isCompressed) {\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n }\n offset++;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const languageTag = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const translatedKeyword = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false, isCompressed);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "iTXt",\n keyword,\n languageTag,\n translatedKeyword,\n text: text2\n };\n }\n chunk_iTXt.parseChunk = parseChunk;\n return chunk_iTXt;\n}\nvar chunk_tIME = {};\nvar hasRequiredChunk_tIME;\nfunction requireChunk_tIME() {\n if (hasRequiredChunk_tIME) return chunk_tIME;\n hasRequiredChunk_tIME = 1;\n Object.defineProperty(chunk_tIME, "__esModule", { value: true });\n chunk_tIME.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 7);\n let offset = chunk.offset + 4 + 4;\n const year = ctx.view.getUint16(offset);\n offset += 2;\n const month = ctx.view.getUint8(offset++);\n const day = ctx.view.getUint8(offset++);\n const hour = ctx.view.getUint8(offset++);\n const minute = ctx.view.getUint8(offset++);\n const second = ctx.view.getUint8(offset++);\n return {\n type: "tIME",\n value: new Date(year, month, day, hour, minute, second)\n };\n }\n chunk_tIME.parseChunk = parseChunk;\n return chunk_tIME;\n}\nvar chunk_oFFs = {};\nvar hasRequiredChunk_oFFs;\nfunction requireChunk_oFFs() {\n if (hasRequiredChunk_oFFs) return chunk_oFFs;\n hasRequiredChunk_oFFs = 1;\n Object.defineProperty(chunk_oFFs, "__esModule", { value: true });\n chunk_oFFs.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 9);\n let offset = chunk.offset + 4 + 4;\n const x = ctx.view.getInt32(offset);\n offset += 4;\n const y = ctx.view.getInt32(offset);\n offset += 4;\n const unitTypeByte = ctx.view.getUint8(offset);\n let unitType;\n switch (unitTypeByte) {\n case 0:\n unitType = "pixel";\n break;\n case 1:\n unitType = "micrometer";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid oFFs unit type ("${unitTypeByte}")`, offset);\n }\n return {\n type: "oFFs",\n offset: { x, y },\n unitType\n };\n }\n chunk_oFFs.parseChunk = parseChunk;\n return chunk_oFFs;\n}\nvar chunk_pCAL = {};\nvar float = {};\nvar hasRequiredFloat;\nfunction requireFloat() {\n if (hasRequiredFloat) return float;\n hasRequiredFloat = 1;\n Object.defineProperty(float, "__esModule", { value: true });\n float.readFloat = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function readFloat(ctx, chunk, textDecoder, offset, maxOffset, readTrailingNull) {\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, readTrailingNull);\n offset += readResult.bytesRead;\n if (!isValidFloatingPoint(readResult.text)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid character in floating point number ("${readResult.text}")`, offset));\n }\n const value = parseFloat(readResult.text);\n return {\n bytesRead: readResult.bytesRead,\n value\n };\n }\n float.readFloat = readFloat;\n function isValidFloatingPoint(text2) {\n return text2.match(/^[+-]?[0-9]+\\.[0-9]+([eE][+-]?[0-9]+)?$/) || text2.match(/^[+-]?[0-9]+\\.?([eE][+-]?[0-9]+)?$/) || text2.match(/^[+-]?\\.[0-9]+([eE][+-]?[0-9]+)?$/);\n }\n return float;\n}\nvar hasRequiredChunk_pCAL;\nfunction requireChunk_pCAL() {\n if (hasRequiredChunk_pCAL) return chunk_pCAL;\n hasRequiredChunk_pCAL = 1;\n Object.defineProperty(chunk_pCAL, "__esModule", { value: true });\n chunk_pCAL.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const float_js_1 = requireFloat();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 4);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readTextResult;\n readTextResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readTextResult.bytesRead;\n const calibrationName = readTextResult.text;\n const x0 = ctx.view.getInt32(offset);\n offset += 4;\n const x1 = ctx.view.getInt32(offset);\n offset += 4;\n const equationTypeByte = ctx.view.getUint8(offset++);\n let equationType;\n switch (equationTypeByte) {\n case 0:\n equationType = "linear-mapping";\n break;\n case 1:\n equationType = "base-e exponential mapping";\n break;\n case 2:\n equationType = "arbitrary-base exponential mapping";\n break;\n case 3:\n equationType = "hyperbolic mapping";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid equation type "${equationTypeByte}"`, offset);\n }\n const parameterCount = ctx.view.getUint8(offset++);\n readTextResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readTextResult.bytesRead;\n const unitName = readTextResult.text;\n const params = [];\n let readFloatResult;\n for (let i = 0; i < parameterCount; i++) {\n readFloatResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, i < parameterCount - 1);\n offset += readFloatResult.bytesRead;\n params.push(readFloatResult.value);\n }\n return {\n type: "pCAL",\n calibrationName,\n x0,\n x1,\n equationType,\n unitName,\n params\n };\n }\n chunk_pCAL.parseChunk = parseChunk;\n return chunk_pCAL;\n}\nvar chunk_pHYs = {};\nvar hasRequiredChunk_pHYs;\nfunction requireChunk_pHYs() {\n if (hasRequiredChunk_pHYs) return chunk_pHYs;\n hasRequiredChunk_pHYs = 1;\n Object.defineProperty(chunk_pHYs, "__esModule", { value: true });\n chunk_pHYs.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 9);\n let offset = chunk.offset + 4 + 4;\n const x = ctx.view.getUint32(offset);\n offset += 4;\n const y = ctx.view.getUint32(offset);\n offset += 4;\n const unitType = ctx.view.getUint8(offset) === 1 ? "meter" : "unknown";\n return {\n type: "pHYs",\n pixelsPerUnit: { x, y },\n unitType\n };\n }\n chunk_pHYs.parseChunk = parseChunk;\n return chunk_pHYs;\n}\nvar chunk_sBIT = {};\nvar hasRequiredChunk_sBIT;\nfunction requireChunk_sBIT() {\n if (hasRequiredChunk_sBIT) return chunk_sBIT;\n hasRequiredChunk_sBIT = 1;\n Object.defineProperty(chunk_sBIT, "__esModule", { value: true });\n chunk_sBIT.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const offset = chunk.offset + 4 + 4;\n let value;\n let expectedLength;\n switch (header.colorType) {\n case 0: {\n value = ctx.view.getUint8(offset);\n expectedLength = 1;\n break;\n }\n case 2:\n case 3: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1),\n ctx.view.getUint8(offset + 2)\n ];\n expectedLength = 3;\n break;\n }\n case 4: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1)\n ];\n expectedLength = 2;\n break;\n }\n case 6: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1),\n ctx.view.getUint8(offset + 2),\n ctx.view.getUint8(offset + 3)\n ];\n expectedLength = 4;\n break;\n }\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Unrecognized color type "${header.colorType}"`, offset);\n }\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, expectedLength);\n return {\n type: "sBIT",\n value\n };\n }\n chunk_sBIT.parseChunk = parseChunk;\n return chunk_sBIT;\n}\nvar chunk_sCAL = {};\nvar hasRequiredChunk_sCAL;\nfunction requireChunk_sCAL() {\n if (hasRequiredChunk_sCAL) return chunk_sCAL;\n hasRequiredChunk_sCAL = 1;\n Object.defineProperty(chunk_sCAL, "__esModule", { value: true });\n chunk_sCAL.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const float_js_1 = requireFloat();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 4);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n const unitTypeByte = ctx.view.getUint8(offset);\n let unitType;\n switch (unitTypeByte) {\n case 0:\n unitType = "meter";\n break;\n case 1:\n unitType = "radian";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid sCAL unit type ("${unitTypeByte}")`, offset);\n }\n offset++;\n let readResult;\n readResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const x = readResult.value;\n readResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, false);\n offset += readResult.bytesRead;\n const y = readResult.value;\n if (x < 0 || y < 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Values cannot be negative (${x}, ${y})`, offset);\n }\n return {\n type: "sCAL",\n pixelsPerUnit: { x, y },\n unitType\n };\n }\n chunk_sCAL.parseChunk = parseChunk;\n return chunk_sCAL;\n}\nvar chunk_sPLT = {};\nvar hasRequiredChunk_sPLT;\nfunction requireChunk_sPLT() {\n if (hasRequiredChunk_sPLT) return chunk_sPLT;\n hasRequiredChunk_sPLT = 1;\n Object.defineProperty(chunk_sPLT, "__esModule", { value: true });\n chunk_sPLT.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const dataStartOffset = chunk.offset + 4 + 4;\n let offset = dataStartOffset;\n const maxOffset = offset + chunk.dataLength;\n const textDecoder = new TextDecoder("latin1");\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const name = readResult.text;\n const sampleDepth = ctx.view.getUint8(offset++);\n const sampleBytes = sampleDepth === 16 ? 2 : 1;\n const entrySize = sampleBytes * 4 + 2;\n const entriesOffset = chunk.dataLength - (offset - dataStartOffset);\n const entryCount = entriesOffset / entrySize;\n if (entryCount % 1 !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid data length: ${entriesOffset} should be divisible by entry size ${entrySize}`, offset);\n }\n const entries = [];\n for (let i = 0; i < entryCount; i++) {\n const channels = [];\n for (let c = 0; c < 4; c++) {\n channels.push(sampleBytes === 2 ? ctx.view.getUint16(offset) : ctx.view.getUint8(offset));\n offset += sampleBytes;\n }\n const frequency = ctx.view.getUint16(offset);\n offset += 2;\n entries.push({\n red: channels[0],\n green: channels[1],\n blue: channels[2],\n alpha: channels[3],\n frequency\n });\n }\n return {\n type: "sPLT",\n name,\n sampleDepth,\n entries\n };\n }\n chunk_sPLT.parseChunk = parseChunk;\n return chunk_sPLT;\n}\nvar chunk_sRGB = {};\nvar hasRequiredChunk_sRGB;\nfunction requireChunk_sRGB() {\n if (hasRequiredChunk_sRGB) return chunk_sRGB;\n hasRequiredChunk_sRGB = 1;\n Object.defineProperty(chunk_sRGB, "__esModule", { value: true });\n chunk_sRGB.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkMutualExclusion)(ctx, chunk, "iCCP");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 1);\n const offset = chunk.offset + 4 + 4;\n const byte = ctx.view.getUint8(offset);\n let renderingIntent;\n switch (byte) {\n case 0:\n case 1:\n case 2:\n case 3:\n renderingIntent = byte;\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid rendering intent "${byte}"`, offset);\n }\n return {\n type: "sRGB",\n renderingIntent\n };\n }\n chunk_sRGB.parseChunk = parseChunk;\n return chunk_sRGB;\n}\nvar chunk_sTER = {};\nvar hasRequiredChunk_sTER;\nfunction requireChunk_sTER() {\n if (hasRequiredChunk_sTER) return chunk_sTER;\n hasRequiredChunk_sTER = 1;\n Object.defineProperty(chunk_sTER, "__esModule", { value: true });\n chunk_sTER.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 1);\n const offset = chunk.offset + 4 + 4;\n const layoutModeByte = ctx.view.getUint8(offset);\n let layoutMode;\n switch (layoutModeByte) {\n case 0:\n layoutMode = "cross-fuse";\n break;\n case 1:\n layoutMode = "diverging-fuse";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid layout mode "${layoutModeByte}"`, offset);\n }\n const padding = 15 - (header.width - 1) % 16;\n if (padding > 7) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid padding value "${padding}" for image width ${header.width}`, offset);\n }\n const subimageWidth = Math.floor((header.width - padding) / 2);\n return {\n type: "sTER",\n layoutMode,\n subimageWidth,\n padding\n };\n }\n chunk_sTER.parseChunk = parseChunk;\n return chunk_sTER;\n}\nvar chunk_tEXt = {};\nvar hasRequiredChunk_tEXt;\nfunction requireChunk_tEXt() {\n if (hasRequiredChunk_tEXt) return chunk_tEXt;\n hasRequiredChunk_tEXt = 1;\n Object.defineProperty(chunk_tEXt, "__esModule", { value: true });\n chunk_tEXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "tEXt",\n keyword,\n text: text2\n };\n }\n chunk_tEXt.parseChunk = parseChunk;\n return chunk_tEXt;\n}\nvar chunk_tRNS = {};\nvar hasRequiredChunk_tRNS;\nfunction requireChunk_tRNS() {\n if (hasRequiredChunk_tRNS) return chunk_tRNS;\n hasRequiredChunk_tRNS = 1;\n Object.defineProperty(chunk_tRNS, "__esModule", { value: true });\n chunk_tRNS.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n switch (header.colorType) {\n case 0:\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 2);\n break;\n case 2:\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 6);\n break;\n case 3:\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "PLTE");\n if (chunk.dataLength > ctx.palette.size) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid data length for color type ${header.colorType}: ${chunk.dataLength} > ${ctx.palette.size}`, chunk.offset + 4 + 4);\n }\n break;\n case 4:\n case 6:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Chunk invalid when color type has alpha (${header.colorType})`, chunk.offset + 4 + 4);\n }\n const offset = chunk.offset + 4 + 4;\n let transparency;\n switch (header.colorType) {\n case 0:\n transparency = ctx.view.getUint16(offset);\n break;\n case 2:\n transparency = [\n ctx.view.getUint16(offset),\n ctx.view.getUint16(offset + 2),\n ctx.view.getUint16(offset + 4)\n ];\n break;\n case 3:\n transparency = [];\n for (let i = 0; i < chunk.dataLength; i++) {\n transparency.push(ctx.view.getUint8(offset + i));\n }\n break;\n }\n return {\n type: "tRNS",\n transparency\n };\n }\n chunk_tRNS.parseChunk = parseChunk;\n return chunk_tRNS;\n}\nvar chunk_zTXt = {};\nvar hasRequiredChunk_zTXt;\nfunction requireChunk_zTXt() {\n if (hasRequiredChunk_zTXt) return chunk_zTXt;\n hasRequiredChunk_zTXt = 1;\n Object.defineProperty(chunk_zTXt, "__esModule", { value: true });\n chunk_zTXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false, true);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "zTXt",\n keyword,\n text: text2\n };\n }\n chunk_zTXt.parseChunk = parseChunk;\n return chunk_zTXt;\n}\nvar chunk_PLTE = {};\nvar hasRequiredChunk_PLTE;\nfunction requireChunk_PLTE() {\n if (hasRequiredChunk_PLTE) return chunk_PLTE;\n hasRequiredChunk_PLTE = 1;\n Object.defineProperty(chunk_PLTE, "__esModule", { value: true });\n chunk_PLTE.Palette = chunk_PLTE.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "bKGD");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "hIST");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "tRNS");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n let offset = chunk.offset + 4;\n if (header.colorType === 0 || header.colorType === 4) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Color type "${header.colorType}" cannot have a palette`, offset);\n }\n offset += 4;\n if (chunk.dataLength === 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "Cannot have 0 entries", offset);\n }\n if (chunk.dataLength % 3 !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Chunk length must be divisible by 3 (actual "${chunk.dataLength}")`, offset);\n }\n if (chunk.dataLength / 3 > 256) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Too many entries (${chunk.dataLength / 3} > 256)`, offset));\n }\n if (chunk.dataLength / 3 > Math.pow(2, header.bitDepth)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Too many entries for bit depth (${chunk.dataLength / 3} > 2^${header.bitDepth})`, offset));\n }\n return new Palette(ctx.view, chunk.offset + 4 + 4, chunk.dataLength);\n }\n chunk_PLTE.parseChunk = parseChunk;\n class Palette {\n constructor(_view, _paletteOffset, _length) {\n this._view = _view;\n this._paletteOffset = _paletteOffset;\n this._length = _length;\n }\n get size() {\n return this._length / 3;\n }\n getRgb(colorIndex) {\n this._checkIndex(colorIndex);\n return new Uint8Array(this._view.buffer.slice(this._view.byteOffset + this._paletteOffset + colorIndex * 3, this._view.byteOffset + this._paletteOffset + colorIndex * 3 + 3));\n }\n setRgba(data, offset, colorIndex) {\n this._checkIndex(colorIndex);\n const i = this._paletteOffset + colorIndex * 3;\n data[offset] = this._view.getUint8(i);\n data[offset + 1] = this._view.getUint8(i + 1);\n data[offset + 2] = this._view.getUint8(i + 2);\n data[offset + 3] = 255;\n }\n _checkIndex(colorIndex) {\n if (colorIndex < 0 || colorIndex * 3 > this._length - 3) {\n throw new Error(`Palette does not contain color index "${colorIndex}"`);\n }\n }\n }\n chunk_PLTE.Palette = Palette;\n return chunk_PLTE;\n}\nvar hasRequiredDecoder;\nfunction requireDecoder() {\n if (hasRequiredDecoder) return decoder;\n hasRequiredDecoder = 1;\n Object.defineProperty(decoder, "__esModule", { value: true });\n decoder.readChunk = decoder.readChunks = decoder.decodePng = decoder.verifyPngSignature = void 0;\n const array_js_1 = requireArray();\n const assert_js_1 = requireAssert$1();\n const chunk_IDAT_js_1 = requireChunk_IDAT();\n const chunk_IEND_js_1 = requireChunk_IEND();\n const chunk_IHDR_js_1 = requireChunk_IHDR();\n const crc32_js_1 = requireCrc32();\n function verifyPngSignature(ctx) {\n if (ctx.view.byteLength < 7) {\n throw new assert_js_1.DecodeError(ctx, `Not enough bytes in file for png signature (${ctx.view.byteLength})`, 0);\n }\n const isCorrect = ctx.view.getUint8(0) === 137 && ctx.view.getUint8(1) === 80 && ctx.view.getUint8(2) === 78 && ctx.view.getUint8(3) === 71 && ctx.view.getUint8(4) === 13 && ctx.view.getUint8(5) === 10 && ctx.view.getUint8(6) === 26 && ctx.view.getUint8(7) === 10;\n if (!isCorrect) {\n const actual = formatHexAssertion(Array.from(new Uint8Array(ctx.view.buffer).slice(ctx.view.byteOffset, ctx.view.byteOffset + 8)));\n const expected = formatHexAssertion([137, 80, 78, 71, 13, 10, 26, 10]);\n throw new assert_js_1.DecodeError(ctx, `Png signature is not correct (${actual} !== ${expected})`, 0);\n }\n }\n decoder.verifyPngSignature = verifyPngSignature;\n function formatHexAssertion(actual) {\n return `0x${actual.map((e) => e.toString(16).padStart(2, "0")).join("")}`;\n }\n const defaultLazyChunkTypes = Object.freeze([\n "tRNS"\n ]);\n const allLazyChunkTypes = Object.freeze([\n "bKGD",\n "cHRM",\n "eXIf",\n "gAMA",\n "hIST",\n "iCCP",\n "iTXt",\n "tIME",\n "oFFs",\n "pCAL",\n "pHYs",\n "sBIT",\n "sCAL",\n "sPLT",\n "sRGB",\n "sTER",\n "tEXt",\n "tRNS",\n "zTXt"\n ]);\n function getChunkDecoder(type) {\n switch (type) {\n case "bKGD":\n return Promise.resolve().then(() => requireChunk_bKGD());\n case "cHRM":\n return Promise.resolve().then(() => requireChunk_cHRM());\n case "eXIf":\n return Promise.resolve().then(() => requireChunk_eXIf());\n case "gAMA":\n return Promise.resolve().then(() => requireChunk_gAMA());\n case "hIST":\n return Promise.resolve().then(() => requireChunk_hIST());\n case "iCCP":\n return Promise.resolve().then(() => requireChunk_iCCP());\n case "iTXt":\n return Promise.resolve().then(() => requireChunk_iTXt());\n case "tIME":\n return Promise.resolve().then(() => requireChunk_tIME());\n case "oFFs":\n return Promise.resolve().then(() => requireChunk_oFFs());\n case "pCAL":\n return Promise.resolve().then(() => requireChunk_pCAL());\n case "pHYs":\n return Promise.resolve().then(() => requireChunk_pHYs());\n case "sBIT":\n return Promise.resolve().then(() => requireChunk_sBIT());\n case "sCAL":\n return Promise.resolve().then(() => requireChunk_sCAL());\n case "sPLT":\n return Promise.resolve().then(() => requireChunk_sPLT());\n case "sRGB":\n return Promise.resolve().then(() => requireChunk_sRGB());\n case "sTER":\n return Promise.resolve().then(() => requireChunk_sTER());\n case "tEXt":\n return Promise.resolve().then(() => requireChunk_tEXt());\n case "tRNS":\n return Promise.resolve().then(() => requireChunk_tRNS());\n case "zTXt":\n return Promise.resolve().then(() => requireChunk_zTXt());\n default:\n throw new Error(`Could not get decoder for chunk type "${type}"`);\n }\n }\n async function decodePng(data, options = {}) {\n const initialCtx = {\n view: new DataView(data.buffer, data.byteOffset, data.byteLength),\n image: void 0,\n palette: void 0,\n metadata: [],\n parsedChunks: /* @__PURE__ */ new Set(),\n warnings: [],\n info: [],\n options\n };\n verifyPngSignature(initialCtx);\n const chunks = readChunks(initialCtx);\n initialCtx.rawChunks = chunks;\n const header = (0, chunk_IHDR_js_1.parseChunk)(initialCtx, chunks[0]);\n const ctx = {\n ...initialCtx,\n header\n };\n let parseChunkTypes;\n if (options && options.parseChunkTypes) {\n if (options.parseChunkTypes === "*") {\n parseChunkTypes = allLazyChunkTypes;\n } else {\n parseChunkTypes = defaultLazyChunkTypes.concat(options.parseChunkTypes);\n }\n } else {\n parseChunkTypes = defaultLazyChunkTypes;\n }\n for (let i = 1; i < chunks.length; i++) {\n const chunk = chunks[i];\n switch (chunk.type) {\n case "IHDR":\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Multiple IHDR chunks not allowed`, chunk.offset + 4));\n break;\n case "IDAT": {\n const dataChunks = [chunk];\n while (chunks.length > i + 1 && chunks[i + 1].type === "IDAT") {\n dataChunks.push(chunks[++i]);\n }\n ctx.image = {\n width: header.width,\n height: header.height,\n data: (0, chunk_IDAT_js_1.parseChunk)(ctx, header, dataChunks)\n };\n break;\n }\n case "PLTE":\n ctx.palette = (await Promise.resolve().then(() => requireChunk_PLTE())).parseChunk(ctx, header, chunk);\n break;\n case "IEND":\n (0, chunk_IEND_js_1.parseChunk)(ctx, header, chunk);\n break;\n default:\n if (parseChunkTypes.includes(chunk.type)) {\n try {\n ctx.metadata.push((await getChunkDecoder(chunk.type)).parseChunk(ctx, header, chunk));\n } catch (e) {\n if (e instanceof assert_js_1.DecodeWarning) {\n (0, assert_js_1.handleWarning)(ctx, e);\n } else {\n throw e;\n }\n }\n } else {\n if (!allLazyChunkTypes.includes(chunk.type)) {\n if (!chunk.isAncillary) {\n throw new assert_js_1.DecodeError(ctx, `Unrecognized critical chunk type "${chunk.type}"`, chunk.offset + 4);\n } else {\n ctx.info.push(`Unrecognized chunk type "${chunk.type}"`);\n }\n }\n }\n break;\n }\n ctx.parsedChunks.add(chunk.type);\n }\n if (!ctx.image) {\n throw new assert_js_1.DecodeError(ctx, "Failed to decode, no IDAT chunk", 0);\n }\n if (options && options.force32 && ctx.image.data.BYTES_PER_ELEMENT === 2) {\n ctx.image.data = (0, array_js_1.convert16BitTo8BitData)(ctx.image.data);\n }\n return {\n image: ctx.image,\n details: {\n width: header.width,\n height: header.height,\n bitDepth: header.bitDepth,\n colorType: header.colorType,\n interlaceMethod: header.interlaceMethod\n },\n palette: ctx.palette,\n metadata: ctx.metadata,\n rawChunks: chunks,\n warnings: ctx.warnings,\n info: ctx.info\n };\n }\n decoder.decodePng = decodePng;\n function readChunks(ctx) {\n const chunks = [];\n let offset = 8;\n let hasData = false;\n let hasEnd = false;\n let chunk;\n while (offset < ctx.view.byteLength) {\n try {\n chunk = readChunk(ctx, offset);\n } catch (e) {\n if (!hasEnd || !(e instanceof Error)) {\n throw e;\n }\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning("Could not parse chunk after IEND: " + e.message, offset));\n }\n offset += 4 + 4 + chunk.dataLength + 4;\n chunks.push(chunk);\n hasData || (hasData = chunk.type === "IDAT");\n hasEnd || (hasEnd = chunk.type === "IEND");\n }\n if (chunks[0].type !== "IHDR") {\n throw new assert_js_1.DecodeError(ctx, `First chunk is not IHDR`, chunks[0].offset + 4);\n }\n if (chunks[chunks.length - 1].type !== "IEND") {\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning("Last chunk is not IEND", chunks[chunks.length - 1].offset + 4));\n }\n if (!hasData) {\n throw new assert_js_1.DecodeError(ctx, "No IDAT chunk", 0);\n }\n return chunks;\n }\n decoder.readChunks = readChunks;\n function readChunk(ctx, offset) {\n if (ctx.view.byteLength < offset + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk length`, offset);\n }\n const dataLength = ctx.view.getUint32(offset);\n if (ctx.view.byteLength < offset + 4 + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk type`, offset);\n }\n const type = String.fromCharCode(ctx.view.getUint8(offset + 4), ctx.view.getUint8(offset + 5), ctx.view.getUint8(offset + 6), ctx.view.getUint8(offset + 7));\n if (ctx.view.byteLength < offset + 4 + 4 + dataLength + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk "${type}"`, offset);\n }\n const actualCrc = ctx.view.getUint32(offset + 4 + 4 + dataLength) >>> 0;\n const expectedCrc = (0, crc32_js_1.crc32)(ctx.view, offset + 4, 4 + dataLength);\n if (actualCrc !== expectedCrc) {\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning(`CRC for chunk "${type}" at offset 0x${offset.toString(16)} doesn\'t match (0x${actualCrc.toString(16)} !== 0x${expectedCrc.toString(16)})`, offset));\n }\n return {\n offset,\n type,\n dataLength,\n isAncillary: isCharLowercase(type, 0),\n isPrivate: isCharLowercase(type, 1),\n isSafeToCopy: isCharLowercase(type, 3)\n };\n }\n decoder.readChunk = readChunk;\n function isCharLowercase(text2, index) {\n return !!(text2.charCodeAt(index) & 32);\n }\n return decoder;\n}\nvar encoder = {};\nvar byteStream = {};\nvar hasRequiredByteStream;\nfunction requireByteStream() {\n if (hasRequiredByteStream) return byteStream;\n hasRequiredByteStream = 1;\n Object.defineProperty(byteStream, "__esModule", { value: true });\n byteStream.ByteStream = void 0;\n class ByteStream {\n constructor(length) {\n this.offset = 0;\n this.array = new Uint8Array(length);\n this.view = new DataView(this.array.buffer, this.array.byteOffset, this.array.byteLength);\n }\n writeUint8(value) {\n this.view.setUint8(this.offset, value);\n this.offset += 1;\n }\n writeUint16(value) {\n this.view.setUint16(this.offset, value);\n this.offset += 2;\n }\n writeUint32(value) {\n this.view.setUint32(this.offset, value);\n this.offset += 4;\n }\n writeArray(values) {\n this.array.set(values, this.array.byteOffset + this.offset);\n this.offset += values.length;\n }\n assertAtEnd() {\n if (this.offset !== this.array.length) {\n throw new Error("Writing finished before expected length of stream");\n }\n }\n }\n byteStream.ByteStream = ByteStream;\n return byteStream;\n}\nvar IDAT_encode = {};\nvar write = {};\nvar hasRequiredWrite;\nfunction requireWrite() {\n if (hasRequiredWrite) return write;\n hasRequiredWrite = 1;\n Object.defineProperty(write, "__esModule", { value: true });\n write.writeChunkDataFn = write.writeChunk = write.writeChunkType = void 0;\n const byteStream_js_1 = requireByteStream();\n const crc32_js_1 = requireCrc32();\n function writeChunkType(stream, type) {\n stream.writeUint8(type.charCodeAt(0));\n stream.writeUint8(type.charCodeAt(1));\n stream.writeUint8(type.charCodeAt(2));\n stream.writeUint8(type.charCodeAt(3));\n }\n write.writeChunkType = writeChunkType;\n function writeChunk(type, data) {\n const stream = new byteStream_js_1.ByteStream(4 + 4 + data.length + 4);\n stream.writeUint32(data.length);\n if (type.length !== 4) {\n throw new Error(`Cannot encode a chunk type of length ${type.length}`);\n }\n writeChunkType(stream, type);\n stream.writeArray(data);\n stream.writeUint32((0, crc32_js_1.crc32)(stream.view, 4, 4 + data.length));\n stream.assertAtEnd();\n return stream.array;\n }\n write.writeChunk = writeChunk;\n function writeChunkDataFn(type, dataLength, writeDataFn) {\n const stream = new byteStream_js_1.ByteStream(4 + 4 + dataLength + 4);\n stream.writeUint32(dataLength);\n if (type.length !== 4) {\n throw new Error(`Cannot encode a chunk type of length ${type.length}`);\n }\n writeChunkType(stream, type);\n writeDataFn(stream);\n stream.writeUint32((0, crc32_js_1.crc32)(stream.view, 4, 4 + dataLength));\n stream.assertAtEnd();\n return stream.array;\n }\n write.writeChunkDataFn = writeChunkDataFn;\n return write;\n}\nvar hasRequiredIDAT_encode;\nfunction requireIDAT_encode() {\n if (hasRequiredIDAT_encode) return IDAT_encode;\n hasRequiredIDAT_encode = 1;\n Object.defineProperty(IDAT_encode, "__esModule", { value: true });\n IDAT_encode.encodeChunk = void 0;\n const pako2 = requirePako();\n const byteStream_js_1 = requireByteStream();\n const paeth_js_1 = requirePaeth();\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n const dataStreamLength = calculateDataLength(ctx, image);\n const stream = new byteStream_js_1.ByteStream(dataStreamLength);\n writeUncompressedData(ctx, image, stream);\n const compressed = pako2.deflate(stream.array);\n const chunkIDAT = (0, write_js_1.writeChunk)("IDAT", compressed);\n return chunkIDAT;\n }\n IDAT_encode.encodeChunk = encodeChunk;\n function calculateDataLength(ctx, image) {\n if (ctx.bitDepth < 8) {\n throw new Error("Only bit depth 8 and 16 is supported currently");\n }\n if (image.data.BYTES_PER_ELEMENT === 2 && ctx.bitDepth === 8) {\n throw new Error("16 to 8 bit conversion isn\'t supported yet");\n }\n if (ctx.interlaceMethod !== 0) {\n throw new Error("Only interlace method 0 is supported currently");\n }\n let channels;\n switch (ctx.colorType) {\n case 0:\n channels = 1;\n break;\n case 2:\n channels = 3;\n break;\n case 3:\n channels = 1;\n break;\n case 4:\n channels = 2;\n break;\n case 6:\n channels = 4;\n break;\n }\n const bytesPerChannel = ctx.bitDepth === 16 ? 2 : 1;\n const bytesPerPixel = channels * bytesPerChannel;\n const bytesPerLine = 1 + bytesPerPixel * image.width;\n const bytesAllLines = bytesPerLine * image.height;\n return bytesAllLines;\n }\n function writeUncompressedData(ctx, image, stream) {\n let i = 0, x = 0, y = 0;\n if (ctx.colorType === 3) {\n if (!ctx.palette) {\n throw new Error("Cannot encode indexed file without palette");\n }\n if (image.data.BYTES_PER_ELEMENT === 2) {\n throw new Error("Cannot encode indexed file from 16-bit image");\n }\n for (; y < image.height; y++) {\n stream.writeUint8(0);\n for (x = 0; x < image.width; x++) {\n stream.writeUint8(ctx.palette.get(image.data[i] << 24 | image.data[i + 1] << 16 | image.data[i + 2] << 8 | image.data[i + 3]));\n i += 4;\n }\n }\n return;\n }\n let filterPattern;\n if (ctx.options.filterPattern) {\n if (ctx.options.filterPattern.length === 0) {\n throw new Error("Filter pattern with 0 entries");\n }\n filterPattern = ctx.options.filterPattern;\n }\n const bpp = 4 * image.data.BYTES_PER_ELEMENT;\n const filterFns = [];\n for (const filterType of [0, 1, 2, 3, 4]) {\n filterFns[filterType] = buildFilterFunction(bpp, bpp * image.width, filterType);\n }\n const channelsToWrite = getChannelsToWrite(ctx.colorType);\n for (; y < image.height; y++) {\n const filterType = filterPattern ? filterPattern[y % filterPattern.length] : pickFilterType(ctx.colorType, image, y * image.width * 4, filterFns);\n const dataUint8 = new Uint8Array(image.data.buffer, image.data.byteOffset, image.data.byteLength);\n stream.writeUint8(filterType);\n let byte = 0, c = 0;\n for (x = 0; x < image.width; x++) {\n for (c of channelsToWrite) {\n for (byte = image.data.BYTES_PER_ELEMENT - 1; byte >= 0; byte--) {\n stream.writeUint8(filterFns[filterType](dataUint8, (i + c) * image.data.BYTES_PER_ELEMENT + byte, x === 0));\n }\n }\n i += 4;\n }\n }\n }\n function pickFilterType(colorType, image, lineIndex, filterFns) {\n const filterSums = [];\n 4 * image.data.BYTES_PER_ELEMENT;\n for (const filterType of [0, 1, 2, 3, 4]) {\n let sum = 0;\n const channelsToWrite = getChannelsToWrite(colorType);\n const dataUint8 = new Uint8Array(image.data.buffer, image.data.byteOffset, image.data.byteLength);\n let c = 0, byte = 0;\n for (let i = lineIndex; i < lineIndex + image.width * 4; i += 4) {\n for (c of channelsToWrite) {\n for (byte = image.data.BYTES_PER_ELEMENT - 1; byte >= 0; byte--) {\n sum += filterFns[filterType](dataUint8, (i + c) * image.data.BYTES_PER_ELEMENT + byte, i === lineIndex);\n }\n }\n }\n filterSums[filterType] = sum;\n }\n let lowestFilterType = 0;\n let lowestSum = filterSums[0];\n for (const filterType of [1, 2, 3, 4]) {\n if (filterSums[filterType] < lowestSum) {\n lowestFilterType = filterType;\n lowestSum = filterSums[filterType];\n }\n }\n return lowestFilterType;\n }\n function buildFilterFunction(bpp, bpl, filterType) {\n let ai = 0, bi = 0, ci = 0;\n switch (filterType) {\n case 0:\n return (filt, filtX) => filt[filtX];\n case 1:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n return (filt[filtX] - (ai < 0 ? 0 : filt[filtX - bpp]) + 256) % 256;\n };\n case 2:\n return (filt, filtX) => {\n bi = filtX - bpl;\n return (filt[filtX] - (bi < 0 ? 0 : filt[bi]) + 256) % 256;\n };\n case 3:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n bi = filtX - bpl;\n return (filt[filtX] - Math.floor(((ai < 0 ? 0 : filt[ai]) + (bi < 0 ? 0 : filt[bi])) / 2) + 256) % 256;\n };\n case 4:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n bi = filtX - bpl;\n ci = isFirstInLine ? -1 : filtX - bpp - bpl;\n return (filt[filtX] - (0, paeth_js_1.paethPredicator)(ai < 0 ? 0 : filt[ai], bi < 0 ? 0 : filt[bi], ci < 0 ? 0 : filt[ci]) + 256) % 256;\n };\n }\n }\n function getChannelsToWrite(colorType) {\n switch (colorType) {\n case 0:\n return [0];\n case 2:\n return [0, 1, 2];\n case 4:\n return [0, 3];\n case 6:\n return [0, 1, 2, 3];\n }\n }\n return IDAT_encode;\n}\nvar IEND_encode = {};\nvar hasRequiredIEND_encode;\nfunction requireIEND_encode() {\n if (hasRequiredIEND_encode) return IEND_encode;\n hasRequiredIEND_encode = 1;\n Object.defineProperty(IEND_encode, "__esModule", { value: true });\n IEND_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk() {\n return (0, write_js_1.writeChunk)("IEND", new Uint8Array(0));\n }\n IEND_encode.encodeChunk = encodeChunk;\n return IEND_encode;\n}\nvar IHDR_encode = {};\nvar hasRequiredIHDR_encode;\nfunction requireIHDR_encode() {\n if (hasRequiredIHDR_encode) return IHDR_encode;\n hasRequiredIHDR_encode = 1;\n Object.defineProperty(IHDR_encode, "__esModule", { value: true });\n IHDR_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n if (image.width <= 0 || image.height <= 0) {\n throw new Error(`Invalid dimensions ${image.width}x${image.height}`);\n }\n return (0, write_js_1.writeChunkDataFn)("IHDR", 13, (stream) => {\n stream.writeUint32(image.width);\n stream.writeUint32(image.height);\n stream.writeUint8(ctx.bitDepth);\n stream.writeUint8(ctx.colorType);\n stream.writeUint8(0);\n stream.writeUint8(0);\n stream.writeUint8(ctx.interlaceMethod);\n });\n }\n IHDR_encode.encodeChunk = encodeChunk;\n return IHDR_encode;\n}\nvar tRNS_encode = {};\nvar hasRequiredTRNS_encode;\nfunction requireTRNS_encode() {\n if (hasRequiredTRNS_encode) return tRNS_encode;\n hasRequiredTRNS_encode = 1;\n Object.defineProperty(tRNS_encode, "__esModule", { value: true });\n tRNS_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n switch (ctx.colorType) {\n case 0: {\n if (ctx.firstTransparentColor === void 0) {\n throw new Error("Cannot write tRNS for grayscale without any transparent colors");\n }\n const firstTransparentColor = ctx.firstTransparentColor;\n return (0, write_js_1.writeChunkDataFn)("tRNS", 2, (stream) => {\n if (image.data.BYTES_PER_ELEMENT === 2) {\n stream.writeUint16(firstTransparentColor >> 48 & 65535);\n } else {\n stream.writeUint16(firstTransparentColor >> 24 & 255);\n }\n });\n }\n case 3: {\n if (!ctx.palette) {\n throw new Error("Cannot encode tRNS chunk for indexed image without palette");\n }\n return (0, write_js_1.writeChunkDataFn)("tRNS", ctx.palette.size, (stream) => {\n for (const color of ctx.colorSet) {\n stream.writeUint8(color & 255);\n }\n });\n }\n case 2: {\n if (ctx.firstTransparentColor === void 0) {\n throw new Error("Cannot write tRNS for True color without any transparent colors");\n }\n const firstTransparentColor = ctx.firstTransparentColor;\n return (0, write_js_1.writeChunkDataFn)("tRNS", 6, (stream) => {\n if (image.data.BYTES_PER_ELEMENT === 2) {\n stream.writeUint16(firstTransparentColor >> 48 & 65535);\n stream.writeUint16(firstTransparentColor >> 32 & 65535);\n stream.writeUint16(firstTransparentColor >> 16 & 65535);\n } else {\n stream.writeUint16(firstTransparentColor >> 24 & 255);\n stream.writeUint16(firstTransparentColor >> 16 & 255);\n stream.writeUint16(firstTransparentColor >> 8 & 255);\n }\n });\n }\n default:\n throw new Error(`Cannot encode tRNS chunk for color type "${ctx.colorType}"`);\n }\n }\n tRNS_encode.encodeChunk = encodeChunk;\n return tRNS_encode;\n}\nvar PLTE_encode = {};\nvar hasRequiredPLTE_encode;\nfunction requirePLTE_encode() {\n if (hasRequiredPLTE_encode) return PLTE_encode;\n hasRequiredPLTE_encode = 1;\n Object.defineProperty(PLTE_encode, "__esModule", { value: true });\n PLTE_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n if (ctx.bitDepth === 16 || image.data.BYTES_PER_ELEMENT === 2) {\n throw new Error("Cannot encode 16 bit images using indexed color type");\n }\n if (ctx.colorSet.size > Math.pow(2, ctx.bitDepth)) {\n throw new Error(`Too many colors ${ctx.colorSet.size} to encode into indexed image (2^${ctx.bitDepth} = ${Math.pow(2, ctx.bitDepth)})`);\n }\n const chunkData = (0, write_js_1.writeChunkDataFn)("PLTE", ctx.colorSet.size * 3, (stream) => {\n for (const color of ctx.colorSet.values()) {\n stream.writeUint8(color >> 24 & 255);\n stream.writeUint8(color >> 16 & 255);\n stream.writeUint8(color >> 8 & 255);\n }\n });\n const palette = /* @__PURE__ */ new Map();\n for (const color of ctx.colorSet.values()) {\n palette.set(color, palette.size);\n }\n return {\n chunkData,\n palette\n };\n }\n PLTE_encode.encodeChunk = encodeChunk;\n return PLTE_encode;\n}\nvar tEXt_encode = {};\nvar hasRequiredTEXt_encode;\nfunction requireTEXt_encode() {\n if (hasRequiredTEXt_encode) return tEXt_encode;\n hasRequiredTEXt_encode = 1;\n Object.defineProperty(tEXt_encode, "__esModule", { value: true });\n tEXt_encode.encodeChunk = void 0;\n const assert_js_1 = requireAssert();\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image, keyword, text2) {\n if (keyword.length === 0 || keyword.length > 79) {\n throw new assert_js_1.EncodeError(`tEXt: Invalid keyword length: 0 < ${keyword.length} < 80`, 0);\n }\n const dataLength = keyword.length + 1 + text2.length;\n return (0, write_js_1.writeChunkDataFn)("tEXt", dataLength, (stream) => {\n let i = 0;\n for (; i < keyword.length; i++) {\n stream.writeUint8(keyword.charCodeAt(i));\n }\n stream.writeUint8(0);\n for (i = 0; i < text2.length; i++) {\n stream.writeUint8(text2.charCodeAt(i));\n }\n });\n }\n tEXt_encode.encodeChunk = encodeChunk;\n return tEXt_encode;\n}\nvar hasRequiredEncoder;\nfunction requireEncoder() {\n if (hasRequiredEncoder) return encoder;\n hasRequiredEncoder = 1;\n Object.defineProperty(encoder, "__esModule", { value: true });\n encoder.encodePng = void 0;\n const byteStream_js_1 = requireByteStream();\n const IDAT_encode_js_1 = requireIDAT_encode();\n const IEND_encode_js_1 = requireIEND_encode();\n const IHDR_encode_js_1 = requireIHDR_encode();\n const assert_js_1 = requireAssert();\n function getChunkDecoder(type) {\n switch (type) {\n case "tRNS":\n return Promise.resolve().then(() => requireTRNS_encode());\n default:\n throw new Error(`Could not get encoder for chunk type "${type}"`);\n }\n }\n async function encodePng(image, options = {}) {\n if (image.data.length !== image.width * image.height * 4) {\n throw new assert_js_1.EncodeError(`Provided image data length (${image.data.length}) is not expected length (${image.width * image.height * 4})`, Math.min(image.data.length, image.width * image.height * 4) - 1);\n }\n const sections = [];\n sections.push(writePngSignature());\n const ctx = analyze(image, options);\n sections.push((0, IHDR_encode_js_1.encodeChunk)(ctx, image));\n if (ctx.colorType === 3) {\n const result2 = (await Promise.resolve().then(() => requirePLTE_encode())).encodeChunk(ctx, image);\n ctx.palette = result2.palette;\n sections.push(result2.chunkData);\n }\n if (ctx.useTransparencyChunk) {\n sections.push((await getChunkDecoder("tRNS")).encodeChunk(ctx, image));\n }\n sections.push((0, IDAT_encode_js_1.encodeChunk)(ctx, image));\n if (options?.ancillaryChunks === void 0) {\n sections.push((await Promise.resolve().then(() => requireTEXt_encode())).encodeChunk(ctx, image, "Software", "@lunapaint/png-codec"));\n } else {\n for (const chunk of options.ancillaryChunks) {\n switch (chunk.type) {\n case "tEXt":\n sections.push((await Promise.resolve().then(() => requireTEXt_encode())).encodeChunk(ctx, image, chunk.keyword, chunk.text));\n break;\n default:\n throw new Error(`Cannot encode chunk type "${chunk.type}"`);\n }\n }\n }\n sections.push((0, IEND_encode_js_1.encodeChunk)());\n const totalLength = sections.reduce((p, c) => p + c.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n for (const s of sections) {\n result.set(s, offset);\n offset += s.length;\n }\n return {\n data: result,\n warnings: ctx.warnings,\n info: ctx.info\n };\n }\n encoder.encodePng = encodePng;\n function writePngSignature() {\n const stream = new byteStream_js_1.ByteStream(8);\n stream.writeUint8(137);\n stream.writeUint8(80);\n stream.writeUint8(78);\n stream.writeUint8(71);\n stream.writeUint8(13);\n stream.writeUint8(10);\n stream.writeUint8(26);\n stream.writeUint8(10);\n stream.assertAtEnd();\n return stream.array;\n }\n function analyze(image, options = {}) {\n const warnings = [];\n const info = [];\n const pixelCount = image.width * image.height;\n const indexCount = pixelCount * 4;\n const colorSet = /* @__PURE__ */ new Set();\n const transparentColorSet = /* @__PURE__ */ new Set();\n let rgbaId = 0;\n if (image.data.BYTES_PER_ELEMENT === 2) {\n for (let i = 0; i < indexCount; i += 4) {\n rgbaId = image.data[i] << 48 | image.data[i + 1] << 32 | image.data[i + 2] << 16 | image.data[i + 3];\n if (image.data[i + 3] < 65535) {\n transparentColorSet.add(rgbaId);\n }\n colorSet.add(rgbaId);\n }\n } else {\n for (let i = 0; i < indexCount; i += 4) {\n rgbaId = image.data[i] << 24 | image.data[i + 1] << 16 | image.data[i + 2] << 8 | image.data[i + 3];\n if (image.data[i + 3] < 255) {\n transparentColorSet.add(rgbaId);\n }\n colorSet.add(rgbaId);\n }\n }\n let colorType = options.colorType;\n if (colorType === void 0) {\n if (colorSet.size > 256 || image.data.BYTES_PER_ELEMENT === 2) {\n colorType = 2;\n } else {\n colorType = 3;\n }\n }\n let useTransparencyChunk;\n switch (colorType) {\n case 0:\n case 2:\n useTransparencyChunk = transparentColorSet.size === 1;\n if (!useTransparencyChunk && transparentColorSet.size > 1) {\n colorType = colorType === 2 ? 6 : 4;\n if (options.colorType === 2) {\n (0, assert_js_1.handleWarning)({ options, warnings }, new assert_js_1.EncodeWarning(`Cannot encode image as color type Truecolor as it contains ${transparentColorSet.size} transparent colors`, 0));\n }\n }\n break;\n case 3:\n useTransparencyChunk = transparentColorSet.size > 0;\n break;\n default:\n useTransparencyChunk = false;\n }\n if (options.colorType === void 0) {\n info.push(`Using color type ${colorType}`);\n }\n return {\n colorType,\n bitDepth: image.data.BYTES_PER_ELEMENT === 2 ? 16 : 8,\n interlaceMethod: 0,\n colorSet,\n transparentColorCount: transparentColorSet.size,\n firstTransparentColor: transparentColorSet.size > 0 ? transparentColorSet.values().next().value : void 0,\n useTransparencyChunk,\n options,\n warnings,\n info\n };\n }\n return encoder;\n}\nvar hasRequiredPng;\nfunction requirePng() {\n if (hasRequiredPng) return png;\n hasRequiredPng = 1;\n (function(exports) {\n Object.defineProperty(exports, "__esModule", { value: true });\n exports.encodePng = exports.decodePng = exports.EncodeWarning = exports.EncodeError = exports.DecodeWarning = exports.DecodeError = void 0;\n var assert_js_1 = requireAssert$1();\n Object.defineProperty(exports, "DecodeError", { enumerable: true, get: function() {\n return assert_js_1.DecodeError;\n } });\n Object.defineProperty(exports, "DecodeWarning", { enumerable: true, get: function() {\n return assert_js_1.DecodeWarning;\n } });\n var assert_js_2 = requireAssert();\n Object.defineProperty(exports, "EncodeError", { enumerable: true, get: function() {\n return assert_js_2.EncodeError;\n } });\n Object.defineProperty(exports, "EncodeWarning", { enumerable: true, get: function() {\n return assert_js_2.EncodeWarning;\n } });\n async function decodePng(data, options) {\n return (await Promise.resolve().then(() => requireDecoder())).decodePng(data, options);\n }\n exports.decodePng = decodePng;\n async function encodePng(data, options) {\n return (await Promise.resolve().then(() => requireEncoder())).encodePng(data, options);\n }\n exports.encodePng = encodePng;\n })(png);\n return png;\n}\nvar pngExports = requirePng();\nfunction unpack8to4(value) {\n const high = value >> 4 & 15;\n const low = value & 15;\n return [high, low];\n}\nfunction convertQuaternion(w, x, y, z) {\n let qw = w;\n let qx = x;\n let qy = y;\n let qz = z;\n if (w < 0) {\n qx = -x;\n qy = -y;\n qz = -z;\n qw = -w;\n }\n const theta = Math.acos(qw) * 2;\n const halfTheta = theta * 0.5;\n const s = Math.sin(halfTheta);\n if (Math.abs(s) < 1e-6) {\n qx = 1;\n qy = 0;\n qz = 0;\n } else {\n qx /= s;\n qy /= s;\n qz /= s;\n }\n const sum = Math.abs(qx) + Math.abs(qy) + Math.abs(qz);\n let px = qx / sum;\n let py = qy / sum;\n if (qz < 0) {\n const previousX = px;\n px = (1 - Math.abs(py)) * (px >= 0 ? 1 : -1);\n py = (1 - Math.abs(previousX)) * (py >= 0 ? 1 : -1);\n }\n const u = Math.min(1, Math.max(0, px * 0.5 + 0.5));\n const v = Math.min(1, Math.max(0, py * 0.5 + 0.5));\n const t = Math.min(1, Math.max(0, theta / Math.PI));\n return {\n u,\n v,\n w: t\n };\n}\nconst worker = self;\nconst ROW_LENGTH_TAVIO = 2 * 3 + 3 + 4 + 3 + 1 + 1;\nconst SPHERICAL_HARMONICS_BASE_ELEMENT = 15 * 3;\nconst TEXTURE_WIDTH_BASE = 1024;\nconst INV_255 = 1 / 255;\nconst INFINITY_F16 = 31744;\nlet currentBuffer = null;\nlet currentIndexBuffer = null;\nlet currentOrderBuffer = null;\nlet currentGeneralBuffer = null;\nlet currentSHBuffer = null;\nlet currentVertexCount = 0;\nlet usingSharedArrayBuffer = false;\nlet usingSphericalHarmonics = false;\nlet currentVertexOffset = 0;\nlet depthUint32;\nconst bucket16 = () => {\n const readback = new Uint16Array(currentOrderBuffer);\n let depthIndex;\n if (usingSharedArrayBuffer === true) {\n depthIndex = new Uint32Array(currentIndexBuffer);\n } else {\n depthIndex = new Uint32Array(currentVertexCount);\n }\n const startTime = Date.now();\n if (depthUint32 == null) {\n depthUint32 = new Uint32Array(INFINITY_F16 + 1);\n }\n depthUint32.fill(0);\n for (let i = 0; i < currentVertexCount; ++i) {\n const depth = readback[i];\n if (depth < INFINITY_F16) {\n depthUint32[depth] += 1;\n }\n }\n let active = 0;\n for (let j = INFINITY_F16 - 1; j >= 0; --j) {\n const next = active + depthUint32[j];\n depthUint32[j] = active;\n active = next;\n }\n for (let k = 0; k < currentVertexCount; ++k) {\n const depth = readback[k];\n if (depth < INFINITY_F16) {\n depthIndex[depthUint32[depth]] = k;\n depthUint32[depth] += 1;\n }\n }\n const time = Date.now() - startTime;\n const updateIndex = true;\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({ updateIndex, currentVertexCount, time });\n } else {\n worker.postMessage({\n updateIndex,\n currentVertexCount,\n time,\n depthIndex\n }, [depthIndex.buffer]);\n }\n};\nconst generateTexture = () => {\n if (currentBuffer == null) {\n return;\n }\n const currentBufferFloatView = new Float16Array(currentBuffer);\n const currentBufferUintView = new Uint8Array(currentBuffer);\n const currentGeneralUintView = new Uint8Array(currentGeneralBuffer);\n const textureWidth = TEXTURE_WIDTH_BASE;\n const textureHeight = Math.ceil(currentVertexCount / textureWidth);\n const textureData = new Uint32Array(textureWidth * textureHeight * 4);\n const textureDataFloatView = new Float16Array(textureData.buffer);\n const textureDataUintView = new Uint8Array(textureData.buffer);\n const halfWidth = TEXTURE_WIDTH_BASE;\n const texelCount = halfWidth * textureHeight;\n let compressed0 = null;\n let compressed1 = null;\n let compressed2 = null;\n let compressed3 = null;\n const floatView = new Float32Array(1);\n const uintView = new Uint32Array(floatView.buffer);\n if (usingSphericalHarmonics === true) {\n compressed0 = new Uint32Array(texelCount * 4);\n compressed1 = new Uint32Array(texelCount * 4);\n compressed2 = new Uint32Array(texelCount * 4);\n compressed3 = new Uint32Array(texelCount * 4);\n }\n let shBuffer = null;\n if (usingSphericalHarmonics === true) {\n shBuffer = new Float32Array(currentSHBuffer);\n }\n const c = new Array(SPHERICAL_HARMONICS_BASE_ELEMENT);\n const tE = (1 << 11) - 1;\n const tT = (1 << 10) - 1;\n for (let i = 0; i < currentVertexCount; ++i) {\n const readFloatIndex = 9 * i;\n const readIntIndex = 18 * i;\n const x = currentBufferFloatView[readFloatIndex + 0];\n const y = currentBufferFloatView[readFloatIndex + 1];\n const z = currentBufferFloatView[readFloatIndex + 2];\n const scaleIndex = readIntIndex + 6;\n const sx = currentBufferUintView[scaleIndex + 0];\n const sy = currentBufferUintView[scaleIndex + 1];\n const sz = currentBufferUintView[scaleIndex + 2];\n const colorIndex = scaleIndex + 3;\n const R = currentBufferUintView[colorIndex + 0];\n const G = currentBufferUintView[colorIndex + 1];\n const B = currentBufferUintView[colorIndex + 2];\n const A = currentBufferUintView[colorIndex + 3];\n const rotationIndex = colorIndex + 4;\n const ru = currentBufferUintView[rotationIndex + 0];\n const rv = currentBufferUintView[rotationIndex + 1];\n const rw = currentBufferUintView[rotationIndex + 2];\n const alphaIndex = rotationIndex + 3;\n const a = currentBufferUintView[alphaIndex];\n const writeFloatIndex = 8 * i;\n const writeIntIndex = 16 * i;\n const writeGeneralUintIndex = 4 * i;\n textureDataFloatView[writeFloatIndex + 0] = x;\n textureDataFloatView[writeFloatIndex + 1] = y;\n textureDataFloatView[writeFloatIndex + 2] = z;\n textureDataUintView[writeIntIndex + 6 + 0] = ru;\n textureDataUintView[writeIntIndex + 6 + 1] = rv;\n textureDataUintView[writeIntIndex + 6 + 2] = sx;\n textureDataUintView[writeIntIndex + 6 + 3] = sy;\n textureDataUintView[writeIntIndex + 6 + 4] = sz;\n textureDataUintView[writeIntIndex + 6 + 5] = rw;\n textureDataUintView[writeIntIndex + 6 + 6] = R;\n textureDataUintView[writeIntIndex + 6 + 7] = G;\n textureDataUintView[writeIntIndex + 6 + 8] = B;\n textureDataUintView[writeIntIndex + 6 + 9] = A;\n currentGeneralUintView[writeGeneralUintIndex + 2] = a;\n if (usingSphericalHarmonics === true) {\n const i4 = i * 4;\n const is = i * SPHERICAL_HARMONICS_BASE_ELEMENT;\n let max = 0;\n for (let j = 0; j < SPHERICAL_HARMONICS_BASE_ELEMENT; ++j) {\n max = Math.max(\n max,\n Math.abs(shBuffer[is + j])\n );\n }\n if (max > 0) {\n c.fill(0);\n for (let k = 0, l = SPHERICAL_HARMONICS_BASE_ELEMENT / 3; k < l; ++k) {\n const k3 = k * 3;\n const nr = Math.floor(\n (shBuffer[is + k3] / max * 0.5 + 0.5) * tE + 0.5\n );\n const ng = Math.floor(\n (shBuffer[is + k3 + 1] / max * 0.5 + 0.5) * tT + 0.5\n );\n const nb = Math.floor(\n (shBuffer[is + k3 + 2] / max * 0.5 + 0.5) * tE + 0.5\n );\n c[k3 + 0] = Math.max(Math.min(tE, nr), 0);\n c[k3 + 1] = Math.max(Math.min(tT, ng), 0);\n c[k3 + 2] = Math.max(Math.min(tE, nb), 0);\n }\n floatView[0] = max;\n compressed0[i4] = c[0] << 21 | c[1] << 11 | c[2];\n compressed0[i4 + 1] = c[3] << 21 | c[4] << 11 | c[5];\n compressed0[i4 + 2] = c[6] << 21 | c[7] << 11 | c[8];\n compressed0[i4 + 3] = c[9] << 21 | c[10] << 11 | c[11];\n compressed1[i4] = c[12] << 21 | c[13] << 11 | c[14];\n compressed1[i4 + 1] = c[15] << 21 | c[16] << 11 | c[17];\n compressed1[i4 + 2] = c[18] << 21 | c[19] << 11 | c[20];\n compressed1[i4 + 3] = c[21] << 21 | c[22] << 11 | c[23];\n compressed2[i4] = c[24] << 21 | c[25] << 11 | c[26];\n compressed2[i4 + 1] = c[27] << 21 | c[28] << 11 | c[29];\n compressed2[i4 + 2] = c[30] << 21 | c[31] << 11 | c[32];\n compressed2[i4 + 3] = c[33] << 21 | c[34] << 11 | c[35];\n compressed3[i4] = c[36] << 21 | c[37] << 11 | c[38];\n compressed3[i4 + 1] = c[39] << 21 | c[40] << 11 | c[41];\n compressed3[i4 + 2] = c[42] << 21 | c[43] << 11 | c[44];\n compressed3[i4 + 3] = uintView[0];\n }\n }\n }\n if (usingSphericalHarmonics === true) {\n worker.postMessage({\n textureData,\n textureWidth,\n textureHeight,\n compressed0,\n compressed1,\n compressed2,\n compressed3\n }, [\n textureData.buffer,\n compressed0.buffer,\n compressed1.buffer,\n compressed2.buffer,\n compressed3.buffer\n ]);\n } else {\n worker.postMessage({\n textureData,\n textureWidth,\n textureHeight\n }, [\n textureData.buffer\n ]);\n }\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount\n });\n } else {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount,\n generalBuffer: currentGeneralBuffer\n });\n }\n};\nconst convertProperty = async (prop) => {\n const count = prop.position.decoded.length / prop.position.channelCount;\n let scale = null;\n let rotation = null;\n let alpha = null;\n const scaleEncode = prop.scale.encode;\n const rotationEncode = prop.rotation.encode;\n const alphaEncode = prop.alpha.encode;\n if (scaleEncode === "ZIP") {\n scale = inflate_1(prop.scale.decoded);\n } else if (scaleEncode === "PNG") {\n const scaleDecoded = await pngExports.decodePng(new Uint8Array(prop.scale.decoded));\n scale = scaleDecoded.image.data;\n }\n if (rotationEncode === "ZIP") {\n rotation = inflate_1(prop.rotation.decoded);\n } else if (rotationEncode === "PNG") {\n const rotationDecoded = await pngExports.decodePng(new Uint8Array(prop.rotation.decoded));\n rotation = rotationDecoded.image.data;\n }\n const rotationMin = prop.rotation.min;\n const rotationRange0 = prop.rotation.max[0] - rotationMin[0];\n const rotationRange1 = prop.rotation.max[1] - rotationMin[1];\n const rotationRange2 = prop.rotation.max[2] - rotationMin[2];\n const rotationRange3 = prop.rotation.max[3] - rotationMin[3];\n if (alphaEncode === "ZIP") {\n alpha = inflate_1(prop.alpha.decoded);\n } else if (alphaEncode === "PNG") {\n const alphaDecoded = await pngExports.decodePng(new Uint8Array(prop.alpha.decoded));\n alpha = alphaDecoded.image.data;\n }\n const isInfinity = !isFinite(prop.alpha.min[0]) || !isFinite(prop.alpha.max[0]);\n const alphaMin = isInfinity === true ? 9.9 : prop.alpha.min[0];\n const alphaMax = isInfinity === true ? 10 : prop.alpha.max[0];\n const alphaRange = alphaMax - alphaMin;\n const position = prop.position.decoded;\n const sh0 = prop.sh0.decoded;\n for (let i = 0; i < count; ++i) {\n const ir = (i + currentVertexOffset) * ROW_LENGTH_TAVIO;\n const i3 = i * 3;\n const i4 = i * 4;\n let s0 = 0;\n let s1 = 0;\n let s2 = 0;\n let a0 = 0;\n let c3 = 0;\n let r0 = 0;\n let r1 = 0;\n let r2 = 0;\n let r3 = 0;\n if (scaleEncode === "ZIP") {\n s0 = scale[i3 + 0];\n s1 = scale[i3 + 1];\n s2 = scale[i3 + 2];\n } else if (scaleEncode === "PNG") {\n s0 = scale[i4 + 2];\n s1 = scale[i4 + 1];\n s2 = scale[i4 + 0];\n }\n if (alphaEncode === "ZIP") {\n a0 = alpha[i];\n c3 = alpha[i] * INV_255 * alphaRange + alphaMin;\n } else if (alphaEncode === "PNG") {\n a0 = alpha[i4];\n c3 = alpha[i4] * INV_255 * alphaRange + alphaMin;\n }\n if (rotationEncode === "ZIP") {\n r0 = rotation[i4 + 0] * INV_255 * rotationRange0 + rotationMin[0];\n r1 = rotation[i4 + 1] * INV_255 * rotationRange1 + rotationMin[1];\n r2 = rotation[i4 + 2] * INV_255 * rotationRange2 + rotationMin[2];\n r3 = rotation[i4 + 3] * INV_255 * rotationRange3 + rotationMin[3];\n } else if (rotationEncode === "PNG") {\n r0 = rotation[i4 + 2] * INV_255 * rotationRange0 + rotationMin[0];\n r1 = rotation[i4 + 1] * INV_255 * rotationRange1 + rotationMin[1];\n r2 = rotation[i4 + 0] * INV_255 * rotationRange2 + rotationMin[2];\n r3 = rotation[i4 + 3] * INV_255 * rotationRange3 + rotationMin[3];\n }\n const viewPosition = new Float16Array(currentBuffer, ir, 3);\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const viewColor = new Uint8ClampedArray(currentBuffer, ir + 9, 4);\n const viewRotation = new Uint8ClampedArray(currentBuffer, ir + 13, 3);\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n viewPosition[0] = position[i3];\n viewPosition[1] = position[i3 + 1];\n viewPosition[2] = position[i3 + 2];\n viewScale[0] = s0;\n viewScale[1] = s1;\n viewScale[2] = s2;\n const qlen = 1 / Math.sqrt(r0 * r0 + r1 * r1 + r2 * r2 + r3 * r3);\n const qw = r0 * qlen;\n const qx = r1 * qlen;\n const qy = r2 * qlen;\n const qz = r3 * qlen;\n const qt = convertQuaternion(qw, qx, qy, qz);\n viewRotation[0] = qt.u * 255;\n viewRotation[1] = qt.v * 255;\n viewRotation[2] = qt.w * 255;\n viewColor[0] = sh0[i3];\n viewColor[1] = sh0[i3 + 1];\n viewColor[2] = sh0[i3 + 2];\n viewColor[3] = 1 / (1 + Math.exp(-c3)) * 255;\n viewRawAlpha[0] = a0;\n }\n if (currentVertexOffset > 0) {\n const scale2 = prop.scale;\n const alpha2 = prop.alpha;\n const scaleRangeX = scale2.max[0] - scale2.min[0];\n const scaleRangeY = scale2.max[1] - scale2.min[1];\n const scaleRangeZ = scale2.max[2] - scale2.min[2];\n const alphaRange2 = alpha2.max[0] - alpha2.min[0];\n const preScale = prop.previousScale;\n const preAlpha = prop.previousAlpha;\n const preScaleRangeX = preScale.max[0] - preScale.min[0];\n const preScaleRangeY = preScale.max[1] - preScale.min[1];\n const preScaleRangeZ = preScale.max[2] - preScale.min[2];\n const preAlphaRange = preAlpha.max[0] - preAlpha.min[0];\n const curScaleMinX = Math.min(scale2.min[0], preScale.min[0]);\n const curScaleMinY = Math.min(scale2.min[1], preScale.min[1]);\n const curScaleMinZ = Math.min(scale2.min[2], preScale.min[2]);\n const curScaleMaxX = Math.max(scale2.max[0], preScale.max[0]);\n const curScaleMaxY = Math.max(scale2.max[1], preScale.max[1]);\n const curScaleMaxZ = Math.max(scale2.max[2], preScale.max[2]);\n const curAlphaMin = Math.min(alpha2.min[0], preAlpha.min[0]);\n const curAlphaMax = Math.max(alpha2.max[0], preAlpha.max[0]);\n const curScaleRangeX = curScaleMaxX - curScaleMinX;\n const curScaleRangeY = curScaleMaxY - curScaleMinY;\n const curScaleRangeZ = curScaleMaxZ - curScaleMinZ;\n const curAlphaRange = curAlphaMax - curAlphaMin;\n for (let i = 0; i < currentVertexOffset; ++i) {\n const ir = i * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * preScaleRangeX + preScale.min[0];\n const rsy = viewScale[1] * INV_255 * preScaleRangeY + preScale.min[1];\n const rsz = viewScale[2] * INV_255 * preScaleRangeZ + preScale.min[2];\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * preAlphaRange + preAlpha.min[0];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n for (let j = currentVertexOffset; j < currentVertexCount; ++j) {\n const ir = j * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * scaleRangeX + scale2.min[0];\n const rsy = viewScale[1] * INV_255 * scaleRangeY + scale2.min[1];\n const rsz = viewScale[2] * INV_255 * scaleRangeZ + scale2.min[2];\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * alphaRange2 + alpha2.min[0];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n }\n worker.postMessage({\n compressedSH: false\n });\n};\nconst convertSHProperty = async (shN) => {\n if (usingSphericalHarmonics !== true) {\n return;\n }\n const invBase = 1 / (Math.pow(2, shN.quantize) - 1);\n const shNMin = shN.min;\n const shNRange = shN.max - shNMin;\n const centroid = inflate_1(shN.centroid.decoded);\n const table = [];\n for (let k = 0, l = shN.cluster; k < l; ++k) {\n const n = k * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const element = [];\n for (let m = 0; m < SPHERICAL_HARMONICS_BASE_ELEMENT; ++m) {\n const c = centroid[m + n] * invBase * shNRange + shNMin;\n element.push(c);\n }\n table[k] = element;\n }\n const label = new Uint16Array(inflate_1(shN.label.decoded).buffer);\n const shBuffer = new Float32Array(currentSHBuffer);\n const count = currentVertexCount - currentVertexOffset;\n for (let o = 0, p = count; o < p; ++o) {\n const index = (o + currentVertexOffset) * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const sh = table[label[o]];\n for (let q = 0; q < SPHERICAL_HARMONICS_BASE_ELEMENT; ++q) {\n shBuffer[index + q] = sh[q];\n }\n }\n worker.postMessage({\n compressedSH: true\n });\n};\nconst create4x4 = (translation, rotation, scale) => {\n const sx = Math.sin(rotation[0]);\n const sy = Math.sin(rotation[1]);\n const sz = Math.sin(rotation[2]);\n const cx = Math.cos(rotation[0]);\n const cy = Math.cos(rotation[1]);\n const cz = Math.cos(rotation[2]);\n const ae = cx * cz;\n const af = cx * sz;\n const be = sx * cz;\n const bf = sx * sz;\n const mat = new Float32Array(16);\n mat[0] = cy * cz * scale;\n mat[1] = (af + be * sy) * scale;\n mat[2] = (bf - ae * sy) * scale;\n mat[3] = 0;\n mat[4] = -cy * sz * scale;\n mat[5] = (ae - bf * sy) * scale;\n mat[6] = (be + af * sy) * scale;\n mat[7] = 0;\n mat[8] = sy * scale;\n mat[9] = -sx * cy * scale;\n mat[10] = cx * cy * scale;\n mat[11] = 0;\n mat[12] = translation[0];\n mat[13] = translation[1];\n mat[14] = translation[2];\n mat[15] = 1;\n return mat;\n};\nconst apply4x4 = (m, x, y, z) => {\n const w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);\n return [\n (m[0] * x + m[4] * y + m[8] * z + m[12]) * w,\n (m[1] * x + m[5] * y + m[9] * z + m[13]) * w,\n (m[2] * x + m[6] * y + m[10] * z + m[14]) * w\n ];\n};\nconst checkSphereCollision = (c, x, y, z) => {\n const px = x - c.position[0];\n const py = y - c.position[1];\n const pz = z - c.position[2];\n const distance = Math.sqrt(px * px + py * py + pz * pz);\n const radius = Math.max(c.scale[0] * c.radius, c.scale[1] * c.radius, c.scale[2] * c.radius);\n if (distance <= radius) {\n const l = apply4x4(c.inverse4x4, x, y, z);\n const d = Math.sqrt(l[0] * l[0] + l[1] * l[1] + l[2] * l[2]);\n return d <= c.radius;\n } else {\n return false;\n }\n};\nconst checkBoxCollision = (c, x, y, z) => {\n const l = apply4x4(c.inverse4x4, x, y, z);\n const w = c.width * 0.5;\n const h = c.height * 0.5;\n const d = c.depth * 0.5;\n return -w <= l[0] && l[0] <= w && (-h <= l[1] && l[1] <= h) && (-d <= l[2] && l[2] <= d);\n};\nconst checkCollision = (sourceTransform, target) => {\n if (currentGeneralBuffer == null) {\n return;\n }\n const currentBufferFloatView = new Float16Array(currentBuffer);\n const currentGeneralByteView = new Uint8Array(currentGeneralBuffer);\n const targets = Array.isArray(target) ? target : [target];\n const targetCount = Math.min(targets.length, 8);\n let reversed = false;\n for (let _i = 0; _i < targetCount; ++_i) {\n reversed = reversed || targets[_i].reversed === true;\n }\n const sources = Array.isArray(sourceTransform) === true ? sourceTransform : [sourceTransform];\n const modelMatrix = sources.map((source) => {\n const t = [-source.translation.x, -source.translation.y, source.translation.z];\n const r = [source.rotation.x, source.rotation.y, source.rotation.z];\n const s = source.scale;\n return create4x4(t, r, s);\n });\n for (let i = 0; i < currentVertexCount; ++i) {\n const iIndex = 4 * i;\n let R = currentGeneralByteView[iIndex];\n let G = currentGeneralByteView[iIndex + 1];\n let B = currentGeneralByteView[iIndex + 2];\n let A = currentGeneralByteView[iIndex + 3];\n const [meshIndex, instanceIndex] = unpack8to4(A);\n if (G > 0) {\n R = 0;\n } else {\n const fIndex = 9 * i;\n const tx = currentBufferFloatView[fIndex + 0];\n const ty = currentBufferFloatView[fIndex + 1];\n const tz = currentBufferFloatView[fIndex + 2];\n const transformed = apply4x4(modelMatrix[instanceIndex], tx, ty, tz);\n const x = transformed[0];\n const y = transformed[1];\n const z = transformed[2];\n for (let j = 0; j < targetCount; ++j) {\n const masked = R & ~(1 << j);\n const t = targets[j];\n if (t.type === "sphere") {\n const sphere = t.target;\n const inclusion = checkSphereCollision(sphere, x, y, z);\n R = masked | +inclusion << j;\n } else if (t.type === "box") {\n const box = t.target;\n const inclusion = checkBoxCollision(box, x, y, z);\n R = masked | +inclusion << j;\n }\n }\n if (reversed === true) {\n R = R > 0 ? 0 : 1;\n }\n }\n currentGeneralByteView[iIndex] = R;\n currentGeneralByteView[iIndex + 1] = G;\n currentGeneralByteView[iIndex + 2] = B;\n currentGeneralByteView[iIndex + 3] = A;\n }\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount\n });\n } else {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount,\n generalBuffer: currentGeneralBuffer\n });\n }\n};\nconst mergeBuffer = (data) => {\n const offset = currentVertexOffset * ROW_LENGTH_TAVIO;\n const viewBuffer = new Uint8ClampedArray(currentBuffer);\n const newArray = new Uint8ClampedArray(data.buffer);\n viewBuffer.set(newArray, offset);\n const shOffset = currentVertexOffset * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const viewSHBuffer = new Float32Array(currentSHBuffer);\n const newSHArray = new Float32Array(data.shBuffer);\n viewSHBuffer.set(newSHArray, shOffset);\n const scale = data.scale;\n const scaleRangeX = scale.max[0] - scale.min[0];\n const scaleRangeY = scale.max[1] - scale.min[1];\n const scaleRangeZ = scale.max[2] - scale.min[2];\n const alpha = data.alpha;\n const alphaRange = alpha.max[0] - alpha.min[0];\n const preScale = data.previousScale;\n const preScaleRangeX = preScale.max[0] - preScale.min[0];\n const preScaleRangeY = preScale.max[1] - preScale.min[1];\n const preScaleRangeZ = preScale.max[2] - preScale.min[2];\n const preAlpha = data.previousAlpha;\n const preAlphaRange = preAlpha.max[0] - preAlpha.min[0];\n const curScaleMinX = Math.min(scale.min[0], preScale.min[0]);\n const curScaleMinY = Math.min(scale.min[1], preScale.min[1]);\n const curScaleMinZ = Math.min(scale.min[2], preScale.min[2]);\n const curScaleMaxX = Math.max(scale.max[0], preScale.max[0]);\n const curScaleMaxY = Math.max(scale.max[1], preScale.max[1]);\n const curScaleMaxZ = Math.max(scale.max[2], preScale.max[2]);\n const curScaleRangeX = curScaleMaxX - curScaleMinX;\n const curScaleRangeY = curScaleMaxY - curScaleMinY;\n const curScaleRangeZ = curScaleMaxZ - curScaleMinZ;\n const curAlphaMin = Math.min(alpha.min[0], preAlpha.min[0]);\n const curAlphaMax = Math.max(alpha.max[0], preAlpha.max[0]);\n const curAlphaRange = curAlphaMax - curAlphaMin;\n for (let i = 0; i < currentVertexOffset; ++i) {\n const ir = i * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * preScaleRangeX + preScale.min[0];\n const rsy = viewScale[1] * INV_255 * preScaleRangeY + preScale.min[1];\n const rsz = viewScale[2] * INV_255 * preScaleRangeZ + preScale.min[2];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * preAlphaRange + preAlpha.min[0];\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n for (let j = currentVertexOffset; j < currentVertexCount; ++j) {\n const ir = j * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * scaleRangeX + scale.min[0];\n const rsy = viewScale[1] * INV_255 * scaleRangeY + scale.min[1];\n const rsz = viewScale[2] * INV_255 * scaleRangeZ + scale.min[2];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * alphaRange + alpha.min[0];\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n};\nonmessage = (e) => {\n if (e.data.usingSharedArrayBuffer != null) {\n usingSharedArrayBuffer = e.data.usingSharedArrayBuffer;\n currentVertexCount = e.data.vertexCount;\n currentVertexOffset = e.data.offset;\n if (usingSharedArrayBuffer === true) {\n currentBuffer = e.data.buffer;\n currentIndexBuffer = e.data.indexBuffer;\n currentOrderBuffer = e.data.orderBuffer;\n currentGeneralBuffer = e.data.generalBuffer;\n currentSHBuffer = e.data.shBuffer;\n } else {\n if (currentVertexOffset > 0) {\n const tempBuffer = new ArrayBuffer(e.data.gaussianDataSize);\n const temp8Array = new Uint8Array(tempBuffer);\n temp8Array.set(new Uint8Array(currentBuffer));\n currentBuffer = tempBuffer;\n const tempGeneralBuffer = new ArrayBuffer(e.data.generalDataSize);\n const tempGeneral8Array = new Uint8Array(tempGeneralBuffer);\n tempGeneral8Array.set(new Uint8Array(currentGeneralBuffer));\n currentGeneralBuffer = tempGeneralBuffer;\n const tempSHBuffer = new ArrayBuffer(e.data.shDataSize);\n const tempSH8Array = new Uint8Array(tempSHBuffer);\n tempSH8Array.set(new Uint8Array(currentSHBuffer));\n currentSHBuffer = tempSHBuffer;\n } else {\n currentBuffer = new ArrayBuffer(e.data.gaussianDataSize);\n currentIndexBuffer = null;\n currentOrderBuffer = null;\n currentGeneralBuffer = new ArrayBuffer(e.data.generalDataSize);\n currentSHBuffer = new ArrayBuffer(e.data.shDataSize);\n }\n }\n } else if (e.data.properties != null) {\n convertProperty(e.data.properties);\n } else if (e.data.shProperty != null) {\n convertSHProperty(e.data.shProperty);\n } else if (e.data.updateTexture != null) {\n if (e.data.previousScale != null) {\n mergeBuffer(e.data);\n } else {\n if (usingSharedArrayBuffer === true) {\n const viewBuffer = new Uint8ClampedArray(currentBuffer);\n const newArray = new Uint8ClampedArray(e.data.buffer);\n viewBuffer.set(newArray);\n if (e.data.shBuffer != null) {\n const viewSHBuffer = new Float32Array(currentSHBuffer);\n const newSHArray = new Float32Array(e.data.shBuffer);\n viewSHBuffer.set(newSHArray);\n }\n } else {\n if (e.data.buffer != null) {\n currentBuffer = e.data.buffer;\n }\n if (e.data.shBuffer != null) {\n currentSHBuffer = e.data.shBuffer;\n }\n }\n }\n generateTexture();\n } else if (e.data.updateOrder != null) {\n if (usingSharedArrayBuffer !== true) {\n currentOrderBuffer = e.data.orderBuffer;\n }\n bucket16();\n } else if (e.data.updateGeneralData != null) {\n currentGeneralBuffer = e.data.generalBuffer;\n } else if (e.data.usingSphericalHarmonics != null) {\n usingSphericalHarmonics = e.data.usingSphericalHarmonics;\n } else if (e.data.collision != null) {\n checkCollision(e.data.source, e.data.collision);\n } else if (e.ports.length > 0 && e.data.requestBuffer != null) {\n const port = e.ports[0];\n const gaussianData = new Uint8Array(currentBuffer).slice();\n const sphericalHarmonicsData = new Float32Array(currentSHBuffer).slice();\n port.postMessage({\n gaussianData,\n sphericalHarmonicsData\n }, [\n gaussianData.buffer,\n sphericalHarmonicsData.buffer\n ]);\n }\n};\n';
|
|
37430
|
-
const blob
|
|
37441
|
+
const jsContent = 'function zero$1(buf) {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n}\nconst MIN_MATCH$1 = 3;\nconst MAX_MATCH$1 = 258;\nconst LENGTH_CODES$1 = 29;\nconst LITERALS$1 = 256;\nconst L_CODES$1 = LITERALS$1 + 1 + LENGTH_CODES$1;\nconst D_CODES$1 = 30;\nconst DIST_CODE_LEN = 512;\nconst static_ltree = new Array((L_CODES$1 + 2) * 2);\nzero$1(static_ltree);\nconst static_dtree = new Array(D_CODES$1 * 2);\nzero$1(static_dtree);\nconst _dist_code = new Array(DIST_CODE_LEN);\nzero$1(_dist_code);\nconst _length_code = new Array(MAX_MATCH$1 - MIN_MATCH$1 + 1);\nzero$1(_length_code);\nconst base_length = new Array(LENGTH_CODES$1);\nzero$1(base_length);\nconst base_dist = new Array(D_CODES$1);\nzero$1(base_dist);\nconst adler32 = (adler, buf, len, pos) => {\n let s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;\n while (len !== 0) {\n n = len > 2e3 ? 2e3 : len;\n len -= n;\n do {\n s1 = s1 + buf[pos++] | 0;\n s2 = s2 + s1 | 0;\n } while (--n);\n s1 %= 65521;\n s2 %= 65521;\n }\n return s1 | s2 << 16 | 0;\n};\nvar adler32_1$1 = adler32;\nconst makeTable = () => {\n let c, table = [];\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;\n }\n table[n] = c;\n }\n return table;\n};\nconst crcTable = new Uint32Array(makeTable());\nconst crc32$1 = (crc, buf, len, pos) => {\n const t = crcTable;\n const end = pos + len;\n crc ^= -1;\n for (let i = pos; i < end; i++) {\n crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];\n }\n return crc ^ -1;\n};\nvar crc32_1$1 = crc32$1;\nvar messages$1 = {\n 2: "need dictionary",\n /* Z_NEED_DICT 2 */\n 1: "stream end",\n /* Z_STREAM_END 1 */\n 0: "",\n /* Z_OK 0 */\n "-1": "file error",\n /* Z_ERRNO (-1) */\n "-2": "stream error",\n /* Z_STREAM_ERROR (-2) */\n "-3": "data error",\n /* Z_DATA_ERROR (-3) */\n "-4": "insufficient memory",\n /* Z_MEM_ERROR (-4) */\n "-5": "buffer error",\n /* Z_BUF_ERROR (-5) */\n "-6": "incompatible version"\n /* Z_VERSION_ERROR (-6) */\n};\nvar constants$2 = {\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n};\nconst _has = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n};\nvar assign = function(obj) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) {\n continue;\n }\n if (typeof source !== "object") {\n throw new TypeError(source + "must be non-object");\n }\n for (const p in source) {\n if (_has(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n return obj;\n};\nvar flattenChunks = (chunks) => {\n let len = 0;\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n const result = new Uint8Array(len);\n for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n let chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n return result;\n};\nvar common$1 = {\n assign,\n flattenChunks\n};\nlet STR_APPLY_UIA_OK = true;\ntry {\n String.fromCharCode.apply(null, new Uint8Array(1));\n} catch (__) {\n STR_APPLY_UIA_OK = false;\n}\nconst _utf8len = new Uint8Array(256);\nfor (let q = 0; q < 256; q++) {\n _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;\n}\n_utf8len[254] = _utf8len[254] = 1;\nvar string2buf = (str) => {\n if (typeof TextEncoder === "function" && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;\n }\n buf = new Uint8Array(buf_len);\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n if (c < 128) {\n buf[i++] = c;\n } else if (c < 2048) {\n buf[i++] = 192 | c >>> 6;\n buf[i++] = 128 | c & 63;\n } else if (c < 65536) {\n buf[i++] = 224 | c >>> 12;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n } else {\n buf[i++] = 240 | c >>> 18;\n buf[i++] = 128 | c >>> 12 & 63;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n }\n }\n return buf;\n};\nconst buf2binstring = (buf, len) => {\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n }\n }\n let result = "";\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n};\nvar buf2string = (buf, max) => {\n const len = max || buf.length;\n if (typeof TextDecoder === "function" && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n let i, out;\n const utf16buf = new Array(len * 2);\n for (out = 0, i = 0; i < len; ) {\n let c = buf[i++];\n if (c < 128) {\n utf16buf[out++] = c;\n continue;\n }\n let c_len = _utf8len[c];\n if (c_len > 4) {\n utf16buf[out++] = 65533;\n i += c_len - 1;\n continue;\n }\n c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;\n while (c_len > 1 && i < len) {\n c = c << 6 | buf[i++] & 63;\n c_len--;\n }\n if (c_len > 1) {\n utf16buf[out++] = 65533;\n continue;\n }\n if (c < 65536) {\n utf16buf[out++] = c;\n } else {\n c -= 65536;\n utf16buf[out++] = 55296 | c >> 10 & 1023;\n utf16buf[out++] = 56320 | c & 1023;\n }\n }\n return buf2binstring(utf16buf, out);\n};\nvar utf8border = (buf, max) => {\n max = max || buf.length;\n if (max > buf.length) {\n max = buf.length;\n }\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 192) === 128) {\n pos--;\n }\n if (pos < 0) {\n return max;\n }\n if (pos === 0) {\n return max;\n }\n return pos + _utf8len[buf[pos]] > max ? pos : max;\n};\nvar strings$1 = {\n string2buf,\n buf2string,\n utf8border\n};\nfunction ZStream() {\n this.input = null;\n this.next_in = 0;\n this.avail_in = 0;\n this.total_in = 0;\n this.output = null;\n this.next_out = 0;\n this.avail_out = 0;\n this.total_out = 0;\n this.msg = "";\n this.state = null;\n this.data_type = 2;\n this.adler = 0;\n}\nvar zstream$1 = ZStream;\nconst BAD$1 = 16209;\nconst TYPE$1 = 16191;\nvar inffast$1 = function inflate_fast(strm, start) {\n let _in;\n let last;\n let _out;\n let beg;\n let end;\n let dmax;\n let wsize;\n let whave;\n let wnext;\n let s_window;\n let hold;\n let bits;\n let lcode;\n let dcode;\n let lmask;\n let dmask;\n let here;\n let op;\n let len;\n let dist;\n let from;\n let from_source;\n let input, output;\n const state = strm.state;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n dmax = state.dmax;\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = lcode[hold & lmask];\n dolen:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op === 0) {\n output[_out++] = here & 65535;\n } else if (op & 16) {\n len = here & 65535;\n op &= 15;\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & (1 << op) - 1;\n hold >>>= op;\n bits -= op;\n }\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n dodist:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op & 16) {\n dist = here & 65535;\n op &= 15;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & (1 << op) - 1;\n if (dist > dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD$1;\n break top;\n }\n hold >>>= op;\n bits -= op;\n op = _out - beg;\n if (dist > op) {\n op = dist - op;\n if (op > whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD$1;\n break top;\n }\n }\n from = 0;\n from_source = s_window;\n if (wnext === 0) {\n from += wsize - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n } else if (wnext < op) {\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) {\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n } else {\n from += wnext - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n } else {\n from = _out - dist;\n do {\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n } else if ((op & 64) === 0) {\n here = dcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dodist;\n } else {\n strm.msg = "invalid distance code";\n state.mode = BAD$1;\n break top;\n }\n break;\n }\n } else if ((op & 64) === 0) {\n here = lcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dolen;\n } else if (op & 32) {\n state.mode = TYPE$1;\n break top;\n } else {\n strm.msg = "invalid literal/length code";\n state.mode = BAD$1;\n break top;\n }\n break;\n }\n } while (_in < last && _out < end);\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);\n strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);\n state.hold = hold;\n state.bits = bits;\n return;\n};\nconst MAXBITS = 15;\nconst ENOUGH_LENS$1 = 852;\nconst ENOUGH_DISTS$1 = 592;\nconst CODES$1 = 0;\nconst LENS$1 = 1;\nconst DISTS$1 = 2;\nconst lbase = new Uint16Array([\n /* Length codes 257..285 base */\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 13,\n 15,\n 17,\n 19,\n 23,\n 27,\n 31,\n 35,\n 43,\n 51,\n 59,\n 67,\n 83,\n 99,\n 115,\n 131,\n 163,\n 195,\n 227,\n 258,\n 0,\n 0\n]);\nconst lext = new Uint8Array([\n /* Length codes 257..285 extra */\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 17,\n 17,\n 18,\n 18,\n 18,\n 18,\n 19,\n 19,\n 19,\n 19,\n 20,\n 20,\n 20,\n 20,\n 21,\n 21,\n 21,\n 21,\n 16,\n 72,\n 78\n]);\nconst dbase = new Uint16Array([\n /* Distance codes 0..29 base */\n 1,\n 2,\n 3,\n 4,\n 5,\n 7,\n 9,\n 13,\n 17,\n 25,\n 33,\n 49,\n 65,\n 97,\n 129,\n 193,\n 257,\n 385,\n 513,\n 769,\n 1025,\n 1537,\n 2049,\n 3073,\n 4097,\n 6145,\n 8193,\n 12289,\n 16385,\n 24577,\n 0,\n 0\n]);\nconst dext = new Uint8Array([\n /* Distance codes 0..29 extra */\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 18,\n 18,\n 19,\n 19,\n 20,\n 20,\n 21,\n 21,\n 22,\n 22,\n 23,\n 23,\n 24,\n 24,\n 25,\n 25,\n 26,\n 26,\n 27,\n 27,\n 28,\n 28,\n 29,\n 29,\n 64,\n 64\n]);\nconst inflate_table = (type, lens, lens_index, codes, table, table_index, work, opts) => {\n const bits = opts.bits;\n let len = 0;\n let sym = 0;\n let min = 0, max = 0;\n let root = 0;\n let curr = 0;\n let drop = 0;\n let left = 0;\n let used = 0;\n let huff = 0;\n let incr;\n let fill;\n let low;\n let mask;\n let next;\n let base = null;\n let match;\n const count = new Uint16Array(MAXBITS + 1);\n const offs = new Uint16Array(MAXBITS + 1);\n let extra = null;\n let here_bits, here_op, here_val;\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) {\n break;\n }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) {\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n opts.bits = 1;\n return 0;\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) {\n break;\n }\n }\n if (root < min) {\n root = min;\n }\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n }\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1;\n }\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n if (type === CODES$1) {\n base = extra = work;\n match = 20;\n } else if (type === LENS$1) {\n base = lbase;\n extra = lext;\n match = 257;\n } else {\n base = dbase;\n extra = dext;\n match = 0;\n }\n huff = 0;\n sym = 0;\n len = min;\n next = table_index;\n curr = root;\n drop = 0;\n low = -1;\n used = 1 << root;\n mask = used - 1;\n if (type === LENS$1 && used > ENOUGH_LENS$1 || type === DISTS$1 && used > ENOUGH_DISTS$1) {\n return 1;\n }\n for (; ; ) {\n here_bits = len - drop;\n if (work[sym] + 1 < match) {\n here_op = 0;\n here_val = work[sym];\n } else if (work[sym] >= match) {\n here_op = extra[work[sym] - match];\n here_val = base[work[sym] - match];\n } else {\n here_op = 32 + 64;\n here_val = 0;\n }\n incr = 1 << len - drop;\n fill = 1 << curr;\n min = fill;\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;\n } while (fill !== 0);\n incr = 1 << len - 1;\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n sym++;\n if (--count[len] === 0) {\n if (len === max) {\n break;\n }\n len = lens[lens_index + work[sym]];\n }\n if (len > root && (huff & mask) !== low) {\n if (drop === 0) {\n drop = root;\n }\n next += min;\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) {\n break;\n }\n curr++;\n left <<= 1;\n }\n used += 1 << curr;\n if (type === LENS$1 && used > ENOUGH_LENS$1 || type === DISTS$1 && used > ENOUGH_DISTS$1) {\n return 1;\n }\n low = huff & mask;\n table[low] = root << 24 | curr << 16 | next - table_index | 0;\n }\n }\n if (huff !== 0) {\n table[next + huff] = len - drop << 24 | 64 << 16 | 0;\n }\n opts.bits = root;\n return 0;\n};\nvar inftrees$1 = inflate_table;\nconst CODES = 0;\nconst LENS = 1;\nconst DISTS = 2;\nconst {\n Z_FINISH: Z_FINISH$1,\n Z_BLOCK,\n Z_TREES,\n Z_OK: Z_OK$1,\n Z_STREAM_END: Z_STREAM_END$1,\n Z_NEED_DICT: Z_NEED_DICT$1,\n Z_STREAM_ERROR: Z_STREAM_ERROR$1,\n Z_DATA_ERROR: Z_DATA_ERROR$1,\n Z_MEM_ERROR: Z_MEM_ERROR$1,\n Z_BUF_ERROR,\n Z_DEFLATED\n} = constants$2;\nconst HEAD = 16180;\nconst FLAGS = 16181;\nconst TIME = 16182;\nconst OS = 16183;\nconst EXLEN = 16184;\nconst EXTRA = 16185;\nconst NAME = 16186;\nconst COMMENT = 16187;\nconst HCRC = 16188;\nconst DICTID = 16189;\nconst DICT = 16190;\nconst TYPE = 16191;\nconst TYPEDO = 16192;\nconst STORED = 16193;\nconst COPY_ = 16194;\nconst COPY = 16195;\nconst TABLE = 16196;\nconst LENLENS = 16197;\nconst CODELENS = 16198;\nconst LEN_ = 16199;\nconst LEN = 16200;\nconst LENEXT = 16201;\nconst DIST = 16202;\nconst DISTEXT = 16203;\nconst MATCH = 16204;\nconst LIT = 16205;\nconst CHECK = 16206;\nconst LENGTH = 16207;\nconst DONE = 16208;\nconst BAD = 16209;\nconst MEM = 16210;\nconst SYNC = 16211;\nconst ENOUGH_LENS = 852;\nconst ENOUGH_DISTS = 592;\nconst MAX_WBITS = 15;\nconst DEF_WBITS = MAX_WBITS;\nconst zswap32 = (q) => {\n return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);\n};\nfunction InflateState() {\n this.strm = null;\n this.mode = 0;\n this.last = false;\n this.wrap = 0;\n this.havedict = false;\n this.flags = 0;\n this.dmax = 0;\n this.check = 0;\n this.total = 0;\n this.head = null;\n this.wbits = 0;\n this.wsize = 0;\n this.whave = 0;\n this.wnext = 0;\n this.window = null;\n this.hold = 0;\n this.bits = 0;\n this.length = 0;\n this.offset = 0;\n this.extra = 0;\n this.lencode = null;\n this.distcode = null;\n this.lenbits = 0;\n this.distbits = 0;\n this.ncode = 0;\n this.nlen = 0;\n this.ndist = 0;\n this.have = 0;\n this.next = null;\n this.lens = new Uint16Array(320);\n this.work = new Uint16Array(288);\n this.lendyn = null;\n this.distdyn = null;\n this.sane = 0;\n this.back = 0;\n this.was = 0;\n}\nconst inflateStateCheck = (strm) => {\n if (!strm) {\n return 1;\n }\n const state = strm.state;\n if (!state || state.strm !== strm || state.mode < HEAD || state.mode > SYNC) {\n return 1;\n }\n return 0;\n};\nconst inflateResetKeep = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = "";\n if (state.wrap) {\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.flags = -1;\n state.dmax = 32768;\n state.head = null;\n state.hold = 0;\n state.bits = 0;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n state.sane = 1;\n state.back = -1;\n return Z_OK$1;\n};\nconst inflateReset = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n};\nconst inflateReset2 = (strm, windowBits) => {\n let wrap;\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else {\n wrap = (windowBits >> 4) + 5;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR$1;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n};\nconst inflateInit2 = (strm, windowBits) => {\n if (!strm) {\n return Z_STREAM_ERROR$1;\n }\n const state = new InflateState();\n strm.state = state;\n state.strm = strm;\n state.window = null;\n state.mode = HEAD;\n const ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK$1) {\n strm.state = null;\n }\n return ret;\n};\nconst inflateInit = (strm) => {\n return inflateInit2(strm, DEF_WBITS);\n};\nlet virgin = true;\nlet lenfix, distfix;\nconst fixedtables = (state) => {\n if (virgin) {\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n let sym = 0;\n while (sym < 144) {\n state.lens[sym++] = 8;\n }\n while (sym < 256) {\n state.lens[sym++] = 9;\n }\n while (sym < 280) {\n state.lens[sym++] = 7;\n }\n while (sym < 288) {\n state.lens[sym++] = 8;\n }\n inftrees$1(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n sym = 0;\n while (sym < 32) {\n state.lens[sym++] = 5;\n }\n inftrees$1(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n virgin = false;\n }\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n};\nconst updatewindow = (strm, src, end, copy) => {\n let dist;\n const state = strm.state;\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n state.window = new Uint8Array(state.wsize);\n }\n if (copy >= state.wsize) {\n state.window.set(src.subarray(end - state.wsize, end), 0);\n state.wnext = 0;\n state.whave = state.wsize;\n } else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n } else {\n state.wnext += dist;\n if (state.wnext === state.wsize) {\n state.wnext = 0;\n }\n if (state.whave < state.wsize) {\n state.whave += dist;\n }\n }\n }\n return 0;\n};\nconst inflate$2 = (strm, flush) => {\n let state;\n let input, output;\n let next;\n let put;\n let have, left;\n let hold;\n let bits;\n let _in, _out;\n let copy;\n let from;\n let from_source;\n let here = 0;\n let here_bits, here_op, here_val;\n let last_bits, last_op, last_val;\n let len;\n let ret;\n const hbuf = new Uint8Array(4);\n let opts;\n let n;\n const order = (\n /* permutation of code lengths */\n new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])\n );\n if (inflateStateCheck(strm) || !strm.output || !strm.input && strm.avail_in !== 0) {\n return Z_STREAM_ERROR$1;\n }\n state = strm.state;\n if (state.mode === TYPE) {\n state.mode = TYPEDO;\n }\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n _in = have;\n _out = left;\n ret = Z_OK$1;\n inf_leave:\n for (; ; ) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 2 && hold === 35615) {\n if (state.wbits === 0) {\n state.wbits = 15;\n }\n state.check = 0;\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n hold = 0;\n bits = 0;\n state.mode = FLAGS;\n break;\n }\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 255) << 8) + (hold >> 8)) % 31) {\n strm.msg = "incorrect header check";\n state.mode = BAD;\n break;\n }\n if ((hold & 15) !== Z_DEFLATED) {\n strm.msg = "unknown compression method";\n state.mode = BAD;\n break;\n }\n hold >>>= 4;\n bits -= 4;\n len = (hold & 15) + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n if (len > 15 || len > state.wbits) {\n strm.msg = "invalid window size";\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << state.wbits;\n state.flags = 0;\n strm.adler = state.check = 1;\n state.mode = hold & 512 ? DICTID : TYPE;\n hold = 0;\n bits = 0;\n break;\n case FLAGS:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.flags = hold;\n if ((state.flags & 255) !== Z_DEFLATED) {\n strm.msg = "unknown compression method";\n state.mode = BAD;\n break;\n }\n if (state.flags & 57344) {\n strm.msg = "unknown header flags set";\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = hold >> 8 & 1;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = TIME;\n /* falls through */\n case TIME:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n hbuf[2] = hold >>> 16 & 255;\n hbuf[3] = hold >>> 24 & 255;\n state.check = crc32_1$1(state.check, hbuf, 4, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = OS;\n /* falls through */\n case OS:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.xflags = hold & 255;\n state.head.os = hold >> 8;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 1024) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc32_1$1(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n } else if (state.head) {\n state.head.extra = null;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 1024) {\n copy = state.length;\n if (copy > have) {\n copy = have;\n }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n state.head.extra = new Uint8Array(state.head.extra_len);\n }\n state.head.extra.set(\n input.subarray(\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n next + copy\n ),\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n }\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) {\n break inf_leave;\n }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 2048) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 4096) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc32_1$1(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 512) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.check & 65535)) {\n strm.msg = "header crc mismatch";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n if (state.head) {\n state.head.hcrc = state.flags >> 9 & 1;\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n strm.adler = state.check = zswap32(hold);\n hold = 0;\n bits = 0;\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n return Z_NEED_DICT$1;\n }\n strm.adler = state.check = 1;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n hold >>>= bits & 7;\n bits -= bits & 7;\n state.mode = CHECK;\n break;\n }\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.last = hold & 1;\n hold >>>= 1;\n bits -= 1;\n switch (hold & 3) {\n case 0:\n state.mode = STORED;\n break;\n case 1:\n fixedtables(state);\n state.mode = LEN_;\n if (flush === Z_TREES) {\n hold >>>= 2;\n bits -= 2;\n break inf_leave;\n }\n break;\n case 2:\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = "invalid block type";\n state.mode = BAD;\n }\n hold >>>= 2;\n bits -= 2;\n break;\n case STORED:\n hold >>>= bits & 7;\n bits -= bits & 7;\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {\n strm.msg = "invalid stored block lengths";\n state.mode = BAD;\n break;\n }\n state.length = hold & 65535;\n hold = 0;\n bits = 0;\n state.mode = COPY_;\n if (flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) {\n copy = have;\n }\n if (copy > left) {\n copy = left;\n }\n if (copy === 0) {\n break inf_leave;\n }\n output.set(input.subarray(next, next + copy), put);\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n state.mode = TYPE;\n break;\n case TABLE:\n while (bits < 14) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.nlen = (hold & 31) + 257;\n hold >>>= 5;\n bits -= 5;\n state.ndist = (hold & 31) + 1;\n hold >>>= 5;\n bits -= 5;\n state.ncode = (hold & 15) + 4;\n hold >>>= 4;\n bits -= 4;\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = "too many length or distance symbols";\n state.mode = BAD;\n break;\n }\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.lens[order[state.have++]] = hold & 7;\n hold >>>= 3;\n bits -= 3;\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n state.lencode = state.lendyn;\n state.lenbits = 7;\n opts = { bits: state.lenbits };\n ret = inftrees$1(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid code lengths set";\n state.mode = BAD;\n break;\n }\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_val < 16) {\n hold >>>= here_bits;\n bits -= here_bits;\n state.lens[state.have++] = here_val;\n } else {\n if (here_val === 16) {\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n if (state.have === 0) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 3);\n hold >>>= 2;\n bits -= 2;\n } else if (here_val === 17) {\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 3 + (hold & 7);\n hold >>>= 3;\n bits -= 3;\n } else {\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 11 + (hold & 127);\n hold >>>= 7;\n bits -= 7;\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n if (state.mode === BAD) {\n break;\n }\n if (state.lens[256] === 0) {\n strm.msg = "invalid code -- missing end-of-block";\n state.mode = BAD;\n break;\n }\n state.lenbits = 9;\n opts = { bits: state.lenbits };\n ret = inftrees$1(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid literal/lengths set";\n state.mode = BAD;\n break;\n }\n state.distbits = 6;\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inftrees$1(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n state.distbits = opts.bits;\n if (ret) {\n strm.msg = "invalid distances set";\n state.mode = BAD;\n break;\n }\n state.mode = LEN_;\n if (flush === Z_TREES) {\n break inf_leave;\n }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n inffast$1(strm, _out);\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_op && (here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = "invalid literal/length code";\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (; ; ) {\n here = state.distcode[hold & (1 << state.distbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = "invalid distance code";\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = here_op & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.offset += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n if (state.offset > state.dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD;\n break;\n }\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) {\n break inf_leave;\n }\n copy = _out - left;\n if (state.offset > copy) {\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD;\n break;\n }\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n } else {\n from = state.wnext - copy;\n }\n if (copy > state.length) {\n copy = state.length;\n }\n from_source = state.window;\n } else {\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) {\n copy = left;\n }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) {\n state.mode = LEN;\n }\n break;\n case LIT:\n if (left === 0) {\n break inf_leave;\n }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold |= input[next++] << bits;\n bits += 8;\n }\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/\n state.flags ? crc32_1$1(state.check, output, _out, put - _out) : adler32_1$1(state.check, output, _out, put - _out);\n }\n _out = left;\n if (state.wrap & 4 && (state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = "incorrect data check";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.total & 4294967295)) {\n strm.msg = "incorrect length check";\n state.mode = BAD;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END$1;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR$1;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR$1;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR$1;\n }\n }\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH$1)) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/\n state.flags ? crc32_1$1(state.check, output, _out, strm.next_out - _out) : adler32_1$1(state.check, output, _out, strm.next_out - _out);\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if ((_in === 0 && _out === 0 || flush === Z_FINISH$1) && ret === Z_OK$1) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n};\nconst inflateEnd = (strm) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK$1;\n};\nconst inflateGetHeader = (strm, head) => {\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n const state = strm.state;\n if ((state.wrap & 2) === 0) {\n return Z_STREAM_ERROR$1;\n }\n state.head = head;\n head.done = false;\n return Z_OK$1;\n};\nconst inflateSetDictionary = (strm, dictionary) => {\n const dictLength = dictionary.length;\n let state;\n let dictid;\n let ret;\n if (inflateStateCheck(strm)) {\n return Z_STREAM_ERROR$1;\n }\n state = strm.state;\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR$1;\n }\n if (state.mode === DICT) {\n dictid = 1;\n dictid = adler32_1$1(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR$1;\n }\n }\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR$1;\n }\n state.havedict = 1;\n return Z_OK$1;\n};\nvar inflateReset_1 = inflateReset;\nvar inflateReset2_1 = inflateReset2;\nvar inflateResetKeep_1 = inflateResetKeep;\nvar inflateInit_1 = inflateInit;\nvar inflateInit2_1 = inflateInit2;\nvar inflate_2$1 = inflate$2;\nvar inflateEnd_1 = inflateEnd;\nvar inflateGetHeader_1 = inflateGetHeader;\nvar inflateSetDictionary_1 = inflateSetDictionary;\nvar inflateInfo = "pako inflate (from Nodeca project)";\nvar inflate_1$2 = {\n inflateReset: inflateReset_1,\n inflateReset2: inflateReset2_1,\n inflateResetKeep: inflateResetKeep_1,\n inflateInit: inflateInit_1,\n inflateInit2: inflateInit2_1,\n inflate: inflate_2$1,\n inflateEnd: inflateEnd_1,\n inflateGetHeader: inflateGetHeader_1,\n inflateSetDictionary: inflateSetDictionary_1,\n inflateInfo\n};\nfunction GZheader() {\n this.text = 0;\n this.time = 0;\n this.xflags = 0;\n this.os = 0;\n this.extra = null;\n this.extra_len = 0;\n this.name = "";\n this.comment = "";\n this.hcrc = 0;\n this.done = false;\n}\nvar gzheader$1 = GZheader;\nconst toString = Object.prototype.toString;\nconst {\n Z_NO_FLUSH,\n Z_FINISH,\n Z_OK,\n Z_STREAM_END,\n Z_NEED_DICT,\n Z_STREAM_ERROR,\n Z_DATA_ERROR,\n Z_MEM_ERROR\n} = constants$2;\nfunction Inflate$1(options) {\n this.options = common$1.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ""\n }, options || {});\n const opt = this.options;\n if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) {\n opt.windowBits = -15;\n }\n }\n if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n if (opt.windowBits > 15 && opt.windowBits < 48) {\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new zstream$1();\n this.strm.avail_out = 0;\n let status = inflate_1$2.inflateInit2(\n this.strm,\n opt.windowBits\n );\n if (status !== Z_OK) {\n throw new Error(messages$1[status]);\n }\n this.header = new gzheader$1();\n inflate_1$2.inflateGetHeader(this.strm, this.header);\n if (opt.dictionary) {\n if (typeof opt.dictionary === "string") {\n opt.dictionary = strings$1.string2buf(opt.dictionary);\n } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) {\n status = inflate_1$2.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK) {\n throw new Error(messages$1[status]);\n }\n }\n }\n}\nInflate$1.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n const dictionary = this.options.dictionary;\n let status, _flush_mode, last_avail_out;\n if (this.ended) return false;\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH : Z_NO_FLUSH;\n if (toString.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n for (; ; ) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = inflate_1$2.inflate(strm, _flush_mode);\n if (status === Z_NEED_DICT && dictionary) {\n status = inflate_1$2.inflateSetDictionary(strm, dictionary);\n if (status === Z_OK) {\n status = inflate_1$2.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR) {\n status = Z_NEED_DICT;\n }\n }\n while (strm.avail_in > 0 && status === Z_STREAM_END && strm.state.wrap > 0 && data[strm.next_in] !== 0) {\n inflate_1$2.inflateReset(strm);\n status = inflate_1$2.inflate(strm, _flush_mode);\n }\n switch (status) {\n case Z_STREAM_ERROR:\n case Z_DATA_ERROR:\n case Z_NEED_DICT:\n case Z_MEM_ERROR:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n last_avail_out = strm.avail_out;\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END) {\n if (this.options.to === "string") {\n let next_out_utf8 = strings$1.utf8border(strm.output, strm.next_out);\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings$1.buf2string(strm.output, next_out_utf8);\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);\n this.onData(utf8str);\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n if (status === Z_OK && last_avail_out === 0) continue;\n if (status === Z_STREAM_END) {\n status = inflate_1$2.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n};\nInflate$1.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n};\nInflate$1.prototype.onEnd = function(status) {\n if (status === Z_OK) {\n if (this.options.to === "string") {\n this.result = this.chunks.join("");\n } else {\n this.result = common$1.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\nfunction inflate$1$1(input, options) {\n const inflator = new Inflate$1(options);\n inflator.push(input);\n if (inflator.err) throw inflator.msg || messages$1[inflator.err];\n return inflator.result;\n}\nvar inflate_2 = inflate$1$1;\nvar inflate_1$1 = {\n inflate: inflate_2\n};\nconst { inflate: inflate$3 } = inflate_1$1;\nvar inflate_1 = inflate$3;\nvar png = {};\nvar assert$1 = {};\nvar hasRequiredAssert$1;\nfunction requireAssert$1() {\n if (hasRequiredAssert$1) return assert$1;\n hasRequiredAssert$1 = 1;\n Object.defineProperty(assert$1, "__esModule", { value: true });\n assert$1.handleWarning = assert$1.DecodeWarning = assert$1.createChunkDecodeWarning = assert$1.DecodeError = assert$1.createChunkDecodeError = assert$1.assertChunkCompressionMethod = assert$1.assertChunkMutualExclusion = assert$1.assertChunkFollows = assert$1.assertChunkPrecedes = assert$1.assertChunkDataLengthGte = assert$1.assertChunkDataLengthEquals = assert$1.assertChunkSinglular = void 0;\n function assertChunkSinglular(ctx, chunk) {\n if (ctx.parsedChunks.has(chunk.type)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Multiple ${chunk.type} chunks not allowed`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkSinglular = assertChunkSinglular;\n function assertChunkDataLengthEquals(ctx, chunk, expected) {\n if (chunk.dataLength !== expected) {\n const error = createChunkDecodeWarning(chunk, `Invalid data length: ${chunk.dataLength} !== ${expected}`, chunk.offset);\n if (chunk.dataLength > expected) {\n handleWarning(ctx, error);\n } else {\n throw error;\n }\n }\n }\n assert$1.assertChunkDataLengthEquals = assertChunkDataLengthEquals;\n function assertChunkDataLengthGte(ctx, chunk, expected) {\n if (chunk.dataLength < expected) {\n throw createChunkDecodeError(ctx, chunk, `Invalid data length: ${chunk.dataLength} < ${expected}`, chunk.offset);\n }\n }\n assert$1.assertChunkDataLengthGte = assertChunkDataLengthGte;\n function assertChunkPrecedes(ctx, chunk, typeAfter) {\n if (ctx.parsedChunks.has(typeAfter)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Must precede ${typeAfter}`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkPrecedes = assertChunkPrecedes;\n function assertChunkFollows(ctx, chunk, typeAfter) {\n if (!ctx.parsedChunks.has(typeAfter)) {\n throw createChunkDecodeError(ctx, chunk, `Must follow ${typeAfter}`, chunk.offset + 4);\n }\n }\n assert$1.assertChunkFollows = assertChunkFollows;\n function assertChunkMutualExclusion(ctx, chunk, otherType) {\n if (ctx.parsedChunks.has(otherType)) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Should not be present alongside ${otherType}`, chunk.offset + 4));\n }\n }\n assert$1.assertChunkMutualExclusion = assertChunkMutualExclusion;\n function assertChunkCompressionMethod(ctx, chunk, compressionMethod, offset) {\n if (compressionMethod !== 0) {\n handleWarning(ctx, createChunkDecodeWarning(chunk, `Unknown compression method "${compressionMethod}"`, offset));\n }\n }\n assert$1.assertChunkCompressionMethod = assertChunkCompressionMethod;\n function createChunkDecodeError(ctx, chunk, message, offset) {\n return new DecodeError(ctx, `${chunk.type}: ${message}`, offset);\n }\n assert$1.createChunkDecodeError = createChunkDecodeError;\n class DecodeError extends Error {\n constructor(ctx, message, offset) {\n super(message);\n this.offset = offset;\n this.partiallyDecodedImage = {\n details: "header" in ctx && ctx.header ? {\n width: ctx.header.width,\n height: ctx.header.height,\n bitDepth: ctx.header.bitDepth,\n colorType: ctx.header.colorType,\n interlaceMethod: ctx.header.interlaceMethod\n } : void 0,\n info: ctx.info,\n metadata: ctx.metadata,\n rawChunks: ctx.rawChunks,\n warnings: ctx.warnings\n };\n }\n }\n assert$1.DecodeError = DecodeError;\n function createChunkDecodeWarning(chunk, message, offset) {\n return new DecodeWarning(`${chunk.type}: ${message}`, offset);\n }\n assert$1.createChunkDecodeWarning = createChunkDecodeWarning;\n class DecodeWarning extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert$1.DecodeWarning = DecodeWarning;\n function handleWarning(ctx, warning) {\n if (ctx.options.strictMode) {\n throw warning;\n }\n ctx.warnings.push(warning);\n }\n assert$1.handleWarning = handleWarning;\n return assert$1;\n}\nvar assert = {};\nvar hasRequiredAssert;\nfunction requireAssert() {\n if (hasRequiredAssert) return assert;\n hasRequiredAssert = 1;\n Object.defineProperty(assert, "__esModule", { value: true });\n assert.handleWarning = assert.EncodeWarning = assert.EncodeError = void 0;\n class EncodeError extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert.EncodeError = EncodeError;\n class EncodeWarning extends Error {\n constructor(message, offset) {\n super(message);\n this.offset = offset;\n }\n }\n assert.EncodeWarning = EncodeWarning;\n function handleWarning(ctx, warning) {\n if (ctx.options.strictMode) {\n throw warning;\n }\n ctx.warnings.push(warning);\n }\n assert.handleWarning = handleWarning;\n return assert;\n}\nvar decoder = {};\nvar array = {};\nvar hasRequiredArray;\nfunction requireArray() {\n if (hasRequiredArray) return array;\n hasRequiredArray = 1;\n Object.defineProperty(array, "__esModule", { value: true });\n array.convert16BitTo8BitData = void 0;\n function convert16BitTo8BitData(data) {\n const view8Bit = new Uint8Array(data.buffer);\n const result = new Uint8Array(data.length);\n for (let i = 0; i < result.length; i++) {\n result[i] = view8Bit[i * 2 + 1];\n }\n return result;\n }\n array.convert16BitTo8BitData = convert16BitTo8BitData;\n return array;\n}\nvar chunk_IDAT = {};\nvar pako = {};\nvar deflate$1 = {};\nvar deflate = {};\nvar trees = {};\nvar hasRequiredTrees;\nfunction requireTrees() {\n if (hasRequiredTrees) return trees;\n hasRequiredTrees = 1;\n const Z_FIXED = 4;\n const Z_BINARY = 0;\n const Z_TEXT = 1;\n const Z_UNKNOWN = 2;\n function zero(buf) {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n }\n const STORED_BLOCK = 0;\n const STATIC_TREES = 1;\n const DYN_TREES = 2;\n const MIN_MATCH = 3;\n const MAX_MATCH = 258;\n const LENGTH_CODES = 29;\n const LITERALS = 256;\n const L_CODES = LITERALS + 1 + LENGTH_CODES;\n const D_CODES = 30;\n const BL_CODES = 19;\n const HEAP_SIZE = 2 * L_CODES + 1;\n const MAX_BITS = 15;\n const Buf_size = 16;\n const MAX_BL_BITS = 7;\n const END_BLOCK = 256;\n const REP_3_6 = 16;\n const REPZ_3_10 = 17;\n const REPZ_11_138 = 18;\n const extra_lbits = (\n /* extra bits for each length code */\n new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0])\n );\n const extra_dbits = (\n /* extra bits for each distance code */\n new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13])\n );\n const extra_blbits = (\n /* extra bits for each bit length code */\n new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7])\n );\n const bl_order = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n const DIST_CODE_LEN2 = 512;\n const static_ltree2 = new Array((L_CODES + 2) * 2);\n zero(static_ltree2);\n const static_dtree2 = new Array(D_CODES * 2);\n zero(static_dtree2);\n const _dist_code2 = new Array(DIST_CODE_LEN2);\n zero(_dist_code2);\n const _length_code2 = new Array(MAX_MATCH - MIN_MATCH + 1);\n zero(_length_code2);\n const base_length2 = new Array(LENGTH_CODES);\n zero(base_length2);\n const base_dist2 = new Array(D_CODES);\n zero(base_dist2);\n function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n this.static_tree = static_tree;\n this.extra_bits = extra_bits;\n this.extra_base = extra_base;\n this.elems = elems;\n this.max_length = max_length;\n this.has_stree = static_tree && static_tree.length;\n }\n let static_l_desc;\n let static_d_desc;\n let static_bl_desc;\n function TreeDesc(dyn_tree, stat_desc) {\n this.dyn_tree = dyn_tree;\n this.max_code = 0;\n this.stat_desc = stat_desc;\n }\n const d_code = (dist) => {\n return dist < 256 ? _dist_code2[dist] : _dist_code2[256 + (dist >>> 7)];\n };\n const put_short = (s, w) => {\n s.pending_buf[s.pending++] = w & 255;\n s.pending_buf[s.pending++] = w >>> 8 & 255;\n };\n const send_bits = (s, value, length) => {\n if (s.bi_valid > Buf_size - length) {\n s.bi_buf |= value << s.bi_valid & 65535;\n put_short(s, s.bi_buf);\n s.bi_buf = value >> Buf_size - s.bi_valid;\n s.bi_valid += length - Buf_size;\n } else {\n s.bi_buf |= value << s.bi_valid & 65535;\n s.bi_valid += length;\n }\n };\n const send_code = (s, c, tree) => {\n send_bits(\n s,\n tree[c * 2],\n tree[c * 2 + 1]\n /*.Len*/\n );\n };\n const bi_reverse = (code, len) => {\n let res = 0;\n do {\n res |= code & 1;\n code >>>= 1;\n res <<= 1;\n } while (--len > 0);\n return res >>> 1;\n };\n const bi_flush = (s) => {\n if (s.bi_valid === 16) {\n put_short(s, s.bi_buf);\n s.bi_buf = 0;\n s.bi_valid = 0;\n } else if (s.bi_valid >= 8) {\n s.pending_buf[s.pending++] = s.bi_buf & 255;\n s.bi_buf >>= 8;\n s.bi_valid -= 8;\n }\n };\n const gen_bitlen = (s, desc) => {\n const tree = desc.dyn_tree;\n const max_code = desc.max_code;\n const stree = desc.stat_desc.static_tree;\n const has_stree = desc.stat_desc.has_stree;\n const extra = desc.stat_desc.extra_bits;\n const base = desc.stat_desc.extra_base;\n const max_length = desc.stat_desc.max_length;\n let h;\n let n, m;\n let bits;\n let xbits;\n let f;\n let overflow = 0;\n for (bits = 0; bits <= MAX_BITS; bits++) {\n s.bl_count[bits] = 0;\n }\n tree[s.heap[s.heap_max] * 2 + 1] = 0;\n for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {\n n = s.heap[h];\n bits = tree[tree[n * 2 + 1] * 2 + 1] + 1;\n if (bits > max_length) {\n bits = max_length;\n overflow++;\n }\n tree[n * 2 + 1] = bits;\n if (n > max_code) {\n continue;\n }\n s.bl_count[bits]++;\n xbits = 0;\n if (n >= base) {\n xbits = extra[n - base];\n }\n f = tree[n * 2];\n s.opt_len += f * (bits + xbits);\n if (has_stree) {\n s.static_len += f * (stree[n * 2 + 1] + xbits);\n }\n }\n if (overflow === 0) {\n return;\n }\n do {\n bits = max_length - 1;\n while (s.bl_count[bits] === 0) {\n bits--;\n }\n s.bl_count[bits]--;\n s.bl_count[bits + 1] += 2;\n s.bl_count[max_length]--;\n overflow -= 2;\n } while (overflow > 0);\n for (bits = max_length; bits !== 0; bits--) {\n n = s.bl_count[bits];\n while (n !== 0) {\n m = s.heap[--h];\n if (m > max_code) {\n continue;\n }\n if (tree[m * 2 + 1] !== bits) {\n s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2];\n tree[m * 2 + 1] = bits;\n }\n n--;\n }\n }\n };\n const gen_codes = (tree, max_code, bl_count) => {\n const next_code = new Array(MAX_BITS + 1);\n let code = 0;\n let bits;\n let n;\n for (bits = 1; bits <= MAX_BITS; bits++) {\n code = code + bl_count[bits - 1] << 1;\n next_code[bits] = code;\n }\n for (n = 0; n <= max_code; n++) {\n let len = tree[n * 2 + 1];\n if (len === 0) {\n continue;\n }\n tree[n * 2] = bi_reverse(next_code[len]++, len);\n }\n };\n const tr_static_init = () => {\n let n;\n let bits;\n let length;\n let code;\n let dist;\n const bl_count = new Array(MAX_BITS + 1);\n length = 0;\n for (code = 0; code < LENGTH_CODES - 1; code++) {\n base_length2[code] = length;\n for (n = 0; n < 1 << extra_lbits[code]; n++) {\n _length_code2[length++] = code;\n }\n }\n _length_code2[length - 1] = code;\n dist = 0;\n for (code = 0; code < 16; code++) {\n base_dist2[code] = dist;\n for (n = 0; n < 1 << extra_dbits[code]; n++) {\n _dist_code2[dist++] = code;\n }\n }\n dist >>= 7;\n for (; code < D_CODES; code++) {\n base_dist2[code] = dist << 7;\n for (n = 0; n < 1 << extra_dbits[code] - 7; n++) {\n _dist_code2[256 + dist++] = code;\n }\n }\n for (bits = 0; bits <= MAX_BITS; bits++) {\n bl_count[bits] = 0;\n }\n n = 0;\n while (n <= 143) {\n static_ltree2[n * 2 + 1] = 8;\n n++;\n bl_count[8]++;\n }\n while (n <= 255) {\n static_ltree2[n * 2 + 1] = 9;\n n++;\n bl_count[9]++;\n }\n while (n <= 279) {\n static_ltree2[n * 2 + 1] = 7;\n n++;\n bl_count[7]++;\n }\n while (n <= 287) {\n static_ltree2[n * 2 + 1] = 8;\n n++;\n bl_count[8]++;\n }\n gen_codes(static_ltree2, L_CODES + 1, bl_count);\n for (n = 0; n < D_CODES; n++) {\n static_dtree2[n * 2 + 1] = 5;\n static_dtree2[n * 2] = bi_reverse(n, 5);\n }\n static_l_desc = new StaticTreeDesc(static_ltree2, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);\n static_d_desc = new StaticTreeDesc(static_dtree2, extra_dbits, 0, D_CODES, MAX_BITS);\n static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);\n };\n const init_block = (s) => {\n let n;\n for (n = 0; n < L_CODES; n++) {\n s.dyn_ltree[n * 2] = 0;\n }\n for (n = 0; n < D_CODES; n++) {\n s.dyn_dtree[n * 2] = 0;\n }\n for (n = 0; n < BL_CODES; n++) {\n s.bl_tree[n * 2] = 0;\n }\n s.dyn_ltree[END_BLOCK * 2] = 1;\n s.opt_len = s.static_len = 0;\n s.sym_next = s.matches = 0;\n };\n const bi_windup = (s) => {\n if (s.bi_valid > 8) {\n put_short(s, s.bi_buf);\n } else if (s.bi_valid > 0) {\n s.pending_buf[s.pending++] = s.bi_buf;\n }\n s.bi_buf = 0;\n s.bi_valid = 0;\n };\n const smaller = (tree, n, m, depth) => {\n const _n2 = n * 2;\n const _m2 = m * 2;\n return tree[_n2] < tree[_m2] || tree[_n2] === tree[_m2] && depth[n] <= depth[m];\n };\n const pqdownheap = (s, tree, k) => {\n const v = s.heap[k];\n let j = k << 1;\n while (j <= s.heap_len) {\n if (j < s.heap_len && smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n j++;\n }\n if (smaller(tree, v, s.heap[j], s.depth)) {\n break;\n }\n s.heap[k] = s.heap[j];\n k = j;\n j <<= 1;\n }\n s.heap[k] = v;\n };\n const compress_block = (s, ltree, dtree) => {\n let dist;\n let lc;\n let sx = 0;\n let code;\n let extra;\n if (s.sym_next !== 0) {\n do {\n dist = s.pending_buf[s.sym_buf + sx++] & 255;\n dist += (s.pending_buf[s.sym_buf + sx++] & 255) << 8;\n lc = s.pending_buf[s.sym_buf + sx++];\n if (dist === 0) {\n send_code(s, lc, ltree);\n } else {\n code = _length_code2[lc];\n send_code(s, code + LITERALS + 1, ltree);\n extra = extra_lbits[code];\n if (extra !== 0) {\n lc -= base_length2[code];\n send_bits(s, lc, extra);\n }\n dist--;\n code = d_code(dist);\n send_code(s, code, dtree);\n extra = extra_dbits[code];\n if (extra !== 0) {\n dist -= base_dist2[code];\n send_bits(s, dist, extra);\n }\n }\n } while (sx < s.sym_next);\n }\n send_code(s, END_BLOCK, ltree);\n };\n const build_tree = (s, desc) => {\n const tree = desc.dyn_tree;\n const stree = desc.stat_desc.static_tree;\n const has_stree = desc.stat_desc.has_stree;\n const elems = desc.stat_desc.elems;\n let n, m;\n let max_code = -1;\n let node;\n s.heap_len = 0;\n s.heap_max = HEAP_SIZE;\n for (n = 0; n < elems; n++) {\n if (tree[n * 2] !== 0) {\n s.heap[++s.heap_len] = max_code = n;\n s.depth[n] = 0;\n } else {\n tree[n * 2 + 1] = 0;\n }\n }\n while (s.heap_len < 2) {\n node = s.heap[++s.heap_len] = max_code < 2 ? ++max_code : 0;\n tree[node * 2] = 1;\n s.depth[node] = 0;\n s.opt_len--;\n if (has_stree) {\n s.static_len -= stree[node * 2 + 1];\n }\n }\n desc.max_code = max_code;\n for (n = s.heap_len >> 1; n >= 1; n--) {\n pqdownheap(s, tree, n);\n }\n node = elems;\n do {\n n = s.heap[\n 1\n /*SMALLEST*/\n ];\n s.heap[\n 1\n /*SMALLEST*/\n ] = s.heap[s.heap_len--];\n pqdownheap(\n s,\n tree,\n 1\n /*SMALLEST*/\n );\n m = s.heap[\n 1\n /*SMALLEST*/\n ];\n s.heap[--s.heap_max] = n;\n s.heap[--s.heap_max] = m;\n tree[node * 2] = tree[n * 2] + tree[m * 2];\n s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n tree[n * 2 + 1] = tree[m * 2 + 1] = node;\n s.heap[\n 1\n /*SMALLEST*/\n ] = node++;\n pqdownheap(\n s,\n tree,\n 1\n /*SMALLEST*/\n );\n } while (s.heap_len >= 2);\n s.heap[--s.heap_max] = s.heap[\n 1\n /*SMALLEST*/\n ];\n gen_bitlen(s, desc);\n gen_codes(tree, max_code, s.bl_count);\n };\n const scan_tree = (s, tree, max_code) => {\n let n;\n let prevlen = -1;\n let curlen;\n let nextlen = tree[0 * 2 + 1];\n let count = 0;\n let max_count = 7;\n let min_count = 4;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n tree[(max_code + 1) * 2 + 1] = 65535;\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1];\n if (++count < max_count && curlen === nextlen) {\n continue;\n } else if (count < min_count) {\n s.bl_tree[curlen * 2] += count;\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n s.bl_tree[curlen * 2]++;\n }\n s.bl_tree[REP_3_6 * 2]++;\n } else if (count <= 10) {\n s.bl_tree[REPZ_3_10 * 2]++;\n } else {\n s.bl_tree[REPZ_11_138 * 2]++;\n }\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n };\n const send_tree = (s, tree, max_code) => {\n let n;\n let prevlen = -1;\n let curlen;\n let nextlen = tree[0 * 2 + 1];\n let count = 0;\n let max_count = 7;\n let min_count = 4;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n }\n for (n = 0; n <= max_code; n++) {\n curlen = nextlen;\n nextlen = tree[(n + 1) * 2 + 1];\n if (++count < max_count && curlen === nextlen) {\n continue;\n } else if (count < min_count) {\n do {\n send_code(s, curlen, s.bl_tree);\n } while (--count !== 0);\n } else if (curlen !== 0) {\n if (curlen !== prevlen) {\n send_code(s, curlen, s.bl_tree);\n count--;\n }\n send_code(s, REP_3_6, s.bl_tree);\n send_bits(s, count - 3, 2);\n } else if (count <= 10) {\n send_code(s, REPZ_3_10, s.bl_tree);\n send_bits(s, count - 3, 3);\n } else {\n send_code(s, REPZ_11_138, s.bl_tree);\n send_bits(s, count - 11, 7);\n }\n count = 0;\n prevlen = curlen;\n if (nextlen === 0) {\n max_count = 138;\n min_count = 3;\n } else if (curlen === nextlen) {\n max_count = 6;\n min_count = 3;\n } else {\n max_count = 7;\n min_count = 4;\n }\n }\n };\n const build_bl_tree = (s) => {\n let max_blindex;\n scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n build_tree(s, s.bl_desc);\n for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {\n if (s.bl_tree[bl_order[max_blindex] * 2 + 1] !== 0) {\n break;\n }\n }\n s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n return max_blindex;\n };\n const send_all_trees = (s, lcodes, dcodes, blcodes) => {\n let rank;\n send_bits(s, lcodes - 257, 5);\n send_bits(s, dcodes - 1, 5);\n send_bits(s, blcodes - 4, 4);\n for (rank = 0; rank < blcodes; rank++) {\n send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1], 3);\n }\n send_tree(s, s.dyn_ltree, lcodes - 1);\n send_tree(s, s.dyn_dtree, dcodes - 1);\n };\n const detect_data_type = (s) => {\n let block_mask = 4093624447;\n let n;\n for (n = 0; n <= 31; n++, block_mask >>>= 1) {\n if (block_mask & 1 && s.dyn_ltree[n * 2] !== 0) {\n return Z_BINARY;\n }\n }\n if (s.dyn_ltree[9 * 2] !== 0 || s.dyn_ltree[10 * 2] !== 0 || s.dyn_ltree[13 * 2] !== 0) {\n return Z_TEXT;\n }\n for (n = 32; n < LITERALS; n++) {\n if (s.dyn_ltree[n * 2] !== 0) {\n return Z_TEXT;\n }\n }\n return Z_BINARY;\n };\n let static_init_done = false;\n const _tr_init = (s) => {\n if (!static_init_done) {\n tr_static_init();\n static_init_done = true;\n }\n s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);\n s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);\n s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n s.bi_buf = 0;\n s.bi_valid = 0;\n init_block(s);\n };\n const _tr_stored_block = (s, buf, stored_len, last) => {\n send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3);\n bi_windup(s);\n put_short(s, stored_len);\n put_short(s, ~stored_len);\n if (stored_len) {\n s.pending_buf.set(s.window.subarray(buf, buf + stored_len), s.pending);\n }\n s.pending += stored_len;\n };\n const _tr_align = (s) => {\n send_bits(s, STATIC_TREES << 1, 3);\n send_code(s, END_BLOCK, static_ltree2);\n bi_flush(s);\n };\n const _tr_flush_block = (s, buf, stored_len, last) => {\n let opt_lenb, static_lenb;\n let max_blindex = 0;\n if (s.level > 0) {\n if (s.strm.data_type === Z_UNKNOWN) {\n s.strm.data_type = detect_data_type(s);\n }\n build_tree(s, s.l_desc);\n build_tree(s, s.d_desc);\n max_blindex = build_bl_tree(s);\n opt_lenb = s.opt_len + 3 + 7 >>> 3;\n static_lenb = s.static_len + 3 + 7 >>> 3;\n if (static_lenb <= opt_lenb) {\n opt_lenb = static_lenb;\n }\n } else {\n opt_lenb = static_lenb = stored_len + 5;\n }\n if (stored_len + 4 <= opt_lenb && buf !== -1) {\n _tr_stored_block(s, buf, stored_len, last);\n } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {\n send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n compress_block(s, static_ltree2, static_dtree2);\n } else {\n send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n compress_block(s, s.dyn_ltree, s.dyn_dtree);\n }\n init_block(s);\n if (last) {\n bi_windup(s);\n }\n };\n const _tr_tally = (s, dist, lc) => {\n s.pending_buf[s.sym_buf + s.sym_next++] = dist;\n s.pending_buf[s.sym_buf + s.sym_next++] = dist >> 8;\n s.pending_buf[s.sym_buf + s.sym_next++] = lc;\n if (dist === 0) {\n s.dyn_ltree[lc * 2]++;\n } else {\n s.matches++;\n dist--;\n s.dyn_ltree[(_length_code2[lc] + LITERALS + 1) * 2]++;\n s.dyn_dtree[d_code(dist) * 2]++;\n }\n return s.sym_next === s.sym_end;\n };\n trees._tr_init = _tr_init;\n trees._tr_stored_block = _tr_stored_block;\n trees._tr_flush_block = _tr_flush_block;\n trees._tr_tally = _tr_tally;\n trees._tr_align = _tr_align;\n return trees;\n}\nvar adler32_1;\nvar hasRequiredAdler32;\nfunction requireAdler32() {\n if (hasRequiredAdler32) return adler32_1;\n hasRequiredAdler32 = 1;\n const adler322 = (adler, buf, len, pos) => {\n let s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;\n while (len !== 0) {\n n = len > 2e3 ? 2e3 : len;\n len -= n;\n do {\n s1 = s1 + buf[pos++] | 0;\n s2 = s2 + s1 | 0;\n } while (--n);\n s1 %= 65521;\n s2 %= 65521;\n }\n return s1 | s2 << 16 | 0;\n };\n adler32_1 = adler322;\n return adler32_1;\n}\nvar crc32_1;\nvar hasRequiredCrc32$1;\nfunction requireCrc32$1() {\n if (hasRequiredCrc32$1) return crc32_1;\n hasRequiredCrc32$1 = 1;\n const makeTable2 = () => {\n let c, table = [];\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;\n }\n table[n] = c;\n }\n return table;\n };\n const crcTable2 = new Uint32Array(makeTable2());\n const crc322 = (crc, buf, len, pos) => {\n const t = crcTable2;\n const end = pos + len;\n crc ^= -1;\n for (let i = pos; i < end; i++) {\n crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];\n }\n return crc ^ -1;\n };\n crc32_1 = crc322;\n return crc32_1;\n}\nvar messages;\nvar hasRequiredMessages;\nfunction requireMessages() {\n if (hasRequiredMessages) return messages;\n hasRequiredMessages = 1;\n messages = {\n 2: "need dictionary",\n /* Z_NEED_DICT 2 */\n 1: "stream end",\n /* Z_STREAM_END 1 */\n 0: "",\n /* Z_OK 0 */\n "-1": "file error",\n /* Z_ERRNO (-1) */\n "-2": "stream error",\n /* Z_STREAM_ERROR (-2) */\n "-3": "data error",\n /* Z_DATA_ERROR (-3) */\n "-4": "insufficient memory",\n /* Z_MEM_ERROR (-4) */\n "-5": "buffer error",\n /* Z_BUF_ERROR (-5) */\n "-6": "incompatible version"\n /* Z_VERSION_ERROR (-6) */\n };\n return messages;\n}\nvar constants;\nvar hasRequiredConstants;\nfunction requireConstants() {\n if (hasRequiredConstants) return constants;\n hasRequiredConstants = 1;\n constants = {\n /* Allowed flush values; see deflate() and inflate() below for details */\n Z_NO_FLUSH: 0,\n Z_PARTIAL_FLUSH: 1,\n Z_SYNC_FLUSH: 2,\n Z_FULL_FLUSH: 3,\n Z_FINISH: 4,\n Z_BLOCK: 5,\n Z_TREES: 6,\n /* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n Z_OK: 0,\n Z_STREAM_END: 1,\n Z_NEED_DICT: 2,\n Z_ERRNO: -1,\n Z_STREAM_ERROR: -2,\n Z_DATA_ERROR: -3,\n Z_MEM_ERROR: -4,\n Z_BUF_ERROR: -5,\n //Z_VERSION_ERROR: -6,\n /* compression levels */\n Z_NO_COMPRESSION: 0,\n Z_BEST_SPEED: 1,\n Z_BEST_COMPRESSION: 9,\n Z_DEFAULT_COMPRESSION: -1,\n Z_FILTERED: 1,\n Z_HUFFMAN_ONLY: 2,\n Z_RLE: 3,\n Z_FIXED: 4,\n Z_DEFAULT_STRATEGY: 0,\n /* Possible values of the data_type field (though see inflate()) */\n Z_BINARY: 0,\n Z_TEXT: 1,\n //Z_ASCII: 1, // = Z_TEXT (deprecated)\n Z_UNKNOWN: 2,\n /* The deflate compression method */\n Z_DEFLATED: 8\n //Z_NULL: null // Use -1 or null inline, depending on var type\n };\n return constants;\n}\nvar hasRequiredDeflate$1;\nfunction requireDeflate$1() {\n if (hasRequiredDeflate$1) return deflate;\n hasRequiredDeflate$1 = 1;\n const { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = requireTrees();\n const adler322 = requireAdler32();\n const crc322 = requireCrc32$1();\n const msg = requireMessages();\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_PARTIAL_FLUSH,\n Z_FULL_FLUSH,\n Z_FINISH: Z_FINISH2,\n Z_BLOCK: Z_BLOCK2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_BUF_ERROR: Z_BUF_ERROR2,\n Z_DEFAULT_COMPRESSION,\n Z_FILTERED,\n Z_HUFFMAN_ONLY,\n Z_RLE,\n Z_FIXED,\n Z_DEFAULT_STRATEGY,\n Z_UNKNOWN,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n const MAX_MEM_LEVEL = 9;\n const MAX_WBITS2 = 15;\n const DEF_MEM_LEVEL = 8;\n const LENGTH_CODES = 29;\n const LITERALS = 256;\n const L_CODES = LITERALS + 1 + LENGTH_CODES;\n const D_CODES = 30;\n const BL_CODES = 19;\n const HEAP_SIZE = 2 * L_CODES + 1;\n const MAX_BITS = 15;\n const MIN_MATCH = 3;\n const MAX_MATCH = 258;\n const MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1;\n const PRESET_DICT = 32;\n const INIT_STATE = 42;\n const GZIP_STATE = 57;\n const EXTRA_STATE = 69;\n const NAME_STATE = 73;\n const COMMENT_STATE = 91;\n const HCRC_STATE = 103;\n const BUSY_STATE = 113;\n const FINISH_STATE = 666;\n const BS_NEED_MORE = 1;\n const BS_BLOCK_DONE = 2;\n const BS_FINISH_STARTED = 3;\n const BS_FINISH_DONE = 4;\n const OS_CODE = 3;\n const err = (strm, errorCode) => {\n strm.msg = msg[errorCode];\n return errorCode;\n };\n const rank = (f) => {\n return f * 2 - (f > 4 ? 9 : 0);\n };\n const zero = (buf) => {\n let len = buf.length;\n while (--len >= 0) {\n buf[len] = 0;\n }\n };\n const slide_hash = (s) => {\n let n, m;\n let p;\n let wsize = s.w_size;\n n = s.hash_size;\n p = n;\n do {\n m = s.head[--p];\n s.head[p] = m >= wsize ? m - wsize : 0;\n } while (--n);\n n = wsize;\n p = n;\n do {\n m = s.prev[--p];\n s.prev[p] = m >= wsize ? m - wsize : 0;\n } while (--n);\n };\n let HASH_ZLIB = (s, prev, data) => (prev << s.hash_shift ^ data) & s.hash_mask;\n let HASH = HASH_ZLIB;\n const flush_pending = (strm) => {\n const s = strm.state;\n let len = s.pending;\n if (len > strm.avail_out) {\n len = strm.avail_out;\n }\n if (len === 0) {\n return;\n }\n strm.output.set(s.pending_buf.subarray(s.pending_out, s.pending_out + len), strm.next_out);\n strm.next_out += len;\n s.pending_out += len;\n strm.total_out += len;\n strm.avail_out -= len;\n s.pending -= len;\n if (s.pending === 0) {\n s.pending_out = 0;\n }\n };\n const flush_block_only = (s, last) => {\n _tr_flush_block(s, s.block_start >= 0 ? s.block_start : -1, s.strstart - s.block_start, last);\n s.block_start = s.strstart;\n flush_pending(s.strm);\n };\n const put_byte = (s, b) => {\n s.pending_buf[s.pending++] = b;\n };\n const putShortMSB = (s, b) => {\n s.pending_buf[s.pending++] = b >>> 8 & 255;\n s.pending_buf[s.pending++] = b & 255;\n };\n const read_buf = (strm, buf, start, size) => {\n let len = strm.avail_in;\n if (len > size) {\n len = size;\n }\n if (len === 0) {\n return 0;\n }\n strm.avail_in -= len;\n buf.set(strm.input.subarray(strm.next_in, strm.next_in + len), start);\n if (strm.state.wrap === 1) {\n strm.adler = adler322(strm.adler, buf, len, start);\n } else if (strm.state.wrap === 2) {\n strm.adler = crc322(strm.adler, buf, len, start);\n }\n strm.next_in += len;\n strm.total_in += len;\n return len;\n };\n const longest_match = (s, cur_match) => {\n let chain_length = s.max_chain_length;\n let scan = s.strstart;\n let match;\n let len;\n let best_len = s.prev_length;\n let nice_match = s.nice_match;\n const limit = s.strstart > s.w_size - MIN_LOOKAHEAD ? s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0;\n const _win = s.window;\n const wmask = s.w_mask;\n const prev = s.prev;\n const strend = s.strstart + MAX_MATCH;\n let scan_end1 = _win[scan + best_len - 1];\n let scan_end = _win[scan + best_len];\n if (s.prev_length >= s.good_match) {\n chain_length >>= 2;\n }\n if (nice_match > s.lookahead) {\n nice_match = s.lookahead;\n }\n do {\n match = cur_match;\n if (_win[match + best_len] !== scan_end || _win[match + best_len - 1] !== scan_end1 || _win[match] !== _win[scan] || _win[++match] !== _win[scan + 1]) {\n continue;\n }\n scan += 2;\n match++;\n do {\n } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend);\n len = MAX_MATCH - (strend - scan);\n scan = strend - MAX_MATCH;\n if (len > best_len) {\n s.match_start = cur_match;\n best_len = len;\n if (len >= nice_match) {\n break;\n }\n scan_end1 = _win[scan + best_len - 1];\n scan_end = _win[scan + best_len];\n }\n } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n if (best_len <= s.lookahead) {\n return best_len;\n }\n return s.lookahead;\n };\n const fill_window = (s) => {\n const _w_size = s.w_size;\n let n, more, str;\n do {\n more = s.window_size - s.lookahead - s.strstart;\n if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n s.window.set(s.window.subarray(_w_size, _w_size + _w_size - more), 0);\n s.match_start -= _w_size;\n s.strstart -= _w_size;\n s.block_start -= _w_size;\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n slide_hash(s);\n more += _w_size;\n }\n if (s.strm.avail_in === 0) {\n break;\n }\n n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n s.lookahead += n;\n if (s.lookahead + s.insert >= MIN_MATCH) {\n str = s.strstart - s.insert;\n s.ins_h = s.window[str];\n s.ins_h = HASH(s, s.ins_h, s.window[str + 1]);\n while (s.insert) {\n s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n s.insert--;\n if (s.lookahead + s.insert < MIN_MATCH) {\n break;\n }\n }\n }\n } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n };\n const deflate_stored = (s, flush) => {\n let min_block = s.pending_buf_size - 5 > s.w_size ? s.w_size : s.pending_buf_size - 5;\n let len, left, have, last = 0;\n let used = s.strm.avail_in;\n do {\n len = 65535;\n have = s.bi_valid + 42 >> 3;\n if (s.strm.avail_out < have) {\n break;\n }\n have = s.strm.avail_out - have;\n left = s.strstart - s.block_start;\n if (len > left + s.strm.avail_in) {\n len = left + s.strm.avail_in;\n }\n if (len > have) {\n len = have;\n }\n if (len < min_block && (len === 0 && flush !== Z_FINISH2 || flush === Z_NO_FLUSH2 || len !== left + s.strm.avail_in)) {\n break;\n }\n last = flush === Z_FINISH2 && len === left + s.strm.avail_in ? 1 : 0;\n _tr_stored_block(s, 0, 0, last);\n s.pending_buf[s.pending - 4] = len;\n s.pending_buf[s.pending - 3] = len >> 8;\n s.pending_buf[s.pending - 2] = ~len;\n s.pending_buf[s.pending - 1] = ~len >> 8;\n flush_pending(s.strm);\n if (left) {\n if (left > len) {\n left = len;\n }\n s.strm.output.set(s.window.subarray(s.block_start, s.block_start + left), s.strm.next_out);\n s.strm.next_out += left;\n s.strm.avail_out -= left;\n s.strm.total_out += left;\n s.block_start += left;\n len -= left;\n }\n if (len) {\n read_buf(s.strm, s.strm.output, s.strm.next_out, len);\n s.strm.next_out += len;\n s.strm.avail_out -= len;\n s.strm.total_out += len;\n }\n } while (last === 0);\n used -= s.strm.avail_in;\n if (used) {\n if (used >= s.w_size) {\n s.matches = 2;\n s.window.set(s.strm.input.subarray(s.strm.next_in - s.w_size, s.strm.next_in), 0);\n s.strstart = s.w_size;\n s.insert = s.strstart;\n } else {\n if (s.window_size - s.strstart <= used) {\n s.strstart -= s.w_size;\n s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0);\n if (s.matches < 2) {\n s.matches++;\n }\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n }\n s.window.set(s.strm.input.subarray(s.strm.next_in - used, s.strm.next_in), s.strstart);\n s.strstart += used;\n s.insert += used > s.w_size - s.insert ? s.w_size - s.insert : used;\n }\n s.block_start = s.strstart;\n }\n if (s.high_water < s.strstart) {\n s.high_water = s.strstart;\n }\n if (last) {\n return BS_FINISH_DONE;\n }\n if (flush !== Z_NO_FLUSH2 && flush !== Z_FINISH2 && s.strm.avail_in === 0 && s.strstart === s.block_start) {\n return BS_BLOCK_DONE;\n }\n have = s.window_size - s.strstart;\n if (s.strm.avail_in > have && s.block_start >= s.w_size) {\n s.block_start -= s.w_size;\n s.strstart -= s.w_size;\n s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0);\n if (s.matches < 2) {\n s.matches++;\n }\n have += s.w_size;\n if (s.insert > s.strstart) {\n s.insert = s.strstart;\n }\n }\n if (have > s.strm.avail_in) {\n have = s.strm.avail_in;\n }\n if (have) {\n read_buf(s.strm, s.window, s.strstart, have);\n s.strstart += have;\n s.insert += have > s.w_size - s.insert ? s.w_size - s.insert : have;\n }\n if (s.high_water < s.strstart) {\n s.high_water = s.strstart;\n }\n have = s.bi_valid + 42 >> 3;\n have = s.pending_buf_size - have > 65535 ? 65535 : s.pending_buf_size - have;\n min_block = have > s.w_size ? s.w_size : have;\n left = s.strstart - s.block_start;\n if (left >= min_block || (left || flush === Z_FINISH2) && flush !== Z_NO_FLUSH2 && s.strm.avail_in === 0 && left <= have) {\n len = left > have ? have : left;\n last = flush === Z_FINISH2 && s.strm.avail_in === 0 && len === left ? 1 : 0;\n _tr_stored_block(s, s.block_start, len, last);\n s.block_start += len;\n flush_pending(s.strm);\n }\n return last ? BS_FINISH_STARTED : BS_NEED_MORE;\n };\n const deflate_fast = (s, flush) => {\n let hash_head;\n let bflush;\n for (; ; ) {\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n hash_head = 0;\n if (s.lookahead >= MIN_MATCH) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n if (hash_head !== 0 && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {\n s.match_length = longest_match(s, hash_head);\n }\n if (s.match_length >= MIN_MATCH) {\n bflush = _tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n s.lookahead -= s.match_length;\n if (s.match_length <= s.max_lazy_match && s.lookahead >= MIN_MATCH) {\n s.match_length--;\n do {\n s.strstart++;\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n } while (--s.match_length !== 0);\n s.strstart++;\n } else {\n s.strstart += s.match_length;\n s.match_length = 0;\n s.ins_h = s.window[s.strstart];\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + 1]);\n }\n } else {\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_slow = (s, flush) => {\n let hash_head;\n let bflush;\n let max_insert;\n for (; ; ) {\n if (s.lookahead < MIN_LOOKAHEAD) {\n fill_window(s);\n if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n hash_head = 0;\n if (s.lookahead >= MIN_MATCH) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n s.prev_length = s.match_length;\n s.prev_match = s.match_start;\n s.match_length = MIN_MATCH - 1;\n if (hash_head !== 0 && s.prev_length < s.max_lazy_match && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {\n s.match_length = longest_match(s, hash_head);\n if (s.match_length <= 5 && (s.strategy === Z_FILTERED || s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096)) {\n s.match_length = MIN_MATCH - 1;\n }\n }\n if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n max_insert = s.strstart + s.lookahead - MIN_MATCH;\n bflush = _tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n s.lookahead -= s.prev_length - 1;\n s.prev_length -= 2;\n do {\n if (++s.strstart <= max_insert) {\n s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);\n hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = s.strstart;\n }\n } while (--s.prev_length !== 0);\n s.match_available = 0;\n s.match_length = MIN_MATCH - 1;\n s.strstart++;\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n } else if (s.match_available) {\n bflush = _tr_tally(s, 0, s.window[s.strstart - 1]);\n if (bflush) {\n flush_block_only(s, false);\n }\n s.strstart++;\n s.lookahead--;\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n } else {\n s.match_available = 1;\n s.strstart++;\n s.lookahead--;\n }\n }\n if (s.match_available) {\n bflush = _tr_tally(s, 0, s.window[s.strstart - 1]);\n s.match_available = 0;\n }\n s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_rle = (s, flush) => {\n let bflush;\n let prev;\n let scan, strend;\n const _win = s.window;\n for (; ; ) {\n if (s.lookahead <= MAX_MATCH) {\n fill_window(s);\n if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n if (s.lookahead === 0) {\n break;\n }\n }\n s.match_length = 0;\n if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n scan = s.strstart - 1;\n prev = _win[scan];\n if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n strend = s.strstart + MAX_MATCH;\n do {\n } while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend);\n s.match_length = MAX_MATCH - (strend - scan);\n if (s.match_length > s.lookahead) {\n s.match_length = s.lookahead;\n }\n }\n }\n if (s.match_length >= MIN_MATCH) {\n bflush = _tr_tally(s, 1, s.match_length - MIN_MATCH);\n s.lookahead -= s.match_length;\n s.strstart += s.match_length;\n s.match_length = 0;\n } else {\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n }\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n const deflate_huff = (s, flush) => {\n let bflush;\n for (; ; ) {\n if (s.lookahead === 0) {\n fill_window(s);\n if (s.lookahead === 0) {\n if (flush === Z_NO_FLUSH2) {\n return BS_NEED_MORE;\n }\n break;\n }\n }\n s.match_length = 0;\n bflush = _tr_tally(s, 0, s.window[s.strstart]);\n s.lookahead--;\n s.strstart++;\n if (bflush) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n }\n s.insert = 0;\n if (flush === Z_FINISH2) {\n flush_block_only(s, true);\n if (s.strm.avail_out === 0) {\n return BS_FINISH_STARTED;\n }\n return BS_FINISH_DONE;\n }\n if (s.sym_next) {\n flush_block_only(s, false);\n if (s.strm.avail_out === 0) {\n return BS_NEED_MORE;\n }\n }\n return BS_BLOCK_DONE;\n };\n function Config(good_length, max_lazy, nice_length, max_chain, func) {\n this.good_length = good_length;\n this.max_lazy = max_lazy;\n this.nice_length = nice_length;\n this.max_chain = max_chain;\n this.func = func;\n }\n const configuration_table = [\n /* good lazy nice chain */\n new Config(0, 0, 0, 0, deflate_stored),\n /* 0 store only */\n new Config(4, 4, 8, 4, deflate_fast),\n /* 1 max speed, no lazy matches */\n new Config(4, 5, 16, 8, deflate_fast),\n /* 2 */\n new Config(4, 6, 32, 32, deflate_fast),\n /* 3 */\n new Config(4, 4, 16, 16, deflate_slow),\n /* 4 lazy matches */\n new Config(8, 16, 32, 32, deflate_slow),\n /* 5 */\n new Config(8, 16, 128, 128, deflate_slow),\n /* 6 */\n new Config(8, 32, 128, 256, deflate_slow),\n /* 7 */\n new Config(32, 128, 258, 1024, deflate_slow),\n /* 8 */\n new Config(32, 258, 258, 4096, deflate_slow)\n /* 9 max compression */\n ];\n const lm_init = (s) => {\n s.window_size = 2 * s.w_size;\n zero(s.head);\n s.max_lazy_match = configuration_table[s.level].max_lazy;\n s.good_match = configuration_table[s.level].good_length;\n s.nice_match = configuration_table[s.level].nice_length;\n s.max_chain_length = configuration_table[s.level].max_chain;\n s.strstart = 0;\n s.block_start = 0;\n s.lookahead = 0;\n s.insert = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n s.ins_h = 0;\n };\n function DeflateState() {\n this.strm = null;\n this.status = 0;\n this.pending_buf = null;\n this.pending_buf_size = 0;\n this.pending_out = 0;\n this.pending = 0;\n this.wrap = 0;\n this.gzhead = null;\n this.gzindex = 0;\n this.method = Z_DEFLATED2;\n this.last_flush = -1;\n this.w_size = 0;\n this.w_bits = 0;\n this.w_mask = 0;\n this.window = null;\n this.window_size = 0;\n this.prev = null;\n this.head = null;\n this.ins_h = 0;\n this.hash_size = 0;\n this.hash_bits = 0;\n this.hash_mask = 0;\n this.hash_shift = 0;\n this.block_start = 0;\n this.match_length = 0;\n this.prev_match = 0;\n this.match_available = 0;\n this.strstart = 0;\n this.match_start = 0;\n this.lookahead = 0;\n this.prev_length = 0;\n this.max_chain_length = 0;\n this.max_lazy_match = 0;\n this.level = 0;\n this.strategy = 0;\n this.good_match = 0;\n this.nice_match = 0;\n this.dyn_ltree = new Uint16Array(HEAP_SIZE * 2);\n this.dyn_dtree = new Uint16Array((2 * D_CODES + 1) * 2);\n this.bl_tree = new Uint16Array((2 * BL_CODES + 1) * 2);\n zero(this.dyn_ltree);\n zero(this.dyn_dtree);\n zero(this.bl_tree);\n this.l_desc = null;\n this.d_desc = null;\n this.bl_desc = null;\n this.bl_count = new Uint16Array(MAX_BITS + 1);\n this.heap = new Uint16Array(2 * L_CODES + 1);\n zero(this.heap);\n this.heap_len = 0;\n this.heap_max = 0;\n this.depth = new Uint16Array(2 * L_CODES + 1);\n zero(this.depth);\n this.sym_buf = 0;\n this.lit_bufsize = 0;\n this.sym_next = 0;\n this.sym_end = 0;\n this.opt_len = 0;\n this.static_len = 0;\n this.matches = 0;\n this.insert = 0;\n this.bi_buf = 0;\n this.bi_valid = 0;\n }\n const deflateStateCheck = (strm) => {\n if (!strm) {\n return 1;\n }\n const s = strm.state;\n if (!s || s.strm !== strm || s.status !== INIT_STATE && //#ifdef GZIP\n s.status !== GZIP_STATE && //#endif\n s.status !== EXTRA_STATE && s.status !== NAME_STATE && s.status !== COMMENT_STATE && s.status !== HCRC_STATE && s.status !== BUSY_STATE && s.status !== FINISH_STATE) {\n return 1;\n }\n return 0;\n };\n const deflateResetKeep = (strm) => {\n if (deflateStateCheck(strm)) {\n return err(strm, Z_STREAM_ERROR2);\n }\n strm.total_in = strm.total_out = 0;\n strm.data_type = Z_UNKNOWN;\n const s = strm.state;\n s.pending = 0;\n s.pending_out = 0;\n if (s.wrap < 0) {\n s.wrap = -s.wrap;\n }\n s.status = //#ifdef GZIP\n s.wrap === 2 ? GZIP_STATE : (\n //#endif\n s.wrap ? INIT_STATE : BUSY_STATE\n );\n strm.adler = s.wrap === 2 ? 0 : 1;\n s.last_flush = -2;\n _tr_init(s);\n return Z_OK2;\n };\n const deflateReset = (strm) => {\n const ret = deflateResetKeep(strm);\n if (ret === Z_OK2) {\n lm_init(strm.state);\n }\n return ret;\n };\n const deflateSetHeader = (strm, head) => {\n if (deflateStateCheck(strm) || strm.state.wrap !== 2) {\n return Z_STREAM_ERROR2;\n }\n strm.state.gzhead = head;\n return Z_OK2;\n };\n const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {\n if (!strm) {\n return Z_STREAM_ERROR2;\n }\n let wrap = 1;\n if (level === Z_DEFAULT_COMPRESSION) {\n level = 6;\n }\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else if (windowBits > 15) {\n wrap = 2;\n windowBits -= 16;\n }\n if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED2 || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED || windowBits === 8 && wrap !== 1) {\n return err(strm, Z_STREAM_ERROR2);\n }\n if (windowBits === 8) {\n windowBits = 9;\n }\n const s = new DeflateState();\n strm.state = s;\n s.strm = strm;\n s.status = INIT_STATE;\n s.wrap = wrap;\n s.gzhead = null;\n s.w_bits = windowBits;\n s.w_size = 1 << s.w_bits;\n s.w_mask = s.w_size - 1;\n s.hash_bits = memLevel + 7;\n s.hash_size = 1 << s.hash_bits;\n s.hash_mask = s.hash_size - 1;\n s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n s.window = new Uint8Array(s.w_size * 2);\n s.head = new Uint16Array(s.hash_size);\n s.prev = new Uint16Array(s.w_size);\n s.lit_bufsize = 1 << memLevel + 6;\n s.pending_buf_size = s.lit_bufsize * 4;\n s.pending_buf = new Uint8Array(s.pending_buf_size);\n s.sym_buf = s.lit_bufsize;\n s.sym_end = (s.lit_bufsize - 1) * 3;\n s.level = level;\n s.strategy = strategy;\n s.method = method;\n return deflateReset(strm);\n };\n const deflateInit = (strm, level) => {\n return deflateInit2(strm, level, Z_DEFLATED2, MAX_WBITS2, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n };\n const deflate$12 = (strm, flush) => {\n if (deflateStateCheck(strm) || flush > Z_BLOCK2 || flush < 0) {\n return strm ? err(strm, Z_STREAM_ERROR2) : Z_STREAM_ERROR2;\n }\n const s = strm.state;\n if (!strm.output || strm.avail_in !== 0 && !strm.input || s.status === FINISH_STATE && flush !== Z_FINISH2) {\n return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR2 : Z_STREAM_ERROR2);\n }\n const old_flush = s.last_flush;\n s.last_flush = flush;\n if (s.pending !== 0) {\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH2) {\n return err(strm, Z_BUF_ERROR2);\n }\n if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n return err(strm, Z_BUF_ERROR2);\n }\n if (s.status === INIT_STATE && s.wrap === 0) {\n s.status = BUSY_STATE;\n }\n if (s.status === INIT_STATE) {\n let header = Z_DEFLATED2 + (s.w_bits - 8 << 4) << 8;\n let level_flags = -1;\n if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n level_flags = 0;\n } else if (s.level < 6) {\n level_flags = 1;\n } else if (s.level === 6) {\n level_flags = 2;\n } else {\n level_flags = 3;\n }\n header |= level_flags << 6;\n if (s.strstart !== 0) {\n header |= PRESET_DICT;\n }\n header += 31 - header % 31;\n putShortMSB(s, header);\n if (s.strstart !== 0) {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 65535);\n }\n strm.adler = 1;\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n if (s.status === GZIP_STATE) {\n strm.adler = 0;\n put_byte(s, 31);\n put_byte(s, 139);\n put_byte(s, 8);\n if (!s.gzhead) {\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, 0);\n put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);\n put_byte(s, OS_CODE);\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n } else {\n put_byte(\n s,\n (s.gzhead.text ? 1 : 0) + (s.gzhead.hcrc ? 2 : 0) + (!s.gzhead.extra ? 0 : 4) + (!s.gzhead.name ? 0 : 8) + (!s.gzhead.comment ? 0 : 16)\n );\n put_byte(s, s.gzhead.time & 255);\n put_byte(s, s.gzhead.time >> 8 & 255);\n put_byte(s, s.gzhead.time >> 16 & 255);\n put_byte(s, s.gzhead.time >> 24 & 255);\n put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);\n put_byte(s, s.gzhead.os & 255);\n if (s.gzhead.extra && s.gzhead.extra.length) {\n put_byte(s, s.gzhead.extra.length & 255);\n put_byte(s, s.gzhead.extra.length >> 8 & 255);\n }\n if (s.gzhead.hcrc) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending, 0);\n }\n s.gzindex = 0;\n s.status = EXTRA_STATE;\n }\n }\n if (s.status === EXTRA_STATE) {\n if (s.gzhead.extra) {\n let beg = s.pending;\n let left = (s.gzhead.extra.length & 65535) - s.gzindex;\n while (s.pending + left > s.pending_buf_size) {\n let copy = s.pending_buf_size - s.pending;\n s.pending_buf.set(s.gzhead.extra.subarray(s.gzindex, s.gzindex + copy), s.pending);\n s.pending = s.pending_buf_size;\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex += copy;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n left -= copy;\n }\n let gzhead_extra = new Uint8Array(s.gzhead.extra);\n s.pending_buf.set(gzhead_extra.subarray(s.gzindex, s.gzindex + left), s.pending);\n s.pending += left;\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex = 0;\n }\n s.status = NAME_STATE;\n }\n if (s.status === NAME_STATE) {\n if (s.gzhead.name) {\n let beg = s.pending;\n let val;\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n }\n if (s.gzindex < s.gzhead.name.length) {\n val = s.gzhead.name.charCodeAt(s.gzindex++) & 255;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n s.gzindex = 0;\n }\n s.status = COMMENT_STATE;\n }\n if (s.status === COMMENT_STATE) {\n if (s.gzhead.comment) {\n let beg = s.pending;\n let val;\n do {\n if (s.pending === s.pending_buf_size) {\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n beg = 0;\n }\n if (s.gzindex < s.gzhead.comment.length) {\n val = s.gzhead.comment.charCodeAt(s.gzindex++) & 255;\n } else {\n val = 0;\n }\n put_byte(s, val);\n } while (val !== 0);\n if (s.gzhead.hcrc && s.pending > beg) {\n strm.adler = crc322(strm.adler, s.pending_buf, s.pending - beg, beg);\n }\n }\n s.status = HCRC_STATE;\n }\n if (s.status === HCRC_STATE) {\n if (s.gzhead.hcrc) {\n if (s.pending + 2 > s.pending_buf_size) {\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n put_byte(s, strm.adler & 255);\n put_byte(s, strm.adler >> 8 & 255);\n strm.adler = 0;\n }\n s.status = BUSY_STATE;\n flush_pending(strm);\n if (s.pending !== 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH2 && s.status !== FINISH_STATE) {\n let bstate = s.level === 0 ? deflate_stored(s, flush) : s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s.strategy === Z_RLE ? deflate_rle(s, flush) : configuration_table[s.level].func(s, flush);\n if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n s.status = FINISH_STATE;\n }\n if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n }\n return Z_OK2;\n }\n if (bstate === BS_BLOCK_DONE) {\n if (flush === Z_PARTIAL_FLUSH) {\n _tr_align(s);\n } else if (flush !== Z_BLOCK2) {\n _tr_stored_block(s, 0, 0, false);\n if (flush === Z_FULL_FLUSH) {\n zero(s.head);\n if (s.lookahead === 0) {\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n }\n }\n flush_pending(strm);\n if (strm.avail_out === 0) {\n s.last_flush = -1;\n return Z_OK2;\n }\n }\n }\n if (flush !== Z_FINISH2) {\n return Z_OK2;\n }\n if (s.wrap <= 0) {\n return Z_STREAM_END2;\n }\n if (s.wrap === 2) {\n put_byte(s, strm.adler & 255);\n put_byte(s, strm.adler >> 8 & 255);\n put_byte(s, strm.adler >> 16 & 255);\n put_byte(s, strm.adler >> 24 & 255);\n put_byte(s, strm.total_in & 255);\n put_byte(s, strm.total_in >> 8 & 255);\n put_byte(s, strm.total_in >> 16 & 255);\n put_byte(s, strm.total_in >> 24 & 255);\n } else {\n putShortMSB(s, strm.adler >>> 16);\n putShortMSB(s, strm.adler & 65535);\n }\n flush_pending(strm);\n if (s.wrap > 0) {\n s.wrap = -s.wrap;\n }\n return s.pending !== 0 ? Z_OK2 : Z_STREAM_END2;\n };\n const deflateEnd = (strm) => {\n if (deflateStateCheck(strm)) {\n return Z_STREAM_ERROR2;\n }\n const status = strm.state.status;\n strm.state = null;\n return status === BUSY_STATE ? err(strm, Z_DATA_ERROR2) : Z_OK2;\n };\n const deflateSetDictionary = (strm, dictionary) => {\n let dictLength = dictionary.length;\n if (deflateStateCheck(strm)) {\n return Z_STREAM_ERROR2;\n }\n const s = strm.state;\n const wrap = s.wrap;\n if (wrap === 2 || wrap === 1 && s.status !== INIT_STATE || s.lookahead) {\n return Z_STREAM_ERROR2;\n }\n if (wrap === 1) {\n strm.adler = adler322(strm.adler, dictionary, dictLength, 0);\n }\n s.wrap = 0;\n if (dictLength >= s.w_size) {\n if (wrap === 0) {\n zero(s.head);\n s.strstart = 0;\n s.block_start = 0;\n s.insert = 0;\n }\n let tmpDict = new Uint8Array(s.w_size);\n tmpDict.set(dictionary.subarray(dictLength - s.w_size, dictLength), 0);\n dictionary = tmpDict;\n dictLength = s.w_size;\n }\n const avail = strm.avail_in;\n const next = strm.next_in;\n const input = strm.input;\n strm.avail_in = dictLength;\n strm.next_in = 0;\n strm.input = dictionary;\n fill_window(s);\n while (s.lookahead >= MIN_MATCH) {\n let str = s.strstart;\n let n = s.lookahead - (MIN_MATCH - 1);\n do {\n s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);\n s.prev[str & s.w_mask] = s.head[s.ins_h];\n s.head[s.ins_h] = str;\n str++;\n } while (--n);\n s.strstart = str;\n s.lookahead = MIN_MATCH - 1;\n fill_window(s);\n }\n s.strstart += s.lookahead;\n s.block_start = s.strstart;\n s.insert = s.lookahead;\n s.lookahead = 0;\n s.match_length = s.prev_length = MIN_MATCH - 1;\n s.match_available = 0;\n strm.next_in = next;\n strm.input = input;\n strm.avail_in = avail;\n s.wrap = wrap;\n return Z_OK2;\n };\n deflate.deflateInit = deflateInit;\n deflate.deflateInit2 = deflateInit2;\n deflate.deflateReset = deflateReset;\n deflate.deflateResetKeep = deflateResetKeep;\n deflate.deflateSetHeader = deflateSetHeader;\n deflate.deflate = deflate$12;\n deflate.deflateEnd = deflateEnd;\n deflate.deflateSetDictionary = deflateSetDictionary;\n deflate.deflateInfo = "pako deflate (from Nodeca project)";\n return deflate;\n}\nvar common = {};\nvar hasRequiredCommon;\nfunction requireCommon() {\n if (hasRequiredCommon) return common;\n hasRequiredCommon = 1;\n const _has2 = (obj, key) => {\n return Object.prototype.hasOwnProperty.call(obj, key);\n };\n common.assign = function(obj) {\n const sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n const source = sources.shift();\n if (!source) {\n continue;\n }\n if (typeof source !== "object") {\n throw new TypeError(source + "must be non-object");\n }\n for (const p in source) {\n if (_has2(source, p)) {\n obj[p] = source[p];\n }\n }\n }\n return obj;\n };\n common.flattenChunks = (chunks) => {\n let len = 0;\n for (let i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n const result = new Uint8Array(len);\n for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {\n let chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n return result;\n };\n return common;\n}\nvar strings = {};\nvar hasRequiredStrings;\nfunction requireStrings() {\n if (hasRequiredStrings) return strings;\n hasRequiredStrings = 1;\n let STR_APPLY_UIA_OK2 = true;\n try {\n String.fromCharCode.apply(null, new Uint8Array(1));\n } catch (__) {\n STR_APPLY_UIA_OK2 = false;\n }\n const _utf8len2 = new Uint8Array(256);\n for (let q = 0; q < 256; q++) {\n _utf8len2[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;\n }\n _utf8len2[254] = _utf8len2[254] = 1;\n strings.string2buf = (str) => {\n if (typeof TextEncoder === "function" && TextEncoder.prototype.encode) {\n return new TextEncoder().encode(str);\n }\n let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;\n }\n buf = new Uint8Array(buf_len);\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 64512) === 55296 && m_pos + 1 < str_len) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 64512) === 56320) {\n c = 65536 + (c - 55296 << 10) + (c2 - 56320);\n m_pos++;\n }\n }\n if (c < 128) {\n buf[i++] = c;\n } else if (c < 2048) {\n buf[i++] = 192 | c >>> 6;\n buf[i++] = 128 | c & 63;\n } else if (c < 65536) {\n buf[i++] = 224 | c >>> 12;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n } else {\n buf[i++] = 240 | c >>> 18;\n buf[i++] = 128 | c >>> 12 & 63;\n buf[i++] = 128 | c >>> 6 & 63;\n buf[i++] = 128 | c & 63;\n }\n }\n return buf;\n };\n const buf2binstring2 = (buf, len) => {\n if (len < 65534) {\n if (buf.subarray && STR_APPLY_UIA_OK2) {\n return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));\n }\n }\n let result = "";\n for (let i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n };\n strings.buf2string = (buf, max) => {\n const len = max || buf.length;\n if (typeof TextDecoder === "function" && TextDecoder.prototype.decode) {\n return new TextDecoder().decode(buf.subarray(0, max));\n }\n let i, out;\n const utf16buf = new Array(len * 2);\n for (out = 0, i = 0; i < len; ) {\n let c = buf[i++];\n if (c < 128) {\n utf16buf[out++] = c;\n continue;\n }\n let c_len = _utf8len2[c];\n if (c_len > 4) {\n utf16buf[out++] = 65533;\n i += c_len - 1;\n continue;\n }\n c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;\n while (c_len > 1 && i < len) {\n c = c << 6 | buf[i++] & 63;\n c_len--;\n }\n if (c_len > 1) {\n utf16buf[out++] = 65533;\n continue;\n }\n if (c < 65536) {\n utf16buf[out++] = c;\n } else {\n c -= 65536;\n utf16buf[out++] = 55296 | c >> 10 & 1023;\n utf16buf[out++] = 56320 | c & 1023;\n }\n }\n return buf2binstring2(utf16buf, out);\n };\n strings.utf8border = (buf, max) => {\n max = max || buf.length;\n if (max > buf.length) {\n max = buf.length;\n }\n let pos = max - 1;\n while (pos >= 0 && (buf[pos] & 192) === 128) {\n pos--;\n }\n if (pos < 0) {\n return max;\n }\n if (pos === 0) {\n return max;\n }\n return pos + _utf8len2[buf[pos]] > max ? pos : max;\n };\n return strings;\n}\nvar zstream;\nvar hasRequiredZstream;\nfunction requireZstream() {\n if (hasRequiredZstream) return zstream;\n hasRequiredZstream = 1;\n function ZStream2() {\n this.input = null;\n this.next_in = 0;\n this.avail_in = 0;\n this.total_in = 0;\n this.output = null;\n this.next_out = 0;\n this.avail_out = 0;\n this.total_out = 0;\n this.msg = "";\n this.state = null;\n this.data_type = 2;\n this.adler = 0;\n }\n zstream = ZStream2;\n return zstream;\n}\nvar hasRequiredDeflate;\nfunction requireDeflate() {\n if (hasRequiredDeflate) return deflate$1;\n hasRequiredDeflate = 1;\n const zlib_deflate = requireDeflate$1();\n const utils = requireCommon();\n const strings2 = requireStrings();\n const msg = requireMessages();\n const ZStream2 = requireZstream();\n const toString2 = Object.prototype.toString;\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_SYNC_FLUSH,\n Z_FULL_FLUSH,\n Z_FINISH: Z_FINISH2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_DEFAULT_COMPRESSION,\n Z_DEFAULT_STRATEGY,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n function Deflate(options) {\n this.options = utils.assign({\n level: Z_DEFAULT_COMPRESSION,\n method: Z_DEFLATED2,\n chunkSize: 16384,\n windowBits: 15,\n memLevel: 8,\n strategy: Z_DEFAULT_STRATEGY\n }, options || {});\n let opt = this.options;\n if (opt.raw && opt.windowBits > 0) {\n opt.windowBits = -opt.windowBits;\n } else if (opt.gzip && opt.windowBits > 0 && opt.windowBits < 16) {\n opt.windowBits += 16;\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new ZStream2();\n this.strm.avail_out = 0;\n let status = zlib_deflate.deflateInit2(\n this.strm,\n opt.level,\n opt.method,\n opt.windowBits,\n opt.memLevel,\n opt.strategy\n );\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n if (opt.header) {\n zlib_deflate.deflateSetHeader(this.strm, opt.header);\n }\n if (opt.dictionary) {\n let dict;\n if (typeof opt.dictionary === "string") {\n dict = strings2.string2buf(opt.dictionary);\n } else if (toString2.call(opt.dictionary) === "[object ArrayBuffer]") {\n dict = new Uint8Array(opt.dictionary);\n } else {\n dict = opt.dictionary;\n }\n status = zlib_deflate.deflateSetDictionary(this.strm, dict);\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n this._dict_set = true;\n }\n }\n Deflate.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n let status, _flush_mode;\n if (this.ended) {\n return false;\n }\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH2 : Z_NO_FLUSH2;\n if (typeof data === "string") {\n strm.input = strings2.string2buf(data);\n } else if (toString2.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n for (; ; ) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n if ((_flush_mode === Z_SYNC_FLUSH || _flush_mode === Z_FULL_FLUSH) && strm.avail_out <= 6) {\n this.onData(strm.output.subarray(0, strm.next_out));\n strm.avail_out = 0;\n continue;\n }\n status = zlib_deflate.deflate(strm, _flush_mode);\n if (status === Z_STREAM_END2) {\n if (strm.next_out > 0) {\n this.onData(strm.output.subarray(0, strm.next_out));\n }\n status = zlib_deflate.deflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK2;\n }\n if (strm.avail_out === 0) {\n this.onData(strm.output);\n continue;\n }\n if (_flush_mode > 0 && strm.next_out > 0) {\n this.onData(strm.output.subarray(0, strm.next_out));\n strm.avail_out = 0;\n continue;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n };\n Deflate.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n };\n Deflate.prototype.onEnd = function(status) {\n if (status === Z_OK2) {\n this.result = utils.flattenChunks(this.chunks);\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n function deflate2(input, options) {\n const deflator = new Deflate(options);\n deflator.push(input, true);\n if (deflator.err) {\n throw deflator.msg || msg[deflator.err];\n }\n return deflator.result;\n }\n function deflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return deflate2(input, options);\n }\n function gzip(input, options) {\n options = options || {};\n options.gzip = true;\n return deflate2(input, options);\n }\n deflate$1.Deflate = Deflate;\n deflate$1.deflate = deflate2;\n deflate$1.deflateRaw = deflateRaw;\n deflate$1.gzip = gzip;\n deflate$1.constants = requireConstants();\n return deflate$1;\n}\nvar inflate$1 = {};\nvar inflate = {};\nvar inffast;\nvar hasRequiredInffast;\nfunction requireInffast() {\n if (hasRequiredInffast) return inffast;\n hasRequiredInffast = 1;\n const BAD2 = 16209;\n const TYPE2 = 16191;\n inffast = function inflate_fast2(strm, start) {\n let _in;\n let last;\n let _out;\n let beg;\n let end;\n let dmax;\n let wsize;\n let whave;\n let wnext;\n let s_window;\n let hold;\n let bits;\n let lcode;\n let dcode;\n let lmask;\n let dmask;\n let here;\n let op;\n let len;\n let dist;\n let from;\n let from_source;\n let input, output;\n const state = strm.state;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n dmax = state.dmax;\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = lcode[hold & lmask];\n dolen:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op === 0) {\n output[_out++] = here & 65535;\n } else if (op & 16) {\n len = here & 65535;\n op &= 15;\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & (1 << op) - 1;\n hold >>>= op;\n bits -= op;\n }\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n dodist:\n for (; ; ) {\n op = here >>> 24;\n hold >>>= op;\n bits -= op;\n op = here >>> 16 & 255;\n if (op & 16) {\n dist = here & 65535;\n op &= 15;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & (1 << op) - 1;\n if (dist > dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break top;\n }\n hold >>>= op;\n bits -= op;\n op = _out - beg;\n if (dist > op) {\n op = dist - op;\n if (op > whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break top;\n }\n }\n from = 0;\n from_source = s_window;\n if (wnext === 0) {\n from += wsize - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n } else if (wnext < op) {\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) {\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n } else {\n from += wnext - op;\n if (op < len) {\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist;\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n } else {\n from = _out - dist;\n do {\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n } else if ((op & 64) === 0) {\n here = dcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dodist;\n } else {\n strm.msg = "invalid distance code";\n state.mode = BAD2;\n break top;\n }\n break;\n }\n } else if ((op & 64) === 0) {\n here = lcode[(here & 65535) + (hold & (1 << op) - 1)];\n continue dolen;\n } else if (op & 32) {\n state.mode = TYPE2;\n break top;\n } else {\n strm.msg = "invalid literal/length code";\n state.mode = BAD2;\n break top;\n }\n break;\n }\n } while (_in < last && _out < end);\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);\n strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);\n state.hold = hold;\n state.bits = bits;\n return;\n };\n return inffast;\n}\nvar inftrees;\nvar hasRequiredInftrees;\nfunction requireInftrees() {\n if (hasRequiredInftrees) return inftrees;\n hasRequiredInftrees = 1;\n const MAXBITS2 = 15;\n const ENOUGH_LENS2 = 852;\n const ENOUGH_DISTS2 = 592;\n const CODES2 = 0;\n const LENS2 = 1;\n const DISTS2 = 2;\n const lbase2 = new Uint16Array([\n /* Length codes 257..285 base */\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 13,\n 15,\n 17,\n 19,\n 23,\n 27,\n 31,\n 35,\n 43,\n 51,\n 59,\n 67,\n 83,\n 99,\n 115,\n 131,\n 163,\n 195,\n 227,\n 258,\n 0,\n 0\n ]);\n const lext2 = new Uint8Array([\n /* Length codes 257..285 extra */\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 17,\n 17,\n 18,\n 18,\n 18,\n 18,\n 19,\n 19,\n 19,\n 19,\n 20,\n 20,\n 20,\n 20,\n 21,\n 21,\n 21,\n 21,\n 16,\n 72,\n 78\n ]);\n const dbase2 = new Uint16Array([\n /* Distance codes 0..29 base */\n 1,\n 2,\n 3,\n 4,\n 5,\n 7,\n 9,\n 13,\n 17,\n 25,\n 33,\n 49,\n 65,\n 97,\n 129,\n 193,\n 257,\n 385,\n 513,\n 769,\n 1025,\n 1537,\n 2049,\n 3073,\n 4097,\n 6145,\n 8193,\n 12289,\n 16385,\n 24577,\n 0,\n 0\n ]);\n const dext2 = new Uint8Array([\n /* Distance codes 0..29 extra */\n 16,\n 16,\n 16,\n 16,\n 17,\n 17,\n 18,\n 18,\n 19,\n 19,\n 20,\n 20,\n 21,\n 21,\n 22,\n 22,\n 23,\n 23,\n 24,\n 24,\n 25,\n 25,\n 26,\n 26,\n 27,\n 27,\n 28,\n 28,\n 29,\n 29,\n 64,\n 64\n ]);\n const inflate_table2 = (type, lens, lens_index, codes, table, table_index, work, opts) => {\n const bits = opts.bits;\n let len = 0;\n let sym = 0;\n let min = 0, max = 0;\n let root = 0;\n let curr = 0;\n let drop = 0;\n let left = 0;\n let used = 0;\n let huff = 0;\n let incr;\n let fill;\n let low;\n let mask;\n let next;\n let base = null;\n let match;\n const count = new Uint16Array(MAXBITS2 + 1);\n const offs = new Uint16Array(MAXBITS2 + 1);\n let extra = null;\n let here_bits, here_op, here_val;\n for (len = 0; len <= MAXBITS2; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n root = bits;\n for (max = MAXBITS2; max >= 1; max--) {\n if (count[max] !== 0) {\n break;\n }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) {\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n table[table_index++] = 1 << 24 | 64 << 16 | 0;\n opts.bits = 1;\n return 0;\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) {\n break;\n }\n }\n if (root < min) {\n root = min;\n }\n left = 1;\n for (len = 1; len <= MAXBITS2; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n }\n }\n if (left > 0 && (type === CODES2 || max !== 1)) {\n return -1;\n }\n offs[1] = 0;\n for (len = 1; len < MAXBITS2; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n if (type === CODES2) {\n base = extra = work;\n match = 20;\n } else if (type === LENS2) {\n base = lbase2;\n extra = lext2;\n match = 257;\n } else {\n base = dbase2;\n extra = dext2;\n match = 0;\n }\n huff = 0;\n sym = 0;\n len = min;\n next = table_index;\n curr = root;\n drop = 0;\n low = -1;\n used = 1 << root;\n mask = used - 1;\n if (type === LENS2 && used > ENOUGH_LENS2 || type === DISTS2 && used > ENOUGH_DISTS2) {\n return 1;\n }\n for (; ; ) {\n here_bits = len - drop;\n if (work[sym] + 1 < match) {\n here_op = 0;\n here_val = work[sym];\n } else if (work[sym] >= match) {\n here_op = extra[work[sym] - match];\n here_val = base[work[sym] - match];\n } else {\n here_op = 32 + 64;\n here_val = 0;\n }\n incr = 1 << len - drop;\n fill = 1 << curr;\n min = fill;\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;\n } while (fill !== 0);\n incr = 1 << len - 1;\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n sym++;\n if (--count[len] === 0) {\n if (len === max) {\n break;\n }\n len = lens[lens_index + work[sym]];\n }\n if (len > root && (huff & mask) !== low) {\n if (drop === 0) {\n drop = root;\n }\n next += min;\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) {\n break;\n }\n curr++;\n left <<= 1;\n }\n used += 1 << curr;\n if (type === LENS2 && used > ENOUGH_LENS2 || type === DISTS2 && used > ENOUGH_DISTS2) {\n return 1;\n }\n low = huff & mask;\n table[low] = root << 24 | curr << 16 | next - table_index | 0;\n }\n }\n if (huff !== 0) {\n table[next + huff] = len - drop << 24 | 64 << 16 | 0;\n }\n opts.bits = root;\n return 0;\n };\n inftrees = inflate_table2;\n return inftrees;\n}\nvar hasRequiredInflate$1;\nfunction requireInflate$1() {\n if (hasRequiredInflate$1) return inflate;\n hasRequiredInflate$1 = 1;\n const adler322 = requireAdler32();\n const crc322 = requireCrc32$1();\n const inflate_fast2 = requireInffast();\n const inflate_table2 = requireInftrees();\n const CODES2 = 0;\n const LENS2 = 1;\n const DISTS2 = 2;\n const {\n Z_FINISH: Z_FINISH2,\n Z_BLOCK: Z_BLOCK2,\n Z_TREES: Z_TREES2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_NEED_DICT: Z_NEED_DICT2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_MEM_ERROR: Z_MEM_ERROR2,\n Z_BUF_ERROR: Z_BUF_ERROR2,\n Z_DEFLATED: Z_DEFLATED2\n } = requireConstants();\n const HEAD2 = 16180;\n const FLAGS2 = 16181;\n const TIME2 = 16182;\n const OS2 = 16183;\n const EXLEN2 = 16184;\n const EXTRA2 = 16185;\n const NAME2 = 16186;\n const COMMENT2 = 16187;\n const HCRC2 = 16188;\n const DICTID2 = 16189;\n const DICT2 = 16190;\n const TYPE2 = 16191;\n const TYPEDO2 = 16192;\n const STORED2 = 16193;\n const COPY_2 = 16194;\n const COPY2 = 16195;\n const TABLE2 = 16196;\n const LENLENS2 = 16197;\n const CODELENS2 = 16198;\n const LEN_2 = 16199;\n const LEN2 = 16200;\n const LENEXT2 = 16201;\n const DIST2 = 16202;\n const DISTEXT2 = 16203;\n const MATCH2 = 16204;\n const LIT2 = 16205;\n const CHECK2 = 16206;\n const LENGTH2 = 16207;\n const DONE2 = 16208;\n const BAD2 = 16209;\n const MEM2 = 16210;\n const SYNC2 = 16211;\n const ENOUGH_LENS2 = 852;\n const ENOUGH_DISTS2 = 592;\n const MAX_WBITS2 = 15;\n const DEF_WBITS2 = MAX_WBITS2;\n const zswap322 = (q) => {\n return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);\n };\n function InflateState2() {\n this.strm = null;\n this.mode = 0;\n this.last = false;\n this.wrap = 0;\n this.havedict = false;\n this.flags = 0;\n this.dmax = 0;\n this.check = 0;\n this.total = 0;\n this.head = null;\n this.wbits = 0;\n this.wsize = 0;\n this.whave = 0;\n this.wnext = 0;\n this.window = null;\n this.hold = 0;\n this.bits = 0;\n this.length = 0;\n this.offset = 0;\n this.extra = 0;\n this.lencode = null;\n this.distcode = null;\n this.lenbits = 0;\n this.distbits = 0;\n this.ncode = 0;\n this.nlen = 0;\n this.ndist = 0;\n this.have = 0;\n this.next = null;\n this.lens = new Uint16Array(320);\n this.work = new Uint16Array(288);\n this.lendyn = null;\n this.distdyn = null;\n this.sane = 0;\n this.back = 0;\n this.was = 0;\n }\n const inflateStateCheck2 = (strm) => {\n if (!strm) {\n return 1;\n }\n const state = strm.state;\n if (!state || state.strm !== strm || state.mode < HEAD2 || state.mode > SYNC2) {\n return 1;\n }\n return 0;\n };\n const inflateResetKeep2 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = "";\n if (state.wrap) {\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD2;\n state.last = 0;\n state.havedict = 0;\n state.flags = -1;\n state.dmax = 32768;\n state.head = null;\n state.hold = 0;\n state.bits = 0;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS2);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS2);\n state.sane = 1;\n state.back = -1;\n return Z_OK2;\n };\n const inflateReset3 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep2(strm);\n };\n const inflateReset22 = (strm, windowBits) => {\n let wrap;\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n } else {\n wrap = (windowBits >> 4) + 5;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR2;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset3(strm);\n };\n const inflateInit22 = (strm, windowBits) => {\n if (!strm) {\n return Z_STREAM_ERROR2;\n }\n const state = new InflateState2();\n strm.state = state;\n state.strm = strm;\n state.window = null;\n state.mode = HEAD2;\n const ret = inflateReset22(strm, windowBits);\n if (ret !== Z_OK2) {\n strm.state = null;\n }\n return ret;\n };\n const inflateInit3 = (strm) => {\n return inflateInit22(strm, DEF_WBITS2);\n };\n let virgin2 = true;\n let lenfix2, distfix2;\n const fixedtables2 = (state) => {\n if (virgin2) {\n lenfix2 = new Int32Array(512);\n distfix2 = new Int32Array(32);\n let sym = 0;\n while (sym < 144) {\n state.lens[sym++] = 8;\n }\n while (sym < 256) {\n state.lens[sym++] = 9;\n }\n while (sym < 280) {\n state.lens[sym++] = 7;\n }\n while (sym < 288) {\n state.lens[sym++] = 8;\n }\n inflate_table2(LENS2, state.lens, 0, 288, lenfix2, 0, state.work, { bits: 9 });\n sym = 0;\n while (sym < 32) {\n state.lens[sym++] = 5;\n }\n inflate_table2(DISTS2, state.lens, 0, 32, distfix2, 0, state.work, { bits: 5 });\n virgin2 = false;\n }\n state.lencode = lenfix2;\n state.lenbits = 9;\n state.distcode = distfix2;\n state.distbits = 5;\n };\n const updatewindow2 = (strm, src, end, copy) => {\n let dist;\n const state = strm.state;\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n state.window = new Uint8Array(state.wsize);\n }\n if (copy >= state.wsize) {\n state.window.set(src.subarray(end - state.wsize, end), 0);\n state.wnext = 0;\n state.whave = state.wsize;\n } else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);\n copy -= dist;\n if (copy) {\n state.window.set(src.subarray(end - copy, end), 0);\n state.wnext = copy;\n state.whave = state.wsize;\n } else {\n state.wnext += dist;\n if (state.wnext === state.wsize) {\n state.wnext = 0;\n }\n if (state.whave < state.wsize) {\n state.whave += dist;\n }\n }\n }\n return 0;\n };\n const inflate$12 = (strm, flush) => {\n let state;\n let input, output;\n let next;\n let put;\n let have, left;\n let hold;\n let bits;\n let _in, _out;\n let copy;\n let from;\n let from_source;\n let here = 0;\n let here_bits, here_op, here_val;\n let last_bits, last_op, last_val;\n let len;\n let ret;\n const hbuf = new Uint8Array(4);\n let opts;\n let n;\n const order = (\n /* permutation of code lengths */\n new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])\n );\n if (inflateStateCheck2(strm) || !strm.output || !strm.input && strm.avail_in !== 0) {\n return Z_STREAM_ERROR2;\n }\n state = strm.state;\n if (state.mode === TYPE2) {\n state.mode = TYPEDO2;\n }\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n _in = have;\n _out = left;\n ret = Z_OK2;\n inf_leave:\n for (; ; ) {\n switch (state.mode) {\n case HEAD2:\n if (state.wrap === 0) {\n state.mode = TYPEDO2;\n break;\n }\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 2 && hold === 35615) {\n if (state.wbits === 0) {\n state.wbits = 15;\n }\n state.check = 0;\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n hold = 0;\n bits = 0;\n state.mode = FLAGS2;\n break;\n }\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 255) << 8) + (hold >> 8)) % 31) {\n strm.msg = "incorrect header check";\n state.mode = BAD2;\n break;\n }\n if ((hold & 15) !== Z_DEFLATED2) {\n strm.msg = "unknown compression method";\n state.mode = BAD2;\n break;\n }\n hold >>>= 4;\n bits -= 4;\n len = (hold & 15) + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n if (len > 15 || len > state.wbits) {\n strm.msg = "invalid window size";\n state.mode = BAD2;\n break;\n }\n state.dmax = 1 << state.wbits;\n state.flags = 0;\n strm.adler = state.check = 1;\n state.mode = hold & 512 ? DICTID2 : TYPE2;\n hold = 0;\n bits = 0;\n break;\n case FLAGS2:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.flags = hold;\n if ((state.flags & 255) !== Z_DEFLATED2) {\n strm.msg = "unknown compression method";\n state.mode = BAD2;\n break;\n }\n if (state.flags & 57344) {\n strm.msg = "unknown header flags set";\n state.mode = BAD2;\n break;\n }\n if (state.head) {\n state.head.text = hold >> 8 & 1;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = TIME2;\n /* falls through */\n case TIME2:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n hbuf[2] = hold >>> 16 & 255;\n hbuf[3] = hold >>> 24 & 255;\n state.check = crc322(state.check, hbuf, 4, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = OS2;\n /* falls through */\n case OS2:\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.head) {\n state.head.xflags = hold & 255;\n state.head.os = hold >> 8;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n state.mode = EXLEN2;\n /* falls through */\n case EXLEN2:\n if (state.flags & 1024) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 512 && state.wrap & 4) {\n hbuf[0] = hold & 255;\n hbuf[1] = hold >>> 8 & 255;\n state.check = crc322(state.check, hbuf, 2, 0);\n }\n hold = 0;\n bits = 0;\n } else if (state.head) {\n state.head.extra = null;\n }\n state.mode = EXTRA2;\n /* falls through */\n case EXTRA2:\n if (state.flags & 1024) {\n copy = state.length;\n if (copy > have) {\n copy = have;\n }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n state.head.extra = new Uint8Array(state.head.extra_len);\n }\n state.head.extra.set(\n input.subarray(\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n next + copy\n ),\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n }\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) {\n break inf_leave;\n }\n }\n state.length = 0;\n state.mode = NAME2;\n /* falls through */\n case NAME2:\n if (state.flags & 2048) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT2;\n /* falls through */\n case COMMENT2:\n if (state.flags & 4096) {\n if (have === 0) {\n break inf_leave;\n }\n copy = 0;\n do {\n len = input[next + copy++];\n if (state.head && len && state.length < 65536) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 512 && state.wrap & 4) {\n state.check = crc322(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) {\n break inf_leave;\n }\n } else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC2;\n /* falls through */\n case HCRC2:\n if (state.flags & 512) {\n while (bits < 16) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.check & 65535)) {\n strm.msg = "header crc mismatch";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n if (state.head) {\n state.head.hcrc = state.flags >> 9 & 1;\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE2;\n break;\n case DICTID2:\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n strm.adler = state.check = zswap322(hold);\n hold = 0;\n bits = 0;\n state.mode = DICT2;\n /* falls through */\n case DICT2:\n if (state.havedict === 0) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n return Z_NEED_DICT2;\n }\n strm.adler = state.check = 1;\n state.mode = TYPE2;\n /* falls through */\n case TYPE2:\n if (flush === Z_BLOCK2 || flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case TYPEDO2:\n if (state.last) {\n hold >>>= bits & 7;\n bits -= bits & 7;\n state.mode = CHECK2;\n break;\n }\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.last = hold & 1;\n hold >>>= 1;\n bits -= 1;\n switch (hold & 3) {\n case 0:\n state.mode = STORED2;\n break;\n case 1:\n fixedtables2(state);\n state.mode = LEN_2;\n if (flush === Z_TREES2) {\n hold >>>= 2;\n bits -= 2;\n break inf_leave;\n }\n break;\n case 2:\n state.mode = TABLE2;\n break;\n case 3:\n strm.msg = "invalid block type";\n state.mode = BAD2;\n }\n hold >>>= 2;\n bits -= 2;\n break;\n case STORED2:\n hold >>>= bits & 7;\n bits -= bits & 7;\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {\n strm.msg = "invalid stored block lengths";\n state.mode = BAD2;\n break;\n }\n state.length = hold & 65535;\n hold = 0;\n bits = 0;\n state.mode = COPY_2;\n if (flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case COPY_2:\n state.mode = COPY2;\n /* falls through */\n case COPY2:\n copy = state.length;\n if (copy) {\n if (copy > have) {\n copy = have;\n }\n if (copy > left) {\n copy = left;\n }\n if (copy === 0) {\n break inf_leave;\n }\n output.set(input.subarray(next, next + copy), put);\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n state.mode = TYPE2;\n break;\n case TABLE2:\n while (bits < 14) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.nlen = (hold & 31) + 257;\n hold >>>= 5;\n bits -= 5;\n state.ndist = (hold & 31) + 1;\n hold >>>= 5;\n bits -= 5;\n state.ncode = (hold & 15) + 4;\n hold >>>= 4;\n bits -= 4;\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = "too many length or distance symbols";\n state.mode = BAD2;\n break;\n }\n state.have = 0;\n state.mode = LENLENS2;\n /* falls through */\n case LENLENS2:\n while (state.have < state.ncode) {\n while (bits < 3) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.lens[order[state.have++]] = hold & 7;\n hold >>>= 3;\n bits -= 3;\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n state.lencode = state.lendyn;\n state.lenbits = 7;\n opts = { bits: state.lenbits };\n ret = inflate_table2(CODES2, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid code lengths set";\n state.mode = BAD2;\n break;\n }\n state.have = 0;\n state.mode = CODELENS2;\n /* falls through */\n case CODELENS2:\n while (state.have < state.nlen + state.ndist) {\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_val < 16) {\n hold >>>= here_bits;\n bits -= here_bits;\n state.lens[state.have++] = here_val;\n } else {\n if (here_val === 16) {\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n if (state.have === 0) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD2;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 3);\n hold >>>= 2;\n bits -= 2;\n } else if (here_val === 17) {\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 3 + (hold & 7);\n hold >>>= 3;\n bits -= 3;\n } else {\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n len = 0;\n copy = 11 + (hold & 127);\n hold >>>= 7;\n bits -= 7;\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = "invalid bit length repeat";\n state.mode = BAD2;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n if (state.mode === BAD2) {\n break;\n }\n if (state.lens[256] === 0) {\n strm.msg = "invalid code -- missing end-of-block";\n state.mode = BAD2;\n break;\n }\n state.lenbits = 9;\n opts = { bits: state.lenbits };\n ret = inflate_table2(LENS2, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n if (ret) {\n strm.msg = "invalid literal/lengths set";\n state.mode = BAD2;\n break;\n }\n state.distbits = 6;\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table2(DISTS2, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n state.distbits = opts.bits;\n if (ret) {\n strm.msg = "invalid distances set";\n state.mode = BAD2;\n break;\n }\n state.mode = LEN_2;\n if (flush === Z_TREES2) {\n break inf_leave;\n }\n /* falls through */\n case LEN_2:\n state.mode = LEN2;\n /* falls through */\n case LEN2:\n if (have >= 6 && left >= 258) {\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n inflate_fast2(strm, _out);\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n if (state.mode === TYPE2) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (; ; ) {\n here = state.lencode[hold & (1 << state.lenbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (here_op && (here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n state.mode = LIT2;\n break;\n }\n if (here_op & 32) {\n state.back = -1;\n state.mode = TYPE2;\n break;\n }\n if (here_op & 64) {\n strm.msg = "invalid literal/length code";\n state.mode = BAD2;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT2;\n /* falls through */\n case LENEXT2:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.length += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n state.was = state.length;\n state.mode = DIST2;\n /* falls through */\n case DIST2:\n for (; ; ) {\n here = state.distcode[hold & (1 << state.distbits) - 1];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if ((here_op & 240) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (; ; ) {\n here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];\n here_bits = here >>> 24;\n here_op = here >>> 16 & 255;\n here_val = here & 65535;\n if (last_bits + here_bits <= bits) {\n break;\n }\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n hold >>>= last_bits;\n bits -= last_bits;\n state.back += last_bits;\n }\n hold >>>= here_bits;\n bits -= here_bits;\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = "invalid distance code";\n state.mode = BAD2;\n break;\n }\n state.offset = here_val;\n state.extra = here_op & 15;\n state.mode = DISTEXT2;\n /* falls through */\n case DISTEXT2:\n if (state.extra) {\n n = state.extra;\n while (bits < n) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n state.offset += hold & (1 << state.extra) - 1;\n hold >>>= state.extra;\n bits -= state.extra;\n state.back += state.extra;\n }\n if (state.offset > state.dmax) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break;\n }\n state.mode = MATCH2;\n /* falls through */\n case MATCH2:\n if (left === 0) {\n break inf_leave;\n }\n copy = _out - left;\n if (state.offset > copy) {\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = "invalid distance too far back";\n state.mode = BAD2;\n break;\n }\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n } else {\n from = state.wnext - copy;\n }\n if (copy > state.length) {\n copy = state.length;\n }\n from_source = state.window;\n } else {\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) {\n copy = left;\n }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) {\n state.mode = LEN2;\n }\n break;\n case LIT2:\n if (left === 0) {\n break inf_leave;\n }\n output[put++] = state.length;\n left--;\n state.mode = LEN2;\n break;\n case CHECK2:\n if (state.wrap) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold |= input[next++] << bits;\n bits += 8;\n }\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/\n state.flags ? crc322(state.check, output, _out, put - _out) : adler322(state.check, output, _out, put - _out);\n }\n _out = left;\n if (state.wrap & 4 && (state.flags ? hold : zswap322(hold)) !== state.check) {\n strm.msg = "incorrect data check";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = LENGTH2;\n /* falls through */\n case LENGTH2:\n if (state.wrap && state.flags) {\n while (bits < 32) {\n if (have === 0) {\n break inf_leave;\n }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n if (state.wrap & 4 && hold !== (state.total & 4294967295)) {\n strm.msg = "incorrect length check";\n state.mode = BAD2;\n break;\n }\n hold = 0;\n bits = 0;\n }\n state.mode = DONE2;\n /* falls through */\n case DONE2:\n ret = Z_STREAM_END2;\n break inf_leave;\n case BAD2:\n ret = Z_DATA_ERROR2;\n break inf_leave;\n case MEM2:\n return Z_MEM_ERROR2;\n case SYNC2:\n /* falls through */\n default:\n return Z_STREAM_ERROR2;\n }\n }\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n if (state.wsize || _out !== strm.avail_out && state.mode < BAD2 && (state.mode < CHECK2 || flush !== Z_FINISH2)) {\n if (updatewindow2(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap & 4 && _out) {\n strm.adler = state.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/\n state.flags ? crc322(state.check, output, _out, strm.next_out - _out) : adler322(state.check, output, _out, strm.next_out - _out);\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE2 ? 128 : 0) + (state.mode === LEN_2 || state.mode === COPY_2 ? 256 : 0);\n if ((_in === 0 && _out === 0 || flush === Z_FINISH2) && ret === Z_OK2) {\n ret = Z_BUF_ERROR2;\n }\n return ret;\n };\n const inflateEnd2 = (strm) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n let state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK2;\n };\n const inflateGetHeader2 = (strm, head) => {\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n const state = strm.state;\n if ((state.wrap & 2) === 0) {\n return Z_STREAM_ERROR2;\n }\n state.head = head;\n head.done = false;\n return Z_OK2;\n };\n const inflateSetDictionary2 = (strm, dictionary) => {\n const dictLength = dictionary.length;\n let state;\n let dictid;\n let ret;\n if (inflateStateCheck2(strm)) {\n return Z_STREAM_ERROR2;\n }\n state = strm.state;\n if (state.wrap !== 0 && state.mode !== DICT2) {\n return Z_STREAM_ERROR2;\n }\n if (state.mode === DICT2) {\n dictid = 1;\n dictid = adler322(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR2;\n }\n }\n ret = updatewindow2(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM2;\n return Z_MEM_ERROR2;\n }\n state.havedict = 1;\n return Z_OK2;\n };\n inflate.inflateReset = inflateReset3;\n inflate.inflateReset2 = inflateReset22;\n inflate.inflateResetKeep = inflateResetKeep2;\n inflate.inflateInit = inflateInit3;\n inflate.inflateInit2 = inflateInit22;\n inflate.inflate = inflate$12;\n inflate.inflateEnd = inflateEnd2;\n inflate.inflateGetHeader = inflateGetHeader2;\n inflate.inflateSetDictionary = inflateSetDictionary2;\n inflate.inflateInfo = "pako inflate (from Nodeca project)";\n return inflate;\n}\nvar gzheader;\nvar hasRequiredGzheader;\nfunction requireGzheader() {\n if (hasRequiredGzheader) return gzheader;\n hasRequiredGzheader = 1;\n function GZheader2() {\n this.text = 0;\n this.time = 0;\n this.xflags = 0;\n this.os = 0;\n this.extra = null;\n this.extra_len = 0;\n this.name = "";\n this.comment = "";\n this.hcrc = 0;\n this.done = false;\n }\n gzheader = GZheader2;\n return gzheader;\n}\nvar hasRequiredInflate;\nfunction requireInflate() {\n if (hasRequiredInflate) return inflate$1;\n hasRequiredInflate = 1;\n const zlib_inflate = requireInflate$1();\n const utils = requireCommon();\n const strings2 = requireStrings();\n const msg = requireMessages();\n const ZStream2 = requireZstream();\n const GZheader2 = requireGzheader();\n const toString2 = Object.prototype.toString;\n const {\n Z_NO_FLUSH: Z_NO_FLUSH2,\n Z_FINISH: Z_FINISH2,\n Z_OK: Z_OK2,\n Z_STREAM_END: Z_STREAM_END2,\n Z_NEED_DICT: Z_NEED_DICT2,\n Z_STREAM_ERROR: Z_STREAM_ERROR2,\n Z_DATA_ERROR: Z_DATA_ERROR2,\n Z_MEM_ERROR: Z_MEM_ERROR2\n } = requireConstants();\n function Inflate(options) {\n this.options = utils.assign({\n chunkSize: 1024 * 64,\n windowBits: 15,\n to: ""\n }, options || {});\n const opt = this.options;\n if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) {\n opt.windowBits = -15;\n }\n }\n if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n if (opt.windowBits > 15 && opt.windowBits < 48) {\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n this.err = 0;\n this.msg = "";\n this.ended = false;\n this.chunks = [];\n this.strm = new ZStream2();\n this.strm.avail_out = 0;\n let status = zlib_inflate.inflateInit2(\n this.strm,\n opt.windowBits\n );\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n this.header = new GZheader2();\n zlib_inflate.inflateGetHeader(this.strm, this.header);\n if (opt.dictionary) {\n if (typeof opt.dictionary === "string") {\n opt.dictionary = strings2.string2buf(opt.dictionary);\n } else if (toString2.call(opt.dictionary) === "[object ArrayBuffer]") {\n opt.dictionary = new Uint8Array(opt.dictionary);\n }\n if (opt.raw) {\n status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);\n if (status !== Z_OK2) {\n throw new Error(msg[status]);\n }\n }\n }\n }\n Inflate.prototype.push = function(data, flush_mode) {\n const strm = this.strm;\n const chunkSize = this.options.chunkSize;\n const dictionary = this.options.dictionary;\n let status, _flush_mode, last_avail_out;\n if (this.ended) return false;\n if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;\n else _flush_mode = flush_mode === true ? Z_FINISH2 : Z_NO_FLUSH2;\n if (toString2.call(data) === "[object ArrayBuffer]") {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n for (; ; ) {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n status = zlib_inflate.inflate(strm, _flush_mode);\n if (status === Z_NEED_DICT2 && dictionary) {\n status = zlib_inflate.inflateSetDictionary(strm, dictionary);\n if (status === Z_OK2) {\n status = zlib_inflate.inflate(strm, _flush_mode);\n } else if (status === Z_DATA_ERROR2) {\n status = Z_NEED_DICT2;\n }\n }\n while (strm.avail_in > 0 && status === Z_STREAM_END2 && strm.state.wrap > 0 && data[strm.next_in] !== 0) {\n zlib_inflate.inflateReset(strm);\n status = zlib_inflate.inflate(strm, _flush_mode);\n }\n switch (status) {\n case Z_STREAM_ERROR2:\n case Z_DATA_ERROR2:\n case Z_NEED_DICT2:\n case Z_MEM_ERROR2:\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n last_avail_out = strm.avail_out;\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END2) {\n if (this.options.to === "string") {\n let next_out_utf8 = strings2.utf8border(strm.output, strm.next_out);\n let tail = strm.next_out - next_out_utf8;\n let utf8str = strings2.buf2string(strm.output, next_out_utf8);\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);\n this.onData(utf8str);\n } else {\n this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));\n }\n }\n }\n if (status === Z_OK2 && last_avail_out === 0) continue;\n if (status === Z_STREAM_END2) {\n status = zlib_inflate.inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return true;\n }\n if (strm.avail_in === 0) break;\n }\n return true;\n };\n Inflate.prototype.onData = function(chunk) {\n this.chunks.push(chunk);\n };\n Inflate.prototype.onEnd = function(status) {\n if (status === Z_OK2) {\n if (this.options.to === "string") {\n this.result = this.chunks.join("");\n } else {\n this.result = utils.flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n };\n function inflate2(input, options) {\n const inflator = new Inflate(options);\n inflator.push(input);\n if (inflator.err) throw inflator.msg || msg[inflator.err];\n return inflator.result;\n }\n function inflateRaw(input, options) {\n options = options || {};\n options.raw = true;\n return inflate2(input, options);\n }\n inflate$1.Inflate = Inflate;\n inflate$1.inflate = inflate2;\n inflate$1.inflateRaw = inflateRaw;\n inflate$1.ungzip = inflate2;\n inflate$1.constants = requireConstants();\n return inflate$1;\n}\nvar hasRequiredPako;\nfunction requirePako() {\n if (hasRequiredPako) return pako;\n hasRequiredPako = 1;\n const { Deflate, deflate: deflate2, deflateRaw, gzip } = requireDeflate();\n const { Inflate, inflate: inflate2, inflateRaw, ungzip } = requireInflate();\n const constants2 = requireConstants();\n pako.Deflate = Deflate;\n pako.deflate = deflate2;\n pako.deflateRaw = deflateRaw;\n pako.gzip = gzip;\n pako.Inflate = Inflate;\n pako.inflate = inflate2;\n pako.inflateRaw = inflateRaw;\n pako.ungzip = ungzip;\n pako.constants = constants2;\n return pako;\n}\nvar paeth = {};\nvar hasRequiredPaeth;\nfunction requirePaeth() {\n if (hasRequiredPaeth) return paeth;\n hasRequiredPaeth = 1;\n Object.defineProperty(paeth, "__esModule", { value: true });\n paeth.paethPredicator = void 0;\n function paethPredicator(a, b, c) {\n const p = a + b - c;\n const pa = Math.abs(p - a);\n const pb = Math.abs(p - b);\n const pc = Math.abs(p - c);\n if (pa <= pb && pa <= pc) {\n return a;\n }\n if (pb <= pc) {\n return b;\n }\n return c;\n }\n paeth.paethPredicator = paethPredicator;\n return paeth;\n}\nvar hasRequiredChunk_IDAT;\nfunction requireChunk_IDAT() {\n if (hasRequiredChunk_IDAT) return chunk_IDAT;\n hasRequiredChunk_IDAT = 1;\n Object.defineProperty(chunk_IDAT, "__esModule", { value: true });\n chunk_IDAT.parseChunk = void 0;\n const pako2 = requirePako();\n const assert_js_1 = requireAssert$1();\n const paeth_js_1 = requirePaeth();\n function parseChunk(ctx, header, chunks) {\n const decompressed = decompress(ctx, chunks);\n let packed;\n if (header.interlaceMethod === 1) {\n packed = deinterlaceAdam7(ctx, header, decompressed);\n } else {\n packed = defilter(ctx, header, decompressed);\n }\n const trnsChunk = ctx.metadata.find((e) => e.type === "tRNS");\n const result = mapPackedDataToRgba(ctx, header, packed, ctx.palette, trnsChunk);\n if (trnsChunk && (header.colorType === 0 || header.colorType === 2)) {\n applyTransparency(header, result, trnsChunk);\n }\n return result;\n }\n chunk_IDAT.parseChunk = parseChunk;\n function decompress(ctx, chunks) {\n const inflator = new pako2.Inflate();\n let offset = 0;\n for (const chunk of chunks) {\n offset = chunk.offset + 4 + 4;\n inflator.push(ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + offset + chunk.dataLength));\n }\n if (inflator.err) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunks[0], `Inflate error: ${inflator.msg}`, chunks[0].offset);\n }\n if (inflator.result === void 0) {\n throw new assert_js_1.DecodeError(ctx, "IDAT: Failed to decompress data chunks", 0);\n }\n return inflator.result;\n }\n function defilter(ctx, header, decompressed, start = 0, width = header.width, height = header.height) {\n let i = 0;\n const bpp = getBytesPerPixel(header);\n const bppFloat = getBytesPerPixelFloat(header);\n const bpl = getBytesPerLine(header, width);\n const bplCeiled = Math.ceil(width * bppFloat);\n const result = new Uint8Array(height * bplCeiled);\n const filterFnCache = /* @__PURE__ */ new Map();\n for (let y = 0; y < height; y++) {\n let lineOffset = start + y * (bpl + 1);\n const filterType = decompressed[lineOffset++];\n if (!isValidFilterType) {\n throw new assert_js_1.DecodeError(ctx, `IDAT: Invalid filter type ${filterType}`, 0);\n }\n let filterFn = filterFnCache.get(filterType);\n if (!filterFn) {\n filterFn = buildDefilterFunction(bppFloat, bpl, width, filterType);\n filterFnCache.set(filterType, filterFn);\n }\n let pixel = 1;\n let x = 0;\n switch (filterType) {\n case 0:\n case 1: {\n for (; x < bpp; x++) {\n result[i] = decompressed[lineOffset + x];\n i++;\n }\n break;\n }\n case 3: {\n let bi = 0;\n for (; x < bpp; x++) {\n bi = i - width * bpp;\n result[i] = decompressed[lineOffset + x] + Math.floor(0 + (bi < 0 ? 0 : result[bi])) / 2;\n i++;\n }\n break;\n }\n case 2: {\n pixel = 0;\n break;\n }\n case 4: {\n for (; x < bpp; x++) {\n const bi = Math.floor(i - bpl);\n result[i] = (decompressed[lineOffset + x] + (0, paeth_js_1.paethPredicator)(0, bi < 0 ? 0 : result[bi], 0)) % 256;\n i++;\n }\n break;\n }\n }\n if (header.bitDepth >= 8) {\n for (; pixel < width; pixel++) {\n for (let x2 = 0; x2 < bpp; x2++) {\n result[i] = filterFn(decompressed, lineOffset + pixel * bpp + x2, result, i);\n i++;\n }\n }\n } else {\n if (pixel) {\n i -= pixel;\n }\n for (x = pixel; x < bpl; x++) {\n result[i + x] = filterFn(decompressed, lineOffset + x, result, i + x);\n }\n i += bpl;\n }\n }\n return result;\n }\n function isValidFilterType(filterType) {\n return filterType % 1 === 0 && filterType >= 0 && filterType <= 4;\n }\n function buildDefilterFunction(bpp, bpl, width, filterType) {\n let ai = 0, bi = 0, ci = 0;\n switch (filterType) {\n case 0:\n return (filt, filtX) => filt[filtX];\n case 1:\n return (filt, filtX, recon, reconX) => (filt[filtX] + recon[Math.floor(reconX - bpp)]) % 256;\n case 2:\n return (filt, filtX, recon, reconX) => {\n bi = Math.floor(reconX - width * bpp);\n return bi < 0 ? filt[filtX] : (filt[filtX] + recon[bi]) % 256;\n };\n case 3:\n return (filt, filtX, recon, reconX) => {\n ai = Math.floor(reconX - bpp);\n bi = Math.floor(reconX - width * bpp);\n return filt[filtX] + Math.floor((ai < 0 ? 0 : recon[ai]) + (bi < 0 ? 0 : recon[bi])) / 2;\n };\n case 4:\n return (filt, filtX, recon, reconX) => {\n ai = Math.floor(reconX - Math.ceil(bpp));\n bi = Math.floor(reconX - bpl);\n ci = Math.floor(reconX - bpl - Math.ceil(bpp));\n return (filt[filtX] + (0, paeth_js_1.paethPredicator)(ai < 0 ? 0 : recon[ai], bi < 0 ? 0 : recon[bi], ci < 0 ? 0 : recon[ci])) % 256;\n };\n }\n }\n function getBytesPerPixel(header) {\n return Math.ceil(getBytesPerPixelFloat(header));\n }\n function getBytesPerPixelFloat(header) {\n return getChannelCount(header.colorType) * header.bitDepth / 8;\n }\n function getBytesPerLine(header, width) {\n return Math.ceil(getChannelCount(header.colorType) * header.bitDepth * width / 8);\n }\n function getChannelCount(colorType) {\n switch (colorType) {\n case 0:\n return 1;\n case 2:\n return 3;\n case 3:\n return 1;\n case 4:\n return 2;\n case 6:\n return 4;\n }\n }\n function deinterlaceAdam7(ctx, header, decompressed) {\n const bppFloat = getBytesPerPixelFloat(header);\n const bplCeiled = Math.ceil(header.width * bppFloat);\n const result = new Uint8Array(bplCeiled * header.height);\n const bpp = getBytesPerPixel(header);\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const xStart = [0, 4, 0, 2, 0, 1, 0];\n const yStart = [0, 0, 4, 0, 2, 0, 1];\n const xGap = [8, 8, 4, 4, 2, 2, 1];\n const yGap = [8, 8, 8, 4, 4, 2, 2];\n let dataPointer = 0;\n for (let pass = 0; pass < 7; pass++) {\n const passXStart = xStart[pass];\n const passYStart = yStart[pass];\n const passXGap = xGap[pass];\n const passYGap = yGap[pass];\n const passWidth = Math.ceil((header.width - passXStart) / passXGap);\n const passHeight = Math.ceil((header.height - passYStart) / passYGap);\n const passBplCeiled = Math.ceil(bppFloat * passWidth);\n if (passWidth === 0 || passHeight === 0) {\n continue;\n }\n const passPacked = defilter(ctx, header, decompressed, dataPointer, passWidth, passHeight);\n let i = 0;\n for (let y = 0; y < passHeight; y++) {\n i = (passYStart + y * passYGap) * bplCeiled + passXStart * bppFloat;\n for (let x = 0; x < passWidth; x++) {\n if (header.bitDepth < 8) {\n let value = passPacked[y * passBplCeiled + Math.floor(x * bppFloat)];\n value >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n value &= maxValue;\n const resultPosition = (pixelsPerByte - 1 - i % 1 * pixelsPerByte) * header.bitDepth;\n value <<= resultPosition;\n result[Math.floor(i)] |= value;\n } else {\n for (let j = 0; j < bpp; j++) {\n result[i + j] = passPacked[(y * passWidth + x) * bpp + j];\n }\n }\n i += passXGap * bppFloat;\n }\n }\n dataPointer += passHeight * (1 + getBytesPerLine(header, passWidth));\n }\n return result;\n }\n function mapPackedDataToRgba(ctx, header, packed, palette, trnsChunk) {\n const result = new (header.bitDepth === 16 ? Uint16Array : Uint8Array)(header.width * header.height * 4);\n let i = 0;\n const bpp = getBytesPerPixel(header);\n const bppFloat = getBytesPerPixelFloat(header);\n const bplCeiled = Math.ceil(header.width * bppFloat);\n switch (header.colorType) {\n case 0: {\n switch (header.bitDepth) {\n case 1:\n case 2:\n case 4: {\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const bytesPerPixel = header.bitDepth / 8;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n result[i] = packed[y * bplCeiled + Math.floor(x * bytesPerPixel)];\n result[i] >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n result[i] &= maxValue;\n result[i] *= 255 / maxValue;\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n result[i + 3] = 255;\n }\n }\n break;\n }\n case 8:\n case 16: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n }\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n result[i + 3] = header.bitDepth === 16 ? 65535 : 255;\n }\n }\n break;\n }\n }\n break;\n }\n case 4: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n }\n result[i + 1] = result[i];\n result[i + 2] = result[i];\n if (header.bitDepth === 16) {\n result[i + 3] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n } else {\n result[i + 3] = packed[(y * header.width + x) * bpp + 1];\n }\n }\n }\n break;\n }\n case 3: {\n if (!palette) {\n throw new assert_js_1.DecodeError(ctx, "IDAT: Cannot decode indexed color type without a palette", 0);\n }\n switch (header.bitDepth) {\n case 1:\n case 2:\n case 4: {\n const pixelsPerByte = 8 / header.bitDepth;\n const maxValue = (1 << header.bitDepth) - 1;\n const bytesPerPixel = header.bitDepth / 8;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n let colorId = packed[y * bplCeiled + Math.floor(x * bytesPerPixel)];\n colorId >>= (pixelsPerByte - x % pixelsPerByte - 1) * header.bitDepth;\n colorId &= maxValue;\n palette.setRgba(result, i, colorId);\n if (trnsChunk && trnsChunk.transparency.length > colorId) {\n result[i + 3] = trnsChunk.transparency[colorId];\n }\n }\n }\n break;\n }\n case 8: {\n let colorId = 0;\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n colorId = packed[y * header.width + x];\n palette.setRgba(result, i, colorId);\n if (trnsChunk && trnsChunk.transparency.length > colorId) {\n result[i + 3] = trnsChunk.transparency[colorId];\n }\n }\n }\n break;\n }\n }\n break;\n }\n case 2: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n result[i + 1] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n result[i + 2] = packed[(y * header.width + x) * bpp + 4] << 8 | packed[(y * header.width + x) * bpp + 5];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n result[i + 1] = packed[(y * header.width + x) * bpp + 1];\n result[i + 2] = packed[(y * header.width + x) * bpp + 2];\n }\n result[i + 3] = header.bitDepth === 16 ? 65535 : 255;\n }\n }\n break;\n }\n case 6: {\n for (let y = 0; y < header.height; y++) {\n for (let x = 0; x < header.width; x++) {\n i = (y * header.width + x) * 4;\n if (header.bitDepth === 16) {\n result[i] = packed[(y * header.width + x) * bpp] << 8 | packed[(y * header.width + x) * bpp + 1];\n result[i + 1] = packed[(y * header.width + x) * bpp + 2] << 8 | packed[(y * header.width + x) * bpp + 3];\n result[i + 2] = packed[(y * header.width + x) * bpp + 4] << 8 | packed[(y * header.width + x) * bpp + 5];\n result[i + 3] = packed[(y * header.width + x) * bpp + 6] << 8 | packed[(y * header.width + x) * bpp + 7];\n } else {\n result[i] = packed[(y * header.width + x) * bpp];\n result[i + 1] = packed[(y * header.width + x) * bpp + 1];\n result[i + 2] = packed[(y * header.width + x) * bpp + 2];\n result[i + 3] = packed[(y * header.width + x) * bpp + 3];\n }\n }\n }\n break;\n }\n }\n return result;\n }\n function applyTransparency(header, data, trnsChunk) {\n const maxEncodedValue = (1 << header.bitDepth) - 1;\n const maxDataValue = header.bitDepth === 16 ? 65535 : 255;\n if (header.colorType === 0) {\n const shade = maxDataValue / maxEncodedValue * trnsChunk.transparency;\n for (let i = 0; i < data.length; i += 4) {\n if (data[i] === shade) {\n data[i + 3] = 0;\n }\n }\n return;\n }\n if (header.colorType === 2) {\n const channels = [\n maxDataValue / maxEncodedValue * trnsChunk.transparency[0],\n maxDataValue / maxEncodedValue * trnsChunk.transparency[1],\n maxDataValue / maxEncodedValue * trnsChunk.transparency[2]\n ];\n for (let i = 0; i < data.length; i += 4) {\n if (data[i] === channels[0] && data[i + 1] === channels[1] && data[i + 2] === channels[2]) {\n data[i + 3] = 0;\n }\n }\n return;\n }\n }\n return chunk_IDAT;\n}\nvar chunk_IEND = {};\nvar hasRequiredChunk_IEND;\nfunction requireChunk_IEND() {\n if (hasRequiredChunk_IEND) return chunk_IEND;\n hasRequiredChunk_IEND = 1;\n Object.defineProperty(chunk_IEND, "__esModule", { value: true });\n chunk_IEND.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 0);\n }\n chunk_IEND.parseChunk = parseChunk;\n return chunk_IEND;\n}\nvar chunk_IHDR = {};\nvar validate = {};\nvar hasRequiredValidate;\nfunction requireValidate() {\n if (hasRequiredValidate) return validate;\n hasRequiredValidate = 1;\n Object.defineProperty(validate, "__esModule", { value: true });\n validate.isValidInterlaceMethod = validate.isValidFilterMethod = validate.isValidColorType = validate.isValidBitDepth = void 0;\n function isValidBitDepth(bitDepth) {\n return bitDepth === 1 || bitDepth === 2 || bitDepth === 4 || bitDepth === 8 || bitDepth === 16;\n }\n validate.isValidBitDepth = isValidBitDepth;\n function isValidColorType(colorType, bitDepth) {\n return colorType === 0 && bitDepth >= 1 && bitDepth <= 16 || colorType === 2 && bitDepth >= 8 && bitDepth <= 16 || colorType === 3 && bitDepth >= 1 && bitDepth <= 8 || colorType === 4 && bitDepth >= 8 && bitDepth <= 16 || colorType === 6 && bitDepth >= 8 && bitDepth <= 16;\n }\n validate.isValidColorType = isValidColorType;\n function isValidFilterMethod(filterMethod) {\n return filterMethod === 0;\n }\n validate.isValidFilterMethod = isValidFilterMethod;\n function isValidInterlaceMethod(interlaceMethod) {\n return interlaceMethod === 0 || interlaceMethod === 1;\n }\n validate.isValidInterlaceMethod = isValidInterlaceMethod;\n return validate;\n}\nvar hasRequiredChunk_IHDR;\nfunction requireChunk_IHDR() {\n if (hasRequiredChunk_IHDR) return chunk_IHDR;\n hasRequiredChunk_IHDR = 1;\n Object.defineProperty(chunk_IHDR, "__esModule", { value: true });\n chunk_IHDR.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const validate_js_1 = requireValidate();\n function parseChunk(ctx, chunk) {\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 13);\n let offset = chunk.offset + 4 + 4;\n const width = ctx.view.getUint32(offset);\n offset += 4;\n const height = ctx.view.getUint32(offset);\n offset += 4;\n const bitDepth = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidBitDepth)(bitDepth)) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunk, `Bit depth "${bitDepth}" is not valid`, offset);\n }\n offset++;\n const colorType = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidColorType)(colorType, bitDepth)) {\n throw (0, assert_js_1.createChunkDecodeError)(ctx, chunk, `Color type "${colorType}" is not valid with bit depth "${bitDepth}"`, offset);\n }\n offset++;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n let filterMethod = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidFilterMethod)(filterMethod)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Filter method "${filterMethod}" is not valid`, offset));\n filterMethod = 0;\n }\n offset++;\n let interlaceMethod = ctx.view.getUint8(offset);\n if (!(0, validate_js_1.isValidInterlaceMethod)(interlaceMethod)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Interlace method "${interlaceMethod}" is not valid`, offset));\n interlaceMethod = 0;\n }\n offset++;\n return {\n width,\n height,\n bitDepth,\n colorType,\n interlaceMethod\n };\n }\n chunk_IHDR.parseChunk = parseChunk;\n return chunk_IHDR;\n}\nvar crc32 = {};\nvar hasRequiredCrc32;\nfunction requireCrc32() {\n if (hasRequiredCrc32) return crc32;\n hasRequiredCrc32 = 1;\n Object.defineProperty(crc32, "__esModule", { value: true });\n crc32.crc32 = crc32.getCrcTable = void 0;\n let tableInternal;\n function getCrcTable() {\n if (tableInternal) {\n return tableInternal;\n }\n tableInternal = [];\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) {\n if (c & 1) {\n c = 3988292384 ^ c >>> 1;\n } else {\n c = c >>> 1;\n }\n }\n tableInternal[n] = c >>> 0;\n }\n return tableInternal;\n }\n crc32.getCrcTable = getCrcTable;\n function updateCrc(crc, dataView, offset, length) {\n const table = getCrcTable();\n let c = crc;\n for (let n = 0; n < length; n++) {\n c = table[(c ^ dataView.getUint8(offset + n)) & 255] ^ c >>> 8;\n }\n return c;\n }\n function crc32$12(dataView, offset, length) {\n return (updateCrc(4294967295, dataView, offset, length) ^ 4294967295) >>> 0;\n }\n crc32.crc32 = crc32$12;\n return crc32;\n}\nvar chunk_bKGD = {};\nvar hasRequiredChunk_bKGD;\nfunction requireChunk_bKGD() {\n if (hasRequiredChunk_bKGD) return chunk_bKGD;\n hasRequiredChunk_bKGD = 1;\n Object.defineProperty(chunk_bKGD, "__esModule", { value: true });\n chunk_bKGD.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const offset = chunk.offset + 4 + 4;\n let color;\n let expectedLength;\n switch (header.colorType) {\n case 0:\n case 4: {\n color = ctx.view.getUint16(offset);\n expectedLength = 2;\n break;\n }\n case 2:\n case 6: {\n color = [\n ctx.view.getUint16(offset),\n ctx.view.getUint16(offset + 2),\n ctx.view.getUint16(offset + 4)\n ];\n expectedLength = 6;\n break;\n }\n case 3: {\n color = ctx.view.getUint8(offset);\n expectedLength = 1;\n break;\n }\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Unrecognized color type "${header.colorType}"`, offset);\n }\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, expectedLength);\n return { type: "bKGD", color };\n }\n chunk_bKGD.parseChunk = parseChunk;\n return chunk_bKGD;\n}\nvar chunk_cHRM = {};\nvar hasRequiredChunk_cHRM;\nfunction requireChunk_cHRM() {\n if (hasRequiredChunk_cHRM) return chunk_cHRM;\n hasRequiredChunk_cHRM = 1;\n Object.defineProperty(chunk_cHRM, "__esModule", { value: true });\n chunk_cHRM.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 32);\n let offset = chunk.offset + 4 + 4;\n const whitePoint = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (whitePoint.x > 1 || whitePoint.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid white point (${whitePoint.x},${whitePoint.y})`, offset);\n }\n offset += 8;\n const red = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (red.x > 1 || red.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid red (${red.x},${red.y})`, offset);\n }\n offset += 8;\n const green = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (green.x > 1 || green.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid green (${green.x},${green.y})`, offset);\n }\n offset += 8;\n const blue = {\n x: ctx.view.getUint32(offset) / 1e5,\n y: ctx.view.getUint32(offset + 4) / 1e5\n };\n if (blue.x > 1 || blue.y > 1) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid blue (${blue.x},${blue.y})`, offset);\n }\n return {\n type: "cHRM",\n whitePoint,\n red,\n green,\n blue\n };\n }\n chunk_cHRM.parseChunk = parseChunk;\n return chunk_cHRM;\n}\nvar chunk_eXIf = {};\nvar hasRequiredChunk_eXIf;\nfunction requireChunk_eXIf() {\n if (hasRequiredChunk_eXIf) return chunk_eXIf;\n hasRequiredChunk_eXIf = 1;\n Object.defineProperty(chunk_eXIf, "__esModule", { value: true });\n chunk_eXIf.parseChunk = void 0;\n function parseChunk(ctx, header, chunk) {\n const offset = chunk.offset + 4 + 4;\n return {\n type: "eXIf",\n value: ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + offset + chunk.dataLength)\n };\n }\n chunk_eXIf.parseChunk = parseChunk;\n return chunk_eXIf;\n}\nvar chunk_gAMA = {};\nvar hasRequiredChunk_gAMA;\nfunction requireChunk_gAMA() {\n if (hasRequiredChunk_gAMA) return chunk_gAMA;\n hasRequiredChunk_gAMA = 1;\n Object.defineProperty(chunk_gAMA, "__esModule", { value: true });\n chunk_gAMA.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 4);\n const offset = chunk.offset + 4 + 4;\n const value = ctx.view.getUint32(offset) / 1e5;\n if (value === 0) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, "A value of 0 is meaningless", offset));\n }\n return {\n type: "gAMA",\n value\n };\n }\n chunk_gAMA.parseChunk = parseChunk;\n return chunk_gAMA;\n}\nvar chunk_hIST = {};\nvar hasRequiredChunk_hIST;\nfunction requireChunk_hIST() {\n if (hasRequiredChunk_hIST) return chunk_hIST;\n hasRequiredChunk_hIST = 1;\n Object.defineProperty(chunk_hIST, "__esModule", { value: true });\n chunk_hIST.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, ctx.palette.size * 2);\n const offset = chunk.offset + 4 + 4;\n const frequency = [];\n for (let i = 0; i < ctx.palette.size * 2; i += 2) {\n frequency.push(ctx.view.getUint16(offset + i));\n }\n return {\n type: "hIST",\n frequency\n };\n }\n chunk_hIST.parseChunk = parseChunk;\n return chunk_hIST;\n}\nvar chunk_iCCP = {};\nvar text = {};\nvar hasRequiredText;\nfunction requireText() {\n if (hasRequiredText) return text;\n hasRequiredText = 1;\n Object.defineProperty(text, "__esModule", { value: true });\n text.readText = void 0;\n const pako2 = requirePako();\n const assert_js_1 = requireAssert$1();\n function readText(ctx, chunk, textDecoder, maxLength, offset, maxOffset, readTrailingNull, isCompressed) {\n const bytes = [];\n let current = 0;\n let i = 0;\n for (; maxLength === void 0 || i < maxLength; i++) {\n if (!readTrailingNull && offset === maxOffset) {\n break;\n }\n try {\n current = ctx.view.getUint8(offset);\n } catch (e) {\n if (e instanceof Error && e.message === "Offset is outside the bounds of the DataView") {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "EOF while reading text", offset);\n }\n throw e;\n }\n if (!isCompressed && current === 0) {\n break;\n }\n offset++;\n bytes.push(current);\n }\n if (readTrailingNull && ctx.view.getUint8(offset) !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "No null character after text", offset);\n }\n let typedArray = new Uint8Array(bytes);\n if (isCompressed) {\n const inflator = new pako2.Inflate();\n inflator.push(typedArray);\n if (inflator.err) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Inflate error: ${inflator.msg}`, offset);\n }\n typedArray = inflator.result;\n }\n return { text: textDecoder ? textDecoder.decode(typedArray) : String.fromCharCode(...bytes), bytesRead: i + 1 };\n }\n text.readText = readText;\n return text;\n}\nvar hasRequiredChunk_iCCP;\nfunction requireChunk_iCCP() {\n if (hasRequiredChunk_iCCP) return chunk_iCCP;\n hasRequiredChunk_iCCP = 1;\n Object.defineProperty(chunk_iCCP, "__esModule", { value: true });\n chunk_iCCP.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkMutualExclusion)(ctx, chunk, "sRGB");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 3);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const name = readResult.text;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n const data = new Uint8Array(ctx.view.buffer.slice(ctx.view.byteOffset + offset, ctx.view.byteOffset + maxOffset));\n return {\n type: "iCCP",\n name,\n data\n };\n }\n chunk_iCCP.parseChunk = parseChunk;\n return chunk_iCCP;\n}\nvar chunk_iTXt = {};\nvar hasRequiredChunk_iTXt;\nfunction requireChunk_iTXt() {\n if (hasRequiredChunk_iTXt) return chunk_iTXt;\n hasRequiredChunk_iTXt = 1;\n Object.defineProperty(chunk_iTXt, "__esModule", { value: true });\n chunk_iTXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n let offset = chunk.offset + 4 + 4;\n const maxOffset = offset + chunk.dataLength;\n const textDecoder = new TextDecoder("utf8");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n const isCompressed = ctx.view.getUint8(offset++) === 1;\n const compressionMethod = ctx.view.getUint8(offset);\n if (isCompressed) {\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n }\n offset++;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const languageTag = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const translatedKeyword = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false, isCompressed);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "iTXt",\n keyword,\n languageTag,\n translatedKeyword,\n text: text2\n };\n }\n chunk_iTXt.parseChunk = parseChunk;\n return chunk_iTXt;\n}\nvar chunk_tIME = {};\nvar hasRequiredChunk_tIME;\nfunction requireChunk_tIME() {\n if (hasRequiredChunk_tIME) return chunk_tIME;\n hasRequiredChunk_tIME = 1;\n Object.defineProperty(chunk_tIME, "__esModule", { value: true });\n chunk_tIME.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 7);\n let offset = chunk.offset + 4 + 4;\n const year = ctx.view.getUint16(offset);\n offset += 2;\n const month = ctx.view.getUint8(offset++);\n const day = ctx.view.getUint8(offset++);\n const hour = ctx.view.getUint8(offset++);\n const minute = ctx.view.getUint8(offset++);\n const second = ctx.view.getUint8(offset++);\n return {\n type: "tIME",\n value: new Date(year, month, day, hour, minute, second)\n };\n }\n chunk_tIME.parseChunk = parseChunk;\n return chunk_tIME;\n}\nvar chunk_oFFs = {};\nvar hasRequiredChunk_oFFs;\nfunction requireChunk_oFFs() {\n if (hasRequiredChunk_oFFs) return chunk_oFFs;\n hasRequiredChunk_oFFs = 1;\n Object.defineProperty(chunk_oFFs, "__esModule", { value: true });\n chunk_oFFs.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 9);\n let offset = chunk.offset + 4 + 4;\n const x = ctx.view.getInt32(offset);\n offset += 4;\n const y = ctx.view.getInt32(offset);\n offset += 4;\n const unitTypeByte = ctx.view.getUint8(offset);\n let unitType;\n switch (unitTypeByte) {\n case 0:\n unitType = "pixel";\n break;\n case 1:\n unitType = "micrometer";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid oFFs unit type ("${unitTypeByte}")`, offset);\n }\n return {\n type: "oFFs",\n offset: { x, y },\n unitType\n };\n }\n chunk_oFFs.parseChunk = parseChunk;\n return chunk_oFFs;\n}\nvar chunk_pCAL = {};\nvar float = {};\nvar hasRequiredFloat;\nfunction requireFloat() {\n if (hasRequiredFloat) return float;\n hasRequiredFloat = 1;\n Object.defineProperty(float, "__esModule", { value: true });\n float.readFloat = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function readFloat(ctx, chunk, textDecoder, offset, maxOffset, readTrailingNull) {\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, readTrailingNull);\n offset += readResult.bytesRead;\n if (!isValidFloatingPoint(readResult.text)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid character in floating point number ("${readResult.text}")`, offset));\n }\n const value = parseFloat(readResult.text);\n return {\n bytesRead: readResult.bytesRead,\n value\n };\n }\n float.readFloat = readFloat;\n function isValidFloatingPoint(text2) {\n return text2.match(/^[+-]?[0-9]+\\.[0-9]+([eE][+-]?[0-9]+)?$/) || text2.match(/^[+-]?[0-9]+\\.?([eE][+-]?[0-9]+)?$/) || text2.match(/^[+-]?\\.[0-9]+([eE][+-]?[0-9]+)?$/);\n }\n return float;\n}\nvar hasRequiredChunk_pCAL;\nfunction requireChunk_pCAL() {\n if (hasRequiredChunk_pCAL) return chunk_pCAL;\n hasRequiredChunk_pCAL = 1;\n Object.defineProperty(chunk_pCAL, "__esModule", { value: true });\n chunk_pCAL.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const float_js_1 = requireFloat();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 4);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readTextResult;\n readTextResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readTextResult.bytesRead;\n const calibrationName = readTextResult.text;\n const x0 = ctx.view.getInt32(offset);\n offset += 4;\n const x1 = ctx.view.getInt32(offset);\n offset += 4;\n const equationTypeByte = ctx.view.getUint8(offset++);\n let equationType;\n switch (equationTypeByte) {\n case 0:\n equationType = "linear-mapping";\n break;\n case 1:\n equationType = "base-e exponential mapping";\n break;\n case 2:\n equationType = "arbitrary-base exponential mapping";\n break;\n case 3:\n equationType = "hyperbolic mapping";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid equation type "${equationTypeByte}"`, offset);\n }\n const parameterCount = ctx.view.getUint8(offset++);\n readTextResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readTextResult.bytesRead;\n const unitName = readTextResult.text;\n const params = [];\n let readFloatResult;\n for (let i = 0; i < parameterCount; i++) {\n readFloatResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, i < parameterCount - 1);\n offset += readFloatResult.bytesRead;\n params.push(readFloatResult.value);\n }\n return {\n type: "pCAL",\n calibrationName,\n x0,\n x1,\n equationType,\n unitName,\n params\n };\n }\n chunk_pCAL.parseChunk = parseChunk;\n return chunk_pCAL;\n}\nvar chunk_pHYs = {};\nvar hasRequiredChunk_pHYs;\nfunction requireChunk_pHYs() {\n if (hasRequiredChunk_pHYs) return chunk_pHYs;\n hasRequiredChunk_pHYs = 1;\n Object.defineProperty(chunk_pHYs, "__esModule", { value: true });\n chunk_pHYs.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 9);\n let offset = chunk.offset + 4 + 4;\n const x = ctx.view.getUint32(offset);\n offset += 4;\n const y = ctx.view.getUint32(offset);\n offset += 4;\n const unitType = ctx.view.getUint8(offset) === 1 ? "meter" : "unknown";\n return {\n type: "pHYs",\n pixelsPerUnit: { x, y },\n unitType\n };\n }\n chunk_pHYs.parseChunk = parseChunk;\n return chunk_pHYs;\n}\nvar chunk_sBIT = {};\nvar hasRequiredChunk_sBIT;\nfunction requireChunk_sBIT() {\n if (hasRequiredChunk_sBIT) return chunk_sBIT;\n hasRequiredChunk_sBIT = 1;\n Object.defineProperty(chunk_sBIT, "__esModule", { value: true });\n chunk_sBIT.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const offset = chunk.offset + 4 + 4;\n let value;\n let expectedLength;\n switch (header.colorType) {\n case 0: {\n value = ctx.view.getUint8(offset);\n expectedLength = 1;\n break;\n }\n case 2:\n case 3: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1),\n ctx.view.getUint8(offset + 2)\n ];\n expectedLength = 3;\n break;\n }\n case 4: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1)\n ];\n expectedLength = 2;\n break;\n }\n case 6: {\n value = [\n ctx.view.getUint8(offset),\n ctx.view.getUint8(offset + 1),\n ctx.view.getUint8(offset + 2),\n ctx.view.getUint8(offset + 3)\n ];\n expectedLength = 4;\n break;\n }\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Unrecognized color type "${header.colorType}"`, offset);\n }\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, expectedLength);\n return {\n type: "sBIT",\n value\n };\n }\n chunk_sBIT.parseChunk = parseChunk;\n return chunk_sBIT;\n}\nvar chunk_sCAL = {};\nvar hasRequiredChunk_sCAL;\nfunction requireChunk_sCAL() {\n if (hasRequiredChunk_sCAL) return chunk_sCAL;\n hasRequiredChunk_sCAL = 1;\n Object.defineProperty(chunk_sCAL, "__esModule", { value: true });\n chunk_sCAL.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const float_js_1 = requireFloat();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 4);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n const unitTypeByte = ctx.view.getUint8(offset);\n let unitType;\n switch (unitTypeByte) {\n case 0:\n unitType = "meter";\n break;\n case 1:\n unitType = "radian";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid sCAL unit type ("${unitTypeByte}")`, offset);\n }\n offset++;\n let readResult;\n readResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const x = readResult.value;\n readResult = (0, float_js_1.readFloat)(ctx, chunk, textDecoder, offset, maxOffset, false);\n offset += readResult.bytesRead;\n const y = readResult.value;\n if (x < 0 || y < 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Values cannot be negative (${x}, ${y})`, offset);\n }\n return {\n type: "sCAL",\n pixelsPerUnit: { x, y },\n unitType\n };\n }\n chunk_sCAL.parseChunk = parseChunk;\n return chunk_sCAL;\n}\nvar chunk_sPLT = {};\nvar hasRequiredChunk_sPLT;\nfunction requireChunk_sPLT() {\n if (hasRequiredChunk_sPLT) return chunk_sPLT;\n hasRequiredChunk_sPLT = 1;\n Object.defineProperty(chunk_sPLT, "__esModule", { value: true });\n chunk_sPLT.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n const dataStartOffset = chunk.offset + 4 + 4;\n let offset = dataStartOffset;\n const maxOffset = offset + chunk.dataLength;\n const textDecoder = new TextDecoder("latin1");\n const readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const name = readResult.text;\n const sampleDepth = ctx.view.getUint8(offset++);\n const sampleBytes = sampleDepth === 16 ? 2 : 1;\n const entrySize = sampleBytes * 4 + 2;\n const entriesOffset = chunk.dataLength - (offset - dataStartOffset);\n const entryCount = entriesOffset / entrySize;\n if (entryCount % 1 !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid data length: ${entriesOffset} should be divisible by entry size ${entrySize}`, offset);\n }\n const entries = [];\n for (let i = 0; i < entryCount; i++) {\n const channels = [];\n for (let c = 0; c < 4; c++) {\n channels.push(sampleBytes === 2 ? ctx.view.getUint16(offset) : ctx.view.getUint8(offset));\n offset += sampleBytes;\n }\n const frequency = ctx.view.getUint16(offset);\n offset += 2;\n entries.push({\n red: channels[0],\n green: channels[1],\n blue: channels[2],\n alpha: channels[3],\n frequency\n });\n }\n return {\n type: "sPLT",\n name,\n sampleDepth,\n entries\n };\n }\n chunk_sPLT.parseChunk = parseChunk;\n return chunk_sPLT;\n}\nvar chunk_sRGB = {};\nvar hasRequiredChunk_sRGB;\nfunction requireChunk_sRGB() {\n if (hasRequiredChunk_sRGB) return chunk_sRGB;\n hasRequiredChunk_sRGB = 1;\n Object.defineProperty(chunk_sRGB, "__esModule", { value: true });\n chunk_sRGB.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkMutualExclusion)(ctx, chunk, "iCCP");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "PLTE");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 1);\n const offset = chunk.offset + 4 + 4;\n const byte = ctx.view.getUint8(offset);\n let renderingIntent;\n switch (byte) {\n case 0:\n case 1:\n case 2:\n case 3:\n renderingIntent = byte;\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid rendering intent "${byte}"`, offset);\n }\n return {\n type: "sRGB",\n renderingIntent\n };\n }\n chunk_sRGB.parseChunk = parseChunk;\n return chunk_sRGB;\n}\nvar chunk_sTER = {};\nvar hasRequiredChunk_sTER;\nfunction requireChunk_sTER() {\n if (hasRequiredChunk_sTER) return chunk_sTER;\n hasRequiredChunk_sTER = 1;\n Object.defineProperty(chunk_sTER, "__esModule", { value: true });\n chunk_sTER.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 1);\n const offset = chunk.offset + 4 + 4;\n const layoutModeByte = ctx.view.getUint8(offset);\n let layoutMode;\n switch (layoutModeByte) {\n case 0:\n layoutMode = "cross-fuse";\n break;\n case 1:\n layoutMode = "diverging-fuse";\n break;\n default:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid layout mode "${layoutModeByte}"`, offset);\n }\n const padding = 15 - (header.width - 1) % 16;\n if (padding > 7) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid padding value "${padding}" for image width ${header.width}`, offset);\n }\n const subimageWidth = Math.floor((header.width - padding) / 2);\n return {\n type: "sTER",\n layoutMode,\n subimageWidth,\n padding\n };\n }\n chunk_sTER.parseChunk = parseChunk;\n return chunk_sTER;\n}\nvar chunk_tEXt = {};\nvar hasRequiredChunk_tEXt;\nfunction requireChunk_tEXt() {\n if (hasRequiredChunk_tEXt) return chunk_tEXt;\n hasRequiredChunk_tEXt = 1;\n Object.defineProperty(chunk_tEXt, "__esModule", { value: true });\n chunk_tEXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "tEXt",\n keyword,\n text: text2\n };\n }\n chunk_tEXt.parseChunk = parseChunk;\n return chunk_tEXt;\n}\nvar chunk_tRNS = {};\nvar hasRequiredChunk_tRNS;\nfunction requireChunk_tRNS() {\n if (hasRequiredChunk_tRNS) return chunk_tRNS;\n hasRequiredChunk_tRNS = 1;\n Object.defineProperty(chunk_tRNS, "__esModule", { value: true });\n chunk_tRNS.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n switch (header.colorType) {\n case 0:\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 2);\n break;\n case 2:\n (0, assert_js_1.assertChunkDataLengthEquals)(ctx, chunk, 6);\n break;\n case 3:\n (0, assert_js_1.assertChunkFollows)(ctx, chunk, "PLTE");\n if (chunk.dataLength > ctx.palette.size) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Invalid data length for color type ${header.colorType}: ${chunk.dataLength} > ${ctx.palette.size}`, chunk.offset + 4 + 4);\n }\n break;\n case 4:\n case 6:\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Chunk invalid when color type has alpha (${header.colorType})`, chunk.offset + 4 + 4);\n }\n const offset = chunk.offset + 4 + 4;\n let transparency;\n switch (header.colorType) {\n case 0:\n transparency = ctx.view.getUint16(offset);\n break;\n case 2:\n transparency = [\n ctx.view.getUint16(offset),\n ctx.view.getUint16(offset + 2),\n ctx.view.getUint16(offset + 4)\n ];\n break;\n case 3:\n transparency = [];\n for (let i = 0; i < chunk.dataLength; i++) {\n transparency.push(ctx.view.getUint8(offset + i));\n }\n break;\n }\n return {\n type: "tRNS",\n transparency\n };\n }\n chunk_tRNS.parseChunk = parseChunk;\n return chunk_tRNS;\n}\nvar chunk_zTXt = {};\nvar hasRequiredChunk_zTXt;\nfunction requireChunk_zTXt() {\n if (hasRequiredChunk_zTXt) return chunk_zTXt;\n hasRequiredChunk_zTXt = 1;\n Object.defineProperty(chunk_zTXt, "__esModule", { value: true });\n chunk_zTXt.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n const text_js_1 = requireText();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkDataLengthGte)(ctx, chunk, 6);\n const chunkDataOffset = chunk.offset + 4 + 4;\n const maxOffset = chunkDataOffset + chunk.dataLength;\n let offset = chunkDataOffset;\n const textDecoder = new TextDecoder("latin1");\n let readResult;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, 79, offset, maxOffset, true);\n offset += readResult.bytesRead;\n const keyword = readResult.text;\n const compressionMethod = ctx.view.getUint8(offset);\n (0, assert_js_1.assertChunkCompressionMethod)(ctx, chunk, compressionMethod, offset);\n offset++;\n readResult = (0, text_js_1.readText)(ctx, chunk, textDecoder, void 0, offset, maxOffset, false, true);\n offset += readResult.bytesRead;\n const text2 = readResult.text;\n return {\n type: "zTXt",\n keyword,\n text: text2\n };\n }\n chunk_zTXt.parseChunk = parseChunk;\n return chunk_zTXt;\n}\nvar chunk_PLTE = {};\nvar hasRequiredChunk_PLTE;\nfunction requireChunk_PLTE() {\n if (hasRequiredChunk_PLTE) return chunk_PLTE;\n hasRequiredChunk_PLTE = 1;\n Object.defineProperty(chunk_PLTE, "__esModule", { value: true });\n chunk_PLTE.Palette = chunk_PLTE.parseChunk = void 0;\n const assert_js_1 = requireAssert$1();\n function parseChunk(ctx, header, chunk) {\n (0, assert_js_1.assertChunkSinglular)(ctx, chunk);\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "bKGD");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "hIST");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "tRNS");\n (0, assert_js_1.assertChunkPrecedes)(ctx, chunk, "IDAT");\n let offset = chunk.offset + 4;\n if (header.colorType === 0 || header.colorType === 4) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Color type "${header.colorType}" cannot have a palette`, offset);\n }\n offset += 4;\n if (chunk.dataLength === 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, "Cannot have 0 entries", offset);\n }\n if (chunk.dataLength % 3 !== 0) {\n throw (0, assert_js_1.createChunkDecodeWarning)(chunk, `Chunk length must be divisible by 3 (actual "${chunk.dataLength}")`, offset);\n }\n if (chunk.dataLength / 3 > 256) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Too many entries (${chunk.dataLength / 3} > 256)`, offset));\n }\n if (chunk.dataLength / 3 > Math.pow(2, header.bitDepth)) {\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Too many entries for bit depth (${chunk.dataLength / 3} > 2^${header.bitDepth})`, offset));\n }\n return new Palette(ctx.view, chunk.offset + 4 + 4, chunk.dataLength);\n }\n chunk_PLTE.parseChunk = parseChunk;\n class Palette {\n constructor(_view, _paletteOffset, _length) {\n this._view = _view;\n this._paletteOffset = _paletteOffset;\n this._length = _length;\n }\n get size() {\n return this._length / 3;\n }\n getRgb(colorIndex) {\n this._checkIndex(colorIndex);\n return new Uint8Array(this._view.buffer.slice(this._view.byteOffset + this._paletteOffset + colorIndex * 3, this._view.byteOffset + this._paletteOffset + colorIndex * 3 + 3));\n }\n setRgba(data, offset, colorIndex) {\n this._checkIndex(colorIndex);\n const i = this._paletteOffset + colorIndex * 3;\n data[offset] = this._view.getUint8(i);\n data[offset + 1] = this._view.getUint8(i + 1);\n data[offset + 2] = this._view.getUint8(i + 2);\n data[offset + 3] = 255;\n }\n _checkIndex(colorIndex) {\n if (colorIndex < 0 || colorIndex * 3 > this._length - 3) {\n throw new Error(`Palette does not contain color index "${colorIndex}"`);\n }\n }\n }\n chunk_PLTE.Palette = Palette;\n return chunk_PLTE;\n}\nvar hasRequiredDecoder;\nfunction requireDecoder() {\n if (hasRequiredDecoder) return decoder;\n hasRequiredDecoder = 1;\n Object.defineProperty(decoder, "__esModule", { value: true });\n decoder.readChunk = decoder.readChunks = decoder.decodePng = decoder.verifyPngSignature = void 0;\n const array_js_1 = requireArray();\n const assert_js_1 = requireAssert$1();\n const chunk_IDAT_js_1 = requireChunk_IDAT();\n const chunk_IEND_js_1 = requireChunk_IEND();\n const chunk_IHDR_js_1 = requireChunk_IHDR();\n const crc32_js_1 = requireCrc32();\n function verifyPngSignature(ctx) {\n if (ctx.view.byteLength < 7) {\n throw new assert_js_1.DecodeError(ctx, `Not enough bytes in file for png signature (${ctx.view.byteLength})`, 0);\n }\n const isCorrect = ctx.view.getUint8(0) === 137 && ctx.view.getUint8(1) === 80 && ctx.view.getUint8(2) === 78 && ctx.view.getUint8(3) === 71 && ctx.view.getUint8(4) === 13 && ctx.view.getUint8(5) === 10 && ctx.view.getUint8(6) === 26 && ctx.view.getUint8(7) === 10;\n if (!isCorrect) {\n const actual = formatHexAssertion(Array.from(new Uint8Array(ctx.view.buffer).slice(ctx.view.byteOffset, ctx.view.byteOffset + 8)));\n const expected = formatHexAssertion([137, 80, 78, 71, 13, 10, 26, 10]);\n throw new assert_js_1.DecodeError(ctx, `Png signature is not correct (${actual} !== ${expected})`, 0);\n }\n }\n decoder.verifyPngSignature = verifyPngSignature;\n function formatHexAssertion(actual) {\n return `0x${actual.map((e) => e.toString(16).padStart(2, "0")).join("")}`;\n }\n const defaultLazyChunkTypes = Object.freeze([\n "tRNS"\n ]);\n const allLazyChunkTypes = Object.freeze([\n "bKGD",\n "cHRM",\n "eXIf",\n "gAMA",\n "hIST",\n "iCCP",\n "iTXt",\n "tIME",\n "oFFs",\n "pCAL",\n "pHYs",\n "sBIT",\n "sCAL",\n "sPLT",\n "sRGB",\n "sTER",\n "tEXt",\n "tRNS",\n "zTXt"\n ]);\n function getChunkDecoder(type) {\n switch (type) {\n case "bKGD":\n return Promise.resolve().then(() => requireChunk_bKGD());\n case "cHRM":\n return Promise.resolve().then(() => requireChunk_cHRM());\n case "eXIf":\n return Promise.resolve().then(() => requireChunk_eXIf());\n case "gAMA":\n return Promise.resolve().then(() => requireChunk_gAMA());\n case "hIST":\n return Promise.resolve().then(() => requireChunk_hIST());\n case "iCCP":\n return Promise.resolve().then(() => requireChunk_iCCP());\n case "iTXt":\n return Promise.resolve().then(() => requireChunk_iTXt());\n case "tIME":\n return Promise.resolve().then(() => requireChunk_tIME());\n case "oFFs":\n return Promise.resolve().then(() => requireChunk_oFFs());\n case "pCAL":\n return Promise.resolve().then(() => requireChunk_pCAL());\n case "pHYs":\n return Promise.resolve().then(() => requireChunk_pHYs());\n case "sBIT":\n return Promise.resolve().then(() => requireChunk_sBIT());\n case "sCAL":\n return Promise.resolve().then(() => requireChunk_sCAL());\n case "sPLT":\n return Promise.resolve().then(() => requireChunk_sPLT());\n case "sRGB":\n return Promise.resolve().then(() => requireChunk_sRGB());\n case "sTER":\n return Promise.resolve().then(() => requireChunk_sTER());\n case "tEXt":\n return Promise.resolve().then(() => requireChunk_tEXt());\n case "tRNS":\n return Promise.resolve().then(() => requireChunk_tRNS());\n case "zTXt":\n return Promise.resolve().then(() => requireChunk_zTXt());\n default:\n throw new Error(`Could not get decoder for chunk type "${type}"`);\n }\n }\n async function decodePng(data, options = {}) {\n const initialCtx = {\n view: new DataView(data.buffer, data.byteOffset, data.byteLength),\n image: void 0,\n palette: void 0,\n metadata: [],\n parsedChunks: /* @__PURE__ */ new Set(),\n warnings: [],\n info: [],\n options\n };\n verifyPngSignature(initialCtx);\n const chunks = readChunks(initialCtx);\n initialCtx.rawChunks = chunks;\n const header = (0, chunk_IHDR_js_1.parseChunk)(initialCtx, chunks[0]);\n const ctx = {\n ...initialCtx,\n header\n };\n let parseChunkTypes;\n if (options && options.parseChunkTypes) {\n if (options.parseChunkTypes === "*") {\n parseChunkTypes = allLazyChunkTypes;\n } else {\n parseChunkTypes = defaultLazyChunkTypes.concat(options.parseChunkTypes);\n }\n } else {\n parseChunkTypes = defaultLazyChunkTypes;\n }\n for (let i = 1; i < chunks.length; i++) {\n const chunk = chunks[i];\n switch (chunk.type) {\n case "IHDR":\n (0, assert_js_1.handleWarning)(ctx, (0, assert_js_1.createChunkDecodeWarning)(chunk, `Multiple IHDR chunks not allowed`, chunk.offset + 4));\n break;\n case "IDAT": {\n const dataChunks = [chunk];\n while (chunks.length > i + 1 && chunks[i + 1].type === "IDAT") {\n dataChunks.push(chunks[++i]);\n }\n ctx.image = {\n width: header.width,\n height: header.height,\n data: (0, chunk_IDAT_js_1.parseChunk)(ctx, header, dataChunks)\n };\n break;\n }\n case "PLTE":\n ctx.palette = (await Promise.resolve().then(() => requireChunk_PLTE())).parseChunk(ctx, header, chunk);\n break;\n case "IEND":\n (0, chunk_IEND_js_1.parseChunk)(ctx, header, chunk);\n break;\n default:\n if (parseChunkTypes.includes(chunk.type)) {\n try {\n ctx.metadata.push((await getChunkDecoder(chunk.type)).parseChunk(ctx, header, chunk));\n } catch (e) {\n if (e instanceof assert_js_1.DecodeWarning) {\n (0, assert_js_1.handleWarning)(ctx, e);\n } else {\n throw e;\n }\n }\n } else {\n if (!allLazyChunkTypes.includes(chunk.type)) {\n if (!chunk.isAncillary) {\n throw new assert_js_1.DecodeError(ctx, `Unrecognized critical chunk type "${chunk.type}"`, chunk.offset + 4);\n } else {\n ctx.info.push(`Unrecognized chunk type "${chunk.type}"`);\n }\n }\n }\n break;\n }\n ctx.parsedChunks.add(chunk.type);\n }\n if (!ctx.image) {\n throw new assert_js_1.DecodeError(ctx, "Failed to decode, no IDAT chunk", 0);\n }\n if (options && options.force32 && ctx.image.data.BYTES_PER_ELEMENT === 2) {\n ctx.image.data = (0, array_js_1.convert16BitTo8BitData)(ctx.image.data);\n }\n return {\n image: ctx.image,\n details: {\n width: header.width,\n height: header.height,\n bitDepth: header.bitDepth,\n colorType: header.colorType,\n interlaceMethod: header.interlaceMethod\n },\n palette: ctx.palette,\n metadata: ctx.metadata,\n rawChunks: chunks,\n warnings: ctx.warnings,\n info: ctx.info\n };\n }\n decoder.decodePng = decodePng;\n function readChunks(ctx) {\n const chunks = [];\n let offset = 8;\n let hasData = false;\n let hasEnd = false;\n let chunk;\n while (offset < ctx.view.byteLength) {\n try {\n chunk = readChunk(ctx, offset);\n } catch (e) {\n if (!hasEnd || !(e instanceof Error)) {\n throw e;\n }\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning("Could not parse chunk after IEND: " + e.message, offset));\n }\n offset += 4 + 4 + chunk.dataLength + 4;\n chunks.push(chunk);\n hasData || (hasData = chunk.type === "IDAT");\n hasEnd || (hasEnd = chunk.type === "IEND");\n }\n if (chunks[0].type !== "IHDR") {\n throw new assert_js_1.DecodeError(ctx, `First chunk is not IHDR`, chunks[0].offset + 4);\n }\n if (chunks[chunks.length - 1].type !== "IEND") {\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning("Last chunk is not IEND", chunks[chunks.length - 1].offset + 4));\n }\n if (!hasData) {\n throw new assert_js_1.DecodeError(ctx, "No IDAT chunk", 0);\n }\n return chunks;\n }\n decoder.readChunks = readChunks;\n function readChunk(ctx, offset) {\n if (ctx.view.byteLength < offset + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk length`, offset);\n }\n const dataLength = ctx.view.getUint32(offset);\n if (ctx.view.byteLength < offset + 4 + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk type`, offset);\n }\n const type = String.fromCharCode(ctx.view.getUint8(offset + 4), ctx.view.getUint8(offset + 5), ctx.view.getUint8(offset + 6), ctx.view.getUint8(offset + 7));\n if (ctx.view.byteLength < offset + 4 + 4 + dataLength + 4) {\n throw new assert_js_1.DecodeError(ctx, `EOF while reading chunk "${type}"`, offset);\n }\n const actualCrc = ctx.view.getUint32(offset + 4 + 4 + dataLength) >>> 0;\n const expectedCrc = (0, crc32_js_1.crc32)(ctx.view, offset + 4, 4 + dataLength);\n if (actualCrc !== expectedCrc) {\n (0, assert_js_1.handleWarning)(ctx, new assert_js_1.DecodeWarning(`CRC for chunk "${type}" at offset 0x${offset.toString(16)} doesn\'t match (0x${actualCrc.toString(16)} !== 0x${expectedCrc.toString(16)})`, offset));\n }\n return {\n offset,\n type,\n dataLength,\n isAncillary: isCharLowercase(type, 0),\n isPrivate: isCharLowercase(type, 1),\n isSafeToCopy: isCharLowercase(type, 3)\n };\n }\n decoder.readChunk = readChunk;\n function isCharLowercase(text2, index) {\n return !!(text2.charCodeAt(index) & 32);\n }\n return decoder;\n}\nvar encoder = {};\nvar byteStream = {};\nvar hasRequiredByteStream;\nfunction requireByteStream() {\n if (hasRequiredByteStream) return byteStream;\n hasRequiredByteStream = 1;\n Object.defineProperty(byteStream, "__esModule", { value: true });\n byteStream.ByteStream = void 0;\n class ByteStream {\n constructor(length) {\n this.offset = 0;\n this.array = new Uint8Array(length);\n this.view = new DataView(this.array.buffer, this.array.byteOffset, this.array.byteLength);\n }\n writeUint8(value) {\n this.view.setUint8(this.offset, value);\n this.offset += 1;\n }\n writeUint16(value) {\n this.view.setUint16(this.offset, value);\n this.offset += 2;\n }\n writeUint32(value) {\n this.view.setUint32(this.offset, value);\n this.offset += 4;\n }\n writeArray(values) {\n this.array.set(values, this.array.byteOffset + this.offset);\n this.offset += values.length;\n }\n assertAtEnd() {\n if (this.offset !== this.array.length) {\n throw new Error("Writing finished before expected length of stream");\n }\n }\n }\n byteStream.ByteStream = ByteStream;\n return byteStream;\n}\nvar IDAT_encode = {};\nvar write = {};\nvar hasRequiredWrite;\nfunction requireWrite() {\n if (hasRequiredWrite) return write;\n hasRequiredWrite = 1;\n Object.defineProperty(write, "__esModule", { value: true });\n write.writeChunkDataFn = write.writeChunk = write.writeChunkType = void 0;\n const byteStream_js_1 = requireByteStream();\n const crc32_js_1 = requireCrc32();\n function writeChunkType(stream, type) {\n stream.writeUint8(type.charCodeAt(0));\n stream.writeUint8(type.charCodeAt(1));\n stream.writeUint8(type.charCodeAt(2));\n stream.writeUint8(type.charCodeAt(3));\n }\n write.writeChunkType = writeChunkType;\n function writeChunk(type, data) {\n const stream = new byteStream_js_1.ByteStream(4 + 4 + data.length + 4);\n stream.writeUint32(data.length);\n if (type.length !== 4) {\n throw new Error(`Cannot encode a chunk type of length ${type.length}`);\n }\n writeChunkType(stream, type);\n stream.writeArray(data);\n stream.writeUint32((0, crc32_js_1.crc32)(stream.view, 4, 4 + data.length));\n stream.assertAtEnd();\n return stream.array;\n }\n write.writeChunk = writeChunk;\n function writeChunkDataFn(type, dataLength, writeDataFn) {\n const stream = new byteStream_js_1.ByteStream(4 + 4 + dataLength + 4);\n stream.writeUint32(dataLength);\n if (type.length !== 4) {\n throw new Error(`Cannot encode a chunk type of length ${type.length}`);\n }\n writeChunkType(stream, type);\n writeDataFn(stream);\n stream.writeUint32((0, crc32_js_1.crc32)(stream.view, 4, 4 + dataLength));\n stream.assertAtEnd();\n return stream.array;\n }\n write.writeChunkDataFn = writeChunkDataFn;\n return write;\n}\nvar hasRequiredIDAT_encode;\nfunction requireIDAT_encode() {\n if (hasRequiredIDAT_encode) return IDAT_encode;\n hasRequiredIDAT_encode = 1;\n Object.defineProperty(IDAT_encode, "__esModule", { value: true });\n IDAT_encode.encodeChunk = void 0;\n const pako2 = requirePako();\n const byteStream_js_1 = requireByteStream();\n const paeth_js_1 = requirePaeth();\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n const dataStreamLength = calculateDataLength(ctx, image);\n const stream = new byteStream_js_1.ByteStream(dataStreamLength);\n writeUncompressedData(ctx, image, stream);\n const compressed = pako2.deflate(stream.array);\n const chunkIDAT = (0, write_js_1.writeChunk)("IDAT", compressed);\n return chunkIDAT;\n }\n IDAT_encode.encodeChunk = encodeChunk;\n function calculateDataLength(ctx, image) {\n if (ctx.bitDepth < 8) {\n throw new Error("Only bit depth 8 and 16 is supported currently");\n }\n if (image.data.BYTES_PER_ELEMENT === 2 && ctx.bitDepth === 8) {\n throw new Error("16 to 8 bit conversion isn\'t supported yet");\n }\n if (ctx.interlaceMethod !== 0) {\n throw new Error("Only interlace method 0 is supported currently");\n }\n let channels;\n switch (ctx.colorType) {\n case 0:\n channels = 1;\n break;\n case 2:\n channels = 3;\n break;\n case 3:\n channels = 1;\n break;\n case 4:\n channels = 2;\n break;\n case 6:\n channels = 4;\n break;\n }\n const bytesPerChannel = ctx.bitDepth === 16 ? 2 : 1;\n const bytesPerPixel = channels * bytesPerChannel;\n const bytesPerLine = 1 + bytesPerPixel * image.width;\n const bytesAllLines = bytesPerLine * image.height;\n return bytesAllLines;\n }\n function writeUncompressedData(ctx, image, stream) {\n let i = 0, x = 0, y = 0;\n if (ctx.colorType === 3) {\n if (!ctx.palette) {\n throw new Error("Cannot encode indexed file without palette");\n }\n if (image.data.BYTES_PER_ELEMENT === 2) {\n throw new Error("Cannot encode indexed file from 16-bit image");\n }\n for (; y < image.height; y++) {\n stream.writeUint8(0);\n for (x = 0; x < image.width; x++) {\n stream.writeUint8(ctx.palette.get(image.data[i] << 24 | image.data[i + 1] << 16 | image.data[i + 2] << 8 | image.data[i + 3]));\n i += 4;\n }\n }\n return;\n }\n let filterPattern;\n if (ctx.options.filterPattern) {\n if (ctx.options.filterPattern.length === 0) {\n throw new Error("Filter pattern with 0 entries");\n }\n filterPattern = ctx.options.filterPattern;\n }\n const bpp = 4 * image.data.BYTES_PER_ELEMENT;\n const filterFns = [];\n for (const filterType of [0, 1, 2, 3, 4]) {\n filterFns[filterType] = buildFilterFunction(bpp, bpp * image.width, filterType);\n }\n const channelsToWrite = getChannelsToWrite(ctx.colorType);\n for (; y < image.height; y++) {\n const filterType = filterPattern ? filterPattern[y % filterPattern.length] : pickFilterType(ctx.colorType, image, y * image.width * 4, filterFns);\n const dataUint8 = new Uint8Array(image.data.buffer, image.data.byteOffset, image.data.byteLength);\n stream.writeUint8(filterType);\n let byte = 0, c = 0;\n for (x = 0; x < image.width; x++) {\n for (c of channelsToWrite) {\n for (byte = image.data.BYTES_PER_ELEMENT - 1; byte >= 0; byte--) {\n stream.writeUint8(filterFns[filterType](dataUint8, (i + c) * image.data.BYTES_PER_ELEMENT + byte, x === 0));\n }\n }\n i += 4;\n }\n }\n }\n function pickFilterType(colorType, image, lineIndex, filterFns) {\n const filterSums = [];\n 4 * image.data.BYTES_PER_ELEMENT;\n for (const filterType of [0, 1, 2, 3, 4]) {\n let sum = 0;\n const channelsToWrite = getChannelsToWrite(colorType);\n const dataUint8 = new Uint8Array(image.data.buffer, image.data.byteOffset, image.data.byteLength);\n let c = 0, byte = 0;\n for (let i = lineIndex; i < lineIndex + image.width * 4; i += 4) {\n for (c of channelsToWrite) {\n for (byte = image.data.BYTES_PER_ELEMENT - 1; byte >= 0; byte--) {\n sum += filterFns[filterType](dataUint8, (i + c) * image.data.BYTES_PER_ELEMENT + byte, i === lineIndex);\n }\n }\n }\n filterSums[filterType] = sum;\n }\n let lowestFilterType = 0;\n let lowestSum = filterSums[0];\n for (const filterType of [1, 2, 3, 4]) {\n if (filterSums[filterType] < lowestSum) {\n lowestFilterType = filterType;\n lowestSum = filterSums[filterType];\n }\n }\n return lowestFilterType;\n }\n function buildFilterFunction(bpp, bpl, filterType) {\n let ai = 0, bi = 0, ci = 0;\n switch (filterType) {\n case 0:\n return (filt, filtX) => filt[filtX];\n case 1:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n return (filt[filtX] - (ai < 0 ? 0 : filt[filtX - bpp]) + 256) % 256;\n };\n case 2:\n return (filt, filtX) => {\n bi = filtX - bpl;\n return (filt[filtX] - (bi < 0 ? 0 : filt[bi]) + 256) % 256;\n };\n case 3:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n bi = filtX - bpl;\n return (filt[filtX] - Math.floor(((ai < 0 ? 0 : filt[ai]) + (bi < 0 ? 0 : filt[bi])) / 2) + 256) % 256;\n };\n case 4:\n return (filt, filtX, isFirstInLine) => {\n ai = isFirstInLine ? -1 : filtX - bpp;\n bi = filtX - bpl;\n ci = isFirstInLine ? -1 : filtX - bpp - bpl;\n return (filt[filtX] - (0, paeth_js_1.paethPredicator)(ai < 0 ? 0 : filt[ai], bi < 0 ? 0 : filt[bi], ci < 0 ? 0 : filt[ci]) + 256) % 256;\n };\n }\n }\n function getChannelsToWrite(colorType) {\n switch (colorType) {\n case 0:\n return [0];\n case 2:\n return [0, 1, 2];\n case 4:\n return [0, 3];\n case 6:\n return [0, 1, 2, 3];\n }\n }\n return IDAT_encode;\n}\nvar IEND_encode = {};\nvar hasRequiredIEND_encode;\nfunction requireIEND_encode() {\n if (hasRequiredIEND_encode) return IEND_encode;\n hasRequiredIEND_encode = 1;\n Object.defineProperty(IEND_encode, "__esModule", { value: true });\n IEND_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk() {\n return (0, write_js_1.writeChunk)("IEND", new Uint8Array(0));\n }\n IEND_encode.encodeChunk = encodeChunk;\n return IEND_encode;\n}\nvar IHDR_encode = {};\nvar hasRequiredIHDR_encode;\nfunction requireIHDR_encode() {\n if (hasRequiredIHDR_encode) return IHDR_encode;\n hasRequiredIHDR_encode = 1;\n Object.defineProperty(IHDR_encode, "__esModule", { value: true });\n IHDR_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n if (image.width <= 0 || image.height <= 0) {\n throw new Error(`Invalid dimensions ${image.width}x${image.height}`);\n }\n return (0, write_js_1.writeChunkDataFn)("IHDR", 13, (stream) => {\n stream.writeUint32(image.width);\n stream.writeUint32(image.height);\n stream.writeUint8(ctx.bitDepth);\n stream.writeUint8(ctx.colorType);\n stream.writeUint8(0);\n stream.writeUint8(0);\n stream.writeUint8(ctx.interlaceMethod);\n });\n }\n IHDR_encode.encodeChunk = encodeChunk;\n return IHDR_encode;\n}\nvar tRNS_encode = {};\nvar hasRequiredTRNS_encode;\nfunction requireTRNS_encode() {\n if (hasRequiredTRNS_encode) return tRNS_encode;\n hasRequiredTRNS_encode = 1;\n Object.defineProperty(tRNS_encode, "__esModule", { value: true });\n tRNS_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n switch (ctx.colorType) {\n case 0: {\n if (ctx.firstTransparentColor === void 0) {\n throw new Error("Cannot write tRNS for grayscale without any transparent colors");\n }\n const firstTransparentColor = ctx.firstTransparentColor;\n return (0, write_js_1.writeChunkDataFn)("tRNS", 2, (stream) => {\n if (image.data.BYTES_PER_ELEMENT === 2) {\n stream.writeUint16(firstTransparentColor >> 48 & 65535);\n } else {\n stream.writeUint16(firstTransparentColor >> 24 & 255);\n }\n });\n }\n case 3: {\n if (!ctx.palette) {\n throw new Error("Cannot encode tRNS chunk for indexed image without palette");\n }\n return (0, write_js_1.writeChunkDataFn)("tRNS", ctx.palette.size, (stream) => {\n for (const color of ctx.colorSet) {\n stream.writeUint8(color & 255);\n }\n });\n }\n case 2: {\n if (ctx.firstTransparentColor === void 0) {\n throw new Error("Cannot write tRNS for True color without any transparent colors");\n }\n const firstTransparentColor = ctx.firstTransparentColor;\n return (0, write_js_1.writeChunkDataFn)("tRNS", 6, (stream) => {\n if (image.data.BYTES_PER_ELEMENT === 2) {\n stream.writeUint16(firstTransparentColor >> 48 & 65535);\n stream.writeUint16(firstTransparentColor >> 32 & 65535);\n stream.writeUint16(firstTransparentColor >> 16 & 65535);\n } else {\n stream.writeUint16(firstTransparentColor >> 24 & 255);\n stream.writeUint16(firstTransparentColor >> 16 & 255);\n stream.writeUint16(firstTransparentColor >> 8 & 255);\n }\n });\n }\n default:\n throw new Error(`Cannot encode tRNS chunk for color type "${ctx.colorType}"`);\n }\n }\n tRNS_encode.encodeChunk = encodeChunk;\n return tRNS_encode;\n}\nvar PLTE_encode = {};\nvar hasRequiredPLTE_encode;\nfunction requirePLTE_encode() {\n if (hasRequiredPLTE_encode) return PLTE_encode;\n hasRequiredPLTE_encode = 1;\n Object.defineProperty(PLTE_encode, "__esModule", { value: true });\n PLTE_encode.encodeChunk = void 0;\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image) {\n if (ctx.bitDepth === 16 || image.data.BYTES_PER_ELEMENT === 2) {\n throw new Error("Cannot encode 16 bit images using indexed color type");\n }\n if (ctx.colorSet.size > Math.pow(2, ctx.bitDepth)) {\n throw new Error(`Too many colors ${ctx.colorSet.size} to encode into indexed image (2^${ctx.bitDepth} = ${Math.pow(2, ctx.bitDepth)})`);\n }\n const chunkData = (0, write_js_1.writeChunkDataFn)("PLTE", ctx.colorSet.size * 3, (stream) => {\n for (const color of ctx.colorSet.values()) {\n stream.writeUint8(color >> 24 & 255);\n stream.writeUint8(color >> 16 & 255);\n stream.writeUint8(color >> 8 & 255);\n }\n });\n const palette = /* @__PURE__ */ new Map();\n for (const color of ctx.colorSet.values()) {\n palette.set(color, palette.size);\n }\n return {\n chunkData,\n palette\n };\n }\n PLTE_encode.encodeChunk = encodeChunk;\n return PLTE_encode;\n}\nvar tEXt_encode = {};\nvar hasRequiredTEXt_encode;\nfunction requireTEXt_encode() {\n if (hasRequiredTEXt_encode) return tEXt_encode;\n hasRequiredTEXt_encode = 1;\n Object.defineProperty(tEXt_encode, "__esModule", { value: true });\n tEXt_encode.encodeChunk = void 0;\n const assert_js_1 = requireAssert();\n const write_js_1 = requireWrite();\n function encodeChunk(ctx, image, keyword, text2) {\n if (keyword.length === 0 || keyword.length > 79) {\n throw new assert_js_1.EncodeError(`tEXt: Invalid keyword length: 0 < ${keyword.length} < 80`, 0);\n }\n const dataLength = keyword.length + 1 + text2.length;\n return (0, write_js_1.writeChunkDataFn)("tEXt", dataLength, (stream) => {\n let i = 0;\n for (; i < keyword.length; i++) {\n stream.writeUint8(keyword.charCodeAt(i));\n }\n stream.writeUint8(0);\n for (i = 0; i < text2.length; i++) {\n stream.writeUint8(text2.charCodeAt(i));\n }\n });\n }\n tEXt_encode.encodeChunk = encodeChunk;\n return tEXt_encode;\n}\nvar hasRequiredEncoder;\nfunction requireEncoder() {\n if (hasRequiredEncoder) return encoder;\n hasRequiredEncoder = 1;\n Object.defineProperty(encoder, "__esModule", { value: true });\n encoder.encodePng = void 0;\n const byteStream_js_1 = requireByteStream();\n const IDAT_encode_js_1 = requireIDAT_encode();\n const IEND_encode_js_1 = requireIEND_encode();\n const IHDR_encode_js_1 = requireIHDR_encode();\n const assert_js_1 = requireAssert();\n function getChunkDecoder(type) {\n switch (type) {\n case "tRNS":\n return Promise.resolve().then(() => requireTRNS_encode());\n default:\n throw new Error(`Could not get encoder for chunk type "${type}"`);\n }\n }\n async function encodePng(image, options = {}) {\n if (image.data.length !== image.width * image.height * 4) {\n throw new assert_js_1.EncodeError(`Provided image data length (${image.data.length}) is not expected length (${image.width * image.height * 4})`, Math.min(image.data.length, image.width * image.height * 4) - 1);\n }\n const sections = [];\n sections.push(writePngSignature());\n const ctx = analyze(image, options);\n sections.push((0, IHDR_encode_js_1.encodeChunk)(ctx, image));\n if (ctx.colorType === 3) {\n const result2 = (await Promise.resolve().then(() => requirePLTE_encode())).encodeChunk(ctx, image);\n ctx.palette = result2.palette;\n sections.push(result2.chunkData);\n }\n if (ctx.useTransparencyChunk) {\n sections.push((await getChunkDecoder("tRNS")).encodeChunk(ctx, image));\n }\n sections.push((0, IDAT_encode_js_1.encodeChunk)(ctx, image));\n if (options?.ancillaryChunks === void 0) {\n sections.push((await Promise.resolve().then(() => requireTEXt_encode())).encodeChunk(ctx, image, "Software", "@lunapaint/png-codec"));\n } else {\n for (const chunk of options.ancillaryChunks) {\n switch (chunk.type) {\n case "tEXt":\n sections.push((await Promise.resolve().then(() => requireTEXt_encode())).encodeChunk(ctx, image, chunk.keyword, chunk.text));\n break;\n default:\n throw new Error(`Cannot encode chunk type "${chunk.type}"`);\n }\n }\n }\n sections.push((0, IEND_encode_js_1.encodeChunk)());\n const totalLength = sections.reduce((p, c) => p + c.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n for (const s of sections) {\n result.set(s, offset);\n offset += s.length;\n }\n return {\n data: result,\n warnings: ctx.warnings,\n info: ctx.info\n };\n }\n encoder.encodePng = encodePng;\n function writePngSignature() {\n const stream = new byteStream_js_1.ByteStream(8);\n stream.writeUint8(137);\n stream.writeUint8(80);\n stream.writeUint8(78);\n stream.writeUint8(71);\n stream.writeUint8(13);\n stream.writeUint8(10);\n stream.writeUint8(26);\n stream.writeUint8(10);\n stream.assertAtEnd();\n return stream.array;\n }\n function analyze(image, options = {}) {\n const warnings = [];\n const info = [];\n const pixelCount = image.width * image.height;\n const indexCount = pixelCount * 4;\n const colorSet = /* @__PURE__ */ new Set();\n const transparentColorSet = /* @__PURE__ */ new Set();\n let rgbaId = 0;\n if (image.data.BYTES_PER_ELEMENT === 2) {\n for (let i = 0; i < indexCount; i += 4) {\n rgbaId = image.data[i] << 48 | image.data[i + 1] << 32 | image.data[i + 2] << 16 | image.data[i + 3];\n if (image.data[i + 3] < 65535) {\n transparentColorSet.add(rgbaId);\n }\n colorSet.add(rgbaId);\n }\n } else {\n for (let i = 0; i < indexCount; i += 4) {\n rgbaId = image.data[i] << 24 | image.data[i + 1] << 16 | image.data[i + 2] << 8 | image.data[i + 3];\n if (image.data[i + 3] < 255) {\n transparentColorSet.add(rgbaId);\n }\n colorSet.add(rgbaId);\n }\n }\n let colorType = options.colorType;\n if (colorType === void 0) {\n if (colorSet.size > 256 || image.data.BYTES_PER_ELEMENT === 2) {\n colorType = 2;\n } else {\n colorType = 3;\n }\n }\n let useTransparencyChunk;\n switch (colorType) {\n case 0:\n case 2:\n useTransparencyChunk = transparentColorSet.size === 1;\n if (!useTransparencyChunk && transparentColorSet.size > 1) {\n colorType = colorType === 2 ? 6 : 4;\n if (options.colorType === 2) {\n (0, assert_js_1.handleWarning)({ options, warnings }, new assert_js_1.EncodeWarning(`Cannot encode image as color type Truecolor as it contains ${transparentColorSet.size} transparent colors`, 0));\n }\n }\n break;\n case 3:\n useTransparencyChunk = transparentColorSet.size > 0;\n break;\n default:\n useTransparencyChunk = false;\n }\n if (options.colorType === void 0) {\n info.push(`Using color type ${colorType}`);\n }\n return {\n colorType,\n bitDepth: image.data.BYTES_PER_ELEMENT === 2 ? 16 : 8,\n interlaceMethod: 0,\n colorSet,\n transparentColorCount: transparentColorSet.size,\n firstTransparentColor: transparentColorSet.size > 0 ? transparentColorSet.values().next().value : void 0,\n useTransparencyChunk,\n options,\n warnings,\n info\n };\n }\n return encoder;\n}\nvar hasRequiredPng;\nfunction requirePng() {\n if (hasRequiredPng) return png;\n hasRequiredPng = 1;\n (function(exports) {\n Object.defineProperty(exports, "__esModule", { value: true });\n exports.encodePng = exports.decodePng = exports.EncodeWarning = exports.EncodeError = exports.DecodeWarning = exports.DecodeError = void 0;\n var assert_js_1 = requireAssert$1();\n Object.defineProperty(exports, "DecodeError", { enumerable: true, get: function() {\n return assert_js_1.DecodeError;\n } });\n Object.defineProperty(exports, "DecodeWarning", { enumerable: true, get: function() {\n return assert_js_1.DecodeWarning;\n } });\n var assert_js_2 = requireAssert();\n Object.defineProperty(exports, "EncodeError", { enumerable: true, get: function() {\n return assert_js_2.EncodeError;\n } });\n Object.defineProperty(exports, "EncodeWarning", { enumerable: true, get: function() {\n return assert_js_2.EncodeWarning;\n } });\n async function decodePng(data, options) {\n return (await Promise.resolve().then(() => requireDecoder())).decodePng(data, options);\n }\n exports.decodePng = decodePng;\n async function encodePng(data, options) {\n return (await Promise.resolve().then(() => requireEncoder())).encodePng(data, options);\n }\n exports.encodePng = encodePng;\n })(png);\n return png;\n}\nvar pngExports = requirePng();\nfunction unpack8to4(value) {\n const high = value >> 4 & 15;\n const low = value & 15;\n return [high, low];\n}\nfunction convertQuaternion(w, x, y, z) {\n let qw = w;\n let qx = x;\n let qy = y;\n let qz = z;\n if (w < 0) {\n qx = -x;\n qy = -y;\n qz = -z;\n qw = -w;\n }\n const theta = Math.acos(qw) * 2;\n const halfTheta = theta * 0.5;\n const s = Math.sin(halfTheta);\n if (Math.abs(s) < 1e-6) {\n qx = 1;\n qy = 0;\n qz = 0;\n } else {\n qx /= s;\n qy /= s;\n qz /= s;\n }\n const sum = Math.abs(qx) + Math.abs(qy) + Math.abs(qz);\n let px = qx / sum;\n let py = qy / sum;\n if (qz < 0) {\n const previousX = px;\n px = (1 - Math.abs(py)) * (px >= 0 ? 1 : -1);\n py = (1 - Math.abs(previousX)) * (py >= 0 ? 1 : -1);\n }\n const u = Math.min(1, Math.max(0, px * 0.5 + 0.5));\n const v = Math.min(1, Math.max(0, py * 0.5 + 0.5));\n const t = Math.min(1, Math.max(0, theta / Math.PI));\n return {\n u,\n v,\n w: t\n };\n}\nconst worker = self;\nconst ROW_LENGTH_TAVIO = 2 * 3 + 3 + 4 + 3 + 1 + 1;\nconst SPHERICAL_HARMONICS_BASE_ELEMENT = 15 * 3;\nconst TEXTURE_WIDTH_BASE = 1024;\nconst INV_255 = 1 / 255;\nconst INFINITY_F16 = 31744;\nlet currentBuffer = null;\nlet currentIndexBuffer = null;\nlet currentOrderBuffer = null;\nlet currentGeneralBuffer = null;\nlet currentSHBuffer = null;\nlet currentVertexCount = 0;\nlet usingSharedArrayBuffer = false;\nlet usingSphericalHarmonics = false;\nlet currentVertexOffset = 0;\nlet depthUint32;\nconst bucket16 = () => {\n const readback = new Uint16Array(currentOrderBuffer);\n let depthIndex;\n if (usingSharedArrayBuffer === true) {\n depthIndex = new Uint32Array(currentIndexBuffer);\n } else {\n depthIndex = new Uint32Array(currentVertexCount);\n }\n const startTime = Date.now();\n if (depthUint32 == null) {\n depthUint32 = new Uint32Array(INFINITY_F16 + 1);\n }\n depthUint32.fill(0);\n for (let i = 0; i < currentVertexCount; ++i) {\n const depth = readback[i];\n if (depth < INFINITY_F16) {\n depthUint32[depth] += 1;\n }\n }\n let active = 0;\n for (let j = INFINITY_F16 - 1; j >= 0; --j) {\n const next = active + depthUint32[j];\n depthUint32[j] = active;\n active = next;\n }\n for (let k = 0; k < currentVertexCount; ++k) {\n const depth = readback[k];\n if (depth < INFINITY_F16) {\n depthIndex[depthUint32[depth]] = k;\n depthUint32[depth] += 1;\n }\n }\n const time = Date.now() - startTime;\n const updateIndex = true;\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({ updateIndex, currentVertexCount, time });\n } else {\n worker.postMessage({\n updateIndex,\n currentVertexCount,\n time,\n depthIndex\n }, [depthIndex.buffer]);\n }\n};\nconst generateTexture = () => {\n if (currentBuffer == null) {\n return;\n }\n const currentBufferFloatView = new Float16Array(currentBuffer);\n const currentBufferUintView = new Uint8Array(currentBuffer);\n const currentGeneralUintView = new Uint8Array(currentGeneralBuffer);\n const textureWidth = TEXTURE_WIDTH_BASE;\n const textureHeight = Math.ceil(currentVertexCount / textureWidth);\n const textureData = new Uint32Array(textureWidth * textureHeight * 4);\n const textureDataFloatView = new Float16Array(textureData.buffer);\n const textureDataUintView = new Uint8Array(textureData.buffer);\n const halfWidth = TEXTURE_WIDTH_BASE;\n const texelCount = halfWidth * textureHeight;\n let compressed0 = null;\n let compressed1 = null;\n let compressed2 = null;\n let compressed3 = null;\n const floatView = new Float32Array(1);\n const uintView = new Uint32Array(floatView.buffer);\n if (usingSphericalHarmonics === true) {\n compressed0 = new Uint32Array(texelCount * 4);\n compressed1 = new Uint32Array(texelCount * 4);\n compressed2 = new Uint32Array(texelCount * 4);\n compressed3 = new Uint32Array(texelCount * 4);\n }\n let shBuffer = null;\n if (usingSphericalHarmonics === true) {\n shBuffer = new Float32Array(currentSHBuffer);\n }\n const c = new Array(SPHERICAL_HARMONICS_BASE_ELEMENT);\n const tE = (1 << 11) - 1;\n const tT = (1 << 10) - 1;\n for (let i = 0; i < currentVertexCount; ++i) {\n const readFloatIndex = 9 * i;\n const readIntIndex = 18 * i;\n const x = currentBufferFloatView[readFloatIndex + 0];\n const y = currentBufferFloatView[readFloatIndex + 1];\n const z = currentBufferFloatView[readFloatIndex + 2];\n const scaleIndex = readIntIndex + 6;\n const sx = currentBufferUintView[scaleIndex + 0];\n const sy = currentBufferUintView[scaleIndex + 1];\n const sz = currentBufferUintView[scaleIndex + 2];\n const colorIndex = scaleIndex + 3;\n const R = currentBufferUintView[colorIndex + 0];\n const G = currentBufferUintView[colorIndex + 1];\n const B = currentBufferUintView[colorIndex + 2];\n const A = currentBufferUintView[colorIndex + 3];\n const rotationIndex = colorIndex + 4;\n const ru = currentBufferUintView[rotationIndex + 0];\n const rv = currentBufferUintView[rotationIndex + 1];\n const rw = currentBufferUintView[rotationIndex + 2];\n const alphaIndex = rotationIndex + 3;\n const a = currentBufferUintView[alphaIndex];\n const writeFloatIndex = 8 * i;\n const writeIntIndex = 16 * i;\n const writeGeneralUintIndex = 4 * i;\n textureDataFloatView[writeFloatIndex + 0] = x;\n textureDataFloatView[writeFloatIndex + 1] = y;\n textureDataFloatView[writeFloatIndex + 2] = z;\n textureDataUintView[writeIntIndex + 6 + 0] = ru;\n textureDataUintView[writeIntIndex + 6 + 1] = rv;\n textureDataUintView[writeIntIndex + 6 + 2] = sx;\n textureDataUintView[writeIntIndex + 6 + 3] = sy;\n textureDataUintView[writeIntIndex + 6 + 4] = sz;\n textureDataUintView[writeIntIndex + 6 + 5] = rw;\n textureDataUintView[writeIntIndex + 6 + 6] = R;\n textureDataUintView[writeIntIndex + 6 + 7] = G;\n textureDataUintView[writeIntIndex + 6 + 8] = B;\n textureDataUintView[writeIntIndex + 6 + 9] = A;\n currentGeneralUintView[writeGeneralUintIndex + 2] = a;\n if (usingSphericalHarmonics === true) {\n const i4 = i * 4;\n const is = i * SPHERICAL_HARMONICS_BASE_ELEMENT;\n let max = 0;\n for (let j = 0; j < SPHERICAL_HARMONICS_BASE_ELEMENT; ++j) {\n max = Math.max(\n max,\n Math.abs(shBuffer[is + j])\n );\n }\n if (max > 0) {\n c.fill(0);\n for (let k = 0, l = SPHERICAL_HARMONICS_BASE_ELEMENT / 3; k < l; ++k) {\n const k3 = k * 3;\n const nr = Math.floor(\n (shBuffer[is + k3] / max * 0.5 + 0.5) * tE + 0.5\n );\n const ng = Math.floor(\n (shBuffer[is + k3 + 1] / max * 0.5 + 0.5) * tT + 0.5\n );\n const nb = Math.floor(\n (shBuffer[is + k3 + 2] / max * 0.5 + 0.5) * tE + 0.5\n );\n c[k3 + 0] = Math.max(Math.min(tE, nr), 0);\n c[k3 + 1] = Math.max(Math.min(tT, ng), 0);\n c[k3 + 2] = Math.max(Math.min(tE, nb), 0);\n }\n floatView[0] = max;\n compressed0[i4] = c[0] << 21 | c[1] << 11 | c[2];\n compressed0[i4 + 1] = c[3] << 21 | c[4] << 11 | c[5];\n compressed0[i4 + 2] = c[6] << 21 | c[7] << 11 | c[8];\n compressed0[i4 + 3] = c[9] << 21 | c[10] << 11 | c[11];\n compressed1[i4] = c[12] << 21 | c[13] << 11 | c[14];\n compressed1[i4 + 1] = c[15] << 21 | c[16] << 11 | c[17];\n compressed1[i4 + 2] = c[18] << 21 | c[19] << 11 | c[20];\n compressed1[i4 + 3] = c[21] << 21 | c[22] << 11 | c[23];\n compressed2[i4] = c[24] << 21 | c[25] << 11 | c[26];\n compressed2[i4 + 1] = c[27] << 21 | c[28] << 11 | c[29];\n compressed2[i4 + 2] = c[30] << 21 | c[31] << 11 | c[32];\n compressed2[i4 + 3] = c[33] << 21 | c[34] << 11 | c[35];\n compressed3[i4] = c[36] << 21 | c[37] << 11 | c[38];\n compressed3[i4 + 1] = c[39] << 21 | c[40] << 11 | c[41];\n compressed3[i4 + 2] = c[42] << 21 | c[43] << 11 | c[44];\n compressed3[i4 + 3] = uintView[0];\n }\n }\n }\n if (usingSphericalHarmonics === true) {\n worker.postMessage({\n textureData,\n textureWidth,\n textureHeight,\n compressed0,\n compressed1,\n compressed2,\n compressed3\n }, [\n textureData.buffer,\n compressed0.buffer,\n compressed1.buffer,\n compressed2.buffer,\n compressed3.buffer\n ]);\n } else {\n worker.postMessage({\n textureData,\n textureWidth,\n textureHeight\n }, [\n textureData.buffer\n ]);\n }\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount\n });\n } else {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount,\n generalBuffer: currentGeneralBuffer\n });\n }\n};\nconst convertProperty = async (prop) => {\n const count = prop.position.decoded.length / prop.position.channelCount;\n let scale = null;\n let rotation = null;\n let alpha = null;\n const scaleEncode = prop.scale.encode;\n const rotationEncode = prop.rotation.encode;\n const alphaEncode = prop.alpha.encode;\n if (scaleEncode === "ZIP") {\n scale = inflate_1(prop.scale.decoded);\n } else if (scaleEncode === "PNG") {\n const scaleDecoded = await pngExports.decodePng(new Uint8Array(prop.scale.decoded));\n scale = scaleDecoded.image.data;\n }\n if (rotationEncode === "ZIP") {\n rotation = inflate_1(prop.rotation.decoded);\n } else if (rotationEncode === "PNG") {\n const rotationDecoded = await pngExports.decodePng(new Uint8Array(prop.rotation.decoded));\n rotation = rotationDecoded.image.data;\n }\n const rotationMin = prop.rotation.min;\n const rotationRange0 = prop.rotation.max[0] - rotationMin[0];\n const rotationRange1 = prop.rotation.max[1] - rotationMin[1];\n const rotationRange2 = prop.rotation.max[2] - rotationMin[2];\n const rotationRange3 = prop.rotation.max[3] - rotationMin[3];\n if (alphaEncode === "ZIP") {\n alpha = inflate_1(prop.alpha.decoded);\n } else if (alphaEncode === "PNG") {\n const alphaDecoded = await pngExports.decodePng(new Uint8Array(prop.alpha.decoded));\n alpha = alphaDecoded.image.data;\n }\n const isInfinity = !isFinite(prop.alpha.min[0]) || !isFinite(prop.alpha.max[0]);\n const alphaMin = isInfinity === true ? 9.9 : prop.alpha.min[0];\n const alphaMax = isInfinity === true ? 10 : prop.alpha.max[0];\n const alphaRange = alphaMax - alphaMin;\n const position = prop.position.decoded;\n const sh0 = prop.sh0.decoded;\n for (let i = 0; i < count; ++i) {\n const ir = (i + currentVertexOffset) * ROW_LENGTH_TAVIO;\n const i3 = i * 3;\n const i4 = i * 4;\n let s0 = 0;\n let s1 = 0;\n let s2 = 0;\n let a0 = 0;\n let c3 = 0;\n let r0 = 0;\n let r1 = 0;\n let r2 = 0;\n let r3 = 0;\n if (scaleEncode === "ZIP") {\n s0 = scale[i3 + 0];\n s1 = scale[i3 + 1];\n s2 = scale[i3 + 2];\n } else if (scaleEncode === "PNG") {\n s0 = scale[i4 + 2];\n s1 = scale[i4 + 1];\n s2 = scale[i4 + 0];\n }\n if (alphaEncode === "ZIP") {\n a0 = alpha[i];\n c3 = alpha[i] * INV_255 * alphaRange + alphaMin;\n } else if (alphaEncode === "PNG") {\n a0 = alpha[i4];\n c3 = alpha[i4] * INV_255 * alphaRange + alphaMin;\n }\n if (rotationEncode === "ZIP") {\n r0 = rotation[i4 + 0] * INV_255 * rotationRange0 + rotationMin[0];\n r1 = rotation[i4 + 1] * INV_255 * rotationRange1 + rotationMin[1];\n r2 = rotation[i4 + 2] * INV_255 * rotationRange2 + rotationMin[2];\n r3 = rotation[i4 + 3] * INV_255 * rotationRange3 + rotationMin[3];\n } else if (rotationEncode === "PNG") {\n r0 = rotation[i4 + 2] * INV_255 * rotationRange0 + rotationMin[0];\n r1 = rotation[i4 + 1] * INV_255 * rotationRange1 + rotationMin[1];\n r2 = rotation[i4 + 0] * INV_255 * rotationRange2 + rotationMin[2];\n r3 = rotation[i4 + 3] * INV_255 * rotationRange3 + rotationMin[3];\n }\n const viewPosition = new Float16Array(currentBuffer, ir, 3);\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const viewColor = new Uint8ClampedArray(currentBuffer, ir + 9, 4);\n const viewRotation = new Uint8ClampedArray(currentBuffer, ir + 13, 3);\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n viewPosition[0] = position[i3];\n viewPosition[1] = position[i3 + 1];\n viewPosition[2] = position[i3 + 2];\n viewScale[0] = s0;\n viewScale[1] = s1;\n viewScale[2] = s2;\n const qlen = 1 / Math.sqrt(r0 * r0 + r1 * r1 + r2 * r2 + r3 * r3);\n const qw = r0 * qlen;\n const qx = r1 * qlen;\n const qy = r2 * qlen;\n const qz = r3 * qlen;\n const qt = convertQuaternion(qw, qx, qy, qz);\n viewRotation[0] = qt.u * 255;\n viewRotation[1] = qt.v * 255;\n viewRotation[2] = qt.w * 255;\n viewColor[0] = sh0[i3];\n viewColor[1] = sh0[i3 + 1];\n viewColor[2] = sh0[i3 + 2];\n viewColor[3] = 1 / (1 + Math.exp(-c3)) * 255;\n viewRawAlpha[0] = a0;\n }\n if (currentVertexOffset > 0) {\n const scale2 = prop.scale;\n const alpha2 = prop.alpha;\n const scaleRangeX = scale2.max[0] - scale2.min[0];\n const scaleRangeY = scale2.max[1] - scale2.min[1];\n const scaleRangeZ = scale2.max[2] - scale2.min[2];\n const alphaRange2 = alpha2.max[0] - alpha2.min[0];\n const preScale = prop.previousScale;\n const preAlpha = prop.previousAlpha;\n const preScaleRangeX = preScale.max[0] - preScale.min[0];\n const preScaleRangeY = preScale.max[1] - preScale.min[1];\n const preScaleRangeZ = preScale.max[2] - preScale.min[2];\n const preAlphaRange = preAlpha.max[0] - preAlpha.min[0];\n const curScaleMinX = Math.min(scale2.min[0], preScale.min[0]);\n const curScaleMinY = Math.min(scale2.min[1], preScale.min[1]);\n const curScaleMinZ = Math.min(scale2.min[2], preScale.min[2]);\n const curScaleMaxX = Math.max(scale2.max[0], preScale.max[0]);\n const curScaleMaxY = Math.max(scale2.max[1], preScale.max[1]);\n const curScaleMaxZ = Math.max(scale2.max[2], preScale.max[2]);\n const curAlphaMin = Math.min(alpha2.min[0], preAlpha.min[0]);\n const curAlphaMax = Math.max(alpha2.max[0], preAlpha.max[0]);\n const curScaleRangeX = curScaleMaxX - curScaleMinX;\n const curScaleRangeY = curScaleMaxY - curScaleMinY;\n const curScaleRangeZ = curScaleMaxZ - curScaleMinZ;\n const curAlphaRange = curAlphaMax - curAlphaMin;\n for (let i = 0; i < currentVertexOffset; ++i) {\n const ir = i * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * preScaleRangeX + preScale.min[0];\n const rsy = viewScale[1] * INV_255 * preScaleRangeY + preScale.min[1];\n const rsz = viewScale[2] * INV_255 * preScaleRangeZ + preScale.min[2];\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * preAlphaRange + preAlpha.min[0];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n for (let j = currentVertexOffset; j < currentVertexCount; ++j) {\n const ir = j * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * scaleRangeX + scale2.min[0];\n const rsy = viewScale[1] * INV_255 * scaleRangeY + scale2.min[1];\n const rsz = viewScale[2] * INV_255 * scaleRangeZ + scale2.min[2];\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * alphaRange2 + alpha2.min[0];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n }\n worker.postMessage({\n compressedSH: false\n });\n};\nconst convertSHProperty = async (shN) => {\n if (usingSphericalHarmonics !== true) {\n return;\n }\n const invBase = 1 / (Math.pow(2, shN.quantize) - 1);\n const shNMin = shN.min;\n const shNRange = shN.max - shNMin;\n const centroid = inflate_1(shN.centroid.decoded);\n const table = [];\n for (let k = 0, l = shN.cluster; k < l; ++k) {\n const n = k * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const element = [];\n for (let m = 0; m < SPHERICAL_HARMONICS_BASE_ELEMENT; ++m) {\n const c = centroid[m + n] * invBase * shNRange + shNMin;\n element.push(c);\n }\n table[k] = element;\n }\n const label = new Uint16Array(inflate_1(shN.label.decoded).buffer);\n const shBuffer = new Float32Array(currentSHBuffer);\n const count = currentVertexCount - currentVertexOffset;\n for (let o = 0, p = count; o < p; ++o) {\n const index = (o + currentVertexOffset) * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const sh = table[label[o]];\n for (let q = 0; q < SPHERICAL_HARMONICS_BASE_ELEMENT; ++q) {\n shBuffer[index + q] = sh[q];\n }\n }\n worker.postMessage({\n compressedSH: true\n });\n};\nconst create4x4 = (translation, rotation, scale) => {\n const sx = Math.sin(rotation[0]);\n const sy = Math.sin(rotation[1]);\n const sz = Math.sin(rotation[2]);\n const cx = Math.cos(rotation[0]);\n const cy = Math.cos(rotation[1]);\n const cz = Math.cos(rotation[2]);\n const ae = cx * cz;\n const af = cx * sz;\n const be = sx * cz;\n const bf = sx * sz;\n const mat = new Float32Array(16);\n mat[0] = cy * cz * scale;\n mat[1] = (af + be * sy) * scale;\n mat[2] = (bf - ae * sy) * scale;\n mat[3] = 0;\n mat[4] = -cy * sz * scale;\n mat[5] = (ae - bf * sy) * scale;\n mat[6] = (be + af * sy) * scale;\n mat[7] = 0;\n mat[8] = sy * scale;\n mat[9] = -sx * cy * scale;\n mat[10] = cx * cy * scale;\n mat[11] = 0;\n mat[12] = translation[0];\n mat[13] = translation[1];\n mat[14] = translation[2];\n mat[15] = 1;\n return mat;\n};\nconst apply4x4 = (m, x, y, z) => {\n const w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);\n return [\n (m[0] * x + m[4] * y + m[8] * z + m[12]) * w,\n (m[1] * x + m[5] * y + m[9] * z + m[13]) * w,\n (m[2] * x + m[6] * y + m[10] * z + m[14]) * w\n ];\n};\nconst checkSphereCollision = (c, x, y, z) => {\n const px = x - c.position[0];\n const py = y - c.position[1];\n const pz = z - c.position[2];\n const distance = Math.sqrt(px * px + py * py + pz * pz);\n const radius = Math.max(c.scale[0] * c.radius, c.scale[1] * c.radius, c.scale[2] * c.radius);\n if (distance <= radius) {\n const l = apply4x4(c.inverse4x4, x, y, z);\n const d = Math.sqrt(l[0] * l[0] + l[1] * l[1] + l[2] * l[2]);\n return d <= c.radius;\n } else {\n return false;\n }\n};\nconst checkBoxCollision = (c, x, y, z) => {\n const l = apply4x4(c.inverse4x4, x, y, z);\n const w = c.width * 0.5;\n const h = c.height * 0.5;\n const d = c.depth * 0.5;\n return -w <= l[0] && l[0] <= w && (-h <= l[1] && l[1] <= h) && (-d <= l[2] && l[2] <= d);\n};\nconst checkCollision = (sourceTransform, target) => {\n if (currentGeneralBuffer == null) {\n return;\n }\n const currentBufferFloatView = new Float16Array(currentBuffer);\n const currentGeneralByteView = new Uint8Array(currentGeneralBuffer);\n const targets = Array.isArray(target) ? target : [target];\n const targetCount = Math.min(targets.length, 8);\n let reversed = false;\n for (let _i = 0; _i < targetCount; ++_i) {\n reversed = reversed || targets[_i].reversed === true;\n }\n const sources = Array.isArray(sourceTransform) === true ? sourceTransform : [sourceTransform];\n const modelMatrix = sources.map((source) => {\n const t = [-source.translation.x, -source.translation.y, source.translation.z];\n const r = [source.rotation.x, source.rotation.y, source.rotation.z];\n const s = source.scale;\n return create4x4(t, r, s);\n });\n for (let i = 0; i < currentVertexCount; ++i) {\n const iIndex = 4 * i;\n let R = currentGeneralByteView[iIndex];\n let G = currentGeneralByteView[iIndex + 1];\n let B = currentGeneralByteView[iIndex + 2];\n let A = currentGeneralByteView[iIndex + 3];\n const [meshIndex, instanceIndex] = unpack8to4(A);\n if (G > 0) {\n R = 0;\n } else {\n const fIndex = 9 * i;\n const tx = currentBufferFloatView[fIndex + 0];\n const ty = currentBufferFloatView[fIndex + 1];\n const tz = currentBufferFloatView[fIndex + 2];\n const transformed = apply4x4(modelMatrix[instanceIndex], tx, ty, tz);\n const x = transformed[0];\n const y = transformed[1];\n const z = transformed[2];\n for (let j = 0; j < targetCount; ++j) {\n const masked = R & ~(1 << j);\n const t = targets[j];\n if (t.type === "sphere") {\n const sphere = t.target;\n const inclusion = checkSphereCollision(sphere, x, y, z);\n R = masked | +inclusion << j;\n } else if (t.type === "box") {\n const box = t.target;\n const inclusion = checkBoxCollision(box, x, y, z);\n R = masked | +inclusion << j;\n }\n }\n if (reversed === true) {\n R = R > 0 ? 0 : 1;\n }\n }\n currentGeneralByteView[iIndex] = R;\n currentGeneralByteView[iIndex + 1] = G;\n currentGeneralByteView[iIndex + 2] = B;\n currentGeneralByteView[iIndex + 3] = A;\n }\n if (usingSharedArrayBuffer === true) {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount\n });\n } else {\n worker.postMessage({\n updateCollision: true,\n currentVertexCount,\n generalBuffer: currentGeneralBuffer\n });\n }\n};\nconst mergeBuffer = (data) => {\n const offset = currentVertexOffset * ROW_LENGTH_TAVIO;\n const viewBuffer = new Uint8ClampedArray(currentBuffer);\n const newArray = new Uint8ClampedArray(data.buffer);\n viewBuffer.set(newArray, offset);\n const shOffset = currentVertexOffset * SPHERICAL_HARMONICS_BASE_ELEMENT;\n const viewSHBuffer = new Float32Array(currentSHBuffer);\n const newSHArray = new Float32Array(data.shBuffer);\n viewSHBuffer.set(newSHArray, shOffset);\n const scale = data.scale;\n const scaleRangeX = scale.max[0] - scale.min[0];\n const scaleRangeY = scale.max[1] - scale.min[1];\n const scaleRangeZ = scale.max[2] - scale.min[2];\n const alpha = data.alpha;\n const alphaRange = alpha.max[0] - alpha.min[0];\n const preScale = data.previousScale;\n const preScaleRangeX = preScale.max[0] - preScale.min[0];\n const preScaleRangeY = preScale.max[1] - preScale.min[1];\n const preScaleRangeZ = preScale.max[2] - preScale.min[2];\n const preAlpha = data.previousAlpha;\n const preAlphaRange = preAlpha.max[0] - preAlpha.min[0];\n const curScaleMinX = Math.min(scale.min[0], preScale.min[0]);\n const curScaleMinY = Math.min(scale.min[1], preScale.min[1]);\n const curScaleMinZ = Math.min(scale.min[2], preScale.min[2]);\n const curScaleMaxX = Math.max(scale.max[0], preScale.max[0]);\n const curScaleMaxY = Math.max(scale.max[1], preScale.max[1]);\n const curScaleMaxZ = Math.max(scale.max[2], preScale.max[2]);\n const curScaleRangeX = curScaleMaxX - curScaleMinX;\n const curScaleRangeY = curScaleMaxY - curScaleMinY;\n const curScaleRangeZ = curScaleMaxZ - curScaleMinZ;\n const curAlphaMin = Math.min(alpha.min[0], preAlpha.min[0]);\n const curAlphaMax = Math.max(alpha.max[0], preAlpha.max[0]);\n const curAlphaRange = curAlphaMax - curAlphaMin;\n for (let i = 0; i < currentVertexOffset; ++i) {\n const ir = i * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * preScaleRangeX + preScale.min[0];\n const rsy = viewScale[1] * INV_255 * preScaleRangeY + preScale.min[1];\n const rsz = viewScale[2] * INV_255 * preScaleRangeZ + preScale.min[2];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * preAlphaRange + preAlpha.min[0];\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n for (let j = currentVertexOffset; j < currentVertexCount; ++j) {\n const ir = j * ROW_LENGTH_TAVIO;\n const viewScale = new Uint8ClampedArray(currentBuffer, ir + 6, 3);\n const rsx = viewScale[0] * INV_255 * scaleRangeX + scale.min[0];\n const rsy = viewScale[1] * INV_255 * scaleRangeY + scale.min[1];\n const rsz = viewScale[2] * INV_255 * scaleRangeZ + scale.min[2];\n viewScale[0] = (rsx - curScaleMinX) / curScaleRangeX * 255;\n viewScale[1] = (rsy - curScaleMinY) / curScaleRangeY * 255;\n viewScale[2] = (rsz - curScaleMinZ) / curScaleRangeZ * 255;\n const viewRawAlpha = new Uint8ClampedArray(currentBuffer, ir + 16, 1);\n const ra = viewRawAlpha[0] * INV_255 * alphaRange + alpha.min[0];\n viewRawAlpha[0] = (ra - curAlphaMin) / curAlphaRange * 255;\n }\n};\nonmessage = (e) => {\n if (e.data.usingSharedArrayBuffer != null) {\n usingSharedArrayBuffer = e.data.usingSharedArrayBuffer;\n currentVertexCount = e.data.vertexCount;\n currentVertexOffset = e.data.offset;\n if (usingSharedArrayBuffer === true) {\n currentBuffer = e.data.buffer;\n currentIndexBuffer = e.data.indexBuffer;\n currentOrderBuffer = e.data.orderBuffer;\n currentGeneralBuffer = e.data.generalBuffer;\n currentSHBuffer = e.data.shBuffer;\n } else {\n if (currentVertexOffset > 0) {\n const tempBuffer = new ArrayBuffer(e.data.gaussianDataSize);\n const temp8Array = new Uint8Array(tempBuffer);\n temp8Array.set(new Uint8Array(currentBuffer));\n currentBuffer = tempBuffer;\n const tempGeneralBuffer = new ArrayBuffer(e.data.generalDataSize);\n const tempGeneral8Array = new Uint8Array(tempGeneralBuffer);\n tempGeneral8Array.set(new Uint8Array(currentGeneralBuffer));\n currentGeneralBuffer = tempGeneralBuffer;\n const tempSHBuffer = new ArrayBuffer(e.data.shDataSize);\n const tempSH8Array = new Uint8Array(tempSHBuffer);\n tempSH8Array.set(new Uint8Array(currentSHBuffer));\n currentSHBuffer = tempSHBuffer;\n } else {\n currentBuffer = new ArrayBuffer(e.data.gaussianDataSize);\n currentIndexBuffer = null;\n currentOrderBuffer = null;\n currentGeneralBuffer = new ArrayBuffer(e.data.generalDataSize);\n currentSHBuffer = new ArrayBuffer(e.data.shDataSize);\n }\n }\n } else if (e.data.properties != null) {\n convertProperty(e.data.properties);\n } else if (e.data.shProperty != null) {\n convertSHProperty(e.data.shProperty);\n } else if (e.data.updateTexture != null) {\n if (e.data.previousScale != null) {\n mergeBuffer(e.data);\n } else {\n if (usingSharedArrayBuffer === true) {\n const viewBuffer = new Uint8ClampedArray(currentBuffer);\n const newArray = new Uint8ClampedArray(e.data.buffer);\n viewBuffer.set(newArray);\n if (e.data.shBuffer != null) {\n const viewSHBuffer = new Float32Array(currentSHBuffer);\n const newSHArray = new Float32Array(e.data.shBuffer);\n viewSHBuffer.set(newSHArray);\n }\n } else {\n if (e.data.buffer != null) {\n currentBuffer = e.data.buffer;\n }\n if (e.data.shBuffer != null) {\n currentSHBuffer = e.data.shBuffer;\n }\n }\n }\n generateTexture();\n } else if (e.data.updateOrder != null) {\n if (usingSharedArrayBuffer !== true) {\n currentOrderBuffer = e.data.orderBuffer;\n }\n bucket16();\n } else if (e.data.updateGeneralData != null) {\n currentGeneralBuffer = e.data.generalBuffer;\n } else if (e.data.usingSphericalHarmonics != null) {\n usingSphericalHarmonics = e.data.usingSphericalHarmonics;\n } else if (e.data.collision != null) {\n checkCollision(e.data.source, e.data.collision);\n } else if (e.ports.length > 0 && e.data.requestBuffer != null) {\n const port = e.ports[0];\n const gaussianData = new Uint8Array(currentBuffer).slice();\n const sphericalHarmonicsData = new Float32Array(currentSHBuffer).slice();\n port.postMessage({\n gaussianData,\n sphericalHarmonicsData\n }, [\n gaussianData.buffer,\n sphericalHarmonicsData.buffer\n ]);\n }\n};\n';
|
|
37442
|
+
const blob = typeof self !== "undefined" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", jsContent], { type: "text/javascript;charset=utf-8" });
|
|
37431
37443
|
function WorkerWrapper$1(options) {
|
|
37432
37444
|
let objURL;
|
|
37433
37445
|
try {
|
|
37434
|
-
objURL = blob
|
|
37446
|
+
objURL = blob && (self.URL || self.webkitURL).createObjectURL(blob);
|
|
37435
37447
|
if (!objURL) throw "";
|
|
37436
37448
|
const worker = new Worker(objURL, {
|
|
37437
37449
|
type: "module",
|
|
@@ -37443,7 +37455,7 @@ function WorkerWrapper$1(options) {
|
|
|
37443
37455
|
return worker;
|
|
37444
37456
|
} catch (e) {
|
|
37445
37457
|
return new Worker(
|
|
37446
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(jsContent
|
|
37458
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(jsContent),
|
|
37447
37459
|
{
|
|
37448
37460
|
type: "module",
|
|
37449
37461
|
name: options?.name
|
|
@@ -37459,10 +37471,10 @@ const TavioWasm = /* @__PURE__ */ (() => {
|
|
|
37459
37471
|
const isThreadSupported = false;
|
|
37460
37472
|
const instance = isThreadSupported ? (
|
|
37461
37473
|
// @ts-ignore
|
|
37462
|
-
await import("./wasm/pkg/thread")
|
|
37474
|
+
await import("./wasm/pkg/thread/tavio.js")
|
|
37463
37475
|
) : (
|
|
37464
37476
|
// @ts-ignore
|
|
37465
|
-
await import("./wasm/pkg/no-thread")
|
|
37477
|
+
await import("./wasm/pkg/no-thread/tavio.js")
|
|
37466
37478
|
);
|
|
37467
37479
|
console.info("[TavioMesh] Initializing WASM...");
|
|
37468
37480
|
try {
|
|
@@ -37489,30 +37501,14 @@ const TavioWasm = /* @__PURE__ */ (() => {
|
|
|
37489
37501
|
return instancePromise;
|
|
37490
37502
|
};
|
|
37491
37503
|
})();
|
|
37492
|
-
const jsContent = 'let wasm = null;\nglobalThis.allocateSharedArrayBuffer = (oldSharedArrayBuffer, newByteSize) => {\n const newSharedArrayBuffer = new SharedArrayBuffer(newByteSize);\n if (oldSharedArrayBuffer) {\n new Uint8Array(newSharedArrayBuffer).set(\n new Uint8Array(oldSharedArrayBuffer)\n );\n }\n return newSharedArrayBuffer;\n};\nself.onmessage = async (e) => {\n switch (e.data.kind) {\n case "init":\n await init(e.data.options);\n break;\n case "registerEventHandler":\n wasm.registerEventHandler((e2) => {\n const message = {\n category: "wasmCallback",\n data: e2\n };\n postMessage(message, collectTransferables(e2));\n });\n break;\n default:\n if ("id" in e.data && "args" in e.data) {\n const { kind, id, args } = e.data;\n try {\n const fn = wasm[kind];\n const result = await fn(...args);\n const message = { kind, id, result };\n postMessage(message);\n } catch (error) {\n const message = {\n category: "wasmError",\n id,\n error\n };\n postMessage(message);\n }\n }\n break;\n }\n};\nasync function init(options) {\n const useSharedArrayBuffer = options?.useSharedArrayBuffer == true;\n const threadCount = Math.min(\n options?.threadCount ?? 1,\n navigator.hardwareConcurrency\n );\n const isParallel = useSharedArrayBuffer && threadCount > 1;\n wasm = useSharedArrayBuffer ? (\n // @ts-ignore\n await import("./wasm/pkg/thread")\n ) : (\n // @ts-ignore\n await import("./wasm/pkg/no-thread")\n );\n try {\n await wasm.default();\n console.info(\n ` WASM${useSharedArrayBuffer ? " (thread)" : "(no-thread)"} initialized successfully`\n );\n } catch (e) {\n console.error("[WasmWorker] Failed to initialize WASM (tavio_bg.wasm):", e);\n console.error("[WasmWorker] This error typically occurs when:");\n console.error(\n " 1. The tavio_bg.wasm file is not deployed to the correct path"\n );\n console.error(" 2. CORS policy is blocking the WASM file");\n console.error(\n " 3. The WASM file has incorrect MIME type (should be application/wasm)"\n );\n throw e;\n }\n if (isParallel) {\n try {\n console.info(\n `[WasmWorker] Initializing thread pool with ${threadCount} threads...`\n );\n wasm.initThreadPool(threadCount);\n console.info("[WasmWorker] Thread pool initialized successfully");\n } catch (e) {\n console.error("[WasmWorker] Failed to initialize thread pool:", e);\n console.error("[WasmWorker] This error typically occurs when:");\n console.error(\n " 1. workerHelpers.js is not deployed to the correct path"\n );\n console.error(\n " 2. SharedArrayBuffer is not available (requires secure context and COOP/COEP headers)"\n );\n throw e;\n }\n }\n postMessage({ category: "wasmLoaded" });\n}\nfunction collectTransferables(value) {\n if (!value || typeof value !== "object") return [];\n const set = /* @__PURE__ */ new Set();\n for (const v of Object.values(value)) {\n if (v instanceof ArrayBuffer) {\n set.add(v);\n } else if (ArrayBuffer.isView(v)) {\n set.add(v.buffer);\n }\n }\n return Array.from(set);\n}\n';
|
|
37493
|
-
const blob = typeof self !== "undefined" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", jsContent], { type: "text/javascript;charset=utf-8" });
|
|
37494
37504
|
function WorkerWrapper(options) {
|
|
37495
|
-
|
|
37496
|
-
|
|
37497
|
-
|
|
37498
|
-
if (!objURL) throw "";
|
|
37499
|
-
const worker = new Worker(objURL, {
|
|
37505
|
+
return new Worker(
|
|
37506
|
+
"" + new URL("wasm-worker-CEuC2YyS.js", import.meta.url).href,
|
|
37507
|
+
{
|
|
37500
37508
|
type: "module",
|
|
37501
37509
|
name: options?.name
|
|
37502
|
-
}
|
|
37503
|
-
|
|
37504
|
-
(self.URL || self.webkitURL).revokeObjectURL(objURL);
|
|
37505
|
-
});
|
|
37506
|
-
return worker;
|
|
37507
|
-
} catch (e) {
|
|
37508
|
-
return new Worker(
|
|
37509
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(jsContent),
|
|
37510
|
-
{
|
|
37511
|
-
type: "module",
|
|
37512
|
-
name: options?.name
|
|
37513
|
-
}
|
|
37514
|
-
);
|
|
37515
|
-
}
|
|
37510
|
+
}
|
|
37511
|
+
);
|
|
37516
37512
|
}
|
|
37517
37513
|
class TavioWasmWorkerClient {
|
|
37518
37514
|
worker = new WorkerWrapper();
|