tanglepaysdk-client
Version:
DApp SDK to interact with TanglePay wallets
1,607 lines • 105 kB
JavaScript
/**
* @license
* author:
* tanglepaysdk-common.js v0.1.9
* Released under the ISC license.
*/
var TanglePaySdkCommon = (function (e) {
'use strict';
var t = function (e, n) {
return (
(t =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (e, t) {
e.__proto__ = t;
}) ||
function (e, t) {
for (var n in t)
Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
}),
t(e, n)
);
};
function n(e, t, n, r) {
return new (n || (n = Promise))(function (i, o) {
function s(e) {
try {
u(r.next(e));
} catch (e) {
o(e);
}
}
function a(e) {
try {
u(r.throw(e));
} catch (e) {
o(e);
}
}
function u(e) {
var t;
e.done
? i(e.value)
: ((t = e.value),
t instanceof n
? t
: new n(function (e) {
e(t);
})).then(s, a);
}
u((r = r.apply(e, t || [])).next());
});
}
function r(e, t) {
var n,
r,
i,
o,
s = {
label: 0,
sent: function () {
if (1 & i[0]) throw i[1];
return i[1];
},
trys: [],
ops: [],
};
return (
(o = { next: a(0), throw: a(1), return: a(2) }),
'function' == typeof Symbol &&
(o[Symbol.iterator] = function () {
return this;
}),
o
);
function a(a) {
return function (u) {
return (function (a) {
if (n) throw new TypeError('Generator is already executing.');
for (; o && ((o = 0), a[0] && (s = 0)), s; )
try {
if (
((n = 1),
r &&
(i =
2 & a[0]
? r.return
: a[0]
? r.throw || ((i = r.return) && i.call(r), 0)
: r.next) &&
!(i = i.call(r, a[1])).done)
)
return i;
switch (((r = 0), i && (a = [2 & a[0], i.value]), a[0])) {
case 0:
case 1:
i = a;
break;
case 4:
return s.label++, { value: a[1], done: !1 };
case 5:
s.label++, (r = a[1]), (a = [0]);
continue;
case 7:
(a = s.ops.pop()), s.trys.pop();
continue;
default:
if (
!((i = s.trys),
(i = i.length > 0 && i[i.length - 1]) ||
(6 !== a[0] && 2 !== a[0]))
) {
s = 0;
continue;
}
if (3 === a[0] && (!i || (a[1] > i[0] && a[1] < i[3]))) {
s.label = a[1];
break;
}
if (6 === a[0] && s.label < i[1]) {
(s.label = i[1]), (i = a);
break;
}
if (i && s.label < i[2]) {
(s.label = i[2]), s.ops.push(a);
break;
}
i[2] && s.ops.pop(), s.trys.pop();
continue;
}
a = t.call(e, s);
} catch (e) {
(a = [6, e]), (r = 0);
} finally {
n = i = 0;
}
if (5 & a[0]) throw a[1];
return { value: a[0] ? a[1] : void 0, done: !0 };
})([a, u]);
};
}
}
function i() {}
function o() {
o.init.call(this);
}
function s(e) {
return void 0 === e._maxListeners ? o.defaultMaxListeners : e._maxListeners;
}
function a(e, t, n, r) {
var o, a, u, f;
if ('function' != typeof n)
throw new TypeError('"listener" argument must be a function');
if (
((a = e._events)
? (a.newListener &&
(e.emit('newListener', t, n.listener ? n.listener : n),
(a = e._events)),
(u = a[t]))
: ((a = e._events = new i()), (e._eventsCount = 0)),
u)
) {
if (
('function' == typeof u
? (u = a[t] = r ? [n, u] : [u, n])
: r
? u.unshift(n)
: u.push(n),
!u.warned && (o = s(e)) && o > 0 && u.length > o)
) {
u.warned = !0;
var h = new Error(
'Possible EventEmitter memory leak detected. ' +
u.length +
' ' +
t +
' listeners added. Use emitter.setMaxListeners() to increase limit',
);
(h.name = 'MaxListenersExceededWarning'),
(h.emitter = e),
(h.type = t),
(h.count = u.length),
(f = h),
'function' == typeof console.warn ? console.warn(f) : console.log(f);
}
} else (u = a[t] = n), ++e._eventsCount;
return e;
}
function u(e, t, n) {
var r = !1;
function i() {
e.removeListener(t, i), r || ((r = !0), n.apply(e, arguments));
}
return (i.listener = n), i;
}
function f(e) {
var t = this._events;
if (t) {
var n = t[e];
if ('function' == typeof n) return 1;
if (n) return n.length;
}
return 0;
}
function h(e, t) {
for (var n = new Array(t); t--; ) n[t] = e[t];
return n;
}
(i.prototype = Object.create(null)),
(o.EventEmitter = o),
(o.usingDomains = !1),
(o.prototype.domain = void 0),
(o.prototype._events = void 0),
(o.prototype._maxListeners = void 0),
(o.defaultMaxListeners = 10),
(o.init = function () {
(this.domain = null),
o.usingDomains && undefined.active,
(this._events &&
this._events !== Object.getPrototypeOf(this)._events) ||
((this._events = new i()), (this._eventsCount = 0)),
(this._maxListeners = this._maxListeners || void 0);
}),
(o.prototype.setMaxListeners = function (e) {
if ('number' != typeof e || e < 0 || isNaN(e))
throw new TypeError('"n" argument must be a positive number');
return (this._maxListeners = e), this;
}),
(o.prototype.getMaxListeners = function () {
return s(this);
}),
(o.prototype.emit = function (e) {
var t,
n,
r,
i,
o,
s,
a,
u = 'error' === e;
if ((s = this._events)) u = u && null == s.error;
else if (!u) return !1;
if (((a = this.domain), u)) {
if (((t = arguments[1]), !a)) {
if (t instanceof Error) throw t;
var f = new Error('Uncaught, unspecified "error" event. (' + t + ')');
throw ((f.context = t), f);
}
return (
t || (t = new Error('Uncaught, unspecified "error" event')),
(t.domainEmitter = this),
(t.domain = a),
(t.domainThrown = !1),
a.emit('error', t),
!1
);
}
if (!(n = s[e])) return !1;
var c = 'function' == typeof n;
switch ((r = arguments.length)) {
case 1:
!(function (e, t, n) {
if (t) e.call(n);
else
for (var r = e.length, i = h(e, r), o = 0; o < r; ++o)
i[o].call(n);
})(n, c, this);
break;
case 2:
!(function (e, t, n, r) {
if (t) e.call(n, r);
else
for (var i = e.length, o = h(e, i), s = 0; s < i; ++s)
o[s].call(n, r);
})(n, c, this, arguments[1]);
break;
case 3:
!(function (e, t, n, r, i) {
if (t) e.call(n, r, i);
else
for (var o = e.length, s = h(e, o), a = 0; a < o; ++a)
s[a].call(n, r, i);
})(n, c, this, arguments[1], arguments[2]);
break;
case 4:
!(function (e, t, n, r, i, o) {
if (t) e.call(n, r, i, o);
else
for (var s = e.length, a = h(e, s), u = 0; u < s; ++u)
a[u].call(n, r, i, o);
})(n, c, this, arguments[1], arguments[2], arguments[3]);
break;
default:
for (i = new Array(r - 1), o = 1; o < r; o++) i[o - 1] = arguments[o];
!(function (e, t, n, r) {
if (t) e.apply(n, r);
else
for (var i = e.length, o = h(e, i), s = 0; s < i; ++s)
o[s].apply(n, r);
})(n, c, this, i);
}
return !0;
}),
(o.prototype.addListener = function (e, t) {
return a(this, e, t, !1);
}),
(o.prototype.on = o.prototype.addListener),
(o.prototype.prependListener = function (e, t) {
return a(this, e, t, !0);
}),
(o.prototype.once = function (e, t) {
if ('function' != typeof t)
throw new TypeError('"listener" argument must be a function');
return this.on(e, u(this, e, t)), this;
}),
(o.prototype.prependOnceListener = function (e, t) {
if ('function' != typeof t)
throw new TypeError('"listener" argument must be a function');
return this.prependListener(e, u(this, e, t)), this;
}),
(o.prototype.removeListener = function (e, t) {
var n, r, o, s, a;
if ('function' != typeof t)
throw new TypeError('"listener" argument must be a function');
if (!(r = this._events)) return this;
if (!(n = r[e])) return this;
if (n === t || (n.listener && n.listener === t))
0 == --this._eventsCount
? (this._events = new i())
: (delete r[e],
r.removeListener &&
this.emit('removeListener', e, n.listener || t));
else if ('function' != typeof n) {
for (o = -1, s = n.length; s-- > 0; )
if (n[s] === t || (n[s].listener && n[s].listener === t)) {
(a = n[s].listener), (o = s);
break;
}
if (o < 0) return this;
if (1 === n.length) {
if (((n[0] = void 0), 0 == --this._eventsCount))
return (this._events = new i()), this;
delete r[e];
} else
!(function (e, t) {
for (var n = t, r = n + 1, i = e.length; r < i; n += 1, r += 1)
e[n] = e[r];
e.pop();
})(n, o);
r.removeListener && this.emit('removeListener', e, a || t);
}
return this;
}),
(o.prototype.off = function (e, t) {
return this.removeListener(e, t);
}),
(o.prototype.removeAllListeners = function (e) {
var t, n;
if (!(n = this._events)) return this;
if (!n.removeListener)
return (
0 === arguments.length
? ((this._events = new i()), (this._eventsCount = 0))
: n[e] &&
(0 == --this._eventsCount
? (this._events = new i())
: delete n[e]),
this
);
if (0 === arguments.length) {
for (var r, o = Object.keys(n), s = 0; s < o.length; ++s)
'removeListener' !== (r = o[s]) && this.removeAllListeners(r);
return (
this.removeAllListeners('removeListener'),
(this._events = new i()),
(this._eventsCount = 0),
this
);
}
if ('function' == typeof (t = n[e])) this.removeListener(e, t);
else if (t)
do {
this.removeListener(e, t[t.length - 1]);
} while (t[0]);
return this;
}),
(o.prototype.listeners = function (e) {
var t,
n = this._events;
return n && (t = n[e])
? 'function' == typeof t
? [t.listener || t]
: (function (e) {
for (var t = new Array(e.length), n = 0; n < t.length; ++n)
t[n] = e[n].listener || e[n];
return t;
})(t)
: [];
}),
(o.listenerCount = function (e, t) {
return 'function' == typeof e.listenerCount
? e.listenerCount(t)
: f.call(e, t);
}),
(o.prototype.listenerCount = f),
(o.prototype.eventNames = function () {
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
});
var c =
'undefined' != typeof global
? global
: 'undefined' != typeof self
? self
: 'undefined' != typeof window
? window
: {},
l = [],
d = [],
p = 'undefined' != typeof Uint8Array ? Uint8Array : Array,
g = !1;
function v() {
g = !0;
for (
var e =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
t = 0;
t < 64;
++t
)
(l[t] = e[t]), (d[e.charCodeAt(t)] = t);
(d['-'.charCodeAt(0)] = 62), (d['_'.charCodeAt(0)] = 63);
}
function w(e, t, n) {
for (var r, i, o = [], s = t; s < n; s += 3)
(r = (e[s] << 16) + (e[s + 1] << 8) + e[s + 2]),
o.push(
l[((i = r) >> 18) & 63] +
l[(i >> 12) & 63] +
l[(i >> 6) & 63] +
l[63 & i],
);
return o.join('');
}
function y(e) {
var t;
g || v();
for (
var n = e.length, r = n % 3, i = '', o = [], s = 16383, a = 0, u = n - r;
a < u;
a += s
)
o.push(w(e, a, a + s > u ? u : a + s));
return (
1 === r
? ((t = e[n - 1]),
(i += l[t >> 2]),
(i += l[(t << 4) & 63]),
(i += '=='))
: 2 === r &&
((t = (e[n - 2] << 8) + e[n - 1]),
(i += l[t >> 10]),
(i += l[(t >> 4) & 63]),
(i += l[(t << 2) & 63]),
(i += '=')),
o.push(i),
o.join('')
);
}
function b(e, t, n, r, i) {
var o,
s,
a = 8 * i - r - 1,
u = (1 << a) - 1,
f = u >> 1,
h = -7,
c = n ? i - 1 : 0,
l = n ? -1 : 1,
d = e[t + c];
for (
c += l, o = d & ((1 << -h) - 1), d >>= -h, h += a;
h > 0;
o = 256 * o + e[t + c], c += l, h -= 8
);
for (
s = o & ((1 << -h) - 1), o >>= -h, h += r;
h > 0;
s = 256 * s + e[t + c], c += l, h -= 8
);
if (0 === o) o = 1 - f;
else {
if (o === u) return s ? NaN : (1 / 0) * (d ? -1 : 1);
(s += Math.pow(2, r)), (o -= f);
}
return (d ? -1 : 1) * s * Math.pow(2, o - r);
}
function m(e, t, n, r, i, o) {
var s,
a,
u,
f = 8 * o - i - 1,
h = (1 << f) - 1,
c = h >> 1,
l = 23 === i ? Math.pow(2, -24) - Math.pow(2, -77) : 0,
d = r ? 0 : o - 1,
p = r ? 1 : -1,
g = t < 0 || (0 === t && 1 / t < 0) ? 1 : 0;
for (
t = Math.abs(t),
isNaN(t) || t === 1 / 0
? ((a = isNaN(t) ? 1 : 0), (s = h))
: ((s = Math.floor(Math.log(t) / Math.LN2)),
t * (u = Math.pow(2, -s)) < 1 && (s--, (u *= 2)),
(t += s + c >= 1 ? l / u : l * Math.pow(2, 1 - c)) * u >= 2 &&
(s++, (u /= 2)),
s + c >= h
? ((a = 0), (s = h))
: s + c >= 1
? ((a = (t * u - 1) * Math.pow(2, i)), (s += c))
: ((a = t * Math.pow(2, c - 1) * Math.pow(2, i)), (s = 0)));
i >= 8;
e[n + d] = 255 & a, d += p, a /= 256, i -= 8
);
for (
s = (s << i) | a, f += i;
f > 0;
e[n + d] = 255 & s, d += p, s /= 256, f -= 8
);
e[n + d - p] |= 128 * g;
}
var _ = {}.toString,
E =
Array.isArray ||
function (e) {
return '[object Array]' == _.call(e);
};
function R() {
return A.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
}
function S(e, t) {
if (R() < t) throw new RangeError('Invalid typed array length');
return (
A.TYPED_ARRAY_SUPPORT
? ((e = new Uint8Array(t)).__proto__ = A.prototype)
: (null === e && (e = new A(t)), (e.length = t)),
e
);
}
function A(e, t, n) {
if (!(A.TYPED_ARRAY_SUPPORT || this instanceof A)) return new A(e, t, n);
if ('number' == typeof e) {
if ('string' == typeof t)
throw new Error(
'If encoding is specified then the first argument must be a string',
);
return T(this, e);
}
return L(this, e, t, n);
}
function L(e, t, n, r) {
if ('number' == typeof t)
throw new TypeError('"value" argument must not be a number');
return 'undefined' != typeof ArrayBuffer && t instanceof ArrayBuffer
? (function (e, t, n, r) {
if ((t.byteLength, n < 0 || t.byteLength < n))
throw new RangeError("'offset' is out of bounds");
if (t.byteLength < n + (r || 0))
throw new RangeError("'length' is out of bounds");
t =
void 0 === n && void 0 === r
? new Uint8Array(t)
: void 0 === r
? new Uint8Array(t, n)
: new Uint8Array(t, n, r);
A.TYPED_ARRAY_SUPPORT
? ((e = t).__proto__ = A.prototype)
: (e = M(e, t));
return e;
})(e, t, n, r)
: 'string' == typeof t
? (function (e, t, n) {
('string' == typeof n && '' !== n) || (n = 'utf8');
if (!A.isEncoding(n))
throw new TypeError('"encoding" must be a valid string encoding');
var r = 0 | C(t, n);
e = S(e, r);
var i = e.write(t, n);
i !== r && (e = e.slice(0, i));
return e;
})(e, t, n)
: (function (e, t) {
if (x(t)) {
var n = 0 | P(t.length);
return 0 === (e = S(e, n)).length || t.copy(e, 0, 0, n), e;
}
if (t) {
if (
('undefined' != typeof ArrayBuffer &&
t.buffer instanceof ArrayBuffer) ||
'length' in t
)
return 'number' != typeof t.length || (r = t.length) != r
? S(e, 0)
: M(e, t);
if ('Buffer' === t.type && E(t.data)) return M(e, t.data);
}
var r;
throw new TypeError(
'First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.',
);
})(e, t);
}
function k(e) {
if ('number' != typeof e)
throw new TypeError('"size" argument must be a number');
if (e < 0) throw new RangeError('"size" argument must not be negative');
}
function T(e, t) {
if ((k(t), (e = S(e, t < 0 ? 0 : 0 | P(t))), !A.TYPED_ARRAY_SUPPORT))
for (var n = 0; n < t; ++n) e[n] = 0;
return e;
}
function M(e, t) {
var n = t.length < 0 ? 0 : 0 | P(t.length);
e = S(e, n);
for (var r = 0; r < n; r += 1) e[r] = 255 & t[r];
return e;
}
function P(e) {
if (e >= R())
throw new RangeError(
'Attempt to allocate Buffer larger than maximum size: 0x' +
R().toString(16) +
' bytes',
);
return 0 | e;
}
function x(e) {
return !(null == e || !e._isBuffer);
}
function C(e, t) {
if (x(e)) return e.length;
if (
'undefined' != typeof ArrayBuffer &&
'function' == typeof ArrayBuffer.isView &&
(ArrayBuffer.isView(e) || e instanceof ArrayBuffer)
)
return e.byteLength;
'string' != typeof e && (e = '' + e);
var n = e.length;
if (0 === n) return 0;
for (var r = !1; ; )
switch (t) {
case 'ascii':
case 'latin1':
case 'binary':
return n;
case 'utf8':
case 'utf-8':
case void 0:
return oe(e).length;
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return 2 * n;
case 'hex':
return n >>> 1;
case 'base64':
return se(e).length;
default:
if (r) return oe(e).length;
(t = ('' + t).toLowerCase()), (r = !0);
}
}
function O(e, t, n) {
var r = !1;
if (((void 0 === t || t < 0) && (t = 0), t > this.length)) return '';
if (((void 0 === n || n > this.length) && (n = this.length), n <= 0))
return '';
if ((n >>>= 0) <= (t >>>= 0)) return '';
for (e || (e = 'utf8'); ; )
switch (e) {
case 'hex':
return $(this, t, n);
case 'utf8':
case 'utf-8':
return F(this, t, n);
case 'ascii':
return G(this, t, n);
case 'latin1':
case 'binary':
return J(this, t, n);
case 'base64':
return W(this, t, n);
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return V(this, t, n);
default:
if (r) throw new TypeError('Unknown encoding: ' + e);
(e = (e + '').toLowerCase()), (r = !0);
}
}
function B(e, t, n) {
var r = e[t];
(e[t] = e[n]), (e[n] = r);
}
function j(e, t, n, r, i) {
if (0 === e.length) return -1;
if (
('string' == typeof n
? ((r = n), (n = 0))
: n > 2147483647
? (n = 2147483647)
: n < -2147483648 && (n = -2147483648),
(n = +n),
isNaN(n) && (n = i ? 0 : e.length - 1),
n < 0 && (n = e.length + n),
n >= e.length)
) {
if (i) return -1;
n = e.length - 1;
} else if (n < 0) {
if (!i) return -1;
n = 0;
}
if (('string' == typeof t && (t = A.from(t, r)), x(t)))
return 0 === t.length ? -1 : U(e, t, n, r, i);
if ('number' == typeof t)
return (
(t &= 255),
A.TYPED_ARRAY_SUPPORT &&
'function' == typeof Uint8Array.prototype.indexOf
? i
? Uint8Array.prototype.indexOf.call(e, t, n)
: Uint8Array.prototype.lastIndexOf.call(e, t, n)
: U(e, [t], n, r, i)
);
throw new TypeError('val must be string, number or Buffer');
}
function U(e, t, n, r, i) {
var o,
s = 1,
a = e.length,
u = t.length;
if (
void 0 !== r &&
('ucs2' === (r = String(r).toLowerCase()) ||
'ucs-2' === r ||
'utf16le' === r ||
'utf-16le' === r)
) {
if (e.length < 2 || t.length < 2) return -1;
(s = 2), (a /= 2), (u /= 2), (n /= 2);
}
function f(e, t) {
return 1 === s ? e[t] : e.readUInt16BE(t * s);
}
if (i) {
var h = -1;
for (o = n; o < a; o++)
if (f(e, o) === f(t, -1 === h ? 0 : o - h)) {
if ((-1 === h && (h = o), o - h + 1 === u)) return h * s;
} else -1 !== h && (o -= o - h), (h = -1);
} else
for (n + u > a && (n = a - u), o = n; o >= 0; o--) {
for (var c = !0, l = 0; l < u; l++)
if (f(e, o + l) !== f(t, l)) {
c = !1;
break;
}
if (c) return o;
}
return -1;
}
function D(e, t, n, r) {
n = Number(n) || 0;
var i = e.length - n;
r ? (r = Number(r)) > i && (r = i) : (r = i);
var o = t.length;
if (o % 2 != 0) throw new TypeError('Invalid hex string');
r > o / 2 && (r = o / 2);
for (var s = 0; s < r; ++s) {
var a = parseInt(t.substr(2 * s, 2), 16);
if (isNaN(a)) return s;
e[n + s] = a;
}
return s;
}
function I(e, t, n, r) {
return ae(oe(t, e.length - n), e, n, r);
}
function Y(e, t, n, r) {
return ae(
(function (e) {
for (var t = [], n = 0; n < e.length; ++n)
t.push(255 & e.charCodeAt(n));
return t;
})(t),
e,
n,
r,
);
}
function z(e, t, n, r) {
return Y(e, t, n, r);
}
function N(e, t, n, r) {
return ae(se(t), e, n, r);
}
function q(e, t, n, r) {
return ae(
(function (e, t) {
for (var n, r, i, o = [], s = 0; s < e.length && !((t -= 2) < 0); ++s)
(r = (n = e.charCodeAt(s)) >> 8), (i = n % 256), o.push(i), o.push(r);
return o;
})(t, e.length - n),
e,
n,
r,
);
}
function W(e, t, n) {
return 0 === t && n === e.length ? y(e) : y(e.slice(t, n));
}
function F(e, t, n) {
n = Math.min(e.length, n);
for (var r = [], i = t; i < n; ) {
var o,
s,
a,
u,
f = e[i],
h = null,
c = f > 239 ? 4 : f > 223 ? 3 : f > 191 ? 2 : 1;
if (i + c <= n)
switch (c) {
case 1:
f < 128 && (h = f);
break;
case 2:
128 == (192 & (o = e[i + 1])) &&
(u = ((31 & f) << 6) | (63 & o)) > 127 &&
(h = u);
break;
case 3:
(o = e[i + 1]),
(s = e[i + 2]),
128 == (192 & o) &&
128 == (192 & s) &&
(u = ((15 & f) << 12) | ((63 & o) << 6) | (63 & s)) > 2047 &&
(u < 55296 || u > 57343) &&
(h = u);
break;
case 4:
(o = e[i + 1]),
(s = e[i + 2]),
(a = e[i + 3]),
128 == (192 & o) &&
128 == (192 & s) &&
128 == (192 & a) &&
(u =
((15 & f) << 18) |
((63 & o) << 12) |
((63 & s) << 6) |
(63 & a)) > 65535 &&
u < 1114112 &&
(h = u);
}
null === h
? ((h = 65533), (c = 1))
: h > 65535 &&
((h -= 65536),
r.push(((h >>> 10) & 1023) | 55296),
(h = 56320 | (1023 & h))),
r.push(h),
(i += c);
}
return (function (e) {
var t = e.length;
if (t <= H) return String.fromCharCode.apply(String, e);
var n = '',
r = 0;
for (; r < t; )
n += String.fromCharCode.apply(String, e.slice(r, (r += H)));
return n;
})(r);
}
(A.TYPED_ARRAY_SUPPORT =
void 0 === c.TYPED_ARRAY_SUPPORT || c.TYPED_ARRAY_SUPPORT),
R(),
(A.poolSize = 8192),
(A._augment = function (e) {
return (e.__proto__ = A.prototype), e;
}),
(A.from = function (e, t, n) {
return L(null, e, t, n);
}),
A.TYPED_ARRAY_SUPPORT &&
((A.prototype.__proto__ = Uint8Array.prototype),
(A.__proto__ = Uint8Array),
'undefined' != typeof Symbol && Symbol.species && A[Symbol.species]),
(A.alloc = function (e, t, n) {
return (function (e, t, n, r) {
return (
k(t),
t <= 0
? S(e, t)
: void 0 !== n
? 'string' == typeof r
? S(e, t).fill(n, r)
: S(e, t).fill(n)
: S(e, t)
);
})(null, e, t, n);
}),
(A.allocUnsafe = function (e) {
return T(null, e);
}),
(A.allocUnsafeSlow = function (e) {
return T(null, e);
}),
(A.isBuffer = function (e) {
return (
null != e &&
(!!e._isBuffer ||
ue(e) ||
(function (e) {
return (
'function' == typeof e.readFloatLE &&
'function' == typeof e.slice &&
ue(e.slice(0, 0))
);
})(e))
);
}),
(A.compare = function (e, t) {
if (!x(e) || !x(t)) throw new TypeError('Arguments must be Buffers');
if (e === t) return 0;
for (
var n = e.length, r = t.length, i = 0, o = Math.min(n, r);
i < o;
++i
)
if (e[i] !== t[i]) {
(n = e[i]), (r = t[i]);
break;
}
return n < r ? -1 : r < n ? 1 : 0;
}),
(A.isEncoding = function (e) {
switch (String(e).toLowerCase()) {
case 'hex':
case 'utf8':
case 'utf-8':
case 'ascii':
case 'latin1':
case 'binary':
case 'base64':
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return !0;
default:
return !1;
}
}),
(A.concat = function (e, t) {
if (!E(e))
throw new TypeError('"list" argument must be an Array of Buffers');
if (0 === e.length) return A.alloc(0);
var n;
if (void 0 === t) for (t = 0, n = 0; n < e.length; ++n) t += e[n].length;
var r = A.allocUnsafe(t),
i = 0;
for (n = 0; n < e.length; ++n) {
var o = e[n];
if (!x(o))
throw new TypeError('"list" argument must be an Array of Buffers');
o.copy(r, i), (i += o.length);
}
return r;
}),
(A.byteLength = C),
(A.prototype._isBuffer = !0),
(A.prototype.swap16 = function () {
var e = this.length;
if (e % 2 != 0)
throw new RangeError('Buffer size must be a multiple of 16-bits');
for (var t = 0; t < e; t += 2) B(this, t, t + 1);
return this;
}),
(A.prototype.swap32 = function () {
var e = this.length;
if (e % 4 != 0)
throw new RangeError('Buffer size must be a multiple of 32-bits');
for (var t = 0; t < e; t += 4) B(this, t, t + 3), B(this, t + 1, t + 2);
return this;
}),
(A.prototype.swap64 = function () {
var e = this.length;
if (e % 8 != 0)
throw new RangeError('Buffer size must be a multiple of 64-bits');
for (var t = 0; t < e; t += 8)
B(this, t, t + 7),
B(this, t + 1, t + 6),
B(this, t + 2, t + 5),
B(this, t + 3, t + 4);
return this;
}),
(A.prototype.toString = function () {
var e = 0 | this.length;
return 0 === e
? ''
: 0 === arguments.length
? F(this, 0, e)
: O.apply(this, arguments);
}),
(A.prototype.equals = function (e) {
if (!x(e)) throw new TypeError('Argument must be a Buffer');
return this === e || 0 === A.compare(this, e);
}),
(A.prototype.inspect = function () {
var e = '';
return (
this.length > 0 &&
((e = this.toString('hex', 0, 50).match(/.{2}/g).join(' ')),
this.length > 50 && (e += ' ... ')),
'<Buffer ' + e + '>'
);
}),
(A.prototype.compare = function (e, t, n, r, i) {
if (!x(e)) throw new TypeError('Argument must be a Buffer');
if (
(void 0 === t && (t = 0),
void 0 === n && (n = e ? e.length : 0),
void 0 === r && (r = 0),
void 0 === i && (i = this.length),
t < 0 || n > e.length || r < 0 || i > this.length)
)
throw new RangeError('out of range index');
if (r >= i && t >= n) return 0;
if (r >= i) return -1;
if (t >= n) return 1;
if (this === e) return 0;
for (
var o = (i >>>= 0) - (r >>>= 0),
s = (n >>>= 0) - (t >>>= 0),
a = Math.min(o, s),
u = this.slice(r, i),
f = e.slice(t, n),
h = 0;
h < a;
++h
)
if (u[h] !== f[h]) {
(o = u[h]), (s = f[h]);
break;
}
return o < s ? -1 : s < o ? 1 : 0;
}),
(A.prototype.includes = function (e, t, n) {
return -1 !== this.indexOf(e, t, n);
}),
(A.prototype.indexOf = function (e, t, n) {
return j(this, e, t, n, !0);
}),
(A.prototype.lastIndexOf = function (e, t, n) {
return j(this, e, t, n, !1);
}),
(A.prototype.write = function (e, t, n, r) {
if (void 0 === t) (r = 'utf8'), (n = this.length), (t = 0);
else if (void 0 === n && 'string' == typeof t)
(r = t), (n = this.length), (t = 0);
else {
if (!isFinite(t))
throw new Error(
'Buffer.write(string, encoding, offset[, length]) is no longer supported',
);
(t |= 0),
isFinite(n)
? ((n |= 0), void 0 === r && (r = 'utf8'))
: ((r = n), (n = void 0));
}
var i = this.length - t;
if (
((void 0 === n || n > i) && (n = i),
(e.length > 0 && (n < 0 || t < 0)) || t > this.length)
)
throw new RangeError('Attempt to write outside buffer bounds');
r || (r = 'utf8');
for (var o = !1; ; )
switch (r) {
case 'hex':
return D(this, e, t, n);
case 'utf8':
case 'utf-8':
return I(this, e, t, n);
case 'ascii':
return Y(this, e, t, n);
case 'latin1':
case 'binary':
return z(this, e, t, n);
case 'base64':
return N(this, e, t, n);
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return q(this, e, t, n);
default:
if (o) throw new TypeError('Unknown encoding: ' + r);
(r = ('' + r).toLowerCase()), (o = !0);
}
}),
(A.prototype.toJSON = function () {
return {
type: 'Buffer',
data: Array.prototype.slice.call(this._arr || this, 0),
};
});
var H = 4096;
function G(e, t, n) {
var r = '';
n = Math.min(e.length, n);
for (var i = t; i < n; ++i) r += String.fromCharCode(127 & e[i]);
return r;
}
function J(e, t, n) {
var r = '';
n = Math.min(e.length, n);
for (var i = t; i < n; ++i) r += String.fromCharCode(e[i]);
return r;
}
function $(e, t, n) {
var r = e.length;
(!t || t < 0) && (t = 0), (!n || n < 0 || n > r) && (n = r);
for (var i = '', o = t; o < n; ++o) i += ie(e[o]);
return i;
}
function V(e, t, n) {
for (var r = e.slice(t, n), i = '', o = 0; o < r.length; o += 2)
i += String.fromCharCode(r[o] + 256 * r[o + 1]);
return i;
}
function Z(e, t, n) {
if (e % 1 != 0 || e < 0) throw new RangeError('offset is not uint');
if (e + t > n)
throw new RangeError('Trying to access beyond buffer length');
}
function K(e, t, n, r, i, o) {
if (!x(e))
throw new TypeError('"buffer" argument must be a Buffer instance');
if (t > i || t < o)
throw new RangeError('"value" argument is out of bounds');
if (n + r > e.length) throw new RangeError('Index out of range');
}
function Q(e, t, n, r) {
t < 0 && (t = 65535 + t + 1);
for (var i = 0, o = Math.min(e.length - n, 2); i < o; ++i)
e[n + i] = (t & (255 << (8 * (r ? i : 1 - i)))) >>> (8 * (r ? i : 1 - i));
}
function X(e, t, n, r) {
t < 0 && (t = 4294967295 + t + 1);
for (var i = 0, o = Math.min(e.length - n, 4); i < o; ++i)
e[n + i] = (t >>> (8 * (r ? i : 3 - i))) & 255;
}
function ee(e, t, n, r, i, o) {
if (n + r > e.length) throw new RangeError('Index out of range');
if (n < 0) throw new RangeError('Index out of range');
}
function te(e, t, n, r, i) {
return i || ee(e, 0, n, 4), m(e, t, n, r, 23, 4), n + 4;
}
function ne(e, t, n, r, i) {
return i || ee(e, 0, n, 8), m(e, t, n, r, 52, 8), n + 8;
}
(A.prototype.slice = function (e, t) {
var n,
r = this.length;
if (
((e = ~~e) < 0 ? (e += r) < 0 && (e = 0) : e > r && (e = r),
(t = void 0 === t ? r : ~~t) < 0
? (t += r) < 0 && (t = 0)
: t > r && (t = r),
t < e && (t = e),
A.TYPED_ARRAY_SUPPORT)
)
(n = this.subarray(e, t)).__proto__ = A.prototype;
else {
var i = t - e;
n = new A(i, void 0);
for (var o = 0; o < i; ++o) n[o] = this[o + e];
}
return n;
}),
(A.prototype.readUIntLE = function (e, t, n) {
(e |= 0), (t |= 0), n || Z(e, t, this.length);
for (var r = this[e], i = 1, o = 0; ++o < t && (i *= 256); )
r += this[e + o] * i;
return r;
}),
(A.prototype.readUIntBE = function (e, t, n) {
(e |= 0), (t |= 0), n || Z(e, t, this.length);
for (var r = this[e + --t], i = 1; t > 0 && (i *= 256); )
r += this[e + --t] * i;
return r;
}),
(A.prototype.readUInt8 = function (e, t) {
return t || Z(e, 1, this.length), this[e];
}),
(A.prototype.readUInt16LE = function (e, t) {
return t || Z(e, 2, this.length), this[e] | (this[e + 1] << 8);
}),
(A.prototype.readUInt16BE = function (e, t) {
return t || Z(e, 2, this.length), (this[e] << 8) | this[e + 1];
}),
(A.prototype.readUInt32LE = function (e, t) {
return (
t || Z(e, 4, this.length),
(this[e] | (this[e + 1] << 8) | (this[e + 2] << 16)) +
16777216 * this[e + 3]
);
}),
(A.prototype.readUInt32BE = function (e, t) {
return (
t || Z(e, 4, this.length),
16777216 * this[e] +
((this[e + 1] << 16) | (this[e + 2] << 8) | this[e + 3])
);
}),
(A.prototype.readIntLE = function (e, t, n) {
(e |= 0), (t |= 0), n || Z(e, t, this.length);
for (var r = this[e], i = 1, o = 0; ++o < t && (i *= 256); )
r += this[e + o] * i;
return r >= (i *= 128) && (r -= Math.pow(2, 8 * t)), r;
}),
(A.prototype.readIntBE = function (e, t, n) {
(e |= 0), (t |= 0), n || Z(e, t, this.length);
for (var r = t, i = 1, o = this[e + --r]; r > 0 && (i *= 256); )
o += this[e + --r] * i;
return o >= (i *= 128) && (o -= Math.pow(2, 8 * t)), o;
}),
(A.prototype.readInt8 = function (e, t) {
return (
t || Z(e, 1, this.length),
128 & this[e] ? -1 * (255 - this[e] + 1) : this[e]
);
}),
(A.prototype.readInt16LE = function (e, t) {
t || Z(e, 2, this.length);
var n = this[e] | (this[e + 1] << 8);
return 32768 & n ? 4294901760 | n : n;
}),
(A.prototype.readInt16BE = function (e, t) {
t || Z(e, 2, this.length);
var n = this[e + 1] | (this[e] << 8);
return 32768 & n ? 4294901760 | n : n;
}),
(A.prototype.readInt32LE = function (e, t) {
return (
t || Z(e, 4, this.length),
this[e] | (this[e + 1] << 8) | (this[e + 2] << 16) | (this[e + 3] << 24)
);
}),
(A.prototype.readInt32BE = function (e, t) {
return (
t || Z(e, 4, this.length),
(this[e] << 24) | (this[e + 1] << 16) | (this[e + 2] << 8) | this[e + 3]
);
}),
(A.prototype.readFloatLE = function (e, t) {
return t || Z(e, 4, this.length), b(this, e, !0, 23, 4);
}),
(A.prototype.readFloatBE = function (e, t) {
return t || Z(e, 4, this.length), b(this, e, !1, 23, 4);
}),
(A.prototype.readDoubleLE = function (e, t) {
return t || Z(e, 8, this.length), b(this, e, !0, 52, 8);
}),
(A.prototype.readDoubleBE = function (e, t) {
return t || Z(e, 8, this.length), b(this, e, !1, 52, 8);
}),
(A.prototype.writeUIntLE = function (e, t, n, r) {
((e = +e), (t |= 0), (n |= 0), r) ||
K(this, e, t, n, Math.pow(2, 8 * n) - 1, 0);
var i = 1,
o = 0;
for (this[t] = 255 & e; ++o < n && (i *= 256); )
this[t + o] = (e / i) & 255;
return t + n;
}),
(A.prototype.writeUIntBE = function (e, t, n, r) {
((e = +e), (t |= 0), (n |= 0), r) ||
K(this, e, t, n, Math.pow(2, 8 * n) - 1, 0);
var i = n - 1,
o = 1;
for (this[t + i] = 255 & e; --i >= 0 && (o *= 256); )
this[t + i] = (e / o) & 255;
return t + n;
}),
(A.prototype.writeUInt8 = function (e, t, n) {
return (
(e = +e),
(t |= 0),
n || K(this, e, t, 1, 255, 0),
A.TYPED_ARRAY_SUPPORT || (e = Math.floor(e)),
(this[t] = 255 & e),
t + 1
);
}),
(A.prototype.writeUInt16LE = function (e, t, n) {
return (
(e = +e),
(t |= 0),
n || K(this, e, t, 2, 65535, 0),
A.TYPED_ARRAY_SUPPORT
? ((this[t] = 255 & e), (this[t + 1] = e >>> 8))
: Q(this, e, t, !0),
t + 2
);
}),
(A.prototype.writeUInt16BE = function (e, t, n) {
return (
(e = +e),
(t |= 0),
n || K(this, e, t, 2, 65535, 0),
A.TYPED_ARRAY_SUPPORT
? ((this[t] = e >>> 8), (this[t + 1] = 255 & e))
: Q(this, e, t, !1),
t + 2
);
}),
(A.prototype.writeUInt32LE = function (e, t, n) {
return (
(e = +e),
(t |= 0),
n || K(this, e, t, 4, 4294967295, 0),
A.TYPED_ARRAY_SUPPORT
? ((this[t + 3] = e >>> 24),
(this[t + 2] = e >>> 16),
(this[t + 1] = e >>> 8),
(this[t] = 255 & e))
: X(this, e, t, !0),
t + 4
);
}),
(A.prototype.writeUInt32BE = function (e, t, n) {
return (
(e = +e),
(t |= 0),
n || K(this, e, t, 4, 4294967295, 0),
A.TYPED_ARRAY_SUPPORT
? ((this[t] = e >>> 24),
(this[t + 1] = e >>> 16),
(this[t + 2] = e >>> 8),
(this[t + 3] = 255 & e))
: X(this, e, t, !1),
t + 4
);
}),
(A.prototype.writeIntLE = function (e, t, n, r) {
if (((e = +e), (t |= 0), !r)) {
var i = Math.pow(2, 8 * n - 1);
K(this, e, t, n, i - 1, -i);
}
var o = 0,
s = 1,
a = 0;
for (this[t] = 255 & e; ++o < n && (s *= 256); )
e < 0 && 0 === a && 0 !== this[t + o - 1] && (a = 1),
(this[t + o] = (((e / s) >> 0) - a) & 255);
return t + n;
}),
(A.prototype.writeIntBE = function (e, t, n, r) {
if (((e = +e), (t |= 0), !r)) {
var i = Math.pow(2, 8 * n - 1);
K(this, e, t, n, i - 1, -i);
}
var o = n - 1,
s = 1,
a = 0;
for (this[t + o] = 255 & e; --o >= 0 && (s *= 256); )
e < 0 && 0 === a && 0 !== this[t + o + 1] && (a = 1),
(this[t + o] = (((e / s) >> 0) - a) & 255);
return t + n;
}),
(A.prototype.writeInt8 = function (e, t, n) {
return (
(e = +e),
(t |= 0),
n || K(this, e, t, 1, 127, -128),
A.TYPED_ARRAY_SUPPORT || (e = Math.floor(e)),
e < 0 && (e = 255 + e + 1),
(this[t] = 255 & e),
t + 1
);
}),
(A.prototype.writeInt16LE = function (e, t, n) {
return (
(e = +e),
(t |= 0),
n || K(this, e, t, 2, 32767, -32768),
A.TYPED_ARRAY_SUPPORT
? ((this[t] = 255 & e), (this[t + 1] = e >>> 8))
: Q(this, e, t, !0),
t + 2
);
}),
(A.prototype.writeInt16BE = function (e, t, n) {
return (
(e = +e),
(t |= 0),
n || K(this, e, t, 2, 32767, -32768),
A.TYPED_ARRAY_SUPPORT
? ((this[t] = e >>> 8), (this[t + 1] = 255 & e))
: Q(this, e, t, !1),
t + 2
);
}),
(A.prototype.writeInt32LE = function (e, t, n) {
return (
(e = +e),
(t |= 0),
n || K(this, e, t, 4, 2147483647, -2147483648),
A.TYPED_ARRAY_SUPPORT
? ((this[t] = 255 & e),
(this[t + 1] = e >>> 8),
(this[t + 2] = e >>> 16),
(this[t + 3] = e >>> 24))
: X(this, e, t, !0),
t + 4
);
}),
(A.prototype.writeInt32BE = function (e, t, n) {
return (
(e = +e),
(t |= 0),
n || K(this, e, t, 4, 2147483647, -2147483648),
e < 0 && (e = 4294967295 + e + 1),
A.TYPED_ARRAY_SUPPORT
? ((this[t] = e >>> 24),
(this[t + 1] = e >>> 16),
(this[t + 2] = e >>> 8),
(this[t + 3] = 255 & e))
: X(this, e, t, !1),
t + 4
);
}),
(A.prototype.writeFloatLE = function (e, t, n) {
return te(this, e, t, !0, n);
}),
(A.prototype.writeFloatBE = function (e, t, n) {
return te(this, e, t, !1, n);
}),
(A.prototype.writeDoubleLE = function (e, t, n) {
return ne(this, e, t, !0, n);
}),
(A.prototype.writeDoubleBE = function (e, t, n) {
return ne(this, e, t, !1, n);
}),
(A.prototype.copy = function (e, t, n, r) {
if (
(n || (n = 0),
r || 0 === r || (r = this.length),
t >= e.length && (t = e.length),
t || (t = 0),
r > 0 && r < n && (r = n),
r === n)
)
return 0;
if (0 === e.length || 0 === this.length) return 0;
if (t < 0) throw new RangeError('targetStart out of bounds');
if (n < 0 || n >= this.length)
throw new RangeError('sourceStart out of bounds');
if (r < 0) throw new RangeError('sourceEnd out of bounds');
r > this.length && (r = this.length),
e.length - t < r - n && (r = e.length - t + n);
var i,
o = r - n;
if (this === e && n < t && t < r)
for (i = o - 1; i >= 0; --i) e[i + t] = this[i + n];
else if (o < 1e3 || !A.TYPED_ARRAY_SUPPORT)
for (i = 0; i < o; ++i) e[i + t] = this[i + n];
else Uint8Array.prototype.set.call(e, this.subarray(n, n + o), t);
return o;
}),
(A.prototype.fill = function (e, t, n, r) {
if ('string' == typeof e) {
if (
('string' == typeof t
? ((r = t), (t = 0), (n = this.length))
: 'string' == typeof n && ((r = n), (n = this.length)),
1 === e.length)
) {
var i = e.charCodeAt(0);
i < 256 && (e = i);
}
if (void 0 !== r && 'string' != typeof r)
throw new TypeError('encoding must be a string');
if ('string' == typeof r && !A.isEncoding(r))
throw new TypeError('Unknown encoding: ' + r);
} else 'number' == typeof e && (e &= 255);
if (t < 0 || this.length < t || this.length < n)
throw new RangeError('Out of range index');
if (n <= t) return this;
var o;
if (
((t >>>= 0),
(n = void 0 === n ? this.length : n >>> 0),
e || (e = 0),
'number' == typeof e)
)
for (o = t; o < n; ++o) this[o] = e;
else {
var s = x(e) ? e : oe(new A(e, r).toString()),
a = s.length;
for (o = 0; o < n - t; ++o) this[o + t] = s[o % a];
}
return this;
});
var re = /[^+\/0-9A-Za-z-_]/g;
function ie(e) {
return e < 16 ? '0' + e.toString(16) : e.toString(16);
}
function oe(e, t) {
var n;
t = t || 1 / 0;
for (var r = e.length, i = null, o = [], s = 0; s < r; ++s) {
if ((n = e.charCodeAt(s)) > 55295 && n < 57344) {
if (!i) {
if (n > 56319) {
(t -= 3) > -1 && o.push(239, 191, 189);
continue;
}
if (s + 1 === r) {
(t -= 3) > -1 && o.push(239, 191, 189);
continue;
}
i = n;
continue;
}
if (n < 56320) {
(t -= 3) > -1 && o.push(239, 191, 189), (i = n);
continue;
}
n = 65536 + (((i - 55296) << 10) | (n - 56320));
} else i && (t -= 3) > -1 && o.push(239, 191, 189);
if (((i = null), n < 128)) {
if ((t -= 1) < 0) break;
o.push(n);
} else if (n < 2048) {
if ((t -= 2) < 0) break;
o.push((n >> 6) | 192, (63 & n) | 128);
} else if (n < 65536) {
if ((t -= 3) < 0) break;
o.push((n >> 12) | 224, ((n >> 6) & 63) | 128, (63 & n) | 128);
} else {
if (!(n < 1114112)) throw new Error('Invalid code point');
if ((t -= 4) < 0) break;
o.push(
(n >> 18) | 240,
((n >> 12) & 63) | 128,
((n >> 6) & 63) | 128,
(63 & n) | 128,
);
}
}
return o;
}
function se(e) {
return (function (e) {
var t, n, r, i, o, s;
g || v();
var a = e.length;
if (a % 4 > 0)
throw new Error('Invalid string. Length must be a multiple of 4');
(o = '=' === e[a - 2] ? 2 : '=' === e[a - 1] ? 1 : 0),
(s = new p((3 * a) / 4 - o)),
(r = o > 0 ? a - 4 : a);
var u = 0;
for (t = 0, n = 0; t < r; t += 4, n += 3)
(i =
(d[e.charCodeAt(t)] << 18) |
(d[e.charCodeAt(t + 1)] << 12) |
(d[e.charCodeAt(t + 2)] << 6) |
d[e.charCodeAt(t + 3)]),
(s[u++] = (i >> 16) & 255),
(s[u++] = (i >> 8) & 255),
(s[u++] = 255 & i);
return (
2 === o
? ((i = (d[e.charCodeAt(t)] << 2) | (d[e.charCodeAt(t + 1)] >> 4)),
(s[u++] = 255 & i))
: 1 === o &&
((i =
(d[e.charCodeAt(t)] << 10) |
(d[e.charCodeAt(t + 1)] << 4) |
(d[e.charCodeAt(t + 2)] >> 2)),
(s[u++] = (i >> 8) & 255),
(s[u++] = 255 & i)),
s
);
})(
(function (