13553 lines
514 KiB
JavaScript
13553 lines
514 KiB
JavaScript
function T499845 (t) {
|
|
var e, r, n, o = t.exports = {};
|
|
function i() {
|
|
throw Error("setTimeout has not been defined")
|
|
}
|
|
function a() {
|
|
throw Error("clearTimeout has not been defined")
|
|
}
|
|
function s(t) {
|
|
if (e === setTimeout)
|
|
return setTimeout(t, 0);
|
|
if ((e === i || !e) && setTimeout)
|
|
return e = setTimeout,
|
|
setTimeout(t, 0);
|
|
try {
|
|
return e(t, 0)
|
|
} catch (r) {
|
|
try {
|
|
return e.call(null, t, 0)
|
|
} catch (r) {
|
|
return e.call(this, t, 0)
|
|
}
|
|
}
|
|
}
|
|
!function() {
|
|
try {
|
|
e = "function" == typeof setTimeout ? setTimeout : i
|
|
} catch (t) {
|
|
e = i
|
|
}
|
|
try {
|
|
r = "function" == typeof clearTimeout ? clearTimeout : a
|
|
} catch (t) {
|
|
r = a
|
|
}
|
|
}();
|
|
var u = []
|
|
, c = !1
|
|
, f = -1;
|
|
function l() {
|
|
if (!!c && !!n)
|
|
c = !1,
|
|
n.length ? u = n.concat(u) : f = -1,
|
|
u.length && h()
|
|
}
|
|
function h() {
|
|
if (!c) {
|
|
var t = s(l);
|
|
c = !0;
|
|
for (var e = u.length; e; ) {
|
|
for (n = u,
|
|
u = []; ++f < e; )
|
|
n && n[f].run();
|
|
f = -1,
|
|
e = u.length
|
|
}
|
|
n = null,
|
|
c = !1,
|
|
!function(t) {
|
|
if (r === clearTimeout)
|
|
return clearTimeout(t);
|
|
if ((r === a || !r) && clearTimeout)
|
|
return r = clearTimeout,
|
|
clearTimeout(t);
|
|
try {
|
|
r(t)
|
|
} catch (e) {
|
|
try {
|
|
return r.call(null, t)
|
|
} catch (e) {
|
|
return r.call(this, t)
|
|
}
|
|
}
|
|
}(t)
|
|
}
|
|
}
|
|
function p(t, e) {
|
|
this.fun = t,
|
|
this.array = e
|
|
}
|
|
function d() {}
|
|
o.nextTick = function(t) {
|
|
var e = Array(arguments.length - 1);
|
|
if (arguments.length > 1)
|
|
for (var r = 1; r < arguments.length; r++)
|
|
e[r - 1] = arguments[r];
|
|
u.push(new p(t,e)),
|
|
1 === u.length && !c && s(h)
|
|
}
|
|
,
|
|
p.prototype.run = function() {
|
|
this.fun.apply(null, this.array)
|
|
}
|
|
,
|
|
o.title = "browser",
|
|
o.browser = !0,
|
|
o.env = {},
|
|
o.argv = [],
|
|
o.version = "",
|
|
o.versions = {},
|
|
o.on = d,
|
|
o.addListener = d,
|
|
o.once = d,
|
|
o.off = d,
|
|
o.removeListener = d,
|
|
o.removeAllListeners = d,
|
|
o.emit = d,
|
|
o.prependListener = d,
|
|
o.prependOnceListener = d,
|
|
o.listeners = function(t) {
|
|
return []
|
|
}
|
|
,
|
|
o.binding = function(t) {
|
|
throw Error("process.binding is not supported")
|
|
}
|
|
,
|
|
o.cwd = function() {
|
|
return "/"
|
|
}
|
|
,
|
|
o.chdir = function(t) {
|
|
throw Error("process.chdir is not supported")
|
|
}
|
|
,
|
|
o.umask = function() {
|
|
return 0
|
|
}
|
|
}
|
|
function T984826(e, t, i) {
|
|
!function(e, t) {
|
|
"use strict";
|
|
function n(e, t) {
|
|
if (!e)
|
|
throw Error(t || "Assertion failed")
|
|
}
|
|
function r(e, t) {
|
|
e.super_ = t;
|
|
var i = function() {};
|
|
i.prototype = t.prototype,
|
|
e.prototype = new i,
|
|
e.prototype.constructor = e
|
|
}
|
|
function a(e, t, i) {
|
|
if (a.isBN(e))
|
|
return e;
|
|
this.negative = 0,
|
|
this.words = null,
|
|
this.length = 0,
|
|
this.red = null,
|
|
null !== e && (("le" === t || "be" === t) && (i = t,
|
|
t = 10),
|
|
this._init(e || 0, t || 10, i || "be"))
|
|
}
|
|
"object" == typeof e ? e.exports = a : t.BN = a,
|
|
a.BN = a,
|
|
a.wordSize = 26;
|
|
try {
|
|
c = "undefined" != typeof window && void 0 !== window.Buffer ? window.Buffer : i(678244).Buffer
|
|
} catch (e) {}
|
|
function o(e, t) {
|
|
var i = e.charCodeAt(t);
|
|
return i >= 65 && i <= 70 ? i - 55 : i >= 97 && i <= 102 ? i - 87 : i - 48 & 15
|
|
}
|
|
function s(e, t, i) {
|
|
var n = o(e, i);
|
|
return i - 1 >= t && (n |= o(e, i - 1) << 4),
|
|
n
|
|
}
|
|
function l(e, t, i, n) {
|
|
for (var r = 0, a = Math.min(e.length, i), o = t; o < a; o++) {
|
|
var s = e.charCodeAt(o) - 48;
|
|
r *= n,
|
|
s >= 49 ? r += s - 49 + 10 : s >= 17 ? r += s - 17 + 10 : r += s
|
|
}
|
|
return r
|
|
}
|
|
a.isBN = function(e) {
|
|
return e instanceof a || null !== e && "object" == typeof e && e.constructor.wordSize === a.wordSize && Array.isArray(e.words)
|
|
}
|
|
,
|
|
a.max = function(e, t) {
|
|
return e.cmp(t) > 0 ? e : t
|
|
}
|
|
,
|
|
a.min = function(e, t) {
|
|
return 0 > e.cmp(t) ? e : t
|
|
}
|
|
,
|
|
a.prototype._init = function(e, t, i) {
|
|
if ("number" == typeof e)
|
|
return this._initNumber(e, t, i);
|
|
if ("object" == typeof e)
|
|
return this._initArray(e, t, i);
|
|
"hex" === t && (t = 16),
|
|
n(t === (0 | t) && t >= 2 && t <= 36),
|
|
e = e.toString().replace(/\s+/g, "");
|
|
var r = 0;
|
|
"-" === e[0] && (r++,
|
|
this.negative = 1),
|
|
r < e.length && (16 === t ? this._parseHex(e, r, i) : (this._parseBase(e, t, r),
|
|
"le" === i && this._initArray(this.toArray(), t, i)))
|
|
}
|
|
,
|
|
a.prototype._initNumber = function(e, t, i) {
|
|
e < 0 && (this.negative = 1,
|
|
e = -e),
|
|
e < 0x4000000 ? (this.words = [0x3ffffff & e],
|
|
this.length = 1) : e < 0x10000000000000 ? (this.words = [0x3ffffff & e, e / 0x4000000 & 0x3ffffff],
|
|
this.length = 2) : (n(e < 0x20000000000000),
|
|
this.words = [0x3ffffff & e, e / 0x4000000 & 0x3ffffff, 1],
|
|
this.length = 3),
|
|
"le" === i && this._initArray(this.toArray(), t, i)
|
|
}
|
|
,
|
|
a.prototype._initArray = function(e, t, i) {
|
|
if (n("number" == typeof e.length),
|
|
e.length <= 0)
|
|
return this.words = [0],
|
|
this.length = 1,
|
|
this;
|
|
this.length = Math.ceil(e.length / 3),
|
|
this.words = Array(this.length);
|
|
for (var r, a, o = 0; o < this.length; o++)
|
|
this.words[o] = 0;
|
|
var s = 0;
|
|
if ("be" === i)
|
|
for (o = e.length - 1,
|
|
r = 0; o >= 0; o -= 3)
|
|
a = e[o] | e[o - 1] << 8 | e[o - 2] << 16,
|
|
this.words[r] |= a << s & 0x3ffffff,
|
|
this.words[r + 1] = a >>> 26 - s & 0x3ffffff,
|
|
(s += 24) >= 26 && (s -= 26,
|
|
r++);
|
|
else if ("le" === i)
|
|
for (o = 0,
|
|
r = 0; o < e.length; o += 3)
|
|
a = e[o] | e[o + 1] << 8 | e[o + 2] << 16,
|
|
this.words[r] |= a << s & 0x3ffffff,
|
|
this.words[r + 1] = a >>> 26 - s & 0x3ffffff,
|
|
(s += 24) >= 26 && (s -= 26,
|
|
r++);
|
|
return this.strip()
|
|
}
|
|
,
|
|
a.prototype._parseHex = function(e, t, i) {
|
|
this.length = Math.ceil((e.length - t) / 6),
|
|
this.words = Array(this.length);
|
|
for (var n, r = 0; r < this.length; r++)
|
|
this.words[r] = 0;
|
|
var a = 0
|
|
, o = 0;
|
|
if ("be" === i)
|
|
for (r = e.length - 1; r >= t; r -= 2)
|
|
n = s(e, t, r) << a,
|
|
this.words[o] |= 0x3ffffff & n,
|
|
a >= 18 ? (a -= 18,
|
|
o += 1,
|
|
this.words[o] |= n >>> 26) : a += 8;
|
|
else
|
|
for (r = (e.length - t) % 2 == 0 ? t + 1 : t; r < e.length; r += 2)
|
|
n = s(e, t, r) << a,
|
|
this.words[o] |= 0x3ffffff & n,
|
|
a >= 18 ? (a -= 18,
|
|
o += 1,
|
|
this.words[o] |= n >>> 26) : a += 8;
|
|
this.strip()
|
|
}
|
|
,
|
|
a.prototype._parseBase = function(e, t, i) {
|
|
this.words = [0],
|
|
this.length = 1;
|
|
for (var n = 0, r = 1; r <= 0x3ffffff; r *= t)
|
|
n++;
|
|
n--,
|
|
r = r / t | 0;
|
|
for (var a = e.length - i, o = a % n, s = Math.min(a, a - o) + i, c = 0, d = i; d < s; d += n)
|
|
c = l(e, d, d + n, t),
|
|
this.imuln(r),
|
|
this.words[0] + c < 0x4000000 ? this.words[0] += c : this._iaddn(c);
|
|
if (0 !== o) {
|
|
var u = 1;
|
|
for (c = l(e, d, e.length, t),
|
|
d = 0; d < o; d++)
|
|
u *= t;
|
|
this.imuln(u),
|
|
this.words[0] + c < 0x4000000 ? this.words[0] += c : this._iaddn(c)
|
|
}
|
|
this.strip()
|
|
}
|
|
,
|
|
a.prototype.copy = function(e) {
|
|
e.words = Array(this.length);
|
|
for (var t = 0; t < this.length; t++)
|
|
e.words[t] = this.words[t];
|
|
e.length = this.length,
|
|
e.negative = this.negative,
|
|
e.red = this.red
|
|
}
|
|
,
|
|
a.prototype.clone = function() {
|
|
var e = new a(null);
|
|
return this.copy(e),
|
|
e
|
|
}
|
|
,
|
|
a.prototype._expand = function(e) {
|
|
for (; this.length < e; )
|
|
this.words[this.length++] = 0;
|
|
return this
|
|
}
|
|
,
|
|
a.prototype.strip = function() {
|
|
for (; this.length > 1 && 0 === this.words[this.length - 1]; )
|
|
this.length--;
|
|
return this._normSign()
|
|
}
|
|
,
|
|
a.prototype._normSign = function() {
|
|
return 1 === this.length && 0 === this.words[0] && (this.negative = 0),
|
|
this
|
|
}
|
|
,
|
|
a.prototype.inspect = function() {
|
|
return (this.red ? "<BN-R: " : "<BN: ") + this.toString(16) + ">"
|
|
}
|
|
;
|
|
var c, d = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"], u = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], f = [0, 0, 0x2000000, 0x290d741, 0x1000000, 0x2e90edd, 0x39aa400, 0x267bf47, 0x1000000, 0x290d741, 1e7, 0x12959c3, 0x222c000, 0x3bd7765, 7529536, 0xadcea1, 0x1000000, 0x1704f61, 0x206fc40, 0x2cddcf9, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 0xb54ba0, 0xdaf26b, 0x1069c00, 0x138f9ad, 243e5, 0x1b4d89f, 0x2000000, 0x25528a1, 0x2b54a20, 0x3216b93, 0x39aa400];
|
|
function h(e) {
|
|
for (var t = Array(e.bitLength()), i = 0; i < t.length; i++) {
|
|
var n = i / 26 | 0
|
|
, r = i % 26;
|
|
t[i] = (e.words[n] & 1 << r) >>> r
|
|
}
|
|
return t
|
|
}
|
|
function p(e, t, i) {
|
|
i.negative = t.negative ^ e.negative;
|
|
var n = e.length + t.length | 0;
|
|
i.length = n,
|
|
n = n - 1 | 0;
|
|
var r = 0 | e.words[0]
|
|
, a = 0 | t.words[0]
|
|
, o = r * a
|
|
, s = 0x3ffffff & o
|
|
, l = o / 0x4000000 | 0;
|
|
i.words[0] = s;
|
|
for (var c = 1; c < n; c++) {
|
|
for (var d = l >>> 26, u = 0x3ffffff & l, f = Math.min(c, t.length - 1), h = Math.max(0, c - e.length + 1); h <= f; h++) {
|
|
var p = c - h | 0;
|
|
r = 0 | e.words[p],
|
|
d += (o = r * (a = 0 | t.words[h]) + u) / 0x4000000 | 0,
|
|
u = 0x3ffffff & o
|
|
}
|
|
i.words[c] = 0 | u,
|
|
l = 0 | d
|
|
}
|
|
return 0 !== l ? i.words[c] = 0 | l : i.length--,
|
|
i.strip()
|
|
}
|
|
a.prototype.toString = function(e, t) {
|
|
if (t = 0 | t || 1,
|
|
16 === (e = e || 10) || "hex" === e) {
|
|
i = "";
|
|
for (var i, r = 0, a = 0, o = 0; o < this.length; o++) {
|
|
var s = this.words[o]
|
|
, l = ((s << r | a) & 0xffffff).toString(16);
|
|
i = 0 != (a = s >>> 24 - r & 0xffffff) || o !== this.length - 1 ? d[6 - l.length] + l + i : l + i,
|
|
(r += 2) >= 26 && (r -= 26,
|
|
o--)
|
|
}
|
|
for (0 !== a && (i = a.toString(16) + i); i.length % t != 0; )
|
|
i = "0" + i;
|
|
return 0 !== this.negative && (i = "-" + i),
|
|
i
|
|
}
|
|
if (e === (0 | e) && e >= 2 && e <= 36) {
|
|
var c = u[e]
|
|
, h = f[e];
|
|
i = "";
|
|
var p = this.clone();
|
|
for (p.negative = 0; !p.isZero(); ) {
|
|
var v = p.modn(h).toString(e);
|
|
i = (p = p.idivn(h)).isZero() ? v + i : d[c - v.length] + v + i
|
|
}
|
|
for (this.isZero() && (i = "0" + i); i.length % t != 0; )
|
|
i = "0" + i;
|
|
return 0 !== this.negative && (i = "-" + i),
|
|
i
|
|
}
|
|
n(!1, "Base should be between 2 and 36")
|
|
}
|
|
,
|
|
a.prototype.toNumber = function() {
|
|
var e = this.words[0];
|
|
return 2 === this.length ? e += 0x4000000 * this.words[1] : 3 === this.length && 1 === this.words[2] ? e += 0x10000000000000 + 0x4000000 * this.words[1] : this.length > 2 && n(!1, "Number can only safely store up to 53 bits"),
|
|
0 !== this.negative ? -e : e
|
|
}
|
|
,
|
|
a.prototype.toJSON = function() {
|
|
return this.toString(16)
|
|
}
|
|
,
|
|
a.prototype.toBuffer = function(e, t) {
|
|
return n(void 0 !== c),
|
|
this.toArrayLike(c, e, t)
|
|
}
|
|
,
|
|
a.prototype.toArray = function(e, t) {
|
|
return this.toArrayLike(Array, e, t)
|
|
}
|
|
,
|
|
a.prototype.toArrayLike = function(e, t, i) {
|
|
var r, a, o = this.byteLength(), s = i || Math.max(1, o);
|
|
n(o <= s, "byte array longer than desired length"),
|
|
n(s > 0, "Requested array length <= 0"),
|
|
this.strip();
|
|
var l = "le" === t
|
|
, c = new e(s)
|
|
, d = this.clone();
|
|
if (l) {
|
|
for (a = 0; !d.isZero(); a++)
|
|
r = d.andln(255),
|
|
d.iushrn(8),
|
|
c[a] = r;
|
|
for (; a < s; a++)
|
|
c[a] = 0
|
|
} else {
|
|
for (a = 0; a < s - o; a++)
|
|
c[a] = 0;
|
|
for (a = 0; !d.isZero(); a++)
|
|
r = d.andln(255),
|
|
d.iushrn(8),
|
|
c[s - a - 1] = r
|
|
}
|
|
return c
|
|
}
|
|
,
|
|
Math.clz32 ? a.prototype._countBits = function(e) {
|
|
return 32 - Math.clz32(e)
|
|
}
|
|
: a.prototype._countBits = function(e) {
|
|
var t = e
|
|
, i = 0;
|
|
return t >= 4096 && (i += 13,
|
|
t >>>= 13),
|
|
t >= 64 && (i += 7,
|
|
t >>>= 7),
|
|
t >= 8 && (i += 4,
|
|
t >>>= 4),
|
|
t >= 2 && (i += 2,
|
|
t >>>= 2),
|
|
i + t
|
|
}
|
|
,
|
|
a.prototype._zeroBits = function(e) {
|
|
if (0 === e)
|
|
return 26;
|
|
var t = e
|
|
, i = 0;
|
|
return (8191 & t) == 0 && (i += 13,
|
|
t >>>= 13),
|
|
(127 & t) == 0 && (i += 7,
|
|
t >>>= 7),
|
|
(15 & t) == 0 && (i += 4,
|
|
t >>>= 4),
|
|
(3 & t) == 0 && (i += 2,
|
|
t >>>= 2),
|
|
(1 & t) == 0 && i++,
|
|
i
|
|
}
|
|
,
|
|
a.prototype.bitLength = function() {
|
|
var e = this.words[this.length - 1]
|
|
, t = this._countBits(e);
|
|
return (this.length - 1) * 26 + t
|
|
}
|
|
,
|
|
a.prototype.zeroBits = function() {
|
|
if (this.isZero())
|
|
return 0;
|
|
for (var e = 0, t = 0; t < this.length; t++) {
|
|
var i = this._zeroBits(this.words[t]);
|
|
if (e += i,
|
|
26 !== i)
|
|
break
|
|
}
|
|
return e
|
|
}
|
|
,
|
|
a.prototype.byteLength = function() {
|
|
return Math.ceil(this.bitLength() / 8)
|
|
}
|
|
,
|
|
a.prototype.toTwos = function(e) {
|
|
return 0 !== this.negative ? this.abs().inotn(e).iaddn(1) : this.clone()
|
|
}
|
|
,
|
|
a.prototype.fromTwos = function(e) {
|
|
return this.testn(e - 1) ? this.notn(e).iaddn(1).ineg() : this.clone()
|
|
}
|
|
,
|
|
a.prototype.isNeg = function() {
|
|
return 0 !== this.negative
|
|
}
|
|
,
|
|
a.prototype.neg = function() {
|
|
return this.clone().ineg()
|
|
}
|
|
,
|
|
a.prototype.ineg = function() {
|
|
return !this.isZero() && (this.negative ^= 1),
|
|
this
|
|
}
|
|
,
|
|
a.prototype.iuor = function(e) {
|
|
for (; this.length < e.length; )
|
|
this.words[this.length++] = 0;
|
|
for (var t = 0; t < e.length; t++)
|
|
this.words[t] = this.words[t] | e.words[t];
|
|
return this.strip()
|
|
}
|
|
,
|
|
a.prototype.ior = function(e) {
|
|
return n((this.negative | e.negative) == 0),
|
|
this.iuor(e)
|
|
}
|
|
,
|
|
a.prototype.or = function(e) {
|
|
return this.length > e.length ? this.clone().ior(e) : e.clone().ior(this)
|
|
}
|
|
,
|
|
a.prototype.uor = function(e) {
|
|
return this.length > e.length ? this.clone().iuor(e) : e.clone().iuor(this)
|
|
}
|
|
,
|
|
a.prototype.iuand = function(e) {
|
|
var t;
|
|
t = this.length > e.length ? e : this;
|
|
for (var i = 0; i < t.length; i++)
|
|
this.words[i] = this.words[i] & e.words[i];
|
|
return this.length = t.length,
|
|
this.strip()
|
|
}
|
|
,
|
|
a.prototype.iand = function(e) {
|
|
return n((this.negative | e.negative) == 0),
|
|
this.iuand(e)
|
|
}
|
|
,
|
|
a.prototype.and = function(e) {
|
|
return this.length > e.length ? this.clone().iand(e) : e.clone().iand(this)
|
|
}
|
|
,
|
|
a.prototype.uand = function(e) {
|
|
return this.length > e.length ? this.clone().iuand(e) : e.clone().iuand(this)
|
|
}
|
|
,
|
|
a.prototype.iuxor = function(e) {
|
|
this.length > e.length ? (t = this,
|
|
i = e) : (t = e,
|
|
i = this);
|
|
for (var t, i, n = 0; n < i.length; n++)
|
|
this.words[n] = t.words[n] ^ i.words[n];
|
|
if (this !== t)
|
|
for (; n < t.length; n++)
|
|
this.words[n] = t.words[n];
|
|
return this.length = t.length,
|
|
this.strip()
|
|
}
|
|
,
|
|
a.prototype.ixor = function(e) {
|
|
return n((this.negative | e.negative) == 0),
|
|
this.iuxor(e)
|
|
}
|
|
,
|
|
a.prototype.xor = function(e) {
|
|
return this.length > e.length ? this.clone().ixor(e) : e.clone().ixor(this)
|
|
}
|
|
,
|
|
a.prototype.uxor = function(e) {
|
|
return this.length > e.length ? this.clone().iuxor(e) : e.clone().iuxor(this)
|
|
}
|
|
,
|
|
a.prototype.inotn = function(e) {
|
|
n("number" == typeof e && e >= 0);
|
|
var t = 0 | Math.ceil(e / 26)
|
|
, i = e % 26;
|
|
this._expand(t),
|
|
i > 0 && t--;
|
|
for (var r = 0; r < t; r++)
|
|
this.words[r] = 0x3ffffff & ~this.words[r];
|
|
return i > 0 && (this.words[r] = ~this.words[r] & 0x3ffffff >> 26 - i),
|
|
this.strip()
|
|
}
|
|
,
|
|
a.prototype.notn = function(e) {
|
|
return this.clone().inotn(e)
|
|
}
|
|
,
|
|
a.prototype.setn = function(e, t) {
|
|
n("number" == typeof e && e >= 0);
|
|
var i = e / 26 | 0
|
|
, r = e % 26;
|
|
return this._expand(i + 1),
|
|
t ? this.words[i] = this.words[i] | 1 << r : this.words[i] = this.words[i] & ~(1 << r),
|
|
this.strip()
|
|
}
|
|
,
|
|
a.prototype.iadd = function(e) {
|
|
if (0 !== this.negative && 0 === e.negative)
|
|
return this.negative = 0,
|
|
t = this.isub(e),
|
|
this.negative ^= 1,
|
|
this._normSign();
|
|
if (0 === this.negative && 0 !== e.negative)
|
|
return e.negative = 0,
|
|
t = this.isub(e),
|
|
e.negative = 1,
|
|
t._normSign();
|
|
this.length > e.length ? (i = this,
|
|
n = e) : (i = e,
|
|
n = this);
|
|
for (var t, i, n, r = 0, a = 0; a < n.length; a++)
|
|
t = (0 | i.words[a]) + (0 | n.words[a]) + r,
|
|
this.words[a] = 0x3ffffff & t,
|
|
r = t >>> 26;
|
|
for (; 0 !== r && a < i.length; a++)
|
|
t = (0 | i.words[a]) + r,
|
|
this.words[a] = 0x3ffffff & t,
|
|
r = t >>> 26;
|
|
if (this.length = i.length,
|
|
0 !== r)
|
|
this.words[this.length] = r,
|
|
this.length++;
|
|
else if (i !== this)
|
|
for (; a < i.length; a++)
|
|
this.words[a] = i.words[a];
|
|
return this
|
|
}
|
|
,
|
|
a.prototype.add = function(e) {
|
|
var t;
|
|
return 0 !== e.negative && 0 === this.negative ? (e.negative = 0,
|
|
t = this.sub(e),
|
|
e.negative ^= 1,
|
|
t) : 0 === e.negative && 0 !== this.negative ? (this.negative = 0,
|
|
t = e.sub(this),
|
|
this.negative = 1,
|
|
t) : this.length > e.length ? this.clone().iadd(e) : e.clone().iadd(this)
|
|
}
|
|
,
|
|
a.prototype.isub = function(e) {
|
|
if (0 !== e.negative) {
|
|
e.negative = 0;
|
|
var t, i, n = this.iadd(e);
|
|
return e.negative = 1,
|
|
n._normSign()
|
|
}
|
|
if (0 !== this.negative)
|
|
return this.negative = 0,
|
|
this.iadd(e),
|
|
this.negative = 1,
|
|
this._normSign();
|
|
var r = this.cmp(e);
|
|
if (0 === r)
|
|
return this.negative = 0,
|
|
this.length = 1,
|
|
this.words[0] = 0,
|
|
this;
|
|
r > 0 ? (t = this,
|
|
i = e) : (t = e,
|
|
i = this);
|
|
for (var a = 0, o = 0; o < i.length; o++)
|
|
a = (n = (0 | t.words[o]) - (0 | i.words[o]) + a) >> 26,
|
|
this.words[o] = 0x3ffffff & n;
|
|
for (; 0 !== a && o < t.length; o++)
|
|
a = (n = (0 | t.words[o]) + a) >> 26,
|
|
this.words[o] = 0x3ffffff & n;
|
|
if (0 === a && o < t.length && t !== this)
|
|
for (; o < t.length; o++)
|
|
this.words[o] = t.words[o];
|
|
return this.length = Math.max(this.length, o),
|
|
t !== this && (this.negative = 1),
|
|
this.strip()
|
|
}
|
|
,
|
|
a.prototype.sub = function(e) {
|
|
return this.clone().isub(e)
|
|
}
|
|
;
|
|
var v = function(e, t, i) {
|
|
var n, r, a, o = e.words, s = t.words, l = i.words, c = 0, d = 0 | o[0], u = 8191 & d, f = d >>> 13, h = 0 | o[1], p = 8191 & h, v = h >>> 13, m = 0 | o[2], g = 8191 & m, _ = m >>> 13, y = 0 | o[3], b = 8191 & y, I = y >>> 13, w = 0 | o[4], x = 8191 & w, S = w >>> 13, M = 0 | o[5], C = 8191 & M, T = M >>> 13, A = 0 | o[6], k = 8191 & A, P = A >>> 13, E = 0 | o[7], D = 8191 & E, R = E >>> 13, N = 0 | o[8], L = 8191 & N, j = N >>> 13, O = 0 | o[9], B = 8191 & O, F = O >>> 13, U = 0 | s[0], G = 8191 & U, z = U >>> 13, V = 0 | s[1], W = 8191 & V, Z = V >>> 13, K = 0 | s[2], H = 8191 & K, q = K >>> 13, J = 0 | s[3], Y = 8191 & J, Q = J >>> 13, X = 0 | s[4], $ = 8191 & X, ee = X >>> 13, et = 0 | s[5], ei = 8191 & et, en = et >>> 13, er = 0 | s[6], ea = 8191 & er, eo = er >>> 13, es = 0 | s[7], el = 8191 & es, ec = es >>> 13, ed = 0 | s[8], eu = 8191 & ed, ef = ed >>> 13, eh = 0 | s[9], ep = 8191 & eh, ev = eh >>> 13;
|
|
i.negative = e.negative ^ t.negative,
|
|
i.length = 19,
|
|
n = Math.imul(u, G),
|
|
r = (r = Math.imul(u, z)) + Math.imul(f, G) | 0;
|
|
var em = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = Math.imul(f, z)) + (r >>> 13) | 0) + (em >>> 26) | 0,
|
|
em &= 0x3ffffff,
|
|
n = Math.imul(p, G),
|
|
r = (r = Math.imul(p, z)) + Math.imul(v, G) | 0,
|
|
a = Math.imul(v, z),
|
|
n = n + Math.imul(u, W) | 0,
|
|
r = (r = r + Math.imul(u, Z) | 0) + Math.imul(f, W) | 0;
|
|
var eg = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(f, Z) | 0) + (r >>> 13) | 0) + (eg >>> 26) | 0,
|
|
eg &= 0x3ffffff,
|
|
n = Math.imul(g, G),
|
|
r = (r = Math.imul(g, z)) + Math.imul(_, G) | 0,
|
|
a = Math.imul(_, z),
|
|
n = n + Math.imul(p, W) | 0,
|
|
r = (r = r + Math.imul(p, Z) | 0) + Math.imul(v, W) | 0,
|
|
a = a + Math.imul(v, Z) | 0,
|
|
n = n + Math.imul(u, H) | 0,
|
|
r = (r = r + Math.imul(u, q) | 0) + Math.imul(f, H) | 0;
|
|
var e_ = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(f, q) | 0) + (r >>> 13) | 0) + (e_ >>> 26) | 0,
|
|
e_ &= 0x3ffffff,
|
|
n = Math.imul(b, G),
|
|
r = (r = Math.imul(b, z)) + Math.imul(I, G) | 0,
|
|
a = Math.imul(I, z),
|
|
n = n + Math.imul(g, W) | 0,
|
|
r = (r = r + Math.imul(g, Z) | 0) + Math.imul(_, W) | 0,
|
|
a = a + Math.imul(_, Z) | 0,
|
|
n = n + Math.imul(p, H) | 0,
|
|
r = (r = r + Math.imul(p, q) | 0) + Math.imul(v, H) | 0,
|
|
a = a + Math.imul(v, q) | 0,
|
|
n = n + Math.imul(u, Y) | 0,
|
|
r = (r = r + Math.imul(u, Q) | 0) + Math.imul(f, Y) | 0;
|
|
var ey = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(f, Q) | 0) + (r >>> 13) | 0) + (ey >>> 26) | 0,
|
|
ey &= 0x3ffffff,
|
|
n = Math.imul(x, G),
|
|
r = (r = Math.imul(x, z)) + Math.imul(S, G) | 0,
|
|
a = Math.imul(S, z),
|
|
n = n + Math.imul(b, W) | 0,
|
|
r = (r = r + Math.imul(b, Z) | 0) + Math.imul(I, W) | 0,
|
|
a = a + Math.imul(I, Z) | 0,
|
|
n = n + Math.imul(g, H) | 0,
|
|
r = (r = r + Math.imul(g, q) | 0) + Math.imul(_, H) | 0,
|
|
a = a + Math.imul(_, q) | 0,
|
|
n = n + Math.imul(p, Y) | 0,
|
|
r = (r = r + Math.imul(p, Q) | 0) + Math.imul(v, Y) | 0,
|
|
a = a + Math.imul(v, Q) | 0,
|
|
n = n + Math.imul(u, $) | 0,
|
|
r = (r = r + Math.imul(u, ee) | 0) + Math.imul(f, $) | 0;
|
|
var eb = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(f, ee) | 0) + (r >>> 13) | 0) + (eb >>> 26) | 0,
|
|
eb &= 0x3ffffff,
|
|
n = Math.imul(C, G),
|
|
r = (r = Math.imul(C, z)) + Math.imul(T, G) | 0,
|
|
a = Math.imul(T, z),
|
|
n = n + Math.imul(x, W) | 0,
|
|
r = (r = r + Math.imul(x, Z) | 0) + Math.imul(S, W) | 0,
|
|
a = a + Math.imul(S, Z) | 0,
|
|
n = n + Math.imul(b, H) | 0,
|
|
r = (r = r + Math.imul(b, q) | 0) + Math.imul(I, H) | 0,
|
|
a = a + Math.imul(I, q) | 0,
|
|
n = n + Math.imul(g, Y) | 0,
|
|
r = (r = r + Math.imul(g, Q) | 0) + Math.imul(_, Y) | 0,
|
|
a = a + Math.imul(_, Q) | 0,
|
|
n = n + Math.imul(p, $) | 0,
|
|
r = (r = r + Math.imul(p, ee) | 0) + Math.imul(v, $) | 0,
|
|
a = a + Math.imul(v, ee) | 0,
|
|
n = n + Math.imul(u, ei) | 0,
|
|
r = (r = r + Math.imul(u, en) | 0) + Math.imul(f, ei) | 0;
|
|
var eI = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(f, en) | 0) + (r >>> 13) | 0) + (eI >>> 26) | 0,
|
|
eI &= 0x3ffffff,
|
|
n = Math.imul(k, G),
|
|
r = (r = Math.imul(k, z)) + Math.imul(P, G) | 0,
|
|
a = Math.imul(P, z),
|
|
n = n + Math.imul(C, W) | 0,
|
|
r = (r = r + Math.imul(C, Z) | 0) + Math.imul(T, W) | 0,
|
|
a = a + Math.imul(T, Z) | 0,
|
|
n = n + Math.imul(x, H) | 0,
|
|
r = (r = r + Math.imul(x, q) | 0) + Math.imul(S, H) | 0,
|
|
a = a + Math.imul(S, q) | 0,
|
|
n = n + Math.imul(b, Y) | 0,
|
|
r = (r = r + Math.imul(b, Q) | 0) + Math.imul(I, Y) | 0,
|
|
a = a + Math.imul(I, Q) | 0,
|
|
n = n + Math.imul(g, $) | 0,
|
|
r = (r = r + Math.imul(g, ee) | 0) + Math.imul(_, $) | 0,
|
|
a = a + Math.imul(_, ee) | 0,
|
|
n = n + Math.imul(p, ei) | 0,
|
|
r = (r = r + Math.imul(p, en) | 0) + Math.imul(v, ei) | 0,
|
|
a = a + Math.imul(v, en) | 0,
|
|
n = n + Math.imul(u, ea) | 0,
|
|
r = (r = r + Math.imul(u, eo) | 0) + Math.imul(f, ea) | 0;
|
|
var ew = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(f, eo) | 0) + (r >>> 13) | 0) + (ew >>> 26) | 0,
|
|
ew &= 0x3ffffff,
|
|
n = Math.imul(D, G),
|
|
r = (r = Math.imul(D, z)) + Math.imul(R, G) | 0,
|
|
a = Math.imul(R, z),
|
|
n = n + Math.imul(k, W) | 0,
|
|
r = (r = r + Math.imul(k, Z) | 0) + Math.imul(P, W) | 0,
|
|
a = a + Math.imul(P, Z) | 0,
|
|
n = n + Math.imul(C, H) | 0,
|
|
r = (r = r + Math.imul(C, q) | 0) + Math.imul(T, H) | 0,
|
|
a = a + Math.imul(T, q) | 0,
|
|
n = n + Math.imul(x, Y) | 0,
|
|
r = (r = r + Math.imul(x, Q) | 0) + Math.imul(S, Y) | 0,
|
|
a = a + Math.imul(S, Q) | 0,
|
|
n = n + Math.imul(b, $) | 0,
|
|
r = (r = r + Math.imul(b, ee) | 0) + Math.imul(I, $) | 0,
|
|
a = a + Math.imul(I, ee) | 0,
|
|
n = n + Math.imul(g, ei) | 0,
|
|
r = (r = r + Math.imul(g, en) | 0) + Math.imul(_, ei) | 0,
|
|
a = a + Math.imul(_, en) | 0,
|
|
n = n + Math.imul(p, ea) | 0,
|
|
r = (r = r + Math.imul(p, eo) | 0) + Math.imul(v, ea) | 0,
|
|
a = a + Math.imul(v, eo) | 0,
|
|
n = n + Math.imul(u, el) | 0,
|
|
r = (r = r + Math.imul(u, ec) | 0) + Math.imul(f, el) | 0;
|
|
var ex = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(f, ec) | 0) + (r >>> 13) | 0) + (ex >>> 26) | 0,
|
|
ex &= 0x3ffffff,
|
|
n = Math.imul(L, G),
|
|
r = (r = Math.imul(L, z)) + Math.imul(j, G) | 0,
|
|
a = Math.imul(j, z),
|
|
n = n + Math.imul(D, W) | 0,
|
|
r = (r = r + Math.imul(D, Z) | 0) + Math.imul(R, W) | 0,
|
|
a = a + Math.imul(R, Z) | 0,
|
|
n = n + Math.imul(k, H) | 0,
|
|
r = (r = r + Math.imul(k, q) | 0) + Math.imul(P, H) | 0,
|
|
a = a + Math.imul(P, q) | 0,
|
|
n = n + Math.imul(C, Y) | 0,
|
|
r = (r = r + Math.imul(C, Q) | 0) + Math.imul(T, Y) | 0,
|
|
a = a + Math.imul(T, Q) | 0,
|
|
n = n + Math.imul(x, $) | 0,
|
|
r = (r = r + Math.imul(x, ee) | 0) + Math.imul(S, $) | 0,
|
|
a = a + Math.imul(S, ee) | 0,
|
|
n = n + Math.imul(b, ei) | 0,
|
|
r = (r = r + Math.imul(b, en) | 0) + Math.imul(I, ei) | 0,
|
|
a = a + Math.imul(I, en) | 0,
|
|
n = n + Math.imul(g, ea) | 0,
|
|
r = (r = r + Math.imul(g, eo) | 0) + Math.imul(_, ea) | 0,
|
|
a = a + Math.imul(_, eo) | 0,
|
|
n = n + Math.imul(p, el) | 0,
|
|
r = (r = r + Math.imul(p, ec) | 0) + Math.imul(v, el) | 0,
|
|
a = a + Math.imul(v, ec) | 0,
|
|
n = n + Math.imul(u, eu) | 0,
|
|
r = (r = r + Math.imul(u, ef) | 0) + Math.imul(f, eu) | 0;
|
|
var eS = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(f, ef) | 0) + (r >>> 13) | 0) + (eS >>> 26) | 0,
|
|
eS &= 0x3ffffff,
|
|
n = Math.imul(B, G),
|
|
r = (r = Math.imul(B, z)) + Math.imul(F, G) | 0,
|
|
a = Math.imul(F, z),
|
|
n = n + Math.imul(L, W) | 0,
|
|
r = (r = r + Math.imul(L, Z) | 0) + Math.imul(j, W) | 0,
|
|
a = a + Math.imul(j, Z) | 0,
|
|
n = n + Math.imul(D, H) | 0,
|
|
r = (r = r + Math.imul(D, q) | 0) + Math.imul(R, H) | 0,
|
|
a = a + Math.imul(R, q) | 0,
|
|
n = n + Math.imul(k, Y) | 0,
|
|
r = (r = r + Math.imul(k, Q) | 0) + Math.imul(P, Y) | 0,
|
|
a = a + Math.imul(P, Q) | 0,
|
|
n = n + Math.imul(C, $) | 0,
|
|
r = (r = r + Math.imul(C, ee) | 0) + Math.imul(T, $) | 0,
|
|
a = a + Math.imul(T, ee) | 0,
|
|
n = n + Math.imul(x, ei) | 0,
|
|
r = (r = r + Math.imul(x, en) | 0) + Math.imul(S, ei) | 0,
|
|
a = a + Math.imul(S, en) | 0,
|
|
n = n + Math.imul(b, ea) | 0,
|
|
r = (r = r + Math.imul(b, eo) | 0) + Math.imul(I, ea) | 0,
|
|
a = a + Math.imul(I, eo) | 0,
|
|
n = n + Math.imul(g, el) | 0,
|
|
r = (r = r + Math.imul(g, ec) | 0) + Math.imul(_, el) | 0,
|
|
a = a + Math.imul(_, ec) | 0,
|
|
n = n + Math.imul(p, eu) | 0,
|
|
r = (r = r + Math.imul(p, ef) | 0) + Math.imul(v, eu) | 0,
|
|
a = a + Math.imul(v, ef) | 0,
|
|
n = n + Math.imul(u, ep) | 0,
|
|
r = (r = r + Math.imul(u, ev) | 0) + Math.imul(f, ep) | 0;
|
|
var eM = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(f, ev) | 0) + (r >>> 13) | 0) + (eM >>> 26) | 0,
|
|
eM &= 0x3ffffff,
|
|
n = Math.imul(B, W),
|
|
r = (r = Math.imul(B, Z)) + Math.imul(F, W) | 0,
|
|
a = Math.imul(F, Z),
|
|
n = n + Math.imul(L, H) | 0,
|
|
r = (r = r + Math.imul(L, q) | 0) + Math.imul(j, H) | 0,
|
|
a = a + Math.imul(j, q) | 0,
|
|
n = n + Math.imul(D, Y) | 0,
|
|
r = (r = r + Math.imul(D, Q) | 0) + Math.imul(R, Y) | 0,
|
|
a = a + Math.imul(R, Q) | 0,
|
|
n = n + Math.imul(k, $) | 0,
|
|
r = (r = r + Math.imul(k, ee) | 0) + Math.imul(P, $) | 0,
|
|
a = a + Math.imul(P, ee) | 0,
|
|
n = n + Math.imul(C, ei) | 0,
|
|
r = (r = r + Math.imul(C, en) | 0) + Math.imul(T, ei) | 0,
|
|
a = a + Math.imul(T, en) | 0,
|
|
n = n + Math.imul(x, ea) | 0,
|
|
r = (r = r + Math.imul(x, eo) | 0) + Math.imul(S, ea) | 0,
|
|
a = a + Math.imul(S, eo) | 0,
|
|
n = n + Math.imul(b, el) | 0,
|
|
r = (r = r + Math.imul(b, ec) | 0) + Math.imul(I, el) | 0,
|
|
a = a + Math.imul(I, ec) | 0,
|
|
n = n + Math.imul(g, eu) | 0,
|
|
r = (r = r + Math.imul(g, ef) | 0) + Math.imul(_, eu) | 0,
|
|
a = a + Math.imul(_, ef) | 0,
|
|
n = n + Math.imul(p, ep) | 0,
|
|
r = (r = r + Math.imul(p, ev) | 0) + Math.imul(v, ep) | 0;
|
|
var eC = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(v, ev) | 0) + (r >>> 13) | 0) + (eC >>> 26) | 0,
|
|
eC &= 0x3ffffff,
|
|
n = Math.imul(B, H),
|
|
r = (r = Math.imul(B, q)) + Math.imul(F, H) | 0,
|
|
a = Math.imul(F, q),
|
|
n = n + Math.imul(L, Y) | 0,
|
|
r = (r = r + Math.imul(L, Q) | 0) + Math.imul(j, Y) | 0,
|
|
a = a + Math.imul(j, Q) | 0,
|
|
n = n + Math.imul(D, $) | 0,
|
|
r = (r = r + Math.imul(D, ee) | 0) + Math.imul(R, $) | 0,
|
|
a = a + Math.imul(R, ee) | 0,
|
|
n = n + Math.imul(k, ei) | 0,
|
|
r = (r = r + Math.imul(k, en) | 0) + Math.imul(P, ei) | 0,
|
|
a = a + Math.imul(P, en) | 0,
|
|
n = n + Math.imul(C, ea) | 0,
|
|
r = (r = r + Math.imul(C, eo) | 0) + Math.imul(T, ea) | 0,
|
|
a = a + Math.imul(T, eo) | 0,
|
|
n = n + Math.imul(x, el) | 0,
|
|
r = (r = r + Math.imul(x, ec) | 0) + Math.imul(S, el) | 0,
|
|
a = a + Math.imul(S, ec) | 0,
|
|
n = n + Math.imul(b, eu) | 0,
|
|
r = (r = r + Math.imul(b, ef) | 0) + Math.imul(I, eu) | 0,
|
|
a = a + Math.imul(I, ef) | 0,
|
|
n = n + Math.imul(g, ep) | 0,
|
|
r = (r = r + Math.imul(g, ev) | 0) + Math.imul(_, ep) | 0;
|
|
var eT = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(_, ev) | 0) + (r >>> 13) | 0) + (eT >>> 26) | 0,
|
|
eT &= 0x3ffffff,
|
|
n = Math.imul(B, Y),
|
|
r = (r = Math.imul(B, Q)) + Math.imul(F, Y) | 0,
|
|
a = Math.imul(F, Q),
|
|
n = n + Math.imul(L, $) | 0,
|
|
r = (r = r + Math.imul(L, ee) | 0) + Math.imul(j, $) | 0,
|
|
a = a + Math.imul(j, ee) | 0,
|
|
n = n + Math.imul(D, ei) | 0,
|
|
r = (r = r + Math.imul(D, en) | 0) + Math.imul(R, ei) | 0,
|
|
a = a + Math.imul(R, en) | 0,
|
|
n = n + Math.imul(k, ea) | 0,
|
|
r = (r = r + Math.imul(k, eo) | 0) + Math.imul(P, ea) | 0,
|
|
a = a + Math.imul(P, eo) | 0,
|
|
n = n + Math.imul(C, el) | 0,
|
|
r = (r = r + Math.imul(C, ec) | 0) + Math.imul(T, el) | 0,
|
|
a = a + Math.imul(T, ec) | 0,
|
|
n = n + Math.imul(x, eu) | 0,
|
|
r = (r = r + Math.imul(x, ef) | 0) + Math.imul(S, eu) | 0,
|
|
a = a + Math.imul(S, ef) | 0,
|
|
n = n + Math.imul(b, ep) | 0,
|
|
r = (r = r + Math.imul(b, ev) | 0) + Math.imul(I, ep) | 0;
|
|
var eA = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(I, ev) | 0) + (r >>> 13) | 0) + (eA >>> 26) | 0,
|
|
eA &= 0x3ffffff,
|
|
n = Math.imul(B, $),
|
|
r = (r = Math.imul(B, ee)) + Math.imul(F, $) | 0,
|
|
a = Math.imul(F, ee),
|
|
n = n + Math.imul(L, ei) | 0,
|
|
r = (r = r + Math.imul(L, en) | 0) + Math.imul(j, ei) | 0,
|
|
a = a + Math.imul(j, en) | 0,
|
|
n = n + Math.imul(D, ea) | 0,
|
|
r = (r = r + Math.imul(D, eo) | 0) + Math.imul(R, ea) | 0,
|
|
a = a + Math.imul(R, eo) | 0,
|
|
n = n + Math.imul(k, el) | 0,
|
|
r = (r = r + Math.imul(k, ec) | 0) + Math.imul(P, el) | 0,
|
|
a = a + Math.imul(P, ec) | 0,
|
|
n = n + Math.imul(C, eu) | 0,
|
|
r = (r = r + Math.imul(C, ef) | 0) + Math.imul(T, eu) | 0,
|
|
a = a + Math.imul(T, ef) | 0,
|
|
n = n + Math.imul(x, ep) | 0,
|
|
r = (r = r + Math.imul(x, ev) | 0) + Math.imul(S, ep) | 0;
|
|
var ek = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(S, ev) | 0) + (r >>> 13) | 0) + (ek >>> 26) | 0,
|
|
ek &= 0x3ffffff,
|
|
n = Math.imul(B, ei),
|
|
r = (r = Math.imul(B, en)) + Math.imul(F, ei) | 0,
|
|
a = Math.imul(F, en),
|
|
n = n + Math.imul(L, ea) | 0,
|
|
r = (r = r + Math.imul(L, eo) | 0) + Math.imul(j, ea) | 0,
|
|
a = a + Math.imul(j, eo) | 0,
|
|
n = n + Math.imul(D, el) | 0,
|
|
r = (r = r + Math.imul(D, ec) | 0) + Math.imul(R, el) | 0,
|
|
a = a + Math.imul(R, ec) | 0,
|
|
n = n + Math.imul(k, eu) | 0,
|
|
r = (r = r + Math.imul(k, ef) | 0) + Math.imul(P, eu) | 0,
|
|
a = a + Math.imul(P, ef) | 0,
|
|
n = n + Math.imul(C, ep) | 0,
|
|
r = (r = r + Math.imul(C, ev) | 0) + Math.imul(T, ep) | 0;
|
|
var eP = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(T, ev) | 0) + (r >>> 13) | 0) + (eP >>> 26) | 0,
|
|
eP &= 0x3ffffff,
|
|
n = Math.imul(B, ea),
|
|
r = (r = Math.imul(B, eo)) + Math.imul(F, ea) | 0,
|
|
a = Math.imul(F, eo),
|
|
n = n + Math.imul(L, el) | 0,
|
|
r = (r = r + Math.imul(L, ec) | 0) + Math.imul(j, el) | 0,
|
|
a = a + Math.imul(j, ec) | 0,
|
|
n = n + Math.imul(D, eu) | 0,
|
|
r = (r = r + Math.imul(D, ef) | 0) + Math.imul(R, eu) | 0,
|
|
a = a + Math.imul(R, ef) | 0,
|
|
n = n + Math.imul(k, ep) | 0,
|
|
r = (r = r + Math.imul(k, ev) | 0) + Math.imul(P, ep) | 0;
|
|
var eE = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(P, ev) | 0) + (r >>> 13) | 0) + (eE >>> 26) | 0,
|
|
eE &= 0x3ffffff,
|
|
n = Math.imul(B, el),
|
|
r = (r = Math.imul(B, ec)) + Math.imul(F, el) | 0,
|
|
a = Math.imul(F, ec),
|
|
n = n + Math.imul(L, eu) | 0,
|
|
r = (r = r + Math.imul(L, ef) | 0) + Math.imul(j, eu) | 0,
|
|
a = a + Math.imul(j, ef) | 0,
|
|
n = n + Math.imul(D, ep) | 0,
|
|
r = (r = r + Math.imul(D, ev) | 0) + Math.imul(R, ep) | 0;
|
|
var eD = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(R, ev) | 0) + (r >>> 13) | 0) + (eD >>> 26) | 0,
|
|
eD &= 0x3ffffff,
|
|
n = Math.imul(B, eu),
|
|
r = (r = Math.imul(B, ef)) + Math.imul(F, eu) | 0,
|
|
a = Math.imul(F, ef),
|
|
n = n + Math.imul(L, ep) | 0,
|
|
r = (r = r + Math.imul(L, ev) | 0) + Math.imul(j, ep) | 0;
|
|
var eR = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
c = ((a = a + Math.imul(j, ev) | 0) + (r >>> 13) | 0) + (eR >>> 26) | 0,
|
|
eR &= 0x3ffffff,
|
|
n = Math.imul(B, ep),
|
|
r = (r = Math.imul(B, ev)) + Math.imul(F, ep) | 0;
|
|
var eN = (c + n | 0) + ((8191 & r) << 13) | 0;
|
|
return c = ((a = Math.imul(F, ev)) + (r >>> 13) | 0) + (eN >>> 26) | 0,
|
|
eN &= 0x3ffffff,
|
|
l[0] = em,
|
|
l[1] = eg,
|
|
l[2] = e_,
|
|
l[3] = ey,
|
|
l[4] = eb,
|
|
l[5] = eI,
|
|
l[6] = ew,
|
|
l[7] = ex,
|
|
l[8] = eS,
|
|
l[9] = eM,
|
|
l[10] = eC,
|
|
l[11] = eT,
|
|
l[12] = eA,
|
|
l[13] = ek,
|
|
l[14] = eP,
|
|
l[15] = eE,
|
|
l[16] = eD,
|
|
l[17] = eR,
|
|
l[18] = eN,
|
|
0 !== c && (l[19] = c,
|
|
i.length++),
|
|
i
|
|
};
|
|
function m(e, t, i) {
|
|
i.negative = t.negative ^ e.negative,
|
|
i.length = e.length + t.length;
|
|
for (var n = 0, r = 0, a = 0; a < i.length - 1; a++) {
|
|
var o = r;
|
|
r = 0;
|
|
for (var s = 0x3ffffff & n, l = Math.min(a, t.length - 1), c = Math.max(0, a - e.length + 1); c <= l; c++) {
|
|
var d = a - c
|
|
, u = (0 | e.words[d]) * (0 | t.words[c])
|
|
, f = 0x3ffffff & u;
|
|
o = o + (u / 0x4000000 | 0) | 0,
|
|
s = 0x3ffffff & (f = f + s | 0),
|
|
r += (o = o + (f >>> 26) | 0) >>> 26,
|
|
o &= 0x3ffffff
|
|
}
|
|
i.words[a] = s,
|
|
n = o,
|
|
o = r
|
|
}
|
|
return 0 !== n ? i.words[a] = n : i.length--,
|
|
i.strip()
|
|
}
|
|
function g(e, t, i) {
|
|
return new _().mulp(e, t, i)
|
|
}
|
|
function _(e, t) {
|
|
this.x = e,
|
|
this.y = t
|
|
}
|
|
!Math.imul && (v = p),
|
|
a.prototype.mulTo = function(e, t) {
|
|
var i, n = this.length + e.length;
|
|
return i = 10 === this.length && 10 === e.length ? v(this, e, t) : n < 63 ? p(this, e, t) : n < 1024 ? m(this, e, t) : g(this, e, t)
|
|
}
|
|
,
|
|
_.prototype.makeRBT = function(e) {
|
|
for (var t = Array(e), i = a.prototype._countBits(e) - 1, n = 0; n < e; n++)
|
|
t[n] = this.revBin(n, i, e);
|
|
return t
|
|
}
|
|
,
|
|
_.prototype.revBin = function(e, t, i) {
|
|
if (0 === e || e === i - 1)
|
|
return e;
|
|
for (var n = 0, r = 0; r < t; r++)
|
|
n |= (1 & e) << t - r - 1,
|
|
e >>= 1;
|
|
return n
|
|
}
|
|
,
|
|
_.prototype.permute = function(e, t, i, n, r, a) {
|
|
for (var o = 0; o < a; o++)
|
|
n[o] = t[e[o]],
|
|
r[o] = i[e[o]]
|
|
}
|
|
,
|
|
_.prototype.transform = function(e, t, i, n, r, a) {
|
|
this.permute(a, e, t, i, n, r);
|
|
for (var o = 1; o < r; o <<= 1) {
|
|
for (var s = o << 1, l = Math.cos(2 * Math.PI / s), c = Math.sin(2 * Math.PI / s), d = 0; d < r; d += s) {
|
|
for (var u = l, f = c, h = 0; h < o; h++) {
|
|
var p = i[d + h]
|
|
, v = n[d + h]
|
|
, m = i[d + h + o]
|
|
, g = n[d + h + o]
|
|
, _ = u * m - f * g;
|
|
g = u * g + f * m,
|
|
m = _,
|
|
i[d + h] = p + m,
|
|
n[d + h] = v + g,
|
|
i[d + h + o] = p - m,
|
|
n[d + h + o] = v - g,
|
|
h !== s && (_ = l * u - c * f,
|
|
f = l * f + c * u,
|
|
u = _)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
,
|
|
_.prototype.guessLen13b = function(e, t) {
|
|
var i = 1 | Math.max(t, e)
|
|
, n = 1 & i
|
|
, r = 0;
|
|
for (i = i / 2 | 0; i; i >>>= 1)
|
|
r++;
|
|
return 1 << r + 1 + n
|
|
}
|
|
,
|
|
_.prototype.conjugate = function(e, t, i) {
|
|
if (!(i <= 1))
|
|
for (var n = 0; n < i / 2; n++) {
|
|
var r = e[n];
|
|
e[n] = e[i - n - 1],
|
|
e[i - n - 1] = r,
|
|
r = t[n],
|
|
t[n] = -t[i - n - 1],
|
|
t[i - n - 1] = -r
|
|
}
|
|
}
|
|
,
|
|
_.prototype.normalize13b = function(e, t) {
|
|
for (var i = 0, n = 0; n < t / 2; n++) {
|
|
var r = 8192 * Math.round(e[2 * n + 1] / t) + Math.round(e[2 * n] / t) + i;
|
|
e[n] = 0x3ffffff & r,
|
|
i = r < 0x4000000 ? 0 : r / 0x4000000 | 0
|
|
}
|
|
return e
|
|
}
|
|
,
|
|
_.prototype.convert13b = function(e, t, i, r) {
|
|
for (var a = 0, o = 0; o < t; o++)
|
|
a += 0 | e[o],
|
|
i[2 * o] = 8191 & a,
|
|
a >>>= 13,
|
|
i[2 * o + 1] = 8191 & a,
|
|
a >>>= 13;
|
|
for (o = 2 * t; o < r; ++o)
|
|
i[o] = 0;
|
|
n(0 === a),
|
|
n((-8192 & a) == 0)
|
|
}
|
|
,
|
|
_.prototype.stub = function(e) {
|
|
for (var t = Array(e), i = 0; i < e; i++)
|
|
t[i] = 0;
|
|
return t
|
|
}
|
|
,
|
|
_.prototype.mulp = function(e, t, i) {
|
|
var n = 2 * this.guessLen13b(e.length, t.length)
|
|
, r = this.makeRBT(n)
|
|
, a = this.stub(n)
|
|
, o = Array(n)
|
|
, s = Array(n)
|
|
, l = Array(n)
|
|
, c = Array(n)
|
|
, d = Array(n)
|
|
, u = Array(n)
|
|
, f = i.words;
|
|
f.length = n,
|
|
this.convert13b(e.words, e.length, o, n),
|
|
this.convert13b(t.words, t.length, c, n),
|
|
this.transform(o, a, s, l, n, r),
|
|
this.transform(c, a, d, u, n, r);
|
|
for (var h = 0; h < n; h++) {
|
|
var p = s[h] * d[h] - l[h] * u[h];
|
|
l[h] = s[h] * u[h] + l[h] * d[h],
|
|
s[h] = p
|
|
}
|
|
return this.conjugate(s, l, n),
|
|
this.transform(s, l, f, a, n, r),
|
|
this.conjugate(f, a, n),
|
|
this.normalize13b(f, n),
|
|
i.negative = e.negative ^ t.negative,
|
|
i.length = e.length + t.length,
|
|
i.strip()
|
|
}
|
|
,
|
|
a.prototype.mul = function(e) {
|
|
var t = new a(null);
|
|
return t.words = Array(this.length + e.length),
|
|
this.mulTo(e, t)
|
|
}
|
|
,
|
|
a.prototype.mulf = function(e) {
|
|
var t = new a(null);
|
|
return t.words = Array(this.length + e.length),
|
|
g(this, e, t)
|
|
}
|
|
,
|
|
a.prototype.imul = function(e) {
|
|
return this.clone().mulTo(e, this)
|
|
}
|
|
,
|
|
a.prototype.imuln = function(e) {
|
|
n("number" == typeof e),
|
|
n(e < 0x4000000);
|
|
for (var t = 0, i = 0; i < this.length; i++) {
|
|
var r = (0 | this.words[i]) * e
|
|
, a = (0x3ffffff & r) + (0x3ffffff & t);
|
|
t >>= 26,
|
|
t += (r / 0x4000000 | 0) + (a >>> 26),
|
|
this.words[i] = 0x3ffffff & a
|
|
}
|
|
return 0 !== t && (this.words[i] = t,
|
|
this.length++),
|
|
this
|
|
}
|
|
,
|
|
a.prototype.muln = function(e) {
|
|
return this.clone().imuln(e)
|
|
}
|
|
,
|
|
a.prototype.sqr = function() {
|
|
return this.mul(this)
|
|
}
|
|
,
|
|
a.prototype.isqr = function() {
|
|
return this.imul(this.clone())
|
|
}
|
|
,
|
|
a.prototype.pow = function(e) {
|
|
var t = h(e);
|
|
if (0 === t.length)
|
|
return new a(1);
|
|
for (var i = this, n = 0; n < t.length && 0 === t[n]; n++,
|
|
i = i.sqr())
|
|
;
|
|
if (++n < t.length)
|
|
for (var r = i.sqr(); n < t.length; n++,
|
|
r = r.sqr())
|
|
0 !== t[n] && (i = i.mul(r));
|
|
return i
|
|
}
|
|
,
|
|
a.prototype.iushln = function(e) {
|
|
n("number" == typeof e && e >= 0);
|
|
var t, i = e % 26, r = (e - i) / 26, a = 0x3ffffff >>> 26 - i << 26 - i;
|
|
if (0 !== i) {
|
|
var o = 0;
|
|
for (t = 0; t < this.length; t++) {
|
|
var s = this.words[t] & a
|
|
, l = (0 | this.words[t]) - s << i;
|
|
this.words[t] = l | o,
|
|
o = s >>> 26 - i
|
|
}
|
|
o && (this.words[t] = o,
|
|
this.length++)
|
|
}
|
|
if (0 !== r) {
|
|
for (t = this.length - 1; t >= 0; t--)
|
|
this.words[t + r] = this.words[t];
|
|
for (t = 0; t < r; t++)
|
|
this.words[t] = 0;
|
|
this.length += r
|
|
}
|
|
return this.strip()
|
|
}
|
|
,
|
|
a.prototype.ishln = function(e) {
|
|
return n(0 === this.negative),
|
|
this.iushln(e)
|
|
}
|
|
,
|
|
a.prototype.iushrn = function(e, t, i) {
|
|
n("number" == typeof e && e >= 0),
|
|
r = t ? (t - t % 26) / 26 : 0;
|
|
var r, a = e % 26, o = Math.min((e - a) / 26, this.length), s = 0x3ffffff ^ 0x3ffffff >>> a << a, l = i;
|
|
if (r -= o,
|
|
r = Math.max(0, r),
|
|
l) {
|
|
for (var c = 0; c < o; c++)
|
|
l.words[c] = this.words[c];
|
|
l.length = o
|
|
}
|
|
if (0 === o)
|
|
;
|
|
else if (this.length > o)
|
|
for (this.length -= o,
|
|
c = 0; c < this.length; c++)
|
|
this.words[c] = this.words[c + o];
|
|
else
|
|
this.words[0] = 0,
|
|
this.length = 1;
|
|
var d = 0;
|
|
for (c = this.length - 1; c >= 0 && (0 !== d || c >= r); c--) {
|
|
var u = 0 | this.words[c];
|
|
this.words[c] = d << 26 - a | u >>> a,
|
|
d = u & s
|
|
}
|
|
return l && 0 !== d && (l.words[l.length++] = d),
|
|
0 === this.length && (this.words[0] = 0,
|
|
this.length = 1),
|
|
this.strip()
|
|
}
|
|
,
|
|
a.prototype.ishrn = function(e, t, i) {
|
|
return n(0 === this.negative),
|
|
this.iushrn(e, t, i)
|
|
}
|
|
,
|
|
a.prototype.shln = function(e) {
|
|
return this.clone().ishln(e)
|
|
}
|
|
,
|
|
a.prototype.ushln = function(e) {
|
|
return this.clone().iushln(e)
|
|
}
|
|
,
|
|
a.prototype.shrn = function(e) {
|
|
return this.clone().ishrn(e)
|
|
}
|
|
,
|
|
a.prototype.ushrn = function(e) {
|
|
return this.clone().iushrn(e)
|
|
}
|
|
,
|
|
a.prototype.testn = function(e) {
|
|
n("number" == typeof e && e >= 0);
|
|
var t = e % 26
|
|
, i = (e - t) / 26
|
|
, r = 1 << t;
|
|
return !(this.length <= i) && !!(this.words[i] & r)
|
|
}
|
|
,
|
|
a.prototype.imaskn = function(e) {
|
|
n("number" == typeof e && e >= 0);
|
|
var t = e % 26
|
|
, i = (e - t) / 26;
|
|
if (n(0 === this.negative, "imaskn works only with positive numbers"),
|
|
this.length <= i)
|
|
return this;
|
|
if (0 !== t && i++,
|
|
this.length = Math.min(i, this.length),
|
|
0 !== t) {
|
|
var r = 0x3ffffff ^ 0x3ffffff >>> t << t;
|
|
this.words[this.length - 1] &= r
|
|
}
|
|
return this.strip()
|
|
}
|
|
,
|
|
a.prototype.maskn = function(e) {
|
|
return this.clone().imaskn(e)
|
|
}
|
|
,
|
|
a.prototype.iaddn = function(e) {
|
|
if (n("number" == typeof e),
|
|
n(e < 0x4000000),
|
|
e < 0)
|
|
return this.isubn(-e);
|
|
if (0 !== this.negative)
|
|
return 1 === this.length && (0 | this.words[0]) < e ? (this.words[0] = e - (0 | this.words[0]),
|
|
this.negative = 0,
|
|
this) : (this.negative = 0,
|
|
this.isubn(e),
|
|
this.negative = 1,
|
|
this);
|
|
return this._iaddn(e)
|
|
}
|
|
,
|
|
a.prototype._iaddn = function(e) {
|
|
this.words[0] += e;
|
|
for (var t = 0; t < this.length && this.words[t] >= 0x4000000; t++)
|
|
this.words[t] -= 0x4000000,
|
|
t === this.length - 1 ? this.words[t + 1] = 1 : this.words[t + 1]++;
|
|
return this.length = Math.max(this.length, t + 1),
|
|
this
|
|
}
|
|
,
|
|
a.prototype.isubn = function(e) {
|
|
if (n("number" == typeof e),
|
|
n(e < 0x4000000),
|
|
e < 0)
|
|
return this.iaddn(-e);
|
|
if (0 !== this.negative)
|
|
return this.negative = 0,
|
|
this.iaddn(e),
|
|
this.negative = 1,
|
|
this;
|
|
if (this.words[0] -= e,
|
|
1 === this.length && this.words[0] < 0)
|
|
this.words[0] = -this.words[0],
|
|
this.negative = 1;
|
|
else
|
|
for (var t = 0; t < this.length && this.words[t] < 0; t++)
|
|
this.words[t] += 0x4000000,
|
|
this.words[t + 1] -= 1;
|
|
return this.strip()
|
|
}
|
|
,
|
|
a.prototype.addn = function(e) {
|
|
return this.clone().iaddn(e)
|
|
}
|
|
,
|
|
a.prototype.subn = function(e) {
|
|
return this.clone().isubn(e)
|
|
}
|
|
,
|
|
a.prototype.iabs = function() {
|
|
return this.negative = 0,
|
|
this
|
|
}
|
|
,
|
|
a.prototype.abs = function() {
|
|
return this.clone().iabs()
|
|
}
|
|
,
|
|
a.prototype._ishlnsubmul = function(e, t, i) {
|
|
var r, a, o = e.length + i;
|
|
this._expand(o);
|
|
var s = 0;
|
|
for (r = 0; r < e.length; r++) {
|
|
a = (0 | this.words[r + i]) + s;
|
|
var l = (0 | e.words[r]) * t;
|
|
a -= 0x3ffffff & l,
|
|
s = (a >> 26) - (l / 0x4000000 | 0),
|
|
this.words[r + i] = 0x3ffffff & a
|
|
}
|
|
for (; r < this.length - i; r++)
|
|
s = (a = (0 | this.words[r + i]) + s) >> 26,
|
|
this.words[r + i] = 0x3ffffff & a;
|
|
if (0 === s)
|
|
return this.strip();
|
|
for (n(-1 === s),
|
|
s = 0,
|
|
r = 0; r < this.length; r++)
|
|
s = (a = -(0 | this.words[r]) + s) >> 26,
|
|
this.words[r] = 0x3ffffff & a;
|
|
return this.negative = 1,
|
|
this.strip()
|
|
}
|
|
,
|
|
a.prototype._wordDiv = function(e, t) {
|
|
var i, n = this.length - e.length, r = this.clone(), o = e, s = 0 | o.words[o.length - 1];
|
|
0 != (n = 26 - this._countBits(s)) && (o = o.ushln(n),
|
|
r.iushln(n),
|
|
s = 0 | o.words[o.length - 1]);
|
|
var l = r.length - o.length;
|
|
if ("mod" !== t) {
|
|
(i = new a(null)).length = l + 1,
|
|
i.words = Array(i.length);
|
|
for (var c = 0; c < i.length; c++)
|
|
i.words[c] = 0
|
|
}
|
|
var d = r.clone()._ishlnsubmul(o, 1, l);
|
|
0 === d.negative && (r = d,
|
|
i && (i.words[l] = 1));
|
|
for (var u = l - 1; u >= 0; u--) {
|
|
var f = (0 | r.words[o.length + u]) * 0x4000000 + (0 | r.words[o.length + u - 1]);
|
|
for (f = Math.min(f / s | 0, 0x3ffffff),
|
|
r._ishlnsubmul(o, f, u); 0 !== r.negative; )
|
|
f--,
|
|
r.negative = 0,
|
|
r._ishlnsubmul(o, 1, u),
|
|
!r.isZero() && (r.negative ^= 1);
|
|
i && (i.words[u] = f)
|
|
}
|
|
return i && i.strip(),
|
|
r.strip(),
|
|
"div" !== t && 0 !== n && r.iushrn(n),
|
|
{
|
|
div: i || null,
|
|
mod: r
|
|
}
|
|
}
|
|
,
|
|
a.prototype.divmod = function(e, t, i) {
|
|
var r, o, s;
|
|
if (n(!e.isZero()),
|
|
this.isZero())
|
|
return {
|
|
div: new a(0),
|
|
mod: new a(0)
|
|
};
|
|
if (0 !== this.negative && 0 === e.negative)
|
|
return s = this.neg().divmod(e, t),
|
|
"mod" !== t && (r = s.div.neg()),
|
|
"div" !== t && (o = s.mod.neg(),
|
|
i && 0 !== o.negative && o.iadd(e)),
|
|
{
|
|
div: r,
|
|
mod: o
|
|
};
|
|
if (0 === this.negative && 0 !== e.negative)
|
|
return s = this.divmod(e.neg(), t),
|
|
"mod" !== t && (r = s.div.neg()),
|
|
{
|
|
div: r,
|
|
mod: s.mod
|
|
};
|
|
if ((this.negative & e.negative) != 0)
|
|
return s = this.neg().divmod(e.neg(), t),
|
|
"div" !== t && (o = s.mod.neg(),
|
|
i && 0 !== o.negative && o.isub(e)),
|
|
{
|
|
div: s.div,
|
|
mod: o
|
|
};
|
|
if (e.length > this.length || 0 > this.cmp(e))
|
|
return {
|
|
div: new a(0),
|
|
mod: this
|
|
};
|
|
if (1 === e.length)
|
|
return "div" === t ? {
|
|
div: this.divn(e.words[0]),
|
|
mod: null
|
|
} : "mod" === t ? {
|
|
div: null,
|
|
mod: new a(this.modn(e.words[0]))
|
|
} : {
|
|
div: this.divn(e.words[0]),
|
|
mod: new a(this.modn(e.words[0]))
|
|
};
|
|
return this._wordDiv(e, t)
|
|
}
|
|
,
|
|
a.prototype.div = function(e) {
|
|
return this.divmod(e, "div", !1).div
|
|
}
|
|
,
|
|
a.prototype.mod = function(e) {
|
|
return this.divmod(e, "mod", !1).mod
|
|
}
|
|
,
|
|
a.prototype.umod = function(e) {
|
|
return this.divmod(e, "mod", !0).mod
|
|
}
|
|
,
|
|
a.prototype.divRound = function(e) {
|
|
var t = this.divmod(e);
|
|
if (t.mod.isZero())
|
|
return t.div;
|
|
var i = 0 !== t.div.negative ? t.mod.isub(e) : t.mod
|
|
, n = e.ushrn(1)
|
|
, r = e.andln(1)
|
|
, a = i.cmp(n);
|
|
return a < 0 || 1 === r && 0 === a ? t.div : 0 !== t.div.negative ? t.div.isubn(1) : t.div.iaddn(1)
|
|
}
|
|
,
|
|
a.prototype.modn = function(e) {
|
|
n(e <= 0x3ffffff);
|
|
for (var t = 0x4000000 % e, i = 0, r = this.length - 1; r >= 0; r--)
|
|
i = (t * i + (0 | this.words[r])) % e;
|
|
return i
|
|
}
|
|
,
|
|
a.prototype.idivn = function(e) {
|
|
n(e <= 0x3ffffff);
|
|
for (var t = 0, i = this.length - 1; i >= 0; i--) {
|
|
var r = (0 | this.words[i]) + 0x4000000 * t;
|
|
this.words[i] = r / e | 0,
|
|
t = r % e
|
|
}
|
|
return this.strip()
|
|
}
|
|
,
|
|
a.prototype.divn = function(e) {
|
|
return this.clone().idivn(e)
|
|
}
|
|
,
|
|
a.prototype.egcd = function(e) {
|
|
n(0 === e.negative),
|
|
n(!e.isZero());
|
|
var t = this
|
|
, i = e.clone();
|
|
t = 0 !== t.negative ? t.umod(e) : t.clone();
|
|
for (var r = new a(1), o = new a(0), s = new a(0), l = new a(1), c = 0; t.isEven() && i.isEven(); )
|
|
t.iushrn(1),
|
|
i.iushrn(1),
|
|
++c;
|
|
for (var d = i.clone(), u = t.clone(); !t.isZero(); ) {
|
|
for (var f = 0, h = 1; (t.words[0] & h) == 0 && f < 26; ++f,
|
|
h <<= 1)
|
|
;
|
|
if (f > 0)
|
|
for (t.iushrn(f); f-- > 0; )
|
|
(r.isOdd() || o.isOdd()) && (r.iadd(d),
|
|
o.isub(u)),
|
|
r.iushrn(1),
|
|
o.iushrn(1);
|
|
for (var p = 0, v = 1; (i.words[0] & v) == 0 && p < 26; ++p,
|
|
v <<= 1)
|
|
;
|
|
if (p > 0)
|
|
for (i.iushrn(p); p-- > 0; )
|
|
(s.isOdd() || l.isOdd()) && (s.iadd(d),
|
|
l.isub(u)),
|
|
s.iushrn(1),
|
|
l.iushrn(1);
|
|
t.cmp(i) >= 0 ? (t.isub(i),
|
|
r.isub(s),
|
|
o.isub(l)) : (i.isub(t),
|
|
s.isub(r),
|
|
l.isub(o))
|
|
}
|
|
return {
|
|
a: s,
|
|
b: l,
|
|
gcd: i.iushln(c)
|
|
}
|
|
}
|
|
,
|
|
a.prototype._invmp = function(e) {
|
|
n(0 === e.negative),
|
|
n(!e.isZero());
|
|
var t, i = this, r = e.clone();
|
|
i = 0 !== i.negative ? i.umod(e) : i.clone();
|
|
for (var o = new a(1), s = new a(0), l = r.clone(); i.cmpn(1) > 0 && r.cmpn(1) > 0; ) {
|
|
for (var c = 0, d = 1; (i.words[0] & d) == 0 && c < 26; ++c,
|
|
d <<= 1)
|
|
;
|
|
if (c > 0)
|
|
for (i.iushrn(c); c-- > 0; )
|
|
o.isOdd() && o.iadd(l),
|
|
o.iushrn(1);
|
|
for (var u = 0, f = 1; (r.words[0] & f) == 0 && u < 26; ++u,
|
|
f <<= 1)
|
|
;
|
|
if (u > 0)
|
|
for (r.iushrn(u); u-- > 0; )
|
|
s.isOdd() && s.iadd(l),
|
|
s.iushrn(1);
|
|
i.cmp(r) >= 0 ? (i.isub(r),
|
|
o.isub(s)) : (r.isub(i),
|
|
s.isub(o))
|
|
}
|
|
return 0 > (t = 0 === i.cmpn(1) ? o : s).cmpn(0) && t.iadd(e),
|
|
t
|
|
}
|
|
,
|
|
a.prototype.gcd = function(e) {
|
|
if (this.isZero())
|
|
return e.abs();
|
|
if (e.isZero())
|
|
return this.abs();
|
|
var t = this.clone()
|
|
, i = e.clone();
|
|
t.negative = 0,
|
|
i.negative = 0;
|
|
for (var n = 0; t.isEven() && i.isEven(); n++)
|
|
t.iushrn(1),
|
|
i.iushrn(1);
|
|
for (; ; ) {
|
|
for (; t.isEven(); )
|
|
t.iushrn(1);
|
|
for (; i.isEven(); )
|
|
i.iushrn(1);
|
|
var r = t.cmp(i);
|
|
if (r < 0) {
|
|
var a = t;
|
|
t = i,
|
|
i = a
|
|
} else if (0 === r || 0 === i.cmpn(1))
|
|
break;
|
|
t.isub(i)
|
|
}
|
|
return i.iushln(n)
|
|
}
|
|
,
|
|
a.prototype.invm = function(e) {
|
|
return this.egcd(e).a.umod(e)
|
|
}
|
|
,
|
|
a.prototype.isEven = function() {
|
|
return (1 & this.words[0]) == 0
|
|
}
|
|
,
|
|
a.prototype.isOdd = function() {
|
|
return (1 & this.words[0]) == 1
|
|
}
|
|
,
|
|
a.prototype.andln = function(e) {
|
|
return this.words[0] & e
|
|
}
|
|
,
|
|
a.prototype.bincn = function(e) {
|
|
n("number" == typeof e);
|
|
var t = e % 26
|
|
, i = (e - t) / 26
|
|
, r = 1 << t;
|
|
if (this.length <= i)
|
|
return this._expand(i + 1),
|
|
this.words[i] |= r,
|
|
this;
|
|
for (var a = r, o = i; 0 !== a && o < this.length; o++) {
|
|
var s = 0 | this.words[o];
|
|
s += a,
|
|
a = s >>> 26,
|
|
s &= 0x3ffffff,
|
|
this.words[o] = s
|
|
}
|
|
return 0 !== a && (this.words[o] = a,
|
|
this.length++),
|
|
this
|
|
}
|
|
,
|
|
a.prototype.isZero = function() {
|
|
return 1 === this.length && 0 === this.words[0]
|
|
}
|
|
,
|
|
a.prototype.cmpn = function(e) {
|
|
var t, i = e < 0;
|
|
if (0 !== this.negative && !i)
|
|
return -1;
|
|
if (0 === this.negative && i)
|
|
return 1;
|
|
if (this.strip(),
|
|
this.length > 1)
|
|
t = 1;
|
|
else {
|
|
i && (e = -e),
|
|
n(e <= 0x3ffffff, "Number is too big");
|
|
var r = 0 | this.words[0];
|
|
t = r === e ? 0 : r < e ? -1 : 1
|
|
}
|
|
return 0 !== this.negative ? 0 | -t : t
|
|
}
|
|
,
|
|
a.prototype.cmp = function(e) {
|
|
if (0 !== this.negative && 0 === e.negative)
|
|
return -1;
|
|
if (0 === this.negative && 0 !== e.negative)
|
|
return 1;
|
|
var t = this.ucmp(e);
|
|
return 0 !== this.negative ? 0 | -t : t
|
|
}
|
|
,
|
|
a.prototype.ucmp = function(e) {
|
|
if (this.length > e.length)
|
|
return 1;
|
|
if (this.length < e.length)
|
|
return -1;
|
|
for (var t = 0, i = this.length - 1; i >= 0; i--) {
|
|
var n = 0 | this.words[i]
|
|
, r = 0 | e.words[i];
|
|
if (n !== r) {
|
|
n < r ? t = -1 : n > r && (t = 1);
|
|
break
|
|
}
|
|
}
|
|
return t
|
|
}
|
|
,
|
|
a.prototype.gtn = function(e) {
|
|
return 1 === this.cmpn(e)
|
|
}
|
|
,
|
|
a.prototype.gt = function(e) {
|
|
return 1 === this.cmp(e)
|
|
}
|
|
,
|
|
a.prototype.gten = function(e) {
|
|
return this.cmpn(e) >= 0
|
|
}
|
|
,
|
|
a.prototype.gte = function(e) {
|
|
return this.cmp(e) >= 0
|
|
}
|
|
,
|
|
a.prototype.ltn = function(e) {
|
|
return -1 === this.cmpn(e)
|
|
}
|
|
,
|
|
a.prototype.lt = function(e) {
|
|
return -1 === this.cmp(e)
|
|
}
|
|
,
|
|
a.prototype.lten = function(e) {
|
|
return 0 >= this.cmpn(e)
|
|
}
|
|
,
|
|
a.prototype.lte = function(e) {
|
|
return 0 >= this.cmp(e)
|
|
}
|
|
,
|
|
a.prototype.eqn = function(e) {
|
|
return 0 === this.cmpn(e)
|
|
}
|
|
,
|
|
a.prototype.eq = function(e) {
|
|
return 0 === this.cmp(e)
|
|
}
|
|
,
|
|
a.red = function(e) {
|
|
return new M(e)
|
|
}
|
|
,
|
|
a.prototype.toRed = function(e) {
|
|
return n(!this.red, "Already a number in reduction context"),
|
|
n(0 === this.negative, "red works only with positives"),
|
|
e.convertTo(this)._forceRed(e)
|
|
}
|
|
,
|
|
a.prototype.fromRed = function() {
|
|
return n(this.red, "fromRed works only with numbers in reduction context"),
|
|
this.red.convertFrom(this)
|
|
}
|
|
,
|
|
a.prototype._forceRed = function(e) {
|
|
return this.red = e,
|
|
this
|
|
}
|
|
,
|
|
a.prototype.forceRed = function(e) {
|
|
return n(!this.red, "Already a number in reduction context"),
|
|
this._forceRed(e)
|
|
}
|
|
,
|
|
a.prototype.redAdd = function(e) {
|
|
return n(this.red, "redAdd works only with red numbers"),
|
|
this.red.add(this, e)
|
|
}
|
|
,
|
|
a.prototype.redIAdd = function(e) {
|
|
return n(this.red, "redIAdd works only with red numbers"),
|
|
this.red.iadd(this, e)
|
|
}
|
|
,
|
|
a.prototype.redSub = function(e) {
|
|
return n(this.red, "redSub works only with red numbers"),
|
|
this.red.sub(this, e)
|
|
}
|
|
,
|
|
a.prototype.redISub = function(e) {
|
|
return n(this.red, "redISub works only with red numbers"),
|
|
this.red.isub(this, e)
|
|
}
|
|
,
|
|
a.prototype.redShl = function(e) {
|
|
return n(this.red, "redShl works only with red numbers"),
|
|
this.red.shl(this, e)
|
|
}
|
|
,
|
|
a.prototype.redMul = function(e) {
|
|
return n(this.red, "redMul works only with red numbers"),
|
|
this.red._verify2(this, e),
|
|
this.red.mul(this, e)
|
|
}
|
|
,
|
|
a.prototype.redIMul = function(e) {
|
|
return n(this.red, "redMul works only with red numbers"),
|
|
this.red._verify2(this, e),
|
|
this.red.imul(this, e)
|
|
}
|
|
,
|
|
a.prototype.redSqr = function() {
|
|
return n(this.red, "redSqr works only with red numbers"),
|
|
this.red._verify1(this),
|
|
this.red.sqr(this)
|
|
}
|
|
,
|
|
a.prototype.redISqr = function() {
|
|
return n(this.red, "redISqr works only with red numbers"),
|
|
this.red._verify1(this),
|
|
this.red.isqr(this)
|
|
}
|
|
,
|
|
a.prototype.redSqrt = function() {
|
|
return n(this.red, "redSqrt works only with red numbers"),
|
|
this.red._verify1(this),
|
|
this.red.sqrt(this)
|
|
}
|
|
,
|
|
a.prototype.redInvm = function() {
|
|
return n(this.red, "redInvm works only with red numbers"),
|
|
this.red._verify1(this),
|
|
this.red.invm(this)
|
|
}
|
|
,
|
|
a.prototype.redNeg = function() {
|
|
return n(this.red, "redNeg works only with red numbers"),
|
|
this.red._verify1(this),
|
|
this.red.neg(this)
|
|
}
|
|
,
|
|
a.prototype.redPow = function(e) {
|
|
return n(this.red && !e.red, "redPow(normalNum)"),
|
|
this.red._verify1(this),
|
|
this.red.pow(this, e)
|
|
}
|
|
;
|
|
var y = {
|
|
k256: null,
|
|
p224: null,
|
|
p192: null,
|
|
p25519: null
|
|
};
|
|
function b(e, t) {
|
|
this.name = e,
|
|
this.p = new a(t,16),
|
|
this.n = this.p.bitLength(),
|
|
this.k = new a(1).iushln(this.n).isub(this.p),
|
|
this.tmp = this._tmp()
|
|
}
|
|
function I() {
|
|
b.call(this, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")
|
|
}
|
|
function w() {
|
|
b.call(this, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")
|
|
}
|
|
function x() {
|
|
b.call(this, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")
|
|
}
|
|
function S() {
|
|
b.call(this, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")
|
|
}
|
|
function M(e) {
|
|
if ("string" == typeof e) {
|
|
var t = a._prime(e);
|
|
this.m = t.p,
|
|
this.prime = t
|
|
} else
|
|
n(e.gtn(1), "modulus must be greater than 1"),
|
|
this.m = e,
|
|
this.prime = null
|
|
}
|
|
function C(e) {
|
|
M.call(this, e),
|
|
this.shift = this.m.bitLength(),
|
|
this.shift % 26 != 0 && (this.shift += 26 - this.shift % 26),
|
|
this.r = new a(1).iushln(this.shift),
|
|
this.r2 = this.imod(this.r.sqr()),
|
|
this.rinv = this.r._invmp(this.m),
|
|
this.minv = this.rinv.mul(this.r).isubn(1).div(this.m),
|
|
this.minv = this.minv.umod(this.r),
|
|
this.minv = this.r.sub(this.minv)
|
|
}
|
|
b.prototype._tmp = function() {
|
|
var e = new a(null);
|
|
return e.words = Array(Math.ceil(this.n / 13)),
|
|
e
|
|
}
|
|
,
|
|
b.prototype.ireduce = function(e) {
|
|
var t, i = e;
|
|
do
|
|
this.split(i, this.tmp),
|
|
t = (i = (i = this.imulK(i)).iadd(this.tmp)).bitLength();
|
|
while (t > this.n);
|
|
var n = t < this.n ? -1 : i.ucmp(this.p);
|
|
return 0 === n ? (i.words[0] = 0,
|
|
i.length = 1) : n > 0 ? i.isub(this.p) : void 0 !== i.strip ? i.strip() : i._strip(),
|
|
i
|
|
}
|
|
,
|
|
b.prototype.split = function(e, t) {
|
|
e.iushrn(this.n, 0, t)
|
|
}
|
|
,
|
|
b.prototype.imulK = function(e) {
|
|
return e.imul(this.k)
|
|
}
|
|
,
|
|
r(I, b),
|
|
I.prototype.split = function(e, t) {
|
|
for (var i = 4194303, n = Math.min(e.length, 9), r = 0; r < n; r++)
|
|
t.words[r] = e.words[r];
|
|
if (t.length = n,
|
|
e.length <= 9) {
|
|
e.words[0] = 0,
|
|
e.length = 1;
|
|
return
|
|
}
|
|
var a = e.words[9];
|
|
for (r = 10,
|
|
t.words[t.length++] = a & i; r < e.length; r++) {
|
|
var o = 0 | e.words[r];
|
|
e.words[r - 10] = (o & i) << 4 | a >>> 22,
|
|
a = o
|
|
}
|
|
a >>>= 22,
|
|
e.words[r - 10] = a,
|
|
0 === a && e.length > 10 ? e.length -= 10 : e.length -= 9
|
|
}
|
|
,
|
|
I.prototype.imulK = function(e) {
|
|
e.words[e.length] = 0,
|
|
e.words[e.length + 1] = 0,
|
|
e.length += 2;
|
|
for (var t = 0, i = 0; i < e.length; i++) {
|
|
var n = 0 | e.words[i];
|
|
t += 977 * n,
|
|
e.words[i] = 0x3ffffff & t,
|
|
t = 64 * n + (t / 0x4000000 | 0)
|
|
}
|
|
return 0 === e.words[e.length - 1] && (e.length--,
|
|
0 === e.words[e.length - 1] && e.length--),
|
|
e
|
|
}
|
|
,
|
|
r(w, b),
|
|
r(x, b),
|
|
r(S, b),
|
|
S.prototype.imulK = function(e) {
|
|
for (var t = 0, i = 0; i < e.length; i++) {
|
|
var n = (0 | e.words[i]) * 19 + t
|
|
, r = 0x3ffffff & n;
|
|
n >>>= 26,
|
|
e.words[i] = r,
|
|
t = n
|
|
}
|
|
return 0 !== t && (e.words[e.length++] = t),
|
|
e
|
|
}
|
|
,
|
|
a._prime = function(e) {
|
|
var t;
|
|
if (y[e])
|
|
return y[e];
|
|
if ("k256" === e)
|
|
t = new I;
|
|
else if ("p224" === e)
|
|
t = new w;
|
|
else if ("p192" === e)
|
|
t = new x;
|
|
else if ("p25519" === e)
|
|
t = new S;
|
|
else
|
|
throw Error("Unknown prime " + e);
|
|
return y[e] = t,
|
|
t
|
|
}
|
|
,
|
|
M.prototype._verify1 = function(e) {
|
|
n(0 === e.negative, "red works only with positives"),
|
|
n(e.red, "red works only with red numbers")
|
|
}
|
|
,
|
|
M.prototype._verify2 = function(e, t) {
|
|
n((e.negative | t.negative) == 0, "red works only with positives"),
|
|
n(e.red && e.red === t.red, "red works only with red numbers")
|
|
}
|
|
,
|
|
M.prototype.imod = function(e) {
|
|
return this.prime ? this.prime.ireduce(e)._forceRed(this) : e.umod(this.m)._forceRed(this)
|
|
}
|
|
,
|
|
M.prototype.neg = function(e) {
|
|
return e.isZero() ? e.clone() : this.m.sub(e)._forceRed(this)
|
|
}
|
|
,
|
|
M.prototype.add = function(e, t) {
|
|
this._verify2(e, t);
|
|
var i = e.add(t);
|
|
return i.cmp(this.m) >= 0 && i.isub(this.m),
|
|
i._forceRed(this)
|
|
}
|
|
,
|
|
M.prototype.iadd = function(e, t) {
|
|
this._verify2(e, t);
|
|
var i = e.iadd(t);
|
|
return i.cmp(this.m) >= 0 && i.isub(this.m),
|
|
i
|
|
}
|
|
,
|
|
M.prototype.sub = function(e, t) {
|
|
this._verify2(e, t);
|
|
var i = e.sub(t);
|
|
return 0 > i.cmpn(0) && i.iadd(this.m),
|
|
i._forceRed(this)
|
|
}
|
|
,
|
|
M.prototype.isub = function(e, t) {
|
|
this._verify2(e, t);
|
|
var i = e.isub(t);
|
|
return 0 > i.cmpn(0) && i.iadd(this.m),
|
|
i
|
|
}
|
|
,
|
|
M.prototype.shl = function(e, t) {
|
|
return this._verify1(e),
|
|
this.imod(e.ushln(t))
|
|
}
|
|
,
|
|
M.prototype.imul = function(e, t) {
|
|
return this._verify2(e, t),
|
|
this.imod(e.imul(t))
|
|
}
|
|
,
|
|
M.prototype.mul = function(e, t) {
|
|
return this._verify2(e, t),
|
|
this.imod(e.mul(t))
|
|
}
|
|
,
|
|
M.prototype.isqr = function(e) {
|
|
return this.imul(e, e.clone())
|
|
}
|
|
,
|
|
M.prototype.sqr = function(e) {
|
|
return this.mul(e, e)
|
|
}
|
|
,
|
|
M.prototype.sqrt = function(e) {
|
|
if (e.isZero())
|
|
return e.clone();
|
|
var t = this.m.andln(3);
|
|
if (n(t % 2 == 1),
|
|
3 === t) {
|
|
var i = this.m.add(new a(1)).iushrn(2);
|
|
return this.pow(e, i)
|
|
}
|
|
for (var r = this.m.subn(1), o = 0; !r.isZero() && 0 === r.andln(1); )
|
|
o++,
|
|
r.iushrn(1);
|
|
n(!r.isZero());
|
|
var s = new a(1).toRed(this)
|
|
, l = s.redNeg()
|
|
, c = this.m.subn(1).iushrn(1)
|
|
, d = this.m.bitLength();
|
|
for (d = new a(2 * d * d).toRed(this); 0 !== this.pow(d, c).cmp(l); )
|
|
d.redIAdd(l);
|
|
for (var u = this.pow(d, r), f = this.pow(e, r.addn(1).iushrn(1)), h = this.pow(e, r), p = o; 0 !== h.cmp(s); ) {
|
|
for (var v = h, m = 0; 0 !== v.cmp(s); m++)
|
|
v = v.redSqr();
|
|
n(m < p);
|
|
var g = this.pow(u, new a(1).iushln(p - m - 1));
|
|
f = f.redMul(g),
|
|
u = g.redSqr(),
|
|
h = h.redMul(u),
|
|
p = m
|
|
}
|
|
return f
|
|
}
|
|
,
|
|
M.prototype.invm = function(e) {
|
|
var t = e._invmp(this.m);
|
|
return 0 !== t.negative ? (t.negative = 0,
|
|
this.imod(t).redNeg()) : this.imod(t)
|
|
}
|
|
,
|
|
M.prototype.pow = function(e, t) {
|
|
if (t.isZero())
|
|
return new a(1).toRed(this);
|
|
if (0 === t.cmpn(1))
|
|
return e.clone();
|
|
var i = 4
|
|
, n = Array(16);
|
|
n[0] = new a(1).toRed(this),
|
|
n[1] = e;
|
|
for (var r = 2; r < n.length; r++)
|
|
n[r] = this.mul(n[r - 1], e);
|
|
var o = n[0]
|
|
, s = 0
|
|
, l = 0
|
|
, c = t.bitLength() % 26;
|
|
for (0 === c && (c = 26),
|
|
r = t.length - 1; r >= 0; r--) {
|
|
for (var d = t.words[r], u = c - 1; u >= 0; u--) {
|
|
var f = d >> u & 1;
|
|
if (o !== n[0] && (o = this.sqr(o)),
|
|
0 === f && 0 === s) {
|
|
l = 0;
|
|
continue
|
|
}
|
|
s <<= 1,
|
|
s |= f,
|
|
(++l === i || 0 === r && 0 === u) && (o = this.mul(o, n[s]),
|
|
l = 0,
|
|
s = 0)
|
|
}
|
|
c = 26
|
|
}
|
|
return o
|
|
}
|
|
,
|
|
M.prototype.convertTo = function(e) {
|
|
var t = e.umod(this.m);
|
|
return t === e ? t.clone() : t
|
|
}
|
|
,
|
|
M.prototype.convertFrom = function(e) {
|
|
var t = e.clone();
|
|
return t.red = null,
|
|
t
|
|
}
|
|
,
|
|
a.mont = function(e) {
|
|
return new C(e)
|
|
}
|
|
,
|
|
r(C, M),
|
|
C.prototype.convertTo = function(e) {
|
|
return this.imod(e.ushln(this.shift))
|
|
}
|
|
,
|
|
C.prototype.convertFrom = function(e) {
|
|
var t = this.imod(e.mul(this.rinv));
|
|
return t.red = null,
|
|
t
|
|
}
|
|
,
|
|
C.prototype.imul = function(e, t) {
|
|
if (e.isZero() || t.isZero())
|
|
return e.words[0] = 0,
|
|
e.length = 1,
|
|
e;
|
|
var i = e.imul(t)
|
|
, n = i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m)
|
|
, r = i.isub(n).iushrn(this.shift)
|
|
, a = r;
|
|
return r.cmp(this.m) >= 0 ? a = r.isub(this.m) : 0 > r.cmpn(0) && (a = r.iadd(this.m)),
|
|
a._forceRed(this)
|
|
}
|
|
,
|
|
C.prototype.mul = function(e, t) {
|
|
if (e.isZero() || t.isZero())
|
|
return new a(0)._forceRed(this);
|
|
var i = e.mul(t)
|
|
, n = i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m)
|
|
, r = i.isub(n).iushrn(this.shift)
|
|
, o = r;
|
|
return r.cmp(this.m) >= 0 ? o = r.isub(this.m) : 0 > r.cmpn(0) && (o = r.iadd(this.m)),
|
|
o._forceRed(this)
|
|
}
|
|
,
|
|
C.prototype.invm = function(e) {
|
|
return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)
|
|
}
|
|
}(e = i.nmd(e), this)
|
|
}
|
|
|
|
function T966465(t, e, r) {
|
|
"use strict";
|
|
let n = r(814800)
|
|
, o = r(933977)
|
|
, i = "function" == typeof Symbol && "function" == typeof Symbol.for ? Symbol.for("nodejs.util.inspect.custom") : null;
|
|
e.Buffer = s,
|
|
e.SlowBuffer = function(t) {
|
|
return +t != t && (t = 0),
|
|
s.alloc(+t)
|
|
}
|
|
,
|
|
e.INSPECT_MAX_BYTES = 50;
|
|
e.kMaxLength = 0x7fffffff,
|
|
s.TYPED_ARRAY_SUPPORT = function() {
|
|
try {
|
|
let t = new Uint8Array(1)
|
|
, e = {
|
|
foo: function() {
|
|
return 42
|
|
}
|
|
};
|
|
return Object.setPrototypeOf(e, Uint8Array.prototype),
|
|
Object.setPrototypeOf(t, e),
|
|
42 === t.foo()
|
|
} catch (t) {
|
|
return !1
|
|
}
|
|
}(),
|
|
!s.TYPED_ARRAY_SUPPORT && "undefined" != typeof console && "function" == typeof console.error && console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");
|
|
function a(t) {
|
|
if (t > 0x7fffffff)
|
|
throw RangeError('The value "' + t + '" is invalid for option "size"');
|
|
let e = new Uint8Array(t);
|
|
return Object.setPrototypeOf(e, s.prototype),
|
|
e
|
|
}
|
|
function s(t, e, r) {
|
|
if ("number" == typeof t) {
|
|
if ("string" == typeof e)
|
|
throw TypeError('The "string" argument must be of type string. Received type number');
|
|
return f(t)
|
|
}
|
|
return u(t, e, r)
|
|
}
|
|
function u(t, e, r) {
|
|
if ("string" == typeof t)
|
|
return function(t, e) {
|
|
if (("string" != typeof e || "" === e) && (e = "utf8"),
|
|
!s.isEncoding(e))
|
|
throw TypeError("Unknown encoding: " + e);
|
|
let r = 0 | d(t, e)
|
|
, n = a(r)
|
|
, o = n.write(t, e);
|
|
return o !== r && (n = n.slice(0, o)),
|
|
n
|
|
}(t, e);
|
|
if (ArrayBuffer.isView(t))
|
|
return function(t) {
|
|
if (U(t, Uint8Array)) {
|
|
let e = new Uint8Array(t);
|
|
return h(e.buffer, e.byteOffset, e.byteLength)
|
|
}
|
|
return l(t)
|
|
}(t);
|
|
if (null == t)
|
|
throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof t);
|
|
if (U(t, ArrayBuffer) || t && U(t.buffer, ArrayBuffer) || "undefined" != typeof SharedArrayBuffer && (U(t, SharedArrayBuffer) || t && U(t.buffer, SharedArrayBuffer)))
|
|
return h(t, e, r);
|
|
if ("number" == typeof t)
|
|
throw TypeError('The "value" argument must not be of type number. Received type number');
|
|
let n = t.valueOf && t.valueOf();
|
|
if (null != n && n !== t)
|
|
return s.from(n, e, r);
|
|
let o = function(t) {
|
|
if (s.isBuffer(t)) {
|
|
let e = 0 | p(t.length)
|
|
, r = a(e);
|
|
return 0 === r.length ? r : (t.copy(r, 0, 0, e),
|
|
r)
|
|
}
|
|
if (void 0 !== t.length)
|
|
return "number" != typeof t.length || B(t.length) ? a(0) : l(t);
|
|
if ("Buffer" === t.type && Array.isArray(t.data))
|
|
return l(t.data)
|
|
}(t);
|
|
if (o)
|
|
return o;
|
|
if ("undefined" != typeof Symbol && null != Symbol.toPrimitive && "function" == typeof t[Symbol.toPrimitive])
|
|
return s.from(t[Symbol.toPrimitive]("string"), e, r);
|
|
throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof t)
|
|
}
|
|
function c(t) {
|
|
if ("number" != typeof t)
|
|
throw TypeError('"size" argument must be of type number');
|
|
if (t < 0)
|
|
throw RangeError('The value "' + t + '" is invalid for option "size"')
|
|
}
|
|
Object.defineProperty(s.prototype, "parent", {
|
|
enumerable: !0,
|
|
get: function() {
|
|
if (s.isBuffer(this))
|
|
return this.buffer
|
|
}
|
|
}),
|
|
Object.defineProperty(s.prototype, "offset", {
|
|
enumerable: !0,
|
|
get: function() {
|
|
if (s.isBuffer(this))
|
|
return this.byteOffset
|
|
}
|
|
}),
|
|
s.poolSize = 8192,
|
|
s.from = function(t, e, r) {
|
|
return u(t, e, r)
|
|
}
|
|
,
|
|
Object.setPrototypeOf(s.prototype, Uint8Array.prototype),
|
|
Object.setPrototypeOf(s, Uint8Array);
|
|
function f(t) {
|
|
return c(t),
|
|
a(t < 0 ? 0 : 0 | p(t))
|
|
}
|
|
s.alloc = function(t, e, r) {
|
|
var n, o, i;
|
|
return n = t,
|
|
o = e,
|
|
i = r,
|
|
(c(n),
|
|
n <= 0) ? a(n) : void 0 !== o ? "string" == typeof i ? a(n).fill(o, i) : a(n).fill(o) : a(n)
|
|
}
|
|
,
|
|
s.allocUnsafe = function(t) {
|
|
return f(t)
|
|
}
|
|
,
|
|
s.allocUnsafeSlow = function(t) {
|
|
return f(t)
|
|
}
|
|
;
|
|
function l(t) {
|
|
let e = t.length < 0 ? 0 : 0 | p(t.length)
|
|
, r = a(e);
|
|
for (let n = 0; n < e; n += 1)
|
|
r[n] = 255 & t[n];
|
|
return r
|
|
}
|
|
function h(t, e, r) {
|
|
let n;
|
|
if (e < 0 || t.byteLength < e)
|
|
throw RangeError('"offset" is outside of buffer bounds');
|
|
if (t.byteLength < e + (r || 0))
|
|
throw RangeError('"length" is outside of buffer bounds');
|
|
return Object.setPrototypeOf(n = void 0 === e && void 0 === r ? new Uint8Array(t) : void 0 === r ? new Uint8Array(t,e) : new Uint8Array(t,e,r), s.prototype),
|
|
n
|
|
}
|
|
function p(t) {
|
|
if (t >= 0x7fffffff)
|
|
throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + "7fffffff bytes");
|
|
return 0 | t
|
|
}
|
|
function d(t, e) {
|
|
if (s.isBuffer(t))
|
|
return t.length;
|
|
if (ArrayBuffer.isView(t) || U(t, ArrayBuffer))
|
|
return t.byteLength;
|
|
if ("string" != typeof t)
|
|
throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof t);
|
|
let r = t.length
|
|
, n = arguments.length > 2 && !0 === arguments[2];
|
|
if (!n && 0 === r)
|
|
return 0;
|
|
let o = !1;
|
|
for (; ; )
|
|
switch (e) {
|
|
case "ascii":
|
|
case "latin1":
|
|
case "binary":
|
|
return r;
|
|
case "utf8":
|
|
case "utf-8":
|
|
return L(t).length;
|
|
case "ucs2":
|
|
case "ucs-2":
|
|
case "utf16le":
|
|
case "utf-16le":
|
|
return 2 * r;
|
|
case "hex":
|
|
return r >>> 1;
|
|
case "base64":
|
|
return M(t).length;
|
|
default:
|
|
if (o)
|
|
return n ? -1 : L(t).length;
|
|
e = ("" + e).toLowerCase(),
|
|
o = !0
|
|
}
|
|
}
|
|
function v(t, e, r) {
|
|
let o = !1;
|
|
if ((void 0 === e || e < 0) && (e = 0),
|
|
e > this.length)
|
|
return "";
|
|
if ((void 0 === r || r > this.length) && (r = this.length),
|
|
r <= 0 || (r >>>= 0) <= (e >>>= 0))
|
|
return "";
|
|
for (!t && (t = "utf8"); ; )
|
|
switch (t) {
|
|
case "hex":
|
|
return function(t, e, r) {
|
|
let n = t.length;
|
|
(!e || e < 0) && (e = 0),
|
|
(!r || r < 0 || r > n) && (r = n);
|
|
let o = "";
|
|
for (let n = e; n < r; ++n)
|
|
o += D[t[n]];
|
|
return o
|
|
}(this, e, r);
|
|
case "utf8":
|
|
case "utf-8":
|
|
return b(this, e, r);
|
|
case "ascii":
|
|
return function(t, e, r) {
|
|
let n = "";
|
|
r = Math.min(t.length, r);
|
|
for (let o = e; o < r; ++o)
|
|
n += String.fromCharCode(127 & t[o]);
|
|
return n
|
|
}(this, e, r);
|
|
case "latin1":
|
|
case "binary":
|
|
return function(t, e, r) {
|
|
let n = "";
|
|
r = Math.min(t.length, r);
|
|
for (let o = e; o < r; ++o)
|
|
n += String.fromCharCode(t[o]);
|
|
return n
|
|
}(this, e, r);
|
|
case "base64":
|
|
return function(t, e, r) {
|
|
return 0 === e && r === t.length ? n.fromByteArray(t) : n.fromByteArray(t.slice(e, r))
|
|
}(this, e, r);
|
|
case "ucs2":
|
|
case "ucs-2":
|
|
case "utf16le":
|
|
case "utf-16le":
|
|
return function(t, e, r) {
|
|
let n = t.slice(e, r)
|
|
, o = "";
|
|
for (let t = 0; t < n.length - 1; t += 2)
|
|
o += String.fromCharCode(n[t] + 256 * n[t + 1]);
|
|
return o
|
|
}(this, e, r);
|
|
default:
|
|
if (o)
|
|
throw TypeError("Unknown encoding: " + t);
|
|
t = (t + "").toLowerCase(),
|
|
o = !0
|
|
}
|
|
}
|
|
function g(t, e, r) {
|
|
let n = t[e];
|
|
t[e] = t[r],
|
|
t[r] = n
|
|
}
|
|
function y(t, e, r, n, o) {
|
|
if (0 === t.length)
|
|
return -1;
|
|
if ("string" == typeof r ? (n = r,
|
|
r = 0) : r > 0x7fffffff ? r = 0x7fffffff : r < -0x80000000 && (r = -0x80000000),
|
|
function(t) {
|
|
return t != t
|
|
}(r = +r) && (r = o ? 0 : t.length - 1),
|
|
r < 0 && (r = t.length + r),
|
|
r >= t.length) {
|
|
if (o)
|
|
return -1;
|
|
r = t.length - 1
|
|
} else if (r < 0) {
|
|
if (!o)
|
|
return -1;
|
|
r = 0
|
|
}
|
|
if ("string" == typeof e && (e = s.from(e, n)),
|
|
s.isBuffer(e))
|
|
return 0 === e.length ? -1 : m(t, e, r, n, o);
|
|
if ("number" == typeof e) {
|
|
if (e &= 255,
|
|
"function" == typeof Uint8Array.prototype.indexOf)
|
|
return o ? Uint8Array.prototype.indexOf.call(t, e, r) : Uint8Array.prototype.lastIndexOf.call(t, e, r);
|
|
return m(t, [e], r, n, o)
|
|
}
|
|
throw TypeError("val must be string, number or Buffer")
|
|
}
|
|
function m(t, e, r, n, o) {
|
|
let i, a = 1, s = t.length, u = e.length;
|
|
if (void 0 !== n && ("ucs2" === (n = String(n).toLowerCase()) || "ucs-2" === n || "utf16le" === n || "utf-16le" === n)) {
|
|
if (t.length < 2 || e.length < 2)
|
|
return -1;
|
|
a = 2,
|
|
s /= 2,
|
|
u /= 2,
|
|
r /= 2
|
|
}
|
|
function c(t, e) {
|
|
return 1 === a ? t[e] : t.readUInt16BE(e * a)
|
|
}
|
|
if (o) {
|
|
let n = -1;
|
|
for (i = r; i < s; i++)
|
|
if (c(t, i) === c(e, -1 === n ? 0 : i - n)) {
|
|
if (-1 === n && (n = i),
|
|
i - n + 1 === u)
|
|
return n * a
|
|
} else
|
|
-1 !== n && (i -= i - n),
|
|
n = -1
|
|
} else
|
|
for (r + u > s && (r = s - u),
|
|
i = r; i >= 0; i--) {
|
|
let r = !0;
|
|
for (let n = 0; n < u; n++)
|
|
if (c(t, i + n) !== c(e, n)) {
|
|
r = !1;
|
|
break
|
|
}
|
|
if (r)
|
|
return i
|
|
}
|
|
return -1
|
|
}
|
|
s.isBuffer = function(t) {
|
|
return null != t && !0 === t._isBuffer && t !== s.prototype
|
|
}
|
|
,
|
|
s.compare = function(t, e) {
|
|
if (U(t, Uint8Array) && (t = s.from(t, t.offset, t.byteLength)),
|
|
U(e, Uint8Array) && (e = s.from(e, e.offset, e.byteLength)),
|
|
!s.isBuffer(t) || !s.isBuffer(e))
|
|
throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');
|
|
if (t === e)
|
|
return 0;
|
|
let r = t.length
|
|
, n = e.length;
|
|
for (let o = 0, i = Math.min(r, n); o < i; ++o)
|
|
if (t[o] !== e[o]) {
|
|
r = t[o],
|
|
n = e[o];
|
|
break
|
|
}
|
|
return r < n ? -1 : n < r ? 1 : 0
|
|
}
|
|
,
|
|
s.isEncoding = function(t) {
|
|
switch (String(t).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
|
|
}
|
|
}
|
|
,
|
|
s.concat = function(t, e) {
|
|
let r;
|
|
if (!Array.isArray(t))
|
|
throw TypeError('"list" argument must be an Array of Buffers');
|
|
if (0 === t.length)
|
|
return s.alloc(0);
|
|
if (void 0 === e)
|
|
for (r = 0,
|
|
e = 0; r < t.length; ++r)
|
|
e += t[r].length;
|
|
let n = s.allocUnsafe(e)
|
|
, o = 0;
|
|
for (r = 0; r < t.length; ++r) {
|
|
let e = t[r];
|
|
if (U(e, Uint8Array))
|
|
o + e.length > n.length ? (!s.isBuffer(e) && (e = s.from(e)),
|
|
e.copy(n, o)) : Uint8Array.prototype.set.call(n, e, o);
|
|
else if (s.isBuffer(e))
|
|
e.copy(n, o);
|
|
else
|
|
throw TypeError('"list" argument must be an Array of Buffers');
|
|
o += e.length
|
|
}
|
|
return n
|
|
}
|
|
,
|
|
s.byteLength = d,
|
|
s.prototype._isBuffer = !0,
|
|
s.prototype.swap16 = function() {
|
|
let t = this.length;
|
|
if (t % 2 != 0)
|
|
throw RangeError("Buffer size must be a multiple of 16-bits");
|
|
for (let e = 0; e < t; e += 2)
|
|
g(this, e, e + 1);
|
|
return this
|
|
}
|
|
,
|
|
s.prototype.swap32 = function() {
|
|
let t = this.length;
|
|
if (t % 4 != 0)
|
|
throw RangeError("Buffer size must be a multiple of 32-bits");
|
|
for (let e = 0; e < t; e += 4)
|
|
g(this, e, e + 3),
|
|
g(this, e + 1, e + 2);
|
|
return this
|
|
}
|
|
,
|
|
s.prototype.swap64 = function() {
|
|
let t = this.length;
|
|
if (t % 8 != 0)
|
|
throw RangeError("Buffer size must be a multiple of 64-bits");
|
|
for (let e = 0; e < t; e += 8)
|
|
g(this, e, e + 7),
|
|
g(this, e + 1, e + 6),
|
|
g(this, e + 2, e + 5),
|
|
g(this, e + 3, e + 4);
|
|
return this
|
|
}
|
|
,
|
|
s.prototype.toString = function() {
|
|
let t = this.length;
|
|
return 0 === t ? "" : 0 == arguments.length ? b(this, 0, t) : v.apply(this, arguments)
|
|
}
|
|
,
|
|
s.prototype.toLocaleString = s.prototype.toString,
|
|
s.prototype.equals = function(t) {
|
|
if (!s.isBuffer(t))
|
|
throw TypeError("Argument must be a Buffer");
|
|
return this === t || 0 === s.compare(this, t)
|
|
}
|
|
,
|
|
s.prototype.inspect = function() {
|
|
let t = ""
|
|
, r = e.INSPECT_MAX_BYTES;
|
|
return t = this.toString("hex", 0, r).replace(/(.{2})/g, "$1 ").trim(),
|
|
this.length > r && (t += " ... "),
|
|
"<Buffer " + t + ">"
|
|
}
|
|
,
|
|
i && (s.prototype[i] = s.prototype.inspect),
|
|
s.prototype.compare = function(t, e, r, n, o) {
|
|
if (U(t, Uint8Array) && (t = s.from(t, t.offset, t.byteLength)),
|
|
!s.isBuffer(t))
|
|
throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof t);
|
|
if (void 0 === e && (e = 0),
|
|
void 0 === r && (r = t ? t.length : 0),
|
|
void 0 === n && (n = 0),
|
|
void 0 === o && (o = this.length),
|
|
e < 0 || r > t.length || n < 0 || o > this.length)
|
|
throw RangeError("out of range index");
|
|
if (n >= o && e >= r)
|
|
return 0;
|
|
if (n >= o)
|
|
return -1;
|
|
if (e >= r)
|
|
return 1;
|
|
if (e >>>= 0,
|
|
r >>>= 0,
|
|
n >>>= 0,
|
|
o >>>= 0,
|
|
this === t)
|
|
return 0;
|
|
let i = o - n
|
|
, a = r - e
|
|
, u = Math.min(i, a)
|
|
, c = this.slice(n, o)
|
|
, f = t.slice(e, r);
|
|
for (let t = 0; t < u; ++t)
|
|
if (c[t] !== f[t]) {
|
|
i = c[t],
|
|
a = f[t];
|
|
break
|
|
}
|
|
return i < a ? -1 : a < i ? 1 : 0
|
|
}
|
|
,
|
|
s.prototype.includes = function(t, e, r) {
|
|
return -1 !== this.indexOf(t, e, r)
|
|
}
|
|
,
|
|
s.prototype.indexOf = function(t, e, r) {
|
|
return y(this, t, e, r, !0)
|
|
}
|
|
,
|
|
s.prototype.lastIndexOf = function(t, e, r) {
|
|
return y(this, t, e, r, !1)
|
|
}
|
|
;
|
|
s.prototype.write = function(t, e, r, n) {
|
|
var o, i, a, s, u, c, f, l, h, p, d, v, g, y, m, b;
|
|
if (void 0 === e)
|
|
n = "utf8",
|
|
r = this.length,
|
|
e = 0;
|
|
else if (void 0 === r && "string" == typeof e)
|
|
n = e,
|
|
r = this.length,
|
|
e = 0;
|
|
else if (isFinite(e))
|
|
e >>>= 0,
|
|
isFinite(r) ? (r >>>= 0,
|
|
void 0 === n && (n = "utf8")) : (n = r,
|
|
r = void 0);
|
|
else
|
|
throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
|
|
let w = this.length - e;
|
|
if ((void 0 === r || r > w) && (r = w),
|
|
t.length > 0 && (r < 0 || e < 0) || e > this.length)
|
|
throw RangeError("Attempt to write outside buffer bounds");
|
|
!n && (n = "utf8");
|
|
let x = !1;
|
|
for (; ; )
|
|
switch (n) {
|
|
case "hex":
|
|
return function(t, e, r, n) {
|
|
let o;
|
|
r = Number(r) || 0;
|
|
let i = t.length - r;
|
|
n ? (n = Number(n)) > i && (n = i) : n = i;
|
|
let a = e.length;
|
|
for (n > a / 2 && (n = a / 2),
|
|
o = 0; o < n; ++o) {
|
|
let n = parseInt(e.substr(2 * o, 2), 16);
|
|
if (function(t) {
|
|
return t != t
|
|
}(n))
|
|
break;
|
|
t[r + o] = n
|
|
}
|
|
return o
|
|
}(this, t, e, r);
|
|
case "utf8":
|
|
case "utf-8":
|
|
;return o = this,
|
|
i = t,
|
|
a = e,
|
|
s = r,
|
|
N(L(i, o.length - a), o, a, s);
|
|
case "ascii":
|
|
case "latin1":
|
|
case "binary":
|
|
;return u = this,
|
|
c = t,
|
|
f = e,
|
|
l = r,
|
|
N(function(t) {
|
|
let e = [];
|
|
for (let r = 0; r < t.length; ++r)
|
|
e.push(255 & t.charCodeAt(r));
|
|
return e
|
|
}(c), u, f, l);
|
|
case "base64":
|
|
;return h = this,
|
|
p = t,
|
|
d = e,
|
|
v = r,
|
|
N(M(p), h, d, v);
|
|
case "ucs2":
|
|
case "ucs-2":
|
|
case "utf16le":
|
|
case "utf-16le":
|
|
;return g = this,
|
|
y = t,
|
|
m = e,
|
|
b = r,
|
|
N(function(t, e) {
|
|
let r, n, o;
|
|
let i = [];
|
|
for (let a = 0; a < t.length && !((e -= 2) < 0); ++a)
|
|
n = (r = t.charCodeAt(a)) >> 8,
|
|
o = r % 256,
|
|
i.push(o),
|
|
i.push(n);
|
|
return i
|
|
}(y, g.length - m), g, m, b);
|
|
default:
|
|
if (x)
|
|
throw TypeError("Unknown encoding: " + n);
|
|
n = ("" + n).toLowerCase(),
|
|
x = !0
|
|
}
|
|
}
|
|
,
|
|
s.prototype.toJSON = function() {
|
|
return {
|
|
type: "Buffer",
|
|
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
}
|
|
}
|
|
;
|
|
function b(t, e, r) {
|
|
r = Math.min(t.length, r);
|
|
let n = []
|
|
, o = e;
|
|
for (; o < r; ) {
|
|
let e = t[o]
|
|
, i = null
|
|
, a = e > 239 ? 4 : e > 223 ? 3 : e > 191 ? 2 : 1;
|
|
if (o + a <= r) {
|
|
let r, n, s, u;
|
|
switch (a) {
|
|
case 1:
|
|
e < 128 && (i = e);
|
|
break;
|
|
case 2:
|
|
(192 & (r = t[o + 1])) == 128 && (u = (31 & e) << 6 | 63 & r) > 127 && (i = u);
|
|
break;
|
|
case 3:
|
|
r = t[o + 1],
|
|
n = t[o + 2],
|
|
(192 & r) == 128 && (192 & n) == 128 && (u = (15 & e) << 12 | (63 & r) << 6 | 63 & n) > 2047 && (u < 55296 || u > 57343) && (i = u);
|
|
break;
|
|
case 4:
|
|
r = t[o + 1],
|
|
n = t[o + 2],
|
|
s = t[o + 3],
|
|
(192 & r) == 128 && (192 & n) == 128 && (192 & s) == 128 && (u = (15 & e) << 18 | (63 & r) << 12 | (63 & n) << 6 | 63 & s) > 65535 && u < 1114112 && (i = u)
|
|
}
|
|
}
|
|
null === i ? (i = 65533,
|
|
a = 1) : i > 65535 && (i -= 65536,
|
|
n.push(i >>> 10 & 1023 | 55296),
|
|
i = 56320 | 1023 & i),
|
|
n.push(i),
|
|
o += a
|
|
}
|
|
return function(t) {
|
|
let e = t.length;
|
|
if (e <= 4096)
|
|
return String.fromCharCode.apply(String, t);
|
|
let r = ""
|
|
, n = 0;
|
|
for (; n < e; )
|
|
r += String.fromCharCode.apply(String, t.slice(n, n += 4096));
|
|
return r
|
|
}(n)
|
|
}
|
|
function w(t, e, r) {
|
|
if (t % 1 != 0 || t < 0)
|
|
throw RangeError("offset is not uint");
|
|
if (t + e > r)
|
|
throw RangeError("Trying to access beyond buffer length")
|
|
}
|
|
function x(t, e, r, n, o, i) {
|
|
if (!s.isBuffer(t))
|
|
throw TypeError('"buffer" argument must be a Buffer instance');
|
|
if (e > o || e < i)
|
|
throw RangeError('"value" argument is out of bounds');
|
|
if (r + n > t.length)
|
|
throw RangeError("Index out of range")
|
|
}
|
|
function E(t, e, r, n, o) {
|
|
k(e, n, o, t, r, 7);
|
|
let i = Number(e & BigInt(0xffffffff));
|
|
t[r++] = i,
|
|
i >>= 8,
|
|
t[r++] = i,
|
|
i >>= 8,
|
|
t[r++] = i,
|
|
i >>= 8,
|
|
t[r++] = i;
|
|
let a = Number(e >> BigInt(32) & BigInt(0xffffffff));
|
|
return t[r++] = a,
|
|
a >>= 8,
|
|
t[r++] = a,
|
|
a >>= 8,
|
|
t[r++] = a,
|
|
a >>= 8,
|
|
t[r++] = a,
|
|
r
|
|
}
|
|
function S(t, e, r, n, o) {
|
|
k(e, n, o, t, r, 7);
|
|
let i = Number(e & BigInt(0xffffffff));
|
|
t[r + 7] = i,
|
|
i >>= 8,
|
|
t[r + 6] = i,
|
|
i >>= 8,
|
|
t[r + 5] = i,
|
|
i >>= 8,
|
|
t[r + 4] = i;
|
|
let a = Number(e >> BigInt(32) & BigInt(0xffffffff));
|
|
return t[r + 3] = a,
|
|
a >>= 8,
|
|
t[r + 2] = a,
|
|
a >>= 8,
|
|
t[r + 1] = a,
|
|
a >>= 8,
|
|
t[r] = a,
|
|
r + 8
|
|
}
|
|
function A(t, e, r, n, o, i) {
|
|
if (r + n > t.length || r < 0)
|
|
throw RangeError("Index out of range")
|
|
}
|
|
function O(t, e, r, n, i) {
|
|
return e = +e,
|
|
r >>>= 0,
|
|
!i && A(t, e, r, 4, 34028234663852886e22, -34028234663852886e22),
|
|
o.write(t, e, r, n, 23, 4),
|
|
r + 4
|
|
}
|
|
function T(t, e, r, n, i) {
|
|
return e = +e,
|
|
r >>>= 0,
|
|
!i && A(t, e, r, 8, 17976931348623157e292, -17976931348623157e292),
|
|
o.write(t, e, r, n, 52, 8),
|
|
r + 8
|
|
}
|
|
s.prototype.slice = function(t, e) {
|
|
let r = this.length;
|
|
t = ~~t,
|
|
e = void 0 === e ? r : ~~e,
|
|
t < 0 ? (t += r) < 0 && (t = 0) : t > r && (t = r),
|
|
e < 0 ? (e += r) < 0 && (e = 0) : e > r && (e = r),
|
|
e < t && (e = t);
|
|
let n = this.subarray(t, e);
|
|
return Object.setPrototypeOf(n, s.prototype),
|
|
n
|
|
}
|
|
,
|
|
s.prototype.readUintLE = s.prototype.readUIntLE = function(t, e, r) {
|
|
t >>>= 0,
|
|
e >>>= 0,
|
|
!r && w(t, e, this.length);
|
|
let n = this[t]
|
|
, o = 1
|
|
, i = 0;
|
|
for (; ++i < e && (o *= 256); )
|
|
n += this[t + i] * o;
|
|
return n
|
|
}
|
|
,
|
|
s.prototype.readUintBE = s.prototype.readUIntBE = function(t, e, r) {
|
|
t >>>= 0,
|
|
e >>>= 0,
|
|
!r && w(t, e, this.length);
|
|
let n = this[t + --e]
|
|
, o = 1;
|
|
for (; e > 0 && (o *= 256); )
|
|
n += this[t + --e] * o;
|
|
return n
|
|
}
|
|
,
|
|
s.prototype.readUint8 = s.prototype.readUInt8 = function(t, e) {
|
|
return t >>>= 0,
|
|
!e && w(t, 1, this.length),
|
|
this[t]
|
|
}
|
|
,
|
|
s.prototype.readUint16LE = s.prototype.readUInt16LE = function(t, e) {
|
|
return t >>>= 0,
|
|
!e && w(t, 2, this.length),
|
|
this[t] | this[t + 1] << 8
|
|
}
|
|
,
|
|
s.prototype.readUint16BE = s.prototype.readUInt16BE = function(t, e) {
|
|
return t >>>= 0,
|
|
!e && w(t, 2, this.length),
|
|
this[t] << 8 | this[t + 1]
|
|
}
|
|
,
|
|
s.prototype.readUint32LE = s.prototype.readUInt32LE = function(t, e) {
|
|
return t >>>= 0,
|
|
!e && w(t, 4, this.length),
|
|
(this[t] | this[t + 1] << 8 | this[t + 2] << 16) + 0x1000000 * this[t + 3]
|
|
}
|
|
,
|
|
s.prototype.readUint32BE = s.prototype.readUInt32BE = function(t, e) {
|
|
return t >>>= 0,
|
|
!e && w(t, 4, this.length),
|
|
0x1000000 * this[t] + (this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3])
|
|
}
|
|
,
|
|
s.prototype.readBigUInt64LE = F(function(t) {
|
|
C(t >>>= 0, "offset");
|
|
let e = this[t]
|
|
, r = this[t + 7];
|
|
(void 0 === e || void 0 === r) && P(t, this.length - 8);
|
|
let n = e + 256 * this[++t] + 65536 * this[++t] + 0x1000000 * this[++t]
|
|
, o = this[++t] + 256 * this[++t] + 65536 * this[++t] + 0x1000000 * r;
|
|
return BigInt(n) + (BigInt(o) << BigInt(32))
|
|
}),
|
|
s.prototype.readBigUInt64BE = F(function(t) {
|
|
C(t >>>= 0, "offset");
|
|
let e = this[t]
|
|
, r = this[t + 7];
|
|
(void 0 === e || void 0 === r) && P(t, this.length - 8);
|
|
let n = 0x1000000 * e + 65536 * this[++t] + 256 * this[++t] + this[++t]
|
|
, o = 0x1000000 * this[++t] + 65536 * this[++t] + 256 * this[++t] + r;
|
|
return (BigInt(n) << BigInt(32)) + BigInt(o)
|
|
}),
|
|
s.prototype.readIntLE = function(t, e, r) {
|
|
t >>>= 0,
|
|
e >>>= 0,
|
|
!r && w(t, e, this.length);
|
|
let n = this[t]
|
|
, o = 1
|
|
, i = 0;
|
|
for (; ++i < e && (o *= 256); )
|
|
n += this[t + i] * o;
|
|
return n >= (o *= 128) && (n -= Math.pow(2, 8 * e)),
|
|
n
|
|
}
|
|
,
|
|
s.prototype.readIntBE = function(t, e, r) {
|
|
t >>>= 0,
|
|
e >>>= 0,
|
|
!r && w(t, e, this.length);
|
|
let n = e
|
|
, o = 1
|
|
, i = this[t + --n];
|
|
for (; n > 0 && (o *= 256); )
|
|
i += this[t + --n] * o;
|
|
return i >= (o *= 128) && (i -= Math.pow(2, 8 * e)),
|
|
i
|
|
}
|
|
,
|
|
s.prototype.readInt8 = function(t, e) {
|
|
return (t >>>= 0,
|
|
!e && w(t, 1, this.length),
|
|
128 & this[t]) ? -((255 - this[t] + 1) * 1) : this[t]
|
|
}
|
|
,
|
|
s.prototype.readInt16LE = function(t, e) {
|
|
t >>>= 0,
|
|
!e && w(t, 2, this.length);
|
|
let r = this[t] | this[t + 1] << 8;
|
|
return 32768 & r ? 0xffff0000 | r : r
|
|
}
|
|
,
|
|
s.prototype.readInt16BE = function(t, e) {
|
|
t >>>= 0,
|
|
!e && w(t, 2, this.length);
|
|
let r = this[t + 1] | this[t] << 8;
|
|
return 32768 & r ? 0xffff0000 | r : r
|
|
}
|
|
,
|
|
s.prototype.readInt32LE = function(t, e) {
|
|
return t >>>= 0,
|
|
!e && w(t, 4, this.length),
|
|
this[t] | this[t + 1] << 8 | this[t + 2] << 16 | this[t + 3] << 24
|
|
}
|
|
,
|
|
s.prototype.readInt32BE = function(t, e) {
|
|
return t >>>= 0,
|
|
!e && w(t, 4, this.length),
|
|
this[t] << 24 | this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3]
|
|
}
|
|
,
|
|
s.prototype.readBigInt64LE = F(function(t) {
|
|
C(t >>>= 0, "offset");
|
|
let e = this[t]
|
|
, r = this[t + 7];
|
|
return (void 0 === e || void 0 === r) && P(t, this.length - 8),
|
|
(BigInt(this[t + 4] + 256 * this[t + 5] + 65536 * this[t + 6] + (r << 24)) << BigInt(32)) + BigInt(e + 256 * this[++t] + 65536 * this[++t] + 0x1000000 * this[++t])
|
|
}),
|
|
s.prototype.readBigInt64BE = F(function(t) {
|
|
C(t >>>= 0, "offset");
|
|
let e = this[t]
|
|
, r = this[t + 7];
|
|
return (void 0 === e || void 0 === r) && P(t, this.length - 8),
|
|
(BigInt((e << 24) + 65536 * this[++t] + 256 * this[++t] + this[++t]) << BigInt(32)) + BigInt(0x1000000 * this[++t] + 65536 * this[++t] + 256 * this[++t] + r)
|
|
}),
|
|
s.prototype.readFloatLE = function(t, e) {
|
|
return t >>>= 0,
|
|
!e && w(t, 4, this.length),
|
|
o.read(this, t, !0, 23, 4)
|
|
}
|
|
,
|
|
s.prototype.readFloatBE = function(t, e) {
|
|
return t >>>= 0,
|
|
!e && w(t, 4, this.length),
|
|
o.read(this, t, !1, 23, 4)
|
|
}
|
|
,
|
|
s.prototype.readDoubleLE = function(t, e) {
|
|
return t >>>= 0,
|
|
!e && w(t, 8, this.length),
|
|
o.read(this, t, !0, 52, 8)
|
|
}
|
|
,
|
|
s.prototype.readDoubleBE = function(t, e) {
|
|
return t >>>= 0,
|
|
!e && w(t, 8, this.length),
|
|
o.read(this, t, !1, 52, 8)
|
|
}
|
|
,
|
|
s.prototype.writeUintLE = s.prototype.writeUIntLE = function(t, e, r, n) {
|
|
if (t = +t,
|
|
e >>>= 0,
|
|
r >>>= 0,
|
|
!n) {
|
|
let n = Math.pow(2, 8 * r) - 1;
|
|
x(this, t, e, r, n, 0)
|
|
}
|
|
let o = 1
|
|
, i = 0;
|
|
for (this[e] = 255 & t; ++i < r && (o *= 256); )
|
|
this[e + i] = t / o & 255;
|
|
return e + r
|
|
}
|
|
,
|
|
s.prototype.writeUintBE = s.prototype.writeUIntBE = function(t, e, r, n) {
|
|
if (t = +t,
|
|
e >>>= 0,
|
|
r >>>= 0,
|
|
!n) {
|
|
let n = Math.pow(2, 8 * r) - 1;
|
|
x(this, t, e, r, n, 0)
|
|
}
|
|
let o = r - 1
|
|
, i = 1;
|
|
for (this[e + o] = 255 & t; --o >= 0 && (i *= 256); )
|
|
this[e + o] = t / i & 255;
|
|
return e + r
|
|
}
|
|
,
|
|
s.prototype.writeUint8 = s.prototype.writeUInt8 = function(t, e, r) {
|
|
return t = +t,
|
|
e >>>= 0,
|
|
!r && x(this, t, e, 1, 255, 0),
|
|
this[e] = 255 & t,
|
|
e + 1
|
|
}
|
|
,
|
|
s.prototype.writeUint16LE = s.prototype.writeUInt16LE = function(t, e, r) {
|
|
return t = +t,
|
|
e >>>= 0,
|
|
!r && x(this, t, e, 2, 65535, 0),
|
|
this[e] = 255 & t,
|
|
this[e + 1] = t >>> 8,
|
|
e + 2
|
|
}
|
|
,
|
|
s.prototype.writeUint16BE = s.prototype.writeUInt16BE = function(t, e, r) {
|
|
return t = +t,
|
|
e >>>= 0,
|
|
!r && x(this, t, e, 2, 65535, 0),
|
|
this[e] = t >>> 8,
|
|
this[e + 1] = 255 & t,
|
|
e + 2
|
|
}
|
|
,
|
|
s.prototype.writeUint32LE = s.prototype.writeUInt32LE = function(t, e, r) {
|
|
return t = +t,
|
|
e >>>= 0,
|
|
!r && x(this, t, e, 4, 0xffffffff, 0),
|
|
this[e + 3] = t >>> 24,
|
|
this[e + 2] = t >>> 16,
|
|
this[e + 1] = t >>> 8,
|
|
this[e] = 255 & t,
|
|
e + 4
|
|
}
|
|
,
|
|
s.prototype.writeUint32BE = s.prototype.writeUInt32BE = function(t, e, r) {
|
|
return t = +t,
|
|
e >>>= 0,
|
|
!r && x(this, t, e, 4, 0xffffffff, 0),
|
|
this[e] = t >>> 24,
|
|
this[e + 1] = t >>> 16,
|
|
this[e + 2] = t >>> 8,
|
|
this[e + 3] = 255 & t,
|
|
e + 4
|
|
}
|
|
,
|
|
s.prototype.writeBigUInt64LE = F(function(t, e=0) {
|
|
return E(this, t, e, BigInt(0), BigInt("0xffffffffffffffff"))
|
|
}),
|
|
s.prototype.writeBigUInt64BE = F(function(t, e=0) {
|
|
return S(this, t, e, BigInt(0), BigInt("0xffffffffffffffff"))
|
|
}),
|
|
s.prototype.writeIntLE = function(t, e, r, n) {
|
|
if (t = +t,
|
|
e >>>= 0,
|
|
!n) {
|
|
let n = Math.pow(2, 8 * r - 1);
|
|
x(this, t, e, r, n - 1, -n)
|
|
}
|
|
let o = 0
|
|
, i = 1
|
|
, a = 0;
|
|
for (this[e] = 255 & t; ++o < r && (i *= 256); )
|
|
t < 0 && 0 === a && 0 !== this[e + o - 1] && (a = 1),
|
|
this[e + o] = (t / i >> 0) - a & 255;
|
|
return e + r
|
|
}
|
|
,
|
|
s.prototype.writeIntBE = function(t, e, r, n) {
|
|
if (t = +t,
|
|
e >>>= 0,
|
|
!n) {
|
|
let n = Math.pow(2, 8 * r - 1);
|
|
x(this, t, e, r, n - 1, -n)
|
|
}
|
|
let o = r - 1
|
|
, i = 1
|
|
, a = 0;
|
|
for (this[e + o] = 255 & t; --o >= 0 && (i *= 256); )
|
|
t < 0 && 0 === a && 0 !== this[e + o + 1] && (a = 1),
|
|
this[e + o] = (t / i >> 0) - a & 255;
|
|
return e + r
|
|
}
|
|
,
|
|
s.prototype.writeInt8 = function(t, e, r) {
|
|
return t = +t,
|
|
e >>>= 0,
|
|
!r && x(this, t, e, 1, 127, -128),
|
|
t < 0 && (t = 255 + t + 1),
|
|
this[e] = 255 & t,
|
|
e + 1
|
|
}
|
|
,
|
|
s.prototype.writeInt16LE = function(t, e, r) {
|
|
return t = +t,
|
|
e >>>= 0,
|
|
!r && x(this, t, e, 2, 32767, -32768),
|
|
this[e] = 255 & t,
|
|
this[e + 1] = t >>> 8,
|
|
e + 2
|
|
}
|
|
,
|
|
s.prototype.writeInt16BE = function(t, e, r) {
|
|
return t = +t,
|
|
e >>>= 0,
|
|
!r && x(this, t, e, 2, 32767, -32768),
|
|
this[e] = t >>> 8,
|
|
this[e + 1] = 255 & t,
|
|
e + 2
|
|
}
|
|
,
|
|
s.prototype.writeInt32LE = function(t, e, r) {
|
|
return t = +t,
|
|
e >>>= 0,
|
|
!r && x(this, t, e, 4, 0x7fffffff, -0x80000000),
|
|
this[e] = 255 & t,
|
|
this[e + 1] = t >>> 8,
|
|
this[e + 2] = t >>> 16,
|
|
this[e + 3] = t >>> 24,
|
|
e + 4
|
|
}
|
|
,
|
|
s.prototype.writeInt32BE = function(t, e, r) {
|
|
return t = +t,
|
|
e >>>= 0,
|
|
!r && x(this, t, e, 4, 0x7fffffff, -0x80000000),
|
|
t < 0 && (t = 0xffffffff + t + 1),
|
|
this[e] = t >>> 24,
|
|
this[e + 1] = t >>> 16,
|
|
this[e + 2] = t >>> 8,
|
|
this[e + 3] = 255 & t,
|
|
e + 4
|
|
}
|
|
,
|
|
s.prototype.writeBigInt64LE = F(function(t, e=0) {
|
|
return E(this, t, e, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"))
|
|
}),
|
|
s.prototype.writeBigInt64BE = F(function(t, e=0) {
|
|
return S(this, t, e, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"))
|
|
}),
|
|
s.prototype.writeFloatLE = function(t, e, r) {
|
|
return O(this, t, e, !0, r)
|
|
}
|
|
,
|
|
s.prototype.writeFloatBE = function(t, e, r) {
|
|
return O(this, t, e, !1, r)
|
|
}
|
|
,
|
|
s.prototype.writeDoubleLE = function(t, e, r) {
|
|
return T(this, t, e, !0, r)
|
|
}
|
|
,
|
|
s.prototype.writeDoubleBE = function(t, e, r) {
|
|
return T(this, t, e, !1, r)
|
|
}
|
|
,
|
|
s.prototype.copy = function(t, e, r, n) {
|
|
if (!s.isBuffer(t))
|
|
throw TypeError("argument should be a Buffer");
|
|
if (!r && (r = 0),
|
|
!n && 0 !== n && (n = this.length),
|
|
e >= t.length && (e = t.length),
|
|
!e && (e = 0),
|
|
n > 0 && n < r && (n = r),
|
|
n === r || 0 === t.length || 0 === this.length)
|
|
return 0;
|
|
if (e < 0)
|
|
throw RangeError("targetStart out of bounds");
|
|
if (r < 0 || r >= this.length)
|
|
throw RangeError("Index out of range");
|
|
if (n < 0)
|
|
throw RangeError("sourceEnd out of bounds");
|
|
n > this.length && (n = this.length),
|
|
t.length - e < n - r && (n = t.length - e + r);
|
|
let o = n - r;
|
|
return this === t && "function" == typeof Uint8Array.prototype.copyWithin ? this.copyWithin(e, r, n) : Uint8Array.prototype.set.call(t, this.subarray(r, n), e),
|
|
o
|
|
}
|
|
,
|
|
s.prototype.fill = function(t, e, r, n) {
|
|
let o;
|
|
if ("string" == typeof t) {
|
|
if ("string" == typeof e ? (n = e,
|
|
e = 0,
|
|
r = this.length) : "string" == typeof r && (n = r,
|
|
r = this.length),
|
|
void 0 !== n && "string" != typeof n)
|
|
throw TypeError("encoding must be a string");
|
|
if ("string" == typeof n && !s.isEncoding(n))
|
|
throw TypeError("Unknown encoding: " + n);
|
|
if (1 === t.length) {
|
|
let e = t.charCodeAt(0);
|
|
("utf8" === n && e < 128 || "latin1" === n) && (t = e)
|
|
}
|
|
} else
|
|
"number" == typeof t ? t &= 255 : "boolean" == typeof t && (t = Number(t));
|
|
if (e < 0 || this.length < e || this.length < r)
|
|
throw RangeError("Out of range index");
|
|
if (r <= e)
|
|
return this;
|
|
if (e >>>= 0,
|
|
r = void 0 === r ? this.length : r >>> 0,
|
|
!t && (t = 0),
|
|
"number" == typeof t)
|
|
for (o = e; o < r; ++o)
|
|
this[o] = t;
|
|
else {
|
|
let i = s.isBuffer(t) ? t : s.from(t, n)
|
|
, a = i.length;
|
|
if (0 === a)
|
|
throw TypeError('The value "' + t + '" is invalid for argument "value"');
|
|
for (o = 0; o < r - e; ++o)
|
|
this[o + e] = i[o % a]
|
|
}
|
|
return this
|
|
}
|
|
;
|
|
let R = {};
|
|
function _(t, e, r) {
|
|
R[t] = class extends r {
|
|
constructor() {
|
|
super(),
|
|
Object.defineProperty(this, "message", {
|
|
value: e.apply(this, arguments),
|
|
writable: !0,
|
|
configurable: !0
|
|
}),
|
|
this.name = `${this.name} [${t}]`,
|
|
this.stack,
|
|
delete this.name
|
|
}
|
|
get code() {
|
|
return t
|
|
}
|
|
set code(t) {
|
|
Object.defineProperty(this, "code", {
|
|
configurable: !0,
|
|
enumerable: !0,
|
|
value: t,
|
|
writable: !0
|
|
})
|
|
}
|
|
toString() {
|
|
return `${this.name} [${t}]: ${this.message}`
|
|
}
|
|
}
|
|
}
|
|
function I(t) {
|
|
let e = ""
|
|
, r = t.length
|
|
, n = "-" === t[0] ? 1 : 0;
|
|
for (; r >= n + 4; r -= 3)
|
|
e = `_${t.slice(r - 3, r)}${e}`;
|
|
return `${t.slice(0, r)}${e}`
|
|
}
|
|
_("ERR_BUFFER_OUT_OF_BOUNDS", function(t) {
|
|
return t ? `${t} is outside of buffer bounds` : "Attempt to access memory outside buffer bounds"
|
|
}, RangeError),
|
|
_("ERR_INVALID_ARG_TYPE", function(t, e) {
|
|
return `The "${t}" argument must be of type number. Received type ${typeof e}`
|
|
}, TypeError),
|
|
_("ERR_OUT_OF_RANGE", function(t, e, r) {
|
|
let n = `The value of "${t}" is out of range.`
|
|
, o = r;
|
|
return Number.isInteger(r) && Math.abs(r) > 0x100000000 ? o = I(String(r)) : "bigint" == typeof r && (o = String(r),
|
|
(r > BigInt(2) ** BigInt(32) || r < -(BigInt(2) ** BigInt(32))) && (o = I(o)),
|
|
o += "n"),
|
|
n += ` It must be ${e}. Received ${o}`
|
|
}, RangeError);
|
|
function k(t, e, r, n, o, i) {
|
|
var a, s, u;
|
|
if (t > r || t < e) {
|
|
let n;
|
|
let o = "bigint" == typeof e ? "n" : "";
|
|
throw n = i > 3 ? 0 === e || e === BigInt(0) ? `>= 0${o} and < 2${o} ** ${(i + 1) * 8}${o}` : `>= -(2${o} ** ${(i + 1) * 8 - 1}${o}) and < 2 ** ${(i + 1) * 8 - 1}${o}` : `>= ${e}${o} and <= ${r}${o}`,
|
|
new R.ERR_OUT_OF_RANGE("value",n,t)
|
|
}
|
|
a = n,
|
|
s = o,
|
|
u = i,
|
|
C(s, "offset"),
|
|
(void 0 === a[s] || void 0 === a[s + u]) && P(s, a.length - (u + 1))
|
|
}
|
|
function C(t, e) {
|
|
if ("number" != typeof t)
|
|
throw new R.ERR_INVALID_ARG_TYPE(e,"number",t)
|
|
}
|
|
function P(t, e, r) {
|
|
if (Math.floor(t) !== t)
|
|
throw C(t, r),
|
|
new R.ERR_OUT_OF_RANGE(r || "offset","an integer",t);
|
|
if (e < 0)
|
|
throw new R.ERR_BUFFER_OUT_OF_BOUNDS;
|
|
throw new R.ERR_OUT_OF_RANGE(r || "offset",`>= ${r ? 1 : 0} and <= ${e}`,t)
|
|
}
|
|
let j = /[^+/0-9A-Za-z-_]/g;
|
|
function L(t, e) {
|
|
let r;
|
|
e = e || 1 / 0;
|
|
let n = t.length
|
|
, o = null
|
|
, i = [];
|
|
for (let a = 0; a < n; ++a) {
|
|
if ((r = t.charCodeAt(a)) > 55295 && r < 57344) {
|
|
if (!o) {
|
|
if (r > 56319) {
|
|
(e -= 3) > -1 && i.push(239, 191, 189);
|
|
continue
|
|
}
|
|
if (a + 1 === n) {
|
|
(e -= 3) > -1 && i.push(239, 191, 189);
|
|
continue
|
|
}
|
|
o = r;
|
|
continue
|
|
}
|
|
if (r < 56320) {
|
|
(e -= 3) > -1 && i.push(239, 191, 189),
|
|
o = r;
|
|
continue
|
|
}
|
|
r = (o - 55296 << 10 | r - 56320) + 65536
|
|
} else
|
|
o && (e -= 3) > -1 && i.push(239, 191, 189);
|
|
if (o = null,
|
|
r < 128) {
|
|
if ((e -= 1) < 0)
|
|
break;
|
|
i.push(r)
|
|
} else if (r < 2048) {
|
|
if ((e -= 2) < 0)
|
|
break;
|
|
i.push(r >> 6 | 192, 63 & r | 128)
|
|
} else if (r < 65536) {
|
|
if ((e -= 3) < 0)
|
|
break;
|
|
i.push(r >> 12 | 224, r >> 6 & 63 | 128, 63 & r | 128)
|
|
} else if (r < 1114112) {
|
|
if ((e -= 4) < 0)
|
|
break;
|
|
i.push(r >> 18 | 240, r >> 12 & 63 | 128, r >> 6 & 63 | 128, 63 & r | 128)
|
|
} else
|
|
throw Error("Invalid code point")
|
|
}
|
|
return i
|
|
}
|
|
function M(t) {
|
|
return n.toByteArray(function(t) {
|
|
if ((t = (t = t.split("=")[0]).trim().replace(j, "")).length < 2)
|
|
return "";
|
|
for (; t.length % 4 != 0; )
|
|
t += "=";
|
|
return t
|
|
}(t))
|
|
}
|
|
function N(t, e, r, n) {
|
|
let o;
|
|
for (o = 0; o < n && !(o + r >= e.length) && !(o >= t.length); ++o)
|
|
e[o + r] = t[o];
|
|
return o
|
|
}
|
|
function U(t, e) {
|
|
return t instanceof e || null != t && null != t.constructor && null != t.constructor.name && t.constructor.name === e.name
|
|
}
|
|
function B(t) {
|
|
return t != t
|
|
}
|
|
let D = function() {
|
|
let t = "0123456789abcdef"
|
|
, e = Array(256);
|
|
for (let r = 0; r < 16; ++r) {
|
|
let n = 16 * r;
|
|
for (let o = 0; o < 16; ++o)
|
|
e[n + o] = t[r] + t[o]
|
|
}
|
|
return e
|
|
}();
|
|
function F(t) {
|
|
return "undefined" == typeof BigInt ? z : t
|
|
}
|
|
function z() {
|
|
throw Error("BigInt not supported")
|
|
}
|
|
}
|
|
function T140860(e, t, i) {
|
|
var n = i(966465)
|
|
, r = n.Buffer;
|
|
function a(e, t) {
|
|
for (var i in e)
|
|
t[i] = e[i]
|
|
}
|
|
function o(e, t, i) {
|
|
return r(e, t, i)
|
|
}
|
|
r.from && r.alloc && r.allocUnsafe && r.allocUnsafeSlow ? e.exports = n : (a(n, t),
|
|
t.Buffer = o),
|
|
o.prototype = Object.create(r.prototype),
|
|
a(r, o),
|
|
o.from = function(e, t, i) {
|
|
if ("number" == typeof e)
|
|
throw TypeError("Argument must not be a number");
|
|
return r(e, t, i)
|
|
}
|
|
,
|
|
o.alloc = function(e, t, i) {
|
|
if ("number" != typeof e)
|
|
throw TypeError("Argument must be a number");
|
|
var n = r(e);
|
|
return void 0 !== t ? "string" == typeof i ? n.fill(t, i) : n.fill(t) : n.fill(0),
|
|
n
|
|
}
|
|
,
|
|
o.allocUnsafe = function(e) {
|
|
if ("number" != typeof e)
|
|
throw TypeError("Argument must be a number");
|
|
return r(e)
|
|
}
|
|
,
|
|
o.allocUnsafeSlow = function(e) {
|
|
if ("number" != typeof e)
|
|
throw TypeError("Argument must be a number");
|
|
return n.SlowBuffer(e)
|
|
}
|
|
}
|
|
function T203960(e, t, i) {
|
|
"use strict";
|
|
var n = T499845(e),
|
|
r = 65536,
|
|
a = 0xffffffff;
|
|
function o() {
|
|
throw Error(
|
|
"Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11"
|
|
);
|
|
}
|
|
var s = i(T140860).Buffer,
|
|
l = window.crypto || window.msCrypto;
|
|
function c(e, t) {
|
|
if (e > a) throw RangeError("requested too many random bytes");
|
|
var i = s.allocUnsafe(e);
|
|
if (e > 0) {
|
|
if (e > r)
|
|
for (var o = 0; o < e; o += r) l.getRandomValues(i.slice(o, o + r));
|
|
else l.getRandomValues(i);
|
|
}
|
|
return "function" == typeof t
|
|
? n.nextTick(function () {
|
|
t(null, i);
|
|
})
|
|
: i;
|
|
}
|
|
l && l.getRandomValues ? (e.exports = c) : (e.exports = o);
|
|
}
|
|
function TEST0(e, t, i) {
|
|
var n = T203960(e, t, i);
|
|
(e.exports = _), (_.simpleSieve = m), (_.fermatTest = g);
|
|
var r = i(984826),
|
|
a = new r(24),
|
|
o = new (i(350724))(),
|
|
s = new r(1),
|
|
l = new r(2),
|
|
c = new r(5);
|
|
new r(16), new r(8);
|
|
var d = new r(10),
|
|
u = new r(3);
|
|
new r(7);
|
|
var f = new r(11),
|
|
h = new r(4);
|
|
new r(12);
|
|
var p = null;
|
|
function v() {
|
|
if (null !== p) return p;
|
|
var e = 1048576,
|
|
t = [];
|
|
t[0] = 2;
|
|
for (var i = 1, n = 3; n < e; n += 2) {
|
|
for (
|
|
var r = Math.ceil(Math.sqrt(n)), a = 0;
|
|
a < i && t[a] <= r && n % t[a] != 0;
|
|
a++
|
|
);
|
|
(i === a || !(t[a] <= r)) && (t[i++] = n);
|
|
}
|
|
return (p = t), t;
|
|
}
|
|
function m(e) {
|
|
for (var t = v(), i = 0; i < t.length; i++)
|
|
if (0 === e.modn(t[i])) {
|
|
if (0 !== e.cmpn(t[i])) return !1;
|
|
break;
|
|
}
|
|
return !0;
|
|
}
|
|
function g(e) {
|
|
var t = r.mont(e);
|
|
return 0 === l.toRed(t).redPow(e.subn(1)).fromRed().cmpn(1);
|
|
}
|
|
function _(e, t) {
|
|
var i, p;
|
|
if (e < 16)
|
|
return 2 === t || 5 === t ? new r([140, 123]) : new r([140, 39]);
|
|
for (t = new r(t); ; ) {
|
|
for (i = new r(n(Math.ceil(e / 8))); i.bitLength() > e; ) i.ishrn(1);
|
|
if ((i.isEven() && i.iadd(s), !i.testn(1) && i.iadd(l), t.cmp(l))) {
|
|
if (!t.cmp(c)) for (; i.mod(d).cmp(u); ) i.iadd(h);
|
|
} else for (; i.mod(a).cmp(f); ) i.iadd(h);
|
|
if (
|
|
m((p = i.shrn(1))) &&
|
|
m(i) &&
|
|
g(p) &&
|
|
g(i) &&
|
|
o.test(p) &&
|
|
o.test(i)
|
|
)
|
|
return i;
|
|
}
|
|
}
|
|
}
|
|
|
|
function TEST(e, t, r) {
|
|
"use strict";
|
|
var n = "object" == typeof Reflect ? Reflect : null
|
|
, i = n && "function" == typeof n.apply ? n.apply : function(e, t, r) {
|
|
return Function.prototype.apply.call(e, t, r)
|
|
}
|
|
, o = n && "function" == typeof n.ownKeys ? n.ownKeys : Object.getOwnPropertySymbols ? function(e) {
|
|
return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))
|
|
}
|
|
: function(e) {
|
|
return Object.getOwnPropertyNames(e)
|
|
}
|
|
, s = Number.isNaN || function(e) {
|
|
return e != e
|
|
}
|
|
;
|
|
function a() {
|
|
a.init.call(this)
|
|
}
|
|
e.exports = a,
|
|
e.exports.once = function(e, t) {
|
|
return new Promise(function(r, n) {
|
|
var i, o, s;
|
|
function a(r) {
|
|
e.removeListener(t, c),
|
|
n(r)
|
|
}
|
|
function c() {
|
|
"function" == typeof e.removeListener && e.removeListener("error", a),
|
|
r([].slice.call(arguments))
|
|
}
|
|
y(e, t, c, {
|
|
once: !0
|
|
}),
|
|
"error" !== t && (i = e,
|
|
o = a,
|
|
s = {
|
|
once: !0
|
|
},
|
|
"function" == typeof i.on && y(i, "error", o, s))
|
|
}
|
|
)
|
|
}
|
|
,
|
|
(a.EventEmitter = a).prototype._events = void 0,
|
|
a.prototype._eventsCount = 0,
|
|
a.prototype._maxListeners = void 0;
|
|
var c = 10;
|
|
function u(e) {
|
|
if ("function" != typeof e)
|
|
throw TypeError('The "listener" argument must be of type Function. Received type ' + typeof e)
|
|
}
|
|
function l(e) {
|
|
return void 0 === e._maxListeners ? a.defaultMaxListeners : e._maxListeners
|
|
}
|
|
function f(e, t, r, n) {
|
|
var i, o, s;
|
|
return u(r),
|
|
void 0 === (i = e._events) ? (i = e._events = Object.create(null),
|
|
e._eventsCount = 0) : (void 0 !== i.newListener && (e.emit("newListener", t, r.listener || r),
|
|
i = e._events),
|
|
o = i[t]),
|
|
void 0 === o ? (o = i[t] = r,
|
|
++e._eventsCount) : ("function" == typeof o ? o = i[t] = n ? [r, o] : [o, r] : n ? o.unshift(r) : o.push(r),
|
|
0 < (i = l(e)) && o.length > i && !o.warned && (o.warned = !0,
|
|
(n = Error("Possible EventEmitter memory leak detected. " + o.length + " " + String(t) + " listeners added. Use emitter.setMaxListeners() to increase limit")).name = "MaxListenersExceededWarning",
|
|
n.emitter = e,
|
|
n.type = t,
|
|
n.count = o.length,
|
|
s = n,
|
|
console && console.warn && console.warn(s))),
|
|
e
|
|
}
|
|
function p(e, t, r) {
|
|
return (t = (function() {
|
|
if (!this.fired)
|
|
return this.target.removeListener(this.type, this.wrapFn),
|
|
this.fired = !0,
|
|
0 == arguments.length ? this.listener.call(this.target) : this.listener.apply(this.target, arguments)
|
|
}
|
|
).bind(e = {
|
|
fired: !1,
|
|
wrapFn: void 0,
|
|
target: e,
|
|
type: t,
|
|
listener: r
|
|
})).listener = r,
|
|
e.wrapFn = t
|
|
}
|
|
function h(e, t, r) {
|
|
var e = e._events;
|
|
return void 0 === e || void 0 === (e = e[t]) ? [] : "function" == typeof e ? r ? [e.listener || e] : [e] : r ? function(e) {
|
|
for (var t = Array(e.length), r = 0; r < t.length; ++r)
|
|
t[r] = e[r].listener || e[r];
|
|
return t
|
|
}(e) : g(e, e.length)
|
|
}
|
|
function d(e) {
|
|
var t = this._events;
|
|
if (void 0 !== t) {
|
|
if ("function" == typeof (t = t[e]))
|
|
return 1;
|
|
if (void 0 !== t)
|
|
return t.length
|
|
}
|
|
return 0
|
|
}
|
|
function g(e, t) {
|
|
for (var r = Array(t), n = 0; n < t; ++n)
|
|
r[n] = e[n];
|
|
return r
|
|
}
|
|
function y(e, t, r, n) {
|
|
if ("function" == typeof e.on)
|
|
n.once ? e.once(t, r) : e.on(t, r);
|
|
else {
|
|
if ("function" != typeof e.addEventListener)
|
|
throw TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof e);
|
|
e.addEventListener(t, function i(o) {
|
|
n.once && e.removeEventListener(t, i),
|
|
r(o)
|
|
})
|
|
}
|
|
}
|
|
Object.defineProperty(a, "defaultMaxListeners", {
|
|
enumerable: !0,
|
|
get: function() {
|
|
return c
|
|
},
|
|
set: function(e) {
|
|
if ("number" != typeof e || e < 0 || s(e))
|
|
throw RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + e + ".");
|
|
c = e
|
|
}
|
|
}),
|
|
a.init = function() {
|
|
void 0 !== this._events && this._events !== Object.getPrototypeOf(this)._events || (this._events = Object.create(null),
|
|
this._eventsCount = 0),
|
|
this._maxListeners = this._maxListeners || void 0
|
|
}
|
|
,
|
|
a.prototype.setMaxListeners = function(e) {
|
|
if ("number" != typeof e || e < 0 || s(e))
|
|
throw RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + e + ".");
|
|
return this._maxListeners = e,
|
|
this
|
|
}
|
|
,
|
|
a.prototype.getMaxListeners = function() {
|
|
return l(this)
|
|
}
|
|
,
|
|
a.prototype.emit = function(e) {
|
|
for (var t = [], r = 1; r < arguments.length; r++)
|
|
t.push(arguments[r]);
|
|
var n = "error" === e
|
|
, o = this._events;
|
|
if (void 0 !== o)
|
|
n = n && void 0 === o.error;
|
|
else if (!n)
|
|
return !1;
|
|
if (n) {
|
|
if ((s = 0 < t.length ? t[0] : s)instanceof Error)
|
|
throw s;
|
|
throw (n = Error("Unhandled error." + (s ? " (" + s.message + ")" : ""))).context = s,
|
|
n
|
|
}
|
|
var s = o[e];
|
|
if (void 0 === s)
|
|
return !1;
|
|
if ("function" == typeof s)
|
|
i(s, this, t);
|
|
else
|
|
for (var a = s.length, c = g(s, a), r = 0; r < a; ++r)
|
|
i(c[r], this, t);
|
|
return !0
|
|
}
|
|
,
|
|
a.prototype.on = a.prototype.addListener = function(e, t) {
|
|
return f(this, e, t, !1)
|
|
}
|
|
,
|
|
a.prototype.prependListener = function(e, t) {
|
|
return f(this, e, t, !0)
|
|
}
|
|
,
|
|
a.prototype.once = function(e, t) {
|
|
return u(t),
|
|
this.on(e, p(this, e, t)),
|
|
this
|
|
}
|
|
,
|
|
a.prototype.prependOnceListener = function(e, t) {
|
|
return u(t),
|
|
this.prependListener(e, p(this, e, t)),
|
|
this
|
|
}
|
|
,
|
|
a.prototype.off = a.prototype.removeListener = function(e, t) {
|
|
var r, n, i, o, s;
|
|
if (u(t),
|
|
void 0 !== (n = this._events) && void 0 !== (r = n[e])) {
|
|
if (r === t || r.listener === t)
|
|
0 == --this._eventsCount ? this._events = Object.create(null) : (delete n[e],
|
|
n.removeListener && this.emit("removeListener", e, r.listener || t));
|
|
else if ("function" != typeof r) {
|
|
for (i = -1,
|
|
o = r.length - 1; 0 <= o; o--)
|
|
if (r[o] === t || r[o].listener === t) {
|
|
s = r[o].listener,
|
|
i = o;
|
|
break
|
|
}
|
|
if (i < 0)
|
|
return this;
|
|
0 === i ? r.shift() : function(e, t) {
|
|
for (; t + 1 < e.length; t++)
|
|
e[t] = e[t + 1];
|
|
e.pop()
|
|
}(r, i),
|
|
1 === r.length && (n[e] = r[0]),
|
|
void 0 !== n.removeListener && this.emit("removeListener", e, s || t)
|
|
}
|
|
}
|
|
return this
|
|
}
|
|
,
|
|
a.prototype.removeAllListeners = function(e) {
|
|
var t, r = this._events;
|
|
if (void 0 !== r) {
|
|
if (void 0 === r.removeListener)
|
|
0 == arguments.length ? (this._events = Object.create(null),
|
|
this._eventsCount = 0) : void 0 !== r[e] && (0 == --this._eventsCount ? this._events = Object.create(null) : delete r[e]);
|
|
else if (0 == arguments.length) {
|
|
for (var n, i = Object.keys(r), o = 0; o < i.length; ++o)
|
|
"removeListener" !== (n = i[o]) && this.removeAllListeners(n);
|
|
this.removeAllListeners("removeListener"),
|
|
this._events = Object.create(null),
|
|
this._eventsCount = 0
|
|
} else if ("function" == typeof (t = r[e]))
|
|
this.removeListener(e, t);
|
|
else if (void 0 !== t)
|
|
for (o = t.length - 1; 0 <= o; o--)
|
|
this.removeListener(e, t[o])
|
|
}
|
|
return this
|
|
}
|
|
,
|
|
a.prototype.listeners = function(e) {
|
|
return h(this, e, !0)
|
|
}
|
|
,
|
|
a.prototype.rawListeners = function(e) {
|
|
return h(this, e, !1)
|
|
}
|
|
,
|
|
a.listenerCount = function(e, t) {
|
|
return "function" == typeof e.listenerCount ? e.listenerCount(t) : d.call(e, t)
|
|
}
|
|
,
|
|
a.prototype.listenerCount = d,
|
|
a.prototype.eventNames = function() {
|
|
return 0 < this._eventsCount ? o(this._events) : []
|
|
}
|
|
}
|
|
function TEST2(e, t, r) {
|
|
(function(t) {
|
|
e.exports = function(e) {
|
|
"use strict";
|
|
var r, n = (r = e) && "object" == typeof r && "default"in r ? r : {
|
|
default: r
|
|
};
|
|
function i(e, t) {
|
|
for (var r, n, i = 0; i < t.length; i++) {
|
|
var o = t[i];
|
|
o.enumerable = o.enumerable || !1,
|
|
o.configurable = !0,
|
|
"value"in o && (o.writable = !0),
|
|
Object.defineProperty(e, (r = o.key,
|
|
n = void 0,
|
|
"symbol" == typeof (n = function(e, t) {
|
|
if ("object" != typeof e || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 !== r) {
|
|
var n = r.call(e, t || "default");
|
|
if ("object" != typeof n)
|
|
return n;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}
|
|
return ("string" === t ? String : Number)(e)
|
|
}(r, "string")) ? n : String(n)), o)
|
|
}
|
|
}
|
|
var o = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : void 0 !== t ? t : "undefined" != typeof self ? self : {};
|
|
function s(e, t, r) {
|
|
return e(r = {
|
|
path: t,
|
|
exports: {},
|
|
require: function(e, t) {
|
|
return function() {
|
|
throw Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")
|
|
}(null == t && r.path)
|
|
}
|
|
}, r.exports),
|
|
r.exports
|
|
}
|
|
var a = s(function(e, t) {
|
|
var r;
|
|
e.exports = r || function(e, t) {
|
|
if ("undefined" != typeof window && window.crypto && (r = window.crypto),
|
|
"undefined" != typeof self && self.crypto && (r = self.crypto),
|
|
"undefined" != typeof globalThis && globalThis.crypto && (r = globalThis.crypto),
|
|
!r && "undefined" != typeof window && window.msCrypto && (r = window.msCrypto),
|
|
!r && void 0 !== o && o.crypto && (r = o.crypto),
|
|
!r)
|
|
try {
|
|
r = n.default
|
|
} catch (e) {}
|
|
var r, i = function() {
|
|
if (r) {
|
|
if ("function" == typeof r.getRandomValues)
|
|
try {
|
|
return r.getRandomValues(new Uint32Array(1))[0]
|
|
} catch (e) {}
|
|
if ("function" == typeof r.randomBytes)
|
|
try {
|
|
return r.randomBytes(4).readInt32LE()
|
|
} catch (e) {}
|
|
}
|
|
throw Error("Native crypto module could not be used to get secure random number.")
|
|
}, s = Object.create || function() {
|
|
function e() {}
|
|
return function(t) {
|
|
var r;
|
|
return e.prototype = t,
|
|
r = new e,
|
|
e.prototype = null,
|
|
r
|
|
}
|
|
}(), a = {}, c = a.lib = {}, u = c.Base = {
|
|
extend: function(e) {
|
|
var t = s(this);
|
|
return e && t.mixIn(e),
|
|
t.hasOwnProperty("init") && this.init !== t.init || (t.init = function() {
|
|
t.$super.init.apply(this, arguments)
|
|
}
|
|
),
|
|
t.init.prototype = t,
|
|
t.$super = this,
|
|
t
|
|
},
|
|
create: function() {
|
|
var e = this.extend();
|
|
return e.init.apply(e, arguments),
|
|
e
|
|
},
|
|
init: function() {},
|
|
mixIn: function(e) {
|
|
for (var t in e)
|
|
e.hasOwnProperty(t) && (this[t] = e[t]);
|
|
e.hasOwnProperty("toString") && (this.toString = e.toString)
|
|
},
|
|
clone: function() {
|
|
return this.init.prototype.extend(this)
|
|
}
|
|
}, l = c.WordArray = u.extend({
|
|
init: function(e, t) {
|
|
e = this.words = e || [],
|
|
this.sigBytes = null != t ? t : 4 * e.length
|
|
},
|
|
toString: function(e) {
|
|
return (e || p).stringify(this)
|
|
},
|
|
concat: function(e) {
|
|
var t = this.words
|
|
, r = e.words
|
|
, n = this.sigBytes
|
|
, i = e.sigBytes;
|
|
if (this.clamp(),
|
|
n % 4)
|
|
for (var o = 0; o < i; o++) {
|
|
var s = r[o >>> 2] >>> 24 - o % 4 * 8 & 255;
|
|
t[n + o >>> 2] |= s << 24 - (n + o) % 4 * 8
|
|
}
|
|
else
|
|
for (var a = 0; a < i; a += 4)
|
|
t[n + a >>> 2] = r[a >>> 2];
|
|
return this.sigBytes += i,
|
|
this
|
|
},
|
|
clamp: function() {
|
|
var t = this.words
|
|
, r = this.sigBytes;
|
|
t[r >>> 2] &= 0xffffffff << 32 - r % 4 * 8,
|
|
t.length = e.ceil(r / 4)
|
|
},
|
|
clone: function() {
|
|
var e = u.clone.call(this);
|
|
return e.words = this.words.slice(0),
|
|
e
|
|
},
|
|
random: function(e) {
|
|
for (var t = [], r = 0; r < e; r += 4)
|
|
t.push(i());
|
|
return new l.init(t,e)
|
|
}
|
|
}), f = a.enc = {}, p = f.Hex = {
|
|
stringify: function(e) {
|
|
for (var t = e.words, r = e.sigBytes, n = [], i = 0; i < r; i++) {
|
|
var o = t[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
n.push((o >>> 4).toString(16)),
|
|
n.push((15 & o).toString(16))
|
|
}
|
|
return n.join("")
|
|
},
|
|
parse: function(e) {
|
|
for (var t = e.length, r = [], n = 0; n < t; n += 2)
|
|
r[n >>> 3] |= parseInt(e.substr(n, 2), 16) << 24 - n % 8 * 4;
|
|
return new l.init(r,t / 2)
|
|
}
|
|
}, h = f.Latin1 = {
|
|
stringify: function(e) {
|
|
for (var t = e.words, r = e.sigBytes, n = [], i = 0; i < r; i++) {
|
|
var o = t[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
n.push(String.fromCharCode(o))
|
|
}
|
|
return n.join("")
|
|
},
|
|
parse: function(e) {
|
|
for (var t = e.length, r = [], n = 0; n < t; n++)
|
|
r[n >>> 2] |= (255 & e.charCodeAt(n)) << 24 - n % 4 * 8;
|
|
return new l.init(r,t)
|
|
}
|
|
}, d = f.Utf8 = {
|
|
stringify: function(e) {
|
|
try {
|
|
return decodeURIComponent(escape(h.stringify(e)))
|
|
} catch (e) {
|
|
throw Error("Malformed UTF-8 data")
|
|
}
|
|
},
|
|
parse: function(e) {
|
|
return h.parse(unescape(encodeURIComponent(e)))
|
|
}
|
|
}, g = c.BufferedBlockAlgorithm = u.extend({
|
|
reset: function() {
|
|
this._data = new l.init,
|
|
this._nDataBytes = 0
|
|
},
|
|
_append: function(e) {
|
|
"string" == typeof e && (e = d.parse(e)),
|
|
this._data.concat(e),
|
|
this._nDataBytes += e.sigBytes
|
|
},
|
|
_process: function(t) {
|
|
var r, n = this._data, i = n.words, o = n.sigBytes, s = this.blockSize, a = o / (4 * s), c = (a = t ? e.ceil(a) : e.max((0 | a) - this._minBufferSize, 0)) * s, u = e.min(4 * c, o);
|
|
if (c) {
|
|
for (var f = 0; f < c; f += s)
|
|
this._doProcessBlock(i, f);
|
|
r = i.splice(0, c),
|
|
n.sigBytes -= u
|
|
}
|
|
return new l.init(r,u)
|
|
},
|
|
clone: function() {
|
|
var e = u.clone.call(this);
|
|
return e._data = this._data.clone(),
|
|
e
|
|
},
|
|
_minBufferSize: 0
|
|
});
|
|
c.Hasher = g.extend({
|
|
cfg: u.extend(),
|
|
init: function(e) {
|
|
this.cfg = this.cfg.extend(e),
|
|
this.reset()
|
|
},
|
|
reset: function() {
|
|
g.reset.call(this),
|
|
this._doReset()
|
|
},
|
|
update: function(e) {
|
|
return this._append(e),
|
|
this._process(),
|
|
this
|
|
},
|
|
finalize: function(e) {
|
|
return e && this._append(e),
|
|
this._doFinalize()
|
|
},
|
|
blockSize: 16,
|
|
_createHelper: function(e) {
|
|
return function(t, r) {
|
|
return new e.init(r).finalize(t)
|
|
}
|
|
},
|
|
_createHmacHelper: function(e) {
|
|
return function(t, r) {
|
|
return new y.HMAC.init(e,r).finalize(t)
|
|
}
|
|
}
|
|
});
|
|
var y = a.algo = {};
|
|
return a
|
|
}(Math)
|
|
})
|
|
, c = s(function(e, t) {
|
|
var r, n, i, o, s, c, u, l, f;
|
|
e.exports = (r = Math,
|
|
i = (n = a.lib).WordArray,
|
|
o = n.Hasher,
|
|
s = a.algo,
|
|
c = [],
|
|
u = [],
|
|
function() {
|
|
function e(e) {
|
|
return 0x100000000 * (e - (0 | e)) | 0
|
|
}
|
|
for (var t = 2, n = 0; n < 64; )
|
|
(function(e) {
|
|
for (var t = r.sqrt(e), n = 2; n <= t; n++)
|
|
if (!(e % n))
|
|
return !1;
|
|
return !0
|
|
}
|
|
)(t) && (n < 8 && (c[n] = e(r.pow(t, .5))),
|
|
u[n] = e(r.pow(t, 1 / 3)),
|
|
n++),
|
|
t++
|
|
}(),
|
|
l = [],
|
|
f = s.SHA256 = o.extend({
|
|
_doReset: function() {
|
|
this._hash = new i.init(c.slice(0))
|
|
},
|
|
_doProcessBlock: function(e, t) {
|
|
for (var r = this._hash.words, n = r[0], i = r[1], o = r[2], s = r[3], a = r[4], c = r[5], f = r[6], p = r[7], h = 0; h < 64; h++) {
|
|
if (h < 16)
|
|
l[h] = 0 | e[t + h];
|
|
else {
|
|
var d = l[h - 15]
|
|
, g = (d << 25 | d >>> 7) ^ (d << 14 | d >>> 18) ^ d >>> 3
|
|
, y = l[h - 2]
|
|
, m = (y << 15 | y >>> 17) ^ (y << 13 | y >>> 19) ^ y >>> 10;
|
|
l[h] = g + l[h - 7] + m + l[h - 16]
|
|
}
|
|
var v = n & i ^ n & o ^ i & o
|
|
, b = (n << 30 | n >>> 2) ^ (n << 19 | n >>> 13) ^ (n << 10 | n >>> 22)
|
|
, _ = p + ((a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25)) + (a & c ^ ~a & f) + u[h] + l[h];
|
|
p = f,
|
|
f = c,
|
|
c = a,
|
|
a = s + _ | 0,
|
|
s = o,
|
|
o = i,
|
|
i = n,
|
|
n = _ + (b + v) | 0
|
|
}
|
|
r[0] = r[0] + n | 0,
|
|
r[1] = r[1] + i | 0,
|
|
r[2] = r[2] + o | 0,
|
|
r[3] = r[3] + s | 0,
|
|
r[4] = r[4] + a | 0,
|
|
r[5] = r[5] + c | 0,
|
|
r[6] = r[6] + f | 0,
|
|
r[7] = r[7] + p | 0
|
|
},
|
|
_doFinalize: function() {
|
|
var e = this._data
|
|
, t = e.words
|
|
, n = 8 * this._nDataBytes
|
|
, i = 8 * e.sigBytes;
|
|
return t[i >>> 5] |= 128 << 24 - i % 32,
|
|
t[14 + (i + 64 >>> 9 << 4)] = r.floor(n / 0x100000000),
|
|
t[15 + (i + 64 >>> 9 << 4)] = n,
|
|
e.sigBytes = 4 * t.length,
|
|
this._process(),
|
|
this._hash
|
|
},
|
|
clone: function() {
|
|
var e = o.clone.call(this);
|
|
return e._hash = this._hash.clone(),
|
|
e
|
|
}
|
|
}),
|
|
a.SHA256 = o._createHelper(f),
|
|
a.HmacSHA256 = o._createHmacHelper(f),
|
|
a.SHA256)
|
|
})
|
|
, u = (s(function(e, t) {
|
|
var r, n;
|
|
e.exports = (r = a.lib.Base,
|
|
n = a.enc.Utf8,
|
|
void (a.algo.HMAC = r.extend({
|
|
init: function(e, t) {
|
|
e = this._hasher = new e.init,
|
|
"string" == typeof t && (t = n.parse(t));
|
|
var r = e.blockSize
|
|
, i = 4 * r;
|
|
t.sigBytes > i && (t = e.finalize(t)),
|
|
t.clamp();
|
|
for (var o = this._oKey = t.clone(), s = this._iKey = t.clone(), a = o.words, c = s.words, u = 0; u < r; u++)
|
|
a[u] ^= 0x5c5c5c5c,
|
|
c[u] ^= 0x36363636;
|
|
o.sigBytes = s.sigBytes = i,
|
|
this.reset()
|
|
},
|
|
reset: function() {
|
|
var e = this._hasher;
|
|
e.reset(),
|
|
e.update(this._iKey)
|
|
},
|
|
update: function(e) {
|
|
return this._hasher.update(e),
|
|
this
|
|
},
|
|
finalize: function(e) {
|
|
var t = this._hasher
|
|
, r = t.finalize(e);
|
|
return t.reset(),
|
|
t.finalize(this._oKey.clone().concat(r))
|
|
}
|
|
})))
|
|
}),
|
|
s(function(e, t) {
|
|
e.exports = a.HmacSHA256
|
|
}))
|
|
, l = {
|
|
hmac: function(e, t) {
|
|
return u(t, e)
|
|
},
|
|
sha256: function(e) {
|
|
return c(e)
|
|
}
|
|
}
|
|
, f = ["authorization", "content-type", "content-length", "user-agent", "presigned-expires", "expect", "x-amzn-trace-id"]
|
|
, p = function(e) {
|
|
try {
|
|
return encodeURIComponent(e).replace(/[^A-Za-z0-9_.~\-%]+/g, escape).replace(/[*]/g, function(e) {
|
|
return "%".concat(e.charCodeAt(0).toString(16).toUpperCase())
|
|
})
|
|
} catch (e) {
|
|
return ""
|
|
}
|
|
}
|
|
, h = function(e) {
|
|
return Object.keys(e).sort().map(function(t) {
|
|
var r = e[t];
|
|
if (null != r) {
|
|
var n = p(t);
|
|
if (n)
|
|
return Array.isArray(r) ? "".concat(n, "=").concat(r.map(p).sort().join("&".concat(n, "="))) : "".concat(n, "=").concat(p(r))
|
|
}
|
|
}).filter(function(e) {
|
|
return e
|
|
}).join("&")
|
|
};
|
|
return function() {
|
|
var e, t;
|
|
function r(e, t, n) {
|
|
!function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, r),
|
|
this.request = e,
|
|
this.request.headers = e.headers || {},
|
|
this.serviceName = t,
|
|
n = n || {},
|
|
this.signatureCache = "boolean" != typeof n.signatureCache || n.signatureCache,
|
|
this.operation = n.operation,
|
|
this.signatureVersion = n.signatureVersion,
|
|
this.constant = n.isVolcengine ? {
|
|
algorithm: "HMAC-SHA256",
|
|
v4Identifier: "request",
|
|
dateHeader: "X-Date",
|
|
tokenHeader: "x-security-token",
|
|
contentSha256Header: "X-Content-Sha256",
|
|
kDatePrefix: ""
|
|
} : {
|
|
algorithm: "AWS4-HMAC-SHA256",
|
|
v4Identifier: "aws4_request",
|
|
dateHeader: "X-Amz-Date",
|
|
tokenHeader: "x-amz-security-token",
|
|
contentSha256Header: "X-Amz-Content-Sha256",
|
|
kDatePrefix: "AWS4"
|
|
},
|
|
this.bodySha256 = n.bodySha256,
|
|
this.shouldSerializeBody = "boolean" != typeof n.shouldSerializeBody || n.shouldSerializeBody
|
|
}
|
|
return e = [{
|
|
key: "addAuthorization",
|
|
value: function(e, t) {
|
|
var r = this.iso8601(t).replace(/[:\-]|\.\d{3}/g, "");
|
|
this.addHeaders(e, r),
|
|
this.request.headers.Authorization = this.authorization(e, r)
|
|
}
|
|
}, {
|
|
key: "addHeaders",
|
|
value: function(e, t) {
|
|
if (this.request.headers[this.constant.dateHeader] = t,
|
|
e.sessionToken && (this.request.headers[this.constant.tokenHeader] = e.sessionToken),
|
|
this.request.body) {
|
|
var r = this.request.body;
|
|
"string" != typeof r && this.shouldSerializeBody && (r = r instanceof URLSearchParams ? r.toString() : JSON.stringify(r)),
|
|
this.request.headers[this.constant.contentSha256Header] = this.bodySha256 || l.sha256(r).toString()
|
|
}
|
|
}
|
|
}, {
|
|
key: "authorization",
|
|
value: function(e, t) {
|
|
var r = []
|
|
, n = this.credentialString(t);
|
|
return r.push("".concat(this.constant.algorithm, " Credential=").concat(e.accessKeyId, "/").concat(n)),
|
|
r.push("SignedHeaders=".concat(this.signedHeaders())),
|
|
r.push("Signature=".concat(this.signature(e, t))),
|
|
r.join(", ")
|
|
}
|
|
}, {
|
|
key: "signature",
|
|
value: function(e, t) {
|
|
var r = this.getSigningKey(e, t.substr(0, 8), this.request.region, this.serviceName, this.signatureCache);
|
|
return l.hmac(r, this.stringToSign(t), "hex")
|
|
}
|
|
}, {
|
|
key: "stringToSign",
|
|
value: function(e) {
|
|
var t = [];
|
|
return t.push(this.constant.algorithm),
|
|
t.push(e),
|
|
t.push(this.credentialString(e)),
|
|
t.push(this.hexEncodedHash(this.canonicalString())),
|
|
t.join("\n")
|
|
}
|
|
}, {
|
|
key: "canonicalString",
|
|
value: function() {
|
|
var e = []
|
|
, t = this.request.pathname || "/";
|
|
return e.push(this.request.method.toUpperCase()),
|
|
e.push(t),
|
|
e.push(h(this.request.params) || ""),
|
|
e.push("".concat(this.canonicalHeaders(), "\n")),
|
|
e.push(this.signedHeaders()),
|
|
e.push(this.hexEncodedBodyHash()),
|
|
e.join("\n")
|
|
}
|
|
}, {
|
|
key: "canonicalHeaders",
|
|
value: function() {
|
|
var e = this
|
|
, t = [];
|
|
Object.keys(this.request.headers).forEach(function(r) {
|
|
t.push([r, e.request.headers[r]])
|
|
}),
|
|
t.sort(function(e, t) {
|
|
return e[0].toLowerCase() < t[0].toLowerCase() ? -1 : 1
|
|
});
|
|
var r = [];
|
|
return t.forEach(function(t) {
|
|
var n = t[0].toLowerCase();
|
|
if (e.isSignableHeader(n)) {
|
|
var i = t[1];
|
|
if (null == i || "function" != typeof i.toString)
|
|
throw Error("Header ".concat(n, " contains invalid value"));
|
|
r.push("".concat(n, ":").concat(e.canonicalHeaderValues(i.toString())))
|
|
}
|
|
}),
|
|
r.join("\n")
|
|
}
|
|
}, {
|
|
key: "canonicalHeaderValues",
|
|
value: function(e) {
|
|
return e.replace(/\s+/g, " ").replace(/^\s+|\s+$/g, "")
|
|
}
|
|
}, {
|
|
key: "signedHeaders",
|
|
value: function() {
|
|
var e = this
|
|
, t = [];
|
|
return Object.keys(this.request.headers).forEach(function(r) {
|
|
r = r.toLowerCase(),
|
|
e.isSignableHeader(r) && t.push(r)
|
|
}),
|
|
t.sort().join(";")
|
|
}
|
|
}, {
|
|
key: "credentialString",
|
|
value: function(e) {
|
|
return this.createScope(e.substr(0, 8), this.request.region, this.serviceName)
|
|
}
|
|
}, {
|
|
key: "hexEncodedHash",
|
|
value: function(e) {
|
|
return l.sha256(e)
|
|
}
|
|
}, {
|
|
key: "hexEncodedBodyHash",
|
|
value: function() {
|
|
return this.request.headers[this.constant.contentSha256Header] ? this.request.headers[this.constant.contentSha256Header] : this.request.body ? this.hexEncodedHash(h(this.request.body)) : this.hexEncodedHash("")
|
|
}
|
|
}, {
|
|
key: "isSignableHeader",
|
|
value: function(e) {
|
|
return 0 === e.toLowerCase().indexOf("x-amz-") || 0 > f.indexOf(e)
|
|
}
|
|
}, {
|
|
key: "iso8601",
|
|
value: function(e) {
|
|
return void 0 === e && (e = new Date),
|
|
e.toISOString().replace(/\.\d{3}Z$/, "Z")
|
|
}
|
|
}, {
|
|
key: "getSigningKey",
|
|
value: function(e, t, r, n) {
|
|
var i = l.hmac("".concat(this.constant.kDatePrefix).concat(e.secretAccessKey), t)
|
|
, o = l.hmac(i, r)
|
|
, s = l.hmac(o, n);
|
|
return l.hmac(s, this.constant.v4Identifier)
|
|
}
|
|
}, {
|
|
key: "createScope",
|
|
value: function(e, t, r) {
|
|
return [e.substr(0, 8), t, r, this.constant.v4Identifier].join("/")
|
|
}
|
|
}],
|
|
i(r.prototype, e),
|
|
t && i(r, t),
|
|
Object.defineProperty(r, "prototype", {
|
|
writable: !1
|
|
}),
|
|
r
|
|
}()
|
|
}(r(9))
|
|
}
|
|
).call(this, r(5))
|
|
}
|
|
function TEST3(e, t, r) {
|
|
e.exports = function() {
|
|
return r(10)('!function(t){var n={};function __webpack_require__(r){var e;return(n[r]||(e=n[r]={i:r,l:!1,exports:{}},t[r].call(e.exports,e,e.exports,__webpack_require__),e.l=!0,e)).exports}__webpack_require__.m=t,__webpack_require__.c=n,__webpack_require__.d=function(r,e,t){__webpack_require__.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:t})},__webpack_require__.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},__webpack_require__.t=function(e,r){if(1&r&&(e=__webpack_require__(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(__webpack_require__.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)__webpack_require__.d(t,n,function(r){return e[r]}.bind(null,n));return t},__webpack_require__.n=function(r){var e=r&&r.__esModule?function getDefault(){return r.default}:function getModuleExports(){return r};return __webpack_require__.d(e,"a",e),e},__webpack_require__.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=9)}([function(r,e,y){!function(_){r.exports=function(){var r=r||function(u,t){var r;if(typeof window!=="undefined"&&window.crypto)r=window.crypto;if(typeof self!=="undefined"&&self.crypto)r=self.crypto;if(typeof globalThis!=="undefined"&&globalThis.crypto)r=globalThis.crypto;if(!r&&typeof window!=="undefined"&&window.msCrypto)r=window.msCrypto;if(!r&&typeof _!=="undefined"&&_.crypto)r=_.crypto;if(!r&&"function"==="function")try{r=y(11)}catch(r){}var n=function(){if(r){if(typeof r.getRandomValues==="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch(r){}if(typeof r.randomBytes==="function")try{return r.randomBytes(4).readInt32LE()}catch(r){}}throw new Error("Native crypto module could not be used to get secure random number.")};var i=Object.create||function(){function F(){}return function(r){var e;F.prototype=r;e=new F;F.prototype=null;return e}}();var e={};var a=e.lib={};var o=a.Base=function(){return{extend:function(r){var e=i(this);if(r)e.mixIn(r);if(!e.hasOwnProperty("init")||this.init===e.init)e.init=function(){e.$super.init.apply(this,arguments)};e.init.prototype=e;e.$super=this;return e},create:function(){var r=this.extend();r.init.apply(r,arguments);return r},init:function(){},mixIn:function(r){for(var e in r)if(r.hasOwnProperty(e))this[e]=r[e];if(r.hasOwnProperty("toString"))this.toString=r.toString},clone:function(){return this.init.prototype.extend(this)}}}();var h=a.WordArray=o.extend({init:function(r,e){r=this.words=r||[];if(e!=t)this.sigBytes=e;else this.sigBytes=r.length*4},toString:function(r){return(r||s).stringify(this)},concat:function(r){var e=this.words;var t=r.words;var n=this.sigBytes;var i=r.sigBytes;this.clamp();if(n%4)for(var a=0;a<i;a++){var o=t[a>>>2]>>>24-a%4*8&255;e[n+a>>>2]|=o<<24-(n+a)%4*8}else for(var c=0;c<i;c+=4)e[n+c>>>2]=t[c>>>2];this.sigBytes+=i;return this},clamp:function(){var r=this.words;var e=this.sigBytes;r[e>>>2]&=4294967295<<32-e%4*8;r.length=u.ceil(e/4)},clone:function(){var r=o.clone.call(this);r.words=this.words.slice(0);return r},random:function(r){var e=[];for(var t=0;t<r;t+=4)e.push(n());return new h.init(e,r)}});var c=e.enc={};var s=c.Hex={stringify:function(r){var e=r.words;var t=r.sigBytes;var n=[];for(var i=0;i<t;i++){var a=e[i>>>2]>>>24-i%4*8&255;n.push((a>>>4).toString(16));n.push((a&15).toString(16))}return n.join("")},parse:function(r){var e=r.length;var t=[];for(var n=0;n<e;n+=2)t[n>>>3]|=parseInt(r.substr(n,2),16)<<24-n%8*4;return new h.init(t,e/2)}};var f=c.Latin1={stringify:function(r){var e=r.words;var t=r.sigBytes;var n=[];for(var i=0;i<t;i++){var a=e[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(a))}return n.join("")},parse:function(r){var e=r.length;var t=[];for(var n=0;n<e;n++)t[n>>>2]|=(r.charCodeAt(n)&255)<<24-n%4*8;return new h.init(t,e)}};var v=c.Utf8={stringify:function(r){try{return decodeURIComponent(escape(f.stringify(r)))}catch(r){throw new Error("Malformed UTF-8 data")}},parse:function(r){return f.parse(unescape(encodeURIComponent(r)))}};var p=a.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new h.init;this._nDataBytes=0},_append:function(r){if(typeof r=="string")r=v.parse(r);this._data.concat(r);this._nDataBytes+=r.sigBytes},_process:function(r){var e;var t=this._data;var n=t.words;var i=t.sigBytes;var a=this.blockSize;var o=a*4;var c=i/o;if(r)c=u.ceil(c);else c=u.max((c|0)-this._minBufferSize,0);var s=c*a;var f=u.min(s*4,i);if(s){for(var v=0;v<s;v+=a)this._doProcessBlock(n,v);e=n.splice(0,s);t.sigBytes-=f}return new h.init(e,f)},clone:function(){var r=o.clone.call(this);r._data=this._data.clone();return r},_minBufferSize:0});var l=a.Hasher=p.extend({cfg:o.extend(),init:function(r){this.cfg=this.cfg.extend(r);this.reset()},reset:function(){p.reset.call(this);this._doReset()},update:function(r){this._append(r);this._process();return this},finalize:function(r){if(r)this._append(r);var e=this._doFinalize();return e},blockSize:512/32,_createHelper:function(t){return function(r,e){return new t.init(e).finalize(r)}},_createHmacHelper:function(t){return function(r,e){return new d.HMAC.init(t,e).finalize(r)}}});var d=e.algo={};return e}(Math);return r}()}.call(this,y(10))},function(r,e,t){r.exports=function(F){F.lib.Cipher||function(o){var r=F;var e=r.lib;var t=e.Base;var s=e.WordArray;var n=e.BufferedBlockAlgorithm;var i=r.enc;var a=i.Utf8;var c=i.Base64;var f=r.algo;var v=f.EvpKDF;var u=e.Cipher=n.extend({cfg:t.extend(),createEncryptor:function(r,e){return this.create(this._ENC_XFORM_MODE,r,e)},createDecryptor:function(r,e){return this.create(this._DEC_XFORM_MODE,r,e)},init:function(r,e,t){this.cfg=this.cfg.extend(t);this._xformMode=r;this._key=e;this.reset()},reset:function(){n.reset.call(this);this._doReset()},process:function(r){this._append(r);return this._process()},finalize:function(r){if(r)this._append(r);var e=this._doFinalize();return e},keySize:128/32,ivSize:128/32,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function selectCipherStrategy(r){if(typeof r=="string")return S;else return m}return function(n){return{encrypt:function(r,e,t){return selectCipherStrategy(e).encrypt(n,r,e,t)},decrypt:function(r,e,t){return selectCipherStrategy(e).decrypt(n,r,e,t)}}}}()});var h=e.StreamCipher=u.extend({_doFinalize:function(){var r=this._process(!!"flush");return r},blockSize:1});var p=r.mode={};var l=e.BlockCipherMode=t.extend({createEncryptor:function(r,e){return this.Encryptor.create(r,e)},createDecryptor:function(r,e){return this.Decryptor.create(r,e)},init:function(r,e){this._cipher=r;this._iv=e}});var d=p.CBC=function(){var r=l.extend();r.Encryptor=r.extend({processBlock:function(r,e){var t=this._cipher;var n=t.blockSize;xorBlock.call(this,r,e,n);t.encryptBlock(r,e);this._prevBlock=r.slice(e,e+n)}});r.Decryptor=r.extend({processBlock:function(r,e){var t=this._cipher;var n=t.blockSize;var i=r.slice(e,e+n);t.decryptBlock(r,e);xorBlock.call(this,r,e,n);this._prevBlock=i}});function xorBlock(r,e,t){var n;var i=this._iv;if(i){n=i;this._iv=o}else n=this._prevBlock;for(var a=0;a<t;a++)r[e+a]^=n[a]}return r}();var _=r.pad={};var y=_.Pkcs7={pad:function(r,e){var t=e*4;var n=t-r.sigBytes%t;var i=n<<24|n<<16|n<<8|n;var a=[];for(var o=0;o<n;o+=4)a.push(i);var c=s.create(a,n);r.concat(c)},unpad:function(r){var e=r.words[r.sigBytes-1>>>2]&255;r.sigBytes-=e}};var g=e.BlockCipher=u.extend({cfg:u.cfg.extend({mode:d,padding:y}),reset:function(){var r;u.reset.call(this);var e=this.cfg;var t=e.iv;var n=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)r=n.createEncryptor;else{r=n.createDecryptor;this._minBufferSize=1}if(this._mode&&this._mode.__creator==r)this._mode.init(this,t&&t.words);else{this._mode=r.call(n,this,t&&t.words);this._mode.__creator=r}},_doProcessBlock:function(r,e){this._mode.processBlock(r,e)},_doFinalize:function(){var r;var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);r=this._process(!!"flush")}else{r=this._process(!!"flush");e.unpad(r)}return r},blockSize:128/32});var w=e.CipherParams=t.extend({init:function(r){this.mixIn(r)},toString:function(r){return(r||this.formatter).stringify(this)}});var k=r.format={};var B=k.OpenSSL={stringify:function(r){var e;var t=r.ciphertext;var n=r.salt;if(n)e=s.create([1398893684,1701076831]).concat(n).concat(t);else e=t;return e.toString(c)},parse:function(r){var e;var t=c.parse(r);var n=t.words;if(n[0]==1398893684&&n[1]==1701076831){e=s.create(n.slice(2,4));n.splice(0,4);t.sigBytes-=16}return w.create({ciphertext:t,salt:e})}};var m=e.SerializableCipher=t.extend({cfg:t.extend({format:B}),encrypt:function(r,e,t,n){n=this.cfg.extend(n);var i=r.createEncryptor(t,n);var a=i.finalize(e);var o=i.cfg;return w.create({ciphertext:a,key:t,iv:o.iv,algorithm:r,mode:o.mode,padding:o.padding,blockSize:r.blockSize,formatter:n.format})},decrypt:function(r,e,t,n){n=this.cfg.extend(n);e=this._parse(e,n.format);var i=r.createDecryptor(t,n).finalize(e.ciphertext);return i},_parse:function(r,e){if(typeof r=="string")return e.parse(r,this);else return r}});var x=r.kdf={};var b=x.OpenSSL={execute:function(r,e,t,n,i){if(!n)n=s.random(64/8);if(!i)var a=v.create({keySize:e+t}).compute(r,n);else var a=v.create({keySize:e+t,hasher:i}).compute(r,n);var o=s.create(a.words.slice(e),t*4);a.sigBytes=e*4;return w.create({key:a,iv:o,salt:n})}};var S=e.PasswordBasedCipher=m.extend({cfg:m.cfg.extend({kdf:b}),encrypt:function(r,e,t,n){n=this.cfg.extend(n);var i=n.kdf.execute(t,r.keySize,r.ivSize,n.salt,n.hasher);n.iv=i.iv;var a=m.encrypt.call(this,r,e,i.key,n);a.mixIn(i);return a},decrypt:function(r,e,t,n){n=this.cfg.extend(n);e=this._parse(e,n.format);var i=n.kdf.execute(t,r.keySize,r.ivSize,e.salt,n.hasher);n.iv=i.iv;var a=m.decrypt.call(this,r,e,i.key,n);return a}})}()}(t(0),t(5))},function(r,e,t){r.exports=function(a){return function(){var r=a;var e=r.lib;var t=e.BlockCipher;var n=r.algo;var v=[];var f=[];var u=[];var h=[];var p=[];var l=[];var d=[];var _=[];var y=[];var g=[];(function(){var r=[];for(var e=0;e<256;e++)if(e<128)r[e]=e<<1;else r[e]=e<<1^283;var t=0;var n=0;for(var e=0;e<256;e++){var i=n^n<<1^n<<2^n<<3^n<<4;i=i>>>8^i&255^99;v[t]=i;f[i]=t;var a=r[t];var o=r[a];var c=r[o];var s=r[i]*257^i*16843008;u[t]=s<<24|s>>>8;h[t]=s<<16|s>>>16;p[t]=s<<8|s>>>24;l[t]=s;var s=c*16843009^o*65537^a*257^t*16843008;d[i]=s<<24|s>>>8;_[i]=s<<16|s>>>16;y[i]=s<<8|s>>>24;g[i]=s;if(!t)t=n=1;else{t=a^r[r[r[c^a]]];n^=r[r[n]]}}})();var w=[0,1,2,4,8,16,32,64,128,27,54];var i=n.AES=t.extend({_doReset:function(){var r;if(this._nRounds&&this._keyPriorReset===this._key)return;var e=this._keyPriorReset=this._key;var t=e.words;var n=e.sigBytes/4;var i=this._nRounds=n+6;var a=(i+1)*4;var o=this._keySchedule=[];for(var c=0;c<a;c++)if(c<n)o[c]=t[c];else{r=o[c-1];if(!(c%n)){r=r<<8|r>>>24;r=v[r>>>24]<<24|v[r>>>16&255]<<16|v[r>>>8&255]<<8|v[r&255];r^=w[c/n|0]<<24}else if(n>6&&c%n==4)r=v[r>>>24]<<24|v[r>>>16&255]<<16|v[r>>>8&255]<<8|v[r&255];o[c]=o[c-n]^r}var s=this._invKeySchedule=[];for(var f=0;f<a;f++){var c=a-f;if(f%4)var r=o[c];else var r=o[c-4];if(f<4||c<=4)s[f]=r;else s[f]=d[v[r>>>24]]^_[v[r>>>16&255]]^y[v[r>>>8&255]]^g[v[r&255]]}},encryptBlock:function(r,e){this._doCryptBlock(r,e,this._keySchedule,u,h,p,l,v)},decryptBlock:function(r,e){var t=r[e+1];r[e+1]=r[e+3];r[e+3]=t;this._doCryptBlock(r,e,this._invKeySchedule,d,_,y,g,f);var t=r[e+1];r[e+1]=r[e+3];r[e+3]=t},_doCryptBlock:function(r,e,t,n,i,a,o,c){var s=this._nRounds;var f=r[e]^t[0];var v=r[e+1]^t[1];var u=r[e+2]^t[2];var h=r[e+3]^t[3];var p=4;for(var l=1;l<s;l++){var d=n[f>>>24]^i[v>>>16&255]^a[u>>>8&255]^o[h&255]^t[p++];var _=n[v>>>24]^i[u>>>16&255]^a[h>>>8&255]^o[f&255]^t[p++];var y=n[u>>>24]^i[h>>>16&255]^a[f>>>8&255]^o[v&255]^t[p++];var g=n[h>>>24]^i[f>>>16&255]^a[v>>>8&255]^o[u&255]^t[p++];f=d;v=_;u=y;h=g}var d=(c[f>>>24]<<24|c[v>>>16&255]<<16|c[u>>>8&255]<<8|c[h&255])^t[p++];var _=(c[v>>>24]<<24|c[u>>>16&255]<<16|c[h>>>8&255]<<8|c[f&255])^t[p++];var y=(c[u>>>24]<<24|c[h>>>16&255]<<16|c[f>>>8&255]<<8|c[v&255])^t[p++];var g=(c[h>>>24]<<24|c[f>>>16&255]<<16|c[v>>>8&255]<<8|c[u&255])^t[p++];r[e]=d;r[e+1]=_;r[e+2]=y;r[e+3]=g},keySize:256/32});r.AES=t._createHelper(i)}(),a.AES}(t(0),(t(12),t(13),t(5),t(1)))},function(r,e,t){r.exports=function(e){return e.mode.ECB=function(){var r=e.lib.BlockCipherMode.extend();r.Encryptor=r.extend({processBlock:function(r,e){this._cipher.encryptBlock(r,e)}});r.Decryptor=r.extend({processBlock:function(r,e){this._cipher.decryptBlock(r,e)}});return r}(),e.mode.ECB}(t(0),t(1))},function(r,e,t){r.exports=function(r){return r.enc.Utf8}(t(0))},function(r,e,t){r.exports=function(o){return function(){var r=o;var e=r.lib;var t=e.Base;var v=e.WordArray;var n=r.algo;var i=n.MD5;var a=n.EvpKDF=t.extend({cfg:t.extend({keySize:128/32,hasher:i,iterations:1}),init:function(r){this.cfg=this.cfg.extend(r)},compute:function(r,e){var t;var n=this.cfg;var i=n.hasher.create();var a=v.create();var o=a.words;var c=n.keySize;var s=n.iterations;while(o.length<c){if(t)i.update(t);t=i.update(r).finalize(e);i.reset();for(var f=1;f<s;f++){t=i.finalize(t);i.reset()}a.concat(t)}a.sigBytes=c*4;return a}});r.EvpKDF=function(r,e,t){return a.create(t).compute(r,e)}}(),o.EvpKDF}(t(0),(t(14),t(15)))},function(r,e,t){r.exports=function(r){return r.pad.Pkcs7}(t(0),t(1))},function(r,e,t){r.exports=function(r){return r.pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding}(t(0),t(1))},function(r,e,t){r.exports=function(a){return function(){if(typeof ArrayBuffer!="function")return;var r=a;var e=r.lib;var t=e.WordArray;var i=t.init;var n=t.init=function(r){if(r instanceof ArrayBuffer)r=new Uint8Array(r);if(r instanceof Int8Array||typeof Uint8ClampedArray!=="undefined"&&r instanceof Uint8ClampedArray||r instanceof Int16Array||r instanceof Uint16Array||r instanceof Int32Array||r instanceof Uint32Array||r instanceof Float32Array||r instanceof Float64Array)r=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);if(r instanceof Uint8Array){var e=r.byteLength;var t=[];for(var n=0;n<e;n++)t[n>>>2]|=r[n]<<24-n%4*8;i.call(this,t,e)}else i.apply(this,arguments)};n.prototype=t}(),a.lib.WordArray}(t(0))},function(r,e,t){"use strict";t.r(e);var e=t(2),o=t.n(e),e=t(3),c=t.n(e),e=t(6),s=t.n(e),e=t(7),f=t.n(e),e=t(8),v=t.n(e),e=t(4),u=t.n(e);function crc32(r,e){for(var t=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],n=("undefined"!=typeof Int32Array&&(t=new Int32Array(t)),-1^~~e),i=(r=new Uint8Array(r)).length,a=0;a<i;a++)n=t[255&(n^r[a])]^n>>>8;return(-1^n)>>>0}function dec2hex(r){if(void 0!==r)return function toEight(r){return r.length<8?toEight(r="0".concat(r)):r}(Number(r).toString(16))}self.onmessage=function(r){var r=r.data,e=r[0],t=r[1],n=r[2],i=r[3],a=r[4],r=r[5];i?(i=v.a.create(e),i=crc32(r=function wordArrayToUint8Array(r){for(var e=r.sigBytes,t=r.words,n=new Uint8Array(e),i=0,a=0;i!==e;){var o=t[a++];if(n[i++]=(4278190080&o)>>>24,i===e)break;if(n[i++]=(16711680&o)>>>16,i===e)break;if(n[i++]=(65280&o)>>>8,i===e)break;n[i++]=255&o}return n}((r&&e.byteLength%16!=0?o.a.encrypt(i,u.a.parse(a),{mode:c.a,padding:s.a}):o.a.encrypt(i,u.a.parse(a),{mode:c.a,padding:f.a})).ciphertext),0),postMessage([r.buffer,dec2hex(i),t,n],[r.buffer])):(a=crc32(e,0),postMessage([e,dec2hex(a),t,n],[e]))}},function(r,e){var t=function(){return this}();try{t=t||new Function("return this")()}catch(r){"object"==typeof window&&(t=window)}r.exports=t},function(r,e){},function(r,e,t){r.exports=function(i){return function(){var r=i;var e=r.lib;var f=e.WordArray;var t=r.enc;var n=t.Base64={stringify:function(r){var e=r.words;var t=r.sigBytes;var n=this._map;r.clamp();var i=[];for(var a=0;a<t;a+=3){var o=e[a>>>2]>>>24-a%4*8&255;var c=e[a+1>>>2]>>>24-(a+1)%4*8&255;var s=e[a+2>>>2]>>>24-(a+2)%4*8&255;var f=o<<16|c<<8|s;for(var v=0;v<4&&a+v*.75<t;v++)i.push(n.charAt(f>>>6*(3-v)&63))}var u=n.charAt(64);if(u)while(i.length%4)i.push(u);return i.join("")},parse:function(r){var e=r.length;var t=this._map;var n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var i=0;i<t.length;i++)n[t.charCodeAt(i)]=i}var a=t.charAt(64);if(a){var o=r.indexOf(a);if(o!==-1)e=o}return parseLoop(r,e,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function parseLoop(r,e,t){var n=[];var i=0;for(var a=0;a<e;a++)if(a%4){var o=t[r.charCodeAt(a-1)]<<a%4*2;var c=t[r.charCodeAt(a)]>>>6-a%4*2;var s=o|c;n[i>>>2]|=s<<24-i%4*8;i++}return f.create(n,i)}}(),i.enc.Base64}(t(0))},function(r,e,t){r.exports=function(o){return function(v){var r=o;var e=r.lib;var t=e.WordArray;var n=e.Hasher;var i=r.algo;var F=[];(function(){for(var r=0;r<64;r++)F[r]=v.abs(v.sin(r+1))*4294967296|0})();var a=i.MD5=n.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(r,e){for(var t=0;t<16;t++){var n=e+t;var i=r[n];r[n]=(i<<8|i>>>24)&16711935|(i<<24|i>>>8)&4278255360}var a=this._hash.words;var o=r[e+0];var c=r[e+1];var s=r[e+2];var f=r[e+3];var v=r[e+4];var u=r[e+5];var h=r[e+6];var p=r[e+7];var l=r[e+8];var d=r[e+9];var _=r[e+10];var y=r[e+11];var g=r[e+12];var w=r[e+13];var k=r[e+14];var B=r[e+15];var m=a[0];var x=a[1];var b=a[2];var S=a[3];m=FF(m,x,b,S,o,7,F[0]);S=FF(S,m,x,b,c,12,F[1]);b=FF(b,S,m,x,s,17,F[2]);x=FF(x,b,S,m,f,22,F[3]);m=FF(m,x,b,S,v,7,F[4]);S=FF(S,m,x,b,u,12,F[5]);b=FF(b,S,m,x,h,17,F[6]);x=FF(x,b,S,m,p,22,F[7]);m=FF(m,x,b,S,l,7,F[8]);S=FF(S,m,x,b,d,12,F[9]);b=FF(b,S,m,x,_,17,F[10]);x=FF(x,b,S,m,y,22,F[11]);m=FF(m,x,b,S,g,7,F[12]);S=FF(S,m,x,b,w,12,F[13]);b=FF(b,S,m,x,k,17,F[14]);x=FF(x,b,S,m,B,22,F[15]);m=GG(m,x,b,S,c,5,F[16]);S=GG(S,m,x,b,h,9,F[17]);b=GG(b,S,m,x,y,14,F[18]);x=GG(x,b,S,m,o,20,F[19]);m=GG(m,x,b,S,u,5,F[20]);S=GG(S,m,x,b,_,9,F[21]);b=GG(b,S,m,x,B,14,F[22]);x=GG(x,b,S,m,v,20,F[23]);m=GG(m,x,b,S,d,5,F[24]);S=GG(S,m,x,b,k,9,F[25]);b=GG(b,S,m,x,f,14,F[26]);x=GG(x,b,S,m,l,20,F[27]);m=GG(m,x,b,S,w,5,F[28]);S=GG(S,m,x,b,s,9,F[29]);b=GG(b,S,m,x,p,14,F[30]);x=GG(x,b,S,m,g,20,F[31]);m=HH(m,x,b,S,u,4,F[32]);S=HH(S,m,x,b,l,11,F[33]);b=HH(b,S,m,x,y,16,F[34]);x=HH(x,b,S,m,k,23,F[35]);m=HH(m,x,b,S,c,4,F[36]);S=HH(S,m,x,b,v,11,F[37]);b=HH(b,S,m,x,p,16,F[38]);x=HH(x,b,S,m,_,23,F[39]);m=HH(m,x,b,S,w,4,F[40]);S=HH(S,m,x,b,o,11,F[41]);b=HH(b,S,m,x,f,16,F[42]);x=HH(x,b,S,m,h,23,F[43]);m=HH(m,x,b,S,d,4,F[44]);S=HH(S,m,x,b,g,11,F[45]);b=HH(b,S,m,x,B,16,F[46]);x=HH(x,b,S,m,s,23,F[47]);m=II(m,x,b,S,o,6,F[48]);S=II(S,m,x,b,p,10,F[49]);b=II(b,S,m,x,k,15,F[50]);x=II(x,b,S,m,u,21,F[51]);m=II(m,x,b,S,g,6,F[52]);S=II(S,m,x,b,f,10,F[53]);b=II(b,S,m,x,_,15,F[54]);x=II(x,b,S,m,c,21,F[55]);m=II(m,x,b,S,l,6,F[56]);S=II(S,m,x,b,B,10,F[57]);b=II(b,S,m,x,h,15,F[58]);x=II(x,b,S,m,w,21,F[59]);m=II(m,x,b,S,v,6,F[60]);S=II(S,m,x,b,y,10,F[61]);b=II(b,S,m,x,s,15,F[62]);x=II(x,b,S,m,d,21,F[63]);a[0]=a[0]+m|0;a[1]=a[1]+x|0;a[2]=a[2]+b|0;a[3]=a[3]+S|0},_doFinalize:function(){var r=this._data;var e=r.words;var t=this._nDataBytes*8;var n=r.sigBytes*8;e[n>>>5]|=128<<24-n%32;var i=v.floor(t/4294967296);var a=t;e[(n+64>>>9<<4)+15]=(i<<8|i>>>24)&16711935|(i<<24|i>>>8)&4278255360;e[(n+64>>>9<<4)+14]=(a<<8|a>>>24)&16711935|(a<<24|a>>>8)&4278255360;r.sigBytes=(e.length+1)*4;this._process();var o=this._hash;var c=o.words;for(var s=0;s<4;s++){var f=c[s];c[s]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360}return o},clone:function(){var r=n.clone.call(this);r._hash=this._hash.clone();return r}});function FF(r,e,t,n,i,a,o){var c=r+(e&t|~e&n)+i+o;return(c<<a|c>>>32-a)+e}function GG(r,e,t,n,i,a,o){var c=r+(e&n|t&~n)+i+o;return(c<<a|c>>>32-a)+e}function HH(r,e,t,n,i,a,o){var c=r+(e^t^n)+i+o;return(c<<a|c>>>32-a)+e}function II(r,e,t,n,i,a,o){var c=r+(t^(e|~n))+i+o;return(c<<a|c>>>32-a)+e}r.MD5=n._createHelper(a);r.HmacMD5=n._createHmacHelper(a)}(Math),o.MD5}(t(0))},function(r,e,t){r.exports=function(o){return function(){var r=o;var e=r.lib;var t=e.WordArray;var n=e.Hasher;var i=r.algo;var u=[];var a=i.SHA1=n.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(r,e){var t=this._hash.words;var n=t[0];var i=t[1];var a=t[2];var o=t[3];var c=t[4];for(var s=0;s<80;s++){if(s<16)u[s]=r[e+s]|0;else{var f=u[s-3]^u[s-8]^u[s-14]^u[s-16];u[s]=f<<1|f>>>31}var v=(n<<5|n>>>27)+c+u[s];if(s<20)v+=(i&a|~i&o)+1518500249;else if(s<40)v+=(i^a^o)+1859775393;else if(s<60)v+=(i&a|i&o|a&o)-1894007588;else v+=(i^a^o)-899497514;c=o;o=a;a=i<<30|i>>>2;i=n;n=v}t[0]=t[0]+n|0;t[1]=t[1]+i|0;t[2]=t[2]+a|0;t[3]=t[3]+o|0;t[4]=t[4]+c|0},_doFinalize:function(){var r=this._data;var e=r.words;var t=this._nDataBytes*8;var n=r.sigBytes*8;e[n>>>5]|=128<<24-n%32;e[(n+64>>>9<<4)+14]=Math.floor(t/4294967296);e[(n+64>>>9<<4)+15]=t;r.sigBytes=e.length*4;this._process();return this._hash},clone:function(){var r=n.clone.call(this);r._hash=this._hash.clone();return r}});r.SHA1=n._createHelper(a);r.HmacSHA1=n._createHmacHelper(a)}(),o.SHA1}(t(0))},function(r,e,t){r.exports=function(o){(function(){var r=o;var e=r.lib;var t=e.Base;var n=r.enc;var f=n.Utf8;var i=r.algo;var a=i.HMAC=t.extend({init:function(r,e){r=this._hasher=new r.init;if(typeof e=="string")e=f.parse(e);var t=r.blockSize;var n=t*4;if(e.sigBytes>n)e=r.finalize(e);e.clamp();var i=this._oKey=e.clone();var a=this._iKey=e.clone();var o=i.words;var c=a.words;for(var s=0;s<t;s++){o[s]^=1549556828;c[s]^=909522486}i.sigBytes=a.sigBytes=n;this.reset()},reset:function(){var r=this._hasher;r.reset();r.update(this._iKey)},update:function(r){this._hasher.update(r);return this},finalize:function(r){var e=this._hasher;var t=e.finalize(r);e.reset();var n=e.finalize(this._oKey.clone().concat(t));return n}})})()}(t(0))}]);', null)
|
|
}
|
|
}
|
|
function TEST4(e, t, r) {
|
|
(function(t) {
|
|
var n;
|
|
e.exports = n || function(e, n) {
|
|
if ("undefined" != typeof window && window.crypto && (i = window.crypto),
|
|
"undefined" != typeof self && self.crypto && (i = self.crypto),
|
|
"undefined" != typeof globalThis && globalThis.crypto && (i = globalThis.crypto),
|
|
!i && "undefined" != typeof window && window.msCrypto && (i = window.msCrypto),
|
|
!i && void 0 !== t && t.crypto && (i = t.crypto),
|
|
!i)
|
|
try {
|
|
i = r(7)
|
|
} catch (e) {}
|
|
var i, o = function() {
|
|
if (i) {
|
|
if ("function" == typeof i.getRandomValues)
|
|
try {
|
|
return i.getRandomValues(new Uint32Array(1))[0]
|
|
} catch (e) {}
|
|
if ("function" == typeof i.randomBytes)
|
|
try {
|
|
return i.randomBytes(4).readInt32LE()
|
|
} catch (e) {}
|
|
}
|
|
throw Error("Native crypto module could not be used to get secure random number.")
|
|
}, s = Object.create || function() {
|
|
function e() {}
|
|
return function(t) {
|
|
var r;
|
|
return e.prototype = t,
|
|
r = new e,
|
|
e.prototype = null,
|
|
r
|
|
}
|
|
}(), a = {}, c = a.lib = {}, u = c.Base = {
|
|
extend: function(e) {
|
|
var t = s(this);
|
|
return e && t.mixIn(e),
|
|
(!t.hasOwnProperty("init") || this.init === t.init) && (t.init = function() {
|
|
t.$super.init.apply(this, arguments)
|
|
}
|
|
),
|
|
t.init.prototype = t,
|
|
t.$super = this,
|
|
t
|
|
},
|
|
create: function() {
|
|
var e = this.extend();
|
|
return e.init.apply(e, arguments),
|
|
e
|
|
},
|
|
init: function() {},
|
|
mixIn: function(e) {
|
|
for (var t in e)
|
|
e.hasOwnProperty(t) && (this[t] = e[t]);
|
|
e.hasOwnProperty("toString") && (this.toString = e.toString)
|
|
},
|
|
clone: function() {
|
|
return this.init.prototype.extend(this)
|
|
}
|
|
}, l = c.WordArray = u.extend({
|
|
init: function(e, t) {
|
|
e = this.words = e || [],
|
|
t != n ? this.sigBytes = t : this.sigBytes = 4 * e.length
|
|
},
|
|
toString: function(e) {
|
|
return (e || p).stringify(this)
|
|
},
|
|
concat: function(e) {
|
|
var t = this.words
|
|
, r = e.words
|
|
, n = this.sigBytes
|
|
, i = e.sigBytes;
|
|
if (this.clamp(),
|
|
n % 4)
|
|
for (var o = 0; o < i; o++) {
|
|
var s = r[o >>> 2] >>> 24 - o % 4 * 8 & 255;
|
|
t[n + o >>> 2] |= s << 24 - (n + o) % 4 * 8
|
|
}
|
|
else
|
|
for (var a = 0; a < i; a += 4)
|
|
t[n + a >>> 2] = r[a >>> 2];
|
|
return this.sigBytes += i,
|
|
this
|
|
},
|
|
clamp: function() {
|
|
var t = this.words
|
|
, r = this.sigBytes;
|
|
t[r >>> 2] &= 0xffffffff << 32 - r % 4 * 8,
|
|
t.length = e.ceil(r / 4)
|
|
},
|
|
clone: function() {
|
|
var e = u.clone.call(this);
|
|
return e.words = this.words.slice(0),
|
|
e
|
|
},
|
|
random: function(e) {
|
|
for (var t = [], r = 0; r < e; r += 4)
|
|
t.push(o());
|
|
return new l.init(t,e)
|
|
}
|
|
}), f = a.enc = {}, p = f.Hex = {
|
|
stringify: function(e) {
|
|
for (var t = e.words, r = e.sigBytes, n = [], i = 0; i < r; i++) {
|
|
var o = t[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
n.push((o >>> 4).toString(16)),
|
|
n.push((15 & o).toString(16))
|
|
}
|
|
return n.join("")
|
|
},
|
|
parse: function(e) {
|
|
for (var t = e.length, r = [], n = 0; n < t; n += 2)
|
|
r[n >>> 3] |= parseInt(e.substr(n, 2), 16) << 24 - n % 8 * 4;
|
|
return new l.init(r,t / 2)
|
|
}
|
|
}, h = f.Latin1 = {
|
|
stringify: function(e) {
|
|
for (var t = e.words, r = e.sigBytes, n = [], i = 0; i < r; i++) {
|
|
var o = t[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
n.push(String.fromCharCode(o))
|
|
}
|
|
return n.join("")
|
|
},
|
|
parse: function(e) {
|
|
for (var t = e.length, r = [], n = 0; n < t; n++)
|
|
r[n >>> 2] |= (255 & e.charCodeAt(n)) << 24 - n % 4 * 8;
|
|
return new l.init(r,t)
|
|
}
|
|
}, d = f.Utf8 = {
|
|
stringify: function(e) {
|
|
try {
|
|
return decodeURIComponent(escape(h.stringify(e)))
|
|
} catch (e) {
|
|
throw Error("Malformed UTF-8 data")
|
|
}
|
|
},
|
|
parse: function(e) {
|
|
return h.parse(unescape(encodeURIComponent(e)))
|
|
}
|
|
}, g = c.BufferedBlockAlgorithm = u.extend({
|
|
reset: function() {
|
|
this._data = new l.init,
|
|
this._nDataBytes = 0
|
|
},
|
|
_append: function(e) {
|
|
"string" == typeof e && (e = d.parse(e)),
|
|
this._data.concat(e),
|
|
this._nDataBytes += e.sigBytes
|
|
},
|
|
_process: function(t) {
|
|
var r, n = this._data, i = n.words, o = n.sigBytes, s = this.blockSize, a = o / (4 * s), c = (a = t ? e.ceil(a) : e.max((0 | a) - this._minBufferSize, 0)) * s, u = e.min(4 * c, o);
|
|
if (c) {
|
|
for (var f = 0; f < c; f += s)
|
|
this._doProcessBlock(i, f);
|
|
r = i.splice(0, c),
|
|
n.sigBytes -= u
|
|
}
|
|
return new l.init(r,u)
|
|
},
|
|
clone: function() {
|
|
var e = u.clone.call(this);
|
|
return e._data = this._data.clone(),
|
|
e
|
|
},
|
|
_minBufferSize: 0
|
|
});
|
|
c.Hasher = g.extend({
|
|
cfg: u.extend(),
|
|
init: function(e) {
|
|
this.cfg = this.cfg.extend(e),
|
|
this.reset()
|
|
},
|
|
reset: function() {
|
|
g.reset.call(this),
|
|
this._doReset()
|
|
},
|
|
update: function(e) {
|
|
return this._append(e),
|
|
this._process(),
|
|
this
|
|
},
|
|
finalize: function(e) {
|
|
return e && this._append(e),
|
|
this._doFinalize()
|
|
},
|
|
blockSize: 16,
|
|
_createHelper: function(e) {
|
|
return function(t, r) {
|
|
return new e.init(r).finalize(t)
|
|
}
|
|
},
|
|
_createHmacHelper: function(e) {
|
|
return function(t, r) {
|
|
return new y.HMAC.init(e,r).finalize(t)
|
|
}
|
|
}
|
|
});
|
|
var y = a.algo = {};
|
|
return a
|
|
}(Math)
|
|
}
|
|
).call(this, r(5))
|
|
}
|
|
function TEST5(e, t, r) {
|
|
var n;
|
|
e.exports = (n = r(3),
|
|
function(e) {
|
|
var t = n.lib
|
|
, r = t.WordArray
|
|
, i = t.Hasher
|
|
, o = n.algo
|
|
, s = []
|
|
, a = [];
|
|
(function() {
|
|
function t(e) {
|
|
return (e - (0 | e)) * 0x100000000 | 0
|
|
}
|
|
for (var r = 2, n = 0; n < 64; )
|
|
(function(t) {
|
|
for (var r = e.sqrt(t), n = 2; n <= r; n++)
|
|
if (!(t % n))
|
|
return !1;
|
|
return !0
|
|
}
|
|
)(r) && (n < 8 && (s[n] = t(e.pow(r, .5))),
|
|
a[n] = t(e.pow(r, 1 / 3)),
|
|
n++),
|
|
r++
|
|
}
|
|
)();
|
|
var c = []
|
|
, u = o.SHA256 = i.extend({
|
|
_doReset: function() {
|
|
this._hash = new r.init(s.slice(0))
|
|
},
|
|
_doProcessBlock: function(e, t) {
|
|
for (var r = this._hash.words, n = r[0], i = r[1], o = r[2], s = r[3], u = r[4], l = r[5], f = r[6], p = r[7], h = 0; h < 64; h++) {
|
|
if (h < 16)
|
|
c[h] = 0 | e[t + h];
|
|
else {
|
|
var d = c[h - 15]
|
|
, g = (d << 25 | d >>> 7) ^ (d << 14 | d >>> 18) ^ d >>> 3
|
|
, y = c[h - 2]
|
|
, m = (y << 15 | y >>> 17) ^ (y << 13 | y >>> 19) ^ y >>> 10;
|
|
c[h] = g + c[h - 7] + m + c[h - 16]
|
|
}
|
|
var v = u & l ^ ~u & f
|
|
, b = n & i ^ n & o ^ i & o
|
|
, _ = (n << 30 | n >>> 2) ^ (n << 19 | n >>> 13) ^ (n << 10 | n >>> 22)
|
|
, S = p + ((u << 26 | u >>> 6) ^ (u << 21 | u >>> 11) ^ (u << 7 | u >>> 25)) + v + a[h] + c[h]
|
|
, x = _ + b;
|
|
p = f,
|
|
f = l,
|
|
l = u,
|
|
u = s + S | 0,
|
|
s = o,
|
|
o = i,
|
|
i = n,
|
|
n = S + x | 0
|
|
}
|
|
r[0] = r[0] + n | 0,
|
|
r[1] = r[1] + i | 0,
|
|
r[2] = r[2] + o | 0,
|
|
r[3] = r[3] + s | 0,
|
|
r[4] = r[4] + u | 0,
|
|
r[5] = r[5] + l | 0,
|
|
r[6] = r[6] + f | 0,
|
|
r[7] = r[7] + p | 0
|
|
},
|
|
_doFinalize: function() {
|
|
var t = this._data
|
|
, r = t.words
|
|
, n = 8 * this._nDataBytes
|
|
, i = 8 * t.sigBytes;
|
|
return r[i >>> 5] |= 128 << 24 - i % 32,
|
|
r[(i + 64 >>> 9 << 4) + 14] = e.floor(n / 0x100000000),
|
|
r[(i + 64 >>> 9 << 4) + 15] = n,
|
|
t.sigBytes = 4 * r.length,
|
|
this._process(),
|
|
this._hash
|
|
},
|
|
clone: function() {
|
|
var e = i.clone.call(this);
|
|
return e._hash = this._hash.clone(),
|
|
e
|
|
}
|
|
});
|
|
n.SHA256 = i._createHelper(u),
|
|
n.HmacSHA256 = i._createHmacHelper(u)
|
|
}(Math),
|
|
n.SHA256)
|
|
}
|
|
function TEST6(e, t) {
|
|
var r = function() {
|
|
return this
|
|
}();
|
|
try {
|
|
r = r || Function("return this")()
|
|
} catch (e) {
|
|
"object" == typeof window && (r = window)
|
|
}
|
|
e.exports = r
|
|
}
|
|
function TEST7(e, t, r) {
|
|
var n;
|
|
e.exports = (n = r(3),
|
|
r(4),
|
|
r(8),
|
|
n.HmacSHA256)
|
|
}
|
|
function TEST8(e, t) {}
|
|
function TEST9(e, t, r) {
|
|
var n, i, o;
|
|
e.exports = void (i = (n = r(3)).lib.Base,
|
|
o = n.enc.Utf8,
|
|
n.algo.HMAC = i.extend({
|
|
init: function(e, t) {
|
|
e = this._hasher = new e.init,
|
|
"string" == typeof t && (t = o.parse(t));
|
|
var r = e.blockSize
|
|
, n = 4 * r;
|
|
t.sigBytes > n && (t = e.finalize(t)),
|
|
t.clamp();
|
|
for (var i = this._oKey = t.clone(), s = this._iKey = t.clone(), a = i.words, c = s.words, u = 0; u < r; u++)
|
|
a[u] ^= 0x5c5c5c5c,
|
|
c[u] ^= 0x36363636;
|
|
i.sigBytes = s.sigBytes = n,
|
|
this.reset()
|
|
},
|
|
reset: function() {
|
|
var e = this._hasher;
|
|
e.reset(),
|
|
e.update(this._iKey)
|
|
},
|
|
update: function(e) {
|
|
return this._hasher.update(e),
|
|
this
|
|
},
|
|
finalize: function(e) {
|
|
var t = this._hasher
|
|
, r = t.finalize(e);
|
|
return t.reset(),
|
|
t.finalize(this._oKey.clone().concat(r))
|
|
}
|
|
}))
|
|
}
|
|
function TEST10(e, t) {}
|
|
function TEST11(e, t, r) {
|
|
"use strict";
|
|
var n = window.URL || window.webkitURL;
|
|
e.exports = function(e, t) {
|
|
try {
|
|
try {
|
|
var r;
|
|
try {
|
|
(r = new (window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder)).append(e),
|
|
r = r.getBlob()
|
|
} catch (t) {
|
|
r = new Blob([e])
|
|
}
|
|
return new Worker(n.createObjectURL(r))
|
|
} catch (t) {
|
|
return new Worker("data:application/javascript," + encodeURIComponent(e))
|
|
}
|
|
} catch (e) {
|
|
if (t)
|
|
return new Worker(t);
|
|
throw Error("Inline worker is not supported")
|
|
}
|
|
}
|
|
}
|
|
function TEST12(e, t, r) {
|
|
"use strict";
|
|
r.r(t),
|
|
r.d(t, "default", function() {
|
|
return t7
|
|
});
|
|
var t = r(0)
|
|
, n = r.n(t)
|
|
, i = "{tosDomain}/upload/v1/{oid}?uploadid={uploadId}&part_number={part_number}&phase=transfer"
|
|
, o = "{tosDomain}/upload/v1/{oid}"
|
|
, s = {
|
|
debug: !1,
|
|
region: "cn-north-1",
|
|
external: {},
|
|
getSliceFunc: null,
|
|
uploadSliceCount: 3,
|
|
retryUploadTime: 2,
|
|
retryProcess: !0,
|
|
retryProcessTime: 3,
|
|
retryTaskTime: 2,
|
|
progressMonitorTime: 1e4,
|
|
progressMonitorSpeed: 50,
|
|
schema: "https",
|
|
enableDiskBreakpoint: !0,
|
|
gatewayTimeout: 3e4,
|
|
uploadTimeout: 18e5,
|
|
realtimeSpeedInterval: 3e3,
|
|
replace: {}
|
|
}
|
|
, a = function() {
|
|
return (a = Object.assign || function(e) {
|
|
for (var t, r = 1, n = arguments.length; r < n; r++)
|
|
for (var i in t = arguments[r])
|
|
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
|
|
return e
|
|
}
|
|
).apply(this, arguments)
|
|
};
|
|
function c() {
|
|
for (var e = [], t = 0; t < arguments.length; t++)
|
|
e = e.concat(function(e, t) {
|
|
var r = "function" == typeof Symbol && e[Symbol.iterator];
|
|
if (!r)
|
|
return e;
|
|
var n, i, o = r.call(e), s = [];
|
|
try {
|
|
for (; (void 0 === t || 0 < t--) && !(n = o.next()).done; )
|
|
s.push(n.value)
|
|
} catch (e) {
|
|
i = {
|
|
error: e
|
|
}
|
|
} finally {
|
|
try {
|
|
n && !n.done && (r = o.return) && r.call(o)
|
|
} finally {
|
|
if (i)
|
|
throw i.error
|
|
}
|
|
}
|
|
return s
|
|
}(arguments[t]));
|
|
return e
|
|
}
|
|
function u(e) {
|
|
return null != e && "[object Object]" == Object.prototype.toString.call(e)
|
|
}
|
|
function l(e) {
|
|
return function(e) {
|
|
if ("string" == typeof e) {
|
|
for (var t = [], r = e.split("z"), n = 0; n < r.length; n++) {
|
|
var i = 64 ^ +parseInt(r[n], 25)
|
|
, i = String.fromCharCode(i);
|
|
t.push(i)
|
|
}
|
|
return t.join("")
|
|
}
|
|
}(e)
|
|
}
|
|
function f(e) {
|
|
var t = document.createElement("a");
|
|
return t.href = e,
|
|
t
|
|
}
|
|
function p(e) {
|
|
var t = {};
|
|
try {
|
|
var r = f(e).search;
|
|
if (!r)
|
|
return t;
|
|
(r = r.slice(1)).split("&").forEach(function(e) {
|
|
var r, n, i = e.split("=");
|
|
i.length && (r = i[0],
|
|
n = i[1]);
|
|
try {
|
|
t[r] = decodeURIComponent(void 0 === n ? "" : n)
|
|
} catch (e) {
|
|
t[r] = n
|
|
}
|
|
})
|
|
} catch (e) {}
|
|
return t
|
|
}
|
|
function h(e) {
|
|
for (var t = 0, r = 0, n = (e += "").length, i = 0; i < n; i++)
|
|
(0x7fffffffffff < (t = 31 * t + e.charCodeAt(r++)) || t < -0x800000000000) && (t &= 0xffffffffffff);
|
|
return t < 0 && (t += 0x7ffffffffffff),
|
|
t
|
|
}
|
|
function d(e, t) {
|
|
try {
|
|
return e ? w.get(e, {
|
|
domain: t || document.domain
|
|
}) : w.get()
|
|
} catch (e) {
|
|
return ""
|
|
}
|
|
}
|
|
function g(e, t, r, n) {
|
|
try {
|
|
var i = n || document.domain
|
|
, o = +new Date + (r || 6048e5);
|
|
w.set(e, t, {
|
|
expires: new Date(o),
|
|
path: "/",
|
|
domain: i
|
|
})
|
|
} catch (e) {}
|
|
}
|
|
function y() {
|
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
|
|
var t = 16 * Math.random() | 0;
|
|
return ("x" === e ? t : 3 & t | 8).toString(16)
|
|
})
|
|
}
|
|
function m() {
|
|
return (function e(t) {
|
|
return t ? (t ^ 16 * Math.random() >> t / 4).toString(10) : "10000000-1000-4000-8000-100000000000".replace(/[018]/g, e)
|
|
}
|
|
)().replace(/-/g, "").slice(0, 19)
|
|
}
|
|
var v, b, _, S, x = function() {
|
|
function e() {
|
|
this._hooks = {},
|
|
this._cache = [],
|
|
this._hooksCache = {}
|
|
}
|
|
return e.prototype.on = function(e, t) {
|
|
e && t && "function" == typeof t && (this._hooks[e] || (this._hooks[e] = []),
|
|
this._hooks[e].push(t))
|
|
}
|
|
,
|
|
e.prototype.once = function(e, t) {
|
|
var r = this;
|
|
e && t && "function" == typeof t && this.on(e, function n(i) {
|
|
t(i),
|
|
r.off(e, n)
|
|
})
|
|
}
|
|
,
|
|
e.prototype.off = function(e, t) {
|
|
e && this._hooks[e] && this._hooks[e].length && (t ? -1 !== (t = this._hooks[e].indexOf(t)) && this._hooks[e].splice(t, 1) : this._hooks[e] = [])
|
|
}
|
|
,
|
|
e.prototype.emit = function(e, t, r) {
|
|
r ? e && (-1 !== this._cache.indexOf(r) ? this._emit(e, t) : (this._hooksCache.hasOwnProperty(r) || (this._hooksCache[r] = {}),
|
|
this._hooksCache[r].hasOwnProperty(e) || (this._hooksCache[r][e] = []),
|
|
this._hooksCache[r][e].push(t))) : this._emit(e, t)
|
|
}
|
|
,
|
|
e.prototype._emit = function(e, t) {
|
|
e && this._hooks[e] && this._hooks[e].length && c(this._hooks[e]).forEach(function(e) {
|
|
try {
|
|
e(t)
|
|
} catch (e) {}
|
|
})
|
|
}
|
|
,
|
|
e.prototype.set = function(e) {
|
|
e && -1 === this._cache.indexOf(e) && this._cache.push(e)
|
|
}
|
|
,
|
|
e
|
|
}(), w = (_ = +Date.now() + Number(("" + Math.random()).slice(2, 8)),
|
|
(t = {
|
|
exports: {}
|
|
}).exports = function() {
|
|
function e() {
|
|
for (var e = 0, t = {}; e < arguments.length; e++) {
|
|
var r, n = arguments[e];
|
|
for (r in n)
|
|
t[r] = n[r]
|
|
}
|
|
return t
|
|
}
|
|
function t(e) {
|
|
return e.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent)
|
|
}
|
|
return function r(n) {
|
|
function i() {}
|
|
function o(t, r, o) {
|
|
if ("undefined" != typeof document) {
|
|
"number" == typeof (o = e({
|
|
path: "/"
|
|
}, i.defaults, o)).expires && (o.expires = new Date(+new Date + 864e5 * o.expires)),
|
|
o.expires = o.expires ? o.expires.toUTCString() : "";
|
|
try {
|
|
var s = JSON.stringify(r);
|
|
/^[\{\[]/.test(s) && (r = s)
|
|
} catch (e) {}
|
|
r = n.write ? n.write(r, t) : encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent),
|
|
t = encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[\(\)]/g, escape);
|
|
var a, c = "";
|
|
for (a in o)
|
|
o[a] && (c += "; " + a,
|
|
!0 !== o[a]) && (c += "=" + o[a].split(";")[0]);
|
|
return document.cookie = t + "=" + r + c
|
|
}
|
|
}
|
|
function s(e, r) {
|
|
if ("undefined" != typeof document) {
|
|
for (var i = {}, o = document.cookie ? document.cookie.split("; ") : [], s = 0; s < o.length; s++) {
|
|
var a = o[s].split("=")
|
|
, c = a.slice(1).join("=");
|
|
r || '"' !== c.charAt(0) || (c = c.slice(1, -1));
|
|
try {
|
|
var u = t(a[0])
|
|
, c = (n.read || n)(c, u) || t(c);
|
|
if (r)
|
|
try {
|
|
c = JSON.parse(c)
|
|
} catch (e) {}
|
|
if (i[u] = c,
|
|
e === u)
|
|
break
|
|
} catch (e) {}
|
|
}
|
|
return e ? i[e] : i
|
|
}
|
|
}
|
|
return i.set = o,
|
|
i.get = function(e) {
|
|
return s(e, !1)
|
|
}
|
|
,
|
|
i.getJSON = function(e) {
|
|
return s(e, !0)
|
|
}
|
|
,
|
|
i.remove = function(t, r) {
|
|
o(t, "", e(r, {
|
|
expires: -1
|
|
}))
|
|
}
|
|
,
|
|
i.defaults = {},
|
|
i.withConverter = r,
|
|
i
|
|
}(function() {})
|
|
}(),
|
|
t.exports), k = function() {
|
|
function e() {
|
|
this.cache = {}
|
|
}
|
|
return e.prototype.setItem = function(e, t) {
|
|
this.cache[e] = t
|
|
}
|
|
,
|
|
e.prototype.getItem = function(e) {
|
|
return this.cache[e]
|
|
}
|
|
,
|
|
e.prototype.removeItem = function(e) {
|
|
this.cache[e] = void 0
|
|
}
|
|
,
|
|
e.prototype.getCookie = function(e, t) {
|
|
return d(e, t)
|
|
}
|
|
,
|
|
e.prototype.setCookie = function(e, t, r, n) {
|
|
g(e, t, r, n)
|
|
}
|
|
,
|
|
e
|
|
}(), E = {
|
|
getItem: function(e) {
|
|
try {
|
|
var t = localStorage.getItem(e)
|
|
, r = t;
|
|
try {
|
|
t && "string" == typeof t && (r = JSON.parse(t))
|
|
} catch (e) {}
|
|
return r || {}
|
|
} catch (e) {}
|
|
return {}
|
|
},
|
|
setItem: function(e, t) {
|
|
try {
|
|
var r = "string" == typeof t ? t : JSON.stringify(t);
|
|
localStorage.setItem(e, r)
|
|
} catch (e) {}
|
|
},
|
|
removeItem: function(e) {
|
|
try {
|
|
localStorage.removeItem(e)
|
|
} catch (e) {}
|
|
},
|
|
getCookie: function(e, t) {
|
|
return d(e, t)
|
|
},
|
|
setCookie: function(e, t, r, n) {
|
|
g(e, t, r, n)
|
|
},
|
|
isSupportLS: function() {
|
|
try {
|
|
return localStorage.setItem("_ranger-test-key", "hi"),
|
|
localStorage.getItem("_ranger-test-key"),
|
|
localStorage.removeItem("_ranger-test-key"),
|
|
!0
|
|
} catch (e) {
|
|
return !1
|
|
}
|
|
}()
|
|
}, O = {
|
|
getItem: function(e) {
|
|
try {
|
|
var t = sessionStorage.getItem(e)
|
|
, r = t;
|
|
try {
|
|
t && "string" == typeof t && (r = JSON.parse(t))
|
|
} catch (e) {}
|
|
return r || {}
|
|
} catch (e) {}
|
|
return {}
|
|
},
|
|
setItem: function(e, t) {
|
|
try {
|
|
var r = "string" == typeof t ? t : JSON.stringify(t);
|
|
sessionStorage.setItem(e, r)
|
|
} catch (e) {}
|
|
},
|
|
removeItem: function(e) {
|
|
try {
|
|
sessionStorage.removeItem(e)
|
|
} catch (e) {}
|
|
},
|
|
getCookie: function(e, t) {
|
|
return d(e, t)
|
|
},
|
|
setCookie: function(e, t, r, n) {
|
|
g(e, t, r, n)
|
|
},
|
|
isSupportSession: function() {
|
|
try {
|
|
return sessionStorage.setItem("_ranger-test-key", "hi"),
|
|
sessionStorage.getItem("_ranger-test-key"),
|
|
sessionStorage.removeItem("_ranger-test-key"),
|
|
!0
|
|
} catch (e) {
|
|
return !1
|
|
}
|
|
}()
|
|
}, T = function() {
|
|
function e(e, t) {
|
|
this._storage = t && "session" === t ? O : !e && E.isSupportLS ? E : new k
|
|
}
|
|
return e.prototype.getItem = function(e) {
|
|
return this._storage.getItem(e)
|
|
}
|
|
,
|
|
e.prototype.setItem = function(e, t) {
|
|
this._storage.setItem(e, t)
|
|
}
|
|
,
|
|
e.prototype.getCookie = function(e, t) {
|
|
return this._storage.getCookie(e, t)
|
|
}
|
|
,
|
|
e.prototype.setCookie = function(e, t, r, n) {
|
|
this._storage.setCookie(e, t, r, n)
|
|
}
|
|
,
|
|
e.prototype.removeItem = function(e) {
|
|
this._storage.removeItem(e)
|
|
}
|
|
,
|
|
e
|
|
}(), C = function() {
|
|
function e(e, t, r) {
|
|
this.appid = e,
|
|
this.domain = t,
|
|
this.userAgent = window.navigator.userAgent,
|
|
this.appVersion = window.navigator.appVersion,
|
|
this.cookie_expire = r
|
|
}
|
|
return e.prototype.init = function() {
|
|
var e = window.navigator.userAgent
|
|
, t = window.navigator.language
|
|
, r = document.referrer
|
|
, n = r ? f(r).hostname : ""
|
|
, i = p(window.location.href)
|
|
, o = /Mobile|htc|mini|Android|iP(ad|od|hone)/.test(this.appVersion) ? "wap" : "web"
|
|
, i = (this.utm = function(e, t, r, n) {
|
|
var i = new T(!1)
|
|
, o = new T(!1,"session")
|
|
, s = e ? "_tea_utm_cache_" + e : "_tea_utm_cache"
|
|
, a = e ? "_$utm_from_url_" + e : "_$utm_from_url"
|
|
, c = {}
|
|
, u = ["tr_shareuser", "tr_admaster", "tr_param1", "tr_param2", "tr_param3", "tr_param4", "$utm_from_url"]
|
|
, l = {
|
|
ad_id: Number(t.ad_id) || void 0,
|
|
campaign_id: Number(t.campaign_id) || void 0,
|
|
creative_id: Number(t.creative_id) || void 0,
|
|
utm_source: t.utm_source,
|
|
utm_medium: t.utm_medium,
|
|
utm_campaign: t.utm_campaign,
|
|
utm_term: t.utm_term,
|
|
utm_content: t.utm_content,
|
|
tr_shareuser: t.tr_shareuser,
|
|
tr_admaster: t.tr_admaster,
|
|
tr_param1: t.tr_param1,
|
|
tr_param2: t.tr_param2,
|
|
tr_param3: t.tr_param3,
|
|
tr_param4: t.tr_param4
|
|
};
|
|
try {
|
|
var f, p, h = !1;
|
|
for (f in l)
|
|
l[f] && (-1 !== u.indexOf(f) ? (c.hasOwnProperty("tracer_data") || (c.tracer_data = {}),
|
|
c.tracer_data[f] = l[f]) : c[f] = l[f],
|
|
h = !0);
|
|
h ? (o.setItem(a, "1"),
|
|
i.setCookie(s, JSON.stringify(c), n, r)) : (p = i.getCookie(s, r)) && (c = JSON.parse(p)),
|
|
o.getItem(a) && (c.hasOwnProperty("tracer_data") || (c.tracer_data = {}),
|
|
c.tracer_data.$utm_from_url = 1)
|
|
} catch (e) {
|
|
return l
|
|
}
|
|
return c
|
|
}(this.appid, i, this.domain, this.cookie_expire),
|
|
this.browser())
|
|
, s = this.os();
|
|
return {
|
|
browser: i.browser,
|
|
browser_version: i.browser_version,
|
|
platform: o,
|
|
os_name: s.os_name,
|
|
os_version: s.os_version,
|
|
userAgent: e,
|
|
screen_width: window.screen && window.screen.width,
|
|
screen_height: window.screen && window.screen.height,
|
|
device_model: this.getDeviceModel(s.os_name),
|
|
language: t,
|
|
referrer: r,
|
|
referrer_host: n,
|
|
utm: this.utm,
|
|
latest_data: this.last(r, n)
|
|
}
|
|
}
|
|
,
|
|
e.prototype.last = function(e, t) {
|
|
var r = ""
|
|
, n = ""
|
|
, i = ""
|
|
, o = location.hostname
|
|
, s = !1;
|
|
return e && t && o !== t && (n = t,
|
|
s = !0,
|
|
(o = p(r = e)).keyword) && (i = o.keyword),
|
|
{
|
|
$latest_referrer: r,
|
|
$latest_referrer_host: n,
|
|
$latest_search_keyword: i,
|
|
isLast: s
|
|
}
|
|
}
|
|
,
|
|
e.prototype.browser = function() {
|
|
var e, t = "", r = "" + parseFloat(this.appVersion), n = this.userAgent;
|
|
return -1 !== n.indexOf("Edge") || -1 !== n.indexOf("Edg") ? (t = "Microsoft Edge",
|
|
r = -1 !== n.indexOf("Edge") ? (e = n.indexOf("Edge"),
|
|
n.substring(e + 5)) : (e = n.indexOf("Edg"),
|
|
n.substring(e + 4))) : -1 !== (e = n.indexOf("MSIE")) ? (t = "Microsoft Internet Explorer",
|
|
r = n.substring(e + 5)) : -1 !== (e = n.indexOf("Lark")) ? (t = "Lark",
|
|
r = n.substring(e + 5, e + 11)) : -1 !== (e = n.indexOf("MetaSr")) ? (t = "sougoubrowser",
|
|
r = n.substring(e + 7, e + 10)) : -1 !== n.indexOf("MQQBrowser") || -1 !== n.indexOf("QQBrowser") ? (t = "qqbrowser",
|
|
-1 !== n.indexOf("MQQBrowser") ? (e = n.indexOf("MQQBrowser"),
|
|
r = n.substring(e + 11, e + 15)) : -1 !== n.indexOf("QQBrowser") && (e = n.indexOf("QQBrowser"),
|
|
r = n.substring(e + 10, e + 17))) : -1 !== n.indexOf("Chrome") ? -1 !== (e = n.indexOf("MicroMessenger")) ? (t = "weixin",
|
|
r = n.substring(e + 15, e + 20)) : -1 !== (e = n.indexOf("360")) ? (t = "360browser",
|
|
r = n.substring(n.indexOf("Chrome") + 7)) : -1 !== n.indexOf("baidubrowser") || -1 !== n.indexOf("BIDUBrowser") ? (-1 !== n.indexOf("baidubrowser") ? (e = n.indexOf("baidubrowser"),
|
|
r = n.substring(e + 13, e + 16)) : -1 !== n.indexOf("BIDUBrowser") && (e = n.indexOf("BIDUBrowser"),
|
|
r = n.substring(e + 12, e + 15)),
|
|
t = "baidubrowser") : -1 !== (e = n.indexOf("xiaomi")) ? r = -1 !== n.indexOf("openlanguagexiaomi") ? (t = "openlanguage xiaomi",
|
|
n.substring(e + 7, e + 13)) : (t = "xiaomi",
|
|
n.substring(e - 7, e - 1)) : -1 !== (e = n.indexOf("TTWebView")) ? (t = "TTWebView",
|
|
r = n.substring(e + 10, e + 23)) : -1 === (e = n.indexOf("Chrome")) && -1 === (e = n.indexOf("Chrome")) || (t = "Chrome",
|
|
r = n.substring(e + 7)) : -1 !== n.indexOf("Safari") ? -1 !== (e = n.indexOf("QQ")) ? (t = "qqbrowser",
|
|
r = n.substring(e + 10, e + 16)) : -1 !== (e = n.indexOf("Safari")) && (t = "Safari",
|
|
r = n.substring(e + 7),
|
|
-1 !== (e = n.indexOf("Version"))) && (r = n.substring(e + 8)) : -1 !== (e = n.indexOf("Firefox")) ? (t = "Firefox",
|
|
r = n.substring(e + 8)) : -1 !== (e = n.indexOf("MicroMessenger")) ? (t = "weixin",
|
|
r = n.substring(e + 15, e + 20)) : -1 !== (e = n.indexOf("QQ")) && (t = "qqbrowser",
|
|
r = n.substring(e + 3, e + 8)),
|
|
{
|
|
browser: t,
|
|
browser_version: r = -1 !== (n = (r = -1 !== (n = (r = -1 !== (n = r.indexOf(";")) ? r.substring(0, n) : r).indexOf(" ")) ? r.substring(0, n) : r).indexOf(")")) ? r.substring(0, n) : r
|
|
}
|
|
}
|
|
,
|
|
e.prototype.os = function() {
|
|
for (var e = "", t = "", r = [{
|
|
s: "Windows 10",
|
|
r: /(Windows 10.0|Windows NT 10.0|Windows NT 10.1)/
|
|
}, {
|
|
s: "Windows 8.1",
|
|
r: /(Windows 8.1|Windows NT 6.3)/
|
|
}, {
|
|
s: "Windows 8",
|
|
r: /(Windows 8|Windows NT 6.2)/
|
|
}, {
|
|
s: "Windows 7",
|
|
r: /(Windows 7|Windows NT 6.1)/
|
|
}, {
|
|
s: "Android",
|
|
r: /Android/
|
|
}, {
|
|
s: "iOS",
|
|
r: /(iPhone|iPad|iPod)/
|
|
}, {
|
|
s: "Mac OS X",
|
|
r: /Mac OS X/
|
|
}, {
|
|
s: "Mac OS",
|
|
r: /(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/
|
|
}, {
|
|
s: "chromeOS",
|
|
r: /CrOS/
|
|
}, {
|
|
s: "Linux",
|
|
r: /(Linux|X11)/
|
|
}, {
|
|
s: "Sun OS",
|
|
r: /SunOS/
|
|
}], n = 0; n < r.length; n++) {
|
|
var i = r[n];
|
|
if (i.r.test(this.userAgent)) {
|
|
"Mac OS X" === (e = i.s) && this.isNewIpad() && (e = "iOS");
|
|
break
|
|
}
|
|
}
|
|
function o(e, t) {
|
|
return (e = e.exec(t)) && e[1] ? e[1] : ""
|
|
}
|
|
function s(e, t) {
|
|
return (e = RegExp("(?:^|[^A-Z0-9-_]|[^A-Z0-9-]_|sprd-)(?:" + e + ")", "i").exec(t)) ? e.slice(1)[0] : ""
|
|
}
|
|
switch (/Windows/.test(e) && (t = o(/Windows (.*)/, e),
|
|
e = "windows"),
|
|
e) {
|
|
case "Mac OS X":
|
|
t = s("Mac[ +]OS[ +]X(?:[ /](?:Version )?(\\d+(?:[_\\.]\\d+)+))?", this.userAgent),
|
|
e = "mac";
|
|
break;
|
|
case "Android":
|
|
t = o(/Android ([\.\_\d]+)/, a = this.userAgent) || o(/Android\/([\.\_\d]+)/, a),
|
|
e = "android";
|
|
break;
|
|
case "iOS":
|
|
t = this.isNewIpad() ? s("Mac[ +]OS[ +]X(?:[ /](?:Version )?(\\d+(?:[_\\.]\\d+)+))?", this.userAgent) : (t = /OS (\d+)_(\d+)_?(\d+)?/.exec(this.appVersion)) ? t[1] + "." + t[2] + "." + (0 | t[3]) : "",
|
|
e = "ios";
|
|
break;
|
|
case "chromeOS":
|
|
var a = this.userAgent.indexOf("x86_64")
|
|
, t = this.userAgent.substring(a + 7, a + 16)
|
|
}
|
|
return {
|
|
os_name: e,
|
|
os_version: t
|
|
}
|
|
}
|
|
,
|
|
e.prototype.getDeviceModel = function(e) {
|
|
var t, r, n = "";
|
|
try {
|
|
"android" === e ? navigator.userAgent.split(";").forEach(function(e) {
|
|
-1 < e.indexOf("Build/") && (n = e.slice(0, e.indexOf("Build/")))
|
|
}) : "ios" !== e && "mac" !== e && "windows" !== e || (n = this.isNewIpad() ? "iPad" : (r = (t = navigator.userAgent.replace("Mozilla/5.0 (", "")).indexOf(";"),
|
|
t.slice(0, r)))
|
|
} catch (e) {}
|
|
return n.trim()
|
|
}
|
|
,
|
|
e.prototype.isNewIpad = function() {
|
|
return void 0 !== this.userAgent && "MacIntel" === navigator.platform && "number" == typeof navigator.maxTouchPoints && 1 < navigator.maxTouchPoints
|
|
}
|
|
,
|
|
e
|
|
}(), D = {
|
|
cn: "1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",
|
|
va: "1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",
|
|
sg: "1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"
|
|
}, j = {
|
|
cn: "1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az28z1gz1hz1gz1cz18z1nz1gz4az1az1mz1k",
|
|
sg: "1fz22z22z1nz21z4mz4bz4bz21z1ez18z1jz1gz49z1kz1az21z4az19z27z22z1cz1mz24z1cz20z21z1cz18z4az1az1mz1k",
|
|
va: "1fz22z22z1nz21z4mz4bz4bz1kz18z1jz1gz24z18z49z1kz1az21z4az19z27z22z1cz1mz24z1cz20z21z1cz18z4az1az1mz1k"
|
|
}, I = "5.1.11", P = function() {
|
|
function e(e, t) {
|
|
this.collector = e,
|
|
this.config = t,
|
|
this.eventNameWhiteList = ["__bav_page", "__bav_beat", "__bav_page_statistics", "__bav_click", "__bav_page_exposure"],
|
|
this.paramsNameWhiteList = ["$inactive", "$inline", "$target_uuid_list", "$source_uuid", "$is_spider", "$source_id", "$is_first_time", "_staging_flag"],
|
|
this.regStr = RegExp("^[a-zA-Z0-9][a-z0-9A-Z_.-]{1,255}$")
|
|
}
|
|
return e.prototype.checkVerify = function(e) {
|
|
var t, r, n, i = this;
|
|
return !!(e && e.length && (e = e[0]) && (t = e.events,
|
|
r = e.header,
|
|
t) && t.length) && (n = !0,
|
|
t.forEach(function(e) {
|
|
e ? (i.checkEventName(e.event) || (n = !1,
|
|
e.checkEvent = "\u4E8B\u4EF6\u540D\u4E0D\u80FD\u4EE5 $ or __\u5F00\u5934"),
|
|
i.checkEventParams(e.params) || (n = !1,
|
|
e.checkParams = "\u5C5E\u6027\u540D\u4E0D\u80FD\u4EE5 $ or __\u5F00\u5934")) : (n = !1,
|
|
e.checkEvent = "\u4E8B\u4EF6\u5F02\u5E38")
|
|
}),
|
|
n = !!this.checkEventParams(r) && n)
|
|
}
|
|
,
|
|
e.prototype.checkEventName = function(e) {
|
|
return !!e && this.calculate(e, "event")
|
|
}
|
|
,
|
|
e.prototype.checkEventParams = function(e) {
|
|
var t = e;
|
|
if ("string" == typeof e && (t = JSON.parse(t)),
|
|
Object.keys(t).length)
|
|
for (var r in t)
|
|
return !(!this.calculate(r, "params") || "string" == typeof t[r] && 1024 < t[r].length && (console.warn("params: " + r + " can not over 1024 byte, please check;"),
|
|
1));
|
|
return !0
|
|
}
|
|
,
|
|
e.prototype.calculate = function(e, t) {
|
|
return -1 !== ("event" === t ? this.eventNameWhiteList : this.paramsNameWhiteList).indexOf(e) || !RegExp("^\\$").test(e) && !RegExp("^__").test(e) || (console.warn(("event" === t ? "event" : "params") + " name: " + e + " can not start with $ or __, pleace check;"),
|
|
!1)
|
|
}
|
|
,
|
|
e
|
|
}(), A = ((v = J = J || {}).Init = "init",
|
|
v.Config = "config",
|
|
v.Start = "start",
|
|
v.Ready = "ready",
|
|
v.UnReady = "un-ready",
|
|
v.TokenComplete = "token-complete",
|
|
v.TokenStorage = "token-storage",
|
|
v.TokenFetch = "token-fetch",
|
|
v.TokenError = "token-error",
|
|
v.ConfigUuid = "config-uuid",
|
|
v.ConfigWebId = "config-webid",
|
|
v.ConfigDomain = "config-domain",
|
|
v.CustomWebId = "custom-webid",
|
|
v.TokenChange = "token-change",
|
|
v.TokenReset = "token-reset",
|
|
v.ConfigTransform = "config-transform",
|
|
v.EnvTransform = "env-transform",
|
|
v.SessionReset = "session-reset",
|
|
v.SessionResetTime = "session-reset-time",
|
|
v.SetSessionId = "set-session-id",
|
|
v.Event = "event",
|
|
v.Events = "events",
|
|
v.EventNow = "event-now",
|
|
v.CleanEvents = "clean-events",
|
|
v.BeconEvent = "becon-event",
|
|
v.SubmitBefore = "submit-before",
|
|
v.SubmitScuess = "submit-scuess",
|
|
v.SubmitAfter = "submit-after",
|
|
v.SubmitError = "submit-error",
|
|
v.SubmitVerify = "submit-verify",
|
|
v.Stay = "stay",
|
|
v.ResetStay = "reset-stay",
|
|
v.StayReady = "stay-ready",
|
|
v.SetStay = "set-stay",
|
|
v.RouteChange = "route-change",
|
|
v.RouteReady = "route-ready",
|
|
v.Ab = "ab",
|
|
v.AbVar = "ab-var",
|
|
v.AbAllVars = "ab-all-vars",
|
|
v.AbConfig = "ab-config",
|
|
v.AbExternalVersion = "ab-external-version",
|
|
v.AbVersionChangeOn = "ab-version-change-on",
|
|
v.AbVersionChangeOff = "ab-version-change-off",
|
|
v.AbOpenLayer = "ab-open-layer",
|
|
v.AbCloseLayer = "ab-close-layer",
|
|
v.AbReady = "ab-ready",
|
|
v.AbComplete = "ab-complete",
|
|
v.AbTimeout = "ab-timeout",
|
|
v.Profile = "profile",
|
|
v.ProfileSet = "profile-set",
|
|
v.ProfileSetOnce = "profile-set-once",
|
|
v.ProfileUnset = "profile-unset",
|
|
v.ProfileIncrement = "profile-increment",
|
|
v.ProfileAppend = "profile-append",
|
|
v.ProfileClear = "profile-clear",
|
|
v.Autotrack = "autotrack",
|
|
v.AutotrackReady = "autotrack-ready",
|
|
v.CepReady = "cep-ready",
|
|
v.TracerReady = "tracer-ready",
|
|
v.sessionRecord = "session-record",
|
|
v.SessionRecordStart = "session-record-start",
|
|
v.SessionRecordPause = "session-record-pause",
|
|
v.SessionRecordEnd = "session-record-end",
|
|
v.SessionRecordReport = "session-record-report",
|
|
v.DestoryInstance = "destory-instance",
|
|
v.VisualCollectReady = "visual-collect-ready",
|
|
v.VisualApiReady = "visual-api-ready",
|
|
v.VisualApiUpdate = "visual-api-update",
|
|
(b = S = S || {}).DEBUGGER_MESSAGE = "debugger-message",
|
|
b.DEBUGGER_MESSAGE_SDK = "debugger-message-sdk",
|
|
b.DEBUGGER_MESSAGE_FETCH = "debugger-message-fetch",
|
|
b.DEBUGGER_MESSAGE_FETCH_RESULT = "debugger-message-fetch-result",
|
|
b.DEBUGGER_MESSAGE_EVENT = "debugger-message-event",
|
|
b.DEVTOOL_WEB_READY = "devtool-web-ready",
|
|
J), R = void 0, t = (new Date).getTimezoneOffset(), z = parseInt("" + -t / 60, 10), B = 60 * t, U = function() {
|
|
function e(e, t) {
|
|
this.is_first_time = !0,
|
|
this.configPersist = !1,
|
|
this.initConfig = t,
|
|
this.collect = e;
|
|
var r = new C(t.app_id,t.cookie_domain || "",t.cookie_expire || 7776e6).init()
|
|
, e = (this.eventCheck = new P(e,t),
|
|
"__tea_cache_first_" + t.app_id)
|
|
, t = (this.configKey = "__tea_cache_config_" + t.app_id,
|
|
this.sessionStorage = new T(!1,"session"),
|
|
this.localStorage = new T(!1,"local"),
|
|
t.configPersist && (this.configPersist = !0,
|
|
this.storage = 1 === t.configPersist ? this.sessionStorage : this.localStorage),
|
|
this.localStorage.getItem(e));
|
|
t && 1 == t ? this.is_first_time = !1 : (this.is_first_time = !0,
|
|
this.localStorage.setItem(e, "1")),
|
|
this.envInfo = {
|
|
user: {
|
|
user_unique_id: R,
|
|
user_type: R,
|
|
user_id: R,
|
|
user_is_auth: R,
|
|
user_is_login: R,
|
|
device_id: R,
|
|
web_id: R,
|
|
ip_addr_id: R,
|
|
user_unique_id_type: R
|
|
},
|
|
header: {
|
|
app_id: R,
|
|
app_name: R,
|
|
app_install_id: R,
|
|
install_id: R,
|
|
app_package: R,
|
|
app_channel: R,
|
|
app_version: R,
|
|
ab_version: R,
|
|
os_name: r.os_name,
|
|
os_version: r.os_version,
|
|
device_model: r.device_model,
|
|
ab_client: R,
|
|
traffic_type: R,
|
|
client_ip: R,
|
|
device_brand: R,
|
|
os_api: R,
|
|
access: R,
|
|
language: r.language,
|
|
region: R,
|
|
app_language: R,
|
|
app_region: R,
|
|
creative_id: r.utm.creative_id,
|
|
ad_id: r.utm.ad_id,
|
|
campaign_id: r.utm.campaign_id,
|
|
log_type: R,
|
|
rnd: R,
|
|
platform: r.platform,
|
|
sdk_version: I,
|
|
sdk_lib: "js",
|
|
province: R,
|
|
city: R,
|
|
timezone: z,
|
|
tz_offset: B,
|
|
tz_name: R,
|
|
sim_region: R,
|
|
carrier: R,
|
|
resolution: r.screen_width + "x" + r.screen_height,
|
|
browser: r.browser,
|
|
browser_version: r.browser_version,
|
|
referrer: r.referrer,
|
|
referrer_host: r.referrer_host,
|
|
width: r.screen_width,
|
|
height: r.screen_height,
|
|
screen_width: r.screen_width,
|
|
screen_height: r.screen_height,
|
|
utm_term: r.utm.utm_term,
|
|
utm_content: r.utm.utm_content,
|
|
utm_source: r.utm.utm_source,
|
|
utm_medium: r.utm.utm_medium,
|
|
utm_campaign: r.utm.utm_campaign,
|
|
tracer_data: JSON.stringify(r.utm.tracer_data),
|
|
custom: {},
|
|
wechat_unionid: R,
|
|
wechat_openid: R
|
|
}
|
|
},
|
|
this.ab_version = "",
|
|
this.evtParams = {},
|
|
this.reportErrorCallback = function() {}
|
|
,
|
|
this.isLast = !1,
|
|
this.setCustom(r),
|
|
this.initDomain(),
|
|
this.initABData()
|
|
}
|
|
return e.prototype.initDomain = function() {
|
|
var e = this.initConfig.channel_domain;
|
|
e ? this.domain = e : (e = this.initConfig.channel,
|
|
this.domain = l(j[e]))
|
|
}
|
|
,
|
|
e.prototype.setDomain = function(e) {
|
|
this.domain = e
|
|
}
|
|
,
|
|
e.prototype.getDomain = function() {
|
|
return this.domain
|
|
}
|
|
,
|
|
e.prototype.initABData = function() {
|
|
var e, t = "__tea_sdk_ab_version_" + this.initConfig.app_id, r = null;
|
|
r = this.initConfig.ab_cross ? (e = this.localStorage.getCookie(t, this.initConfig.ab_cookie_domain)) ? JSON.parse(e) : null : this.localStorage.getItem(t),
|
|
this.setAbCache(r)
|
|
}
|
|
,
|
|
e.prototype.setAbCache = function(e) {
|
|
this.ab_cache = e
|
|
}
|
|
,
|
|
e.prototype.getAbCache = function() {
|
|
return this.ab_cache
|
|
}
|
|
,
|
|
e.prototype.setAbVersion = function(e) {
|
|
this.ab_version = e
|
|
}
|
|
,
|
|
e.prototype.getAbVersion = function() {
|
|
return this.ab_version
|
|
}
|
|
,
|
|
e.prototype.clearAbCache = function() {
|
|
this.ab_version = "",
|
|
this.ab_cache = {}
|
|
}
|
|
,
|
|
e.prototype.getUrl = function(e) {
|
|
var t = "";
|
|
switch (e) {
|
|
case "event":
|
|
t = "/list";
|
|
break;
|
|
case "webid":
|
|
t = "/webid";
|
|
break;
|
|
case "tobid":
|
|
t = "/tobid"
|
|
}
|
|
return e = "",
|
|
this.initConfig.caller && (e = "?sdk_version=5.1.11&sdk_name=web&app_id=" + this.initConfig.app_id + "&caller=" + this.initConfig.caller),
|
|
"" + this.getDomain() + t + e
|
|
}
|
|
,
|
|
e.prototype.setCustom = function(e) {
|
|
if (e && e.latest_data && e.latest_data.isLast)
|
|
for (var t in delete e.latest_data.isLast,
|
|
this.isLast = !0,
|
|
e.latest_data)
|
|
this.envInfo.header.custom[t] = e.latest_data[t]
|
|
}
|
|
,
|
|
e.prototype.set = function(e) {
|
|
var t = this;
|
|
Object.keys(e).forEach(function(r) {
|
|
var n, i, o;
|
|
void 0 !== e[r] && null !== e[r] || t.delete(r);
|
|
try {
|
|
t.eventCheck.calculate(r, "config")
|
|
} catch (e) {}
|
|
"traffic_type" === r && t.isLast && (t.envInfo.header.custom.$latest_traffic_source_type = e[r]),
|
|
"evtParams" === r ? t.evtParams = a({}, t.evtParams || {}, e.evtParams || {}) : "_staging_flag" === r ? t.evtParams = a({}, t.evtParams || {}, {
|
|
_staging_flag: e._staging_flag
|
|
}) : "reportErrorCallback" === r && "function" == typeof e[r] ? t.reportErrorCallback = e[r] : (o = i = "",
|
|
-1 < r.indexOf(".") && (i = (n = r.split("."))[0],
|
|
o = n[1]),
|
|
i ? "user" === i || "header" === i ? t.envInfo[i][o] = e[r] : t.envInfo.header.custom[o] = e[r] : Object.hasOwnProperty.call(t.envInfo.user, r) ? -1 < ["user_type", "ip_addr_id"].indexOf(r) ? t.envInfo.user[r] = e[r] && Number(e[r]) : -1 < ["user_id", "web_id", "user_unique_id", "user_unique_id_type"].indexOf(r) ? t.envInfo.user[r] = e[r] && String(e[r]) : -1 < ["user_is_auth", "user_is_login"].indexOf(r) ? t.envInfo.user[r] = !!e[r] : "device_id" === r && (t.envInfo.user[r] = e[r]) : Object.hasOwnProperty.call(t.envInfo.header, r) ? t.envInfo.header[r] = e[r] : t.envInfo.header.custom[r] = e[r])
|
|
})
|
|
}
|
|
,
|
|
e.prototype.get = function(e) {
|
|
try {
|
|
return e ? "evtParams" === e ? this.evtParams : "reportErrorCallback" === e ? this[e] : Object.hasOwnProperty.call(this.envInfo.user, e) ? this.envInfo.user[e] : Object.hasOwnProperty.call(this.envInfo.header, e) ? this.envInfo.header[e] : JSON.parse(JSON.stringify(this.envInfo[e])) : JSON.parse(JSON.stringify(this.envInfo))
|
|
} catch (e) {
|
|
console.log("get config stringify error "),
|
|
this.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: e.message
|
|
})
|
|
}
|
|
}
|
|
,
|
|
e.prototype.setStore = function(e) {
|
|
try {
|
|
var t, r;
|
|
this.configPersist && (t = this.storage.getItem(this.configKey) || {}) && Object.keys(e).length && (r = Object.assign(e, t),
|
|
this.storage.setItem(this.configKey, r))
|
|
} catch (e) {
|
|
console.log("setStore error"),
|
|
this.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: e.message
|
|
})
|
|
}
|
|
}
|
|
,
|
|
e.prototype.getStore = function() {
|
|
try {
|
|
var e;
|
|
return this.configPersist && (e = this.storage.getItem(this.configKey) || {},
|
|
Object.keys(e).length) ? e : null
|
|
} catch (e) {
|
|
return this.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: e.message
|
|
}),
|
|
null
|
|
}
|
|
}
|
|
,
|
|
e.prototype.delete = function(e) {
|
|
try {
|
|
var t;
|
|
this.configPersist && (t = this.storage.getItem(this.configKey) || {}) && Object.hasOwnProperty.call(t, e) && (delete t[e],
|
|
this.storage.setItem(this.configKey, t))
|
|
} catch (e) {
|
|
this.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: e.message
|
|
}),
|
|
console.log("delete error")
|
|
}
|
|
}
|
|
,
|
|
e
|
|
}(), M = function() {
|
|
function e(e, t) {
|
|
this.isLog = t || !1,
|
|
this.name = e || ""
|
|
}
|
|
return e.prototype.info = function(e) {
|
|
this.isLog && console.log("%c %s", "color: yellow; background-color: black;", "[AppLog WEB SDK] [instance: " + this.name + "] " + e)
|
|
}
|
|
,
|
|
e.prototype.warn = function(e) {
|
|
this.isLog && console.warn("[AppLog WEB SDK] [instance: " + this.name + "] " + e)
|
|
}
|
|
,
|
|
e.prototype.error = function(e) {
|
|
this.isLog && console.error("[AppLog WEB SDK] [instance: " + this.name + "] " + e)
|
|
}
|
|
,
|
|
e.prototype.throw = function(e) {
|
|
throw this.error(this.name),
|
|
Error(e)
|
|
}
|
|
,
|
|
e
|
|
}(), G = function() {
|
|
function e() {
|
|
this.spiderBot = ["Baiduspider", "googlebot", "360Spider", "haosouspider", "YoudaoBot", "Sogou News Spider", "Yisouspider", "Googlebot", "Headless", "Applebot", "Bingbot", "PetalBot"]
|
|
}
|
|
return e.prototype.checkSpider = function(e) {
|
|
var t, r;
|
|
return !!e.enable_spider && (!(t = window.navigator.userAgent) || (r = !1,
|
|
this.spiderBot.forEach(function(e) {
|
|
-1 !== t.indexOf(e) && (r = !0)
|
|
}),
|
|
r))
|
|
}
|
|
,
|
|
e
|
|
}(), F = function() {
|
|
function e(e, t) {
|
|
this.collect = e,
|
|
this.native = t
|
|
}
|
|
var t = e.prototype;
|
|
return t.bridgeInject = function() {
|
|
try {
|
|
return !!this.native && (AppLogBridge ? (console.log("AppLogBridge is injected"),
|
|
!0) : (console.log("AppLogBridge is not inject"),
|
|
!1))
|
|
} catch (e) {
|
|
return console.log("AppLogBridge is not inject"),
|
|
!1
|
|
}
|
|
}
|
|
,
|
|
t.bridgeReady = function() {
|
|
var e = this;
|
|
return new Promise(function(t, r) {
|
|
try {
|
|
e.bridgeInject() ? AppLogBridge.hasStarted(function(e) {
|
|
console.log("AppLogBridge is started? : " + e),
|
|
e ? t(!0) : r(!1)
|
|
}) : r(!1)
|
|
} catch (e) {
|
|
console.log("AppLogBridge, error:" + JSON.stringify(e.stack)),
|
|
r(!1)
|
|
}
|
|
}
|
|
)
|
|
}
|
|
,
|
|
t.setNativeAppId = function(e) {
|
|
try {
|
|
AppLogBridge.setNativeAppId(JSON.stringify(e)),
|
|
console.log("change bridge appid, event report with appid: " + e)
|
|
} catch (e) {
|
|
console.error("setNativeAppId error")
|
|
}
|
|
}
|
|
,
|
|
t.setConfig = function(e) {
|
|
var t = this;
|
|
try {
|
|
Object.keys(e).forEach(function(r) {
|
|
"user_unique_id" === r ? t.setUserUniqueId(e[r]) : e[r] ? t.addHeaderInfo(r, e[r]) : t.removeHeaderInfo(r)
|
|
})
|
|
} catch (e) {
|
|
console.error("setConfig error")
|
|
}
|
|
}
|
|
,
|
|
t.setUserUniqueId = function(e) {
|
|
try {
|
|
AppLogBridge.setUserUniqueId(e)
|
|
} catch (e) {
|
|
console.error("setUserUniqueId error")
|
|
}
|
|
}
|
|
,
|
|
t.addHeaderInfo = function(e, t) {
|
|
try {
|
|
AppLogBridge.addHeaderInfo(e, t)
|
|
} catch (e) {
|
|
console.error("addHeaderInfo error")
|
|
}
|
|
}
|
|
,
|
|
t.setHeaderInfo = function(e) {
|
|
try {
|
|
AppLogBridge.setHeaderInfo(JSON.stringify(e))
|
|
} catch (e) {
|
|
console.error("setHeaderInfo error")
|
|
}
|
|
}
|
|
,
|
|
t.removeHeaderInfo = function(e) {
|
|
try {
|
|
AppLogBridge.removeHeaderInfo(e)
|
|
} catch (e) {
|
|
console.error("removeHeaderInfo error")
|
|
}
|
|
}
|
|
,
|
|
t.reportPv = function(e) {
|
|
this.onEventV3("predefine_pageview", e)
|
|
}
|
|
,
|
|
t.onEventV3 = function(e, t) {
|
|
try {
|
|
AppLogBridge.onEventV3(e, t),
|
|
this.collect.emit(DebuggerMesssge.DEBUGGER_MESSAGE, {
|
|
type: DebuggerMesssge.DEBUGGER_MESSAGE_EVENT,
|
|
info: "bridge\u57CB\u70B9\u4E0A\u62A5",
|
|
time: Date.now(),
|
|
data: [{
|
|
events: [{
|
|
event: e,
|
|
params: t
|
|
}]
|
|
}],
|
|
code: 200,
|
|
status: "success"
|
|
})
|
|
} catch (e) {
|
|
console.error("onEventV3 error")
|
|
}
|
|
}
|
|
,
|
|
t.profileSet = function(e) {
|
|
try {
|
|
AppLogBridge.profileSet(e)
|
|
} catch (e) {
|
|
console.error("profileSet error")
|
|
}
|
|
}
|
|
,
|
|
t.profileSetOnce = function(e) {
|
|
try {
|
|
AppLogBridge.profileSetOnce(e)
|
|
} catch (e) {
|
|
console.error("profileSetOnce error")
|
|
}
|
|
}
|
|
,
|
|
t.profileIncrement = function(e) {
|
|
try {
|
|
AppLogBridge.profileIncrement(e)
|
|
} catch (e) {
|
|
console.error("profileIncrement error")
|
|
}
|
|
}
|
|
,
|
|
t.profileUnset = function(e) {
|
|
try {
|
|
AppLogBridge.profileUnset(e)
|
|
} catch (e) {
|
|
console.error("profileUnset error")
|
|
}
|
|
}
|
|
,
|
|
t.profileAppend = function(e) {
|
|
try {
|
|
AppLogBridge.profileAppend(e)
|
|
} catch (e) {
|
|
console.error("profileAppend error")
|
|
}
|
|
}
|
|
,
|
|
e
|
|
}(), N = function() {
|
|
function e() {}
|
|
return e.prototype.apply = function(e, t) {
|
|
var r = this;
|
|
this.collect = e,
|
|
this.storage = new T(!1,"session"),
|
|
this.sessionKey = "__tea_session_id_" + t.app_id,
|
|
this.expireTime = t.expireTime || 18e5,
|
|
this.disableSession = t.disable_session,
|
|
this.disableSessionTimeCheck = t.disable_session_check,
|
|
this.disableSession || (this.setSessionId(),
|
|
this.collect.on(A.SessionReset, function(e) {
|
|
r.resetSessionId(e)
|
|
}),
|
|
this.collect.on(A.SessionResetTime, function() {
|
|
r.updateSessionIdTime()
|
|
}))
|
|
}
|
|
,
|
|
e.prototype.updateSessionIdTime = function() {
|
|
var e, t = this.storage.getItem(this.sessionKey);
|
|
t && t.sessionId && (e = t.timestamp,
|
|
Date.now() - e > this.expireTime ? t = {
|
|
sessionId: y(),
|
|
timestamp: Date.now()
|
|
} : t.timestamp = Date.now(),
|
|
this.storage.setItem(this.sessionKey, t),
|
|
this.resetExpTime())
|
|
}
|
|
,
|
|
e.prototype.setSessionId = function() {
|
|
var e = this
|
|
, t = this.storage.getItem(this.sessionKey);
|
|
t && t.sessionId ? t.timestamp = Date.now() : t = {
|
|
sessionId: y(),
|
|
timestamp: Date.now()
|
|
},
|
|
this.storage.setItem(this.sessionKey, t),
|
|
this.disableSessionTimeCheck || (this.sessionExp = setInterval(function() {
|
|
e.checkEXp()
|
|
}, this.expireTime))
|
|
}
|
|
,
|
|
e.prototype.getSessionId = function() {
|
|
var e = this.storage.getItem(this.sessionKey);
|
|
return !this.disableSession && e && e.sessionId ? e.sessionId : ""
|
|
}
|
|
,
|
|
e.prototype.resetExpTime = function() {
|
|
var e = this;
|
|
this.sessionExp && (clearInterval(this.sessionExp),
|
|
this.sessionExp = setInterval(function() {
|
|
e.checkEXp()
|
|
}, this.expireTime))
|
|
}
|
|
,
|
|
e.prototype.resetSessionId = function(e) {
|
|
e = {
|
|
sessionId: e || y(),
|
|
timestamp: Date.now()
|
|
},
|
|
this.storage.setItem(this.sessionKey, e)
|
|
}
|
|
,
|
|
e.prototype.checkEXp = function() {
|
|
var e = this.storage.getItem(this.sessionKey);
|
|
e && e.sessionId && Date.now() - e.timestamp + 30 >= this.expireTime && (e = {
|
|
sessionId: y(),
|
|
timestamp: Date.now()
|
|
},
|
|
this.storage.setItem(this.sessionKey, e))
|
|
}
|
|
,
|
|
e
|
|
}(), H = function() {
|
|
function e() {
|
|
this.eventLimit = 50,
|
|
this.enable_ttwebid = !1,
|
|
this.eventCache = [],
|
|
this.beconEventCache = []
|
|
}
|
|
return e.prototype.apply = function(e, t) {
|
|
var r = this
|
|
, n = (this.collect = e,
|
|
this.config = t,
|
|
this.configManager = e.configManager,
|
|
this.eventCheck = new P(e,t),
|
|
this.cacheStorgae = new T(!0),
|
|
this.localStorage = new T(!1),
|
|
this.maxReport = t.max_report || 10,
|
|
this.reportTime = t.reportTime || t.report_time || 30,
|
|
this.timeout = t.timeout || 1e5,
|
|
this.enable_ttwebid = t.enable_ttwebid,
|
|
this.reportUrl = t.report_url || this.configManager.getUrl("event"),
|
|
this.eventKey = "__tea_cache_events_" + this.configManager.get("app_id"),
|
|
this.beconKey = "__tea_cache_events_becon_" + this.configManager.get("app_id"),
|
|
this.abKey = "__tea_sdk_ab_version_" + this.configManager.get("app_id"),
|
|
this.refer_key = "__tea_cache_refer_" + this.configManager.get("app_id"),
|
|
this.pageId = y(),
|
|
this.collect.on(A.Ready, function() {
|
|
r.reportAll(!1)
|
|
}),
|
|
this.collect.on(A.ConfigDomain, function() {
|
|
r.reportUrl = r.configManager.getUrl("event")
|
|
}),
|
|
this.collect.on(A.Event, function(e) {
|
|
r.event(e)
|
|
}),
|
|
this.collect.on(A.BeconEvent, function(e) {
|
|
r.beconEvent(e)
|
|
}),
|
|
this.collect.on(A.CleanEvents, function() {
|
|
r.reportAll(!1)
|
|
}),
|
|
this.linster());
|
|
this.collect.on(A.DestoryInstance, function() {
|
|
n && n()
|
|
})
|
|
}
|
|
,
|
|
e.prototype.linster = function() {
|
|
function e() {
|
|
n.reportAll(!0)
|
|
}
|
|
function t() {
|
|
"hidden" === document.visibilityState && n.reportAll(!0)
|
|
}
|
|
var r, n = this;
|
|
return window.addEventListener("unload", e, !1),
|
|
r = e,
|
|
navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) ? window.addEventListener("pagehide", r, !1) : window.addEventListener("beforeunload", r, !1),
|
|
document.addEventListener("visibilitychange", t, !1),
|
|
function() {
|
|
window.removeEventListener("unload", e),
|
|
window.removeEventListener("pagehide", e, !1),
|
|
window.removeEventListener("beforeunload", e, !1),
|
|
document.removeEventListener("visibilitychange", t, !1)
|
|
}
|
|
}
|
|
,
|
|
e.prototype.reportAll = function(e) {
|
|
this.report(e),
|
|
this.reportBecon()
|
|
}
|
|
,
|
|
e.prototype.event = function(e) {
|
|
var t = this;
|
|
try {
|
|
var r, n = c(e, this.cacheStorgae.getItem(this.eventKey) || []);
|
|
this.cacheStorgae.setItem(this.eventKey, n),
|
|
this.reportTimeout && clearTimeout(this.reportTimeout),
|
|
n.length >= this.maxReport ? this.report(!1) : (r = this.reportTime,
|
|
this.reportTimeout = setTimeout(function() {
|
|
t.report(!1),
|
|
t.reportTimeout = null
|
|
}, r))
|
|
} catch (e) {
|
|
this.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: e.message
|
|
})
|
|
}
|
|
}
|
|
,
|
|
e.prototype.beconEvent = function(e) {
|
|
e = c(e, this.cacheStorgae.getItem(this.beconKey) || []),
|
|
this.cacheStorgae.setItem(this.beconKey, e),
|
|
this.collect.destroy || this.collect.sdkStop || this.collect.tokenManager.getReady() && this.collect.sdkReady && (this.cacheStorgae.removeItem(this.beconKey),
|
|
this.send(this.split(this.merge(e)), !0))
|
|
}
|
|
,
|
|
e.prototype.reportBecon = function() {
|
|
var e;
|
|
!this.collect.destroy && !this.collect.sdkStop && this.collect.tokenManager.getReady() && this.collect.sdkReady && (e = this.cacheStorgae.getItem(this.beconKey) || []) && e.length && (this.cacheStorgae.removeItem(this.beconKey),
|
|
this.send(this.split(this.merge(e)), !0))
|
|
}
|
|
,
|
|
e.prototype.report = function(e) {
|
|
var t;
|
|
!this.collect.destroy && !this.collect.sdkStop && this.collect.tokenManager.getReady() && this.collect.sdkReady && (t = this.cacheStorgae.getItem(this.eventKey) || []).length && (this.cacheStorgae.removeItem(this.eventKey),
|
|
this.sliceEvent(t, e))
|
|
}
|
|
,
|
|
e.prototype.sliceEvent = function(e, t) {
|
|
if (e.length > this.eventLimit)
|
|
for (var r = 0; r < e.length; r += this.eventLimit) {
|
|
var n = e.slice(r, r + this.eventLimit)
|
|
, i = this.split(this.merge(n));
|
|
this.send(i, t)
|
|
}
|
|
else
|
|
i = this.split(this.merge(e)),
|
|
this.send(i, t)
|
|
}
|
|
,
|
|
e.prototype.handleRefer = function() {
|
|
var e, t = "";
|
|
try {
|
|
t = (this.config.spa || this.config.autotrack) && (e = this.localStorage.getItem(this.refer_key) || {}).routeChange ? e.refer_key : this.configManager.get("referrer")
|
|
} catch (e) {
|
|
t = document.referrer
|
|
}
|
|
return t
|
|
}
|
|
,
|
|
e.prototype.merge = function(e, t) {
|
|
var r = this
|
|
, n = this.configManager.get()
|
|
, i = n.header
|
|
, o = n.user
|
|
, s = (this.config.enable_pageid && (i.custom.page_id = this.pageId),
|
|
i.referrer = this.handleRefer(),
|
|
i.custom = JSON.stringify(i.custom),
|
|
this.configManager.get("evtParams"))
|
|
, c = this.configManager.get("user_unique_id_type")
|
|
, n = e.map(function(e) {
|
|
try {
|
|
Object.keys(s).length && !t && (e.params = a({}, s, e.params)),
|
|
c && (e.params.$user_unique_id_type = c);
|
|
var n = r.configManager.getAbCache()
|
|
, i = o[r.config.ab_user_mode] || o.user_unique_id;
|
|
return n && n.uuid && n.uuid === i && r.configManager.getAbVersion() && (e.ab_sdk_version = r.configManager.getAbVersion()),
|
|
e.session_id = r.collect.sessionManager.getSessionId(),
|
|
e.params = JSON.stringify(e.params),
|
|
e
|
|
} catch (t) {
|
|
return r.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: t.message
|
|
}),
|
|
e
|
|
}
|
|
})
|
|
, e = JSON.parse(JSON.stringify({
|
|
events: n,
|
|
user: o,
|
|
header: i
|
|
}))
|
|
, n = (e.local_time = Math.floor(Date.now() / 1e3),
|
|
e.user_unique_type = this.config.enable_ttwebid ? this.config.user_unique_type : void 0,
|
|
e.verbose = 1,
|
|
[]);
|
|
return n.push(e),
|
|
n
|
|
}
|
|
,
|
|
e.prototype.split = function(e) {
|
|
return e.map(function(e) {
|
|
var t = [];
|
|
return t.push(e),
|
|
t
|
|
})
|
|
}
|
|
,
|
|
e.prototype.send = function(e, t) {
|
|
var r = this;
|
|
e.length && !this.config.disable_track_event && e.forEach(function(e) {
|
|
try {
|
|
var n, i = JSON.parse(JSON.stringify(e)), o = (!r.config.filter || (i = r.config.filter(i)) || console.warn("filter must return data !!"),
|
|
r.collect.eventFilter && i && ((i = r.collect.eventFilter(i)) || console.warn("filterEvent api must return data !!")),
|
|
i || e), s = JSON.parse(JSON.stringify(o));
|
|
r.eventCheck.checkVerify(s),
|
|
o.length && (n = !0,
|
|
o.forEach(function(e) {
|
|
e.events.length || (n = !1)
|
|
}),
|
|
n && (r.collect.emit(A.SubmitBefore, o),
|
|
r.collect.requestManager.useRequest({
|
|
url: r.reportUrl,
|
|
data: o,
|
|
success: function(e, t) {
|
|
e && 0 !== e.e ? (r.collect.emit(A.SubmitError, {
|
|
type: "f_data",
|
|
eventData: t,
|
|
errorCode: e.e,
|
|
response: e
|
|
}),
|
|
r.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_EVENT,
|
|
info: "\u57CB\u70B9\u4E0A\u62A5\u5931\u8D25",
|
|
time: Date.now(),
|
|
data: s,
|
|
code: e.e,
|
|
failType: "\u6570\u636E\u5F02\u5E38\u5931\u8D25",
|
|
status: "fail"
|
|
})) : (r.collect.emit(A.SubmitScuess, {
|
|
eventData: t,
|
|
res: e
|
|
}),
|
|
r.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_EVENT,
|
|
info: "\u57CB\u70B9\u4E0A\u62A5\u6210\u529F",
|
|
time: Date.now(),
|
|
data: s,
|
|
code: 200,
|
|
status: "success"
|
|
}))
|
|
},
|
|
fail: function(e, t) {
|
|
r.configManager.get("reportErrorCallback")(e, t),
|
|
r.collect.emit(A.SubmitError, {
|
|
type: "f_net",
|
|
eventData: e,
|
|
errorCode: t
|
|
}),
|
|
r.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_EVENT,
|
|
info: "\u57CB\u70B9\u4E0A\u62A5\u7F51\u7EDC\u5F02\u5E38",
|
|
time: Date.now(),
|
|
data: s,
|
|
code: t,
|
|
failType: "\u7F51\u7EDC\u5F02\u5E38\u5931\u8D25",
|
|
status: "fail"
|
|
})
|
|
},
|
|
timeout: r.timeout,
|
|
useBeacon: t,
|
|
withCredentials: r.enable_ttwebid
|
|
}),
|
|
r.collect.emit(A.SubmitAfter, o)))
|
|
} catch (e) {
|
|
console.warn("something error, " + JSON.stringify(e.stack)),
|
|
r.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: e.message
|
|
})
|
|
}
|
|
})
|
|
}
|
|
,
|
|
e
|
|
}(), L = function() {
|
|
function e() {
|
|
this.cacheToken = {},
|
|
this.enableCookie = !1,
|
|
this.enable_ttwebid = !1,
|
|
this.enableCustomWebid = !1
|
|
}
|
|
return e.prototype.apply = function(e, t) {
|
|
var r = this;
|
|
this.collect = e,
|
|
this.config = t,
|
|
this.configManager = this.collect.configManager,
|
|
this.storage = new T(!1),
|
|
this.tokenKey = "__tea_cache_tokens_" + t.app_id,
|
|
this.enable_ttwebid = t.enable_ttwebid,
|
|
this.enableCustomWebid = t.enable_custom_webid,
|
|
this.collect.on(A.ConfigUuid, function(e) {
|
|
r.setUuid(e)
|
|
}),
|
|
this.collect.on(A.ConfigWebId, function(e) {
|
|
r.setWebId(e)
|
|
}),
|
|
this.enableCookie = t.cross_subdomain,
|
|
this.expiresTime = t.cookie_expire || 6048e5,
|
|
this.cookieDomain = t.cookie_domain || "",
|
|
this.checkStorage()
|
|
}
|
|
,
|
|
e.prototype.checkStorage = function() {
|
|
var e, t = this;
|
|
this.enableCookie ? (e = this.storage.getCookie(this.tokenKey, this.cookieDomain),
|
|
this.cacheToken = e && "string" == typeof e ? JSON.parse(e) : {}) : this.cacheToken = this.storage.getItem(this.tokenKey) || {},
|
|
this.tokenType = this.cacheToken && this.cacheToken._type_ ? this.cacheToken._type_ : "default",
|
|
"custom" !== this.tokenType || this.enableCustomWebid ? this.enableCustomWebid ? this.collect.on(A.CustomWebId, function() {
|
|
t.tokenReady = !0,
|
|
t.collect.emit(A.TokenComplete)
|
|
}) : this.checkEnv() || (this.enable_ttwebid ? this.completeTtWid(this.cacheToken) : this.check()) : this.remoteWebid()
|
|
}
|
|
,
|
|
e.prototype.check = function() {
|
|
this.cacheToken && this.cacheToken.web_id ? this.complete(this.cacheToken) : this.config.disable_webid ? this.complete({
|
|
web_id: m(),
|
|
user_unique_id: this.configManager.get("user_unique_id") || m()
|
|
}) : this.remoteWebid()
|
|
}
|
|
,
|
|
e.prototype.checkEnv = function() {
|
|
var e = window.navigator.userAgent;
|
|
return (-1 !== e.indexOf("miniProgram") || -1 !== e.indexOf("MiniProgram")) && !(!(e = p(window.location.href)) || !e.Web_ID || (this.complete({
|
|
web_id: "" + e.Web_ID,
|
|
user_unique_id: this.configManager.get("user_unique_id") || "" + e.Web_ID
|
|
}),
|
|
0))
|
|
}
|
|
,
|
|
e.prototype.remoteWebid = function() {
|
|
var e = this
|
|
, t = this.configManager.getUrl("webid")
|
|
, r = {
|
|
app_key: this.config.app_key,
|
|
app_id: this.config.app_id,
|
|
url: location.href,
|
|
user_agent: window.navigator.userAgent,
|
|
referer: document.referrer,
|
|
user_unique_id: ""
|
|
};
|
|
this.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "SDK \u53D1\u8D77WEBID\u8BF7\u6C42",
|
|
logType: "fetch",
|
|
level: "info",
|
|
time: Date.now(),
|
|
data: r
|
|
}),
|
|
this.collect.requestManager.useRequest({
|
|
url: t,
|
|
data: r,
|
|
success: function(t) {
|
|
var r, n;
|
|
t && 0 === t.e ? (n = t.web_id,
|
|
e.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "WEBID\u8BF7\u6C42\u6210\u529F",
|
|
logType: "fetch",
|
|
level: "info",
|
|
time: Date.now(),
|
|
data: t
|
|
})) : (r = m(),
|
|
e.collect.configManager.set({
|
|
localWebId: n = r
|
|
}),
|
|
e.collect.emit(A.TokenError),
|
|
e.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "WEBID\u8BF7\u6C42\u8FD4\u56DE\u503C\u5F02\u5E38",
|
|
logType: "fetch",
|
|
level: "warn",
|
|
time: Date.now(),
|
|
data: t
|
|
}),
|
|
e.collect.logger.warn("appid: " + e.config.app_id + " get webid error, use local webid~")),
|
|
e.complete({
|
|
web_id: e.configManager.get("web_id") || n,
|
|
user_unique_id: e.configManager.get("user_unique_id") || n
|
|
})
|
|
},
|
|
fail: function() {
|
|
var t = m();
|
|
e.complete({
|
|
web_id: e.configManager.get("web_id") || t,
|
|
user_unique_id: e.configManager.get("user_unique_id") || t
|
|
}),
|
|
e.collect.configManager.set({
|
|
localWebId: t
|
|
}),
|
|
e.collect.emit(A.TokenError),
|
|
e.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "WEBID\u8BF7\u6C42\u7F51\u7EDC\u5F02\u5E38",
|
|
logType: "fetch",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: null
|
|
}),
|
|
e.collect.logger.warn("appid: " + e.config.app_id + ", get webid error, use local webid~")
|
|
},
|
|
timeout: 3e5
|
|
})
|
|
}
|
|
,
|
|
e.prototype.complete = function(e) {
|
|
var t = e.web_id
|
|
, r = e.user_unique_id;
|
|
e.timestamp = Date.now(),
|
|
this.collect.configManager.set({
|
|
web_id: t,
|
|
user_unique_id: r
|
|
}),
|
|
this.setStorage(e),
|
|
this.tokenReady = !0,
|
|
this.collect.emit(A.TokenComplete)
|
|
}
|
|
,
|
|
e.prototype.completeTtWid = function(e) {
|
|
var t = e.user_unique_id || ""
|
|
, r = this.configManager.get("user_unique_id");
|
|
(r || t) && this.configManager.set({
|
|
user_unique_id: r || t
|
|
}),
|
|
this.setStorage(e),
|
|
this.tokenReady = !0,
|
|
this.collect.emit(A.TokenComplete)
|
|
}
|
|
,
|
|
e.prototype.setUuid = function(e) {
|
|
var t, r;
|
|
e && -1 === ["null", "undefined", "Null", "None"].indexOf(e) ? (e = String(e),
|
|
t = this.configManager.get("user_unique_id"),
|
|
r = this.cacheToken && this.cacheToken.user_unique_id,
|
|
e === t && e === r || (this.configManager.set({
|
|
user_unique_id: e
|
|
}),
|
|
this.cacheToken || (this.cacheToken = {}),
|
|
this.cacheToken.user_unique_id = e,
|
|
this.cacheToken.timestamp = Date.now(),
|
|
this.setStorage(this.cacheToken),
|
|
this.collect.emit(A.TokenChange, "uuid"),
|
|
this.collect.emit(A.SessionReset))) : this.clearUuid()
|
|
}
|
|
,
|
|
e.prototype.clearUuid = function() {
|
|
this.config.enable_ttwebid || this.configManager.get("web_id") && this.configManager.get("user_unique_id") !== this.configManager.get("web_id") && (this.configManager.set({
|
|
user_unique_id: this.configManager.get("web_id")
|
|
}),
|
|
this.cacheToken && this.cacheToken.web_id && (this.cacheToken.user_unique_id = this.cacheToken.web_id,
|
|
this.cacheToken.timestamp = Date.now(),
|
|
this.setStorage(this.cacheToken)),
|
|
this.collect.emit(A.TokenReset, "uuid"))
|
|
}
|
|
,
|
|
e.prototype.setWebId = function(e) {
|
|
var t, r;
|
|
e && !this.config.enable_ttwebid && (this.cacheToken && this.cacheToken.web_id ? this.cacheToken.web_id !== e && (this.cacheToken.user_unique_id = this.cacheToken.web_id === this.cacheToken.user_unique_id ? e : this.cacheToken.user_unique_id,
|
|
this.cacheToken.web_id = e) : (this.cacheToken = {},
|
|
this.cacheToken.web_id = e,
|
|
this.cacheToken.user_unique_id = e),
|
|
this.cacheToken.timestamp = Date.now(),
|
|
t = this.configManager.get("web_id"),
|
|
(r = this.configManager.get("user_unique_id")) && r !== t || (this.configManager.set({
|
|
user_unique_id: e
|
|
}),
|
|
this.collect.emit(A.TokenChange, "uuid")),
|
|
t !== e && (this.configManager.set({
|
|
web_id: e
|
|
}),
|
|
this.collect.emit(A.TokenChange, "webid")),
|
|
this.setStorage(this.cacheToken))
|
|
}
|
|
,
|
|
e.prototype.setStorage = function(e) {
|
|
e._type_ = this.enableCustomWebid ? "custom" : "default",
|
|
delete e["diss".split("").reverse().join("")],
|
|
this.enableCookie || this.enable_ttwebid ? (this.storage.setCookie(this.tokenKey, e, this.expiresTime, this.cookieDomain),
|
|
this.enable_ttwebid && (delete e.web_id,
|
|
this.storage.setItem(this.tokenKey, e))) : this.storage.setItem(this.tokenKey, e),
|
|
this.cacheToken = e
|
|
}
|
|
,
|
|
e.prototype.getReady = function() {
|
|
return this.tokenReady
|
|
}
|
|
,
|
|
e.prototype.getTobId = function() {
|
|
var e = this;
|
|
return new Promise(function(t) {
|
|
e.collect.requestManager.useRequest({
|
|
url: e.configManager.getUrl("tobid"),
|
|
data: {
|
|
app_id: e.config.app_id,
|
|
user_unique_id: e.configManager.get("user_unique_id"),
|
|
web_id: e.configManager.get("web_id"),
|
|
user_unique_id_type: e.configManager.get("user_unique_id_type")
|
|
},
|
|
success: function(e) {
|
|
e && 0 === e.e ? t(e.tobid) : t("")
|
|
},
|
|
fail: function() {
|
|
t("")
|
|
},
|
|
time: 3e4,
|
|
withCredentials: e.enable_ttwebid
|
|
})
|
|
}
|
|
)
|
|
}
|
|
,
|
|
e
|
|
}(), K = function() {
|
|
function e(e, t) {
|
|
this.collector = e,
|
|
this.config = t,
|
|
this.requestType = t.request_type || "xhr",
|
|
this.supportBeacon = !(!window.navigator || !window.navigator.sendBeacon),
|
|
this.errorCode = {
|
|
NO_URL: 4001,
|
|
IMG_ON: 4e3,
|
|
IMG_CATCH: 4002,
|
|
BEACON_FALSE: 4003,
|
|
XHR_ON: 500,
|
|
RESPONSE: 5001,
|
|
TIMEOUT: 5005
|
|
},
|
|
this.customHeader = t.custom_request_header || {}
|
|
}
|
|
return e.prototype.useFetch = function(e) {
|
|
var t = e.url
|
|
, r = e.data
|
|
, n = e.method
|
|
, i = e.success
|
|
, o = e.fail
|
|
, s = {
|
|
"Content-Type": "application/json; charset=utf-8"
|
|
};
|
|
if (Object.keys(this.customHeader).length)
|
|
for (var a in this.customHeader)
|
|
s[a] = this.customHeader[a];
|
|
window.fetch ? fetch(t, {
|
|
method: n || "POST",
|
|
headers: s,
|
|
body: JSON.stringify(r)
|
|
}).then(function(e) {
|
|
return e.json()
|
|
}).then(function(e) {
|
|
i && i(e)
|
|
}).catch(function(e) {
|
|
o && o(r, e)
|
|
}) : (this.requestType = "xhr",
|
|
console.log("your brwoser not support fetch, use xhr"),
|
|
this.useRequest({
|
|
url: t,
|
|
data: r,
|
|
method: n,
|
|
success: i,
|
|
fail: o
|
|
}))
|
|
}
|
|
,
|
|
e.prototype.useBeacon = function(e) {
|
|
var t = e.url
|
|
, r = e.data
|
|
, n = e.success
|
|
, e = e.fail;
|
|
window.navigator.sendBeacon(t, JSON.stringify(r)) ? n && n() : e && e(r, this.errorCode.BEACON_FALSE)
|
|
}
|
|
,
|
|
e.prototype.useRequest = function(e) {
|
|
var t = this
|
|
, r = e.url
|
|
, n = e.data
|
|
, i = e.method
|
|
, o = e.success
|
|
, s = e.fail
|
|
, a = e.timeout
|
|
, c = e.useBeacon
|
|
, u = e.withCredentials
|
|
, l = e.app_key
|
|
, f = e.forceXhr;
|
|
if (c && this.supportBeacon)
|
|
this.useBeacon({
|
|
url: r,
|
|
data: n,
|
|
method: i,
|
|
success: o,
|
|
fail: s
|
|
});
|
|
else if ("fetch" !== this.requestType || f)
|
|
try {
|
|
var p = new XMLHttpRequest
|
|
, h = i || "POST";
|
|
if (p.open(h, "" + r, !0),
|
|
p.setRequestHeader("Content-Type", "application/json; charset=utf-8"),
|
|
l && p.setRequestHeader("X-MCS-AppKey", "" + l),
|
|
Object.keys(this.customHeader).length)
|
|
for (var d in this.customHeader)
|
|
p.setRequestHeader(d, this.customHeader[d]);
|
|
u && (p.withCredentials = !0),
|
|
a && (p.timeout = a,
|
|
p.ontimeout = function() {
|
|
s && s(n, t.errorCode.TIMEOUT)
|
|
}
|
|
),
|
|
p.onload = function() {
|
|
if (o) {
|
|
var e = null;
|
|
if (p.responseText) {
|
|
try {
|
|
e = JSON.parse(p.responseText)
|
|
} catch (t) {
|
|
e = {}
|
|
}
|
|
o(e, n)
|
|
}
|
|
}
|
|
}
|
|
,
|
|
p.onerror = function() {
|
|
p.abort(),
|
|
s && s(n, t.errorCode.XHR_ON)
|
|
}
|
|
,
|
|
p.send(JSON.stringify(n))
|
|
} catch (e) {}
|
|
else
|
|
this.useFetch({
|
|
url: r,
|
|
data: n,
|
|
method: i,
|
|
success: o,
|
|
fail: s
|
|
})
|
|
}
|
|
,
|
|
e
|
|
}(), q = function() {
|
|
function e(e, t) {
|
|
var r;
|
|
this.devToolReady = !1,
|
|
this.devToolOrigin = "*",
|
|
this.sendAlready = !1,
|
|
this.eventVerifyReady = !1,
|
|
t.enable_debug && (r = e.adapters.storage,
|
|
this.collect = e,
|
|
this.config = t,
|
|
this.app_id = t.app_id,
|
|
this.cacheStorgae = new r(!1,"session"),
|
|
this.eventVerifyInfo = [],
|
|
this.sdk_type = I.includes("tob") ? "tob" : "inner",
|
|
this.filterEvent = ["__bav_page", "__bav_beat", "__bav_page_statistics", "__bav_click", "__bav_page_exposure", "bav2b_page", "bav2b_beat", "bav2b_page_statistics", "bav2b_click", "bav2b_page_exposure", "_be_active", "predefine_pageview", "__profile_set", "__profile_set_once", "__profile_increment", "__profile_unset", "__profile_append", "predefine_page_alive", "predefine_page_close", "abtest_exposure"],
|
|
this.load())
|
|
}
|
|
return e.prototype.loadScript = function(e) {
|
|
try {
|
|
var t = document.createElement("script");
|
|
t.src = e,
|
|
t.onerror = function() {
|
|
console.log("load DevTool render fail")
|
|
}
|
|
,
|
|
t.onload = function() {
|
|
console.log("load DevTool render success")
|
|
}
|
|
,
|
|
document.getElementsByTagName("body")[0].appendChild(t)
|
|
} catch (e) {
|
|
console.log("devTool load fail, " + e.message)
|
|
}
|
|
}
|
|
,
|
|
e.prototype.parseUrl = function() {
|
|
var e = {};
|
|
try {
|
|
var t = window.location.href.split("?")[1].split("&");
|
|
t.length && t.forEach(function(t) {
|
|
t = t.split("="),
|
|
e[decodeURIComponent(t[0])] = decodeURIComponent(t[1])
|
|
})
|
|
} catch (e) {}
|
|
return e
|
|
}
|
|
,
|
|
e.prototype.load = function() {
|
|
var e, t, r;
|
|
return e = this,
|
|
r = function() {
|
|
var e;
|
|
return function(e, t) {
|
|
var r, n, i, o = {
|
|
label: 0,
|
|
sent: function() {
|
|
if (1 & i[0])
|
|
throw i[1];
|
|
return i[1]
|
|
},
|
|
trys: [],
|
|
ops: []
|
|
}, s = {
|
|
next: a(0),
|
|
throw: a(1),
|
|
return: a(2)
|
|
};
|
|
return "function" == typeof Symbol && (s[Symbol.iterator] = function() {
|
|
return this
|
|
}
|
|
),
|
|
s;
|
|
function a(s) {
|
|
return function(a) {
|
|
return function(s) {
|
|
if (r)
|
|
throw TypeError("Generator is already executing.");
|
|
for (; o; )
|
|
try {
|
|
if (r = 1,
|
|
n && (i = 2 & s[0] ? n.return : s[0] ? n.throw || ((i = n.return) && i.call(n),
|
|
0) : n.next) && !(i = i.call(n, s[1])).done)
|
|
return i;
|
|
switch (n = 0,
|
|
(s = i ? [2 & s[0], i.value] : s)[0]) {
|
|
case 0:
|
|
case 1:
|
|
i = s;
|
|
break;
|
|
case 4:
|
|
return o.label++,
|
|
{
|
|
value: s[1],
|
|
done: !1
|
|
};
|
|
case 5:
|
|
o.label++,
|
|
n = s[1],
|
|
s = [0];
|
|
continue;
|
|
case 7:
|
|
s = o.ops.pop(),
|
|
o.trys.pop();
|
|
continue;
|
|
default:
|
|
if (!(i = 0 < (i = o.trys).length && i[i.length - 1]) && (6 === s[0] || 2 === s[0])) {
|
|
o = 0;
|
|
continue
|
|
}
|
|
if (3 === s[0] && (!i || s[1] > i[0] && s[1] < i[3]))
|
|
o.label = s[1];
|
|
else if (6 === s[0] && o.label < i[1])
|
|
o.label = i[1],
|
|
i = s;
|
|
else {
|
|
if (!(i && o.label < i[2])) {
|
|
i[2] && o.ops.pop(),
|
|
o.trys.pop();
|
|
continue
|
|
}
|
|
o.label = i[2],
|
|
o.ops.push(s)
|
|
}
|
|
}
|
|
s = t.call(e, o)
|
|
} catch (e) {
|
|
s = [6, e],
|
|
n = 0
|
|
} finally {
|
|
r = i = 0
|
|
}
|
|
if (5 & s[0])
|
|
throw s[1];
|
|
return {
|
|
value: s[0] ? s[1] : void 0,
|
|
done: !0
|
|
}
|
|
}([s, a])
|
|
}
|
|
}
|
|
}(this, function(t) {
|
|
switch (t.label) {
|
|
case 0:
|
|
if (t.trys.push([0, 2, , 3]),
|
|
(e = this.parseUrl()).open_devtool_web && e.app_id) {
|
|
if (parseInt(e.app_id) !== this.app_id)
|
|
return [2]
|
|
} else if (!this.getStorage())
|
|
return [2];
|
|
return this.loadBaseInfo(),
|
|
this.loadHook(),
|
|
this.setStorage(),
|
|
this.addLintener(),
|
|
this.loadDebuggerModule(),
|
|
this.loadDevTool(),
|
|
[4, this.fetchEventInfo()];
|
|
case 1:
|
|
return e = t.sent(),
|
|
this.sendData("devtool:web:verify", e.verifyStatus),
|
|
this.eventVerifyInfo = e.data,
|
|
[3, 3];
|
|
case 2:
|
|
return console.log("debug fail, " + t.sent().message),
|
|
[3, 3];
|
|
case 3:
|
|
return [2]
|
|
}
|
|
})
|
|
}
|
|
,
|
|
new (t = void 0,
|
|
t = Promise)(function(n, i) {
|
|
function o(e) {
|
|
try {
|
|
a(r.next(e))
|
|
} catch (e) {
|
|
i(e)
|
|
}
|
|
}
|
|
function s(e) {
|
|
try {
|
|
a(r.throw(e))
|
|
} catch (e) {
|
|
i(e)
|
|
}
|
|
}
|
|
function a(e) {
|
|
e.done ? n(e.value) : new t(function(t) {
|
|
t(e.value)
|
|
}
|
|
).then(o, s)
|
|
}
|
|
a((r = r.apply(e, [])).next())
|
|
}
|
|
)
|
|
}
|
|
,
|
|
e.prototype.getStorage = function() {
|
|
var e = this.cacheStorgae.getItem("__applog_devtool_web");
|
|
return e && parseInt(e) === this.app_id
|
|
}
|
|
,
|
|
e.prototype.setStorage = function() {
|
|
this.cacheStorgae.setItem("__applog_devtool_web", this.app_id)
|
|
}
|
|
,
|
|
e.prototype.loadDevTool = function() {
|
|
this.loadScript("https://lf3-cdn-tos.bytescm.com/obj/static/log-sdk/collect/devtool/debug-web.0.0.2.js")
|
|
}
|
|
,
|
|
e.prototype.loadBaseInfo = function() {
|
|
var e = this;
|
|
this.info = [{
|
|
title: "\u57FA\u672C\u4FE1\u606F",
|
|
type: 1,
|
|
infoName: {
|
|
app_id: this.config.app_id,
|
|
channel: this.config.channel,
|
|
\u4E0A\u62A5\u57DF\u540D: this.collect.configManager.getDomain(),
|
|
SDK\u7248\u672C: I,
|
|
SDK\u5F15\u5165\u65B9\u5F0F: "npm"
|
|
}
|
|
}, {
|
|
title: "\u7528\u6237\u4FE1\u606F",
|
|
type: 2,
|
|
infoName: {
|
|
uuid: this.collect.configManager.get("user").user_unique_id || "",
|
|
web_id: this.collect.configManager.get("user").web_id || "",
|
|
ssid: "\u70B9\u51FB\u83B7\u53D6SSID"
|
|
}
|
|
}, {
|
|
title: "\u516C\u5171\u53C2\u6570\u4FE1\u606F",
|
|
type: 2,
|
|
infoName: {
|
|
\u6D4F\u89C8\u5668: this.collect.configManager.get("browser"),
|
|
\u6D4F\u89C8\u5668\u7248\u672C: this.collect.configManager.get("browser_version"),
|
|
\u5E73\u53F0: this.collect.configManager.get("platform"),
|
|
\u8BBE\u5907\u578B\u53F7: this.collect.configManager.get("device_model"),
|
|
\u64CD\u4F5C\u7CFB\u7EDF: this.collect.configManager.get("os_name"),
|
|
\u64CD\u4F5C\u7CFB\u7EDF\u7248\u672C: this.collect.configManager.get("os_version"),
|
|
\u5C4F\u5E55\u5206\u8FA8\u7387: this.collect.configManager.get("resolution"),
|
|
\u6765\u6E90: this.collect.configManager.get("referrer"),
|
|
\u81EA\u5B9A\u4E49\u4FE1\u606F: ""
|
|
}
|
|
}, {
|
|
title: "\u914D\u7F6E\u4FE1\u606F",
|
|
type: 3,
|
|
infoName: {
|
|
\u5168\u57CB\u70B9: !!this.config.autotrack,
|
|
\u505C\u7559\u65F6\u957F: !!this.config.enable_stay_duration
|
|
}
|
|
}, {
|
|
title: "A/B\u914D\u7F6E\u4FE1\u606F",
|
|
type: 4,
|
|
infoName: {
|
|
"A/B\u5B9E\u9A8C": !!this.config.enable_ab_test
|
|
}
|
|
}, {
|
|
title: "\u5BA2\u6237\u7AEF\u4FE1\u606F",
|
|
type: 3,
|
|
infoName: {
|
|
\u6253\u901A\u5F00\u5173: !!this.config.Native
|
|
}
|
|
}],
|
|
this.log = [],
|
|
this.event = [],
|
|
this.collect.on(A.Ready, function() {
|
|
e.info[1].infoName.uuid = e.collect.configManager.get("user").user_unique_id,
|
|
e.info[1].infoName.web_id = e.collect.configManager.get("user").web_id,
|
|
e.info[2].infoName["\u81EA\u5B9A\u4E49\u4FE1\u606F"] = JSON.stringify(e.collect.configManager.get("custom")),
|
|
e.config.enable_ab_test && (e.info[4].infoName["\u5DF2\u66DD\u5149VID"] = e.collect.configManager.getAbVersion(),
|
|
e.info[4].infoName["A/B\u57DF\u540D"] = e.config.ab_channel_domain || l(D[e.config.channel]),
|
|
e.info[4].infoName["\u5168\u90E8\u914D\u7F6E"] = e.collect.configManager.getAbData()),
|
|
e.config.Native && (e.info[5].infoName["\u662F\u5426\u6253\u901A"] = !!e.collect.bridgeReport)
|
|
})
|
|
}
|
|
,
|
|
e.prototype.loadHook = function() {
|
|
var e = this;
|
|
this.collect.stop(),
|
|
this.collect.on(S.DEBUGGER_MESSAGE, function(t) {
|
|
switch (t.type) {
|
|
case S.DEBUGGER_MESSAGE_SDK:
|
|
var r = {
|
|
time: t.time,
|
|
type: t.logType || "sdk",
|
|
level: t.level,
|
|
name: t.info,
|
|
show: !0,
|
|
levelShow: !0,
|
|
needDesc: !!t.data
|
|
};
|
|
return t.data && (r.desc = {
|
|
content: JSON.stringify(t.data)
|
|
}),
|
|
e.updateLog(r),
|
|
t.secType && "AB" === t.secType ? (e.info[4].infoName["\u5DF2\u66DD\u5149VID"] = e.collect.configManager.getAbVersion(),
|
|
e.info[4].infoName["\u5168\u90E8\u914D\u7F6E"] = e.collect.configManager.getAbData()) : "USER" === t.secType && (e.info[1].infoName.uuid = e.collect.configManager.get("user").user_unique_id,
|
|
e.info[1].infoName.web_id = e.collect.configManager.get("user").web_id),
|
|
void e.updateInfo();
|
|
case S.DEBUGGER_MESSAGE_EVENT:
|
|
if (t.data && t.data.length) {
|
|
var r = t.data[0]
|
|
, n = r.events
|
|
, i = r.header;
|
|
if (i.custom = JSON.parse(i.custom),
|
|
!n.length)
|
|
return;
|
|
n.forEach(function(r) {
|
|
r.checkShow = !0,
|
|
r.searchShow = !0,
|
|
r.type = -1 !== e.filterEvent.indexOf(r.event) ? "sdk" : "cus",
|
|
r.type = e.collect.bridgeReport ? "bridge" : r.type,
|
|
r.params = JSON.parse(r.params),
|
|
"fail" === t.status && (r.info = {
|
|
message: "code: " + t.code + "\uFF0C msg: " + t.failType
|
|
},
|
|
r.failType = t.failType);
|
|
var n = !1
|
|
, i = !1
|
|
, o = [];
|
|
e.eventVerifyInfo && e.eventVerifyInfo.length && (e.eventVerifyInfo.forEach(function(e) {
|
|
e.eventStatus = !1
|
|
}),
|
|
e.eventVerifyInfo.forEach(function(t) {
|
|
r.event === t.name && (n = i = !0,
|
|
r.verifyStatus = t.status,
|
|
Object.keys(r.params).forEach(function(n) {
|
|
var s;
|
|
"event_index" !== n && ((s = {}).paramsKey = n,
|
|
s.paramsKeyValue = r.params["" + n],
|
|
s.paramsStatus = !1,
|
|
s.paramsStatusInfo = "\u5C5E\u6027\u672A\u5F55\u5165",
|
|
t.params.forEach(function(t) {
|
|
n === t.name && (t.checked = !0,
|
|
typeof r.params["" + n] !== e.formatParamsType(t.value_type) ? s.paramsStatusInfo = "\u5C5E\u6027\u7C7B\u578B\u9519\u8BEF\uFF0C\u5E94\u4E3A" + e.formatParamsType(t.value_type) : (s.paramsStatus = !0,
|
|
s.paramsStatusInfo = ""))
|
|
}),
|
|
o.push(s),
|
|
s.paramsStatusInfo) && (i = !1)
|
|
}),
|
|
t.params.forEach(function(e) {
|
|
e.checked || (i = !1,
|
|
o.push({
|
|
paramsKey: e.name,
|
|
paramsStatus: !1,
|
|
paramsStatusInfo: "\u7F3A\u5C11\u5C5E\u6027" + e.name
|
|
}))
|
|
}))
|
|
})),
|
|
r.reportStatus = "success" === t.status,
|
|
r.paramsInfo = o,
|
|
r.eventStatus = i && "success" === t.status,
|
|
r.eventRecord = n
|
|
}),
|
|
e.updateEvent(r)
|
|
}
|
|
return
|
|
}
|
|
})
|
|
}
|
|
,
|
|
e.prototype.formatParamsType = function(e) {
|
|
switch (e) {
|
|
case 0:
|
|
return "string";
|
|
case 1:
|
|
case 2:
|
|
return "number";
|
|
case 3:
|
|
return "boolean"
|
|
}
|
|
}
|
|
,
|
|
e.prototype.fetchEventInfo = function() {
|
|
var e = this;
|
|
try {
|
|
return new Promise(function(t) {
|
|
var r = l("1fz22z22z1nz21z4mz4bz4bz18z1nz1nz1jz1mz1ez1fz1mz1kz1cz4az19z27z22z1cz1bz18z1lz1az1cz4az1lz1cz22z4bz18z1nz1nz1jz1mz1ez1bz1cz24z22z1mz1mz1jz21z4bz1mz1nz1cz1lz18z1nz1gz4bz24z4dz4bz18z1nz1nz16z1jz1mz1ez16z1kz1cz22z18") + "?app_id=" + e.app_id + "&t=" + e.sdk_type + "&nc=false";
|
|
e.collect.requestManager.useRequest({
|
|
url: r,
|
|
method: "GET",
|
|
success: function(r) {
|
|
e.eventVerifyReady = !0,
|
|
e.collect.reStart(),
|
|
t({
|
|
data: r.data,
|
|
verifyStatus: !0
|
|
})
|
|
},
|
|
fail: function() {
|
|
e.eventVerifyReady = !0,
|
|
e.collect.reStart(),
|
|
t({
|
|
data: [],
|
|
verifyStatus: !1
|
|
})
|
|
},
|
|
timeout: 3e3
|
|
})
|
|
}
|
|
)
|
|
} catch (e) {
|
|
return {
|
|
data: [],
|
|
verifyStatus: !1
|
|
}
|
|
}
|
|
}
|
|
,
|
|
e.prototype.addLintener = function() {
|
|
var e = this;
|
|
window.addEventListener("message", function(t) {
|
|
if (t.origin === location.origin) {
|
|
if (t && t.data && "devtool:web:ready" === t.data.type) {
|
|
if (e.devToolOrigin = t.origin,
|
|
e.devToolReady = !0,
|
|
e.sendAlready)
|
|
return;
|
|
e.sendData("devtool:web:init", {
|
|
info: e.info,
|
|
log: e.log,
|
|
event: e.event,
|
|
appid: e.app_id
|
|
}),
|
|
e.sendAlready = !0
|
|
}
|
|
t && t.data && "devtool:web:ssid" === t.data.type && e.collect.getToken(function(t) {
|
|
e.info[1].infoName.ssid = t.tobid,
|
|
e.updateInfo()
|
|
}),
|
|
t && t.data && t.data.type
|
|
}
|
|
})
|
|
}
|
|
,
|
|
e.prototype.sendData = function(e, t) {
|
|
try {
|
|
(window.opener || window.parent).postMessage({
|
|
type: e,
|
|
payload: t
|
|
}, this.devToolOrigin)
|
|
} catch (e) {}
|
|
}
|
|
,
|
|
e.prototype.updateInfo = function() {
|
|
this.devToolReady && this.sendData("devtool:web:info", this.info)
|
|
}
|
|
,
|
|
e.prototype.updateLog = function(e) {
|
|
this.devToolReady ? this.sendData("devtool:web:log", e) : this.log.push(e)
|
|
}
|
|
,
|
|
e.prototype.updateEvent = function(e) {
|
|
this.devToolReady || this.eventVerifyReady ? this.sendData("devtool:web:event", e) : this.event.push(e)
|
|
}
|
|
,
|
|
e.prototype.loadDebuggerModule = function() {
|
|
var e = document.head || document.getElementsByTagName("head")[0]
|
|
, t = document.createElement("style")
|
|
, e = (t.appendChild(document.createTextNode("#debugger-applog-web {\n position: fixed;\n width: 50px;\n height: 50px;\n background-image: url('https://lf-cdn-tos.bytescm.com/obj/static/log-sdk/collect/devtool/applog.png');;\n bottom: 5%;\n right: 10%;\n cursor: pointer;\n z-index:100;\n background-size: 50px;\n }")),
|
|
e.appendChild(t),
|
|
document.createElement("div"))
|
|
, t = (e.innerHTML = '<div id="debugger-applog-web" class="debugger-applog-web"></div>',
|
|
document.createElement("div"));
|
|
t.innerHTML = '<div id="debugger-container" class="debugger-container"></div>',
|
|
document.getElementsByTagName("body")[0].appendChild(e),
|
|
document.getElementsByTagName("body")[0].appendChild(t),
|
|
document.getElementById("debugger-applog-web").addEventListener("click", function() {
|
|
(window.opener || window.parent).postMessage({
|
|
type: "devtool:web:open-draw"
|
|
}, location.origin)
|
|
})
|
|
}
|
|
,
|
|
e
|
|
}(), V = {
|
|
autotrack: {
|
|
src: {
|
|
cn: "https://lf3-cdn-tos.bytescm.com/obj/static/log-sdk/collect/5.0/plugin/autotrack.js",
|
|
sg: "https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/autotrack.js",
|
|
va: "https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/autotrack.js"
|
|
},
|
|
object: "LogAutoTrack"
|
|
},
|
|
ab: {
|
|
src: {
|
|
cn: "https://lf3-cdn-tos.bytescm.com/obj/static/log-sdk/collect/5.0/plugin/ab.js",
|
|
sg: "https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/ab.js",
|
|
va: "https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/ab.js"
|
|
},
|
|
object: "LogAb"
|
|
},
|
|
stay: {
|
|
src: {
|
|
cn: "https://lf3-cdn-tos.bytescm.com/obj/static/log-sdk/collect/5.0/plugin/stay.js",
|
|
sg: "https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/stay.js",
|
|
va: "https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/stay.js"
|
|
},
|
|
object: "LogStay"
|
|
},
|
|
route: {
|
|
src: {
|
|
cn: "https://lf3-cdn-tos.bytescm.com/obj/static/log-sdk/collect/5.0/plugin/route.js",
|
|
sg: "https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/route.js",
|
|
va: "https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/route.js"
|
|
},
|
|
object: "LogRoute"
|
|
},
|
|
cep: {
|
|
src: {
|
|
cn: "https://lf3-cdn-tos.bytescm.com/obj/static/log-sdk/collect/5.0/plugin/cep.js",
|
|
sg: "https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/cep.js",
|
|
va: "https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/cep.js"
|
|
},
|
|
object: "LogCep"
|
|
},
|
|
tracer: {
|
|
src: {
|
|
cn: "https://lf3-cdn-tos.bytescm.com/obj/static/log-sdk/collect/5.0/plugin/tracer.js",
|
|
sg: "https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/tracer.js",
|
|
va: "https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/tracer.js"
|
|
},
|
|
object: "LogTracer"
|
|
},
|
|
retry: {
|
|
src: {
|
|
cn: "https://lf3-cdn-tos.bytescm.com/obj/static/log-sdk/collect/5.0/plugin/retry.js",
|
|
sg: "https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/retry.js",
|
|
va: "https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/retry.js"
|
|
},
|
|
object: "LogRetry"
|
|
},
|
|
visual: {
|
|
src: {
|
|
cn: "https://lf3-cdn-tos.bytescm.com/obj/static/log-sdk/collect/5.0/plugin/visual.js",
|
|
sg: "https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/visual.js",
|
|
va: "https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/visual.js"
|
|
},
|
|
object: "LogVisual"
|
|
}
|
|
}, W = ["et", "profile", "heartbeat", "monitor"], J = function() {
|
|
function e(e) {
|
|
this.disableAutoPageView = !1,
|
|
this.bridgeReport = !1,
|
|
this.staging = !1,
|
|
this.pluginInstances = [],
|
|
this.sended = !1,
|
|
this.started = !1,
|
|
this.destroy = !1,
|
|
this.sdkReady = !1,
|
|
this.adapters = {},
|
|
this.loadType = "base",
|
|
this.sdkStop = !1,
|
|
this.name = e,
|
|
this.hook = new x,
|
|
this.remotePlugin = new Map,
|
|
this.Types = A,
|
|
this.adapters.storage = T
|
|
}
|
|
return e.usePlugin = function(t, r, n) {
|
|
if (r) {
|
|
for (var i = !1, o = 0, s = e.plugins.length; o < s; o++)
|
|
if (e.plugins[o].name === r) {
|
|
e.plugins[o].plugin = t,
|
|
e.plugins[o].options = n || {},
|
|
i = !0;
|
|
break
|
|
}
|
|
i || e.plugins.push({
|
|
name: r,
|
|
plugin: t,
|
|
options: n
|
|
})
|
|
} else
|
|
e.plugins.push({
|
|
plugin: t
|
|
})
|
|
}
|
|
,
|
|
e.prototype.usePlugin = function(e, t, r) {
|
|
e && ("full" === this.loadType && W.includes(e) ? console.info("your sdk version has " + e + " plugin already ~") : t ? "string" == typeof t ? this.remotePlugin.get(e) || this.remotePlugin.set(e, {
|
|
src: t,
|
|
call: r
|
|
}) : this.remotePlugin.get(e) || this.remotePlugin.set(e, {
|
|
instance: t
|
|
}) : this.remotePlugin.get(e) || this.remotePlugin.set(e, "sdk"))
|
|
}
|
|
,
|
|
e.prototype.init = function(t) {
|
|
var r, n = this;
|
|
this.logger = new M(this.name,t.log),
|
|
this.inited ? this.logger.warn("[instance: " + this.name + "], every instance's api: init, can be call only one time!") : t && u(t) ? t.app_id && "number" == typeof (r = t.app_id) && !isNaN(r) ? t.app_key && "string" != typeof t.app_key ? this.logger.warn("app_key param is error, must be string, please check!") : (t.channel_domain || -1 !== ["cn", "sg", "va"].indexOf(t.channel) || (this.logger.warn("channel must be `cn`, `sg`,`va` !"),
|
|
t.channel = "cn"),
|
|
this.spider = new G,
|
|
this.spider.checkSpider(t) ? this.logger.warn("your env may be a spider, can not report!") : (this.appBridge = new F(this,t.enable_native),
|
|
this.requestManager = new K(this,t),
|
|
this.bridgeReport = this.appBridge.bridgeInject(),
|
|
this.configManager = new U(this,t),
|
|
this.debugger = new q(this,t),
|
|
this.initConfig = t,
|
|
this.emit(A.Init),
|
|
this.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "SDK \u6267\u884CINIT",
|
|
data: t,
|
|
level: "info",
|
|
time: Date.now()
|
|
}),
|
|
this.destroy = !1,
|
|
t.disable_auto_pv && (this.disableAutoPageView = !0),
|
|
this.bridgeReport || (this.configManager.set({
|
|
app_id: t.app_id
|
|
}),
|
|
this.eventManager = new H,
|
|
this.tokenManager = new L,
|
|
this.sessionManager = new N,
|
|
Promise.all([new Promise(function(e) {
|
|
n.once(A.TokenComplete, function() {
|
|
e(!0)
|
|
})
|
|
}
|
|
), new Promise(function(e) {
|
|
n.once(A.Start, function() {
|
|
e(!0)
|
|
})
|
|
}
|
|
)]).then(function() {
|
|
try {
|
|
e.plugins.reduce(function(e, t) {
|
|
var r = t.plugin
|
|
, t = t.options
|
|
, t = Object.assign(n.initConfig, t)
|
|
, r = new r;
|
|
return r.apply(n, t),
|
|
e.push(r),
|
|
e
|
|
}, n.pluginInstances)
|
|
} catch (e) {
|
|
console.warn("load plugin error, " + e.message),
|
|
n.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: e.message
|
|
})
|
|
}
|
|
n.sdkReady = !0,
|
|
n.emit(A.Ready),
|
|
n.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "SDK \u521D\u59CB\u5316\u5B8C\u6210",
|
|
time: Date.now(),
|
|
level: "info",
|
|
data: n.configManager.get("user")
|
|
}),
|
|
n.logger.info("appid: " + t.app_id + ", userInfo:" + JSON.stringify(n.configManager.get("user"))),
|
|
n.logger.info("appid: " + t.app_id + ", sdk is ready, version type is " + n.loadType + ", version is " + I + ", you can report now !!!"),
|
|
t.disable_auto_pv && (n.disableAutoPageView = !0);
|
|
try {
|
|
"full" === n.loadType && (t.enable_ab_test || t.autotrack) && (window.opener || window.parent).postMessage("[tea-sdk]ready", "*")
|
|
} catch (e) {
|
|
n.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: e.message
|
|
})
|
|
}
|
|
n.pageView(),
|
|
n.on(A.TokenChange, function(e) {
|
|
"webid" === e && n.pageView(),
|
|
n.logger.info("appid: " + t.app_id + " token change, new userInfo:" + JSON.stringify(n.configManager.get("user"))),
|
|
n.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "SDK \u8BBE\u7F6E\u4E86\u7528\u6237\u4FE1\u606F",
|
|
time: Date.now(),
|
|
secType: "USER",
|
|
level: "info",
|
|
data: n.configManager.get("user")
|
|
})
|
|
}),
|
|
n.on(A.TokenReset, function() {
|
|
n.logger.info("appid: " + t.app_id + " token reset, new userInfo:" + JSON.stringify(n.configManager.get("user"))),
|
|
n.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "SDK \u91CD\u7F6E\u4E86\u7528\u6237\u4FE1\u606F",
|
|
time: Date.now(),
|
|
secType: "USER",
|
|
level: "info",
|
|
data: n.configManager.get("user")
|
|
})
|
|
}),
|
|
n.on(A.RouteChange, function(e) {
|
|
e.init || t.disable_route_report || n.pageView()
|
|
})
|
|
}),
|
|
this.tokenManager.apply(this, t),
|
|
this.eventManager.apply(this, t),
|
|
this.sessionManager.apply(this, t)),
|
|
this.inited = !0)) : this.logger.warn("app_id param is error, must be number, please check!") : this.logger.warn("init params error,please check!")
|
|
}
|
|
,
|
|
e.prototype.config = function(e) {
|
|
var t, r;
|
|
this.inited ? e && u(e) ? this.bridgeReport ? this.appBridge.setConfig(e) : (e._staging_flag && 1 === e._staging_flag && (this.staging = !0),
|
|
e.disable_auto_pv && (this.disableAutoPageView = !0,
|
|
delete e.disable_auto_pv),
|
|
t = a({}, e),
|
|
r = this.initConfig.configPersist || this.initConfig.config_persist || !1,
|
|
this.initConfig && r && ((r = this.configManager.getStore()) && (t = Object.assign(r, e)),
|
|
this.configManager.setStore(e)),
|
|
t.web_id,
|
|
t.user_unique_id,
|
|
r = function(e, t) {
|
|
var r = {};
|
|
for (i in e)
|
|
Object.prototype.hasOwnProperty.call(e, i) && 0 > t.indexOf(i) && (r[i] = e[i]);
|
|
if (null != e && "function" == typeof Object.getOwnPropertySymbols)
|
|
for (var n = 0, i = Object.getOwnPropertySymbols(e); n < i.length; n++)
|
|
0 > t.indexOf(i[n]) && (r[i[n]] = e[i[n]]);
|
|
return r
|
|
}(t, ["web_id", "user_unique_id"]),
|
|
this.configManager.set(r),
|
|
t.hasOwnProperty("web_id") && this.emit(A.ConfigWebId, t.web_id),
|
|
t.hasOwnProperty("user_unique_id") && this.emit(A.ConfigUuid, t.user_unique_id),
|
|
this.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "SDK \u6267\u884CCONFIG",
|
|
level: "info",
|
|
time: Date.now(),
|
|
data: t
|
|
})) : console.warn("config params is error, please check") : console.warn("config must be use after function init")
|
|
}
|
|
,
|
|
e.prototype.setUserUniqueID = function(e) {
|
|
this.config({
|
|
user_unique_id: e
|
|
})
|
|
}
|
|
,
|
|
e.prototype.setHeaderInfo = function(e, t) {
|
|
var r = {};
|
|
r[e] = t,
|
|
this.config(r)
|
|
}
|
|
,
|
|
e.prototype.removeHeaderInfo = function(e) {
|
|
var t = {};
|
|
t[e] = void 0,
|
|
this.config(t)
|
|
}
|
|
,
|
|
e.prototype.setDomain = function(e) {
|
|
this.configManager && this.configManager.setDomain(e),
|
|
this.emit(A.ConfigDomain)
|
|
}
|
|
,
|
|
e.prototype.getConfig = function(e) {
|
|
return this.configManager.get(e)
|
|
}
|
|
,
|
|
e.prototype.send = function() {
|
|
this.start()
|
|
}
|
|
,
|
|
e.prototype.start = function() {
|
|
this.inited && !this.sended && (this.sended = !0,
|
|
this.started = !0,
|
|
this.emit(A.Start),
|
|
this.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "SDK \u6267\u884CSTART",
|
|
level: "info",
|
|
time: Date.now()
|
|
}),
|
|
this.bridgeReport) && (this.pageView(),
|
|
this.emit(A.Ready))
|
|
}
|
|
,
|
|
e.prototype.event = function(e, t) {
|
|
var r = this;
|
|
try {
|
|
var n = [];
|
|
if (Array.isArray(e))
|
|
e.forEach(function(e) {
|
|
(e = r.processEvent(e[0], e[1] || {})) && n.push(e)
|
|
});
|
|
else {
|
|
var i = this.processEvent(e, t);
|
|
if (!i)
|
|
return;
|
|
n.push(i)
|
|
}
|
|
this.bridgeReport ? n.forEach(function(e) {
|
|
var t = e.event
|
|
, e = e.params;
|
|
r.appBridge.onEventV3(t, JSON.stringify(e))
|
|
}) : n.length && (this.emit(A.Event, n),
|
|
this.emit(A.SessionResetTime))
|
|
} catch (e) {
|
|
this.logger.warn("something error, please check"),
|
|
this.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: e.message
|
|
})
|
|
}
|
|
}
|
|
,
|
|
e.prototype.beconEvent = function(e, t) {
|
|
var r;
|
|
Array.isArray(e) ? console.warn("beconEvent not support batch report, please check") : (r = [],
|
|
(e = this.processEvent(e, t || {})) && (r.push(e),
|
|
r.length) && (this.emit(A.BeconEvent, r),
|
|
this.emit(A.SessionResetTime)))
|
|
}
|
|
,
|
|
e.prototype.beaconEvent = function(e, t) {
|
|
this.beconEvent(e, t)
|
|
}
|
|
,
|
|
e.prototype.processEvent = function(e, t) {
|
|
void 0 === t && (t = {});
|
|
try {
|
|
var r, n, i;
|
|
return e ? (/^event\./.test(r = e) && (r = e.slice(6)),
|
|
i = void ((n = "object" != typeof (n = t) ? {} : n).profile ? delete n.profile : n.event_index = _ += 1),
|
|
n.local_ms ? (i = n.local_ms,
|
|
delete n.local_ms) : i = +new Date,
|
|
{
|
|
event: r,
|
|
params: n,
|
|
local_time_ms: i,
|
|
is_bav: this.initConfig && this.initConfig.autotrack ? 1 : 0
|
|
}) : (console.warn("eventName is null\uFF0C please check"),
|
|
null)
|
|
} catch (r) {
|
|
return this.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: r.message
|
|
}),
|
|
{
|
|
event: e,
|
|
params: t
|
|
}
|
|
}
|
|
}
|
|
,
|
|
e.prototype.filterEvent = function(e) {
|
|
this.eventFilter = e
|
|
}
|
|
,
|
|
e.prototype.on = function(e, t) {
|
|
this.hook.on(e, t)
|
|
}
|
|
,
|
|
e.prototype.once = function(e, t) {
|
|
this.hook.once(e, t)
|
|
}
|
|
,
|
|
e.prototype.off = function(e, t) {
|
|
this.hook.off(e, t)
|
|
}
|
|
,
|
|
e.prototype.emit = function(e, t, r) {
|
|
this.hook.emit(e, t, r)
|
|
}
|
|
,
|
|
e.prototype.set = function(e) {
|
|
this.hook.set(e)
|
|
}
|
|
,
|
|
e.prototype.stop = function() {
|
|
this.sdkStop = !0
|
|
}
|
|
,
|
|
e.prototype.reStart = function() {
|
|
this.sdkStop = !1
|
|
}
|
|
,
|
|
e.prototype.pageView = function() {
|
|
this.disableAutoPageView || this.predefinePageView()
|
|
}
|
|
,
|
|
e.prototype.predefinePageView = function(e) {
|
|
var t;
|
|
void 0 === e && (e = {}),
|
|
this.inited ? (t = {
|
|
title: document.title || location.pathname,
|
|
url: location.href,
|
|
url_path: location.pathname,
|
|
time: Date.now(),
|
|
referrer: window.document.referrer,
|
|
$is_first_time: "" + (this.configManager && this.configManager.is_first_time || !1)
|
|
},
|
|
t = a({}, t, e),
|
|
this.event("predefine_pageview", t)) : console.warn("predefinePageView must be use after function init")
|
|
}
|
|
,
|
|
e.prototype.clearEventCache = function() {
|
|
this.emit(A.CleanEvents)
|
|
}
|
|
,
|
|
e.prototype.setWebIDviaUnionID = function(e) {
|
|
var t;
|
|
e && (t = h(e),
|
|
this.config({
|
|
web_id: "" + t,
|
|
wechat_unionid: e
|
|
}),
|
|
this.emit(A.CustomWebId))
|
|
}
|
|
,
|
|
e.prototype.setWebId = function(e) {
|
|
this.config({
|
|
web_id: "" + e
|
|
})
|
|
}
|
|
,
|
|
e.prototype.setWebIDviaOpenID = function(e) {
|
|
var t;
|
|
e && (t = h(e),
|
|
this.config({
|
|
web_id: "" + t,
|
|
wechat_openid: e
|
|
}),
|
|
this.emit(A.CustomWebId))
|
|
}
|
|
,
|
|
e.prototype.setNativeAppId = function(e) {
|
|
this.bridgeReport && this.appBridge.setNativeAppId(e)
|
|
}
|
|
,
|
|
e.prototype.getSessionId = y,
|
|
e.prototype.setSessionId = function(e) {
|
|
this.emit(A.SessionReset, e)
|
|
}
|
|
,
|
|
e.prototype.resetStayDuration = function(e, t, r) {
|
|
this.emit(A.ResetStay, {
|
|
url_path: e,
|
|
title: t,
|
|
url: r
|
|
}, A.Stay)
|
|
}
|
|
,
|
|
e.prototype.resetStayParams = function(e, t, r) {
|
|
this.emit(A.SetStay, {
|
|
url_path: e = void 0 === e ? "" : e,
|
|
title: t = void 0 === t ? "" : t,
|
|
url: r = void 0 === r ? "" : r
|
|
}, A.Stay)
|
|
}
|
|
,
|
|
e.prototype.getToken = function(e, t) {
|
|
var r, n, i, o = this;
|
|
this.inited ? (r = !1,
|
|
n = function(t) {
|
|
var n;
|
|
if (!r)
|
|
return r = !0,
|
|
n = o.configManager.get().user,
|
|
t && (n.tobid = t,
|
|
n["diss".split("").reverse().join("")] = t),
|
|
e(a({}, n))
|
|
}
|
|
,
|
|
i = function() {
|
|
o.tokenManager.getTobId().then(function(e) {
|
|
n(e)
|
|
})
|
|
}
|
|
,
|
|
this.sdkReady ? i() : (t && setTimeout(function() {
|
|
n()
|
|
}, t),
|
|
this.on(A.Ready, function() {
|
|
i()
|
|
}))) : console.warn("getToken must be use after function init")
|
|
}
|
|
,
|
|
e.prototype.profileSet = function(e) {
|
|
this.bridgeReport ? this.appBridge.profileSet(JSON.stringify(e)) : this.emit(A.ProfileSet, e, A.Profile),
|
|
this.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "SDK \u6267\u884CprofileSet",
|
|
level: "info",
|
|
time: Date.now(),
|
|
data: e
|
|
})
|
|
}
|
|
,
|
|
e.prototype.profileSetOnce = function(e) {
|
|
this.bridgeReport ? this.appBridge.profileSetOnce(JSON.stringify(e)) : this.emit(A.ProfileSetOnce, e, A.Profile),
|
|
this.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "SDK \u6267\u884CprofileSetOnce",
|
|
level: "info",
|
|
time: Date.now(),
|
|
data: e
|
|
})
|
|
}
|
|
,
|
|
e.prototype.profileIncrement = function(e) {
|
|
this.bridgeReport ? this.appBridge.profileIncrement(JSON.stringify(e)) : this.emit(A.ProfileIncrement, e, A.Profile),
|
|
this.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "SDK \u6267\u884CprofileIncrement",
|
|
level: "info",
|
|
time: Date.now(),
|
|
data: e
|
|
})
|
|
}
|
|
,
|
|
e.prototype.profileUnset = function(e) {
|
|
this.bridgeReport ? this.appBridge.profileUnset(e) : this.emit(A.ProfileUnset, e, A.Profile),
|
|
this.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "SDK \u6267\u884CprofileUnset",
|
|
level: "info",
|
|
time: Date.now(),
|
|
data: e
|
|
})
|
|
}
|
|
,
|
|
e.prototype.profileAppend = function(e) {
|
|
this.bridgeReport ? this.appBridge.profileAppend(JSON.stringify(e)) : this.emit(A.ProfileAppend, e, A.Profile),
|
|
this.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "SDK \u6267\u884CprofileAppend",
|
|
level: "info",
|
|
time: Date.now(),
|
|
data: e
|
|
})
|
|
}
|
|
,
|
|
e.prototype.setExternalAbVersion = function(e) {
|
|
this.emit(A.AbExternalVersion, "string" == typeof e && e ? ("" + e).trim() : null, A.Ab)
|
|
}
|
|
,
|
|
e.prototype.getVar = function(e, t, r) {
|
|
this.emit(A.AbVar, {
|
|
name: e,
|
|
defaultValue: t,
|
|
callback: r
|
|
}, A.Ab)
|
|
}
|
|
,
|
|
e.prototype.getABconfig = function(e, t) {
|
|
this.emit(A.AbConfig, {
|
|
params: e,
|
|
callback: t
|
|
}, A.Ab)
|
|
}
|
|
,
|
|
e.prototype.getAbSdkVersion = function() {
|
|
return this.configManager.getAbVersion()
|
|
}
|
|
,
|
|
e.prototype.onAbSdkVersionChange = function(e) {
|
|
var t = this;
|
|
return this.emit(A.AbVersionChangeOn, e, A.Ab),
|
|
function() {
|
|
t.emit(A.AbVersionChangeOff, e, A.Ab)
|
|
}
|
|
}
|
|
,
|
|
e.prototype.offAbSdkVersionChange = function(e) {
|
|
this.emit(A.AbVersionChangeOff, e, A.Ab)
|
|
}
|
|
,
|
|
e.prototype.openOverlayer = function() {
|
|
this.emit(A.AbOpenLayer, "", A.Ab)
|
|
}
|
|
,
|
|
e.prototype.closeOverlayer = function() {
|
|
this.emit(A.AbCloseLayer, "", A.Ab)
|
|
}
|
|
,
|
|
e.prototype.getAllVars = function(e) {
|
|
this.emit(A.AbAllVars, e, A.Ab)
|
|
}
|
|
,
|
|
e.prototype.destoryInstace = function() {
|
|
this.destroy || (this.destroy = !0,
|
|
this.off(A.TokenComplete),
|
|
this.emit(A.DestoryInstance))
|
|
}
|
|
,
|
|
e.prototype.destroyInstance = function() {
|
|
this.destroy || (this.destroy = !0,
|
|
this.off(A.TokenComplete),
|
|
this.emit(A.DestoryInstance))
|
|
}
|
|
,
|
|
e.plugins = [],
|
|
e
|
|
}(), t = function() {
|
|
function e() {}
|
|
return e.prototype.apply = function(e, t) {
|
|
var r = this;
|
|
t.event_verify_url && ("string" == typeof t.event_verify_url ? (this.url = t.event_verify_url + "/v1/list_test",
|
|
e.on(e.Types.SubmitBefore, function(t) {
|
|
e.requestManager.useBeacon({
|
|
url: r.url,
|
|
data: t
|
|
})
|
|
})) : console.log("please use correct et_test url"))
|
|
}
|
|
,
|
|
e
|
|
}(), Q = function() {
|
|
function e() {}
|
|
return e.prototype.apply = function(e, t) {
|
|
var r = this
|
|
, n = (this.collect = e,
|
|
this.config = t,
|
|
this.duration = 6e4,
|
|
this.reportUrl = e.configManager.getDomain() + "/profile/list",
|
|
e.Types);
|
|
this.eventCheck = new P(e,t),
|
|
this.cache = {},
|
|
this.collect.on(n.ProfileSet, function(e) {
|
|
r.setProfile(e)
|
|
}),
|
|
this.collect.on(n.ProfileSetOnce, function(e) {
|
|
r.setOnceProfile(e)
|
|
}),
|
|
this.collect.on(n.ProfileUnset, function(e) {
|
|
r.unsetProfile(e)
|
|
}),
|
|
this.collect.on(n.ProfileIncrement, function(e) {
|
|
r.incrementProfile(e)
|
|
}),
|
|
this.collect.on(n.ProfileAppend, function(e) {
|
|
r.appendProfile(e)
|
|
}),
|
|
this.collect.on(n.ProfileClear, function() {
|
|
r.cache = {}
|
|
}),
|
|
this.ready(n.Profile)
|
|
}
|
|
,
|
|
e.prototype.ready = function(e) {
|
|
var t = this;
|
|
if (this.collect.set(e),
|
|
this.collect.hook._hooksCache.hasOwnProperty(e)) {
|
|
var r = this.collect.hook._hooksCache[e];
|
|
if (Object.keys(r).length)
|
|
for (var n in r)
|
|
!function(e) {
|
|
r[e].length && r[e].forEach(function(r) {
|
|
t.collect.hook.emit(e, r)
|
|
})
|
|
}(n)
|
|
}
|
|
}
|
|
,
|
|
e.prototype.report = function(e, t) {
|
|
void 0 === t && (t = {});
|
|
try {
|
|
var r, n;
|
|
this.config.disable_track_event || ((r = []).push(this.collect.processEvent(e, t)),
|
|
n = this.collect.eventManager.merge(r),
|
|
this.collect.requestManager.useRequest({
|
|
url: this.reportUrl,
|
|
data: n
|
|
}),
|
|
this.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_EVENT,
|
|
info: "\u57CB\u70B9\u4E0A\u62A5\u6210\u529F",
|
|
time: Date.now(),
|
|
data: n,
|
|
code: 200,
|
|
status: "success"
|
|
}))
|
|
} catch (e) {
|
|
this.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: e.message
|
|
})
|
|
}
|
|
}
|
|
,
|
|
e.prototype.setProfile = function(e) {
|
|
(e = this.formatParams(e)) && Object.keys(e).length && (this.pushCache(e),
|
|
this.report("__profile_set", a({}, e, {
|
|
profile: !0
|
|
})))
|
|
}
|
|
,
|
|
e.prototype.setOnceProfile = function(e) {
|
|
(e = this.formatParams(e, !0)) && Object.keys(e).length && (this.pushCache(e),
|
|
this.report("__profile_set_once", a({}, e, {
|
|
profile: !0
|
|
})))
|
|
}
|
|
,
|
|
e.prototype.incrementProfile = function(e) {
|
|
e ? this.report("__profile_increment", a({}, e, {
|
|
profile: !0
|
|
})) : console.warn("please check the params, must be object!!!")
|
|
}
|
|
,
|
|
e.prototype.unsetProfile = function(e) {
|
|
var t;
|
|
e ? ((t = {})[e] = "1",
|
|
this.report("__profile_unset", a({}, t, {
|
|
profile: !0
|
|
}))) : console.warn("please check the key, must be string!!!")
|
|
}
|
|
,
|
|
e.prototype.appendProfile = function(e) {
|
|
if (e) {
|
|
var t, r = {};
|
|
for (t in e)
|
|
"string" == typeof e[t] || "Array" === Object.prototype.toString.call(e[t]).slice(8, -1) ? r[t] = e[t] : console.warn("please check the value of param: " + t + ", must be string or array !!!");
|
|
Object.keys(r).length && this.report("__profile_append", a({}, r, {
|
|
profile: !0
|
|
}))
|
|
} else
|
|
console.warn("please check the params, must be object!!!")
|
|
}
|
|
,
|
|
e.prototype.pushCache = function(e) {
|
|
var t = this;
|
|
Object.keys(e).forEach(function(r) {
|
|
t.cache[r] = {
|
|
val: t.clone(e[r]),
|
|
timestamp: Date.now()
|
|
}
|
|
})
|
|
}
|
|
,
|
|
e.prototype.formatParams = function(e, t) {
|
|
var r = this;
|
|
void 0 === t && (t = !1);
|
|
try {
|
|
if (e && "[object Object]" === Object.prototype.toString.call(e)) {
|
|
var n, i = {};
|
|
for (n in e)
|
|
"string" == typeof e[n] || "number" == typeof e[n] || "Array" === Object.prototype.toString.call(e[n]).slice(8, -1) ? i[n] = e[n] : console.warn("please check the value of params:" + n + ", must be string,number,Array !!!");
|
|
var o, s = Object.keys(i);
|
|
if (s.length && this.eventCheck.checkEventParams(i))
|
|
return o = Date.now(),
|
|
s.filter(function(n) {
|
|
var i = r.cache[n];
|
|
return t ? !i : !(i && r.compare(i.val, e[n]) && o - i.timestamp < r.duration)
|
|
}).reduce(function(e, t) {
|
|
return e[t] = i[t],
|
|
e
|
|
}, {})
|
|
} else
|
|
console.warn("please check the params type, must be object !!!")
|
|
} catch (e) {
|
|
this.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: e.message
|
|
}),
|
|
console.log("error")
|
|
}
|
|
}
|
|
,
|
|
e.prototype.compare = function(e, t) {
|
|
try {
|
|
return JSON.stringify(e) === JSON.stringify(t)
|
|
} catch (e) {
|
|
return this.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: e.message
|
|
}),
|
|
!1
|
|
}
|
|
}
|
|
,
|
|
e.prototype.clone = function(e) {
|
|
try {
|
|
return JSON.parse(JSON.stringify(e))
|
|
} catch (t) {
|
|
return this.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: t.message
|
|
}),
|
|
e
|
|
}
|
|
}
|
|
,
|
|
e.prototype.unReady = function() {
|
|
console.warn("sdk is not ready, please use this api after start")
|
|
}
|
|
,
|
|
e
|
|
}(), X = function() {
|
|
function e() {
|
|
var e = this;
|
|
this.setInterval = function() {
|
|
var t, r, n, i;
|
|
e.clearIntervalFunc = (t = function() {
|
|
e.isSessionhasEvent && e.endCurrentSession()
|
|
}
|
|
,
|
|
r = e.sessionInterval,
|
|
void 0 === t && (t = function() {}
|
|
),
|
|
void 0 === r && (r = 1e3),
|
|
n = Date.now() + r,
|
|
i = window.setTimeout(function e() {
|
|
var o = Date.now() - n;
|
|
t(),
|
|
n += r,
|
|
i = window.setTimeout(e, Math.max(0, r - o))
|
|
}, r),
|
|
function() {
|
|
window.clearTimeout(i)
|
|
}
|
|
)
|
|
}
|
|
,
|
|
this.clearInterval = function() {
|
|
e.clearIntervalFunc && e.clearIntervalFunc()
|
|
}
|
|
}
|
|
return e.prototype.apply = function(e, t) {
|
|
var r = this;
|
|
this.collect = e,
|
|
t.disable_heartbeat || (this.sessionInterval = 6e4,
|
|
this.startTime = 0,
|
|
this.lastTime = 0,
|
|
this.setInterval(),
|
|
e = this.collect.Types,
|
|
this.collect.on(e.SessionResetTime, function() {
|
|
r.process()
|
|
}))
|
|
}
|
|
,
|
|
e.prototype.endCurrentSession = function() {
|
|
this.collect.event("_be_active", {
|
|
start_time: this.startTime,
|
|
end_time: this.lastTime,
|
|
url: window.location.href,
|
|
referrer: window.document.referrer,
|
|
title: document.title || location.pathname
|
|
}),
|
|
this.isSessionhasEvent = !1,
|
|
this.startTime = 0
|
|
}
|
|
,
|
|
e.prototype.process = function() {
|
|
this.isSessionhasEvent || (this.isSessionhasEvent = !0,
|
|
this.startTime = +new Date);
|
|
var e = this.lastTime || +new Date;
|
|
this.lastTime = +new Date,
|
|
this.lastTime - e > this.sessionInterval && (this.clearInterval(),
|
|
this.endCurrentSession(),
|
|
this.setInterval())
|
|
}
|
|
,
|
|
e
|
|
}(), $ = function() {
|
|
function e() {}
|
|
return e.prototype.apply = function(e, t) {
|
|
var r = this;
|
|
t.channel_domain || t.disable_track_event || t.disable_sdk_monitor || (this.collect = e,
|
|
this.config = t,
|
|
this.url = e.configManager.getUrl("event"),
|
|
this.collect.on(e.Types.Ready, function() {
|
|
r.sdkOnload()
|
|
}),
|
|
this.collect.on(e.Types.SubmitError, function(e) {
|
|
var t = e.type
|
|
, n = e.eventData
|
|
, e = e.errorCode;
|
|
"f_data" === t && r.sdkError(n, e)
|
|
}))
|
|
}
|
|
,
|
|
e.prototype.sdkOnload = function() {
|
|
var e = this;
|
|
try {
|
|
var t = this.collect.configManager.get()
|
|
, r = t.header
|
|
, n = t.user
|
|
, i = r.app_id
|
|
, o = r.app_name
|
|
, s = r.sdk_version
|
|
, a = n.web_id
|
|
, c = {
|
|
events: [{
|
|
event: "onload",
|
|
params: JSON.stringify({
|
|
app_id: i,
|
|
app_name: o || "",
|
|
sdk_version: s,
|
|
sdk_type: "npm",
|
|
sdk_config: this.config,
|
|
sdk_desc: "TOC",
|
|
url: location.href
|
|
}),
|
|
local_time_ms: Date.now()
|
|
}],
|
|
user: {
|
|
user_unique_id: a
|
|
},
|
|
header: {}
|
|
};
|
|
setTimeout(function() {
|
|
e.collect.requestManager.useRequest({
|
|
url: e.url,
|
|
data: [c],
|
|
timeout: 3e4,
|
|
app_key: "566f58151b0ed37e",
|
|
forceXhr: !0
|
|
})
|
|
}, 16)
|
|
} catch (e) {}
|
|
}
|
|
,
|
|
e.prototype.sdkError = function(e, t) {
|
|
var r = this;
|
|
try {
|
|
var n = e[0]
|
|
, i = n.user
|
|
, o = n.header
|
|
, s = []
|
|
, a = (e.forEach(function(e) {
|
|
e.events.forEach(function(e) {
|
|
s.push(e)
|
|
})
|
|
}),
|
|
{
|
|
events: s.map(function(e) {
|
|
return {
|
|
event: "on_error",
|
|
params: JSON.stringify({
|
|
error_code: t,
|
|
app_id: o.app_id,
|
|
app_name: o.app_name || "",
|
|
error_event: e.event,
|
|
sdk_version: o.sdk_version,
|
|
local_time_ms: e.local_time_ms,
|
|
tea_event_index: Date.now(),
|
|
params: e.params,
|
|
header: JSON.stringify(o),
|
|
user: JSON.stringify(i)
|
|
}),
|
|
local_time_ms: Date.now()
|
|
}
|
|
}),
|
|
user: {
|
|
user_unique_id: i.user_unique_id
|
|
},
|
|
header: {}
|
|
});
|
|
setTimeout(function() {
|
|
r.collect.requestManager.useRequest({
|
|
url: r.url,
|
|
data: [a],
|
|
timeout: 3e4,
|
|
app_key: "566f58151b0ed37e",
|
|
forceXhr: !0
|
|
})
|
|
}, 16)
|
|
} catch (e) {}
|
|
}
|
|
,
|
|
e
|
|
}(), Z = "undefined" != typeof window ? (window.LogPluginObject || (window.LogPluginObject = {}),
|
|
window.LogPluginObject) : null, Y = function() {
|
|
function e() {}
|
|
return e.prototype.apply = function(e, t) {
|
|
this._plugin = {},
|
|
this.config = t,
|
|
this.collect = e,
|
|
this.channel = t.channel || "cn",
|
|
this.loadExtend()
|
|
}
|
|
,
|
|
e.prototype.loadExtend = function() {
|
|
var e = this;
|
|
try {
|
|
this.collect.remotePlugin.forEach(function(t, r) {
|
|
var n, i;
|
|
"sdk" === t ? V.hasOwnProperty(r) ? (n = V[r].object,
|
|
i = V[r].src[e.channel] + "?query=" + Date.now(),
|
|
e.exist(r, n, i)) : console.warn("your " + r + " is not exist\uFF0Cplease check plugin name") : "object" == typeof t && (t.src ? e.exist(r, t.call, t.src) : e.process(r, t.instance, "INSTANCE"))
|
|
})
|
|
} catch (e) {
|
|
this.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: e.message
|
|
}),
|
|
console.log("load extend error")
|
|
}
|
|
}
|
|
,
|
|
e.prototype.exist = function(e, t, r) {
|
|
var n = this;
|
|
Z[t] ? (this.process(e, Z[t]),
|
|
console.log("\u5DF2\u6709" + e + "\u63D2\u4EF6\uFF0C\u907F\u514D\u91CD\u590D\u52A0\u8F7D~")) : this.loadPlugin(e, r, function() {
|
|
n.process(e, Z[t]),
|
|
console.log(" %c %s %s %s", "color: yellow; background-color: black;", "\u2013", "load plugin:" + e + " success", "-")
|
|
}, function() {
|
|
console.log(" %c %s %s %s", "color: red; background-color: yellow;", "\u2013", "load plugin:" + e + " error", "-")
|
|
})
|
|
}
|
|
,
|
|
e.prototype.process = function(e, t, r) {
|
|
try {
|
|
var n;
|
|
r ? ((n = new t).apply && n.apply(this.collect, this.config),
|
|
console.log("excude " + e + " success")) : t && t(this.collect, this.config)
|
|
} catch (t) {
|
|
this.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: t.message
|
|
}),
|
|
console.log("excude " + e + " error, message:" + t.message)
|
|
}
|
|
}
|
|
,
|
|
e.prototype.loadPlugin = function(e, t, r, n) {
|
|
var i = this;
|
|
try {
|
|
var o = document.createElement("script");
|
|
o.src = t,
|
|
this._plugin[e] || (this._plugin[e] = []),
|
|
this._plugin[e].push(r),
|
|
o.onerror = function() {
|
|
n(t)
|
|
}
|
|
,
|
|
o.onload = function() {
|
|
i._plugin[e].forEach(function(e) {
|
|
e()
|
|
})
|
|
}
|
|
,
|
|
document.getElementsByTagName("head")[0].appendChild(o)
|
|
} catch (e) {
|
|
this.collect.emit(S.DEBUGGER_MESSAGE, {
|
|
type: S.DEBUGGER_MESSAGE_SDK,
|
|
info: "\u53D1\u751F\u4E86\u5F02\u5E38",
|
|
level: "error",
|
|
time: Date.now(),
|
|
data: e.message
|
|
})
|
|
}
|
|
}
|
|
,
|
|
e
|
|
}(), Y = (J.usePlugin(Y, "extend"),
|
|
J.usePlugin(t, "et"),
|
|
J.usePlugin(Q, "profile"),
|
|
J.usePlugin(X, "heartbeat"),
|
|
J.usePlugin($, "monitor"),
|
|
new J("default")), ee = Y, et = {
|
|
selectRoute: 900,
|
|
browserError: 1e3,
|
|
crc32: 1e3,
|
|
preUpload: 1001,
|
|
initUploadID: 1002,
|
|
process: 1003,
|
|
fileMerge: 1004,
|
|
complete: 1005
|
|
}, er = "video", en = "image", ei = "object", eo = {
|
|
video: "video_upload",
|
|
image: "image_upload",
|
|
object: "object_upload"
|
|
}, es = "imagex";
|
|
function ea(e) {
|
|
return (ea = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
|
|
return typeof e
|
|
}
|
|
: function(e) {
|
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
}
|
|
)(e)
|
|
}
|
|
function ec() {
|
|
return (ec = Object.assign ? Object.assign.bind() : function(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r, n = arguments[t];
|
|
for (r in n)
|
|
Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r])
|
|
}
|
|
return e
|
|
}
|
|
).apply(this, arguments)
|
|
}
|
|
function eu(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var n, i = t[r];
|
|
i.enumerable = i.enumerable || !1,
|
|
i.configurable = !0,
|
|
"value"in i && (i.writable = !0),
|
|
Object.defineProperty(e, (n = function(e, t) {
|
|
if ("object" !== ea(e) || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 === r)
|
|
return ("string" === t ? String : Number)(e);
|
|
if (r = r.call(e, t || "default"),
|
|
"object" !== ea(r))
|
|
return r;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}(n = i.key, "string"),
|
|
"symbol" === ea(n) ? n : String(n)), i)
|
|
}
|
|
}
|
|
var el = function() {
|
|
var e, t, r;
|
|
function n(e, t) {
|
|
switch (!function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, n),
|
|
this.options = e,
|
|
this.context = t,
|
|
this.teaLog = ee,
|
|
this.tea_app_id = 2562,
|
|
this.tea_channel = "cn",
|
|
this.options.region) {
|
|
case "us-east-1":
|
|
case "us-east-red":
|
|
case "gcp":
|
|
case "US-TTP":
|
|
this.tea_app_id = 2643,
|
|
this.tea_channel = "va";
|
|
break;
|
|
case "boei18n":
|
|
case "ap-singapore-1":
|
|
this.tea_app_id = 2643,
|
|
this.tea_channel = "sg";
|
|
break;
|
|
default:
|
|
this.tea_app_id = 2562,
|
|
this.tea_channel = "cn"
|
|
}
|
|
this.teaLog.init({
|
|
app_id: this.tea_app_id,
|
|
channel: this.tea_channel,
|
|
log: !1,
|
|
disable_sdk_monitor: !0,
|
|
disable_auto_pv: !0
|
|
}),
|
|
this.teaLog.config({
|
|
evtParams: {
|
|
sdk_version: "2.0.9",
|
|
line_app_id: this.options.appId
|
|
},
|
|
user_unique_id: this.options.userId
|
|
}),
|
|
this.teaLog.start()
|
|
}
|
|
return e = n,
|
|
t = [{
|
|
key: "send",
|
|
value: function(e) {
|
|
var t = this.context
|
|
, r = e.key
|
|
, t = t.tasks[r]
|
|
, n = et[e.stage] || 999
|
|
, t = e.fileType || t && t.fileType
|
|
, i = e.fileSize || 0
|
|
, r = {
|
|
log_type: eo[t],
|
|
stage: n,
|
|
fk: r,
|
|
fs: i,
|
|
req: e.req,
|
|
res: e.res,
|
|
ts: Math.round(Date.now() / 1e3),
|
|
sst: e.stageStartTime,
|
|
set: e.stageEndTime,
|
|
dur: e.duration,
|
|
tdur: e.totalDuration,
|
|
durs: e.duration / 1e3,
|
|
tdurs: e.totalDuration / 1e3,
|
|
eslr: e.enableSelectRoute,
|
|
ucsrr: e.useClientSelectRouteResult,
|
|
skipCommit: !!e.skipCommit
|
|
}
|
|
, i = e.type
|
|
, o = "error" === i || "retry" === i ? i : n
|
|
, t = "".concat("image" === t ? "image" : "video", "_").concat(o);
|
|
"success" === i ? this.sendSuccessLog(t, e, r, n) : this.teaLog.event(t, ec({}, r, {
|
|
type: e.type,
|
|
oid: e.oid,
|
|
upload_host: e.tosDomain,
|
|
errc: e.extra && e.extra.errorCode,
|
|
ex: JSON.stringify({
|
|
errc: e.extra && e.extra.errorCode,
|
|
msg: e.extra && e.extra.message
|
|
})
|
|
}))
|
|
}
|
|
}, {
|
|
key: "sendSuccessLog",
|
|
value: function(e, t, r, n) {
|
|
switch (r.type = t.type,
|
|
n) {
|
|
case et.selectRoute:
|
|
this.teaLog.event(e, ec({}, r, {
|
|
race_info: t.raceInfo,
|
|
client_ip: t.lastClientIp,
|
|
uc: t.useCache,
|
|
ex: JSON.stringify({
|
|
msg: t.extra && t.extra.message
|
|
})
|
|
}));
|
|
break;
|
|
case et.crc32:
|
|
this.teaLog.event(e, ec({}, r, {
|
|
ex: JSON.stringify({
|
|
msg: t.extra && t.extra.message,
|
|
crc32Array: t.crc32Array,
|
|
isDirect: t.isDirect
|
|
})
|
|
}));
|
|
break;
|
|
case et.preUpload:
|
|
this.teaLog.event(e, ec({}, r, {
|
|
oid: t.oid,
|
|
upload_host: t.tosDomain,
|
|
ex: JSON.stringify({
|
|
msg: t.extra && t.extra.message,
|
|
sig: t.signature,
|
|
stk: t.proxyStsToken
|
|
})
|
|
}));
|
|
break;
|
|
case et.initUploadID:
|
|
this.teaLog.event(e, ec({}, r, {
|
|
oid: t.oid,
|
|
upload_host: t.tosDomain,
|
|
ex: JSON.stringify({
|
|
msg: t.extra && t.extra.message,
|
|
upid: t.UploadID
|
|
})
|
|
}));
|
|
break;
|
|
case et.process:
|
|
t.isAllFinish || t.isDirect || (delete r.sst,
|
|
delete r.set,
|
|
delete r.dur),
|
|
this.teaLog.event(e, ec({}, r, {
|
|
oid: t.oid,
|
|
upload_host: t.tosDomain,
|
|
af: t.isAllFinish,
|
|
cst: t.crc32StartTime,
|
|
cet: t.crc32EndTime,
|
|
cdur: t.crc32Duration,
|
|
slst: t.sliceStartTime,
|
|
slet: t.sliceEndTime,
|
|
sldurs: t.sliceDuration && t.sliceDuration / 1e3,
|
|
ex: JSON.stringify({
|
|
msg: t.extra && t.extra.message,
|
|
si: t.sliceIndex,
|
|
af: t.isAllFinish
|
|
})
|
|
}));
|
|
break;
|
|
case et.fileMerge:
|
|
this.teaLog.event(e, ec({}, r, {
|
|
oid: t.oid,
|
|
upload_host: t.tosDomain,
|
|
ex: JSON.stringify({
|
|
msg: t.extra && t.extra.message
|
|
})
|
|
}));
|
|
break;
|
|
case et.complete:
|
|
this.teaLog.event(e, ec({}, r, {
|
|
oid: t.oid,
|
|
upload_host: t.tosDomain,
|
|
speed: Math.round(t.fileSize / (t.totalDuration / 1e3) / 1024),
|
|
ex: JSON.stringify({
|
|
msg: t.extra && t.extra.message,
|
|
vid: t.uploadResult && t.uploadResult.Vid
|
|
})
|
|
}))
|
|
}
|
|
}
|
|
}, {
|
|
key: "console",
|
|
value: function(e) {
|
|
function t(t) {
|
|
return e.apply(this, arguments)
|
|
}
|
|
return t.toString = function() {
|
|
return e.toString()
|
|
}
|
|
,
|
|
t
|
|
}(function(e) {
|
|
this.options.debug && console.log(e)
|
|
})
|
|
}],
|
|
eu(e.prototype, t),
|
|
Object.defineProperty(e, "prototype", {
|
|
writable: !1
|
|
}),
|
|
n
|
|
}()
|
|
, t = r(6)
|
|
, ef = r.n(t)
|
|
, Q = r(4)
|
|
, ep = r.n(Q)
|
|
, eh = {
|
|
urlTemplate: function(e, t) {
|
|
var r;
|
|
return Object.keys(t = t || {}).forEach(function(n) {
|
|
r = RegExp("{".concat(n, "}"), "g"),
|
|
e = e.replace(r, t[n])
|
|
}),
|
|
e
|
|
},
|
|
toQueryString: function() {
|
|
var e = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {};
|
|
return Object.keys(e).map(function(t) {
|
|
return "".concat(t, "=").concat(encodeURIComponent(e[t]))
|
|
}).join("&")
|
|
},
|
|
supportChunked: function() {
|
|
var e = window.Blob || window.WebKitBlob;
|
|
try {
|
|
var t = e.prototype;
|
|
return !(!FormData || !(t.slice || t.webkitSlice || t.mozSlice))
|
|
} catch (e) {
|
|
return !1
|
|
}
|
|
},
|
|
supportXhr: function() {
|
|
return !!window.FormData || window.ProgressEvent && window.FileReader
|
|
},
|
|
supportCrc32: function() {
|
|
var e = window.FileReader && window.FileReader.prototype.readAsBinaryString;
|
|
return "undefined" != typeof Int32Array && e && (Blob.prototype.slice || Blob.prototype.webkitSlice || Blob.prototype.mozSlice)
|
|
},
|
|
storage: function(e) {
|
|
var t = e
|
|
, e = {
|
|
removeItem: function(e) {
|
|
delete t.cache[e]
|
|
},
|
|
setItem: function(e, r) {
|
|
t.cache[e] = r
|
|
},
|
|
getItem: function(e) {
|
|
return t.cache[e]
|
|
},
|
|
clear: function() {
|
|
delete t.cache,
|
|
t.cache = {}
|
|
}
|
|
};
|
|
if (!(1 < arguments.length && void 0 !== arguments[1]) || arguments[1])
|
|
try {
|
|
if (window.localStorage)
|
|
return window.localStorage.setItem("", ""),
|
|
window.localStorage
|
|
} catch (e) {}
|
|
return e
|
|
},
|
|
noop: function() {},
|
|
getUnique: function(e) {
|
|
return "".concat(e, "_").concat((new Date).getTime(), "_").concat(parseInt(1e6 * Math.random()))
|
|
},
|
|
getFileSliceLength: function(e, t) {
|
|
var r = e.size;
|
|
return t && "function" == typeof t ? 2097152 > t(r) ? 2097152 : t(r) || r : 0xc800000 < r ? 0xa00000 : r <= 0xc800000 && 2097152 <= r ? 5242880 : e.size
|
|
},
|
|
getFileSuffix: function(e) {
|
|
if (e && "[object String]" === Object.prototype.toString.call(e)) {
|
|
var t = e.lastIndexOf(".");
|
|
return 0 < t && (e = ".".concat(e.substring(t + 1))).length <= 8 ? e : ""
|
|
}
|
|
},
|
|
fileSlice: function(e, t, r) {
|
|
return (e.slice || e.webkitSlice || e.mozSlice).call(e, t, r)
|
|
},
|
|
getPathByURL: function(e) {
|
|
return /^(?:(https?:)\/\/)?(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/.exec(e)[5] || "/"
|
|
},
|
|
crypto: {
|
|
hmac: function(e, t) {
|
|
return ef()(t, e)
|
|
},
|
|
sha256: function(e) {
|
|
return ep()(e)
|
|
}
|
|
},
|
|
date: {
|
|
iso8601: function(e) {
|
|
return (e = void 0 === e ? eh.date.getDate() : e).toISOString().replace(/\.\d{3}Z$/, "Z")
|
|
}
|
|
},
|
|
Buffer: Uint8Array,
|
|
generateKey: function(e) {
|
|
for (var t = "", r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", n = r.length, i = 0; i < e; i++)
|
|
t += r.charAt(Math.floor(Math.random() * n));
|
|
return t
|
|
}
|
|
};
|
|
function ed(e) {
|
|
return (ed = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
|
|
return typeof e
|
|
}
|
|
: function(e) {
|
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
}
|
|
)(e)
|
|
}
|
|
function eg(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var n, i = t[r];
|
|
i.enumerable = i.enumerable || !1,
|
|
i.configurable = !0,
|
|
"value"in i && (i.writable = !0),
|
|
Object.defineProperty(e, (n = function(e, t) {
|
|
if ("object" !== ed(e) || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 === r)
|
|
return ("string" === t ? String : Number)(e);
|
|
if (r = r.call(e, t || "default"),
|
|
"object" !== ed(r))
|
|
return r;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}(n = i.key, "string"),
|
|
"symbol" === ed(n) ? n : String(n)), i)
|
|
}
|
|
}
|
|
function ey(e, t) {
|
|
return (ey = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
|
|
return e.__proto__ = t,
|
|
e
|
|
}
|
|
)(e, t)
|
|
}
|
|
function em(e) {
|
|
return (em = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
|
|
return e.__proto__ || Object.getPrototypeOf(e)
|
|
}
|
|
)(e)
|
|
}
|
|
var ev = function() {
|
|
!function(e, t) {
|
|
if ("function" != typeof t && null !== t)
|
|
throw TypeError("Super expression must either be null or a function");
|
|
e.prototype = Object.create(t && t.prototype, {
|
|
constructor: {
|
|
value: e,
|
|
writable: !0,
|
|
configurable: !0
|
|
}
|
|
}),
|
|
Object.defineProperty(e, "prototype", {
|
|
writable: !1
|
|
}),
|
|
t && ey(e, t)
|
|
}(a, n.a);
|
|
var e, t, r, i, o, s = (e = a,
|
|
t = function() {
|
|
if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham)
|
|
return !1;
|
|
if ("function" == typeof Proxy)
|
|
return !0;
|
|
try {
|
|
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
|
!0
|
|
} catch (e) {
|
|
return !1
|
|
}
|
|
}(),
|
|
function() {
|
|
var r = em(e);
|
|
return function(e, t) {
|
|
if (t && ("object" === ed(t) || "function" == typeof t))
|
|
return t;
|
|
if (void 0 !== t)
|
|
throw TypeError("Derived constructors may only return object or undefined");
|
|
return function(e) {
|
|
if (void 0 !== e)
|
|
return e;
|
|
throw ReferenceError("this hasn't been initialised - super() hasn't been called")
|
|
}(e)
|
|
}(this, t ? Reflect.construct(r, arguments, em(this).constructor) : r.apply(this, arguments))
|
|
}
|
|
);
|
|
function a() {
|
|
var e;
|
|
return function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, a),
|
|
(e = s.call(this)).xhr = new XMLHttpRequest,
|
|
e._data = null,
|
|
e
|
|
}
|
|
return r = a,
|
|
i = [{
|
|
key: "_ajax",
|
|
value: function(e) {
|
|
var t = this
|
|
, r = this.xhr;
|
|
r.upload.onprogress = function(e) {
|
|
t.emit("progress", e)
|
|
}
|
|
,
|
|
r.onreadystatechange = function() {
|
|
4 === r.readyState && (r.upload.onprogress = eh.noop,
|
|
r.onreadystatechange = eh.noop,
|
|
r.params = e,
|
|
t._data && t._data.url && (r.currentUrl = t._data.url),
|
|
r.status >= 200 && r.status < 300 || 304 === r.status ? t.emit("complete", r) : r.status >= 400 && t.emit("error", r))
|
|
}
|
|
,
|
|
r.onerror = function() {
|
|
r.errText = "unknow net error",
|
|
t.emit("error", r)
|
|
}
|
|
,
|
|
r.ontimeout = function() {
|
|
r.errText = "timeout",
|
|
t.emit("error", r)
|
|
}
|
|
,
|
|
r.onabort = function() {
|
|
r.errText = "abort",
|
|
t.emit("error", r)
|
|
}
|
|
,
|
|
r.send(e)
|
|
}
|
|
}, {
|
|
key: "send",
|
|
value: function(e) {
|
|
var t = this;
|
|
return this._data = e,
|
|
this.xhr.open(e.method || "POST", e.url || "", !0),
|
|
e.headers && Object.keys(e.headers).forEach(function(r) {
|
|
t.xhr.setRequestHeader(r, e.headers[r])
|
|
}),
|
|
this.xhr.timeout = e.timeout || 0,
|
|
e.ontimeout && (this.xhr.ontimeout = e.ontimeout),
|
|
e.binary ? this.sendAsBinary(e) : e.custom ? "object" === ed(e.custom) ? this.sendAsCustom(JSON.stringify(e.custom)) : "none" === e.custom ? (delete e.custom,
|
|
this.sendAsCustom()) : this.sendAsCustom(e.custom) : this.sendAsFormData(e)
|
|
}
|
|
}, {
|
|
key: "sendAsBinary",
|
|
value: function(e) {
|
|
return this.xhr.setRequestHeader("Content-Type", "application/octet-stream"),
|
|
this.xhr.setRequestHeader("Content-Disposition", 'attachment; filename="'.concat(encodeURI(e.filename), '"')),
|
|
this._ajax(e.file)
|
|
}
|
|
}, {
|
|
key: "sendAsFormData",
|
|
value: function(e) {
|
|
t = (t = e.formData ? "function" == typeof e.formData ? e.formData() : e.formData : t) || [];
|
|
for (var t, r = new FormData, n = 0, i = t.length; n < i; n++) {
|
|
var o = r[n];
|
|
r.append(o.name, o.value)
|
|
}
|
|
return e.file && r.append(e.field, e.file, e.name),
|
|
this._ajax(r)
|
|
}
|
|
}, {
|
|
key: "sendAsCustom",
|
|
value: function(e) {
|
|
return this._ajax(e)
|
|
}
|
|
}, {
|
|
key: "abort",
|
|
value: function() {
|
|
this.xhr.onreadystatechange = eh.noop,
|
|
this.xhr.abort()
|
|
}
|
|
}, {
|
|
key: "getResponse",
|
|
value: function() {
|
|
return this.xhr.response
|
|
}
|
|
}, {
|
|
key: "getText",
|
|
value: function() {
|
|
return this.xhr.responseText
|
|
}
|
|
}, {
|
|
key: "getJson",
|
|
value: function() {
|
|
return JSON.parse(this.xhr.responseText)
|
|
}
|
|
}],
|
|
eg(r.prototype, i),
|
|
Object.defineProperty(r, "prototype", {
|
|
writable: !1
|
|
}),
|
|
a
|
|
}()
|
|
, X = r(1)
|
|
, eb = r.n(X);
|
|
function e_(e) {
|
|
return (e_ = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
|
|
return typeof e
|
|
}
|
|
: function(e) {
|
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
}
|
|
)(e)
|
|
}
|
|
function eS(e, t) {
|
|
var r, n = Object.keys(e);
|
|
return Object.getOwnPropertySymbols && (r = Object.getOwnPropertySymbols(e),
|
|
t && (r = r.filter(function(t) {
|
|
return Object.getOwnPropertyDescriptor(e, t).enumerable
|
|
})),
|
|
n.push.apply(n, r)),
|
|
n
|
|
}
|
|
function ex(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r = null != arguments[t] ? arguments[t] : {};
|
|
t % 2 ? eS(Object(r), !0).forEach(function(t) {
|
|
var n, i, o;
|
|
n = e,
|
|
i = t,
|
|
o = r[t],
|
|
(i = eE(i))in n ? Object.defineProperty(n, i, {
|
|
value: o,
|
|
enumerable: !0,
|
|
configurable: !0,
|
|
writable: !0
|
|
}) : n[i] = o
|
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : eS(Object(r)).forEach(function(t) {
|
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t))
|
|
})
|
|
}
|
|
return e
|
|
}
|
|
function ew() {
|
|
return (ew = Object.assign ? Object.assign.bind() : function(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r, n = arguments[t];
|
|
for (r in n)
|
|
Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r])
|
|
}
|
|
return e
|
|
}
|
|
).apply(this, arguments)
|
|
}
|
|
function ek(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var n = t[r];
|
|
n.enumerable = n.enumerable || !1,
|
|
n.configurable = !0,
|
|
"value"in n && (n.writable = !0),
|
|
Object.defineProperty(e, eE(n.key), n)
|
|
}
|
|
}
|
|
function eE(e) {
|
|
return e = function(e, t) {
|
|
if ("object" !== e_(e) || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 === r)
|
|
return ("string" === t ? String : Number)(e);
|
|
if (r = r.call(e, t || "default"),
|
|
"object" !== e_(r))
|
|
return r;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}(e, "string"),
|
|
"symbol" === e_(e) ? e : String(e)
|
|
}
|
|
function eO(e, t) {
|
|
return (eO = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
|
|
return e.__proto__ = t,
|
|
e
|
|
}
|
|
)(e, t)
|
|
}
|
|
function eT(e) {
|
|
return (eT = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
|
|
return e.__proto__ || Object.getPrototypeOf(e)
|
|
}
|
|
)(e)
|
|
}
|
|
var eC = function() {
|
|
!function(e, t) {
|
|
if ("function" != typeof t && null !== t)
|
|
throw TypeError("Super expression must either be null or a function");
|
|
e.prototype = Object.create(t && t.prototype, {
|
|
constructor: {
|
|
value: e,
|
|
writable: !0,
|
|
configurable: !0
|
|
}
|
|
}),
|
|
Object.defineProperty(e, "prototype", {
|
|
writable: !1
|
|
}),
|
|
t && eO(e, t)
|
|
}(c, n.a);
|
|
var e, t, r, i, s, a = (e = c,
|
|
t = function() {
|
|
if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham)
|
|
return !1;
|
|
if ("function" == typeof Proxy)
|
|
return !0;
|
|
try {
|
|
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
|
!0
|
|
} catch (e) {
|
|
return !1
|
|
}
|
|
}(),
|
|
function() {
|
|
var r = eT(e);
|
|
return function(e, t) {
|
|
if (t && ("object" === e_(t) || "function" == typeof t))
|
|
return t;
|
|
if (void 0 !== t)
|
|
throw TypeError("Derived constructors may only return object or undefined");
|
|
return function(e) {
|
|
if (void 0 !== e)
|
|
return e;
|
|
throw ReferenceError("this hasn't been initialised - super() hasn't been called")
|
|
}(e)
|
|
}(this, t ? Reflect.construct(r, arguments, eT(this).constructor) : r.apply(this, arguments))
|
|
}
|
|
);
|
|
function c(e, t) {
|
|
var r;
|
|
return function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, c),
|
|
(r = a.call(this)).options = e,
|
|
r.config = t,
|
|
r.uploaderCtx = e.context,
|
|
r.file = e.file,
|
|
r.cacheKey = "__bd_uploader_cache",
|
|
r
|
|
}
|
|
return r = c,
|
|
i = [{
|
|
key: "start",
|
|
value: function(e, t) {
|
|
this._st = Date.now(),
|
|
this.uploaderCtx._broadcast("startSelectRoute", null, !0),
|
|
this.clientIp = e.clientIp,
|
|
this.selectRouteTimeout = e.selectRouteTimeout || 5e3,
|
|
this.selectRouteCacheTime = e.selectRouteCacheTime || 36e5,
|
|
this.selectRouteFileSize = e.selectRouteFileSize || 0x80000000,
|
|
this.completeCallback = t,
|
|
(e = this.checkSelect({
|
|
clientIp: this.clientIp
|
|
})) ? this.success(e, null, !0) : this.startSelectRoute()
|
|
}
|
|
}, {
|
|
key: "checkSelect",
|
|
value: function(e) {
|
|
var e = e.clientIp
|
|
, t = null;
|
|
try {
|
|
t = JSON.parse(this.uploaderCtx.storage.getItem(this.cacheKey))
|
|
} catch (e) {
|
|
return null
|
|
}
|
|
if (t) {
|
|
var r = t.lastClientIp
|
|
, n = t.lastSelectRouteTime;
|
|
if (e && e !== r)
|
|
return null;
|
|
if ((new Date).getTime() - n < this.selectRouteCacheTime)
|
|
return t
|
|
}
|
|
return null
|
|
}
|
|
}, {
|
|
key: "startSelectRoute",
|
|
value: function() {
|
|
var e = this
|
|
, t = this.config.region
|
|
, r = new ev
|
|
, n = (r.on("complete", function(t) {
|
|
if (t.response)
|
|
try {
|
|
var r, n = JSON.parse(t.response);
|
|
n.ResponseMetadata.Error ? e.fail({
|
|
xhr: t,
|
|
errorCode: n.ResponseMetadata.Error.CodeN,
|
|
error: n.ResponseMetadata.Error.Code,
|
|
message: n.ResponseMetadata.Error.Message
|
|
}) : (r = n.Result.Domains,
|
|
e.race(r, t))
|
|
} catch (r) {
|
|
e.fail({
|
|
error: "catch error: ".concat(r.toString()),
|
|
xhr: t
|
|
})
|
|
}
|
|
else
|
|
e.fail({
|
|
error: "request fail: ".concat(t.statusText || t.errText || "UNKNOWN"),
|
|
xhr: t
|
|
})
|
|
}),
|
|
r.on("error", function(t) {
|
|
var r = {
|
|
error: "request fail: ".concat(t.statusText || t.errText || "UNKNOWN"),
|
|
xhr: t
|
|
};
|
|
t.response && (t = JSON.parse(t.response)).ResponseMetadata && t.ResponseMetadata.Error && (r.errorCode = t.ResponseMetadata.Error.CodeN,
|
|
r.error = t.ResponseMetadata.Error.Code,
|
|
r.message = t.ResponseMetadata.Error.Message),
|
|
e.fail(r)
|
|
}),
|
|
this.config.videoHost)
|
|
, i = this.config.videoConfig && this.config.videoConfig.spaceName
|
|
, o = {
|
|
Action: "GetUploadCandidates",
|
|
Version: "2020-11-19",
|
|
SpaceName: i = this.options.type === ei && null != (o = this.config.objectConfig) && o.spaceName ? null == (o = this.config.objectConfig) ? void 0 : o.spaceName : i
|
|
}
|
|
, i = this.options.stsToken
|
|
, s = eh.toQueryString(o)
|
|
, a = i.AccessKeyID
|
|
, c = i.AccessKeyId
|
|
, u = i.SecretAccessKey
|
|
, l = i.SessionToken
|
|
, i = i.CurrentTime
|
|
, n = {
|
|
method: "GET",
|
|
url: "".concat(n, "?").concat(s),
|
|
timeout: this.config.gatewayTimeout,
|
|
region: t,
|
|
params: o
|
|
}
|
|
, s = new eb.a(n,"vod")
|
|
, t = (this.config.useServerCurrentTime && Math.abs(new Date(i) - new Date) > 6e4 && (this.systemTimeGap = new Date(i) - new Date),
|
|
this.systemTimeGap ? new Date((new Date).getTime() + this.systemTimeGap) : new Date);
|
|
s.addAuthorization({
|
|
accessKeyId: c || a,
|
|
secretAccessKey: u,
|
|
sessionToken: l
|
|
}, t),
|
|
r.send(n)
|
|
}
|
|
}, {
|
|
key: "race",
|
|
value: function(e, t) {
|
|
var r = this
|
|
, n = this.file
|
|
, i = (n.slice || n.webkitSlice || n.mozSlice).call(n, 0, Math.min(this.selectRouteFileSize, n.size))
|
|
, s = e.map(function(e) {
|
|
return {
|
|
domainName: e.Name,
|
|
domainInfo: e,
|
|
percent: 0,
|
|
startTime: (new Date).getTime(),
|
|
endTime: (new Date).getTime(),
|
|
complete: !1
|
|
}
|
|
})
|
|
, a = 0
|
|
, c = s.length;
|
|
s.forEach(function(e, n) {
|
|
var i = new ev;
|
|
i.on("complete", function() {
|
|
s[n].endTime = (new Date).getTime(),
|
|
s[n].complete = !0,
|
|
s.forEach(function(e, t) {
|
|
n !== t && e.transport && e.transport.abort()
|
|
}),
|
|
r.formatRaceInfo(s, t)
|
|
}),
|
|
i.on("error", function(e) {
|
|
s[n].endTime = (new Date).getTime(),
|
|
s[n].complete = !0,
|
|
s[n].error = e.errText,
|
|
c <= ++a && r.formatRaceInfo(s, t)
|
|
}),
|
|
i.on("progress", function(e) {
|
|
e = e.loaded / e.total,
|
|
s[n].percent = e
|
|
}),
|
|
s[n].transport = i
|
|
}),
|
|
s.forEach(function(e) {
|
|
var t = e.domainInfo
|
|
, n = {
|
|
oid: t.StoreID,
|
|
tosDomain: "".concat(r.config.schema, "://").concat(t.Name)
|
|
}
|
|
, n = "".concat(eh.urlTemplate(o, n), "?speedtest")
|
|
, t = t.Sign;
|
|
e.transport.send({
|
|
method: "post",
|
|
url: n,
|
|
headers: {
|
|
Authorization: t,
|
|
"Content-CRC32": "ignore"
|
|
},
|
|
file: i,
|
|
binary: 1,
|
|
timeout: r.selectRouteTimeout
|
|
})
|
|
})
|
|
}
|
|
}, {
|
|
key: "formatRaceInfo",
|
|
value: function(e, t) {
|
|
e.sort(function(e, t) {
|
|
return e.percent < t.percent ? 1 : e.percent > t.percent ? -1 : e.error ? 1 : t.error ? -1 : 0
|
|
}),
|
|
e.forEach(function(e) {
|
|
delete e.transport
|
|
}),
|
|
e = {
|
|
lastClientIp: this.clientIp,
|
|
lastSelectRouteTime: (new Date).getTime(),
|
|
raceInfo: e,
|
|
type: "success"
|
|
},
|
|
this.uploaderCtx.storage.setItem(this.cacheKey, JSON.stringify(e)),
|
|
this.success(e, t)
|
|
}
|
|
}, {
|
|
key: "success",
|
|
value: function(e, t) {
|
|
var r = 2 < arguments.length && void 0 !== arguments[2] && arguments[2]
|
|
, t = t && this.formatXhr(t);
|
|
this.uploaderCtx.logger.send(ew(ex(ex({
|
|
stage: "selectRoute",
|
|
stageStartTime: this._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - this._st,
|
|
fileSize: this.file && this.file.size
|
|
}, t), {}, {
|
|
useCache: r
|
|
}), e)),
|
|
this.uploaderCtx._broadcast("completeSelectRoute", ex(ex({}, e), {}, {
|
|
useCache: r
|
|
}), !0),
|
|
this.completeCallback({
|
|
selectRouteResult: e.raceInfo
|
|
})
|
|
}
|
|
}, {
|
|
key: "fail",
|
|
value: function(e) {
|
|
var t = {
|
|
error: e.error,
|
|
errorCode: e.errorCode,
|
|
message: e.message
|
|
};
|
|
this.uploaderCtx.logger.send(ew(ex({
|
|
stage: "selectRoute",
|
|
stageStartTime: this._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - this._st,
|
|
fileSize: this.file && this.file.size,
|
|
extra: t,
|
|
type: "warn"
|
|
}, this.formatXhr(e.xhr)))),
|
|
this.uploaderCtx._broadcast("completeSelectRoute", ex({
|
|
type: "warn"
|
|
}, t), !0),
|
|
this.completeCallback()
|
|
}
|
|
}, {
|
|
key: "formatXhr",
|
|
value: function(e) {
|
|
return {
|
|
req: {
|
|
url: e.currentUrl,
|
|
param: e.params
|
|
},
|
|
res: {
|
|
status: e.status,
|
|
header: e.getAllResponseHeaders(),
|
|
body: e.responseText
|
|
}
|
|
}
|
|
}
|
|
}],
|
|
ek(r.prototype, i),
|
|
Object.defineProperty(r, "prototype", {
|
|
writable: !1
|
|
}),
|
|
c
|
|
}()
|
|
, eD = {
|
|
crc32: function(e, t) {
|
|
for (var r = [0, 0x77073096, 0xee0e612c, 0x990951ba, 0x76dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0xedb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x9b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x1db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x6b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0xf00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x86d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x3b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x4db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0xd6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0xa00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x26d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x5005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0xcb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0xbdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 936918e3, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d], n = ("undefined" != typeof Int32Array && (r = new Int32Array(r)),
|
|
-1 ^ ~~t), i = (e = new Uint8Array(e)).length, o = 0; o < i; o++)
|
|
n = r[255 & (n ^ e[o])] ^ n >>> 8;
|
|
return (-1 ^ n) >>> 0
|
|
},
|
|
dec2hex: function(e) {
|
|
if (void 0 !== e)
|
|
return function e(t) {
|
|
return t.length < 8 ? e(t = "0".concat(t)) : t
|
|
}(Number(e).toString(16))
|
|
}
|
|
};
|
|
function ej(e) {
|
|
return (ej = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
|
|
return typeof e
|
|
}
|
|
: function(e) {
|
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
}
|
|
)(e)
|
|
}
|
|
function eI(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var n, i = t[r];
|
|
i.enumerable = i.enumerable || !1,
|
|
i.configurable = !0,
|
|
"value"in i && (i.writable = !0),
|
|
Object.defineProperty(e, (n = function(e, t) {
|
|
if ("object" !== ej(e) || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 === r)
|
|
return ("string" === t ? String : Number)(e);
|
|
if (r = r.call(e, t || "default"),
|
|
"object" !== ej(r))
|
|
return r;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}(n = i.key, "string"),
|
|
"symbol" === ej(n) ? n : String(n)), i)
|
|
}
|
|
}
|
|
var eP = function() {
|
|
var e, t, r;
|
|
function n(e, t, r, i) {
|
|
!function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, n),
|
|
this.file = e,
|
|
this.successProcess = r,
|
|
this.failProcess = i,
|
|
this.sliceLength = t,
|
|
this.retryTime = 0,
|
|
this.fileSize = e.size,
|
|
this.crc32Array = []
|
|
}
|
|
return e = n,
|
|
t = [{
|
|
key: "start",
|
|
value: function() {
|
|
this.readFileCrc32(this.file)
|
|
}
|
|
}, {
|
|
key: "readFileCrc32",
|
|
value: function(e) {
|
|
var t = this
|
|
, r = this.sliceLength
|
|
, n = e.slice || e.webkitSlice || e.mozSlice
|
|
, i = new FileReader
|
|
, o = 0
|
|
, s = 0
|
|
, a = 0;
|
|
(function c() {
|
|
s < e.size && (s = Math.min(o + r, e.size),
|
|
e.size > 0x6400000) && (s = e.size),
|
|
i.readAsArrayBuffer(n.call(e, o, s)),
|
|
i.onload = function(r) {
|
|
r = r.target.result,
|
|
a = eD.crc32(r, 0),
|
|
t.crc32Array.push({
|
|
start: o,
|
|
end: s,
|
|
crc32: eD.dec2hex(a),
|
|
buffer: r
|
|
}),
|
|
(o = s) < e.size ? c() : t.success(t.crc32Array)
|
|
}
|
|
}
|
|
)()
|
|
}
|
|
}, {
|
|
key: "success",
|
|
value: function(e) {
|
|
this.successProcess(e)
|
|
}
|
|
}, {
|
|
key: "fail",
|
|
value: function(e, t, r, n) {
|
|
3 <= this.retryTime ? this.failProcess() : (this.readFileCrc32(e, t, r, n),
|
|
this.retryTime++)
|
|
}
|
|
}],
|
|
eI(e.prototype, t),
|
|
Object.defineProperty(e, "prototype", {
|
|
writable: !1
|
|
}),
|
|
n
|
|
}()
|
|
, eA = "The format of stsToken is incorrect.";
|
|
function eR(e) {
|
|
return (eR = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
|
|
return typeof e
|
|
}
|
|
: function(e) {
|
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
}
|
|
)(e)
|
|
}
|
|
function ez() {
|
|
return (ez = Object.assign ? Object.assign.bind() : function(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r, n = arguments[t];
|
|
for (r in n)
|
|
Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r])
|
|
}
|
|
return e
|
|
}
|
|
).apply(this, arguments)
|
|
}
|
|
function eB(e, t) {
|
|
(null == t || t > e.length) && (t = e.length);
|
|
for (var r = 0, n = Array(t); r < t; r++)
|
|
n[r] = e[r];
|
|
return n
|
|
}
|
|
function eU(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var n, i = t[r];
|
|
i.enumerable = i.enumerable || !1,
|
|
i.configurable = !0,
|
|
"value"in i && (i.writable = !0),
|
|
Object.defineProperty(e, (n = function(e, t) {
|
|
if ("object" !== eR(e) || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 === r)
|
|
return ("string" === t ? String : Number)(e);
|
|
if (r = r.call(e, t || "default"),
|
|
"object" !== eR(r))
|
|
return r;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}(n = i.key, "string"),
|
|
"symbol" === eR(n) ? n : String(n)), i)
|
|
}
|
|
}
|
|
var eM = function() {
|
|
var e, t, r;
|
|
function n(e) {
|
|
var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {};
|
|
!function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, n),
|
|
this.context = e.context,
|
|
this.key = e.key,
|
|
this.isDirect = e.isDirect,
|
|
this.isImageBatchUpload = e.isImageBatchUpload,
|
|
this.file = e.file,
|
|
this.type = (this.isImageBatchUpload ? null == (e = this.file[0]) ? void 0 : e.type : null == (e = this.file) ? void 0 : e.type) || "",
|
|
this.sliceLength = eh.getFileSliceLength(this.file, t.getSliceFunc),
|
|
this.config = t
|
|
}
|
|
return e = n,
|
|
t = [{
|
|
key: "start",
|
|
value: function(e, t, r) {
|
|
this.successProcess = t,
|
|
this.failProcess = r,
|
|
this._st = Date.now(),
|
|
this.crc32(this.file, this.sliceLength)
|
|
}
|
|
}, {
|
|
key: "crc32",
|
|
value: function(e, t) {
|
|
var r = this;
|
|
if (this.isImageBatchUpload)
|
|
for (var n = e.length, i = [], o = function(t) {
|
|
new eP(e[t],e[t].size,function(e) {
|
|
i[t] = e[0],
|
|
i.filter(function(e) {
|
|
return !!e
|
|
}).length === n && r.success(i)
|
|
}
|
|
,function(e) {
|
|
r.fail(e)
|
|
}
|
|
).start()
|
|
}, s = 0; s < n; s++)
|
|
o(s);
|
|
else
|
|
e && e.size && !(e.size <= 0) ? this.isDirect ? new eP(e,e.size,function(e) {
|
|
r.success(e)
|
|
}
|
|
,function(e) {
|
|
r.fail({
|
|
errorCode: 1000003,
|
|
message: "get crc32 error: ".concat(e && e.message)
|
|
})
|
|
}
|
|
).start() : this.sliceFile(e, t, function(e) {
|
|
r.success(e)
|
|
}, function(e) {
|
|
r.fail(e)
|
|
}) : this.fail({
|
|
errorCode: 1000003,
|
|
message: "There is a problem with the input file or fileSize."
|
|
})
|
|
}
|
|
}, {
|
|
key: "sliceFile",
|
|
value: function(e, t, r, n) {
|
|
for (var i = [], o = e.size, s = e.slice || e.webkitSlice || e.mozSlice, a = 0, c = 0, u = 0; c < o; )
|
|
c = Math.min(a + t, o),
|
|
0x6400000 < o && o - c <= 5242880 && (c = o),
|
|
i.push({
|
|
start: a,
|
|
end: c,
|
|
crc32: 0
|
|
}),
|
|
a = c;
|
|
try {
|
|
!function t(a) {
|
|
var c = new FileReader
|
|
, l = i[a].start
|
|
, f = i[a].end;
|
|
c.readAsArrayBuffer(s.call(e, l, f)),
|
|
c.onload = function(e) {
|
|
e = e.target.result,
|
|
u = eD.dec2hex(eD.crc32(e, 0)),
|
|
i[a].crc32 = u,
|
|
f === o ? r(i) : t(i.length - 1)
|
|
}
|
|
,
|
|
c.onerror = function(e) {
|
|
var t = e.target.error.name
|
|
, e = e.target.error.message;
|
|
n({
|
|
crc32Array: i,
|
|
errorCode: 1000003,
|
|
message: "".concat(t, ": ").concat(e)
|
|
})
|
|
}
|
|
}(0)
|
|
} catch (e) {
|
|
n({
|
|
message: e && e.toString()
|
|
})
|
|
}
|
|
}
|
|
}, {
|
|
key: "getCrc32Key",
|
|
value: function(e, t) {
|
|
var r;
|
|
return (t = "[object Array]" === Object.prototype.toString.call(t) ? function(e) {
|
|
if (Array.isArray(e))
|
|
return eB(e)
|
|
}(r = t) || function(e) {
|
|
if ("undefined" != typeof Symbol && null != e[Symbol.iterator] || null != e["@@iterator"])
|
|
return Array.from(e)
|
|
}(r) || function(e, t) {
|
|
var r;
|
|
if (e)
|
|
return "string" == typeof e ? eB(e, void 0) : "Map" === (r = "Object" === (r = Object.prototype.toString.call(e).slice(8, -1)) && e.constructor ? e.constructor.name : r) || "Set" === r ? Array.from(e) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? eB(e, t) : void 0
|
|
}(r) || function() {
|
|
throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
|
|
}() : [t]).push(e[0].crc32, e[e.length - 1].crc32),
|
|
this.config.instanceId && t.push(this.config.instanceId),
|
|
t.join("_")
|
|
}
|
|
}, {
|
|
key: "success",
|
|
value: function(e) {
|
|
var t = this.context
|
|
, r = this.key
|
|
, n = []
|
|
, i = [];
|
|
if (this.isImageBatchUpload)
|
|
for (var o = 0; o < this.file.length; o++)
|
|
n.push(this.file[o].size),
|
|
i.push(this.file[o].name);
|
|
else
|
|
n = this.file.size,
|
|
i = this.file.name;
|
|
var s = this.getCrc32Key(e, n)
|
|
, t = t.tasks[r];
|
|
t && this.successProcess(ez(t, {
|
|
key: r,
|
|
crc32Array: e,
|
|
crc32Key: s,
|
|
sdkVersion: "2.0.9",
|
|
sliceLength: this.sliceLength,
|
|
extra: {
|
|
message: "get crc32 success"
|
|
},
|
|
stage: "crc32",
|
|
type: "success",
|
|
fileSize: n,
|
|
fileName: i,
|
|
stageStartTime: this._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - this._st,
|
|
totalDuration: Date.now() - this._st,
|
|
isDirect: this.isDirect,
|
|
isImageBatchUpload: this.isImageBatchUpload
|
|
}))
|
|
}
|
|
}, {
|
|
key: "fail",
|
|
value: function(e) {
|
|
var t = this.context
|
|
, r = this.key
|
|
, n = e && e.message ? e.message : "get crc32 error"
|
|
, i = e && e.errorCode
|
|
, e = e && e.crc32Array
|
|
, t = ez(t.tasks[r], {
|
|
crc32Array: e,
|
|
extra: {
|
|
message: n,
|
|
errorCode: i
|
|
},
|
|
type: "error",
|
|
stage: "crc32",
|
|
stageStartTime: this._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - this._st,
|
|
totalDuration: Date.now() - this._st
|
|
});
|
|
this.failProcess(t)
|
|
}
|
|
}],
|
|
eU(e.prototype, t),
|
|
Object.defineProperty(e, "prototype", {
|
|
writable: !1
|
|
}),
|
|
n
|
|
}()
|
|
, eG = {
|
|
checkStsToken: function(e) {
|
|
return !e || e.SessionToken && e.SecretAccessKey && (e.AccessKeyId || e.AccessKeyID)
|
|
},
|
|
checkServiceName: function(e, t, r) {
|
|
if ("vod" === r || r === es)
|
|
return r;
|
|
if (e !== er) {
|
|
if (e === en)
|
|
return es;
|
|
if (e === ei) {
|
|
if (t.objectConfig && t.objectConfig.spaceName)
|
|
return "vod";
|
|
if (t.objectConfig && t.objectConfig.serviceId)
|
|
return es;
|
|
if (t.videoConfig && t.videoConfig.spaceName)
|
|
return "vod";
|
|
if (t.imageConfig && t.imageConfig.serviceId)
|
|
return es
|
|
}
|
|
}
|
|
return "vod"
|
|
}
|
|
};
|
|
function eF(e) {
|
|
return (eF = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
|
|
return typeof e
|
|
}
|
|
: function(e) {
|
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
}
|
|
)(e)
|
|
}
|
|
function eN(e, t) {
|
|
var r, n = Object.keys(e);
|
|
return Object.getOwnPropertySymbols && (r = Object.getOwnPropertySymbols(e),
|
|
t && (r = r.filter(function(t) {
|
|
return Object.getOwnPropertyDescriptor(e, t).enumerable
|
|
})),
|
|
n.push.apply(n, r)),
|
|
n
|
|
}
|
|
function eH() {
|
|
return (eH = Object.assign ? Object.assign.bind() : function(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r, n = arguments[t];
|
|
for (r in n)
|
|
Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r])
|
|
}
|
|
return e
|
|
}
|
|
).apply(this, arguments)
|
|
}
|
|
function eL(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var n = t[r];
|
|
n.enumerable = n.enumerable || !1,
|
|
n.configurable = !0,
|
|
"value"in n && (n.writable = !0),
|
|
Object.defineProperty(e, eK(n.key), n)
|
|
}
|
|
}
|
|
function eK(e) {
|
|
return e = function(e, t) {
|
|
if ("object" !== eF(e) || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 === r)
|
|
return ("string" === t ? String : Number)(e);
|
|
if (r = r.call(e, t || "default"),
|
|
"object" !== eF(r))
|
|
return r;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}(e, "string"),
|
|
"symbol" === eF(e) ? e : String(e)
|
|
}
|
|
function eq(e, t) {
|
|
return (eq = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
|
|
return e.__proto__ = t,
|
|
e
|
|
}
|
|
)(e, t)
|
|
}
|
|
function eV(e) {
|
|
return (eV = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
|
|
return e.__proto__ || Object.getPrototypeOf(e)
|
|
}
|
|
)(e)
|
|
}
|
|
var eW = function() {
|
|
!function(e, t) {
|
|
if ("function" != typeof t && null !== t)
|
|
throw TypeError("Super expression must either be null or a function");
|
|
e.prototype = Object.create(t && t.prototype, {
|
|
constructor: {
|
|
value: e,
|
|
writable: !0,
|
|
configurable: !0
|
|
}
|
|
}),
|
|
Object.defineProperty(e, "prototype", {
|
|
writable: !1
|
|
}),
|
|
t && eq(e, t)
|
|
}(a, n.a);
|
|
var e, t, r, i, o, s = (e = a,
|
|
t = function() {
|
|
if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham)
|
|
return !1;
|
|
if ("function" == typeof Proxy)
|
|
return !0;
|
|
try {
|
|
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
|
!0
|
|
} catch (e) {
|
|
return !1
|
|
}
|
|
}(),
|
|
function() {
|
|
var r = eV(e);
|
|
return function(e, t) {
|
|
if (t && ("object" === eF(t) || "function" == typeof t))
|
|
return t;
|
|
if (void 0 !== t)
|
|
throw TypeError("Derived constructors may only return object or undefined");
|
|
return function(e) {
|
|
if (void 0 !== e)
|
|
return e;
|
|
throw ReferenceError("this hasn't been initialised - super() hasn't been called")
|
|
}(e)
|
|
}(this, t ? Reflect.construct(r, arguments, eV(this).constructor) : r.apply(this, arguments))
|
|
}
|
|
);
|
|
function a(e, t) {
|
|
var r;
|
|
return function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, a),
|
|
(r = s.call(this)).options = e,
|
|
r.config = t,
|
|
r.uploaderCtx = e.context,
|
|
r.currFileCtx = e.context.tasks[e.key],
|
|
r.systemTimeGap = 0,
|
|
r.retryTime = t.retryTaskTime,
|
|
r.hasRetryTime = 0,
|
|
r.isImageBatchUpload = !!r.options.isImageBatchUpload,
|
|
r.isDirect = r.options.isDirect,
|
|
r.serviceName = eG.checkServiceName(r.options.type, r.config, r.options.serviceType),
|
|
r
|
|
}
|
|
return r = a,
|
|
i = [{
|
|
key: "start",
|
|
value: function(e, t, r) {
|
|
this.startOptions = e,
|
|
this.failProcess = r,
|
|
this.successProcess = t,
|
|
this._st = Date.now(),
|
|
r = (e = this.uploaderCtx._getCache(this.currFileCtx.crc32Key)) ? JSON.parse(e) : {},
|
|
!this.isDirect && r.oid && r.UploadID ? this.resumeFromCache(r) : this.startPreUpload()
|
|
}
|
|
}, {
|
|
key: "startPreUpload",
|
|
value: function() {
|
|
var e = this
|
|
, t = this.config.region
|
|
, r = new ev
|
|
, n = (r.on("complete", function(t) {
|
|
e.success(t)
|
|
}),
|
|
r.on("error", function(t) {
|
|
e.handleError(t)
|
|
}),
|
|
"")
|
|
, i = {}
|
|
, o = this.uploaderCtx.useBackupDomain
|
|
, s = eG.checkServiceName(this.options.type, this.config, this.options.serviceType)
|
|
, i = s === es ? (n = o ? this.config.imageFallbackHost : this.config.imageHost,
|
|
this.createImageXParams()) : (n = o ? this.config.videoFallbackHost : this.config.videoHost,
|
|
this.createVodParams())
|
|
, o = (this.currFileCtx.fileSize && (i.FileSize = this.currFileCtx.fileSize),
|
|
this.config.useFileExtension && this.currFileCtx.fileName && (this.options.type === ei || this.options.type === en) && (o = this.currFileCtx.fileName,
|
|
o = eh.getFileSuffix(o)) && (i.FileExtension = o),
|
|
this.options.fileExtension && (i.FileExtension = this.options.fileExtension),
|
|
this.config.accountId && (i["X-Account-Id"] = this.config.accountId),
|
|
this.options.type !== er && this.config.bizType && (i.BizType = this.config.bizType,
|
|
i.AppID = this.config.appId,
|
|
i.UserID = this.config.userId),
|
|
this.config.openExperiment && (i.app_id = this.config.appId,
|
|
i.user_id = this.config.userId),
|
|
i.s = Math.random().toString(36).substring(2),
|
|
this.options.fileSize && (i.FileSize = this.options.fileSize),
|
|
this.currFileCtx.proxyStsToken || this.config.stsToken)
|
|
, a = eh.toQueryString(i)
|
|
, c = o.AccessKeyID
|
|
, u = o.AccessKeyId
|
|
, l = o.SecretAccessKey
|
|
, f = o.SessionToken
|
|
, o = o.CurrentTime
|
|
, a = {
|
|
method: "GET",
|
|
url: "".concat(n, "?").concat(a),
|
|
timeout: this.config.gatewayTimeout || 0,
|
|
region: t,
|
|
params: i,
|
|
pathname: eh.getPathByURL(n)
|
|
}
|
|
, t = new eb.a(a,s)
|
|
, i = (this.config.useServerCurrentTime && Math.abs(new Date(o) - new Date) > 6e4 && (this.systemTimeGap = new Date(o) - new Date),
|
|
this.systemTimeGap ? new Date((new Date).getTime() + this.systemTimeGap) : new Date);
|
|
t.addAuthorization({
|
|
accessKeyId: u || c,
|
|
secretAccessKey: l,
|
|
sessionToken: f
|
|
}, i),
|
|
r.send(a)
|
|
}
|
|
}, {
|
|
key: "createImageXParams",
|
|
value: function() {
|
|
var e, t = {
|
|
Action: "ApplyImageUpload",
|
|
Version: "2018-08-01"
|
|
};
|
|
return this.options.type === en && (this.config.imageConfig && this.config.imageConfig.serviceId ? t.ServiceId = this.config.imageConfig.serviceId : t.SpaceName = this.config.videoConfig && this.config.videoConfig.spaceName),
|
|
this.options.type === ei && (t.ServiceId = this.config.objectConfig && this.config.objectConfig.serviceId || this.config.imageConfig && this.config.imageConfig.serviceId),
|
|
this.currFileCtx.fileSize && 1 < this.currFileCtx.fileSize.length && (t.UploadNum = this.currFileCtx.fileSize.length),
|
|
this.options.storeKey && (e = this.options.storeKey,
|
|
"[object Array]" === Object.prototype.toString.call(e) ? t.StoreKeys = e : "[object String]" === Object.prototype.toString.call(e) && (t.StoreKeys = [e])),
|
|
t
|
|
}
|
|
}, {
|
|
key: "createVodParams",
|
|
value: function() {
|
|
var e = this.config.videoConfig && this.config.videoConfig.spaceName
|
|
, t = {
|
|
Action: "ApplyUploadInner",
|
|
Version: "2020-11-19",
|
|
SpaceName: e = this.options.type === ei && null != (t = this.config.objectConfig) && t.spaceName ? null == (t = this.config.objectConfig) ? void 0 : t.spaceName : e,
|
|
FileType: this.options.type,
|
|
IsInner: 1
|
|
};
|
|
return this.config.enOID && (t.EnOID = 1),
|
|
(this.options.testHost || this.config.testHost) && (t.TestHost = this.options.testHost || this.config.testHost),
|
|
this.startOptions && this.startOptions.selectRouteResult && (e = this.startOptions.selectRouteResult,
|
|
t.ClientBestHosts = e.map(function(e) {
|
|
return e.domainName
|
|
}).join(",")),
|
|
t
|
|
}
|
|
}, {
|
|
key: "resumeFromCache",
|
|
value: function(e) {
|
|
var t = this
|
|
, r = this.options.key
|
|
, n = new ev
|
|
, i = (n.on("complete", function(n) {
|
|
var i = null;
|
|
try {
|
|
var o = JSON.parse(n.response);
|
|
if (!(2e3 === o.code && 0 < o.data.partlist.length))
|
|
return t.startPreUpload();
|
|
var s = t.confirmCache(o.data.partlist)
|
|
, a = e.hasMerge ? 5 : s.isAllFinished ? 4 : 3
|
|
, i = eH(t.currFileCtx, e, {
|
|
key: r,
|
|
xhr: n,
|
|
extra: {
|
|
message: "prepare upload from cache success"
|
|
},
|
|
stage: "preUpload",
|
|
type: "success",
|
|
percent: 0,
|
|
cacheTask: a,
|
|
proxyStsToken: t.options.stsToken,
|
|
currentTask: 1,
|
|
status: 1,
|
|
isBreak: 1,
|
|
crc32Array: s.crc32Array,
|
|
stageStartTime: t._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - t._st,
|
|
totalDuration: Date.now() - t._st + t.currFileCtx.totalDuration
|
|
})
|
|
} catch (e) {
|
|
return t.startPreUpload()
|
|
}
|
|
t.successProcess(i)
|
|
}),
|
|
n.on("error", function(e) {
|
|
e.status >= 400 ? t.startPreUpload() : t.fail({
|
|
error: "request error",
|
|
xhr: e
|
|
})
|
|
}),
|
|
this.config.userId);
|
|
n.send({
|
|
method: "get",
|
|
url: eh.urlTemplate("{tosDomain}/upload/v1/{oid}?uploadid={uploadId}&action=part_list", {
|
|
tosDomain: e.tosDomain,
|
|
oid: e.oid,
|
|
uploadId: e.UploadID
|
|
}),
|
|
headers: function(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r = null != arguments[t] ? arguments[t] : {};
|
|
t % 2 ? eN(Object(r), !0).forEach(function(t) {
|
|
var n, i, o;
|
|
n = e,
|
|
i = t,
|
|
o = r[t],
|
|
(i = eK(i))in n ? Object.defineProperty(n, i, {
|
|
value: o,
|
|
enumerable: !0,
|
|
configurable: !0,
|
|
writable: !0
|
|
}) : n[i] = o
|
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : eN(Object(r)).forEach(function(t) {
|
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t))
|
|
})
|
|
}
|
|
return e
|
|
}({
|
|
Authorization: e.signature,
|
|
"X-Storage-U": encodeURIComponent(i)
|
|
}, e.UploadHeader),
|
|
timeout: 3e4
|
|
})
|
|
}
|
|
}, {
|
|
key: "confirmCache",
|
|
value: function(e) {
|
|
var t = this.currFileCtx.crc32Array
|
|
, r = {}
|
|
, n = (e.forEach(function(e) {
|
|
void 0 === r[e.num - 1] && (r[e.num - 1] = {
|
|
tag: !0,
|
|
crc32: e.crc32
|
|
})
|
|
}),
|
|
!0)
|
|
, e = t.map(function(e, t) {
|
|
return r[t] && r[t].tag && r[t].crc32 ? (e.crc32 = r[t].crc32,
|
|
e.finished = !0,
|
|
e.loaded = e.end - e.start) : n = !1,
|
|
e
|
|
});
|
|
return {
|
|
isAllFinished: n,
|
|
crc32Array: e
|
|
}
|
|
}
|
|
}, {
|
|
key: "handleError",
|
|
value: function(e) {
|
|
if ((this.options.type === en && this.config.imageFallbackHost || this.options.type === er && this.config.videoFallbackHost) && !this.uploaderCtx.useBackupDomain)
|
|
this.hasRetryTime < this.retryTime - 1 ? this.hasRetryTime++ : this.uploaderCtx.useBackupDomain = !0,
|
|
this.startPreUpload();
|
|
else {
|
|
var t = {
|
|
error: "request fail: ".concat(e.statusText || e.errText || "UNKNOWN"),
|
|
xhr: e
|
|
};
|
|
if (e.response)
|
|
try {
|
|
var r = JSON.parse(e.response);
|
|
r.ResponseMetadata && r.ResponseMetadata.Error && (t.errorCode = r.ResponseMetadata.Error.CodeN,
|
|
t.error = r.ResponseMetadata.Error.Code,
|
|
t.message = r.ResponseMetadata.Error.Message)
|
|
} catch (r) {
|
|
t.error = e.response.toString(),
|
|
t.message = e.response.toString()
|
|
}
|
|
this.fail(t)
|
|
}
|
|
}
|
|
}, {
|
|
key: "success",
|
|
value: function(e) {
|
|
if (e.response) {
|
|
var t = null;
|
|
try {
|
|
var r = JSON.parse(e.response);
|
|
if (r.ResponseMetadata.Error)
|
|
return this.fail({
|
|
xhr: e,
|
|
errorCode: r.ResponseMetadata.Error.CodeN,
|
|
error: r.ResponseMetadata.Error.Code,
|
|
message: r.ResponseMetadata.Error.Message
|
|
});
|
|
var n, i, o, s, a, c, u, l = this.serviceName, f = r.Result, p = l === es ? f.UploadAddress : f.InnerUploadAddress.UploadNodes[0], h = p.StoreInfos, d = p.UploadHosts, g = p.SessionKey, y = p.UploadHeader, m = l === es ? d[0] : p.UploadHost, v = null == (n = h[0]) ? void 0 : n.UploadID, b = [], _ = [];
|
|
this.isImageBatchUpload && 1 < h.length ? h.forEach(function(e) {
|
|
b.push(e.Auth),
|
|
_.push(e.StoreUri)
|
|
}) : (b = h[0].Auth,
|
|
_ = h[0].StoreUri),
|
|
"vod" === l && (i = f.InnerUploadAddress.UploadNodes).length && 1 < i.length && (s = {
|
|
SessionKey: (o = i[1]).SessionKey,
|
|
UploadHeader: o.UploadHeader,
|
|
StoreInfo: o.StoreInfos[0],
|
|
UploadHost: o.UploadHost
|
|
}),
|
|
this.startOptions && this.startOptions.enableSelectRoute && (u = !0,
|
|
this.startOptions.selectRouteResult) && (c = !(((a = this.startOptions.selectRouteResult)[0] && a[0].domainName) !== m)),
|
|
t = eH(this.currFileCtx, {
|
|
key: this.options.key,
|
|
useBackupDomain: this.uploaderCtx.useBackupDomain,
|
|
signature: b,
|
|
type: "success",
|
|
extra: {
|
|
message: "prepare upload success"
|
|
},
|
|
stage: "preUpload",
|
|
oid: _,
|
|
systemTimeGap: this.systemTimeGap,
|
|
tosDomain: "".concat(this.config.schema, "://").concat(m),
|
|
xhr: e,
|
|
UploadHeader: void 0 === y ? {} : y,
|
|
SessionKey: g,
|
|
UploadID: v,
|
|
fallbackStoreInfo: s,
|
|
stageStartTime: this._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - this._st,
|
|
totalDuration: Date.now() - this._st + this.currFileCtx.totalDuration,
|
|
useClientSelectRouteResult: c,
|
|
enableSelectRoute: u
|
|
})
|
|
} catch (t) {
|
|
return this.fail({
|
|
error: "catch error: ".concat(t.message || t.toString()),
|
|
xhr: e
|
|
})
|
|
}
|
|
return this.successProcess(t)
|
|
}
|
|
return this.fail({
|
|
error: "request fail: ".concat(e.statusText || e.errText || "UNKNOWN"),
|
|
xhr: e
|
|
})
|
|
}
|
|
}, {
|
|
key: "fail",
|
|
value: function(e) {
|
|
var t = this
|
|
, r = e.xhr
|
|
, n = e.errorCode || 1001e3
|
|
, i = "prepare upload error: UNKNOWN"
|
|
, i = (r && (i = 0 === r.status ? "prepare upload error: NETERROR" : e.message || "prepare upload error: ".concat(r.status)),
|
|
eH(this.currFileCtx, {
|
|
extra: {
|
|
message: i,
|
|
error: e.error,
|
|
errorCode: n
|
|
},
|
|
type: "error",
|
|
stage: "preUpload",
|
|
xhr: r,
|
|
stageStartTime: this._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - this._st,
|
|
totalDuration: Date.now() - this._st + this.currFileCtx.totalDuration
|
|
}));
|
|
this.isImageBatchUpload && (i.successImage = [],
|
|
i.failImage = null == (e = this.currFileCtx) ? void 0 : e.crc32Array.map(function(e, r) {
|
|
return {
|
|
crc32: e.crc32,
|
|
fileSize: null == (e = t.currFileCtx) ? void 0 : e.fileSize[r],
|
|
fileName: null == (e = t.currFileCtx) ? void 0 : e.fileName[r],
|
|
finishSize: 0,
|
|
success: !1
|
|
}
|
|
})),
|
|
this.uploaderCtx._removeTaskCache(this.options.key),
|
|
this.failProcess(i)
|
|
}
|
|
}],
|
|
eL(r.prototype, i),
|
|
Object.defineProperty(r, "prototype", {
|
|
writable: !1
|
|
}),
|
|
a
|
|
}();
|
|
function eJ(e) {
|
|
return (eJ = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
|
|
return typeof e
|
|
}
|
|
: function(e) {
|
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
}
|
|
)(e)
|
|
}
|
|
function eQ(e, t) {
|
|
var r, n = Object.keys(e);
|
|
return Object.getOwnPropertySymbols && (r = Object.getOwnPropertySymbols(e),
|
|
t && (r = r.filter(function(t) {
|
|
return Object.getOwnPropertyDescriptor(e, t).enumerable
|
|
})),
|
|
n.push.apply(n, r)),
|
|
n
|
|
}
|
|
function eX() {
|
|
return (eX = Object.assign ? Object.assign.bind() : function(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r, n = arguments[t];
|
|
for (r in n)
|
|
Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r])
|
|
}
|
|
return e
|
|
}
|
|
).apply(this, arguments)
|
|
}
|
|
function e$(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var n = t[r];
|
|
n.enumerable = n.enumerable || !1,
|
|
n.configurable = !0,
|
|
"value"in n && (n.writable = !0),
|
|
Object.defineProperty(e, eZ(n.key), n)
|
|
}
|
|
}
|
|
function eZ(e) {
|
|
return e = function(e, t) {
|
|
if ("object" !== eJ(e) || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 === r)
|
|
return ("string" === t ? String : Number)(e);
|
|
if (r = r.call(e, t || "default"),
|
|
"object" !== eJ(r))
|
|
return r;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}(e, "string"),
|
|
"symbol" === eJ(e) ? e : String(e)
|
|
}
|
|
function eY(e, t) {
|
|
return (eY = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
|
|
return e.__proto__ = t,
|
|
e
|
|
}
|
|
)(e, t)
|
|
}
|
|
function e0(e) {
|
|
return (e0 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
|
|
return e.__proto__ || Object.getPrototypeOf(e)
|
|
}
|
|
)(e)
|
|
}
|
|
var e1 = function() {
|
|
!function(e, t) {
|
|
if ("function" != typeof t && null !== t)
|
|
throw TypeError("Super expression must either be null or a function");
|
|
e.prototype = Object.create(t && t.prototype, {
|
|
constructor: {
|
|
value: e,
|
|
writable: !0,
|
|
configurable: !0
|
|
}
|
|
}),
|
|
Object.defineProperty(e, "prototype", {
|
|
writable: !1
|
|
}),
|
|
t && eY(e, t)
|
|
}(a, n.a);
|
|
var e, t, r, i, o, s = (e = a,
|
|
t = function() {
|
|
if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham)
|
|
return !1;
|
|
if ("function" == typeof Proxy)
|
|
return !0;
|
|
try {
|
|
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
|
!0
|
|
} catch (e) {
|
|
return !1
|
|
}
|
|
}(),
|
|
function() {
|
|
var r = e0(e);
|
|
return function(e, t) {
|
|
if (t && ("object" === eJ(t) || "function" == typeof t))
|
|
return t;
|
|
if (void 0 !== t)
|
|
throw TypeError("Derived constructors may only return object or undefined");
|
|
return function(e) {
|
|
if (void 0 !== e)
|
|
return e;
|
|
throw ReferenceError("this hasn't been initialised - super() hasn't been called")
|
|
}(e)
|
|
}(this, t ? Reflect.construct(r, arguments, e0(this).constructor) : r.apply(this, arguments))
|
|
}
|
|
);
|
|
function a(e, t) {
|
|
var r;
|
|
return function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, a),
|
|
(r = s.call(this)).options = e,
|
|
r.config = t,
|
|
r.transport = new ev,
|
|
r.uploaderCtx = e.context,
|
|
r.currFileCtx = e.context.tasks[e.key],
|
|
r.eventInit(),
|
|
r
|
|
}
|
|
return r = a,
|
|
i = [{
|
|
key: "initUpload",
|
|
value: function(e) {
|
|
e && (e = this.currFileCtx.fallbackStoreInfo) && eX(this.currFileCtx, {
|
|
oid: e.StoreInfo.StoreUri,
|
|
tosDomain: "".concat(this.config.schema, "://").concat(e.UploadHost),
|
|
signature: e.StoreInfo.Auth,
|
|
UploadHeader: e.UploadHeader,
|
|
SessionKey: e.SessionKey
|
|
});
|
|
var e = {
|
|
oid: this.currFileCtx.oid,
|
|
tosDomain: this.currFileCtx.tosDomain
|
|
}
|
|
, e = eh.urlTemplate("{tosDomain}/upload/v1/{oid}?uploadmode=part&phase=init", e)
|
|
, t = this.config.userId;
|
|
this.transport.send({
|
|
method: "post",
|
|
url: e,
|
|
headers: function(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r = null != arguments[t] ? arguments[t] : {};
|
|
t % 2 ? eQ(Object(r), !0).forEach(function(t) {
|
|
var n, i, o;
|
|
n = e,
|
|
i = t,
|
|
o = r[t],
|
|
(i = eZ(i))in n ? Object.defineProperty(n, i, {
|
|
value: o,
|
|
enumerable: !0,
|
|
configurable: !0,
|
|
writable: !0
|
|
}) : n[i] = o
|
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : eQ(Object(r)).forEach(function(t) {
|
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t))
|
|
})
|
|
}
|
|
return e
|
|
}({
|
|
Authorization: this.currFileCtx.signature,
|
|
"X-Storage-U": encodeURIComponent(t)
|
|
}, this.currFileCtx.UploadHeader),
|
|
timeout: this.config.gatewayTimeout
|
|
})
|
|
}
|
|
}, {
|
|
key: "start",
|
|
value: function(e, t, r) {
|
|
this.successProcess = t,
|
|
this.failProcess = r,
|
|
this._st = Date.now(),
|
|
this.initUpload(e && e.changeNodeRetry)
|
|
}
|
|
}, {
|
|
key: "eventInit",
|
|
value: function() {
|
|
var e = this;
|
|
this.transport.on("complete", function(t) {
|
|
var r = null;
|
|
try {
|
|
var n, i = JSON.parse(t.response), o = null == (n = i.data) ? void 0 : n.uploadid;
|
|
if (2e3 !== i.code || !o)
|
|
return e.fail({
|
|
error: "fail! response.code: ".concat(i.code, ", fail message: ").concat(i.message),
|
|
xhr: t,
|
|
errorCode: null == i ? void 0 : i.code
|
|
});
|
|
r = eX(e.currFileCtx, {
|
|
UploadID: o,
|
|
percent: 0,
|
|
type: "success",
|
|
extra: {
|
|
message: "init upload id success"
|
|
},
|
|
stage: "initUploadID",
|
|
xhr: t,
|
|
stageStartTime: e._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - e._st,
|
|
totalDuration: Date.now() - e._st + e.currFileCtx.totalDuration
|
|
})
|
|
} catch (r) {
|
|
return e.fail({
|
|
error: "catch error: ".concat(r.message || JSON.stringify(r)),
|
|
xhr: t
|
|
})
|
|
}
|
|
return e.successProcess(r)
|
|
}),
|
|
this.transport.on("error", function(t) {
|
|
e.fail({
|
|
error: "request fail: ".concat(t.statusText || t.errText || "UNKNOWN"),
|
|
xhr: t
|
|
})
|
|
})
|
|
}
|
|
}, {
|
|
key: "fail",
|
|
value: function(e) {
|
|
var t = this.options.context
|
|
, r = this.options.key
|
|
, t = eX(t.tasks[r], {
|
|
extra: {
|
|
message: "init upload id error, ".concat(e.error),
|
|
errorCode: e.errorCode || 1002e3
|
|
},
|
|
type: "error",
|
|
stage: "initUploadID",
|
|
xhr: e.xhr,
|
|
stageStartTime: this._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - this._st,
|
|
totalDuration: Date.now() - this._st + this.currFileCtx.totalDuration
|
|
});
|
|
this.uploaderCtx._removeTaskCache(this.options.key),
|
|
this.failProcess(t)
|
|
}
|
|
}],
|
|
e$(r.prototype, i),
|
|
Object.defineProperty(r, "prototype", {
|
|
writable: !1
|
|
}),
|
|
a
|
|
}();
|
|
function e2(e) {
|
|
return (e2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
|
|
return typeof e
|
|
}
|
|
: function(e) {
|
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
}
|
|
)(e)
|
|
}
|
|
function e3(e, t) {
|
|
var r, n = Object.keys(e);
|
|
return Object.getOwnPropertySymbols && (r = Object.getOwnPropertySymbols(e),
|
|
t && (r = r.filter(function(t) {
|
|
return Object.getOwnPropertyDescriptor(e, t).enumerable
|
|
})),
|
|
n.push.apply(n, r)),
|
|
n
|
|
}
|
|
function e4(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r = null != arguments[t] ? arguments[t] : {};
|
|
t % 2 ? e3(Object(r), !0).forEach(function(t) {
|
|
var n, i, o;
|
|
n = e,
|
|
i = t,
|
|
o = r[t],
|
|
(i = e6(i))in n ? Object.defineProperty(n, i, {
|
|
value: o,
|
|
enumerable: !0,
|
|
configurable: !0,
|
|
writable: !0
|
|
}) : n[i] = o
|
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : e3(Object(r)).forEach(function(t) {
|
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t))
|
|
})
|
|
}
|
|
return e
|
|
}
|
|
function e5(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var n = t[r];
|
|
n.enumerable = n.enumerable || !1,
|
|
n.configurable = !0,
|
|
"value"in n && (n.writable = !0),
|
|
Object.defineProperty(e, e6(n.key), n)
|
|
}
|
|
}
|
|
function e6(e) {
|
|
return e = function(e, t) {
|
|
if ("object" !== e2(e) || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 === r)
|
|
return ("string" === t ? String : Number)(e);
|
|
if (r = r.call(e, t || "default"),
|
|
"object" !== e2(r))
|
|
return r;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}(e, "string"),
|
|
"symbol" === e2(e) ? e : String(e)
|
|
}
|
|
function e8(e, t) {
|
|
return (e8 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
|
|
return e.__proto__ = t,
|
|
e
|
|
}
|
|
)(e, t)
|
|
}
|
|
function e7(e) {
|
|
return (e7 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
|
|
return e.__proto__ || Object.getPrototypeOf(e)
|
|
}
|
|
)(e)
|
|
}
|
|
var e9 = function() {
|
|
!function(e, t) {
|
|
if ("function" != typeof t && null !== t)
|
|
throw TypeError("Super expression must either be null or a function");
|
|
e.prototype = Object.create(t && t.prototype, {
|
|
constructor: {
|
|
value: e,
|
|
writable: !0,
|
|
configurable: !0
|
|
}
|
|
}),
|
|
Object.defineProperty(e, "prototype", {
|
|
writable: !1
|
|
}),
|
|
t && e8(e, t)
|
|
}(a, n.a);
|
|
var e, t, r, i, o, s = (e = a,
|
|
t = function() {
|
|
if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham)
|
|
return !1;
|
|
if ("function" == typeof Proxy)
|
|
return !0;
|
|
try {
|
|
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
|
!0
|
|
} catch (e) {
|
|
return !1
|
|
}
|
|
}(),
|
|
function() {
|
|
var r = e7(e);
|
|
return function(e, t) {
|
|
if (t && ("object" === e2(t) || "function" == typeof t))
|
|
return t;
|
|
if (void 0 !== t)
|
|
throw TypeError("Derived constructors may only return object or undefined");
|
|
return function(e) {
|
|
if (void 0 !== e)
|
|
return e;
|
|
throw ReferenceError("this hasn't been initialised - super() hasn't been called")
|
|
}(e)
|
|
}(this, t ? Reflect.construct(r, arguments, e7(this).constructor) : r.apply(this, arguments))
|
|
}
|
|
);
|
|
function a(e) {
|
|
var t, r = e.sliceItem, n = e.crc32, i = e.url, o = e.signature, c = e.uploadHeader, u = e.userId, l = e.retryTime, f = e.timeout, e = e.method, e = void 0 === e ? "POST" : e;
|
|
return function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, a),
|
|
(t = s.call(this)).fileSlice = r,
|
|
t.crc32 = n,
|
|
t.uploadUrl = i,
|
|
t.uploadHeader = c,
|
|
t.signature = o,
|
|
t.userId = u,
|
|
t.retryTime = l || 0,
|
|
t.method = e,
|
|
t.retryCount = 0,
|
|
t.timeout = f,
|
|
t.ready = !1,
|
|
t.cancel = !1,
|
|
t.transport = new ev,
|
|
t.eventInit(),
|
|
t
|
|
}
|
|
return r = a,
|
|
i = [{
|
|
key: "upload",
|
|
value: function(e, t) {
|
|
this.isParamsValid() && (this._st = Date.now(),
|
|
this.transport && this.transport.send({
|
|
method: this.method,
|
|
url: this.uploadUrl,
|
|
headers: e4({
|
|
Authorization: this.signature,
|
|
"Content-CRC32": this.crc32,
|
|
"X-Storage-U": encodeURIComponent(this.userId)
|
|
}, this.uploadHeader),
|
|
file: this.fileSlice,
|
|
binary: 1,
|
|
timeout: this.timeout
|
|
}),
|
|
e) && this.emit("retry", t)
|
|
}
|
|
}, {
|
|
key: "isParamsValid",
|
|
value: function() {
|
|
return this.fileSlice && (this.fileSlice.size || this.fileSlice.byteLength) ? this.crc32 ? !!this.uploadUrl || (this.emit("error", {
|
|
message: "slice upload failed: NOURL",
|
|
crc32: this.crc32,
|
|
size: this.fileSlice.size || this.fileSlice.byteLength
|
|
}),
|
|
!1) : (this.emit("error", {
|
|
message: "slice upload failed: NOCRC32",
|
|
crc32: this.crc32,
|
|
size: this.fileSlice.size || this.fileSlice.byteLength
|
|
}),
|
|
!1) : (this.emit("error", {
|
|
message: "slice upload failed: NOCONTENT",
|
|
crc32: this.crc32
|
|
}),
|
|
!1)
|
|
}
|
|
}, {
|
|
key: "eventInit",
|
|
value: function() {
|
|
var e = this;
|
|
this.transport.on("complete", function(t) {
|
|
try {
|
|
var r = JSON.parse(t.response);
|
|
2e3 === r.code ? e.success(t) : e.fail(t, r)
|
|
} catch (r) {
|
|
e.fail(t)
|
|
}
|
|
}),
|
|
this.transport.on("error", function(t) {
|
|
e.fail(t)
|
|
}),
|
|
this.transport.on("progress", function(t) {
|
|
e.process(t)
|
|
})
|
|
}
|
|
}, {
|
|
key: "success",
|
|
value: function(e) {
|
|
this.ready = !0;
|
|
var t = Date.now() - this._st
|
|
, r = this.fileSlice.size || this.fileSlice.byteLength;
|
|
this.emit("complete", {
|
|
crc32: this.crc32,
|
|
size: r,
|
|
speed: r / t,
|
|
xhr: e,
|
|
sliceStartTime: this._st,
|
|
sliceEndTime: Date.now(),
|
|
sliceDuration: Date.now() - this._st
|
|
})
|
|
}
|
|
}, {
|
|
key: "fail",
|
|
value: function(e) {
|
|
var t, r, n = this, i = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : null;
|
|
this.cancel || (t = {
|
|
crc32: this.crc32,
|
|
size: this.fileSlice.size || this.fileSlice.byteLength,
|
|
xhr: e,
|
|
sliceStartTime: this._st,
|
|
sliceEndTime: Date.now(),
|
|
sliceDuration: Date.now() - this._st
|
|
},
|
|
e && 401 === e.status ? this.emit("error", e4({
|
|
message: "slice upload failed: UNAUTHORIZED"
|
|
}, t)) : (r = "slice upload failed: UNKNOWN",
|
|
e && (r = e.status ? "slice upload failed: ".concat((null == i ? void 0 : i.message) || e.status) : "slice upload failed: NETERROR"),
|
|
this.retryCount < this.retryTime ? (setTimeout(function() {
|
|
n.upload(!0, e4({
|
|
message: r
|
|
}, t))
|
|
}, 1e3),
|
|
this.retryCount++) : this.emit("error", e4({
|
|
message: r,
|
|
errorCode: null == i ? void 0 : i.code
|
|
}, t))))
|
|
}
|
|
}, {
|
|
key: "process",
|
|
value: function(e) {
|
|
this.cancel || this.emit("progress", {
|
|
crc32: this.crc32,
|
|
loaded: e.loaded || 0,
|
|
total: e.total || 0
|
|
})
|
|
}
|
|
}, {
|
|
key: "abort",
|
|
value: function() {
|
|
this.transport && (this.cancel = !0,
|
|
this.transport.abort())
|
|
}
|
|
}, {
|
|
key: "destroy",
|
|
value: function() {
|
|
this.transport = null
|
|
}
|
|
}],
|
|
e5(r.prototype, i),
|
|
Object.defineProperty(r, "prototype", {
|
|
writable: !1
|
|
}),
|
|
a
|
|
}()
|
|
, $ = r(2)
|
|
, te = r.n($);
|
|
function tt(e) {
|
|
return (tt = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
|
|
return typeof e
|
|
}
|
|
: function(e) {
|
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
}
|
|
)(e)
|
|
}
|
|
function tr() {
|
|
return (tr = Object.assign ? Object.assign.bind() : function(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r, n = arguments[t];
|
|
for (r in n)
|
|
Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r])
|
|
}
|
|
return e
|
|
}
|
|
).apply(this, arguments)
|
|
}
|
|
function tn(e, t) {
|
|
(null == t || t > e.length) && (t = e.length);
|
|
for (var r = 0, n = Array(t); r < t; r++)
|
|
n[r] = e[r];
|
|
return n
|
|
}
|
|
function ti(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var n, i = t[r];
|
|
i.enumerable = i.enumerable || !1,
|
|
i.configurable = !0,
|
|
"value"in i && (i.writable = !0),
|
|
Object.defineProperty(e, (n = function(e, t) {
|
|
if ("object" !== tt(e) || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 === r)
|
|
return ("string" === t ? String : Number)(e);
|
|
if (r = r.call(e, t || "default"),
|
|
"object" !== tt(r))
|
|
return r;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}(n = i.key, "string"),
|
|
"symbol" === tt(n) ? n : String(n)), i)
|
|
}
|
|
}
|
|
function to(e, t) {
|
|
return (to = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
|
|
return e.__proto__ = t,
|
|
e
|
|
}
|
|
)(e, t)
|
|
}
|
|
function ts(e) {
|
|
return (ts = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
|
|
return e.__proto__ || Object.getPrototypeOf(e)
|
|
}
|
|
)(e)
|
|
}
|
|
var ta = function() {
|
|
!function(e, t) {
|
|
if ("function" != typeof t && null !== t)
|
|
throw TypeError("Super expression must either be null or a function");
|
|
e.prototype = Object.create(t && t.prototype, {
|
|
constructor: {
|
|
value: e,
|
|
writable: !0,
|
|
configurable: !0
|
|
}
|
|
}),
|
|
Object.defineProperty(e, "prototype", {
|
|
writable: !1
|
|
}),
|
|
t && to(e, t)
|
|
}(c, n.a);
|
|
var e, t, r, o, s, a = (e = c,
|
|
t = function() {
|
|
if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham)
|
|
return !1;
|
|
if ("function" == typeof Proxy)
|
|
return !0;
|
|
try {
|
|
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
|
!0
|
|
} catch (e) {
|
|
return !1
|
|
}
|
|
}(),
|
|
function() {
|
|
var r = ts(e);
|
|
return function(e, t) {
|
|
if (t && ("object" === tt(t) || "function" == typeof t))
|
|
return t;
|
|
if (void 0 !== t)
|
|
throw TypeError("Derived constructors may only return object or undefined");
|
|
return function(e) {
|
|
if (void 0 !== e)
|
|
return e;
|
|
throw ReferenceError("this hasn't been initialised - super() hasn't been called")
|
|
}(e)
|
|
}(this, t ? Reflect.construct(r, arguments, ts(this).constructor) : r.apply(this, arguments))
|
|
}
|
|
);
|
|
function c(e) {
|
|
var t, r = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {};
|
|
return function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, c),
|
|
(t = a.call(this)).file = e.file,
|
|
t.context = e.context,
|
|
t.key = e.key,
|
|
t.config = r,
|
|
t.finishArr = [],
|
|
t.errorLength = 0,
|
|
t.finishSize = 0,
|
|
t.retryUploadTime = Number(r.retryUploadTime),
|
|
t.progressMonitorTime = Number(r.progressMonitorTime),
|
|
t.progressMonitorSpeed = Number(r.progressMonitorSpeed),
|
|
t.uploadSliceCount = Number(r.uploadSliceCount),
|
|
t.realtimeSpeedInterval = Number(r.realtimeSpeedInterval),
|
|
t.processRetry = 0,
|
|
t.lastFinishSize = -1,
|
|
t.lastProcessPercent = -1,
|
|
t.lastIntervalSize = -1,
|
|
t.lastCalculateSpeedTime = -1,
|
|
t.lastCalculateSpeedSize = 0,
|
|
t.uploadHandlers = {},
|
|
t
|
|
}
|
|
return r = c,
|
|
o = [{
|
|
key: "start",
|
|
value: function(e, t, r) {
|
|
this.failProcess = r,
|
|
this.successProcess = t,
|
|
this.errorLength = 0,
|
|
this.currentCtx = this.context.tasks[this.key],
|
|
this.crc32Array = this.context.tasks[this.key].crc32Array,
|
|
this.uploadSliceCount = this.uploadSliceCount > this.crc32Array.length ? this.crc32Array.length : this.uploadSliceCount,
|
|
this.lastIndex = 0,
|
|
this.uploading = [],
|
|
this._uploadSize = this.crc32Array.reduce(function(e, t) {
|
|
return e + (t.finished ? 0 : t.end - t.start)
|
|
}, 0),
|
|
this._st = Date.now(),
|
|
this._lastSaveTime = Date.now(),
|
|
this.lastCalculateSpeedTime = this._st,
|
|
this.initWorker(),
|
|
this.setProgressMonitor(),
|
|
this.threadUpload()
|
|
}
|
|
}, {
|
|
key: "initWorker",
|
|
value: function() {
|
|
var e, t = this;
|
|
this.worker || (e = this.crc32Array,
|
|
this.worker = new te.a,
|
|
this.worker.onmessage = function(r) {
|
|
var n, i, r = (n = r.data,
|
|
i = 4,
|
|
function(e) {
|
|
if (Array.isArray(e))
|
|
return e
|
|
}(n) || function(e, t) {
|
|
var r = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
|
|
if (null != r) {
|
|
var n, i, o, s, a = [], c = !0, u = !1;
|
|
try {
|
|
if (o = (r = r.call(e)).next,
|
|
0 === t) {
|
|
if (Object(r) !== r)
|
|
return;
|
|
c = !1
|
|
} else
|
|
for (; !(c = (n = o.call(r)).done) && (a.push(n.value),
|
|
a.length !== t); c = !0)
|
|
;
|
|
} catch (e) {
|
|
u = !0,
|
|
i = e
|
|
} finally {
|
|
try {
|
|
if (!c && null != r.return && (s = r.return(),
|
|
Object(s) !== s))
|
|
return
|
|
} finally {
|
|
if (u)
|
|
throw i
|
|
}
|
|
}
|
|
return a
|
|
}
|
|
}(n, 4) || function(e, t) {
|
|
var r;
|
|
if (e)
|
|
return "string" == typeof e ? tn(e, t) : "Map" === (r = "Object" === (r = Object.prototype.toString.call(e).slice(8, -1)) && e.constructor ? e.constructor.name : r) || "Set" === r ? Array.from(e) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? tn(e, t) : void 0
|
|
}(n, i) || function() {
|
|
throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
|
|
}()), o = r[0], s = r[1], a = r[2], r = r[3], c = (new Date).getTime(), u = e[a];
|
|
u.crc32 = s,
|
|
u.crc32StartTime = r,
|
|
u.crc32EndTime = c,
|
|
u.crc32Duration = c - r,
|
|
t.upload(u, o, a)
|
|
}
|
|
)
|
|
}
|
|
}, {
|
|
key: "read",
|
|
value: function(e, t) {
|
|
var r = this
|
|
, n = this.file
|
|
, i = n.slice || n.webkitSlice || n.mozSlice
|
|
, o = new FileReader;
|
|
o.onload = function(e) {
|
|
var n = (new Date).getTime();
|
|
r.worker.postMessage([e.target.result, t, n, !!r.config.clientEncrypt, r.currentCtx.clientEncryptKey, r.crc32Array.length - 1 === t], [e.target.result])
|
|
}
|
|
,
|
|
o.onerror = function() {
|
|
r.stop(),
|
|
r.fail({
|
|
extra: {
|
|
message: "An error occurred reading the file",
|
|
errorCode: 1003003
|
|
}
|
|
})
|
|
}
|
|
,
|
|
o.readAsArrayBuffer(i.call(n, e.start, e.end))
|
|
}
|
|
}, {
|
|
key: "threadUpload",
|
|
value: function() {
|
|
if (this.uploading.length < this.uploadSliceCount) {
|
|
var e = this.lastIndex
|
|
, t = this.crc32Array[e];
|
|
if (t) {
|
|
if (t.finished) {
|
|
if (-1 === this.finishArr.indexOf(t.start) && (this.finishArr.push(t.start),
|
|
this.finishArr.length >= this.crc32Array.length))
|
|
return this.stop(),
|
|
void this.success()
|
|
} else
|
|
t.loaded = 0,
|
|
this.uploading.push(e),
|
|
this.read(t, e);
|
|
this.lastIndex++,
|
|
this.threadUpload()
|
|
}
|
|
}
|
|
}
|
|
}, {
|
|
key: "stop",
|
|
value: function() {
|
|
var e = this;
|
|
Object.keys(this.uploadHandlers).forEach(function(t) {
|
|
e.uploadHandlers[t].abort(),
|
|
e.uploadHandlers[t].destroy()
|
|
}),
|
|
this.uploadHandlers = {},
|
|
this.worker && this.worker.terminate(),
|
|
this.worker = null,
|
|
this.clearMonitor()
|
|
}
|
|
}, {
|
|
key: "setProgressMonitor",
|
|
value: function() {
|
|
var e = this;
|
|
this.progressMonitorInterval = setInterval(function() {
|
|
var t, r = e.finishSize;
|
|
r - e.lastIntervalSize < e.progressMonitorTime / 1e3 * e.progressMonitorSpeed * 1024 ? (t = tr(e.currentCtx, {
|
|
stage: "process",
|
|
type: "warn",
|
|
extra: {
|
|
message: "percent are not updated in ".concat(e.progressMonitorTime, " seconds")
|
|
}
|
|
}),
|
|
e.context.logger.send(t),
|
|
e.context._broadcast("slowProgress", t),
|
|
e.clearMonitor()) : e.lastIntervalSize = r
|
|
}, this.progressMonitorTime)
|
|
}
|
|
}, {
|
|
key: "clearMonitor",
|
|
value: function() {
|
|
this.progressMonitorInterval && clearInterval(this.progressMonitorInterval)
|
|
}
|
|
}, {
|
|
key: "upload",
|
|
value: function(e, t, r) {
|
|
var n = this
|
|
, o = e.crc32
|
|
, s = {
|
|
part_number: r + 1,
|
|
uploadId: this.currentCtx.UploadID,
|
|
oid: this.currentCtx.oid,
|
|
tosDomain: this.currentCtx.tosDomain
|
|
}
|
|
, s = eh.urlTemplate(i, s)
|
|
, a = this.config.userId
|
|
, t = (this.config.clientEncrypt || (t = eh.fileSlice(this.file, e.start, e.end)),
|
|
new e9({
|
|
sliceItem: t,
|
|
crc32: o,
|
|
url: s,
|
|
signature: this.currentCtx.signature,
|
|
uploadHeader: this.currentCtx.UploadHeader,
|
|
userId: a,
|
|
method: "POST",
|
|
retryTime: this.retryUploadTime,
|
|
timeout: this.config.uploadTimeout
|
|
}));
|
|
t.on("complete", function(t) {
|
|
1 === n.currentCtx.status && (t.start = e.start,
|
|
t.crc32StartTime = e.crc32StartTime,
|
|
t.crc32EndTime = e.crc32EndTime,
|
|
t.crc32Duration = e.crc32Duration,
|
|
t.index = r,
|
|
n.fileSliceSuccess(t))
|
|
}),
|
|
t.on("error", function(t) {
|
|
1 === n.currentCtx.status && (t.start = e.start,
|
|
t.crc32StartTime = e.crc32StartTime,
|
|
t.crc32EndTime = e.crc32EndTime,
|
|
t.crc32Duration = e.crc32Duration,
|
|
t.index = r,
|
|
n.fail(t))
|
|
}),
|
|
t.on("progress", function(t) {
|
|
1 === n.currentCtx.status && (t.start = e.start,
|
|
t.index = r,
|
|
n.process(t))
|
|
}),
|
|
t.on("retry", function(t) {
|
|
1 === n.currentCtx.status && (t.start = e.start,
|
|
t.index = r,
|
|
n.retry(t))
|
|
}),
|
|
t.upload(),
|
|
this.uploadHandlers[r] = t
|
|
}
|
|
}, {
|
|
key: "success",
|
|
value: function(e) {
|
|
this.finishArr = [];
|
|
var t = Date.now() - this._st
|
|
, t = this._uploadSize / t
|
|
, t = tr(this.currentCtx, {
|
|
type: "success",
|
|
stage: "process",
|
|
percent: 100,
|
|
extra: {
|
|
message: "upload all success"
|
|
},
|
|
speed: t,
|
|
xhr: e,
|
|
stageStartTime: this._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - this._st,
|
|
totalDuration: Date.now() - this._lastSaveTime + this.currentCtx.totalDuration,
|
|
isAllFinish: !0
|
|
});
|
|
this.worker && this.worker.terminate(),
|
|
this.successProcess(t)
|
|
}
|
|
}, {
|
|
key: "fail",
|
|
value: function(e) {
|
|
var t = this.errorFormat(e);
|
|
t.type = "error",
|
|
void 0 !== e.statusCode && tr(this.currentCtx, {
|
|
statusCode: e.statusCode
|
|
}),
|
|
this.errorLength || (this.context.logger.send(tr({}, t)),
|
|
this.stop(),
|
|
this.context._broadcast("error", t),
|
|
this.currentCtx.isBreak ? this.context._cancel(this.key) : this.context._pause(this.key),
|
|
this.errorLength++)
|
|
}
|
|
}, {
|
|
key: "retry",
|
|
value: function(e) {
|
|
e = this.errorFormat(e),
|
|
this.context.logger.send(tr({}, e, {
|
|
type: "retry"
|
|
}))
|
|
}
|
|
}, {
|
|
key: "fileSliceSuccess",
|
|
value: function(e) {
|
|
var t, r = e.index, n = Date.now(), i = (-1 === this.finishArr.indexOf(e.start) && this.finishArr.push(e.start),
|
|
this.crc32Array[r].finished = !0,
|
|
this.crc32Array[r].speed = e.speed,
|
|
{
|
|
message: "slice upload success"
|
|
});
|
|
e.xhr && (t = e.xhr,
|
|
i.currentUrl = t.currentUrl || "",
|
|
tr(this.currentCtx, {
|
|
req: {
|
|
url: t.currentUrl,
|
|
param: t.params
|
|
},
|
|
res: {
|
|
status: t.status,
|
|
body: t.responseText,
|
|
header: t.getAllResponseHeaders()
|
|
}
|
|
}),
|
|
delete e.xhr),
|
|
this.context.logger.send(tr(this.currentCtx, {
|
|
stage: "process",
|
|
type: "success",
|
|
sliceIndex: r,
|
|
extra: i,
|
|
totalDuration: n - this._lastSaveTime + this.currentCtx.totalDuration,
|
|
sliceStartTime: e.sliceStartTime,
|
|
sliceEndTime: e.sliceEndTime,
|
|
sliceDuration: e.sliceDuration,
|
|
crc32StartTime: e.crc32StartTime,
|
|
crc32EndTime: e.crc32EndTime,
|
|
crc32Duration: e.crc32Duration
|
|
})),
|
|
this._lastSaveTime = n,
|
|
this.uploading.splice(this.uploading.indexOf(r), 1),
|
|
this.uploadHandlers[r] && delete this.uploadHandlers[r],
|
|
this.finishArr.length >= this.crc32Array.length ? (this.stop(),
|
|
this.success(e.xhr)) : this.threadUpload()
|
|
}
|
|
}, {
|
|
key: "getFinishSize",
|
|
value: function(e, t) {
|
|
var r = t.crc32
|
|
, n = 0;
|
|
return e.forEach(function(e) {
|
|
e.crc32 === r ? (e.loaded = t.loaded,
|
|
n += t.loaded) : (e.loaded || (e.loaded = 0),
|
|
n += e.loaded)
|
|
}),
|
|
n
|
|
}
|
|
}, {
|
|
key: "process",
|
|
value: function(e) {
|
|
var t = this.currentCtx.realtimeSpeed || 0
|
|
, r = this.currentCtx.fileSize
|
|
, n = (this.finishSize = this.getFinishSize(this.crc32Array, e),
|
|
this.finishSize > this.lastFinishSize && ((e = new Date).getTime() - this.lastCalculateSpeedTime > this.realtimeSpeedInterval && (i = e.getTime() - this.lastCalculateSpeedTime,
|
|
t = Math.floor((n = this.finishSize - this.lastCalculateSpeedSize) / i),
|
|
this.lastCalculateSpeedTime = e.getTime(),
|
|
this.lastCalculateSpeedSize = this.finishSize),
|
|
this.lastFinishSize = this.finishSize),
|
|
Math.floor(this.finishSize / r * 100) || 0)
|
|
, i = tr(this.currentCtx, {
|
|
stage: "process",
|
|
percent: n,
|
|
realtimeSpeed: t
|
|
});
|
|
n > this.lastProcessPercent && 100 !== n && (this.lastProcessPercent = n,
|
|
this.context._broadcast("progress", i))
|
|
}
|
|
}, {
|
|
key: "errorFormat",
|
|
value: function(e) {
|
|
var t = this.currentCtx.totalDuration
|
|
, r = Date.now() - this._st
|
|
, n = e.index
|
|
, i = e.crc32 ? {
|
|
message: e.message,
|
|
data: e.crc32,
|
|
size: e.size
|
|
} : e.extra
|
|
, o = (i.errorCode = (null == (o = e.extra) ? void 0 : o.errorCode) || e.errorCode || 1003e3,
|
|
tr(this.currentCtx, {
|
|
extra: i,
|
|
sliceIndex: n,
|
|
stage: "process",
|
|
req: {},
|
|
res: {},
|
|
totalDuration: r + t,
|
|
sliceStartTime: e.sliceStartTime,
|
|
sliceEndTime: e.sliceEndTime,
|
|
sliceDuration: e.sliceDuration,
|
|
crc32StartTime: e.crc32StartTime,
|
|
crc32EndTime: e.crc32EndTime,
|
|
crc32Duration: e.crc32Duration
|
|
}));
|
|
return e.xhr && (i = e.xhr,
|
|
o.req = {
|
|
url: e.xhr.currentUrl
|
|
},
|
|
o.res = {
|
|
status: i.status,
|
|
body: i.responseText,
|
|
header: i.getAllResponseHeaders()
|
|
},
|
|
delete e.xhr),
|
|
o
|
|
}
|
|
}],
|
|
ti(r.prototype, o),
|
|
Object.defineProperty(r, "prototype", {
|
|
writable: !1
|
|
}),
|
|
c
|
|
}();
|
|
function tc(e) {
|
|
return (tc = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
|
|
return typeof e
|
|
}
|
|
: function(e) {
|
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
}
|
|
)(e)
|
|
}
|
|
function tu() {
|
|
return (tu = Object.assign ? Object.assign.bind() : function(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r, n = arguments[t];
|
|
for (r in n)
|
|
Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r])
|
|
}
|
|
return e
|
|
}
|
|
).apply(this, arguments)
|
|
}
|
|
function tl(e, t) {
|
|
var r, n = Object.keys(e);
|
|
return Object.getOwnPropertySymbols && (r = Object.getOwnPropertySymbols(e),
|
|
t && (r = r.filter(function(t) {
|
|
return Object.getOwnPropertyDescriptor(e, t).enumerable
|
|
})),
|
|
n.push.apply(n, r)),
|
|
n
|
|
}
|
|
function tf(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var n = t[r];
|
|
n.enumerable = n.enumerable || !1,
|
|
n.configurable = !0,
|
|
"value"in n && (n.writable = !0),
|
|
Object.defineProperty(e, tp(n.key), n)
|
|
}
|
|
}
|
|
function tp(e) {
|
|
return e = function(e, t) {
|
|
if ("object" !== tc(e) || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 === r)
|
|
return ("string" === t ? String : Number)(e);
|
|
if (r = r.call(e, t || "default"),
|
|
"object" !== tc(r))
|
|
return r;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}(e, "string"),
|
|
"symbol" === tc(e) ? e : String(e)
|
|
}
|
|
function th(e, t) {
|
|
return (th = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
|
|
return e.__proto__ = t,
|
|
e
|
|
}
|
|
)(e, t)
|
|
}
|
|
function td(e) {
|
|
return (td = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
|
|
return e.__proto__ || Object.getPrototypeOf(e)
|
|
}
|
|
)(e)
|
|
}
|
|
var tg = function() {
|
|
!function(e, t) {
|
|
if ("function" != typeof t && null !== t)
|
|
throw TypeError("Super expression must either be null or a function");
|
|
e.prototype = Object.create(t && t.prototype, {
|
|
constructor: {
|
|
value: e,
|
|
writable: !0,
|
|
configurable: !0
|
|
}
|
|
}),
|
|
Object.defineProperty(e, "prototype", {
|
|
writable: !1
|
|
}),
|
|
t && th(e, t)
|
|
}(a, n.a);
|
|
var e, t, r, i, o, s = (e = a,
|
|
t = function() {
|
|
if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham)
|
|
return !1;
|
|
if ("function" == typeof Proxy)
|
|
return !0;
|
|
try {
|
|
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
|
!0
|
|
} catch (e) {
|
|
return !1
|
|
}
|
|
}(),
|
|
function() {
|
|
var r = td(e);
|
|
return function(e, t) {
|
|
if (t && ("object" === tc(t) || "function" == typeof t))
|
|
return t;
|
|
if (void 0 !== t)
|
|
throw TypeError("Derived constructors may only return object or undefined");
|
|
return function(e) {
|
|
if (void 0 !== e)
|
|
return e;
|
|
throw ReferenceError("this hasn't been initialised - super() hasn't been called")
|
|
}(e)
|
|
}(this, t ? Reflect.construct(r, arguments, td(this).constructor) : r.apply(this, arguments))
|
|
}
|
|
);
|
|
function a(e, t) {
|
|
var r;
|
|
return function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, a),
|
|
(r = s.call(this)).options = e,
|
|
r.config = t,
|
|
r.transport = new ev,
|
|
r.eventInit(),
|
|
r.errorCount = 0,
|
|
r.uploaderCtx = e.context,
|
|
r.currFileCtx = e.context.tasks[e.key],
|
|
r
|
|
}
|
|
return r = a,
|
|
i = [{
|
|
key: "mergeFile",
|
|
value: function() {
|
|
for (var e = {
|
|
oid: this.currFileCtx.oid,
|
|
uploadId: this.currFileCtx.UploadID,
|
|
tosDomain: this.currFileCtx.tosDomain
|
|
}, t = this.currFileCtx.crc32Array, r = "", n = 0; n < t.length; n++)
|
|
r = (r ? "".concat(r, ",") : "").concat(n + 1, ":").concat(t[n].crc32);
|
|
var e = eh.urlTemplate("{tosDomain}/upload/v1/{oid}?uploadmode=part&phase=finish&uploadid={uploadId}", e)
|
|
, i = this.config.userId
|
|
, i = function(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r = null != arguments[t] ? arguments[t] : {};
|
|
t % 2 ? tl(Object(r), !0).forEach(function(t) {
|
|
var n, i, o;
|
|
n = e,
|
|
i = t,
|
|
o = r[t],
|
|
(i = tp(i))in n ? Object.defineProperty(n, i, {
|
|
value: o,
|
|
enumerable: !0,
|
|
configurable: !0,
|
|
writable: !0
|
|
}) : n[i] = o
|
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : tl(Object(r)).forEach(function(t) {
|
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t))
|
|
})
|
|
}
|
|
return e
|
|
}({
|
|
Authorization: this.currFileCtx.signature,
|
|
"X-Storage-U": encodeURIComponent(i)
|
|
}, this.currFileCtx.UploadHeader);
|
|
this.config.clientEncrypt && (i["x-upload-encryption-mode"] = 2,
|
|
i["x-upload-encryption-key"] = btoa(this.currFileCtx.clientEncryptKey)),
|
|
this.transport.send({
|
|
method: "post",
|
|
url: e,
|
|
headers: i,
|
|
custom: r
|
|
})
|
|
}
|
|
}, {
|
|
key: "start",
|
|
value: function(e, t, r) {
|
|
this.successProcess = t,
|
|
this.failProcess = r,
|
|
this._st = Date.now(),
|
|
this.mergeFile()
|
|
}
|
|
}, {
|
|
key: "eventInit",
|
|
value: function() {
|
|
var e = this
|
|
, t = this.options.stage;
|
|
this.transport.on("complete", function(r) {
|
|
var n = null;
|
|
try {
|
|
var i, o = JSON.parse(r.response);
|
|
if (2e3 !== o.code || null == (i = o.data) || !i.key)
|
|
return e.fail({
|
|
error: "fail! response.code: ".concat(o.code, ", fail message: ").concat(o.message),
|
|
xhr: r,
|
|
errorCode: o.code
|
|
});
|
|
n = tu(e.currFileCtx, {
|
|
stage: t,
|
|
type: "success",
|
|
hasMerge: !0,
|
|
extra: {
|
|
message: "merge file success"
|
|
},
|
|
xhr: r,
|
|
stageStartTime: e._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - e._st,
|
|
totalDuration: Date.now() - e._st + e.currFileCtx.totalDuration
|
|
})
|
|
} catch (t) {
|
|
return e.fail({
|
|
error: "response parse error: ".concat(t.message || JSON.stringify(t)),
|
|
xhr: r
|
|
})
|
|
}
|
|
return e.successProcess(n)
|
|
}),
|
|
this.transport.on("error", function(t) {
|
|
e.fail({
|
|
error: "request fail: ".concat(t.statusText || t.errText),
|
|
xhr: t
|
|
})
|
|
})
|
|
}
|
|
}, {
|
|
key: "getProcessIndex",
|
|
value: function(e) {
|
|
var t = 0;
|
|
return e.forEach(function(e, r) {
|
|
"process" === e.stage && (t = r)
|
|
}),
|
|
t
|
|
}
|
|
}, {
|
|
key: "fail",
|
|
value: function(e) {
|
|
e = tu(this.currFileCtx, {
|
|
extra: {
|
|
message: "merge file error, ".concat(e.error),
|
|
errorCode: e.errorCode || 1004e3
|
|
},
|
|
type: "error",
|
|
stage: this.options.stage,
|
|
xhr: e.xhr,
|
|
stageStartTime: this._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - this._st,
|
|
totalDuration: Date.now() - this._st + this.currFileCtx.totalDuration
|
|
}),
|
|
this.failProcess(e)
|
|
}
|
|
}],
|
|
tf(r.prototype, i),
|
|
Object.defineProperty(r, "prototype", {
|
|
writable: !1
|
|
}),
|
|
a
|
|
}();
|
|
function ty(e) {
|
|
return (ty = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
|
|
return typeof e
|
|
}
|
|
: function(e) {
|
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
}
|
|
)(e)
|
|
}
|
|
function tm() {
|
|
return (tm = Object.assign ? Object.assign.bind() : function(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r, n = arguments[t];
|
|
for (r in n)
|
|
Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r])
|
|
}
|
|
return e
|
|
}
|
|
).apply(this, arguments)
|
|
}
|
|
function tv(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var n, i = t[r];
|
|
i.enumerable = i.enumerable || !1,
|
|
i.configurable = !0,
|
|
"value"in i && (i.writable = !0),
|
|
Object.defineProperty(e, (n = function(e, t) {
|
|
if ("object" !== ty(e) || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 === r)
|
|
return ("string" === t ? String : Number)(e);
|
|
if (r = r.call(e, t || "default"),
|
|
"object" !== ty(r))
|
|
return r;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}(n = i.key, "string"),
|
|
"symbol" === ty(n) ? n : String(n)), i)
|
|
}
|
|
}
|
|
function tb(e, t) {
|
|
return (tb = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
|
|
return e.__proto__ = t,
|
|
e
|
|
}
|
|
)(e, t)
|
|
}
|
|
function t_(e) {
|
|
return (t_ = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
|
|
return e.__proto__ || Object.getPrototypeOf(e)
|
|
}
|
|
)(e)
|
|
}
|
|
var tS = function() {
|
|
!function(e, t) {
|
|
if ("function" != typeof t && null !== t)
|
|
throw TypeError("Super expression must either be null or a function");
|
|
e.prototype = Object.create(t && t.prototype, {
|
|
constructor: {
|
|
value: e,
|
|
writable: !0,
|
|
configurable: !0
|
|
}
|
|
}),
|
|
Object.defineProperty(e, "prototype", {
|
|
writable: !1
|
|
}),
|
|
t && tb(e, t)
|
|
}(c, n.a);
|
|
var e, t, r, i, s, a = (e = c,
|
|
t = function() {
|
|
if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham)
|
|
return !1;
|
|
if ("function" == typeof Proxy)
|
|
return !0;
|
|
try {
|
|
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
|
!0
|
|
} catch (e) {
|
|
return !1
|
|
}
|
|
}(),
|
|
function() {
|
|
var r = t_(e);
|
|
return function(e, t) {
|
|
if (t && ("object" === ty(t) || "function" == typeof t))
|
|
return t;
|
|
if (void 0 !== t)
|
|
throw TypeError("Derived constructors may only return object or undefined");
|
|
return function(e) {
|
|
if (void 0 !== e)
|
|
return e;
|
|
throw ReferenceError("this hasn't been initialised - super() hasn't been called")
|
|
}(e)
|
|
}(this, t ? Reflect.construct(r, arguments, t_(this).constructor) : r.apply(this, arguments))
|
|
}
|
|
);
|
|
function c(e) {
|
|
var t, r = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {};
|
|
return function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, c),
|
|
(t = a.call(this)).options = e,
|
|
t.file = e.file,
|
|
t.context = e.context,
|
|
t.key = e.key,
|
|
t.isImageBatchUpload = e.isImageBatchUpload,
|
|
t.config = r,
|
|
t.finishArr = [],
|
|
t.errorLength = 0,
|
|
t.finishSize = 0,
|
|
t.retryUploadTime = t.config.retryUploadTime || 0,
|
|
t.processRetry = 0,
|
|
t.lastFinishSize = -1,
|
|
t.lastProcessPercent = -1,
|
|
t.lastIntervalSize = -1,
|
|
t.uploader = {},
|
|
t._uploadProcessMap = {},
|
|
t
|
|
}
|
|
return r = c,
|
|
i = [{
|
|
key: "start",
|
|
value: function(e, t, r) {
|
|
this.failProcess = r,
|
|
this.successProcess = t,
|
|
this.currentCtx = this.context.tasks[this.key],
|
|
this.crc32Array = this.context.tasks[this.key].crc32Array,
|
|
this._uploadSize = this.isImageBatchUpload ? this.currentCtx.fileSize.reduce(function(e, t) {
|
|
return e + t
|
|
}) : this.file.size,
|
|
this._st = Date.now(),
|
|
this.upload()
|
|
}
|
|
}, {
|
|
key: "stop",
|
|
value: function() {
|
|
var e = this;
|
|
this.uploader && Object.keys(this.uploader).forEach(function(t) {
|
|
e.uploader[t] && (e.uploader[t].abort(),
|
|
e.uploader[t].destroy())
|
|
})
|
|
}
|
|
}, {
|
|
key: "upload",
|
|
value: function() {
|
|
for (var e = this, t = this.crc32Array.length, r = 0, n = 0, i = 0; i < t; i++) {
|
|
var s = this.crc32Array[i]
|
|
, a = s.buffer
|
|
, s = s.crc32
|
|
, c = this.currentCtx.signature
|
|
, c = "[object Array]" === Object.prototype.toString.call(c) ? c[i] : c
|
|
, u = this.currentCtx.oid
|
|
, u = "[object Array]" === Object.prototype.toString.call(u) ? u[i] : u
|
|
, l = {
|
|
oid: u,
|
|
tosDomain: this.currentCtx.tosDomain
|
|
}
|
|
, l = eh.urlTemplate(o, l)
|
|
, f = this.config.userId
|
|
, p = void 0
|
|
, h = this.isImageBatchUpload ? (p = this.currentCtx.fileSize[i],
|
|
this.currentCtx.fileName[i]) : (p = this.file.size,
|
|
this.file.name);
|
|
this._uploadProcessMap[s] && this._uploadProcessMap[s].success ? r += 1 : (this._uploadProcessMap[s] = {
|
|
crc32: s,
|
|
fileSize: p,
|
|
fileName: h,
|
|
oid: u,
|
|
finishSize: 0,
|
|
success: !1
|
|
},
|
|
(p = new e9({
|
|
sliceItem: a,
|
|
crc32: s,
|
|
url: l,
|
|
signature: c,
|
|
uploadHeader: this.currentCtx.UploadHeader,
|
|
userId: f,
|
|
retryTime: this.retryUploadTime,
|
|
method: "POST",
|
|
timeout: this.config.uploadTimeout
|
|
})).on("complete", function(i) {
|
|
r++,
|
|
e._uploadProcessMap[i.crc32].finishSize = i.size,
|
|
e._uploadProcessMap[i.crc32].success = !0,
|
|
n + r === t && e.success(i.xhr)
|
|
}),
|
|
p.on("error", function(r) {
|
|
++n === t && e.fail(r)
|
|
}),
|
|
p.on("progress", function(t) {
|
|
e.process(t)
|
|
}),
|
|
p.upload(),
|
|
this.uploader[s] = p)
|
|
}
|
|
}
|
|
}, {
|
|
key: "success",
|
|
value: function(e) {
|
|
this.finishArr = [];
|
|
var t = Date.now() - this._st
|
|
, t = this._uploadSize / t
|
|
, r = tm(this.currentCtx, {
|
|
type: "success",
|
|
stage: "process",
|
|
percent: 99,
|
|
extra: {
|
|
message: "direct upload success"
|
|
},
|
|
speed: t,
|
|
xhr: e,
|
|
stageStartTime: this._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - this._st,
|
|
totalDuration: Date.now() - this._st + this.currentCtx.totalDuration
|
|
});
|
|
this.isImageBatchUpload && (r.successImage = [],
|
|
r.failImage = [],
|
|
Object.values(this._uploadProcessMap).forEach(function(e) {
|
|
(e.success ? r.successImage : r.failImage).push(e)
|
|
})),
|
|
this.uploader = null,
|
|
this._uploadProcessMap = null,
|
|
this.successProcess(r)
|
|
}
|
|
}, {
|
|
key: "fail",
|
|
value: function(e) {
|
|
e = tm(this.currentCtx, {
|
|
extra: {
|
|
message: "direct upload error: ".concat(e.message || e.xhr.errText),
|
|
errorCode: e.errorCode || 1003e3
|
|
},
|
|
type: "error",
|
|
stage: "process",
|
|
xhr: e.xhr,
|
|
stageStartTime: this._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - this._st,
|
|
totalDuration: Date.now() - this._st + this.currentCtx.totalDuration
|
|
}),
|
|
this.isImageBatchUpload && (e.failImage = Object.values(this._uploadProcessMap)),
|
|
this.uploader = null,
|
|
this._uploadProcessMap = null,
|
|
this.failProcess(e)
|
|
}
|
|
}, {
|
|
key: "process",
|
|
value: function(e) {
|
|
var t = this._uploadSize
|
|
, e = (this._uploadProcessMap[e.crc32].finishSize = Math.max(this._uploadProcessMap[e.crc32].finishSize, e.loaded),
|
|
this.finishSize = Object.values(this._uploadProcessMap).reduce(function(e, t) {
|
|
return e + t.finishSize
|
|
}, 0),
|
|
this.finishSize > this.lastFinishSize && (this.lastFinishSize = this.finishSize),
|
|
Math.floor(this.finishSize / t * 100) || 0)
|
|
, t = tm(this.currentCtx, {
|
|
stage: "process",
|
|
percent: e
|
|
});
|
|
e > this.lastProcessPercent && 100 !== e && (this.lastProcessPercent = e,
|
|
this.context._broadcast("progress", t))
|
|
}
|
|
}],
|
|
tv(r.prototype, i),
|
|
Object.defineProperty(r, "prototype", {
|
|
writable: !1
|
|
}),
|
|
c
|
|
}();
|
|
function tx(e) {
|
|
return (tx = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
|
|
return typeof e
|
|
}
|
|
: function(e) {
|
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
}
|
|
)(e)
|
|
}
|
|
function tw() {
|
|
return (tw = Object.assign ? Object.assign.bind() : function(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r, n = arguments[t];
|
|
for (r in n)
|
|
Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r])
|
|
}
|
|
return e
|
|
}
|
|
).apply(this, arguments)
|
|
}
|
|
function tk(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var n, i = t[r];
|
|
i.enumerable = i.enumerable || !1,
|
|
i.configurable = !0,
|
|
"value"in i && (i.writable = !0),
|
|
Object.defineProperty(e, (n = function(e, t) {
|
|
if ("object" !== tx(e) || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 === r)
|
|
return ("string" === t ? String : Number)(e);
|
|
if (r = r.call(e, t || "default"),
|
|
"object" !== tx(r))
|
|
return r;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}(n = i.key, "string"),
|
|
"symbol" === tx(n) ? n : String(n)), i)
|
|
}
|
|
}
|
|
function tE(e, t) {
|
|
return (tE = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
|
|
return e.__proto__ = t,
|
|
e
|
|
}
|
|
)(e, t)
|
|
}
|
|
function tO(e) {
|
|
return (tO = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
|
|
return e.__proto__ || Object.getPrototypeOf(e)
|
|
}
|
|
)(e)
|
|
}
|
|
var tT = function() {
|
|
!function(e, t) {
|
|
if ("function" != typeof t && null !== t)
|
|
throw TypeError("Super expression must either be null or a function");
|
|
e.prototype = Object.create(t && t.prototype, {
|
|
constructor: {
|
|
value: e,
|
|
writable: !0,
|
|
configurable: !0
|
|
}
|
|
}),
|
|
Object.defineProperty(e, "prototype", {
|
|
writable: !1
|
|
}),
|
|
t && tE(e, t)
|
|
}(c, n.a);
|
|
var e, t, r, o, s, a = (e = c,
|
|
t = function() {
|
|
if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham)
|
|
return !1;
|
|
if ("function" == typeof Proxy)
|
|
return !0;
|
|
try {
|
|
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
|
!0
|
|
} catch (e) {
|
|
return !1
|
|
}
|
|
}(),
|
|
function() {
|
|
var r = tO(e);
|
|
return function(e, t) {
|
|
if (t && ("object" === tx(t) || "function" == typeof t))
|
|
return t;
|
|
if (void 0 !== t)
|
|
throw TypeError("Derived constructors may only return object or undefined");
|
|
return function(e) {
|
|
if (void 0 !== e)
|
|
return e;
|
|
throw ReferenceError("this hasn't been initialised - super() hasn't been called")
|
|
}(e)
|
|
}(this, t ? Reflect.construct(r, arguments, tO(this).constructor) : r.apply(this, arguments))
|
|
}
|
|
);
|
|
function c(e) {
|
|
var t, r = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {};
|
|
return function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, c),
|
|
(t = a.call(this)).options = e,
|
|
t.file = e.file,
|
|
t.context = e.context,
|
|
t.key = e.key,
|
|
t.config = r,
|
|
t.errorLength = 0,
|
|
t.retryUploadTime = Number(r.retryUploadTime),
|
|
t.maxUploadSliceCount = Number(r.uploadSliceCount),
|
|
t.uploadQueue = [],
|
|
t.crc32Array = [],
|
|
t.uploadSliceCount = 0,
|
|
t.isCalcCrc32 = !1,
|
|
t.isFileReading = !1,
|
|
t.hasStarted = !1,
|
|
t.hasCompleteUpload = !1,
|
|
t
|
|
}
|
|
return r = c,
|
|
o = [{
|
|
key: "start",
|
|
value: function(e, t, r) {
|
|
this.failProcess = r,
|
|
this.successProcess = t,
|
|
this.currentCtx = this.context.tasks[this.key],
|
|
this.hasStarted = !0,
|
|
this._st = Date.now(),
|
|
this.initWorker()
|
|
}
|
|
}, {
|
|
key: "initWorker",
|
|
value: function() {
|
|
var e = this;
|
|
this.worker || (this.worker = new te.a,
|
|
this.worker.onmessage = function(t) {
|
|
e.isCalcCrc32 = !1;
|
|
var r = t.data[0]
|
|
, n = t.data[2]
|
|
, i = t.data[1];
|
|
e.uploadQueue.forEach(function(t, o) {
|
|
t.index === n && (e.uploadQueue[o].crc32 = i,
|
|
e.uploadQueue[o].fileSliceBuffer = r,
|
|
e.crc32Array[n] = {
|
|
crc32: i
|
|
})
|
|
}),
|
|
e.startUploadQueue()
|
|
}
|
|
,
|
|
this.startUploadQueue())
|
|
}
|
|
}, {
|
|
key: "addStreamSlice",
|
|
value: function(e) {
|
|
var t = this
|
|
, r = e.fileSlice
|
|
, n = e.index
|
|
, e = (this.isFileReading = !0,
|
|
new FileReader);
|
|
e.readAsArrayBuffer(r),
|
|
e.onload = function(e) {
|
|
t.isFileReading = !1,
|
|
e = e.target.result,
|
|
t.uploadQueue.push({
|
|
fileSliceBuffer: e,
|
|
index: n
|
|
}),
|
|
t.hasStarted && t.startUploadQueue()
|
|
}
|
|
}
|
|
}, {
|
|
key: "completeStreamUpload",
|
|
value: function() {
|
|
this.hasCompleteUpload = !0,
|
|
0 !== this.uploadQueue.length || this.isFileReading || this.success()
|
|
}
|
|
}, {
|
|
key: "startUploadQueue",
|
|
value: function() {
|
|
var e;
|
|
this.uploadSliceCount <= this.maxUploadSliceCount && 0 < this.uploadQueue.length && this.uploadQueue[0].crc32 ? (e = this.uploadQueue.shift(),
|
|
this.uploadSliceCount++,
|
|
this.upload({
|
|
sliceItem: e.fileSliceBuffer,
|
|
index: e.index,
|
|
crc32: e.crc32
|
|
})) : 0 < this.uploadQueue.length && !this.uploadQueue[0].crc32 && this.startCrc32Queue()
|
|
}
|
|
}, {
|
|
key: "startCrc32Queue",
|
|
value: function() {
|
|
if (!this.isCalcCrc32)
|
|
for (var e = 0; e < this.uploadQueue.length; e++) {
|
|
var t = this.uploadQueue[e];
|
|
if (!t.crc32) {
|
|
this.isCalcCrc32 = !0,
|
|
this.worker.postMessage([t.fileSliceBuffer, t.index], [t.fileSliceBuffer]);
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}, {
|
|
key: "upload",
|
|
value: function(e) {
|
|
var t = this
|
|
, r = e.sliceItem
|
|
, n = e.index
|
|
, e = e.crc32
|
|
, o = this.currentCtx.signature
|
|
, s = {
|
|
part_number: n + 1,
|
|
uploadId: this.currentCtx.UploadID,
|
|
oid: this.currentCtx.oid,
|
|
tosDomain: this.currentCtx.tosDomain
|
|
}
|
|
, s = eh.urlTemplate(i, s)
|
|
, a = this.config.userId
|
|
, r = new e9({
|
|
sliceItem: r,
|
|
crc32: e,
|
|
url: s,
|
|
signature: o,
|
|
uploadHeader: this.currentCtx.UploadHeader,
|
|
userId: a,
|
|
retryTime: this.retryUploadTime,
|
|
method: "POST",
|
|
timeout: this.config.uploadTimeout
|
|
});
|
|
r.on("complete", function(e) {
|
|
1 === t.currentCtx.status && (e.index = n,
|
|
t.fileSliceSuccess(e))
|
|
}),
|
|
r.on("error", function(e) {
|
|
1 === t.currentCtx.status && (e.index = n,
|
|
t.fail(e))
|
|
}),
|
|
r.upload()
|
|
}
|
|
}, {
|
|
key: "fileSliceSuccess",
|
|
value: function(e) {
|
|
var t = e.index
|
|
, r = Date.now()
|
|
, n = {
|
|
message: "stream slice upload success"
|
|
}
|
|
, i = (e.xhr && (i = e.xhr,
|
|
n.currentUrl = i.currentUrl || "",
|
|
tw(this.currentCtx, {
|
|
req: {
|
|
url: i.currentUrl,
|
|
param: i.params
|
|
},
|
|
res: {
|
|
status: i.status,
|
|
body: i.responseText,
|
|
header: i.getAllResponseHeaders()
|
|
}
|
|
}),
|
|
delete e.xhr),
|
|
this.context.logger.send(tw(this.currentCtx, {
|
|
stage: "process",
|
|
type: "success",
|
|
sliceIndex: t,
|
|
extra: n,
|
|
totalDuration: r - this._lastSaveTime + this.currentCtx.totalDuration
|
|
})),
|
|
tw(this.currentCtx, {
|
|
uploadQueueLength: this.uploadQueue.length,
|
|
sliceIndex: t
|
|
}));
|
|
this.context._broadcast("stream-progress", i),
|
|
this.uploadSliceCount--,
|
|
this.hasCompleteUpload && 0 === this.uploadQueue.length ? this.success(e.xhr) : this.startUploadQueue()
|
|
}
|
|
}, {
|
|
key: "success",
|
|
value: function(e) {
|
|
this.isAllSuccess || (e = tw(this.currentCtx, {
|
|
type: "success",
|
|
stage: "process",
|
|
percent: 100,
|
|
extra: {
|
|
message: "all slice upload success"
|
|
},
|
|
crc32Array: this.crc32Array,
|
|
xhr: e,
|
|
stageStartTime: this._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - this._st,
|
|
totalDuration: Date.now() - this._st + this.currentCtx.totalDuration
|
|
}),
|
|
this.successProcess(e))
|
|
}
|
|
}, {
|
|
key: "fail",
|
|
value: function(e) {
|
|
var t = e.index
|
|
, e = tw(this.currentCtx, {
|
|
extra: {
|
|
message: "stream slice upload error"
|
|
},
|
|
type: "error",
|
|
stage: "process",
|
|
xhr: e.xhr,
|
|
stageStartTime: this._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - this._st,
|
|
totalDuration: Date.now() - this._st + this.currentCtx.totalDuration,
|
|
sliceIndex: t
|
|
});
|
|
this.context.logger.send(tw({}, e)),
|
|
this.context._broadcast("error", e)
|
|
}
|
|
}],
|
|
tk(r.prototype, o),
|
|
Object.defineProperty(r, "prototype", {
|
|
writable: !1
|
|
}),
|
|
c
|
|
}();
|
|
function tC(e) {
|
|
return (tC = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
|
|
return typeof e
|
|
}
|
|
: function(e) {
|
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
}
|
|
)(e)
|
|
}
|
|
function tD(e, t) {
|
|
var r, n = Object.keys(e);
|
|
return Object.getOwnPropertySymbols && (r = Object.getOwnPropertySymbols(e),
|
|
t && (r = r.filter(function(t) {
|
|
return Object.getOwnPropertyDescriptor(e, t).enumerable
|
|
})),
|
|
n.push.apply(n, r)),
|
|
n
|
|
}
|
|
function tj(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r = null != arguments[t] ? arguments[t] : {};
|
|
t % 2 ? tD(Object(r), !0).forEach(function(t) {
|
|
var n, i, o;
|
|
n = e,
|
|
i = t,
|
|
o = r[t],
|
|
(i = tz(i))in n ? Object.defineProperty(n, i, {
|
|
value: o,
|
|
enumerable: !0,
|
|
configurable: !0,
|
|
writable: !0
|
|
}) : n[i] = o
|
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : tD(Object(r)).forEach(function(t) {
|
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t))
|
|
})
|
|
}
|
|
return e
|
|
}
|
|
function tI() {
|
|
return (tI = Object.assign ? Object.assign.bind() : function(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r, n = arguments[t];
|
|
for (r in n)
|
|
Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r])
|
|
}
|
|
return e
|
|
}
|
|
).apply(this, arguments)
|
|
}
|
|
function tP(e, t) {
|
|
return function(e) {
|
|
if (Array.isArray(e))
|
|
return e
|
|
}(e) || function(e, t) {
|
|
var r = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
|
|
if (null != r) {
|
|
var n, i, o, s, a = [], c = !0, u = !1;
|
|
try {
|
|
if (o = (r = r.call(e)).next,
|
|
0 === t) {
|
|
if (Object(r) !== r)
|
|
return;
|
|
c = !1
|
|
} else
|
|
for (; !(c = (n = o.call(r)).done) && (a.push(n.value),
|
|
a.length !== t); c = !0)
|
|
;
|
|
} catch (e) {
|
|
u = !0,
|
|
i = e
|
|
} finally {
|
|
try {
|
|
if (!c && null != r.return && (s = r.return(),
|
|
Object(s) !== s))
|
|
return
|
|
} finally {
|
|
if (u)
|
|
throw i
|
|
}
|
|
}
|
|
return a
|
|
}
|
|
}(e, t) || function(e, t) {
|
|
var r;
|
|
if (e)
|
|
return "string" == typeof e ? tA(e, t) : "Map" === (r = "Object" === (r = Object.prototype.toString.call(e).slice(8, -1)) && e.constructor ? e.constructor.name : r) || "Set" === r ? Array.from(e) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? tA(e, t) : void 0
|
|
}(e, t) || function() {
|
|
throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
|
|
}()
|
|
}
|
|
function tA(e, t) {
|
|
(null == t || t > e.length) && (t = e.length);
|
|
for (var r = 0, n = Array(t); r < t; r++)
|
|
n[r] = e[r];
|
|
return n
|
|
}
|
|
function tR(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var n = t[r];
|
|
n.enumerable = n.enumerable || !1,
|
|
n.configurable = !0,
|
|
"value"in n && (n.writable = !0),
|
|
Object.defineProperty(e, tz(n.key), n)
|
|
}
|
|
}
|
|
function tz(e) {
|
|
return e = function(e, t) {
|
|
if ("object" !== tC(e) || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 === r)
|
|
return ("string" === t ? String : Number)(e);
|
|
if (r = r.call(e, t || "default"),
|
|
"object" !== tC(r))
|
|
return r;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}(e, "string"),
|
|
"symbol" === tC(e) ? e : String(e)
|
|
}
|
|
function tB(e, t) {
|
|
return (tB = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
|
|
return e.__proto__ = t,
|
|
e
|
|
}
|
|
)(e, t)
|
|
}
|
|
function tU(e) {
|
|
return (tU = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
|
|
return e.__proto__ || Object.getPrototypeOf(e)
|
|
}
|
|
)(e)
|
|
}
|
|
var tM = function() {
|
|
!function(e, t) {
|
|
if ("function" != typeof t && null !== t)
|
|
throw TypeError("Super expression must either be null or a function");
|
|
e.prototype = Object.create(t && t.prototype, {
|
|
constructor: {
|
|
value: e,
|
|
writable: !0,
|
|
configurable: !0
|
|
}
|
|
}),
|
|
Object.defineProperty(e, "prototype", {
|
|
writable: !1
|
|
}),
|
|
t && tB(e, t)
|
|
}(a, n.a);
|
|
var e, t, r, i, o, s = (e = a,
|
|
t = function() {
|
|
if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham)
|
|
return !1;
|
|
if ("function" == typeof Proxy)
|
|
return !0;
|
|
try {
|
|
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
|
!0
|
|
} catch (e) {
|
|
return !1
|
|
}
|
|
}(),
|
|
function() {
|
|
var r = tU(e);
|
|
return function(e, t) {
|
|
if (t && ("object" === tC(t) || "function" == typeof t))
|
|
return t;
|
|
if (void 0 !== t)
|
|
throw TypeError("Derived constructors may only return object or undefined");
|
|
return function(e) {
|
|
if (void 0 !== e)
|
|
return e;
|
|
throw ReferenceError("this hasn't been initialised - super() hasn't been called")
|
|
}(e)
|
|
}(this, t ? Reflect.construct(r, arguments, tU(this).constructor) : r.apply(this, arguments))
|
|
}
|
|
);
|
|
function a(e, t) {
|
|
var r;
|
|
return function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, a),
|
|
(r = s.call(this)).options = e,
|
|
r.config = t,
|
|
r.uploaderCtx = e.context,
|
|
r.currFileCtx = e.context.tasks[e.key],
|
|
r.isImageBatchUpload = !!r.options.isImageBatchUpload,
|
|
r.skipCommit = e.skipCommit,
|
|
r.transport = new ev,
|
|
r.eventInit(),
|
|
r
|
|
}
|
|
return r = a,
|
|
i = [{
|
|
key: "commitUpload",
|
|
value: function() {
|
|
var e, t, r = this.config.region, n = "", i = {}, o = this.uploaderCtx.useBackupDomain, s = eG.checkServiceName(this.options.type, this.config, this.options.serviceType), o = (s === es && (n = o ? this.config.imageFallbackHost : this.config.imageHost,
|
|
i = (t = tP(this.createImageXParams(), 3))[0],
|
|
e = t[1],
|
|
t = t[2]),
|
|
"vod" === s && (n = o ? this.config.videoFallbackHost : this.config.videoHost,
|
|
i = (o = tP(this.createVodParams(), 3))[0],
|
|
e = o[1],
|
|
t = o[2]),
|
|
this.config.accountId && (i["X-Account-Id"] = this.config.accountId),
|
|
this.config.openExperiment && (i.app_id = this.config.appId,
|
|
i.user_id = this.config.userId),
|
|
eh.toQueryString(i)), a = this.currFileCtx.proxyStsToken || this.config.stsToken, c = a.AccessKeyID, u = a.AccessKeyId, l = a.SecretAccessKey, a = a.SessionToken, o = {
|
|
method: "POST",
|
|
url: "".concat(n, "?").concat(o),
|
|
timeout: this.config.gatewayTimeout,
|
|
region: r,
|
|
params: i,
|
|
headers: {},
|
|
pathname: eh.getPathByURL(n)
|
|
}, r = (o.custom = t,
|
|
o.body = e,
|
|
s === es && (o.headers["Content-Type"] = "application/json"),
|
|
new eb.a(o,s)), i = this.currFileCtx.systemTimeGap, n = i ? new Date((new Date).getTime() + i) : new Date;
|
|
r.addAuthorization({
|
|
accessKeyId: u || c,
|
|
secretAccessKey: l,
|
|
sessionToken: a
|
|
}, n),
|
|
this.transport.send(o)
|
|
}
|
|
}, {
|
|
key: "createImageXParams",
|
|
value: function() {
|
|
var e = {
|
|
Action: "CommitImageUpload",
|
|
Version: "2018-08-01"
|
|
}
|
|
, t = {
|
|
SessionKey: this.currFileCtx.SessionKey
|
|
}
|
|
, r = (this.options.type === en && (this.config.imageConfig && this.config.imageConfig.serviceId ? e.ServiceId = this.config.imageConfig.serviceId : e.SpaceName = this.config.videoConfig && this.config.videoConfig.spaceName,
|
|
Array.isArray(r = this.config.imageConfig && this.config.imageConfig.processAction) && 0 < r.length && (t.Functions = r),
|
|
this.config.skipMeta) && (e.SkipMeta = !0),
|
|
this.options.type === ei && (e.ServiceId = this.config.objectConfig && this.config.objectConfig.serviceId || this.config.imageConfig && this.config.imageConfig.serviceId),
|
|
JSON.stringify(t));
|
|
return [e, t, r]
|
|
}
|
|
}, {
|
|
key: "createVodParams",
|
|
value: function() {
|
|
var e = null == (e = this.config.videoConfig) ? void 0 : e.spaceName
|
|
, t = {
|
|
Action: "CommitUploadInner",
|
|
Version: "2020-11-19",
|
|
SpaceName: e = this.options.type === ei && null != (t = this.config.objectConfig) && t.spaceName ? null == (t = this.config.objectConfig) ? void 0 : t.spaceName : e
|
|
}
|
|
, e = {
|
|
SessionKey: this.currFileCtx.SessionKey,
|
|
Functions: []
|
|
}
|
|
, r = this.config.videoConfig && this.config.videoConfig.processAction
|
|
, n = (this.options.type === ei && null != (n = this.config.objectConfig) && n.processAction && (r = null == (n = this.config.objectConfig) ? void 0 : n.processAction),
|
|
Array.isArray(r) && 0 < r.length && (e.Functions = r),
|
|
(this.config.videoConfig && this.config.videoConfig.callbackArgs || this.options.callbackArgs) && (e.CallbackArgs = this.options.callbackArgs || this.config.videoConfig.callbackArgs),
|
|
this.options.type === er && this.config.skipDownload && (t.SkipDownload = !0),
|
|
this.options.type === ei && this.options.objectSync && (e.ObjectSync = this.options.objectSync),
|
|
this.options.type === er && this.options.needExactFormat && (e.needExactFormat = this.options.needExactFormat),
|
|
JSON.stringify(e));
|
|
return [t, e, n]
|
|
}
|
|
}, {
|
|
key: "start",
|
|
value: function(e, t, r) {
|
|
if (this.successProcess = t,
|
|
this.failProcess = r,
|
|
this._st = Date.now(),
|
|
this.skipCommit)
|
|
return this.successProcess(tI(this.currFileCtx, {
|
|
stage: "complete",
|
|
type: "success",
|
|
percent: 100,
|
|
extra: {
|
|
message: "upload successful, skip commit"
|
|
},
|
|
stageStartTime: this._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - this._st,
|
|
totalDuration: Date.now() - this._st + this.currFileCtx.totalDuration,
|
|
skipCommit: this.skipCommit
|
|
}));
|
|
try {
|
|
this.commitUpload()
|
|
} catch (e) {
|
|
this.fail({
|
|
error: "catch error: ".concat(e.toString())
|
|
})
|
|
}
|
|
}
|
|
}, {
|
|
key: "eventInit",
|
|
value: function() {
|
|
var e = this;
|
|
this.transport.on("complete", function(t) {
|
|
var r = null;
|
|
try {
|
|
var n = JSON.parse(t.response);
|
|
if (n.ResponseMetadata.Error)
|
|
return e.fail({
|
|
xhr: t,
|
|
errorCode: n.ResponseMetadata.Error.CodeN,
|
|
error: n.ResponseMetadata.Error.Code,
|
|
message: n.ResponseMetadata.Error.Message
|
|
});
|
|
var i, o, s = eG.checkServiceName(e.options.type, e.config, e.options.serviceType), a = n.Result, c = {};
|
|
s === es ? e.isImageBatchUpload ? (i = a.Results,
|
|
o = a.PluginResult || [],
|
|
i.forEach(function(e, t) {
|
|
i[t] = tj(tj({}, i[t]), o[t])
|
|
}),
|
|
c = i) : tI(c = a.Results[0], a.PluginResult && a.PluginResult[0]) : c = a.Results[0],
|
|
r = tI(e.currFileCtx, {
|
|
stage: "complete",
|
|
type: "success",
|
|
percent: 100,
|
|
extra: {
|
|
message: "upload successful"
|
|
},
|
|
uploadResult: c,
|
|
xhr: t,
|
|
stageStartTime: e._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - e._st,
|
|
totalDuration: Date.now() - e._st + e.currFileCtx.totalDuration,
|
|
skipCommit: e.skipCommit
|
|
})
|
|
} catch (r) {
|
|
return e.fail({
|
|
error: "catch error: ".concat(r.message || r.toString()),
|
|
xhr: t
|
|
})
|
|
}
|
|
return e.successProcess(r)
|
|
}),
|
|
this.transport.on("error", function(t) {
|
|
var r = {
|
|
error: "request fail: ".concat(t.statusText || t.errText || "UNKNOWN"),
|
|
xhr: t
|
|
};
|
|
if (t.response)
|
|
try {
|
|
var n = JSON.parse(t.response);
|
|
n.ResponseMetadata && n.ResponseMetadata.Error && (r.errorCode = n.ResponseMetadata.Error.CodeN,
|
|
r.error = n.ResponseMetadata.Error.Code,
|
|
r.message = n.ResponseMetadata.Error.Message)
|
|
} catch (e) {
|
|
r.error = t.response.toString(),
|
|
r.message = t.response.toString()
|
|
}
|
|
e.fail(r)
|
|
})
|
|
}
|
|
}, {
|
|
key: "fail",
|
|
value: function(e) {
|
|
var t = e.xhr
|
|
, r = e.errorCode || 1005e3
|
|
, n = "commit upload error: UNKNOWN"
|
|
, n = (t && (n = 0 === t.status ? "commit upload error: NETERROR" : e.message || "commit upload error: ".concat(t.status)),
|
|
tI(this.currFileCtx, {
|
|
extra: {
|
|
message: n,
|
|
error: e.error,
|
|
errorCode: r
|
|
},
|
|
type: "error",
|
|
stage: "complete",
|
|
xhr: t,
|
|
stageStartTime: this._st,
|
|
stageEndTime: Date.now(),
|
|
duration: Date.now() - this._st,
|
|
totalDuration: Date.now() - this._st + this.currFileCtx.totalDuration,
|
|
skipCommit: this.skipCommit
|
|
}));
|
|
this.failProcess(n)
|
|
}
|
|
}],
|
|
tR(r.prototype, i),
|
|
Object.defineProperty(r, "prototype", {
|
|
writable: !1
|
|
}),
|
|
a
|
|
}();
|
|
function tG(e) {
|
|
return (tG = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
|
|
return typeof e
|
|
}
|
|
: function(e) {
|
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
}
|
|
)(e)
|
|
}
|
|
function tF(e, t) {
|
|
var r, n = Object.keys(e);
|
|
return Object.getOwnPropertySymbols && (r = Object.getOwnPropertySymbols(e),
|
|
t && (r = r.filter(function(t) {
|
|
return Object.getOwnPropertyDescriptor(e, t).enumerable
|
|
})),
|
|
n.push.apply(n, r)),
|
|
n
|
|
}
|
|
function tN(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r = null != arguments[t] ? arguments[t] : {};
|
|
t % 2 ? tF(Object(r), !0).forEach(function(t) {
|
|
var n, i, o;
|
|
n = e,
|
|
i = t,
|
|
o = r[t],
|
|
(i = tK(i))in n ? Object.defineProperty(n, i, {
|
|
value: o,
|
|
enumerable: !0,
|
|
configurable: !0,
|
|
writable: !0
|
|
}) : n[i] = o
|
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : tF(Object(r)).forEach(function(t) {
|
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t))
|
|
})
|
|
}
|
|
return e
|
|
}
|
|
function tH() {
|
|
return (tH = Object.assign ? Object.assign.bind() : function(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r, n = arguments[t];
|
|
for (r in n)
|
|
Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r])
|
|
}
|
|
return e
|
|
}
|
|
).apply(this, arguments)
|
|
}
|
|
function tL(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var n = t[r];
|
|
n.enumerable = n.enumerable || !1,
|
|
n.configurable = !0,
|
|
"value"in n && (n.writable = !0),
|
|
Object.defineProperty(e, tK(n.key), n)
|
|
}
|
|
}
|
|
function tK(e) {
|
|
return e = function(e, t) {
|
|
if ("object" !== tG(e) || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 === r)
|
|
return ("string" === t ? String : Number)(e);
|
|
if (r = r.call(e, t || "default"),
|
|
"object" !== tG(r))
|
|
return r;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}(e, "string"),
|
|
"symbol" === tG(e) ? e : String(e)
|
|
}
|
|
function tq(e, t) {
|
|
return (tq = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
|
|
return e.__proto__ = t,
|
|
e
|
|
}
|
|
)(e, t)
|
|
}
|
|
function tV(e) {
|
|
return (tV = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
|
|
return e.__proto__ || Object.getPrototypeOf(e)
|
|
}
|
|
)(e)
|
|
}
|
|
var tW = function() {
|
|
!function(e, t) {
|
|
if ("function" != typeof t && null !== t)
|
|
throw TypeError("Super expression must either be null or a function");
|
|
e.prototype = Object.create(t && t.prototype, {
|
|
constructor: {
|
|
value: e,
|
|
writable: !0,
|
|
configurable: !0
|
|
}
|
|
}),
|
|
Object.defineProperty(e, "prototype", {
|
|
writable: !1
|
|
}),
|
|
t && tq(e, t)
|
|
}(a, n.a);
|
|
var e, t, r, i, o, s = (e = a,
|
|
t = function() {
|
|
if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham)
|
|
return !1;
|
|
if ("function" == typeof Proxy)
|
|
return !0;
|
|
try {
|
|
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
|
!0
|
|
} catch (e) {
|
|
return !1
|
|
}
|
|
}(),
|
|
function() {
|
|
var r = tV(e);
|
|
return function(e, t) {
|
|
if (t && ("object" === tG(t) || "function" == typeof t))
|
|
return t;
|
|
if (void 0 !== t)
|
|
throw TypeError("Derived constructors may only return object or undefined");
|
|
return function(e) {
|
|
if (void 0 !== e)
|
|
return e;
|
|
throw ReferenceError("this hasn't been initialised - super() hasn't been called")
|
|
}(e)
|
|
}(this, t ? Reflect.construct(r, arguments, tV(this).constructor) : r.apply(this, arguments))
|
|
}
|
|
);
|
|
function a(e, t, r, n) {
|
|
var i;
|
|
return function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, a),
|
|
(i = s.call(this, e)).tasks = e,
|
|
i.config = t,
|
|
i.key = n,
|
|
i.uploaderCtx = r,
|
|
i.current = 0,
|
|
i.length = i.tasks.length,
|
|
i.taskError = {},
|
|
i.uploadList = [],
|
|
i.retryTaskTime = t.retryTaskTime,
|
|
i
|
|
}
|
|
return r = a,
|
|
i = [{
|
|
key: "start",
|
|
value: function(e) {
|
|
var t = this.tasks.shift();
|
|
t && (this.current = t.index,
|
|
this.execTask(t, e))
|
|
}
|
|
}, {
|
|
key: "execTask",
|
|
value: function(e, t) {
|
|
var r, n, i = this, o = e.key, s = this.uploaderCtx, a = s.tasks[o];
|
|
a && (r = a.cacheTask,
|
|
n = s.taskList[o].length,
|
|
r && 0 < e.index && e.index < r ? this.start() : (a.currentTask = e.index,
|
|
1 === a.status && (1 !== e.index && "initUploadID" !== e.stage || (e.arg = tH(e.arg, t)),
|
|
e) && e.func.call(e.context, e.arg, function(r) {
|
|
var c;
|
|
s.taskList[o] && ((c = s.taskList[o][e.index + 1]) && 0 !== e.index && !a.isDirect && i.config.enableDiskBreakpoint ? s._saveTask(o, {
|
|
currentTask: c.index,
|
|
stage: c.stage
|
|
}) : e.index === n - 1 && s._removeTaskCache(o),
|
|
i.success(r),
|
|
0 < i.tasks.length ? i.start(t) : s._queueSuccess(o))
|
|
}, function(r) {
|
|
var n;
|
|
r.xhr && r.xhr.status >= 400 || 3 === e.index && r.isDirect ? i.fail(r) : !i.taskError[o] || i.taskError[o] < i.retryTaskTime ? (i.taskError[o] ? i.taskError[o]++ : i.taskError[o] = 1,
|
|
n = i.errorFormat(r, !0),
|
|
i.uploaderCtx.logger.send(n),
|
|
"initUploadID" === e.stage ? i.execTask(e, tN(tN({}, t), {}, {
|
|
changeNodeRetry: !0
|
|
})) : i.execTask(e, t)) : (r.key = o,
|
|
i.fail(r))
|
|
})))
|
|
}
|
|
}, {
|
|
key: "addTask",
|
|
value: function(e) {
|
|
this.tasks.push(e)
|
|
}
|
|
}, {
|
|
key: "success",
|
|
value: function(e) {
|
|
var t;
|
|
e.xhr && (t = e.xhr,
|
|
e.req = {
|
|
url: t.currentUrl,
|
|
param: t.params
|
|
},
|
|
e.res = {
|
|
status: t.status,
|
|
header: t.getAllResponseHeaders(),
|
|
body: t.responseText
|
|
},
|
|
delete e.xhr),
|
|
tH(e, {
|
|
type: "success"
|
|
});
|
|
try {
|
|
this.uploaderCtx._broadcast(e.stage, e)
|
|
} catch (e) {
|
|
console.error(e)
|
|
}
|
|
this.uploaderCtx.logger.send(e)
|
|
}
|
|
}, {
|
|
key: "fail",
|
|
value: function(e) {
|
|
var t = this.uploaderCtx
|
|
, r = e.key
|
|
, e = this.errorFormat(e);
|
|
try {
|
|
t._broadcast("error", e)
|
|
} catch (e) {}
|
|
t.tasks[r].isBreak ? t._cancel(r) : t._pause(r),
|
|
t.logger.send(e)
|
|
}
|
|
}, {
|
|
key: "cancel",
|
|
value: function(e) {
|
|
var t, r = this.key, n = this.uploaderCtx.tasks[r].currentTask;
|
|
this.uploaderCtx.taskList[r].forEach(function(e) {
|
|
n === e.index && (t = e)
|
|
}),
|
|
e ? 3 === n && this.uploaderCtx.tasks[r].isDirect && t && null != (e = t) && null != (e = e.context) && e.stop() : (this.tasks = [],
|
|
t && 3 === t.index && t.context.stop(),
|
|
this.uploaderCtx._removeTaskCache(r))
|
|
}
|
|
}, {
|
|
key: "restart",
|
|
value: function() {
|
|
this.uploadList.forEach(function(e) {
|
|
e.cancel = !1
|
|
}),
|
|
this.start()
|
|
}
|
|
}, {
|
|
key: "errorFormat",
|
|
value: function(e, t) {
|
|
var r, t = {
|
|
type: t ? "retry" : "error"
|
|
};
|
|
return e.xhr && (r = e.xhr,
|
|
e.req = {
|
|
url: r.currentUrl,
|
|
param: r.params
|
|
},
|
|
e.res = {
|
|
status: r.status,
|
|
header: r.getAllResponseHeaders(),
|
|
body: r.responseText
|
|
},
|
|
e.extra && (e.extra.req = e.req,
|
|
e.extra.res = e.res),
|
|
delete e.xhr),
|
|
tH(e, t)
|
|
}
|
|
}],
|
|
tL(r.prototype, i),
|
|
Object.defineProperty(r, "prototype", {
|
|
writable: !1
|
|
}),
|
|
a
|
|
}();
|
|
function tJ(e) {
|
|
return (tJ = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
|
|
return typeof e
|
|
}
|
|
: function(e) {
|
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
}
|
|
)(e)
|
|
}
|
|
function tQ() {
|
|
return (tQ = Object.assign ? Object.assign.bind() : function(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r, n = arguments[t];
|
|
for (r in n)
|
|
Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r])
|
|
}
|
|
return e
|
|
}
|
|
).apply(this, arguments)
|
|
}
|
|
function tX(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var n, i = t[r];
|
|
i.enumerable = i.enumerable || !1,
|
|
i.configurable = !0,
|
|
"value"in i && (i.writable = !0),
|
|
Object.defineProperty(e, (n = function(e, t) {
|
|
if ("object" !== tJ(e) || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 === r)
|
|
return ("string" === t ? String : Number)(e);
|
|
if (r = r.call(e, t || "default"),
|
|
"object" !== tJ(r))
|
|
return r;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}(n = i.key, "string"),
|
|
"symbol" === tJ(n) ? n : String(n)), i)
|
|
}
|
|
}
|
|
function t$(e, t) {
|
|
return (t$ = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
|
|
return e.__proto__ = t,
|
|
e
|
|
}
|
|
)(e, t)
|
|
}
|
|
function tZ(e) {
|
|
if (void 0 === e)
|
|
throw ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
return e
|
|
}
|
|
function tY(e) {
|
|
return (tY = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
|
|
return e.__proto__ || Object.getPrototypeOf(e)
|
|
}
|
|
)(e)
|
|
}
|
|
var t0 = function() {
|
|
!function(e, t) {
|
|
if ("function" != typeof t && null !== t)
|
|
throw TypeError("Super expression must either be null or a function");
|
|
e.prototype = Object.create(t && t.prototype, {
|
|
constructor: {
|
|
value: e,
|
|
writable: !0,
|
|
configurable: !0
|
|
}
|
|
}),
|
|
Object.defineProperty(e, "prototype", {
|
|
writable: !1
|
|
}),
|
|
t && t$(e, t)
|
|
}(c, n.a);
|
|
var e, t, r, i, o, a = (e = c,
|
|
t = function() {
|
|
if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham)
|
|
return !1;
|
|
if ("function" == typeof Proxy)
|
|
return !0;
|
|
try {
|
|
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
|
!0
|
|
} catch (e) {
|
|
return !1
|
|
}
|
|
}(),
|
|
function() {
|
|
var r = tY(e);
|
|
return function(e, t) {
|
|
if (t && ("object" === tJ(t) || "function" == typeof t))
|
|
return t;
|
|
if (void 0 !== t)
|
|
throw TypeError("Derived constructors may only return object or undefined");
|
|
return tZ(e)
|
|
}(this, t ? Reflect.construct(r, arguments, tY(this).constructor) : r.apply(this, arguments))
|
|
}
|
|
);
|
|
function c(e) {
|
|
var t;
|
|
return function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, c),
|
|
(t = a.call(this, e)).config = tQ({}, s),
|
|
t._mergeOptions(t.config, e),
|
|
t.tasks = {},
|
|
t.taskList = {},
|
|
t.cache = {},
|
|
t.storage = eh.storage(tZ(t), t.config.enableDiskBreakpoint),
|
|
t.logger = t.config.noLog ? {
|
|
send: function() {
|
|
return !0
|
|
}
|
|
} : new el(t.config,tZ(t)),
|
|
t
|
|
}
|
|
return r = c,
|
|
i = [{
|
|
key: "_mergeOptions",
|
|
value: function(e, t) {
|
|
t && "object" === tJ(t) && (tQ(e, t),
|
|
Object.keys(t).forEach(function(r) {
|
|
"vodDomain" === r && (e.replace[r] = t[r])
|
|
}))
|
|
}
|
|
}, {
|
|
key: "_setCache",
|
|
value: function(e, t) {
|
|
this.storage.setItem(e, t)
|
|
}
|
|
}, {
|
|
key: "_getCache",
|
|
value: function(e) {
|
|
return this.storage.getItem(e)
|
|
}
|
|
}, {
|
|
key: "_removeCache",
|
|
value: function(e) {
|
|
e ? this.storage.removeItem(e) : this.storage.clear()
|
|
}
|
|
}, {
|
|
key: "_addTask",
|
|
value: function(e, t) {
|
|
var r = this.tasks
|
|
, n = this.taskList;
|
|
r[e] && r[e].task ? n[e].push(t) : (n[e] = [],
|
|
n[e].push(t),
|
|
r[e] = r[e] || {},
|
|
r[e].task = new tW([],this.config,this,e)),
|
|
r[e].task.addTask(t)
|
|
}
|
|
}, {
|
|
key: "_broadcast",
|
|
value: function(e, t, r) {
|
|
(r || 1 === (r = this.tasks[t.key].status) || 0 === r) && this.emit(e, t)
|
|
}
|
|
}, {
|
|
key: "_addCrc32ProcessTask",
|
|
value: function(e, t) {
|
|
var r = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : {}
|
|
, n = r.isDirect
|
|
, r = r.isImageBatchUpload
|
|
, e = new eM({
|
|
file: e.file,
|
|
context: this,
|
|
key: t,
|
|
isDirect: n,
|
|
isImageBatchUpload: void 0 !== r && r
|
|
},this.config)
|
|
, n = {
|
|
context: e,
|
|
func: e.start,
|
|
arg: {},
|
|
key: t,
|
|
index: 0,
|
|
stage: "crc32"
|
|
};
|
|
this._addTask(t, n)
|
|
}
|
|
}, {
|
|
key: "_addPreUploadTask",
|
|
value: function(e, t) {
|
|
var r = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : {}
|
|
, n = r.isDirect
|
|
, r = r.isImageBatchUpload
|
|
, n = {
|
|
file: e.file,
|
|
stsToken: e.stsToken,
|
|
context: this,
|
|
type: e.type || er,
|
|
preUploadUriParams: e.preUploadUriParams || {},
|
|
storeKey: e.storeKey,
|
|
testHost: e.testHost,
|
|
key: t,
|
|
isDirect: n,
|
|
isImageBatchUpload: void 0 !== r && r,
|
|
fileSize: e.fileSize,
|
|
serviceType: e.serviceType || null,
|
|
fileExtension: e.fileExtension
|
|
}
|
|
, r = new eW(n,this.config)
|
|
, e = {
|
|
context: r,
|
|
func: r.start,
|
|
arg: {},
|
|
key: t,
|
|
index: 1,
|
|
stage: "preUpload"
|
|
};
|
|
this._addTask(t, e)
|
|
}
|
|
}, {
|
|
key: "_addDirectUploadTask",
|
|
value: function(e, t) {
|
|
var r = (2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : {}).isImageBatchUpload
|
|
, e = new tS({
|
|
file: e.file,
|
|
context: this,
|
|
key: t,
|
|
isImageBatchUpload: void 0 !== r && r
|
|
},this.config)
|
|
, r = {
|
|
context: e,
|
|
func: e.start,
|
|
arg: {},
|
|
key: t,
|
|
index: 3,
|
|
stage: "process"
|
|
};
|
|
this._addTask(t, r)
|
|
}
|
|
}, {
|
|
key: "_addInitUploadIDTask",
|
|
value: function(e, t) {
|
|
e = {
|
|
context: e = new e1({
|
|
file: e.file,
|
|
context: this,
|
|
key: t
|
|
},this.config),
|
|
func: e.start,
|
|
arg: {},
|
|
key: t,
|
|
index: 2,
|
|
stage: "initUploadID"
|
|
},
|
|
this._addTask(t, e)
|
|
}
|
|
}, {
|
|
key: "_addUploadProcessTask",
|
|
value: function(e, t) {
|
|
e = {
|
|
context: e = new ta({
|
|
file: e.file,
|
|
context: this,
|
|
key: t
|
|
},this.config),
|
|
func: e.start,
|
|
arg: {},
|
|
key: t,
|
|
index: 3,
|
|
stage: "process"
|
|
},
|
|
this._addTask(t, e)
|
|
}
|
|
}, {
|
|
key: "_addStreamUploadTask",
|
|
value: function(e, t) {
|
|
this.streamUploadTask = new tT({
|
|
context: this,
|
|
key: t
|
|
},this.config);
|
|
var r = {
|
|
context: this.streamUploadTask,
|
|
func: this.streamUploadTask.start,
|
|
arg: {},
|
|
key: t,
|
|
index: 3,
|
|
stage: "process"
|
|
};
|
|
this._addTask(t, r)
|
|
}
|
|
}, {
|
|
key: "_mergeFileTask",
|
|
value: function(e, t) {
|
|
e = {
|
|
context: e = new tg({
|
|
file: e.file,
|
|
context: this,
|
|
stage: "fileMerge",
|
|
key: t
|
|
},this.config),
|
|
func: e.start,
|
|
arg: {},
|
|
key: t,
|
|
index: 4,
|
|
stage: "fileMerge"
|
|
},
|
|
this._addTask(t, e)
|
|
}
|
|
}, {
|
|
key: "_getMetaInfoTask",
|
|
value: function(e, t) {
|
|
var r = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : {}
|
|
, n = r.isImageBatchUpload
|
|
, r = r.skipCommit
|
|
, n = {
|
|
file: e.file,
|
|
context: this,
|
|
data: e.data,
|
|
type: e.type || er,
|
|
callbackArgs: e.callbackArgs,
|
|
objectSync: e.objectSync,
|
|
needExactFormat: e.needExactFormat,
|
|
key: t,
|
|
isImageBatchUpload: void 0 !== n && n,
|
|
skipCommit: void 0 !== r && r,
|
|
serviceType: e.serviceType || null
|
|
}
|
|
, r = new tM(n,this.config)
|
|
, e = {
|
|
context: r,
|
|
func: r.start,
|
|
arg: {},
|
|
key: t,
|
|
index: 5,
|
|
stage: "complete"
|
|
};
|
|
this._addTask(t, e)
|
|
}
|
|
}, {
|
|
key: "_addAllUploadProcess",
|
|
value: function(e, t) {
|
|
var r = e.type === en && "[object Array]" === Object.prototype.toString.call(e.file)
|
|
, n = (this.tasks[t] = this.tasks[t] || {},
|
|
this.tasks[t].fileType = e.type || er,
|
|
this.tasks[t].fileSize = e.file && e.file.size,
|
|
this.tasks[t].proxyStsToken = e.stsToken,
|
|
this.lastStsToken = e.stsToken,
|
|
this.lastFile = e.file,
|
|
e.file.size <= eh.getFileSliceLength(e.file) || r)
|
|
, n = (e.useDirectUpload && (n = !0),
|
|
this._addCrc32ProcessTask(e, t, {
|
|
isDirect: n,
|
|
isImageBatchUpload: r
|
|
}),
|
|
this._addPreUploadTask(e, t, {
|
|
isDirect: n,
|
|
isImageBatchUpload: r
|
|
}),
|
|
n ? this._addDirectUploadTask(e, t, {
|
|
isImageBatchUpload: r
|
|
}) : (this._addInitUploadIDTask(e, t),
|
|
this._addUploadProcessTask(e, t),
|
|
this._mergeFileTask(e, t)),
|
|
!(!this.config.skipCommit || eG.checkServiceName(e.type, this.config) !== es));
|
|
this._getMetaInfoTask(e, t, {
|
|
isImageBatchUpload: r,
|
|
skipCommit: n
|
|
})
|
|
}
|
|
}, {
|
|
key: "_addAllUploadProcessClientEncrypt",
|
|
value: function(e) {
|
|
var t, r = this;
|
|
return e.type === en && Array.isArray(e.file) ? (t = [],
|
|
e.file.forEach(function(n) {
|
|
t.push(r._createClientEncryptTask({
|
|
stsToken: e.stsToken,
|
|
type: e.type,
|
|
file: n
|
|
}))
|
|
}),
|
|
t) : this._createClientEncryptTask(e)
|
|
}
|
|
}, {
|
|
key: "_createClientEncryptTask",
|
|
value: function(e) {
|
|
var t = eh.getUnique("file")
|
|
, r = (this.tasks[t] = this.tasks[t] || {},
|
|
this.tasks[t].fileType = e.type || er,
|
|
this.tasks[t].fileSize = e.file && e.file.size,
|
|
this.tasks[t].proxyStsToken = e.stsToken,
|
|
this.tasks[t].clientEncryptKey = eh.generateKey(16),
|
|
this._addCrc32ProcessTask(e, t, {
|
|
isDirect: !1,
|
|
isImageBatchUpload: !1
|
|
}),
|
|
this._addPreUploadTask(e, t, {
|
|
isDirect: !1,
|
|
isImageBatchUpload: !1
|
|
}),
|
|
this._addInitUploadIDTask(e, t),
|
|
this._addUploadProcessTask(e, t),
|
|
this._mergeFileTask(e, t),
|
|
!(!this.config.skipCommit || eG.checkServiceName(e.type, this.config) !== es));
|
|
return this._getMetaInfoTask(e, t, {
|
|
isImageBatchUpload: !1,
|
|
skipCommit: r
|
|
}),
|
|
t
|
|
}
|
|
}, {
|
|
key: "_addAllStreamUploadProcess",
|
|
value: function(e, t) {
|
|
this.tasks[t] = this.tasks[t] || {},
|
|
this.tasks[t].fileType = e.type || er,
|
|
this.tasks[t].proxyStsToken = e.stsToken,
|
|
this._addPreUploadTask(e, t),
|
|
this._addInitUploadIDTask(e, t),
|
|
this._addStreamUploadTask(e, t),
|
|
this._mergeFileTask(e, t),
|
|
this._getMetaInfoTask(e, t)
|
|
}
|
|
}, {
|
|
key: "_addStreamSlice",
|
|
value: function(e) {
|
|
var t = e.fileSlice
|
|
, e = e.index;
|
|
this.streamUploadTask.addStreamSlice({
|
|
fileSlice: t,
|
|
index: e
|
|
})
|
|
}
|
|
}, {
|
|
key: "_completeStreamUpload",
|
|
value: function() {
|
|
this.streamUploadTask.completeStreamUpload()
|
|
}
|
|
}, {
|
|
key: "_run",
|
|
value: function(e, t) {
|
|
var r = this.tasks
|
|
, n = navigator.userAgent.toLowerCase().match(/msie ([\d.]+)/);
|
|
n && n[1] && 9 >= Number(n[1]) ? (this._broadcast("error", tQ(r[e], {
|
|
key: e,
|
|
status: 0,
|
|
stage: "browserError",
|
|
extra: {
|
|
message: "cannot support the browser below ie10"
|
|
},
|
|
type: "error"
|
|
})),
|
|
this.logger.send(r[e]),
|
|
this._cancel(e)) : r[e] ? 3 === r[e].status ? this._restart(e) : (r[e].startTime = (new Date).getTime(),
|
|
r[e].task && 1 !== r[e].status && r[e].task.tasks.length && (r[e].status = 1,
|
|
this.logger.send(tQ({}, r[e], {
|
|
extra: {
|
|
message: "start upload"
|
|
},
|
|
type: "start",
|
|
key: e
|
|
})),
|
|
r[e].task.start(t))) : console.warn("".concat(e, " is not exit in object tasks, stop running..."))
|
|
}
|
|
}, {
|
|
key: "_selectRoute",
|
|
value: function(e, t) {
|
|
new eC({
|
|
stsToken: this.lastStsToken,
|
|
context: this,
|
|
type: er,
|
|
file: this.lastFile
|
|
},this.config).start(e, t)
|
|
}
|
|
}, {
|
|
key: "_restart",
|
|
value: function(e) {
|
|
var t, r, n = this, i = this.tasks;
|
|
i[e] ? (t = i[e].task,
|
|
r = i[e].currentTask || 0,
|
|
this.taskList[e].forEach(function(i, o) {
|
|
i.index === r && (t.tasks = n.taskList[e].slice(o))
|
|
}),
|
|
t && 1 !== i[e].status && t.tasks.length && (i[e].status = 1,
|
|
t.restart())) : console.warn("".concat(e, " is not exit in object tasks"))
|
|
}
|
|
}, {
|
|
key: "_cancel",
|
|
value: function(e) {
|
|
var t = this.tasks;
|
|
t[e] ? (t[e].status = 2,
|
|
t[e].task.cancel(),
|
|
delete this.taskList[e]) : console.warn("".concat(e, " is not exit in object tasks"))
|
|
}
|
|
}, {
|
|
key: "_pause",
|
|
value: function(e) {
|
|
var t = this.tasks;
|
|
t[e] ? (t[e].status = 3,
|
|
t[e].task.cancel(!0),
|
|
t[e].isDirect || this._saveTask(e)) : console.warn("".concat(e, " is not exit in object tasks"))
|
|
}
|
|
}, {
|
|
key: "_removeTaskCache",
|
|
value: function(e) {
|
|
var t = this.tasks;
|
|
t[e] ? (t = t[e].crc32Key) && this._removeCache(t) : console.warn("".concat(e, " is not exit in object tasks"))
|
|
}
|
|
}, {
|
|
key: "_saveTask",
|
|
value: function(e, t) {
|
|
t = (e = tQ({}, this.tasks[e], t || {})).crc32Key;
|
|
try {
|
|
t && this._setCache(t, this.serializeCacheInfo(e))
|
|
} catch (e) {
|
|
console.warn(e)
|
|
}
|
|
}
|
|
}, {
|
|
key: "serializeCacheInfo",
|
|
value: function(e) {
|
|
var t = "";
|
|
delete e.task,
|
|
delete e.xhr,
|
|
delete e.crc32Array;
|
|
try {
|
|
t = JSON.stringify(e)
|
|
} catch (n) {
|
|
var r = {};
|
|
Object.keys(e).forEach(function(t) {
|
|
"task" !== t && "xhr" !== t && "crc32Array" !== t && (r[t] = e[t])
|
|
}),
|
|
t = JSON.stringify(r)
|
|
}
|
|
return t
|
|
}
|
|
}, {
|
|
key: "_queueSuccess",
|
|
value: function(e) {
|
|
var t, r = this.tasks;
|
|
r[e] ? (t = new Date,
|
|
r[e].endTime = t.getTime(),
|
|
r[e].time = r[e].endTime - r[e].startTime,
|
|
r[e].status = 0,
|
|
delete this.taskList[e],
|
|
delete r[e]) : console.warn("".concat(e, " is not exit in object tasks"))
|
|
}
|
|
}, {
|
|
key: "_removeFile",
|
|
value: function(e) {
|
|
delete this.tasks[e]
|
|
}
|
|
}, {
|
|
key: "_batchAction",
|
|
value: function(e, t) {
|
|
Object.keys(this.tasks).forEach(function(r) {
|
|
e && e(r, t)
|
|
})
|
|
}
|
|
}, {
|
|
key: "_refreshSTSToken",
|
|
value: function(e) {
|
|
var t = this
|
|
, r = this.tasks;
|
|
Object.keys(r).forEach(function(n) {
|
|
var n = r[n]
|
|
, i = tQ({}, n, {
|
|
proxyStsToken: e
|
|
})
|
|
, o = (n.proxyStsToken = e,
|
|
i.crc32Key);
|
|
o && (n.proxyStsToken = e,
|
|
t._setCache(o, t.serializeCacheInfo(i)))
|
|
})
|
|
}
|
|
}, {
|
|
key: "_setOption",
|
|
value: function(e) {
|
|
this._mergeOptions(this.config, e)
|
|
}
|
|
}, {
|
|
key: "_getOption",
|
|
value: function(e) {
|
|
var t = tQ({}, this.config);
|
|
return Object.keys(t).forEach(function(e) {
|
|
(-1 < e.indexOf("Url") || "replace" === e || "log" === e) && delete t[e]
|
|
}),
|
|
e ? t[e] : t
|
|
}
|
|
}, {
|
|
key: "_userCancel",
|
|
value: function(e) {
|
|
var t = this
|
|
, r = this.tasks;
|
|
e ? (this._cancel(e),
|
|
this.logger.send(tQ({}, r[e], {
|
|
type: "cancel"
|
|
})),
|
|
delete this.tasks[e]) : Object.keys(r).forEach(function(e) {
|
|
t._cancel(e),
|
|
t.logger.send(tQ({}, r[e], {
|
|
type: "cancel"
|
|
})),
|
|
delete t.tasks[e]
|
|
})
|
|
}
|
|
}, {
|
|
key: "_userPause",
|
|
value: function(e) {
|
|
var t = this
|
|
, r = this.tasks;
|
|
e ? (this._pause(e),
|
|
this.logger.send(tQ({}, r[e], {
|
|
type: "pause"
|
|
}))) : Object.keys(r).forEach(function(e) {
|
|
t._pause(e),
|
|
t.logger.send(tQ({}, r[e], {
|
|
type: "pause"
|
|
}))
|
|
})
|
|
}
|
|
}],
|
|
tX(r.prototype, i),
|
|
Object.defineProperty(r, "prototype", {
|
|
writable: !1
|
|
}),
|
|
c
|
|
}();
|
|
function t1(e) {
|
|
return (t1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
|
|
return typeof e
|
|
}
|
|
: function(e) {
|
|
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
}
|
|
)(e)
|
|
}
|
|
function t2(e, t) {
|
|
var r, n = Object.keys(e);
|
|
return Object.getOwnPropertySymbols && (r = Object.getOwnPropertySymbols(e),
|
|
t && (r = r.filter(function(t) {
|
|
return Object.getOwnPropertyDescriptor(e, t).enumerable
|
|
})),
|
|
n.push.apply(n, r)),
|
|
n
|
|
}
|
|
function t3(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r = null != arguments[t] ? arguments[t] : {};
|
|
t % 2 ? t2(Object(r), !0).forEach(function(t) {
|
|
var n, i, o;
|
|
n = e,
|
|
i = t,
|
|
o = r[t],
|
|
(i = t5(i))in n ? Object.defineProperty(n, i, {
|
|
value: o,
|
|
enumerable: !0,
|
|
configurable: !0,
|
|
writable: !0
|
|
}) : n[i] = o
|
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : t2(Object(r)).forEach(function(t) {
|
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t))
|
|
})
|
|
}
|
|
return e
|
|
}
|
|
function t4(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var n = t[r];
|
|
n.enumerable = n.enumerable || !1,
|
|
n.configurable = !0,
|
|
"value"in n && (n.writable = !0),
|
|
Object.defineProperty(e, t5(n.key), n)
|
|
}
|
|
}
|
|
function t5(e) {
|
|
return e = function(e, t) {
|
|
if ("object" !== t1(e) || null === e)
|
|
return e;
|
|
var r = e[Symbol.toPrimitive];
|
|
if (void 0 === r)
|
|
return ("string" === t ? String : Number)(e);
|
|
if (r = r.call(e, t || "default"),
|
|
"object" !== t1(r))
|
|
return r;
|
|
throw TypeError("@@toPrimitive must return a primitive value.")
|
|
}(e, "string"),
|
|
"symbol" === t1(e) ? e : String(e)
|
|
}
|
|
function t6(e, t) {
|
|
return (t6 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
|
|
return e.__proto__ = t,
|
|
e
|
|
}
|
|
)(e, t)
|
|
}
|
|
function t8(e) {
|
|
return (t8 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
|
|
return e.__proto__ || Object.getPrototypeOf(e)
|
|
}
|
|
)(e)
|
|
}
|
|
var t7 = function() {
|
|
!function(e, t) {
|
|
if ("function" != typeof t && null !== t)
|
|
throw TypeError("Super expression must either be null or a function");
|
|
e.prototype = Object.create(t && t.prototype, {
|
|
constructor: {
|
|
value: e,
|
|
writable: !0,
|
|
configurable: !0
|
|
}
|
|
}),
|
|
Object.defineProperty(e, "prototype", {
|
|
writable: !1
|
|
}),
|
|
t && t6(e, t)
|
|
}(s, t0);
|
|
var e, t, r, n, i, o = (e = s,
|
|
t = function() {
|
|
if ("undefined" == typeof Reflect || !Reflect.construct || Reflect.construct.sham)
|
|
return !1;
|
|
if ("function" == typeof Proxy)
|
|
return !0;
|
|
try {
|
|
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
|
!0
|
|
} catch (e) {
|
|
return !1
|
|
}
|
|
}(),
|
|
function() {
|
|
var r = t8(e);
|
|
return function(e, t) {
|
|
if (t && ("object" === t1(t) || "function" == typeof t))
|
|
return t;
|
|
if (void 0 !== t)
|
|
throw TypeError("Derived constructors may only return object or undefined");
|
|
return function(e) {
|
|
if (void 0 !== e)
|
|
return e;
|
|
throw ReferenceError("this hasn't been initialised - super() hasn't been called")
|
|
}(e)
|
|
}(this, t ? Reflect.construct(r, arguments, t8(this).constructor) : r.apply(this, arguments))
|
|
}
|
|
);
|
|
function s() {
|
|
return function(e, t) {
|
|
if (!(e instanceof t))
|
|
throw TypeError("Cannot call a class as a function")
|
|
}(this, s),
|
|
o.apply(this, arguments)
|
|
}
|
|
return r = s,
|
|
n = [{
|
|
key: "start",
|
|
value: function(e) {
|
|
var t = this
|
|
, r = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {};
|
|
this.abort = !1,
|
|
r.selectRoute ? this._selectRoute(r, function(r) {
|
|
r = t3(t3({}, r), {}, {
|
|
enableSelectRoute: !0
|
|
}),
|
|
e ? t._run(e, r) : t._batchAction(t._run.bind(t), r)
|
|
}) : e ? this._run(e) : this._batchAction(this._run.bind(this))
|
|
}
|
|
}, {
|
|
key: "addFile",
|
|
value: function(e) {
|
|
var t;
|
|
return e && eG.checkStsToken(e.stsToken) ? e.file && this.config.clientEncrypt ? this._addAllUploadProcessClientEncrypt(e) : e.file ? (t = eh.getUnique("file"),
|
|
this._addAllUploadProcess(e, t),
|
|
t) : null : (this.emit("error", {
|
|
extra: {
|
|
message: eA,
|
|
errorCode: 1000002
|
|
}
|
|
}),
|
|
null)
|
|
}
|
|
}, {
|
|
key: "addImageFile",
|
|
value: function(e) {
|
|
var t;
|
|
return e && eG.checkStsToken(e.stsToken) ? e.file ? (e.type = e.type || en,
|
|
t = eh.getUnique("file"),
|
|
this._addAllUploadProcess(e, t),
|
|
t) : null : (this.emit("error", {
|
|
extra: {
|
|
message: eA,
|
|
errorCode: 1000002
|
|
}
|
|
}),
|
|
null)
|
|
}
|
|
}, {
|
|
key: "addStreamUploadTask",
|
|
value: function(e) {
|
|
var t;
|
|
return e && eG.checkStsToken(e.stsToken) ? (t = eh.getUnique("file"),
|
|
this._addAllStreamUploadProcess(e, t),
|
|
t) : (this.emit("error", {
|
|
extra: {
|
|
message: eA,
|
|
errorCode: 1000002
|
|
}
|
|
}),
|
|
null)
|
|
}
|
|
}, {
|
|
key: "addStreamSlice",
|
|
value: function(e) {
|
|
var t = e.fileSlice
|
|
, e = e.index;
|
|
this._addStreamSlice({
|
|
fileSlice: t,
|
|
index: e
|
|
})
|
|
}
|
|
}, {
|
|
key: "completeStreamUpload",
|
|
value: function() {
|
|
this._completeStreamUpload()
|
|
}
|
|
}, {
|
|
key: "removeFile",
|
|
value: function(e) {
|
|
e && this._removeFile(e)
|
|
}
|
|
}, {
|
|
key: "cancel",
|
|
value: function(e) {
|
|
e ? this._userCancel(e) : this._batchAction(this._userCancel.bind(this))
|
|
}
|
|
}, {
|
|
key: "pause",
|
|
value: function(e) {
|
|
this._userPause(e)
|
|
}
|
|
}, {
|
|
key: "restart",
|
|
value: function(e) {
|
|
e ? this._restart(e) : this._batchAction(this._restart.bind(this))
|
|
}
|
|
}, {
|
|
key: "refreshSTSToken",
|
|
value: function(e) {
|
|
this._refreshSTSToken(e)
|
|
}
|
|
}, {
|
|
key: "setOption",
|
|
value: function(e) {
|
|
this._setOption(e)
|
|
}
|
|
}, {
|
|
key: "getOption",
|
|
value: function(e) {
|
|
return this._getOption(e)
|
|
}
|
|
}],
|
|
t4(r.prototype, n),
|
|
Object.defineProperty(r, "prototype", {
|
|
writable: !1
|
|
}),
|
|
s
|
|
}()
|
|
}
|
|
|
|
|
|
// 1. 创建一个模拟的 module 对象
|
|
var myTempModule = { exports: {} };
|
|
|
|
// 2. 获取全局上下文 (通常是 window)
|
|
var globalCtx = (typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : globalThis);
|
|
var fncache = {};
|
|
|
|
T499845(window.tttt.e)
|
|
T984826(window.tttt.e, window.tttt.t, window.tttt.i)
|
|
T203960(window.tttt.e, window.tttt.t, window.tttt.i)
|
|
|
|
// TEST(myTempModule, globalCtx, (num)=>{
|
|
// fncache[num] = myTempModule.exports;
|
|
// });
|
|
// TEST2(myTempModule, globalCtx, (num)=>{
|
|
// fncache[num] = myTempModule.exports;
|
|
// });
|
|
// TEST3(myTempModule, globalCtx, (num)=>{
|
|
// fncache[num] = myTempModule.exports;
|
|
// });
|
|
// TEST4(myTempModule, globalCtx, (num)=>{
|
|
// fncache[num] = myTempModule.exports;
|
|
// });
|
|
// TEST5(myTempModule, globalCtx, (num)=>{
|
|
// fncache[num] = myTempModule.exports;
|
|
// });
|
|
// console.log(fncache);
|