var lz4_codec = function() {
  typeof document !== "undefined" && document.currentScript ? document.currentScript.src : void 0;
  return function(lz4_codec2) {
    lz4_codec2 = lz4_codec2 || {};
    var e;
    e || (e = typeof lz4_codec2 !== "undefined" ? lz4_codec2 : {});
    var aa, ba;
    e.ready = new Promise(function(a, b) {
      aa = a;
      ba = b;
    });
    var t = {}, u;
    for (u in e)
      e.hasOwnProperty(u) && (t[u] = e[u]);
    var v = e.printErr || console.warn.bind(console);
    for (u in t)
      t.hasOwnProperty(u) && (e[u] = t[u]);
    t = null;
    var x;
    e.wasmBinary && (x = e.wasmBinary);
    e.noExitRuntime && e.noExitRuntime;
    typeof WebAssembly !== "object" && y("no native wasm support detected");
    var z, ca = false, da = typeof TextDecoder !== "undefined" ? new TextDecoder("utf8") : void 0;
    function ea(a, b, c) {
      var d = A;
      if (0 < c) {
        c = b + c - 1;
        for (var f = 0; f < a.length; ++f) {
          var g = a.charCodeAt(f);
          if (55296 <= g && 57343 >= g) {
            var n = a.charCodeAt(++f);
            g = 65536 + ((g & 1023) << 10) | n & 1023;
          }
          if (127 >= g) {
            if (b >= c)
              break;
            d[b++] = g;
          } else {
            if (2047 >= g) {
              if (b + 1 >= c)
                break;
              d[b++] = 192 | g >> 6;
            } else {
              if (65535 >= g) {
                if (b + 2 >= c)
                  break;
                d[b++] = 224 | g >> 12;
              } else {
                if (b + 3 >= c)
                  break;
                d[b++] = 240 | g >> 18;
                d[b++] = 128 | g >> 12 & 63;
              }
              d[b++] = 128 | g >> 6 & 63;
            }
            d[b++] = 128 | g & 63;
          }
        }
        d[b] = 0;
      }
    }
    var fa = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-16le") : void 0;
    function ha(a, b) {
      var c = a >> 1;
      for (var d = c + b / 2; !(c >= d) && B[c]; )
        ++c;
      c <<= 1;
      if (32 < c - a && fa)
        return fa.decode(A.subarray(a, c));
      c = 0;
      for (d = ""; ; ) {
        var f = C[a + 2 * c >> 1];
        if (f == 0 || c == b / 2)
          return d;
        ++c;
        d += String.fromCharCode(f);
      }
    }
    function ia(a, b, c) {
      c === void 0 && (c = 2147483647);
      if (2 > c)
        return 0;
      c -= 2;
      var d = b;
      c = c < 2 * a.length ? c / 2 : a.length;
      for (var f = 0; f < c; ++f)
        C[b >> 1] = a.charCodeAt(f), b += 2;
      C[b >> 1] = 0;
      return b - d;
    }
    function ja(a) {
      return 2 * a.length;
    }
    function ka(a, b) {
      for (var c = 0, d = ""; !(c >= b / 4); ) {
        var f = D[a + 4 * c >> 2];
        if (f == 0)
          break;
        ++c;
        65536 <= f ? (f -= 65536, d += String.fromCharCode(55296 | f >> 10, 56320 | f & 1023)) : d += String.fromCharCode(f);
      }
      return d;
    }
    function la(a, b, c) {
      c === void 0 && (c = 2147483647);
      if (4 > c)
        return 0;
      var d = b;
      c = d + c - 4;
      for (var f = 0; f < a.length; ++f) {
        var g = a.charCodeAt(f);
        if (55296 <= g && 57343 >= g) {
          var n = a.charCodeAt(++f);
          g = 65536 + ((g & 1023) << 10) | n & 1023;
        }
        D[b >> 2] = g;
        b += 4;
        if (b + 4 > c)
          break;
      }
      D[b >> 2] = 0;
      return b - d;
    }
    function ma(a) {
      for (var b = 0, c = 0; c < a.length; ++c) {
        var d = a.charCodeAt(c);
        55296 <= d && 57343 >= d && ++c;
        b += 4;
      }
      return b;
    }
    var E, F, A, C, B, D, H, na, oa;
    function pa(a) {
      E = a;
      e.HEAP8 = F = new Int8Array(a);
      e.HEAP16 = C = new Int16Array(a);
      e.HEAP32 = D = new Int32Array(a);
      e.HEAPU8 = A = new Uint8Array(a);
      e.HEAPU16 = B = new Uint16Array(a);
      e.HEAPU32 = H = new Uint32Array(a);
      e.HEAPF32 = na = new Float32Array(a);
      e.HEAPF64 = oa = new Float64Array(a);
    }
    var qa = e.INITIAL_MEMORY || 16777216;
    e.wasmMemory ? z = e.wasmMemory : z = new WebAssembly.Memory({ initial: qa / 65536, maximum: 32768 });
    z && (E = z.buffer);
    qa = E.byteLength;
    pa(E);
    var I, ra = [], sa = [], ta = [], ua = [];
    function va() {
      var a = e.preRun.shift();
      ra.unshift(a);
    }
    var J = 0, L = null;
    e.preloadedImages = {};
    e.preloadedAudios = {};
    function y(a) {
      if (e.onAbort)
        e.onAbort(a);
      v(a);
      ca = true;
      a = new WebAssembly.RuntimeError("abort(" + a + "). Build with -s ASSERTIONS=1 for more info.");
      ba(a);
      throw a;
    }
    function xa(a) {
      var b = M;
      return String.prototype.startsWith ? b.startsWith(a) : b.indexOf(a) === 0;
    }
    function ya() {
      return xa("data:application/octet-stream;base64,");
    }
    var M = "lz4_codec.wasm";
    if (!ya()) {
      var za = M;
      M = e.locateFile ? e.locateFile(za, "") : "" + za;
    }
    function Aa() {
      try {
        if (x)
          return new Uint8Array(x);
        throw "both async and sync fetching of the wasm failed";
      } catch (a) {
        y(a);
      }
    }
    function N(a) {
      for (; 0 < a.length; ) {
        var b = a.shift();
        if (typeof b == "function")
          b(e);
        else {
          var c = b.I;
          typeof c === "number" ? b.D === void 0 ? I.get(c)() : I.get(c)(b.D) : c(b.D === void 0 ? null : b.D);
        }
      }
    }
    function Ba(a) {
      this.C = a - 16;
      this.P = function(b) {
        D[this.C + 8 >> 2] = b;
      };
      this.M = function(b) {
        D[this.C + 0 >> 2] = b;
      };
      this.N = function() {
        D[this.C + 4 >> 2] = 0;
      };
      this.L = function() {
        F[this.C + 12 >> 0] = 0;
      };
      this.O = function() {
        F[this.C + 13 >> 0] = 0;
      };
      this.K = function(b, c) {
        this.P(b);
        this.M(c);
        this.N();
        this.L();
        this.O();
      };
    }
    function Ca(a) {
      switch (a) {
        case 1:
          return 0;
        case 2:
          return 1;
        case 4:
          return 2;
        case 8:
          return 3;
        default:
          throw new TypeError("Unknown type size: " + a);
      }
    }
    var Da = void 0;
    function P(a) {
      for (var b = ""; A[a]; )
        b += Da[A[a++]];
      return b;
    }
    var Q = {}, R = {}, S = {};
    function Ea(a) {
      if (a === void 0)
        return "_unknown";
      a = a.replace(/[^a-zA-Z0-9_]/g, "$");
      var b = a.charCodeAt(0);
      return 48 <= b && 57 >= b ? "_" + a : a;
    }
    function Fa(a, b) {
      a = Ea(a);
      return new Function("body", "return function " + a + '() {\n    "use strict";    return body.apply(this, arguments);\n};\n')(b);
    }
    function Ga(a) {
      var b = Error, c = Fa(a, function(d) {
        this.name = a;
        this.message = d;
        d = Error(d).stack;
        d !== void 0 && (this.stack = this.toString() + "\n" + d.replace(/^Error(:[^\n]*)?\n/, ""));
      });
      c.prototype = Object.create(b.prototype);
      c.prototype.constructor = c;
      c.prototype.toString = function() {
        return this.message === void 0 ? this.name : this.name + ": " + this.message;
      };
      return c;
    }
    var Ha = void 0;
    function T(a) {
      throw new Ha(a);
    }
    var Ia = void 0;
    function La(a, b) {
      function c(h) {
        h = b(h);
        if (h.length !== d.length)
          throw new Ia("Mismatched type converter count");
        for (var l = 0; l < d.length; ++l)
          U(d[l], h[l]);
      }
      var d = [];
      d.forEach(function(h) {
        S[h] = a;
      });
      var f = Array(a.length), g = [], n = 0;
      a.forEach(function(h, l) {
        R.hasOwnProperty(h) ? f[l] = R[h] : (g.push(h), Q.hasOwnProperty(h) || (Q[h] = []), Q[h].push(function() {
          f[l] = R[h];
          ++n;
          n === g.length && c(f);
        }));
      });
      g.length === 0 && c(f);
    }
    function U(a, b, c) {
      c = c || {};
      if (!("argPackAdvance" in b))
        throw new TypeError("registerType registeredInstance requires argPackAdvance");
      var d = b.name;
      a || T('type "' + d + '" must have a positive integer typeid pointer');
      if (R.hasOwnProperty(a)) {
        if (c.J)
          return;
        T("Cannot register type '" + d + "' twice");
      }
      R[a] = b;
      delete S[a];
      Q.hasOwnProperty(a) && (b = Q[a], delete Q[a], b.forEach(function(f) {
        f();
      }));
    }
    var Ma = [], V = [{}, { value: void 0 }, { value: null }, { value: true }, { value: false }];
    function Na(a) {
      4 < a && --V[a].F === 0 && (V[a] = void 0, Ma.push(a));
    }
    function Oa(a) {
      switch (a) {
        case void 0:
          return 1;
        case null:
          return 2;
        case true:
          return 3;
        case false:
          return 4;
        default:
          var b = Ma.length ? Ma.pop() : V.length;
          V[b] = { F: 1, value: a };
          return b;
      }
    }
    function Pa(a) {
      return this.fromWireType(H[a >> 2]);
    }
    function Qa(a) {
      if (a === null)
        return "null";
      var b = typeof a;
      return b === "object" || b === "array" || b === "function" ? a.toString() : "" + a;
    }
    function Ra(a, b) {
      switch (b) {
        case 2:
          return function(c) {
            return this.fromWireType(na[c >> 2]);
          };
        case 3:
          return function(c) {
            return this.fromWireType(oa[c >> 3]);
          };
        default:
          throw new TypeError("Unknown float type: " + a);
      }
    }
    function Sa(a) {
      var b = Function;
      if (!(b instanceof Function))
        throw new TypeError("new_ called with constructor type " + typeof b + " which is not a function");
      var c = Fa(b.name || "unknownFunctionName", function() {
      });
      c.prototype = b.prototype;
      c = new c();
      a = b.apply(c, a);
      return a instanceof Object ? a : c;
    }
    function Ta(a) {
      for (; a.length; ) {
        var b = a.pop();
        a.pop()(b);
      }
    }
    function Ua(a, b) {
      var c = e;
      if (c[a].A === void 0) {
        var d = c[a];
        c[a] = function() {
          c[a].A.hasOwnProperty(arguments.length) || T("Function '" + b + "' called with an invalid number of arguments (" + arguments.length + ") - expects one of (" + c[a].A + ")!");
          return c[a].A[arguments.length].apply(this, arguments);
        };
        c[a].A = [];
        c[a].A[d.H] = d;
      }
    }
    function Va(a, b, c) {
      e.hasOwnProperty(a) ? ((c === void 0 || e[a].A !== void 0 && e[a].A[c] !== void 0) && T("Cannot register public name '" + a + "' twice"), Ua(a, a), e.hasOwnProperty(c) && T("Cannot register multiple overloads of a function with the same number of arguments (" + c + ")!"), e[a].A[c] = b) : (e[a] = b, c !== void 0 && (e[a].S = c));
    }
    function Wa(a, b) {
      for (var c = [], d = 0; d < a; d++)
        c.push(D[(b >> 2) + d]);
      return c;
    }
    function Xa(a, b) {
      0 <= a.indexOf("j") || y("Assertion failed: getDynCaller should only be called with i64 sigs");
      var c = [];
      return function() {
        c.length = arguments.length;
        for (var d = 0; d < arguments.length; d++)
          c[d] = arguments[d];
        var f;
        a.indexOf("j") != -1 ? f = c && c.length ? e["dynCall_" + a].apply(null, [b].concat(c)) : e["dynCall_" + a].call(null, b) : f = I.get(b).apply(null, c);
        return f;
      };
    }
    function Ya(a, b) {
      a = P(a);
      var c = a.indexOf("j") != -1 ? Xa(a, b) : I.get(b);
      typeof c !== "function" && T("unknown function pointer with signature " + a + ": " + b);
      return c;
    }
    var Za = void 0;
    function $a(a) {
      a = ab(a);
      var b = P(a);
      W(a);
      return b;
    }
    function bb(a, b) {
      function c(g) {
        f[g] || R[g] || (S[g] ? S[g].forEach(c) : (d.push(g), f[g] = true));
      }
      var d = [], f = {};
      b.forEach(c);
      throw new Za(a + ": " + d.map($a).join([", "]));
    }
    function cb(a, b, c) {
      switch (b) {
        case 0:
          return c ? function(d) {
            return F[d];
          } : function(d) {
            return A[d];
          };
        case 1:
          return c ? function(d) {
            return C[d >> 1];
          } : function(d) {
            return B[d >> 1];
          };
        case 2:
          return c ? function(d) {
            return D[d >> 2];
          } : function(d) {
            return H[d >> 2];
          };
        default:
          throw new TypeError("Unknown integer type: " + a);
      }
    }
    for (var db = Array(256), X = 0; 256 > X; ++X)
      db[X] = String.fromCharCode(X);
    Da = db;
    Ha = e.BindingError = Ga("BindingError");
    Ia = e.InternalError = Ga("InternalError");
    e.count_emval_handles = function() {
      for (var a = 0, b = 5; b < V.length; ++b)
        V[b] !== void 0 && ++a;
      return a;
    };
    e.get_first_emval = function() {
      for (var a = 5; a < V.length; ++a)
        if (V[a] !== void 0)
          return V[a];
      return null;
    };
    Za = e.UnboundTypeError = Ga("UnboundTypeError");
    sa.push({ I: function() {
      eb();
    } });
    var fb = {
      l: function(a) {
        return Y(a + 16) + 16;
      },
      k: function(a, b, c) {
        new Ba(a).K(b, c);
        throw a;
      },
      h: function(a, b, c, d, f) {
        var g = Ca(c);
        b = P(b);
        U(a, { name: b, fromWireType: function(n) {
          return !!n;
        }, toWireType: function(n, h) {
          return h ? d : f;
        }, argPackAdvance: 8, readValueFromPointer: function(n) {
          if (c === 1)
            var h = F;
          else if (c === 2)
            h = C;
          else if (c === 4)
            h = D;
          else
            throw new TypeError("Unknown boolean type size: " + b);
          return this.fromWireType(h[n >> g]);
        }, B: null });
      },
      q: function(a, b) {
        b = P(b);
        U(a, { name: b, fromWireType: function(c) {
          var d = V[c].value;
          Na(c);
          return d;
        }, toWireType: function(c, d) {
          return Oa(d);
        }, argPackAdvance: 8, readValueFromPointer: Pa, B: null });
      },
      g: function(a, b, c) {
        c = Ca(c);
        b = P(b);
        U(a, { name: b, fromWireType: function(d) {
          return d;
        }, toWireType: function(d, f) {
          if (typeof f !== "number" && typeof f !== "boolean")
            throw new TypeError('Cannot convert "' + Qa(f) + '" to ' + this.name);
          return f;
        }, argPackAdvance: 8, readValueFromPointer: Ra(b, c), B: null });
      },
      e: function(a, b, c, d, f, g) {
        var n = Wa(b, c);
        a = P(a);
        f = Ya(d, f);
        Va(a, function() {
          bb("Cannot call " + a + " due to unbound types", n);
        }, b - 1);
        La(n, function(h) {
          var l = a, p = a;
          h = [h[0], null].concat(h.slice(1));
          var q = f, m = h.length;
          2 > m && T("argTypes array size mismatch! Must at least get return value and 'this' types!");
          for (var r = h[1] !== null && false, w = false, k = 1; k < h.length; ++k)
            if (h[k] !== null && h[k].B === void 0) {
              w = true;
              break;
            }
          var Ja = h[0].name !== "void", G = "", K = "";
          for (k = 0; k < m - 2; ++k)
            G += (k !== 0 ? ", " : "") + "arg" + k, K += (k !== 0 ? ", " : "") + "arg" + k + "Wired";
          p = "return function " + Ea(p) + "(" + G + ") {\nif (arguments.length !== " + (m - 2) + ") {\nthrowBindingError('function " + p + " called with ' + arguments.length + ' arguments, expected " + (m - 2) + " args!');\n}\n";
          w && (p += "var destructors = [];\n");
          var Ka = w ? "destructors" : "null";
          G = "throwBindingError invoker fn runDestructors retType classParam".split(" ");
          q = [T, q, g, Ta, h[0], h[1]];
          r && (p += "var thisWired = classParam.toWireType(" + Ka + ", this);\n");
          for (k = 0; k < m - 2; ++k)
            p += "var arg" + k + "Wired = argType" + k + ".toWireType(" + Ka + ", arg" + k + "); // " + h[k + 2].name + "\n", G.push("argType" + k), q.push(h[k + 2]);
          r && (K = "thisWired" + (0 < K.length ? ", " : "") + K);
          p += (Ja ? "var rv = " : "") + "invoker(fn" + (0 < K.length ? ", " : "") + K + ");\n";
          if (w)
            p += "runDestructors(destructors);\n";
          else
            for (k = r ? 1 : 2; k < h.length; ++k)
              m = k === 1 ? "thisWired" : "arg" + (k - 2) + "Wired", h[k].B !== null && (p += m + "_dtor(" + m + "); // " + h[k].name + "\n", G.push(m + "_dtor"), q.push(h[k].B));
          Ja && (p += "var ret = retType.fromWireType(rv);\nreturn ret;\n");
          G.push(p + "}\n");
          h = Sa(G).apply(null, q);
          k = b - 1;
          if (!e.hasOwnProperty(l))
            throw new Ia("Replacing nonexistant public symbol");
          e[l].A !== void 0 && k !== void 0 ? e[l].A[k] = h : (e[l] = h, e[l].H = k);
          return [];
        });
      },
      c: function(a, b, c, d, f) {
        function g(p) {
          return p;
        }
        b = P(b);
        f === -1 && (f = 4294967295);
        var n = Ca(c);
        if (d === 0) {
          var h = 32 - 8 * c;
          g = function(p) {
            return p << h >>> h;
          };
        }
        var l = b.indexOf("unsigned") != -1;
        U(a, { name: b, fromWireType: g, toWireType: function(p, q) {
          if (typeof q !== "number" && typeof q !== "boolean")
            throw new TypeError('Cannot convert "' + Qa(q) + '" to ' + this.name);
          if (q < d || q > f)
            throw new TypeError('Passing a number "' + Qa(q) + '" from JS side to C/C++ side to an argument of type "' + b + '", which is outside the valid range [' + d + ", " + f + "]!");
          return l ? q >>> 0 : q | 0;
        }, argPackAdvance: 8, readValueFromPointer: cb(b, n, d !== 0), B: null });
      },
      b: function(a, b, c) {
        function d(g) {
          g >>= 2;
          var n = H;
          return new f(E, n[g + 1], n[g]);
        }
        var f = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array][b];
        c = P(c);
        U(a, { name: c, fromWireType: d, argPackAdvance: 8, readValueFromPointer: d }, { J: true });
      },
      f: function(a, b) {
        b = P(b);
        var c = b === "std::string";
        U(a, { name: b, fromWireType: function(d) {
          var f = H[d >> 2];
          if (c)
            for (var g = d + 4, n = 0; n <= f; ++n) {
              var h = d + 4 + n;
              if (n == f || A[h] == 0) {
                if (g) {
                  var l = g;
                  var p = A, q = l + (h - g);
                  for (g = l; p[g] && !(g >= q); )
                    ++g;
                  if (16 < g - l && p.subarray && da)
                    l = da.decode(p.subarray(l, g));
                  else {
                    for (q = ""; l < g; ) {
                      var m = p[l++];
                      if (m & 128) {
                        var r = p[l++] & 63;
                        if ((m & 224) == 192)
                          q += String.fromCharCode((m & 31) << 6 | r);
                        else {
                          var w = p[l++] & 63;
                          m = (m & 240) == 224 ? (m & 15) << 12 | r << 6 | w : (m & 7) << 18 | r << 12 | w << 6 | p[l++] & 63;
                          65536 > m ? q += String.fromCharCode(m) : (m -= 65536, q += String.fromCharCode(55296 | m >> 10, 56320 | m & 1023));
                        }
                      } else
                        q += String.fromCharCode(m);
                    }
                    l = q;
                  }
                } else
                  l = "";
                if (k === void 0)
                  var k = l;
                else
                  k += String.fromCharCode(0), k += l;
                g = h + 1;
              }
            }
          else {
            k = Array(f);
            for (n = 0; n < f; ++n)
              k[n] = String.fromCharCode(A[d + 4 + n]);
            k = k.join("");
          }
          W(d);
          return k;
        }, toWireType: function(d, f) {
          f instanceof ArrayBuffer && (f = new Uint8Array(f));
          var g = typeof f === "string";
          g || f instanceof Uint8Array || f instanceof Uint8ClampedArray || f instanceof Int8Array || T("Cannot pass non-string to std::string");
          var n = (c && g ? function() {
            for (var p = 0, q = 0; q < f.length; ++q) {
              var m = f.charCodeAt(q);
              55296 <= m && 57343 >= m && (m = 65536 + ((m & 1023) << 10) | f.charCodeAt(++q) & 1023);
              127 >= m ? ++p : p = 2047 >= m ? p + 2 : 65535 >= m ? p + 3 : p + 4;
            }
            return p;
          } : function() {
            return f.length;
          })(), h = Y(4 + n + 1);
          H[h >> 2] = n;
          if (c && g)
            ea(f, h + 4, n + 1);
          else if (g)
            for (g = 0; g < n; ++g) {
              var l = f.charCodeAt(g);
              255 < l && (W(h), T("String has UTF-16 code units that do not fit in 8 bits"));
              A[h + 4 + g] = l;
            }
          else
            for (g = 0; g < n; ++g)
              A[h + 4 + g] = f[g];
          d !== null && d.push(W, h);
          return h;
        }, argPackAdvance: 8, readValueFromPointer: Pa, B: function(d) {
          W(d);
        } });
      },
      d: function(a, b, c) {
        c = P(c);
        if (b === 2) {
          var d = ha;
          var f = ia;
          var g = ja;
          var n = function() {
            return B;
          };
          var h = 1;
        } else
          b === 4 && (d = ka, f = la, g = ma, n = function() {
            return H;
          }, h = 2);
        U(a, { name: c, fromWireType: function(l) {
          for (var p = H[l >> 2], q = n(), m, r = l + 4, w = 0; w <= p; ++w) {
            var k = l + 4 + w * b;
            if (w == p || q[k >> h] == 0)
              r = d(r, k - r), m === void 0 ? m = r : (m += String.fromCharCode(0), m += r), r = k + b;
          }
          W(l);
          return m;
        }, toWireType: function(l, p) {
          typeof p !== "string" && T("Cannot pass non-string to C++ string type " + c);
          var q = g(p), m = Y(4 + q + b);
          H[m >> 2] = q >> h;
          f(p, m + 4, q + b);
          l !== null && l.push(W, m);
          return m;
        }, argPackAdvance: 8, readValueFromPointer: Pa, B: function(l) {
          W(l);
        } });
      },
      i: function(a, b) {
        b = P(b);
        U(a, { R: true, name: b, argPackAdvance: 0, fromWireType: function() {
        }, toWireType: function() {
        } });
      },
      j: Na,
      m: function(a) {
        4 < a && (V[a].F += 1);
      },
      r: function(a, b) {
        var c = R[a];
        c === void 0 && T("_emval_take_value has unknown type " + $a(a));
        a = c.readValueFromPointer(b);
        return Oa(a);
      },
      p: function() {
        y();
      },
      n: function(a, b, c) {
        A.copyWithin(a, b, b + c);
      },
      o: function(a) {
        a >>>= 0;
        var b = A.length;
        if (2147483648 < a)
          return false;
        for (var c = 1; 4 >= c; c *= 2) {
          var d = b * (1 + 0.2 / c);
          d = Math.min(d, a + 100663296);
          d = Math.max(16777216, a, d);
          0 < d % 65536 && (d += 65536 - d % 65536);
          a: {
            try {
              z.grow(Math.min(2147483648, d) - E.byteLength + 65535 >>> 16);
              pa(z.buffer);
              var f = 1;
              break a;
            } catch (g) {
            }
            f = void 0;
          }
          if (f)
            return true;
        }
        return false;
      },
      a: z
    };
    (function() {
      function a(f) {
        e.asm = f.exports;
        I = e.asm.s;
        J--;
        e.monitorRunDependencies && e.monitorRunDependencies(J);
        J == 0 && (L && (f = L, L = null, f()));
      }
      function b(f) {
        a(f.instance);
      }
      function c(f) {
        return Promise.resolve().then(Aa).then(function(g) {
          return WebAssembly.instantiate(g, d);
        }).then(f, function(g) {
          v("failed to asynchronously prepare wasm: " + g);
          y(g);
        });
      }
      var d = { a: fb };
      J++;
      e.monitorRunDependencies && e.monitorRunDependencies(J);
      if (e.instantiateWasm)
        try {
          return e.instantiateWasm(d, a);
        } catch (f) {
          return v("Module.instantiateWasm callback failed with error: " + f), false;
        }
      (function() {
        return x || typeof WebAssembly.instantiateStreaming !== "function" || ya() || xa("file://") || typeof fetch !== "function" ? c(b) : fetch(M, { credentials: "same-origin" }).then(function(f) {
          return WebAssembly.instantiateStreaming(f, d).then(b, function(g) {
            v("wasm streaming compile failed: " + g);
            v("falling back to ArrayBuffer instantiation");
            return c(b);
          });
        });
      })().catch(ba);
      return {};
    })();
    var eb = e.___wasm_call_ctors = function() {
      return (eb = e.___wasm_call_ctors = e.asm.t).apply(null, arguments);
    }, Y = e._malloc = function() {
      return (Y = e._malloc = e.asm.u).apply(null, arguments);
    }, W = e._free = function() {
      return (W = e._free = e.asm.v).apply(null, arguments);
    }, ab = e.___getTypeName = function() {
      return (ab = e.___getTypeName = e.asm.w).apply(null, arguments);
    };
    e.___embind_register_native_and_builtin_types = function() {
      return (e.___embind_register_native_and_builtin_types = e.asm.x).apply(null, arguments);
    };
    var Z;
    L = function gb() {
      Z || hb();
      Z || (L = gb);
    };
    function hb() {
      function a() {
        if (!Z && (Z = true, e.calledRun = true, !ca)) {
          N(sa);
          N(ta);
          aa(e);
          if (e.onRuntimeInitialized)
            e.onRuntimeInitialized();
          if (e.postRun)
            for (typeof e.postRun == "function" && (e.postRun = [e.postRun]); e.postRun.length; ) {
              var b = e.postRun.shift();
              ua.unshift(b);
            }
          N(ua);
        }
      }
      if (!(0 < J)) {
        if (e.preRun)
          for (typeof e.preRun == "function" && (e.preRun = [e.preRun]); e.preRun.length; )
            va();
        N(ra);
        0 < J || (e.setStatus ? (e.setStatus("Running..."), setTimeout(function() {
          setTimeout(function() {
            e.setStatus("");
          }, 1);
          a();
        }, 1)) : a());
      }
    }
    e.run = hb;
    if (e.preInit)
      for (typeof e.preInit == "function" && (e.preInit = [e.preInit]); 0 < e.preInit.length; )
        e.preInit.pop()();
    hb();
    return lz4_codec2.ready;
  };
}();
var __isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
var __toBinary = __isNode ? (base64) => new Uint8Array(Buffer.from(base64, "base64")) : /* @__PURE__ */ (() => {
  var table = new Uint8Array(128);
  for (var i = 0; i < 64; i++)
    table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i;
  return (base64) => {
    var n = base64.length, bytes = new Uint8Array((n - (base64[n - 1] == "=") - (base64[n - 2] == "=")) * 3 / 4 | 0);
    for (var i2 = 0, j = 0; i2 < n; ) {
      var c0 = table[base64.charCodeAt(i2++)], c1 = table[base64.charCodeAt(i2++)];
      var c2 = table[base64.charCodeAt(i2++)], c3 = table[base64.charCodeAt(i2++)];
      bytes[j++] = c0 << 2 | c1 >> 4;
      bytes[j++] = c1 << 4 | c2 >> 2;
      bytes[j++] = c2 << 6 | c3;
    }
    return bytes;
  };
})();
var wasmBinary = __toBinary(" ");
var _a;
const DEFAULT_ACCELERATION = 1;
const MAX_BUFFER_SIZE = 2113929216;
let emscriptenModule;
const init = () => lz4_codec({ noInitialRun: true, wasmBinary });
const LZ4 = (_a = class {
  constructor(acceleration = DEFAULT_ACCELERATION) {
    this.max_buffer_size = MAX_BUFFER_SIZE;
    if (!Number.isInteger(acceleration)) {
      throw Error(`Invalid acceleration "${acceleration}". Must be a positive integer.`);
    }
    this.acceleration = acceleration <= 0 ? DEFAULT_ACCELERATION : acceleration;
  }
  static fromConfig({ acceleration }) {
    return new _a(acceleration);
  }
  async encode(data) {
    if (!emscriptenModule) {
      emscriptenModule = init();
    }
    if (data.length > MAX_BUFFER_SIZE) {
      throw Error(`Codec does not support buffers of > ${MAX_BUFFER_SIZE} bytes.`);
    }
    const module = await emscriptenModule;
    const view = module.compress(data, this.acceleration);
    const result = new Uint8Array(view);
    module.free_result();
    return result;
  }
  async decode(data, out) {
    if (!emscriptenModule) {
      emscriptenModule = init();
    }
    if (data.length > MAX_BUFFER_SIZE) {
      throw Error(`Codec does not support buffers of > ${MAX_BUFFER_SIZE} bytes.`);
    }
    const module = await emscriptenModule;
    const view = module.decompress(data);
    const result = new Uint8Array(view);
    module.free_result();
    if (out !== void 0) {
      out.set(result);
      return out;
    }
    return result;
  }
}, _a.codecId = "lz4", _a.DEFAULT_ACCELERATION = DEFAULT_ACCELERATION, _a.max_buffer_size = MAX_BUFFER_SIZE, _a);
export {
  LZ4 as default
};
