@niivue/niivue
Version:
minimal webgl2 nifti image viewer
1,582 lines (1,579 loc) • 4.51 MB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
var __commonJS = (cb, mod) => function __require2() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key2 of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key2) && key2 !== except)
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
// node_modules/array-equal/index.js
var require_array_equal = __commonJS({
"node_modules/array-equal/index.js"(exports2, module2) {
module2.exports = function equal(arr1, arr2) {
var length4 = arr1.length;
if (arr1 === arr2) return true;
if (length4 !== arr2.length) return false;
for (var i2 = 0; i2 < length4; i2++)
if (arr1[i2] !== arr2[i2])
return false;
return true;
};
}
});
// node_modules/fflate/lib/node.cjs
var require_node = __commonJS({
"node_modules/fflate/lib/node.cjs"(exports2) {
"use strict";
var Worker2;
var workerAdd = ";var __w=require('worker_threads');__w.parentPort.on('message',function(m){onmessage({data:m})}),postMessage=function(m,t){__w.parentPort.postMessage(m,t)},close=process.exit;self=global";
try {
Worker2 = __require("worker_threads").Worker;
} catch (e) {
}
var node_worker_1 = {};
node_worker_1["default"] = Worker2 ? function(c, _, msg, transfer, cb) {
var done = false;
var w = new Worker2(c + workerAdd, { eval: true }).on("error", function(e) {
return cb(e, null);
}).on("message", function(m) {
return cb(null, m);
}).on("exit", function(c2) {
if (c2 && !done)
cb(new Error("exited with code " + c2), null);
});
w.postMessage(msg, transfer);
w.terminate = function() {
done = true;
return Worker2.prototype.terminate.call(w);
};
return w;
} : function(_, __, ___, ____, cb) {
setImmediate(function() {
return cb(new Error("async operations unsupported - update to Node 12+ (or Node 10-11 with the --experimental-worker CLI flag)"), null);
});
var NOP = function() {
};
return {
terminate: NOP,
postMessage: NOP
};
};
var u82 = Uint8Array;
var u162 = Uint16Array;
var i322 = Int32Array;
var fleb2 = new u82([
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,
/* unused */
0,
0,
/* impossible */
0
]);
var fdeb2 = new u82([
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,
/* unused */
0,
0
]);
var clim2 = new u82([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
var freb2 = function(eb, start) {
var b = new u162(31);
for (var i3 = 0; i3 < 31; ++i3) {
b[i3] = start += 1 << eb[i3 - 1];
}
var r = new i322(b[30]);
for (var i3 = 1; i3 < 30; ++i3) {
for (var j = b[i3]; j < b[i3 + 1]; ++j) {
r[j] = j - b[i3] << 5 | i3;
}
}
return { b, r };
};
var _a2 = freb2(fleb2, 2);
var fl2 = _a2.b;
var revfl2 = _a2.r;
fl2[28] = 258, revfl2[258] = 28;
var _b2 = freb2(fdeb2, 0);
var fd2 = _b2.b;
var revfd2 = _b2.r;
var rev2 = new u162(32768);
for (i2 = 0; i2 < 32768; ++i2) {
x = (i2 & 43690) >> 1 | (i2 & 21845) << 1;
x = (x & 52428) >> 2 | (x & 13107) << 2;
x = (x & 61680) >> 4 | (x & 3855) << 4;
rev2[i2] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
}
var x;
var i2;
var hMap2 = function(cd, mb, r) {
var s = cd.length;
var i3 = 0;
var l = new u162(mb);
for (; i3 < s; ++i3) {
if (cd[i3])
++l[cd[i3] - 1];
}
var le = new u162(mb);
for (i3 = 1; i3 < mb; ++i3) {
le[i3] = le[i3 - 1] + l[i3 - 1] << 1;
}
var co;
if (r) {
co = new u162(1 << mb);
var rvb = 15 - mb;
for (i3 = 0; i3 < s; ++i3) {
if (cd[i3]) {
var sv = i3 << 4 | cd[i3];
var r_1 = mb - cd[i3];
var v = le[cd[i3] - 1]++ << r_1;
for (var m = v | (1 << r_1) - 1; v <= m; ++v) {
co[rev2[v] >> rvb] = sv;
}
}
}
} else {
co = new u162(s);
for (i3 = 0; i3 < s; ++i3) {
if (cd[i3]) {
co[i3] = rev2[le[cd[i3] - 1]++] >> 15 - cd[i3];
}
}
}
return co;
};
var flt2 = new u82(288);
for (i2 = 0; i2 < 144; ++i2)
flt2[i2] = 8;
var i2;
for (i2 = 144; i2 < 256; ++i2)
flt2[i2] = 9;
var i2;
for (i2 = 256; i2 < 280; ++i2)
flt2[i2] = 7;
var i2;
for (i2 = 280; i2 < 288; ++i2)
flt2[i2] = 8;
var i2;
var fdt2 = new u82(32);
for (i2 = 0; i2 < 32; ++i2)
fdt2[i2] = 5;
var i2;
var flm2 = /* @__PURE__ */ hMap2(flt2, 9, 0);
var flrm2 = /* @__PURE__ */ hMap2(flt2, 9, 1);
var fdm2 = /* @__PURE__ */ hMap2(fdt2, 5, 0);
var fdrm2 = /* @__PURE__ */ hMap2(fdt2, 5, 1);
var max5 = function(a) {
var m = a[0];
for (var i3 = 1; i3 < a.length; ++i3) {
if (a[i3] > m)
m = a[i3];
}
return m;
};
var bits2 = function(d, p, m) {
var o = p / 8 | 0;
return (d[o] | d[o + 1] << 8) >> (p & 7) & m;
};
var bits162 = function(d, p) {
var o = p / 8 | 0;
return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
};
var shft2 = function(p) {
return (p + 7) / 8 | 0;
};
var slc2 = function(v, s, e) {
if (s == null || s < 0)
s = 0;
if (e == null || e > v.length)
e = v.length;
return new u82(v.subarray(s, e));
};
exports2.FlateErrorCode = {
UnexpectedEOF: 0,
InvalidBlockType: 1,
InvalidLengthLiteral: 2,
InvalidDistance: 3,
StreamFinished: 4,
NoStreamHandler: 5,
InvalidHeader: 6,
NoCallback: 7,
InvalidUTF8: 8,
ExtraFieldTooLong: 9,
InvalidDate: 10,
FilenameTooLong: 11,
StreamFinishing: 12,
InvalidZipData: 13,
UnknownCompressionMethod: 14
};
var ec2 = [
"unexpected EOF",
"invalid block type",
"invalid length/literal",
"invalid distance",
"stream finished",
"no stream handler",
,
"no callback",
"invalid UTF-8 data",
"extra field too long",
"date not in range 1980-2099",
"filename too long",
"stream finishing",
"invalid zip data"
// determined by unknown compression method
];
var err2 = function(ind, msg, nt) {
var e = new Error(msg || ec2[ind]);
e.code = ind;
if (Error.captureStackTrace)
Error.captureStackTrace(e, err2);
if (!nt)
throw e;
return e;
};
var inflt2 = function(dat, st, buf, dict) {
var sl = dat.length, dl = dict ? dict.length : 0;
if (!sl || st.f && !st.l)
return buf || new u82(0);
var noBuf = !buf;
var resize = noBuf || st.i != 2;
var noSt = st.i;
if (noBuf)
buf = new u82(sl * 3);
var cbuf = function(l2) {
var bl = buf.length;
if (l2 > bl) {
var nbuf = new u82(Math.max(bl * 2, l2));
nbuf.set(buf);
buf = nbuf;
}
};
var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
var tbts = sl * 8;
do {
if (!lm) {
final = bits2(dat, pos, 1);
var type2 = bits2(dat, pos + 1, 3);
pos += 3;
if (!type2) {
var s = shft2(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l;
if (t > sl) {
if (noSt)
err2(0);
break;
}
if (resize)
cbuf(bt + l);
buf.set(dat.subarray(s, t), bt);
st.b = bt += l, st.p = pos = t * 8, st.f = final;
continue;
} else if (type2 == 1)
lm = flrm2, dm = fdrm2, lbt = 9, dbt = 5;
else if (type2 == 2) {
var hLit = bits2(dat, pos, 31) + 257, hcLen = bits2(dat, pos + 10, 15) + 4;
var tl = hLit + bits2(dat, pos + 5, 31) + 1;
pos += 14;
var ldt = new u82(tl);
var clt = new u82(19);
for (var i3 = 0; i3 < hcLen; ++i3) {
clt[clim2[i3]] = bits2(dat, pos + i3 * 3, 7);
}
pos += hcLen * 3;
var clb = max5(clt), clbmsk = (1 << clb) - 1;
var clm = hMap2(clt, clb, 1);
for (var i3 = 0; i3 < tl; ) {
var r = clm[bits2(dat, pos, clbmsk)];
pos += r & 15;
var s = r >> 4;
if (s < 16) {
ldt[i3++] = s;
} else {
var c = 0, n = 0;
if (s == 16)
n = 3 + bits2(dat, pos, 3), pos += 2, c = ldt[i3 - 1];
else if (s == 17)
n = 3 + bits2(dat, pos, 7), pos += 3;
else if (s == 18)
n = 11 + bits2(dat, pos, 127), pos += 7;
while (n--)
ldt[i3++] = c;
}
}
var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
lbt = max5(lt);
dbt = max5(dt);
lm = hMap2(lt, lbt, 1);
dm = hMap2(dt, dbt, 1);
} else
err2(1);
if (pos > tbts) {
if (noSt)
err2(0);
break;
}
}
if (resize)
cbuf(bt + 131072);
var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
var lpos = pos;
for (; ; lpos = pos) {
var c = lm[bits162(dat, pos) & lms], sym = c >> 4;
pos += c & 15;
if (pos > tbts) {
if (noSt)
err2(0);
break;
}
if (!c)
err2(2);
if (sym < 256)
buf[bt++] = sym;
else if (sym == 256) {
lpos = pos, lm = null;
break;
} else {
var add6 = sym - 254;
if (sym > 264) {
var i3 = sym - 257, b = fleb2[i3];
add6 = bits2(dat, pos, (1 << b) - 1) + fl2[i3];
pos += b;
}
var d = dm[bits162(dat, pos) & dms], dsym = d >> 4;
if (!d)
err2(3);
pos += d & 15;
var dt = fd2[dsym];
if (dsym > 3) {
var b = fdeb2[dsym];
dt += bits162(dat, pos) & (1 << b) - 1, pos += b;
}
if (pos > tbts) {
if (noSt)
err2(0);
break;
}
if (resize)
cbuf(bt + 131072);
var end = bt + add6;
if (bt < dt) {
var shift = dl - dt, dend = Math.min(dt, end);
if (shift + bt < 0)
err2(3);
for (; bt < dend; ++bt)
buf[bt] = dict[shift + bt];
}
for (; bt < end; ++bt)
buf[bt] = buf[bt - dt];
}
}
st.l = lm, st.p = lpos, st.b = bt, st.f = final;
if (lm)
final = 1, st.m = lbt, st.d = dm, st.n = dbt;
} while (!final);
return bt != buf.length && noBuf ? slc2(buf, 0, bt) : buf.subarray(0, bt);
};
var wbits2 = function(d, p, v) {
v <<= p & 7;
var o = p / 8 | 0;
d[o] |= v;
d[o + 1] |= v >> 8;
};
var wbits162 = function(d, p, v) {
v <<= p & 7;
var o = p / 8 | 0;
d[o] |= v;
d[o + 1] |= v >> 8;
d[o + 2] |= v >> 16;
};
var hTree2 = function(d, mb) {
var t = [];
for (var i3 = 0; i3 < d.length; ++i3) {
if (d[i3])
t.push({ s: i3, f: d[i3] });
}
var s = t.length;
var t2 = t.slice();
if (!s)
return { t: et2, l: 0 };
if (s == 1) {
var v = new u82(t[0].s + 1);
v[t[0].s] = 1;
return { t: v, l: 1 };
}
t.sort(function(a, b) {
return a.f - b.f;
});
t.push({ s: -1, f: 25001 });
var l = t[0], r = t[1], i0 = 0, i1 = 1, i22 = 2;
t[0] = { s: -1, f: l.f + r.f, l, r };
while (i1 != s - 1) {
l = t[t[i0].f < t[i22].f ? i0++ : i22++];
r = t[i0 != i1 && t[i0].f < t[i22].f ? i0++ : i22++];
t[i1++] = { s: -1, f: l.f + r.f, l, r };
}
var maxSym = t2[0].s;
for (var i3 = 1; i3 < s; ++i3) {
if (t2[i3].s > maxSym)
maxSym = t2[i3].s;
}
var tr = new u162(maxSym + 1);
var mbt = ln2(t[i1 - 1], tr, 0);
if (mbt > mb) {
var i3 = 0, dt = 0;
var lft = mbt - mb, cst = 1 << lft;
t2.sort(function(a, b) {
return tr[b.s] - tr[a.s] || a.f - b.f;
});
for (; i3 < s; ++i3) {
var i2_1 = t2[i3].s;
if (tr[i2_1] > mb) {
dt += cst - (1 << mbt - tr[i2_1]);
tr[i2_1] = mb;
} else
break;
}
dt >>= lft;
while (dt > 0) {
var i2_2 = t2[i3].s;
if (tr[i2_2] < mb)
dt -= 1 << mb - tr[i2_2]++ - 1;
else
++i3;
}
for (; i3 >= 0 && dt; --i3) {
var i2_3 = t2[i3].s;
if (tr[i2_3] == mb) {
--tr[i2_3];
++dt;
}
}
mbt = mb;
}
return { t: new u82(tr), l: mbt };
};
var ln2 = function(n, l, d) {
return n.s == -1 ? Math.max(ln2(n.l, l, d + 1), ln2(n.r, l, d + 1)) : l[n.s] = d;
};
var lc2 = function(c) {
var s = c.length;
while (s && !c[--s])
;
var cl = new u162(++s);
var cli = 0, cln = c[0], cls = 1;
var w = function(v) {
cl[cli++] = v;
};
for (var i3 = 1; i3 <= s; ++i3) {
if (c[i3] == cln && i3 != s)
++cls;
else {
if (!cln && cls > 2) {
for (; cls > 138; cls -= 138)
w(32754);
if (cls > 2) {
w(cls > 10 ? cls - 11 << 5 | 28690 : cls - 3 << 5 | 12305);
cls = 0;
}
} else if (cls > 3) {
w(cln), --cls;
for (; cls > 6; cls -= 6)
w(8304);
if (cls > 2)
w(cls - 3 << 5 | 8208), cls = 0;
}
while (cls--)
w(cln);
cls = 1;
cln = c[i3];
}
}
return { c: cl.subarray(0, cli), n: s };
};
var clen2 = function(cf, cl) {
var l = 0;
for (var i3 = 0; i3 < cl.length; ++i3)
l += cf[i3] * cl[i3];
return l;
};
var wfblk2 = function(out, pos, dat) {
var s = dat.length;
var o = shft2(pos + 2);
out[o] = s & 255;
out[o + 1] = s >> 8;
out[o + 2] = out[o] ^ 255;
out[o + 3] = out[o + 1] ^ 255;
for (var i3 = 0; i3 < s; ++i3)
out[o + i3 + 4] = dat[i3];
return (o + 4 + s) * 8;
};
var wblk2 = function(dat, out, final, syms, lf, df, eb, li, bs, bl, p) {
wbits2(out, p++, final);
++lf[256];
var _a3 = hTree2(lf, 15), dlt = _a3.t, mlb = _a3.l;
var _b3 = hTree2(df, 15), ddt = _b3.t, mdb = _b3.l;
var _c = lc2(dlt), lclt = _c.c, nlc = _c.n;
var _d = lc2(ddt), lcdt = _d.c, ndc = _d.n;
var lcfreq = new u162(19);
for (var i3 = 0; i3 < lclt.length; ++i3)
++lcfreq[lclt[i3] & 31];
for (var i3 = 0; i3 < lcdt.length; ++i3)
++lcfreq[lcdt[i3] & 31];
var _e = hTree2(lcfreq, 7), lct = _e.t, mlcb = _e.l;
var nlcc = 19;
for (; nlcc > 4 && !lct[clim2[nlcc - 1]]; --nlcc)
;
var flen = bl + 5 << 3;
var ftlen = clen2(lf, flt2) + clen2(df, fdt2) + eb;
var dtlen = clen2(lf, dlt) + clen2(df, ddt) + eb + 14 + 3 * nlcc + clen2(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18];
if (bs >= 0 && flen <= ftlen && flen <= dtlen)
return wfblk2(out, p, dat.subarray(bs, bs + bl));
var lm, ll, dm, dl;
wbits2(out, p, 1 + (dtlen < ftlen)), p += 2;
if (dtlen < ftlen) {
lm = hMap2(dlt, mlb, 0), ll = dlt, dm = hMap2(ddt, mdb, 0), dl = ddt;
var llm = hMap2(lct, mlcb, 0);
wbits2(out, p, nlc - 257);
wbits2(out, p + 5, ndc - 1);
wbits2(out, p + 10, nlcc - 4);
p += 14;
for (var i3 = 0; i3 < nlcc; ++i3)
wbits2(out, p + 3 * i3, lct[clim2[i3]]);
p += 3 * nlcc;
var lcts = [lclt, lcdt];
for (var it = 0; it < 2; ++it) {
var clct = lcts[it];
for (var i3 = 0; i3 < clct.length; ++i3) {
var len4 = clct[i3] & 31;
wbits2(out, p, llm[len4]), p += lct[len4];
if (len4 > 15)
wbits2(out, p, clct[i3] >> 5 & 127), p += clct[i3] >> 12;
}
}
} else {
lm = flm2, ll = flt2, dm = fdm2, dl = fdt2;
}
for (var i3 = 0; i3 < li; ++i3) {
var sym = syms[i3];
if (sym > 255) {
var len4 = sym >> 18 & 31;
wbits162(out, p, lm[len4 + 257]), p += ll[len4 + 257];
if (len4 > 7)
wbits2(out, p, sym >> 23 & 31), p += fleb2[len4];
var dst = sym & 31;
wbits162(out, p, dm[dst]), p += dl[dst];
if (dst > 3)
wbits162(out, p, sym >> 5 & 8191), p += fdeb2[dst];
} else {
wbits162(out, p, lm[sym]), p += ll[sym];
}
}
wbits162(out, p, lm[256]);
return p + ll[256];
};
var deo2 = /* @__PURE__ */ new i322([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);
var et2 = /* @__PURE__ */ new u82(0);
var dflt2 = function(dat, lvl, plvl, pre, post, st) {
var s = st.z || dat.length;
var o = new u82(pre + s + 5 * (1 + Math.ceil(s / 7e3)) + post);
var w = o.subarray(pre, o.length - post);
var lst = st.l;
var pos = (st.r || 0) & 7;
if (lvl) {
if (pos)
w[0] = st.r >> 3;
var opt = deo2[lvl - 1];
var n = opt >> 13, c = opt & 8191;
var msk_1 = (1 << plvl) - 1;
var prev = st.p || new u162(32768), head = st.h || new u162(msk_1 + 1);
var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;
var hsh = function(i4) {
return (dat[i4] ^ dat[i4 + 1] << bs1_1 ^ dat[i4 + 2] << bs2_1) & msk_1;
};
var syms = new i322(25e3);
var lf = new u162(288), df = new u162(32);
var lc_1 = 0, eb = 0, i3 = st.i || 0, li = 0, wi = st.w || 0, bs = 0;
for (; i3 + 2 < s; ++i3) {
var hv = hsh(i3);
var imod = i3 & 32767, pimod = head[hv];
prev[imod] = pimod;
head[hv] = imod;
if (wi <= i3) {
var rem = s - i3;
if ((lc_1 > 7e3 || li > 24576) && (rem > 423 || !lst)) {
pos = wblk2(dat, w, 0, syms, lf, df, eb, li, bs, i3 - bs, pos);
li = lc_1 = eb = 0, bs = i3;
for (var j = 0; j < 286; ++j)
lf[j] = 0;
for (var j = 0; j < 30; ++j)
df[j] = 0;
}
var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;
if (rem > 2 && hv == hsh(i3 - dif)) {
var maxn = Math.min(n, rem) - 1;
var maxd = Math.min(32767, i3);
var ml = Math.min(258, rem);
while (dif <= maxd && --ch_1 && imod != pimod) {
if (dat[i3 + l] == dat[i3 + l - dif]) {
var nl = 0;
for (; nl < ml && dat[i3 + nl] == dat[i3 + nl - dif]; ++nl)
;
if (nl > l) {
l = nl, d = dif;
if (nl > maxn)
break;
var mmd = Math.min(dif, nl - 2);
var md = 0;
for (var j = 0; j < mmd; ++j) {
var ti = i3 - dif + j & 32767;
var pti = prev[ti];
var cd = ti - pti & 32767;
if (cd > md)
md = cd, pimod = ti;
}
}
}
imod = pimod, pimod = prev[imod];
dif += imod - pimod & 32767;
}
}
if (d) {
syms[li++] = 268435456 | revfl2[l] << 18 | revfd2[d];
var lin = revfl2[l] & 31, din = revfd2[d] & 31;
eb += fleb2[lin] + fdeb2[din];
++lf[257 + lin];
++df[din];
wi = i3 + l;
++lc_1;
} else {
syms[li++] = dat[i3];
++lf[dat[i3]];
}
}
}
for (i3 = Math.max(i3, wi); i3 < s; ++i3) {
syms[li++] = dat[i3];
++lf[dat[i3]];
}
pos = wblk2(dat, w, lst, syms, lf, df, eb, li, bs, i3 - bs, pos);
if (!lst) {
st.r = pos & 7 | w[pos / 8 | 0] << 3;
pos -= 7;
st.h = head, st.p = prev, st.i = i3, st.w = wi;
}
} else {
for (var i3 = st.w || 0; i3 < s + lst; i3 += 65535) {
var e = i3 + 65535;
if (e >= s) {
w[pos / 8 | 0] = lst;
e = s;
}
pos = wfblk2(w, pos + 1, dat.subarray(i3, e));
}
st.i = s;
}
return slc2(o, 0, pre + shft2(pos) + post);
};
var crct2 = /* @__PURE__ */ function() {
var t = new Int32Array(256);
for (var i3 = 0; i3 < 256; ++i3) {
var c = i3, k = 9;
while (--k)
c = (c & 1 && -306674912) ^ c >>> 1;
t[i3] = c;
}
return t;
}();
var crc2 = function() {
var c = -1;
return {
p: function(d) {
var cr = c;
for (var i3 = 0; i3 < d.length; ++i3)
cr = crct2[cr & 255 ^ d[i3]] ^ cr >>> 8;
c = cr;
},
d: function() {
return ~c;
}
};
};
var adler = function() {
var a = 1, b = 0;
return {
p: function(d) {
var n = a, m = b;
var l = d.length | 0;
for (var i3 = 0; i3 != l; ) {
var e = Math.min(i3 + 2655, l);
for (; i3 < e; ++i3)
m += n += d[i3];
n = (n & 65535) + 15 * (n >> 16), m = (m & 65535) + 15 * (m >> 16);
}
a = n, b = m;
},
d: function() {
a %= 65521, b %= 65521;
return (a & 255) << 24 | (a & 65280) << 8 | (b & 255) << 8 | b >> 8;
}
};
};
var dopt2 = function(dat, opt, pre, post, st) {
if (!st) {
st = { l: 1 };
if (opt.dictionary) {
var dict = opt.dictionary.subarray(-32768);
var newDat = new u82(dict.length + dat.length);
newDat.set(dict);
newDat.set(dat, dict.length);
dat = newDat;
st.w = dict.length;
}
}
return dflt2(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? st.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20 : 12 + opt.mem, pre, post, st);
};
var mrg2 = function(a, b) {
var o = {};
for (var k in a)
o[k] = a[k];
for (var k in b)
o[k] = b[k];
return o;
};
var wcln2 = function(fn, fnStr, td3) {
var dt = fn();
var st = fn.toString();
var ks = st.slice(st.indexOf("[") + 1, st.lastIndexOf("]")).replace(/\s+/g, "").split(",");
for (var i3 = 0; i3 < dt.length; ++i3) {
var v = dt[i3], k = ks[i3];
if (typeof v == "function") {
fnStr += ";" + k + "=";
var st_1 = v.toString();
if (v.prototype) {
if (st_1.indexOf("[native code]") != -1) {
var spInd = st_1.indexOf(" ", 8) + 1;
fnStr += st_1.slice(spInd, st_1.indexOf("(", spInd));
} else {
fnStr += st_1;
for (var t in v.prototype)
fnStr += ";" + k + ".prototype." + t + "=" + v.prototype[t].toString();
}
} else
fnStr += st_1;
} else
td3[k] = v;
}
return fnStr;
};
var ch3 = [];
var cbfs2 = function(v) {
var tl = [];
for (var k in v) {
if (v[k].buffer) {
tl.push((v[k] = new v[k].constructor(v[k])).buffer);
}
}
return tl;
};
var wrkr2 = function(fns, init, id, cb) {
if (!ch3[id]) {
var fnStr = "", td_1 = {}, m = fns.length - 1;
for (var i3 = 0; i3 < m; ++i3)
fnStr = wcln2(fns[i3], fnStr, td_1);
ch3[id] = { c: wcln2(fns[m], fnStr, td_1), e: td_1 };
}
var td3 = mrg2({}, ch3[id].e);
return (0, node_worker_1.default)(ch3[id].c + ";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=" + init.toString() + "}", id, td3, cbfs2(td3), cb);
};
var bInflt2 = function() {
return [u82, u162, i322, fleb2, fdeb2, clim2, fl2, fd2, flrm2, fdrm2, rev2, ec2, hMap2, max5, bits2, bits162, shft2, slc2, err2, inflt2, inflateSync2, pbf2, gopt2];
};
var bDflt2 = function() {
return [u82, u162, i322, fleb2, fdeb2, clim2, revfl2, revfd2, flm2, flt2, fdm2, fdt2, rev2, deo2, et2, hMap2, wbits2, wbits162, hTree2, ln2, lc2, clen2, wfblk2, wblk2, shft2, slc2, dflt2, dopt2, deflateSync2, pbf2];
};
var gze2 = function() {
return [gzh2, gzhl2, wbytes2, crc2, crct2];
};
var guze2 = function() {
return [gzs2, gzl2];
};
var zle = function() {
return [zlh, wbytes2, adler];
};
var zule2 = function() {
return [zls2];
};
var pbf2 = function(msg) {
return postMessage(msg, [msg.buffer]);
};
var gopt2 = function(o) {
return o && {
out: o.size && new u82(o.size),
dictionary: o.dictionary
};
};
var cbify2 = function(dat, opts, fns, init, id, cb) {
var w = wrkr2(fns, init, id, function(err3, dat2) {
w.terminate();
cb(err3, dat2);
});
w.postMessage([dat, opts], opts.consume ? [dat.buffer] : []);
return function() {
w.terminate();
};
};
var astrm = function(strm) {
strm.ondata = function(dat, final) {
return postMessage([dat, final], [dat.buffer]);
};
return function(ev) {
if (ev.data.length) {
strm.push(ev.data[0], ev.data[1]);
postMessage([ev.data[0].length]);
} else
strm.flush();
};
};
var astrmify = function(fns, strm, opts, init, id, flush, ext) {
var t;
var w = wrkr2(fns, init, id, function(err3, dat) {
if (err3)
w.terminate(), strm.ondata.call(strm, err3);
else if (!Array.isArray(dat))
ext(dat);
else if (dat.length == 1) {
strm.queuedSize -= dat[0];
if (strm.ondrain)
strm.ondrain(dat[0]);
} else {
if (dat[1])
w.terminate();
strm.ondata.call(strm, err3, dat[0], dat[1]);
}
});
w.postMessage(opts);
strm.queuedSize = 0;
strm.push = function(d, f) {
if (!strm.ondata)
err2(5);
if (t)
strm.ondata(err2(4, 0, 1), null, !!f);
strm.queuedSize += d.length;
w.postMessage([d, t = f], [d.buffer]);
};
strm.terminate = function() {
w.terminate();
};
if (flush) {
strm.flush = function() {
w.postMessage([]);
};
}
};
var b22 = function(d, b) {
return d[b] | d[b + 1] << 8;
};
var b42 = function(d, b) {
return (d[b] | d[b + 1] << 8 | d[b + 2] << 16 | d[b + 3] << 24) >>> 0;
};
var b82 = function(d, b) {
return b42(d, b) + b42(d, b + 4) * 4294967296;
};
var wbytes2 = function(d, b, v) {
for (; v; ++b)
d[b] = v, v >>>= 8;
};
var gzh2 = function(c, o) {
var fn = o.filename;
c[0] = 31, c[1] = 139, c[2] = 8, c[8] = o.level < 2 ? 4 : o.level == 9 ? 2 : 0, c[9] = 3;
if (o.mtime != 0)
wbytes2(c, 4, Math.floor(new Date(o.mtime || Date.now()) / 1e3));
if (fn) {
c[3] = 8;
for (var i3 = 0; i3 <= fn.length; ++i3)
c[i3 + 10] = fn.charCodeAt(i3);
}
};
var gzs2 = function(d) {
if (d[0] != 31 || d[1] != 139 || d[2] != 8)
err2(6, "invalid gzip data");
var flg = d[3];
var st = 10;
if (flg & 4)
st += (d[10] | d[11] << 8) + 2;
for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++])
;
return st + (flg & 2);
};
var gzl2 = function(d) {
var l = d.length;
return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0;
};
var gzhl2 = function(o) {
return 10 + (o.filename ? o.filename.length + 1 : 0);
};
var zlh = function(c, o) {
var lv = o.level, fl3 = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;
c[0] = 120, c[1] = fl3 << 6 | (o.dictionary && 32);
c[1] |= 31 - (c[0] << 8 | c[1]) % 31;
if (o.dictionary) {
var h = adler();
h.p(o.dictionary);
wbytes2(c, 2, h.d());
}
};
var zls2 = function(d, dict) {
if ((d[0] & 15) != 8 || d[0] >> 4 > 7 || (d[0] << 8 | d[1]) % 31)
err2(6, "invalid zlib data");
if ((d[1] >> 5 & 1) == +!dict)
err2(6, "invalid zlib data: " + (d[1] & 32 ? "need" : "unexpected") + " dictionary");
return (d[1] >> 3 & 4) + 2;
};
function StrmOpt2(opts, cb) {
if (typeof opts == "function")
cb = opts, opts = {};
this.ondata = cb;
return opts;
}
var Deflate = /* @__PURE__ */ function() {
function Deflate2(opts, cb) {
if (typeof opts == "function")
cb = opts, opts = {};
this.ondata = cb;
this.o = opts || {};
this.s = { l: 0, i: 32768, w: 32768, z: 32768 };
this.b = new u82(98304);
if (this.o.dictionary) {
var dict = this.o.dictionary.subarray(-32768);
this.b.set(dict, 32768 - dict.length);
this.s.i = 32768 - dict.length;
}
}
Deflate2.prototype.p = function(c, f) {
this.ondata(dopt2(c, this.o, 0, 0, this.s), f);
};
Deflate2.prototype.push = function(chunk, final) {
if (!this.ondata)
err2(5);
if (this.s.l)
err2(4);
var endLen = chunk.length + this.s.z;
if (endLen > this.b.length) {
if (endLen > 2 * this.b.length - 32768) {
var newBuf = new u82(endLen & -32768);
newBuf.set(this.b.subarray(0, this.s.z));
this.b = newBuf;
}
var split = this.b.length - this.s.z;
this.b.set(chunk.subarray(0, split), this.s.z);
this.s.z = this.b.length;
this.p(this.b, false);
this.b.set(this.b.subarray(-32768));
this.b.set(chunk.subarray(split), 32768);
this.s.z = chunk.length - split + 32768;
this.s.i = 32766, this.s.w = 32768;
} else {
this.b.set(chunk, this.s.z);
this.s.z += chunk.length;
}
this.s.l = final & 1;
if (this.s.z > this.s.w + 8191 || final) {
this.p(this.b, final || false);
this.s.w = this.s.i, this.s.i -= 2;
}
};
Deflate2.prototype.flush = function() {
if (!this.ondata)
err2(5);
if (this.s.l)
err2(4);
this.p(this.b, false);
this.s.w = this.s.i, this.s.i -= 2;
};
return Deflate2;
}();
exports2.Deflate = Deflate;
var AsyncDeflate = /* @__PURE__ */ function() {
function AsyncDeflate2(opts, cb) {
astrmify([
bDflt2,
function() {
return [astrm, Deflate];
}
], this, StrmOpt2.call(this, opts, cb), function(ev) {
var strm = new Deflate(ev.data);
onmessage = astrm(strm);
}, 6, 1);
}
return AsyncDeflate2;
}();
exports2.AsyncDeflate = AsyncDeflate;
function deflate(data, opts, cb) {
if (!cb)
cb = opts, opts = {};
if (typeof cb != "function")
err2(7);
return cbify2(data, opts, [
bDflt2
], function(ev) {
return pbf2(deflateSync2(ev.data[0], ev.data[1]));
}, 0, cb);
}
exports2.deflate = deflate;
function deflateSync2(data, opts) {
return dopt2(data, opts || {}, 0, 0);
}
exports2.deflateSync = deflateSync2;
var Inflate2 = /* @__PURE__ */ function() {
function Inflate3(opts, cb) {
if (typeof opts == "function")
cb = opts, opts = {};
this.ondata = cb;
var dict = opts && opts.dictionary && opts.dictionary.subarray(-32768);
this.s = { i: 0, b: dict ? dict.length : 0 };
this.o = new u82(32768);
this.p = new u82(0);
if (dict)
this.o.set(dict);
}
Inflate3.prototype.e = function(c) {
if (!this.ondata)
err2(5);
if (this.d)
err2(4);
if (!this.p.length)
this.p = c;
else if (c.length) {
var n = new u82(this.p.length + c.length);
n.set(this.p), n.set(c, this.p.length), this.p = n;
}
};
Inflate3.prototype.c = function(final) {
this.s.i = +(this.d = final || false);
var bts = this.s.b;
var dt = inflt2(this.p, this.s, this.o);
this.ondata(slc2(dt, bts, this.s.b), this.d);
this.o = slc2(dt, this.s.b - 32768), this.s.b = this.o.length;
this.p = slc2(this.p, this.s.p / 8 | 0), this.s.p &= 7;
};
Inflate3.prototype.push = function(chunk, final) {
this.e(chunk), this.c(final);
};
return Inflate3;
}();
exports2.Inflate = Inflate2;
var AsyncInflate = /* @__PURE__ */ function() {
function AsyncInflate2(opts, cb) {
astrmify([
bInflt2,
function() {
return [astrm, Inflate2];
}
], this, StrmOpt2.call(this, opts, cb), function(ev) {
var strm = new Inflate2(ev.data);
onmessage = astrm(strm);
}, 7, 0);
}
return AsyncInflate2;
}();
exports2.AsyncInflate = AsyncInflate;
function inflate2(data, opts, cb) {
if (!cb)
cb = opts, opts = {};
if (typeof cb != "function")
err2(7);
return cbify2(data, opts, [
bInflt2
], function(ev) {
return pbf2(inflateSync2(ev.data[0], gopt2(ev.data[1])));
}, 1, cb);
}
exports2.inflate = inflate2;
function inflateSync2(data, opts) {
return inflt2(data, { i: 2 }, opts && opts.out, opts && opts.dictionary);
}
exports2.inflateSync = inflateSync2;
var Gzip = /* @__PURE__ */ function() {
function Gzip2(opts, cb) {
this.c = crc2();
this.l = 0;
this.v = 1;
Deflate.call(this, opts, cb);
}
Gzip2.prototype.push = function(chunk, final) {
this.c.p(chunk);
this.l += chunk.length;
Deflate.prototype.push.call(this, chunk, final);
};
Gzip2.prototype.p = function(c, f) {
var raw = dopt2(c, this.o, this.v && gzhl2(this.o), f && 8, this.s);
if (this.v)
gzh2(raw, this.o), this.v = 0;
if (f)
wbytes2(raw, raw.length - 8, this.c.d()), wbytes2(raw, raw.length - 4, this.l);
this.ondata(raw, f);
};
Gzip2.prototype.flush = function() {
Deflate.prototype.flush.call(this);
};
return Gzip2;
}();
exports2.Gzip = Gzip;
exports2.Compress = Gzip;
var AsyncGzip = /* @__PURE__ */ function() {
function AsyncGzip2(opts, cb) {
astrmify([
bDflt2,
gze2,
function() {
return [astrm, Deflate, Gzip];
}
], this, StrmOpt2.call(this, opts, cb), function(ev) {
var strm = new Gzip(ev.data);
onmessage = astrm(strm);
}, 8, 1);
}
return AsyncGzip2;
}();
exports2.AsyncGzip = AsyncGzip;
exports2.AsyncCompress = AsyncGzip;
function gzip2(data, opts, cb) {
if (!cb)
cb = opts, opts = {};
if (typeof cb != "function")
err2(7);
return cbify2(data, opts, [
bDflt2,
gze2,
function() {
return [gzipSync2];
}
], function(ev) {
return pbf2(gzipSync2(ev.data[0], ev.data[1]));
}, 2, cb);
}
exports2.gzip = gzip2;
exports2.compress = gzip2;
function gzipSync2(data, opts) {
if (!opts)
opts = {};
var c = crc2(), l = data.length;
c.p(data);
var d = dopt2(data, opts, gzhl2(opts), 8), s = d.length;
return gzh2(d, opts), wbytes2(d, s - 8, c.d()), wbytes2(d, s - 4, l), d;
}
exports2.gzipSync = gzipSync2;
exports2.compressSync = gzipSync2;
var Gunzip2 = /* @__PURE__ */ function() {
function Gunzip3(opts, cb) {
this.v = 1;
this.r = 0;
Inflate2.call(this, opts, cb);
}
Gunzip3.prototype.push = function(chunk, final) {
Inflate2.prototype.e.call(this, chunk);
this.r += chunk.length;
if (this.v) {
var p = this.p.subarray(this.v - 1);
var s = p.length > 3 ? gzs2(p) : 4;
if (s > p.length) {
if (!final)
return;
} else if (this.v > 1 && this.onmember) {
this.onmember(this.r - p.length);
}
this.p = p.subarray(s), this.v = 0;
}
Inflate2.prototype.c.call(this, final);
if (this.s.f && !this.s.l && !final) {
this.v = shft2(this.s.p) + 9;
this.s = { i: 0 };
this.o = new u82(0);
this.push(new u82(0), final);
}
};
return Gunzip3;
}();
exports2.Gunzip = Gunzip2;
var AsyncGunzip = /* @__PURE__ */ function() {
function AsyncGunzip2(opts, cb) {
var _this = this;
astrmify([
bInflt2,
guze2,
function() {
return [astrm, Inflate2, Gunzip2];
}
], this, StrmOpt2.call(this, opts, cb), function(ev) {
var strm = new Gunzip2(ev.data);
strm.onmember = function(offset) {
return postMessage(offset);
};
onmessage = astrm(strm);
}, 9, 0, function(offset) {
return _this.onmember && _this.onmember(offset);
});
}
return AsyncGunzip2;
}();
exports2.AsyncGunzip = AsyncGunzip;
function gunzip2(data, opts, cb) {
if (!cb)
cb = opts, opts = {};
if (typeof cb != "function")
err2(7);
return cbify2(data, opts, [
bInflt2,
guze2,
function() {
return [gunzipSync2];
}
], function(ev) {
return pbf2(gunzipSync2(ev.data[0], ev.data[1]));
}, 3, cb);
}
exports2.gunzip = gunzip2;
function gunzipSync2(data, opts) {
var st = gzs2(data);
if (st + 8 > data.length)
err2(6, "invalid gzip data");
return inflt2(data.subarray(st, -8), { i: 2 }, opts && opts.out || new u82(gzl2(data)), opts && opts.dictionary);
}
exports2.gunzipSync = gunzipSync2;
var Zlib = /* @__PURE__ */ function() {
function Zlib2(opts, cb) {
this.c = adler();
this.v = 1;
Deflate.call(this, opts, cb);
}
Zlib2.prototype.push = function(chunk, final) {
this.c.p(chunk);
Deflate.prototype.push.call(this, chunk, final);
};
Zlib2.prototype.p = function(c, f) {
var raw = dopt2(c, this.o, this.v && (this.o.dictionary ? 6 : 2), f && 4, this.s);
if (this.v)
zlh(raw, this.o), this.v = 0;
if (f)
wbytes2(raw, raw.length - 4, this.c.d());
this.ondata(raw, f);
};
Zlib2.prototype.flush = function() {
Deflate.prototype.flush.call(this);
};
return Zlib2;
}();
exports2.Zlib = Zlib;
var AsyncZlib = /* @__PURE__ */ function() {
function AsyncZlib2(opts, cb) {
astrmify([
bDflt2,
zle,
function() {
return [astrm, Deflate, Zlib];
}
], this, StrmOpt2.call(this, opts, cb), function(ev) {
var strm = new Zlib(ev.data);
onmessage = astrm(strm);
}, 10, 1);
}
return AsyncZlib2;
}();
exports2.AsyncZlib = AsyncZlib;
function zlib(data, opts, cb) {
if (!cb)
cb = opts, opts = {};
if (typeof cb != "function")
err2(7);
return cbify2(data, opts, [
bDflt2,
zle,
function() {
return [zlibSync];
}
], function(ev) {
return pbf2(zlibSync(ev.data[0], ev.data[1]));
}, 4, cb);
}
exports2.zlib = zlib;
function zlibSync(data, opts) {
if (!opts)
opts = {};
var a = adler();
a.p(data);
var d = dopt2(data, opts, opts.dictionary ? 6 : 2, 4);
return zlh(d, opts), wbytes2(d, d.length - 4, a.d()), d;
}
exports2.zlibSync = zlibSync;
var Unzlib2 = /* @__PURE__ */ function() {
function Unzlib3(opts, cb) {
Inflate2.call(this, opts, cb);
this.v = opts && opts.dictionary ? 2 : 1;
}
Unzlib3.prototype.push = function(chunk, final) {
Inflate2.prototype.e.call(this, chunk);
if (this.v) {
if (this.p.length < 6 && !final)
return;
this.p = this.p.subarray(zls2(this.p, this.v - 1)), this.v = 0;
}
if (final) {
if (this.p.length < 4)
err2(6, "invalid zlib data");
this.p = this.p.subarray(0, -4);
}
Inflate2.prototype.c.call(this, final);
};
return Unzlib3;
}();
exports2.Unzlib = Unzlib2;
var AsyncUnzlib = /* @__PURE__ */ function() {
function AsyncUnzlib2(opts, cb) {
astrmify([
bInflt2,
zule2,
function() {
return [astrm, Inflate2, Unzlib2];
}
], this, StrmOpt2.call(this, opts, cb), function(ev) {
var strm = new Unzlib2(ev.data);
onmessage = astrm(strm);
}, 11, 0);
}
return AsyncUnzlib2;
}();
exports2.AsyncUnzlib = AsyncUnzlib;
function unzlib2(data, opts, cb) {
if (!cb)
cb = opts, opts = {};
if (typeof cb != "function")
err2(7);
return cbify2(data, opts, [
bInflt2,
zule2,
function() {
return [unzlibSync2];
}
], function(ev) {
return pbf2(unzlibSync2(ev.data[0], gopt2(ev.data[1])));
}, 5, cb);
}
exports2.unzlib = unzlib2;
function unzlibSync2(data, opts) {
return inflt2(data.subarray(zls2(data, opts && opts.dictionary), -4), { i: 2 }, opts && opts.out, opts && opts.dictionary);
}
exports2.unzlibSync = unzlibSync2;
var Decompress2 = /* @__PURE__ */ function() {
function Decompress3(opts, cb) {
this.o = StrmOpt2.call(this, opts, cb) || {};
this.G = Gunzip2;
this.I = Inflate2;
this.Z = Unzlib2;
}
Decompress3.prototype.i = function() {
var _this = this;
this.s.ondata = function(dat, final) {
_this.ondata(dat, final);
};
};
Decompress3.prototype.push = function(chunk, final) {
if (!this.ondata)
err2(5);
if (!this.s) {
if (this.p && this.p.length) {
var n = new u82(this.p.length + chunk.length);
n.set(this.p), n.set(chunk, this.p.length);
} else
this.p = chunk;
if (this.p.length > 2) {
this.s = this.p[0] == 31 && this.p[1] == 139 && this.p[2] == 8 ? new this.G(this.o) : (this.p[0] & 15) != 8 || this.p[0] >> 4 > 7 || (this.p[0] << 8 | this.p[1]) % 31 ? new this.I(this.o) : new this.Z(this.o);
this.i();
this.s.push(this.p, final);
this.p = null;
}
} else
this.s.push(chunk, final);
};
return Decompress3;
}();
exports2.Decompress = Decompress2;
var AsyncDecompress = /* @__PURE__ */ function() {
function AsyncDecompress2(opts, cb) {
Decompress2.call(this, opts, cb);
this.queuedSize = 0;
this.G = AsyncGunzip;
this.I = AsyncInflate;
this.Z = AsyncUnzlib;
}
AsyncDecompress2.prototype.i = function() {
var _this = this;
this.s.ondata = function(err3, dat, final) {
_this.ondata(err3, dat, final);
};
this.s.ondrain = function(size) {
_this.queuedSize -= size;
if (_this.ondrain)
_this.ondrain(size);
};
};
AsyncDecompress2.prototype.push = function(chunk, final) {
this.queuedSize += chunk.length;
Decompress2.prototype.push.call(this, chunk, final);
};
return AsyncDecompress2;
}();
exports2.AsyncDecompress = AsyncDecompress;
function decompress3(data, opts, cb) {
if (!cb)
cb = opts, opts = {};
if (typeof cb != "function")
err2(7);
return data[0] == 31 && data[1] == 139 && data[2] == 8 ? gunzip2(data, opts, cb) : (data[0] & 15) != 8 || data[0] >> 4 > 7 || (data[0] << 8 | data[1]) % 31 ? inflate2(data, opts, cb) : unzlib2(data, opts, cb);
}
exports2.decompress = decompress3;
function decompressSync2(data, opts) {
return data[0] == 31 && data[1] == 139 && data[2] == 8 ? gunzipSync2(data, opts) : (data[0] & 15) != 8 || data[0] >> 4 > 7 || (data[0] << 8 | data[1]) % 31 ? inflateSync2(data, opts) : unzlibSync2(data, opts);
}
exports2.decompressSync = decompressSync2;
var fltn = function(d, p, t, o) {
for (var k in d) {
var val = d[k], n = p + k, op = o;
if (Array.isArray(val))
op = mrg2(o, val[1]), val = val[0];
if (val instanceof u82)
t[n] = [val, op];
else {
t[n += "/"] = [new u82(0), op];
fltn(val, n, t, o);
}
}
};
var te2 = typeof TextEncoder != "undefined" && /* @__PURE__ */ new TextEncoder();
var td2 = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder();
var tds2 = 0;
try {
td2.decode(et2, { stream: true });
tds2 = 1;
} catch (e) {
}
var dutf82 = function(d) {
for (var r = "", i3 = 0; ; ) {
var c = d[i3++];
var eb = (c > 127) + (c > 223) + (c > 239);
if (i3 + eb > d.length)
return { s: r, r: slc2(d, i3 - 1) };
if (!eb)
r += String.fromCharCode(c);
else if (eb == 3) {
c = ((c & 15) << 18 | (d[i3++] & 63) << 12 | (d[i3++] & 63) << 6 | d[i3++] & 63) - 65536, r += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);
} else if (eb & 1)
r += String.fromCharCode((c & 31) << 6 | d[i3++] & 63);
else
r += String.fromCharCode((c & 15) << 12 | (d[i3++] & 63) << 6 | d[i3++] & 63);
}
};
var DecodeUTF8 = /* @__PURE__ */ function() {
function DecodeUTF82(cb) {
this.ondata = cb;
if (tds2)
this.t = new TextDecoder();
else
this.p = et2;
}
DecodeUTF82.prototype.push = function(chunk, final) {
if (!this.ondata)
err2(5);
final = !!final;
if (this.t) {
this.ondata(this.t.decode(chunk, { stream: true }), final);
if (final) {
if (this.t.decode().length)
err2(8);
this.t = null;
}
return;