tt-uploader 1.2.1 → 1.3.0-bata.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function webpackUniversalModuleDefinition(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.TTUploader=t():e.TTUploader=t()}("undefined"!=typeof self?self:this,()=>(()=>{var r={452:function(e,t,r){e.exports=function(o){return function(){var e=o;var t=e.lib;var r=t.BlockCipher;var i=e.algo;var l=[];var u=[];var p=[];var f=[];var h=[];var d=[];var y=[];var g=[];var v=[];var _=[];(function(){var e=[];for(var t=0;t<256;t++)if(t<128)e[t]=t<<1;else e[t]=t<<1^283;var r=0;var i=0;for(var t=0;t<256;t++){var n=i^i<<1^i<<2^i<<3^i<<4;n=n>>>8^n&255^99;l[r]=n;u[n]=r;var o=e[r];var s=e[o];var a=e[s];var c=e[n]*257^n*16843008;p[r]=c<<24|c>>>8;f[r]=c<<16|c>>>16;h[r]=c<<8|c>>>24;d[r]=c;var c=a*16843009^s*65537^o*257^r*16843008;y[n]=c<<24|c>>>8;g[n]=c<<16|c>>>16;v[n]=c<<8|c>>>24;_[n]=c;if(!r)r=i=1;else{r=o^e[e[e[a^o]]];i^=e[e[i]]}}})();var m=[0,1,2,4,8,16,32,64,128,27,54];var n=i.AES=r.extend({_doReset:function(){var e;if(this._nRounds&&this._keyPriorReset===this._key)return;var t=this._keyPriorReset=this._key;var r=t.words;var i=t.sigBytes/4;var n=this._nRounds=i+6;var o=(n+1)*4;var s=this._keySchedule=[];for(var a=0;a<o;a++)if(a<i)s[a]=r[a];else{e=s[a-1];if(!(a%i)){e=e<<8|e>>>24;e=l[e>>>24]<<24|l[e>>>16&255]<<16|l[e>>>8&255]<<8|l[e&255];e^=m[a/i|0]<<24}else if(i>6&&a%i==4)e=l[e>>>24]<<24|l[e>>>16&255]<<16|l[e>>>8&255]<<8|l[e&255];s[a]=s[a-i]^e}var c=this._invKeySchedule=[];for(var u=0;u<o;u++){var a=o-u;if(u%4)var e=s[a];else var e=s[a-4];if(u<4||a<=4)c[u]=e;else c[u]=y[l[e>>>24]]^g[l[e>>>16&255]]^v[l[e>>>8&255]]^_[l[e&255]]}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,p,f,h,d,l)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3];e[t+3]=r;this._doCryptBlock(e,t,this._invKeySchedule,y,g,v,_,u);var r=e[t+1];e[t+1]=e[t+3];e[t+3]=r},_doCryptBlock:function(e,t,r,i,n,o,s,a){var c=this._nRounds;var u=e[t]^r[0];var l=e[t+1]^r[1];var p=e[t+2]^r[2];var f=e[t+3]^r[3];var h=4;for(var d=1;d<c;d++){var y=i[u>>>24]^n[l>>>16&255]^o[p>>>8&255]^s[f&255]^r[h++];var g=i[l>>>24]^n[p>>>16&255]^o[f>>>8&255]^s[u&255]^r[h++];var v=i[p>>>24]^n[f>>>16&255]^o[u>>>8&255]^s[l&255]^r[h++];var _=i[f>>>24]^n[u>>>16&255]^o[l>>>8&255]^s[p&255]^r[h++];u=y;l=g;p=v;f=_}var y=(a[u>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[f&255])^r[h++];var g=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[f>>>8&255]<<8|a[u&255])^r[h++];var v=(a[p>>>24]<<24|a[f>>>16&255]<<16|a[u>>>8&255]<<8|a[l&255])^r[h++];var _=(a[f>>>24]<<24|a[u>>>16&255]<<16|a[l>>>8&255]<<8|a[p&255])^r[h++];e[t]=y;e[t+1]=g;e[t+2]=v;e[t+3]=_},keySize:256/32});e.AES=r._createHelper(n)}(),o.AES}(r(249),(r(269),r(214),r(888),r(109)))},109:function(e,t,r){e.exports=function(O){O.lib.Cipher||function(s){var e=O;var t=e.lib;var r=t.Base;var c=t.WordArray;var i=t.BufferedBlockAlgorithm;var n=e.enc;var o=n.Utf8;var a=n.Base64;var u=e.algo;var l=u.EvpKDF;var p=t.Cipher=i.extend({cfg:r.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r);this._xformMode=e;this._key=t;this.reset()},reset:function(){i.reset.call(this);this._doReset()},process:function(e){this._append(e);return this._process()},finalize:function(e){if(e)this._append(e);var t=this._doFinalize();return t},keySize:128/32,ivSize:128/32,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function selectCipherStrategy(e){if(typeof e=="string")return S;else return k}return function(i){return{encrypt:function(e,t,r){return selectCipherStrategy(t).encrypt(i,e,t,r)},decrypt:function(e,t,r){return selectCipherStrategy(t).decrypt(i,e,t,r)}}}}()});var f=t.StreamCipher=p.extend({_doFinalize:function(){var e=this._process(!!"flush");return e},blockSize:1});var h=e.mode={};var d=t.BlockCipherMode=r.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e;this._iv=t}});var y=h.CBC=function(){var e=d.extend();e.Encryptor=e.extend({processBlock:function(e,t){var r=this._cipher;var i=r.blockSize;xorBlock.call(this,e,t,i);r.encryptBlock(e,t);this._prevBlock=e.slice(t,t+i)}});e.Decryptor=e.extend({processBlock:function(e,t){var r=this._cipher;var i=r.blockSize;var n=e.slice(t,t+i);r.decryptBlock(e,t);xorBlock.call(this,e,t,i);this._prevBlock=n}});function xorBlock(e,t,r){var i;var n=this._iv;if(n){i=n;this._iv=s}else i=this._prevBlock;for(var o=0;o<r;o++)e[t+o]^=i[o]}return e}();var g=e.pad={};var v=g.Pkcs7={pad:function(e,t){var r=t*4;var i=r-e.sigBytes%r;var n=i<<24|i<<16|i<<8|i;var o=[];for(var s=0;s<i;s+=4)o.push(n);var a=c.create(o,i);e.concat(a)},unpad:function(e){var t=e.words[e.sigBytes-1>>>2]&255;e.sigBytes-=t}};var _=t.BlockCipher=p.extend({cfg:p.cfg.extend({mode:y,padding:v}),reset:function(){var e;p.reset.call(this);var t=this.cfg;var r=t.iv;var i=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)e=i.createEncryptor;else{e=i.createDecryptor;this._minBufferSize=1}if(this._mode&&this._mode.__creator==e)this._mode.init(this,r&&r.words);else{this._mode=e.call(i,this,r&&r.words);this._mode.__creator=e}},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e;var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);e=this._process(!!"flush")}else{e=this._process(!!"flush");t.unpad(e)}return e},blockSize:128/32});var m=t.CipherParams=r.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}});var b=e.format={};var x=b.OpenSSL={stringify:function(e){var t;var r=e.ciphertext;var i=e.salt;if(i)t=c.create([1398893684,1701076831]).concat(i).concat(r);else t=r;return t.toString(a)},parse:function(e){var t;var r=a.parse(e);var i=r.words;if(i[0]==1398893684&&i[1]==1701076831){t=c.create(i.slice(2,4));i.splice(0,4);r.sigBytes-=16}return m.create({ciphertext:r,salt:t})}};var k=t.SerializableCipher=r.extend({cfg:r.extend({format:x}),encrypt:function(e,t,r,i){i=this.cfg.extend(i);var n=e.createEncryptor(r,i);var o=n.finalize(t);var s=n.cfg;return m.create({ciphertext:o,key:r,iv:s.iv,algorithm:e,mode:s.mode,padding:s.padding,blockSize:e.blockSize,formatter:i.format})},decrypt:function(e,t,r,i){i=this.cfg.extend(i);t=this._parse(t,i.format);var n=e.createDecryptor(r,i).finalize(t.ciphertext);return n},_parse:function(e,t){if(typeof e=="string")return t.parse(e,this);else return e}});var w=e.kdf={};var C=w.OpenSSL={execute:function(e,t,r,i,n){if(!i)i=c.random(64/8);if(!n)var o=l.create({keySize:t+r}).compute(e,i);else var o=l.create({keySize:t+r,hasher:n}).compute(e,i);var s=c.create(o.words.slice(t),r*4);o.sigBytes=t*4;return m.create({key:o,iv:s,salt:i})}};var S=t.PasswordBasedCipher=k.extend({cfg:k.cfg.extend({kdf:C}),encrypt:function(e,t,r,i){i=this.cfg.extend(i);var n=i.kdf.execute(r,e.keySize,e.ivSize,i.salt,i.hasher);i.iv=n.iv;var o=k.encrypt.call(this,e,t,n.key,i);o.mixIn(n);return o},decrypt:function(e,t,r,i){i=this.cfg.extend(i);t=this._parse(t,i.format);var n=i.kdf.execute(r,e.keySize,e.ivSize,t.salt,i.hasher);i.iv=n.iv;var o=k.decrypt.call(this,e,t,n.key,i);return o}})}()}(r(249),r(888))},249:function(e,t,g){e.exports=function(){var e=e||function(p,r){var e;if(typeof window!=="undefined"&&window.crypto)e=window.crypto;if(typeof self!=="undefined"&&self.crypto)e=self.crypto;if(typeof globalThis!=="undefined"&&globalThis.crypto)e=globalThis.crypto;if(!e&&typeof window!=="undefined"&&window.msCrypto)e=window.msCrypto;if(!e&&typeof global!=="undefined"&&global.crypto)e=global.crypto;if(!e&&"function"==="function")try{e=g(480)}catch(e){}var i=function(){if(e){if(typeof e.getRandomValues==="function")try{return e.getRandomValues(new Uint32Array(1))[0]}catch(e){}if(typeof e.randomBytes==="function")try{return e.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")};var n=Object.create||function(){function F(){}return function(e){var t;F.prototype=e;t=new F;F.prototype=null;return t}}();var t={};var o=t.lib={};var s=o.Base=function(){return{extend:function(e){var t=n(this);if(e)t.mixIn(e);if(!t.hasOwnProperty("init")||this.init===t.init)t.init=function(){t.$super.init.apply(this,arguments)};t.init.prototype=t;t.$super=this;return t},create:function(){var e=this.extend();e.init.apply(e,arguments);return e},init:function(){},mixIn:function(e){for(var t in e)if(e.hasOwnProperty(t))this[t]=e[t];if(e.hasOwnProperty("toString"))this.toString=e.toString},clone:function(){return this.init.prototype.extend(this)}}}();var f=o.WordArray=s.extend({init:function(e,t){e=this.words=e||[];if(t!=r)this.sigBytes=t;else this.sigBytes=e.length*4},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words;var r=e.words;var i=this.sigBytes;var n=e.sigBytes;this.clamp();if(i%4)for(var o=0;o<n;o++){var s=r[o>>>2]>>>24-o%4*8&255;t[i+o>>>2]|=s<<24-(i+o)%4*8}else for(var a=0;a<n;a+=4)t[i+a>>>2]=r[a>>>2];this.sigBytes+=n;return this},clamp:function(){var e=this.words;var t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8;e.length=p.ceil(t/4)},clone:function(){var e=s.clone.call(this);e.words=this.words.slice(0);return e},random:function(e){var t=[];for(var r=0;r<e;r+=4)t.push(i());return new f.init(t,e)}});var a=t.enc={};var c=a.Hex={stringify:function(e){var t=e.words;var r=e.sigBytes;var i=[];for(var n=0;n<r;n++){var o=t[n>>>2]>>>24-n%4*8&255;i.push((o>>>4).toString(16));i.push((o&15).toString(16))}return i.join("")},parse:function(e){var t=e.length;var r=[];for(var i=0;i<t;i+=2)r[i>>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new f.init(r,t/2)}};var u=a.Latin1={stringify:function(e){var t=e.words;var r=e.sigBytes;var i=[];for(var n=0;n<r;n++){var o=t[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(e){var t=e.length;var r=[];for(var i=0;i<t;i++)r[i>>>2]|=(e.charCodeAt(i)&255)<<24-i%4*8;return new f.init(r,t)}};var l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}};var h=o.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new f.init;this._nDataBytes=0},_append:function(e){if(typeof e=="string")e=l.parse(e);this._data.concat(e);this._nDataBytes+=e.sigBytes},_process:function(e){var t;var r=this._data;var i=r.words;var n=r.sigBytes;var o=this.blockSize;var s=o*4;var a=n/s;if(e)a=p.ceil(a);else a=p.max((a|0)-this._minBufferSize,0);var c=a*o;var u=p.min(c*4,n);if(c){for(var l=0;l<c;l+=o)this._doProcessBlock(i,l);t=i.splice(0,c);r.sigBytes-=u}return new f.init(t,u)},clone:function(){var e=s.clone.call(this);e._data=this._data.clone();return e},_minBufferSize:0});var d=o.Hasher=h.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e);this.reset()},reset:function(){h.reset.call(this);this._doReset()},update:function(e){this._append(e);this._process();return this},finalize:function(e){if(e)this._append(e);var t=this._doFinalize();return t},blockSize:512/32,_createHelper:function(r){return function(e,t){return new r.init(t).finalize(e)}},_createHmacHelper:function(r){return function(e,t){return new y.HMAC.init(r,t).finalize(e)}}});var y=t.algo={};return t}(Math);return e}()},269:function(e,t,r){e.exports=function(n){return function(){var e=n;var t=e.lib;var u=t.WordArray;var r=e.enc;var i=r.Base64={stringify:function(e){var t=e.words;var r=e.sigBytes;var i=this._map;e.clamp();var n=[];for(var o=0;o<r;o+=3){var s=t[o>>>2]>>>24-o%4*8&255;var a=t[o+1>>>2]>>>24-(o+1)%4*8&255;var c=t[o+2>>>2]>>>24-(o+2)%4*8&255;var u=s<<16|a<<8|c;for(var l=0;l<4&&o+l*.75<r;l++)n.push(i.charAt(u>>>6*(3-l)&63))}var p=i.charAt(64);if(p)while(n.length%4)n.push(p);return n.join("")},parse:function(e){var t=e.length;var r=this._map;var i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var n=0;n<r.length;n++)i[r.charCodeAt(n)]=n}var o=r.charAt(64);if(o){var s=e.indexOf(o);if(s!==-1)t=s}return parseLoop(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function parseLoop(e,t,r){var i=[];var n=0;for(var o=0;o<t;o++)if(o%4){var s=r[e.charCodeAt(o-1)]<<o%4*2;var a=r[e.charCodeAt(o)]>>>6-o%4*2;var c=s|a;i[n>>>2]|=c<<24-n%4*8;n++}return u.create(i,n)}}(),n.enc.Base64}(r(249))},743:function(e,t,r){e.exports=function(e){return e.enc.Utf8}(r(249))},888:function(e,t,r){e.exports=function(s){return function(){var e=s;var t=e.lib;var r=t.Base;var l=t.WordArray;var i=e.algo;var n=i.MD5;var o=i.EvpKDF=r.extend({cfg:r.extend({keySize:128/32,hasher:n,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){var r;var i=this.cfg;var n=i.hasher.create();var o=l.create();var s=o.words;var a=i.keySize;var c=i.iterations;while(s.length<a){if(r)n.update(r);r=n.update(e).finalize(t);n.reset();for(var u=1;u<c;u++){r=n.finalize(r);n.reset()}o.concat(r)}o.sigBytes=a*4;return o}});e.EvpKDF=function(e,t,r){return o.create(r).compute(e,t)}}(),s.EvpKDF}(r(249),(r(783),r(824)))},10:function(e,t,r){e.exports=function(e){return e.HmacSHA256}(r(249),(r(153),r(824)))},824:function(e,t,r){e.exports=function(s){(function(){var e=s;var t=e.lib;var r=t.Base;var i=e.enc;var u=i.Utf8;var n=e.algo;var o=n.HMAC=r.extend({init:function(e,t){e=this._hasher=new e.init;if(typeof t=="string")t=u.parse(t);var r=e.blockSize;var i=r*4;if(t.sigBytes>i)t=e.finalize(t);t.clamp();var n=this._oKey=t.clone();var o=this._iKey=t.clone();var s=n.words;var a=o.words;for(var c=0;c<r;c++){s[c]^=1549556828;a[c]^=909522486}n.sigBytes=o.sigBytes=i;this.reset()},reset:function(){var e=this._hasher;e.reset();e.update(this._iKey)},update:function(e){this._hasher.update(e);return this},finalize:function(e){var t=this._hasher;var r=t.finalize(e);t.reset();var i=t.finalize(this._oKey.clone().concat(r));return i}})})()}(r(249))},433:function(e,t,r){e.exports=function(o){return function(){if(typeof ArrayBuffer!="function")return;var e=o;var t=e.lib;var r=t.WordArray;var n=r.init;var i=r.init=function(e){if(e instanceof ArrayBuffer)e=new Uint8Array(e);if(e instanceof Int8Array||typeof Uint8ClampedArray!=="undefined"&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(e instanceof Uint8Array){var t=e.byteLength;var r=[];for(var i=0;i<t;i++)r[i>>>2]|=e[i]<<24-i%4*8;n.call(this,r,t)}else n.apply(this,arguments)};i.prototype=r}(),o.lib.WordArray}(r(249))},214:function(e,t,r){e.exports=function(s){return function(l){var e=s;var t=e.lib;var r=t.WordArray;var i=t.Hasher;var n=e.algo;var O=[];(function(){for(var e=0;e<64;e++)O[e]=l.abs(l.sin(e+1))*4294967296|0})();var o=n.MD5=i.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var i=t+r;var n=e[i];e[i]=(n<<8|n>>>24)&16711935|(n<<24|n>>>8)&4278255360}var o=this._hash.words;var s=e[t+0];var a=e[t+1];var c=e[t+2];var u=e[t+3];var l=e[t+4];var p=e[t+5];var f=e[t+6];var h=e[t+7];var d=e[t+8];var y=e[t+9];var g=e[t+10];var v=e[t+11];var _=e[t+12];var m=e[t+13];var b=e[t+14];var x=e[t+15];var k=o[0];var w=o[1];var C=o[2];var S=o[3];k=FF(k,w,C,S,s,7,O[0]);S=FF(S,k,w,C,a,12,O[1]);C=FF(C,S,k,w,c,17,O[2]);w=FF(w,C,S,k,u,22,O[3]);k=FF(k,w,C,S,l,7,O[4]);S=FF(S,k,w,C,p,12,O[5]);C=FF(C,S,k,w,f,17,O[6]);w=FF(w,C,S,k,h,22,O[7]);k=FF(k,w,C,S,d,7,O[8]);S=FF(S,k,w,C,y,12,O[9]);C=FF(C,S,k,w,g,17,O[10]);w=FF(w,C,S,k,v,22,O[11]);k=FF(k,w,C,S,_,7,O[12]);S=FF(S,k,w,C,m,12,O[13]);C=FF(C,S,k,w,b,17,O[14]);w=FF(w,C,S,k,x,22,O[15]);k=GG(k,w,C,S,a,5,O[16]);S=GG(S,k,w,C,f,9,O[17]);C=GG(C,S,k,w,v,14,O[18]);w=GG(w,C,S,k,s,20,O[19]);k=GG(k,w,C,S,p,5,O[20]);S=GG(S,k,w,C,g,9,O[21]);C=GG(C,S,k,w,x,14,O[22]);w=GG(w,C,S,k,l,20,O[23]);k=GG(k,w,C,S,y,5,O[24]);S=GG(S,k,w,C,b,9,O[25]);C=GG(C,S,k,w,u,14,O[26]);w=GG(w,C,S,k,d,20,O[27]);k=GG(k,w,C,S,m,5,O[28]);S=GG(S,k,w,C,c,9,O[29]);C=GG(C,S,k,w,h,14,O[30]);w=GG(w,C,S,k,_,20,O[31]);k=HH(k,w,C,S,p,4,O[32]);S=HH(S,k,w,C,d,11,O[33]);C=HH(C,S,k,w,v,16,O[34]);w=HH(w,C,S,k,b,23,O[35]);k=HH(k,w,C,S,a,4,O[36]);S=HH(S,k,w,C,l,11,O[37]);C=HH(C,S,k,w,h,16,O[38]);w=HH(w,C,S,k,g,23,O[39]);k=HH(k,w,C,S,m,4,O[40]);S=HH(S,k,w,C,s,11,O[41]);C=HH(C,S,k,w,u,16,O[42]);w=HH(w,C,S,k,f,23,O[43]);k=HH(k,w,C,S,y,4,O[44]);S=HH(S,k,w,C,_,11,O[45]);C=HH(C,S,k,w,x,16,O[46]);w=HH(w,C,S,k,c,23,O[47]);k=II(k,w,C,S,s,6,O[48]);S=II(S,k,w,C,h,10,O[49]);C=II(C,S,k,w,b,15,O[50]);w=II(w,C,S,k,p,21,O[51]);k=II(k,w,C,S,_,6,O[52]);S=II(S,k,w,C,u,10,O[53]);C=II(C,S,k,w,g,15,O[54]);w=II(w,C,S,k,a,21,O[55]);k=II(k,w,C,S,d,6,O[56]);S=II(S,k,w,C,x,10,O[57]);C=II(C,S,k,w,f,15,O[58]);w=II(w,C,S,k,m,21,O[59]);k=II(k,w,C,S,l,6,O[60]);S=II(S,k,w,C,v,10,O[61]);C=II(C,S,k,w,c,15,O[62]);w=II(w,C,S,k,y,21,O[63]);o[0]=o[0]+k|0;o[1]=o[1]+w|0;o[2]=o[2]+C|0;o[3]=o[3]+S|0},_doFinalize:function(){var e=this._data;var t=e.words;var r=this._nDataBytes*8;var i=e.sigBytes*8;t[i>>>5]|=128<<24-i%32;var n=l.floor(r/4294967296);var o=r;t[(i+64>>>9<<4)+15]=(n<<8|n>>>24)&16711935|(n<<24|n>>>8)&4278255360;t[(i+64>>>9<<4)+14]=(o<<8|o>>>24)&16711935|(o<<24|o>>>8)&4278255360;e.sigBytes=(t.length+1)*4;this._process();var s=this._hash;var a=s.words;for(var c=0;c<4;c++){var u=a[c];a[c]=(u<<8|u>>>24)&16711935|(u<<24|u>>>8)&4278255360}return s},clone:function(){var e=i.clone.call(this);e._hash=this._hash.clone();return e}});function FF(e,t,r,i,n,o,s){var a=e+(t&r|~t&i)+n+s;return(a<<o|a>>>32-o)+t}function GG(e,t,r,i,n,o,s){var a=e+(t&i|r&~i)+n+s;return(a<<o|a>>>32-o)+t}function HH(e,t,r,i,n,o,s){var a=e+(t^r^i)+n+s;return(a<<o|a>>>32-o)+t}function II(e,t,r,i,n,o,s){var a=e+(r^(t|~i))+n+s;return(a<<o|a>>>32-o)+t}e.MD5=i._createHelper(o);e.HmacMD5=i._createHmacHelper(o)}(Math),s.MD5}(r(249))},568:function(e,t,r){e.exports=function(t){return t.mode.CFB=function(){var e=t.lib.BlockCipherMode.extend();e.Encryptor=e.extend({processBlock:function(e,t){var r=this._cipher;var i=r.blockSize;generateKeystreamAndEncrypt.call(this,e,t,i,r);this._prevBlock=e.slice(t,t+i)}});e.Decryptor=e.extend({processBlock:function(e,t){var r=this._cipher;var i=r.blockSize;var n=e.slice(t,t+i);generateKeystreamAndEncrypt.call(this,e,t,i,r);this._prevBlock=n}});function generateKeystreamAndEncrypt(e,t,r,i){var n;var o=this._iv;if(o){n=o.slice(0);this._iv=undefined}else n=this._prevBlock;i.encryptBlock(n,0);for(var s=0;s<r;s++)e[t+s]^=n[s]}return e}(),t.mode.CFB}(r(249),r(109))},991:function(e,t,r){e.exports=function(e){return e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding}(r(249),r(109))},783:function(e,t,r){e.exports=function(s){return function(){var e=s;var t=e.lib;var r=t.WordArray;var i=t.Hasher;var n=e.algo;var p=[];var o=n.SHA1=i.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){var r=this._hash.words;var i=r[0];var n=r[1];var o=r[2];var s=r[3];var a=r[4];for(var c=0;c<80;c++){if(c<16)p[c]=e[t+c]|0;else{var u=p[c-3]^p[c-8]^p[c-14]^p[c-16];p[c]=u<<1|u>>>31}var l=(i<<5|i>>>27)+a+p[c];if(c<20)l+=(n&o|~n&s)+1518500249;else if(c<40)l+=(n^o^s)+1859775393;else if(c<60)l+=(n&o|n&s|o&s)-1894007588;else l+=(n^o^s)-899497514;a=s;s=o;o=n<<30|n>>>2;n=i;i=l}r[0]=r[0]+i|0;r[1]=r[1]+n|0;r[2]=r[2]+o|0;r[3]=r[3]+s|0;r[4]=r[4]+a|0},_doFinalize:function(){var e=this._data;var t=e.words;var r=this._nDataBytes*8;var i=e.sigBytes*8;t[i>>>5]|=128<<24-i%32;t[(i+64>>>9<<4)+14]=Math.floor(r/4294967296);t[(i+64>>>9<<4)+15]=r;e.sigBytes=t.length*4;this._process();return this._hash},clone:function(){var e=i.clone.call(this);e._hash=this._hash.clone();return e}});e.SHA1=i._createHelper(o);e.HmacSHA1=i._createHmacHelper(o)}(),s.SHA1}(r(249))},153:function(e,t,r){e.exports=function(c){return function(n){var e=c;var t=e.lib;var r=t.WordArray;var i=t.Hasher;var o=e.algo;var s=[];var k=[];(function(){function isPrime(e){var t=n.sqrt(e);for(var r=2;r<=t;r++)if(!(e%r))return false;return true}function getFractionalBits(e){return(e-(e|0))*4294967296|0}var e=2;var t=0;while(t<64){if(isPrime(e)){if(t<8)s[t]=getFractionalBits(n.pow(e,1/2));k[t]=getFractionalBits(n.pow(e,1/3));t++}e++}})();var w=[];var a=o.SHA256=i.extend({_doReset:function(){this._hash=new r.init(s.slice(0))},_doProcessBlock:function(e,t){var r=this._hash.words;var i=r[0];var n=r[1];var o=r[2];var s=r[3];var a=r[4];var c=r[5];var u=r[6];var l=r[7];for(var p=0;p<64;p++){if(p<16)w[p]=e[t+p]|0;else{var f=w[p-15];var h=(f<<25|f>>>7)^(f<<14|f>>>18)^f>>>3;var d=w[p-2];var y=(d<<15|d>>>17)^(d<<13|d>>>19)^d>>>10;w[p]=h+w[p-7]+y+w[p-16]}var g=a&c^~a&u;var v=i&n^i&o^n&o;var _=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22);var m=(a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25);var b=l+m+g+k[p]+w[p];var x=_+v;l=u;u=c;c=a;a=s+b|0;s=o;o=n;n=i;i=b+x|0}r[0]=r[0]+i|0;r[1]=r[1]+n|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]+u|0;r[7]=r[7]+l|0},_doFinalize:function(){var e=this._data;var t=e.words;var r=this._nDataBytes*8;var i=e.sigBytes*8;t[i>>>5]|=128<<24-i%32;t[(i+64>>>9<<4)+14]=n.floor(r/4294967296);t[(i+64>>>9<<4)+15]=r;e.sigBytes=t.length*4;this._process();return this._hash},clone:function(){var e=i.clone.call(this);e._hash=this._hash.clone();return e}});e.SHA256=i._createHelper(a);e.HmacSHA256=i._createHmacHelper(a)}(Math),c.SHA256}(r(249))},187:e=>{function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(e){return"function"==typeof e}function isObject(e){return"object"==typeof e&&null!==e}function isUndefined(e){return void 0===e}((e.exports=EventEmitter).EventEmitter=EventEmitter).prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(e){if(!function isNumber(e){return"number"==typeof e}(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},EventEmitter.prototype.emit=function(e){var t,r,i,n,o,s,a;if((this._events||(this._events={}),"error"===e)&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length))throw(a=arguments[1])instanceof Error?a:((s=new Error('Uncaught, unspecified "error" event. ('+a+")")).context=a,s);if(isUndefined(t=this._events[e]))return!1;if(isFunction(t))switch(arguments.length){case 1:t.call(this);break;case 2:t.call(this,arguments[1]);break;case 3:t.call(this,arguments[1],arguments[2]);break;default:i=Array.prototype.slice.call(arguments,1),t.apply(this,i)}else if(isObject(t))for(i=Array.prototype.slice.call(arguments,1),r=(o=t.slice()).length,n=0;n<r;n++)o[n].apply(this,i);return!0},EventEmitter.prototype.on=EventEmitter.prototype.addListener=function(e,t){if(isFunction(t))return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,isFunction(t.listener)?t.listener:t),this._events[e]?isObject(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,isObject(this._events[e])&&!this._events[e].warned&&(t=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners)&&0<t&&this._events[e].length>t&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace)&&console.trace(),this;throw TypeError("listener must be a function")},EventEmitter.prototype.once=function(e,t){var r;if(isFunction(t))return r=!1,g.listener=t,this.on(e,g),this;throw TypeError("listener must be a function");function g(){this.removeListener(e,g),r||(r=!0,t.apply(this,arguments))}},EventEmitter.prototype.removeListener=function(e,t){var r,i,n,o;if(!isFunction(t))throw TypeError("listener must be a function");if(this._events&&this._events[e])if(n=(r=this._events[e]).length,i=-1,r===t||isFunction(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(isObject(r)){for(o=n;0<o--;)if(r[o]===t||r[o].listener&&r[o].listener===t){i=o;break}if(i<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},EventEmitter.prototype.removeAllListeners=function(e){var t,r;if(this._events)if(this._events.removeListener)if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);this.removeAllListeners("removeListener"),this._events={}}else{if(isFunction(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);delete this._events[e]}else 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e];return this},EventEmitter.prototype.listeners=function(e){e=this._events&&this._events[e]?isFunction(this._events[e])?[this._events[e]]:this._events[e].slice():[];return e},EventEmitter.prototype.listenerCount=function(e){if(this._events){e=this._events[e];if(isFunction(e))return 1;if(e)return e.length}return 0},EventEmitter.listenerCount=function(e,t){return e.listenerCount(t)}},391:(e,t,r)=>{e.exports=function(){return r(855)('(()=>{function dec2hex(n){if(void 0!==n)return function toEight(n){return n.length<8?toEight(n="0".concat(n)):n}(Number(n).toString(16))}self.onmessage=function(n){var n=n.data,t=n[0],n=n[1],e=function crc32(n,t){for(var e=[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],r=("undefined"!=typeof Int32Array&&(e=new Int32Array(e)),-1^~~t),o=(n=new Uint8Array(n)).length,i=0;i<o;i++)r=e[255&(r^n[i])]^r>>>8;return(-1^r)>>>0}(t,0);postMessage([t,dec2hex(e),n],[t])}})();',null)}},855:e=>{"use strict";var n=window.URL||window.webkitURL;e.exports=function(t,r){try{try{var i;try{(i=new(window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder)).append(t),i=i.getBlob()}catch(e){i=new Blob([t])}return new Worker(n.createObjectURL(i))}catch(e){return new Worker("data:application/javascript,"+encodeURIComponent(t))}}catch(e){if(r)return new Worker(r);throw Error("Inline worker is not supported")}}},480:()=>{}},n={};function __webpack_require__(e){var t=n[e];return void 0!==t||(t=n[e]={exports:{}},r[e].call(t.exports,t,t.exports,__webpack_require__)),t.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Qe={};return(()=>{"use strict";__webpack_require__.d(Qe,{default:()=>Ge});var r=__webpack_require__(187),n=__webpack_require__.n(r);const C={debug:!1,region:"cn-north-1",getSliceFunc:null,uploadSliceCount:5,retryUploadTime:3,retryProcess:!0,retryProcessTime:3,retryTaskTime:3,maxProcessPause:20,schema:"https",useLocalStorage:!0};function _typeof(e){return(_typeof="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)}var s=function e(){return(s=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function t(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,o=r.call(e),s=[];try{for(;(void 0===t||0<t--)&&!(i=o.next()).done;)s.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s}function i(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(t(arguments[r]));return e}function $5(e,a){var t,r=function r(e){var t=document.createElement("a");return t.href=e,t},i=window.screen.width,n=window.screen.height,o=window.navigator.appVersion,s=window.navigator.userAgent,c=window.navigator.language,u=document.referrer,l=u?r(u).hostname:"",p=function(e){var e=(e=r(e).search).slice(1),i={};return e.split("&").forEach(function(e){var t,r,e=e.split("=");e.length&&(t=e[0],r=e[1]),r=r&&r.replace(/\%/g,"%25"),i[t]=decodeURIComponent(void 0===r?"":r)}),i}(window.location.href),f="",h="",d="",y=""+parseFloat(o);-1!==(v=s.indexOf("Opera"))&&(d="Opera",y=s.substring(v+6),-1!==(v=s.indexOf("Version")))&&(y=s.substring(v+8)),-1!==(v=s.indexOf("Edge"))?(d="Microsoft Edge",y=s.substring(v+5)):-1!==(v=s.indexOf("MSIE"))?(d="Microsoft Internet Explorer",y=s.substring(v+5)):-1!==s.indexOf("Chrome")?-1!==(v=s.indexOf("MicroMessenger"))?(d="weixin",y=s.substring(v+15,v+20)):-1!==(v=s.indexOf("MQQBrowser"))?(d="qqbrowser",y=s.substring(v+11,v+15)):-1!==(v=s.indexOf("Chrome"))&&(d="Chrome",y=s.substring(v+7)):-1!==s.indexOf("Safari")?-1!==(v=s.indexOf("QQ"))?(d="qqbrowser",y=s.substring(v+10,v+16)):-1!==(v=s.indexOf("Safari"))&&(d="Safari",y=s.substring(v+7),-1!==(v=s.indexOf("Version")))&&(y=s.substring(v+8)):-1!==(v=s.indexOf("Firefox"))?(d="Firefox",y=s.substring(v+8)):-1!==(v=s.indexOf("MicroMessenger"))?(d="weixin",y=s.substring(v+15,v+20)):-1!==(v=s.indexOf("QQ"))&&(d="qqbrowser",y=s.substring(v+3,v+8)),-1!==(t=(y=-1!==(t=(y=-1!==(t=y.indexOf(";"))?y.substring(0,t):y).indexOf(" "))?y.substring(0,t):y).indexOf(")"))&&(y=y.substring(0,t));for(var g,v=/Mobile|htc|mini|Android|iP(ad|od|hone)/.test(o)?"wap":"web",_=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0)/},{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:"Sun OS",r:/SunOS/},{s:"Linux",r:/(Linux|X11)/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/}],m=0;m<_.length;m++){var b=_[m];if(b.r.test(s)){f=b.s;break}}function I(e,t){e=e.exec(t);return e&&e[1]?e[1]:""}switch(/Windows/.test(f)&&(h=I(/Windows (.*)/,f),f="windows"),f){case"Mac OS X":h=I(/Mac OS X (10[\.\_\d]+)/,s),f="mac";break;case"Android":h=I(/Android ([\.\_\d]+)/,g=s)||I(/Android\/([\.\_\d]+)/,g),f="android";break;case"iOS":h=(h=/OS (\d+)_(\d+)_?(\d+)?/.exec(o))?h[1]+"."+h[2]+"."+(0|h[3]):"",f="ios"}return e=e?function(){var e=a?"_tea_utm_cache_"+a:"_tea_utm_cache",t={},r={utm_source:p.utm_source,utm_medium:p.utm_medium,utm_campaign:p.utm_campaign,utm_term:p.utm_term,utm_content:p.utm_content};try{var i,n,o=window.sessionStorage,s=!1;for(i in r)r[i]&&(t[i]=r[i],s=!0);s?o.setItem(e,JSON.stringify(t)):(n=o.getItem(e))&&(t=JSON.parse(n))}catch(e){return r}return t}():{},{browser:d,browser_version:y,platform:v,os_name:f,os_version:h,userAgent:s,screen_width:i,screen_height:n,device_model:function(e){var t,r,i="";try{"android"===e?navigator.userAgent.split(";").forEach(function(e){-1<e.indexOf("Build/")&&(i=e.slice(0,e.indexOf("Build/")))}):"ios"!==e&&"mac"!==e||(r=(t=navigator.userAgent.replace("Mozilla/5.0 (","")).indexOf(";"),i=t.slice(0,r))}catch(e){}return i.trim()}(f),language:c,referrer:u,referrer_host:l,utm_source:e.utm_source,utm_medium:e.utm_medium,utm_campaign:e.utm_campaign,utm_term:e.utm_term,utm_content:e.utm_content,isSupportBeacon:("ios"!==f||"safari"!==d)&&(!(!window.navigator||!window.navigator.sendBeacon)||void 0)}}(function(e){e.exports=function i(){function e(){for(var e=0,t={};e<arguments.length;e++){var r,i=arguments[e];for(r in i)t[r]=i[r]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function i(u){function r(){}function o(t,i,n){if("undefined"!=typeof document){"number"==typeof(n=e({path:"/"},r.defaults,n)).expires&&(n.expires=new Date(+new Date+864e5*n.expires)),n.expires=n.expires?n.expires.toUTCString():"";try{var o=JSON.stringify(i);/^[\{\[]/.test(o)&&(i=o)}catch(e){}i=u.write?u.write(i,t):encodeURIComponent(String(i)).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 s,a="";for(s in n)n[s]&&(a+="; "+s,!0!==n[s])&&(a+="="+n[s].split(";")[0]);return document.cookie=t+"="+i+a}}function s(e,r){if("undefined"!=typeof document){for(var i={},n=document.cookie?document.cookie.split("; "):[],o=0;o<n.length;o++){var s=n[o].split("="),a=s.slice(1).join("=");r||'"'!==a.charAt(0)||(a=a.slice(1,-1));try{var c=t(s[0]),a=(u.read||u)(a,c)||t(a);if(r)try{a=JSON.parse(a)}catch(e){}if(i[c]=a,e===c)break}catch(e){}}return e?i[e]:i}}return r.set=o,r.get=function(e){return s(e,!1)},r.getJSON=function(e){return s(e,!0)},r.remove=function(t,r){o(t,"",e(r,{expires:-1}))},r.defaults={},r.withConverter=i,r}(function(){})}()})(r={exports:{}});var S=r.exports,O=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}(),I={getItem:function getItem(e){try{var t=localStorage.getItem(e),r=t;try{t&&"string"==typeof t&&(r=JSON.parse(t))}catch(e){}return r||void 0}catch(e){}},setItem:function setItem(e,t){try{var r="string"==typeof t?t:JSON.stringify(t);localStorage.setItem(e,r)}catch(e){}},removeItem:function removeItem(e){try{localStorage.removeItem(e)}catch(e){}},getCookie:function getCookie(e){try{var t=document.cookie.match(new RegExp("(?:^|;)\\s*"+e+"=([^;]+)")),r=t?t[1]:"";return decodeURIComponent(r)}catch(e){return""}},setCookie:function setCookie(e,t,r){try{var i=+new Date+r;S.set(e,t,{expires:new Date(i),path:"/",domain:document.domain.split(".").slice(-2).join(".")})}catch(e){}},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}}()},U=function(){function e(e){this._storage=!e&&I.isSupportLS?I:new O}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){return this._storage.getCookie(e)},e.prototype.setCookie=function(e,t,r){this._storage.setCookie(e,t,r)},e.prototype.removeItem=function(e){this._storage.removeItem(e)},e}(),T={cn:"https://mcs.snssdk.com",sg:"https://sgali-mcs.byteoversea.com",va:"https://maliva-mcs.byteoversea.com"},j="/v1/user/webid",f={NO_URL:4001,IMG_ON:4e3,IMG_CATCH:4002,BEACON_FALSE:4003,XHR_ON:500,RESPONSE:5001},E=function _(e,t){return t?"__tea_cache_tokens_"+e:"__tea_cache_events_"+e},F=function p(r,i,n,o){try{var e=r.match(/\/v\d\//),t=e?e[0]:-1!==r.indexOf("/v1/")?"/v1/":"/v2/",s=r.split(t)[0];s?i.forEach(function(e){var e=function(e){var t,r="";for(t in e)e.hasOwnProperty(t)&&void 0!==e[t]&&(r+="&"+t+"="+encodeURIComponent(JSON.stringify(e[t])));return"&"===r[0]?r.slice(1):r}(e),t=new Image(1,1);t.onload=function(){t=null,n&&n()},t.onerror=function(){t=null,o&&o(r,i,f.IMG_ON)},t.src=s+"/v1/gif?"+e}):o(r,i,f.NO_URL)}catch(n){o&&o(r,i,f.IMG_CATCH,n.message)}},N=function l(e,t,r,i,n,o,s,a){var c=window.navigator.userAgent,c=-1!==window.navigator.appName.indexOf("Microsoft Internet Explorer")&&(-1!==c.indexOf("MSIE 8.0")||-1!==c.indexOf("MSIE 9.0")),u=!!r;if(!u&&c)F(e,t,i,n);else if(!u&&s)return $5(!1).isSupportBeacon?(a&&a(),void(window.navigator.sendBeacon(e,JSON.stringify(t))?i():n(e,t,f.BEACON_FALSE))):void F(e,t,i,n);o&&delete t.app_key,function(e,t,r,i,n){var o=new XMLHttpRequest;o.open("POST",""+e,!0),o.setRequestHeader("Content-Type","application/json; charset=utf-8"),n&&o.setRequestHeader("X-MCS-AppKey",""+n),o.onload=function(){if(r){var t=null;if(o.responseText){try{t=JSON.parse(o.responseText)}catch(e){t={}}r(t)}}},o.onerror=function(){o.abort(),i&&i(t,f.XHR_ON)},o.send(JSON.stringify(t))}(e,t,i,n,r)};function g(e){return e?(e^16*Math.random()>>e/4).toString(10):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,g)}var B,z=function v(){return g().replace(/-/g,"").slice(0,19)},H=function(){function e(e,t){this.browser=$5(!0,e.app_id),this.config=e,this.cfg=t,this.storage=new U(!1),this.appInfo=e.app_key||e.app_id,this.isNoWebid=e.disable_webid,this.isNoSsid=e.disable_webid||e.disable_ssid,this.domain=e.channel_domain||T[e.channel],this.tokenReady=!1,this.checkExp=e.checkExp||!1,this.enableCookie=e.cross_subdomain||!1,this.expiresTime=this.enableCookie?94608e6:0,this.fetchUrl=this.domain+j}return e.prototype._getToken=function(){this.tokensKey=E(this.appInfo,!0),this.cookieKey="__tea_cookie_tokens_"+this.appInfo;var e,t,r,i,n=this.storage.getItem(this.tokensKey);this.enableCookie?(i=this.storage.getCookie(this.cookieKey))?(i=decodeURIComponent(i),e=(i=JSON.parse(i)).user_unique_id,t=i.web_id,r=i.timestamp,i=i.ssid,this._setToken(t,e,i,r)):n?(this.storage.setCookie(this.cookieKey,encodeURIComponent(JSON.stringify(n)),this.expiresTime),this._checkLocal(n)):this._requestWebId():n?this._checkLocal(n):this._requestWebId()},e.prototype._checkLocal=function(e){e.web_id||(t=this.storage.getCookie("tt_webid"),n=this.storage.getCookie("__tea_sdk__ssid"),r=this.storage.getCookie("__tea_sdk__user_unique_id"),t&&n&&r&&(e={web_id:t,ssid:n,user_unique_id:r,timestamp:Date.now()},this.storage.setItem(this.tokensKey,e)));var t,r,e=this.storage.getItem(this.tokensKey),i=(r=e.user_unique_id,t=e.web_id,e.timestamp),n=e.ssid;t&&r?this._setToken(t,r,n,i):this._requestWebId()},e.prototype._setToken=function(e,t,r,i){if(this.uuid=t,this.web_id=e,this.ssid=r,this.checkExp){i=Date.now()-parseFloat(i);if(7344e6<i)return void this._requestWebId();if(432e7<i)return void this._updateWebId(e)}this._complete(e,t,r)},e.prototype._complete=function(e,t,r){this.cfg.envInfo.user.ssid=r,this.cfg.envInfo.user.web_id=e,this.cfg.envInfo.user.user_unique_id=t,this.tokenReady=!0},e.prototype._requestWebId=function(){this.isNoWebid?this._setwebId({web_id:z(),ssid:""}):this._fetchWebId(this.fetchUrl,!1)},e.prototype._updateWebId=function(e){e=this.domain+j+"/"+e+"/update";this._fetchWebId(e,!0)},e.prototype._fetchWebId=function(e,r){var i=this;this.isGetWebId=!0,N(e,{app_key:this.config.app_key,app_id:this.config.app_id,url:location.href,user_agent:this.browser.userAgent,referer:this.browser.referrer,user_unique_id:""},this.config.app_key,function(e){var t;e&&0===e.e?(r?(t={web_id:i.web_id,ssid:i.ssid,user_unique_id:i.uuid,timestamp:Date.now()},i.enableCookie&&i.storage.setCookie(i.cookieKey,encodeURIComponent(JSON.stringify(t)),i.expiresTime),i.storage.setItem(i.tokensKey,t),i._complete(i.web_id,i.uuid,i.ssid)):(i.isGetWebId=!1,i._setwebId(e)),i.isGetSsid?i._requestSsId():i.callback&&i.callback()):r?i._fetchWebId(i.fetchUrl,!1):i.isGetWebId=!1},function(){i.isGetWebId=!1},!0)},e.prototype._setwebId=function(e){var t=this.cfg.envInfo.user.web_id||e.web_id,r={web_id:t,ssid:e.ssid,user_unique_id:this._uuid||t,timestamp:Date.now()};this.enableCookie&&this.storage.setCookie(this.cookieKey,encodeURIComponent(JSON.stringify(r)),this.expiresTime),this.storage.setItem(this.tokensKey,r),this.cfg.envInfo.user.ssid=e.ssid,this.cfg.envInfo.user.web_id=t,this.cfg.envInfo.user.user_unique_id=this._uuid||t,this.uuid=this._uuid||t,this.web_id=t,this.ssid=e.ssid,this.tokenReady=!0},e.prototype._getSsid=function(e){e&&-1===["0","Null","None","","undefined"].indexOf(e)&&(this.uuid===e&&this.web_id&&this.ssid?this.tokenReady=!0:(this._uuid=e,this.uuid=e,this.cfg.envInfo.user.user_unique_id=e,this.isGetSsid=!0,this.isNoSsid||this.isGetWebId?this.callback&&this.callback():(this.tokenReady=!1,this.isGetSsid=!1,this._requestSsId())))},e.prototype._requestSsId=function(){var t=this,e=this.domain+"/v1/user/ssid";N(e,{app_key:this.config.app_key,app_id:this.config.app_id,web_id:this.web_id,user_unique_id:this.uuid},this.config.app_key,function(e){e&&0===e.e&&(t.cfg.envInfo.user.ssid=e.ssid,e={web_id:t.web_id,ssid:e.ssid,user_unique_id:t.uuid,timestamp:Date.now()},t.enableCookie&&t.storage.setCookie(t.cookieKey,encodeURIComponent(JSON.stringify(e)),t.expiresTime),t.storage.setItem(t.tokensKey,e)),t.tokenReady=!0,t.callback&&t.callback()},function(){t.tokenReady=!0,t.callback&&t.callback()},!0)},e.prototype.isTokenReady=function(){return this.tokenReady},e}(),L=function(){function t(e,t,r,i){this.cfg=t,this.config=e,this._token=r,this.appInfo=e.app_key||e.app_id,this.debugMode=!!e.log,this.evtDataKey=E(this.appInfo,!1);t=e.channel_domain||T[e.channel];this.reportUrl=e.report_url||t+"/v1/list",this.maxReport=e.max_report||20,this.storage=new U(!0),this.plugin=i,this.addListener()}return t.prototype.addListener=function(){var e=this;window.addEventListener("unload",function(){e.report(!0)},!1),window.addEventListener("beforeunload",function(){e.report(!0)},!1),document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&e.report(!0)},!1)},t.prototype.setReady=function(){this.isReady=!0,this.report()},t.prototype.event=function(e,t){var r=this,n=(void 0===e&&(e=[]),void 0===t&&(t=!1),this.storage.getItem(this.evtDataKey)||[]),t=t?i(e,n):i(n,e);this.storage.setItem(this.evtDataKey,t),this.reportTimer&&clearTimeout(this.reportTimer),t.length>=this.maxReport?this.report():this.reportTimer=setTimeout(function(){r.report(),r.reportTimer=null},30)},t.prototype.report=function(e){var t;void 0===e&&(e=!1),this._token.isTokenReady()&&this.isReady&&(t=this.storage.getItem(this.evtDataKey)||[],t=this._mergeEvents(t),this.storage.removeItem(this.evtDataKey),this._dealData(t,e))},t.prototype._mergeEvents=function(e){var t,r,i=this;return e.length?((t=this.cfg.get()).header.custom=JSON.stringify(t.header.custom),(r=[]).push(e),r.map(function(e){return{events:e.map(function(e){var t=s({},i.cfg.get("evtParams"),e.params);return delete t.__disable_storage__,s({},e,{params:JSON.stringify(t)})}),user:t.user,header:t.header,verbose:i.debugMode?1:void 0}})):e},t.prototype._dealData=function(e,r){var i=this;if(!e.length)return e;e.map(function(e){var t=[];return t.push(e),t}).forEach(function(e){var t=z();i._send(t,e,r)})},t.prototype._send=function(e,t,i){var n=this,o=(this.isSending=!0,function r(){n.isSending=!1});N(this.reportUrl,t,this.config.app_key,function(){o()},function(e,t){o(),n.cfg.get("reportErrorCallback")(e,t)},!1,i,o)},t}(),o=void 0,r=(new Date).getTimezoneOffset(),K=parseInt(""+-r/60,10),q=60*r,W=function(){function t(e){e=$5(!0,e);this.envInfo={user:{user_unique_id:o,user_type:o,user_id:o,user_is_auth:o,user_is_login:o,device_id:o,web_id:o,ip_addr_id:o,ssid:o},header:{app_id:o,app_name:o,app_install_id:o,install_id:o,app_package:o,app_channel:o,app_version:o,os_name:e.os_name,os_version:e.os_version,device_model:e.device_model,ab_client:o,ab_version:o,ab_sdk_version:o,traffic_type:o,client_ip:o,device_brand:o,os_api:o,access:o,language:e.language,region:o,app_language:o,app_region:o,creative_id:o,ad_id:o,campaign_id:o,log_type:o,rnd:o,platform:e.platform,sdk_version:"4.1.15",province:o,city:o,timezone:K,tz_offset:q,tz_name:o,sim_region:o,carrier:o,resolution:e.screen_width+"x"+e.screen_height,browser:e.browser,browser_version:e.browser_version,referrer:e.referrer,referrer_host:e.referrer_host,width:e.screen_width,height:e.screen_height,screen_width:e.screen_width,screen_height:e.screen_height,utm_term:e.utm_term,utm_content:e.utm_content,utm_source:e.utm_source,utm_medium:e.utm_medium,utm_campaign:e.utm_campaign,custom:{}}},this.evtParams={},this.reportErrorCallback=function(){}}return t.prototype.set=function(e,t){var r=this;if("disable_auto_pv"!==e)if("evtParams"===e||"_staging_flag"===e){var i="evtParams"===e?t:{_staging_flag:Number(t)},n=s({},i);Object.keys(n).forEach(function(e){r.evtParams[e]=n[e]})}else if("reportErrorCallback"===e&&"function"==typeof t)this.reportErrorCallback=t;else{var o,i="";if(-1<e.indexOf(".")&&(i=(o=e.split("."))[0],e=o[1]),"user_unique_id"===e){if(!t)return;if(-1!==["0","Null","None","","undefined"].indexOf(t))return}if("web_id"===(e="os_version"===e?""+t:e)){if(!t)return;(!this.envInfo.user.user_unique_id||this.envInfo.user.user_unique_id&&this.envInfo.user.user_unique_id===this.envInfo.user.web_id)&&(this.envInfo.user.user_unique_id=t)}i?"user"===i||"header"===i?this.envInfo[i][e]=t:this.envInfo.header.custom[e]=t:this.envInfo.user.hasOwnProperty(e)?-1<["user_type","device_id","ip_addr_id"].indexOf(e)?this.envInfo.user[e]=Number(t):-1<["user_id","web_id","user_unique_id","ssid"].indexOf(e)?this.envInfo.user[e]=String(t):-1<["user_is_auth","user_is_login"].indexOf(e)&&(this.envInfo.user[e]=Boolean(t)):this.envInfo.header.hasOwnProperty(e)?this.envInfo.header[e]=t:this.envInfo.header.custom[e]=t}},t.prototype.get=function(e){return e?"evtParams"===e?this.evtParams:"reportErrorCallback"===e?this.reportErrorCallback:JSON.parse(JSON.stringify(this.envInfo[e])):JSON.parse(JSON.stringify(this.envInfo))},t}(),G=function(){function e(e,t){this.isLog=t,this.name=e||""}var t=e.prototype;return t.info=function(e){this.isLog&&console.log(this.name+" "+e)},t.warn=function(e){this.isLog&&console.warn(this.name+" "+e)},t.error=function(e){this.isLog&&console.error(this.name+" "+e)},t.throw=function(e){throw this.error(this.name),new Error(e)},e}(),Q=i(["init","config","send","start"],[]),J=(B=+Date.now()+Number((""+Math.random()).slice(2,8)),function(){function i(e){var r=this;this.predefinePageView=function(e){void 0===e&&(e={});var t=s({title:document.title||location.pathname,url:location.href,url_path:location.pathname,time:Date.now(),referrer:window.document.referrer},r._event.closeStorage?{}:{__disable_storage__:1}),t=s({},t,e);r.event("predefine_pageview",t,!0)},this.name=e,this._isSend=!1,this.autoPV=!0}return i.prototype.init=function(e){var t=this;if(!this._inited){if(this._inited=!0,!e||"object"!=_typeof(e))throw new Error("init参数有误,请检查");var r=e.app_id,i=e.app_key,n=e.log;this._config=new W(r),this.logger=new G(this.name,n),i||r||this.logger.throw("没有传入 app_key 或 app_id "),r&&"number"!=typeof r&&this.logger.throw("app_id参数有误,请检查 "),i&&"string"!=typeof i&&this.logger.warn("app_key为空,如果有请传入"),e.channel_domain||-1!==["cn","sg","va"].indexOf(e.channel)||this.logger.throw("channel 变量只能是 `cn`, `sg`,`va`"),this._config.set("app_id",r),e.channel=e.channel||"cn",this._initConfig=e,this._token=new H(e,this._config),this._token.callback=function(){t.callbackSend&&t.start()},this._event=new L(e,this._config,this._token,this.plugin),this._token._getToken()}},i.prototype.config=function(e){if(this._inited)if(e&&"object"==_typeof(e)){if(e.user_unique_id){if("string"!=typeof e.user_unique_id)throw new Error("user_unique_id 只能是string");this._token._getSsid(e.user_unique_id)}for(var t in e.disable_auto_pv&&(this.autoPV=!1),e)this._config.set(t,e[t])}else this.logger.warn("config参数有误,请检查");else this.logger.warn("config应在init之后调用")},i.prototype.send=function(){this.start()},i.prototype.start=function(){this._token.isTokenReady()?this._isSend||(this._isSend=!0,this.logger.info("用户信息:"+JSON.stringify(this._config.get("user"))),this.autoPV&&this.predefinePageView(),this._event.setReady()):this.callbackSend=!0},i.prototype.event=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var i="boolean"==typeof e[e.length-1]&&e[e.length-1],n="boolean"==typeof e[e.length-1]?e.slice(0,e.length-1):e,o=t(n,1)[0],s=[];"Array"!==Object.prototype.toString.call(o).slice(8,-1)?s[0]=n:s=n,s=s.map(function(e){return function(e,t){var r=e,e=(/^event\./.test(e)&&(r=e.slice(6)),t);return(e="object"!=_typeof(e)?{}:e).event_index=B+=1,{event:r,params:e,local_time_ms:+new Date,is_bav:0}}(e[0],e[1])}),this._event.event(s,i)},i}());function R(e,t,r){t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}var V=function M(e){var o=this;return R(this,"_exportCollect",function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];o._isProcess?o._executeCmd.apply(o,t):(o.cmdQueue.push(t),o._processCmd())}),R(this,"_processCmd",function(){var e,r,i;0!==o.cmdQueue.length&&(e=o.cmdQueue,r=-1,e.forEach(function(e,t){"init"===e[0]&&(r=t)}),-1!==(i=r))&&(o._isProcess=!0,o._executeCmd.apply(o,o.cmdQueue[i]),o.cmdQueue.forEach(function(e,t){t!==i&&o._executeCmd.apply(o,e)}),o.cmdQueue=[])}),R(this,"_executeCmd",function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var i,n=t[0];-1<Q.indexOf(n)?(i=o.colloctor)[n].apply(i,t.slice(1)):(n=o.colloctor).event.apply(n,t)}),this.cmdQueue=[],this.name=e,this.colloctor=new J(e),this._isProcess=!1,this._alias={},this._processCmd(),Q.forEach(function(e){o._exportCollect[e]=o._exportCollect.bind(o,e)}),this._exportCollect},a={},c={},u=function P(e){return c[e]||(c[e]=[]),c[e]},X=function A(e){var e=t(e),r=e[0],e=e.slice(1),n=r.split(".");1===n.length?u("default").push(i([r],e)):2===n.length?"event"===n[0]?u("default").push(i([r],e)):u(n[0]).push(i([n[1]],e)):(r=n[0],n=[n[1],n[2]].join("."),u(r).push(i([n],e)))},$=function D(){h.q.forEach(function(e){e=[].slice.call(e);"Array"===Object.prototype.toString.call(e[0]).slice(8,-1)?e.forEach(function(e){X(e)}):X(e)}),Object.keys(c).forEach(function(t){c[t].forEach(function(e){!function(e){return a[e]||(a[e]=new V(e)),a[e]}(t).apply(void 0,i(e))}),c[t]=[]}),h.q=[]},h=function e(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];e.q.push(t),$()};h.q=[],h.l=Date.now(),h._instanceMap=a,h._instanceCmdMap=c,Q.forEach(function(e){h[e]=h.bind(null,e)}),function(e){var t,r;"undefined"!=typeof window&&(t=function(){if("undefined"!=typeof window)return window.TeaAnalyticsObject}())&&window[t]&&((r=window[t]).init||(e.q=r.q||[],e.l=r.l||Date.now(),window[t]=e))}(h),$();const Z=h;var Y={browserError:1e3,crc32:1e3,preUpload:1001,initUploadID:1002,process:1003,fileMerge:1004,complete:1005},ee="video",te="image",d="object",re={video:"video_upload",image:"image_upload",object:"object_upload"},y=1,ie=2,ne=3,_="vod",m="imagex",oe={"cn-north-1":"cn-north-1","us-east-1":"us-east-1","ap-singapore-1":"ap-singapore-1"},se={"cn-north-1":"https://vod.volcengineapi.com","ap-singapore-1":"https://vod.byteplusapi.com"},ae={"cn-north-1":"https://imagex.volcengineapi.com","us-east-1":"https://imagex-us-east-1.volcengineapi.com","ap-singapore-1":"https://imagex-ap-singapore-1.volcengineapi.com"},ce="{tosDomain}/{oid}?uploads",ue="{tosDomain}/{oid}?partNumber={number}&uploadID={uploadId}",le="{tosDomain}/{oid}?uploadID={uploadId}",pe="{tosDomain}/{oid}?uploadID={uploadId}",fe="{tosDomain}/{oid}";function LoggerV5_typeof(e){return(LoggerV5_typeof="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 _extends(){return(_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,function _toPropertyKey(e){e=function _toPrimitive(e,t){if("object"!==LoggerV5_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==LoggerV5_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===LoggerV5_typeof(e)?e:String(e)}(i.key),i)}}var he=function(){function Logger(e,t){!function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,Logger),this.options=e,this.context=t,this.teaLog=Z,this.teaLog.init({app_id:2562,channel:"cn",log:!1,disable_sdk_monitor:!0}),this.teaLog.config({evtParams:{sdk_version:"1.2.1",line_app_id:this.options.appId,toB:!0},user_unique_id:this.options.userId,disable_auto_pv:!0}),this.teaLog.start()}return function _createClass(e,t,r){t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(Logger,[{key:"send",value:function send(e){var t=this.context,r=e.key,t=t.tasks[r];if(e&&t){var i=Y[e.stage]||999,n=e.serviceType,o=e.isDirect,s=e.isImageBatchUpload,a=e.extra,c=e.type,t=e.fileType||t.fileType,u=e.fileSize||0,l={type:c,log_type:re[t],stage:i,fk:r,fs:u,req:e.req,res:e.res,ts:Math.round(Date.now()/1e3),sst:e.stageStartTime,set:e.stageEndTime,dur:e.duration,tdur:e.totalDuration,errc:null==a?void 0:a.errorCode,err:null==a?void 0:a.error,errmsg:null==a?void 0:a.message,msg:null==a?void 0:a.message,idu:o,ibu:s,serviceType:n},t=n===m?"image":"video",p="".concat(t);switch(p+="_".concat("error"===c||"retry"===c?c:i),i){case 1e3:this.teaLog(p,_extends({},l,{ex:JSON.stringify({errc:e.extra&&e.extra.errorCode,msg:e.extra&&e.extra.message,crc32Array:e.crc32Array,isDirect:e.isDirect})}));break;case 1001:this.teaLog(p,_extends({},l,{oid:e.oid,upload_host:e.tosDomain,ex:JSON.stringify({errc:e.extra&&e.extra.errorCode,err:e.extra&&e.extra.error,msg:e.extra&&e.extra.message,sig:e.signature})}));break;case 1002:this.teaLog(p,_extends({},l,{oid:e.oid,upload_host:e.tosDomain,uploadId:e.uploadID,ex:JSON.stringify({errc:e.extra&&e.extra.errorCode,msg:e.extra&&e.extra.message,upid:e.uploadID})}));break;case 1003:e.isAllFinish||e.isDirect||(delete l.sst,delete l.set,delete l.dur),this.teaLog(p,_extends({},l,{oid:e.oid,upload_host:e.tosDomain,uploadId:e.uploadID,si:e.slice_index,ex:JSON.stringify({errc:e.extra&&e.extra.errorCode,msg:e.extra&&e.extra.message,si:e.slice_index,af:e.isAllFinish})}));break;case 1004:this.teaLog(p,_extends({},l,{oid:e.oid,upload_host:e.tosDomain,uploadId:e.uploadID,ex:JSON.stringify({errc:e.extra&&e.extra.errorCode,msg:e.extra&&e.extra.message})}));break;case 1005:this.teaLog(p,_extends({},l,{oid:e.oid,upload_host:e.tosDomain,uploadId:e.uploadID,vid:e.uploadResult&&e.uploadResult.Vid,ex:JSON.stringify({errc:e.extra&&e.extra.errorCode,err:e.extra&&e.extra.error,msg:e.extra&&e.extra.message,vid:e.uploadResult&&e.uploadResult.Vid})}));break;default:this.teaLog(p,_extends({},l,{oid:e.oid,upload_host:e.tosDomain,ex:JSON.stringify({errc:e.extra&&e.extra.errorCode,msg:e.extra&&e.extra.message})}))}}}},{key:"console",value:function(t){function console(e){return t.apply(this,arguments)}return console.toString=function(){return t.toString()},console}(function(e){this.options.debug&&console.log(e)})}]),Logger}();const b={resolveLocalTimeDiff:function resolveLocalTimeDiff(e){var t=Number(e.substring(0,4)),r=Number(e.substring(4,6)),i=Number(e.substring(6,8)),n=Number(e.substring(8,10)),o=Number(e.substring(10,12)),e=Number(e.substring(12,14));return Date.UTC(t,r-1,i,n-8,o,e)-Date.now()},concatAb:function concatAb(){for(var e=0,t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];for(var n=0,o=r;n<o.length;n++)e+=o[n].byteLength;for(var s=new ArrayBuffer(e),a=new Uint8Array(s),c=0,u=0,l=r;u<l.length;u++){var p=l[u];a.set(new Uint8Array(p),c),c+=p.byteLength}return s},str2ab:function str2ab(e){for(var t=e.length,r=new ArrayBuffer(t),i=new Uint8Array(r),n=0;n<t;n++)i[n]=e.charCodeAt(n);return r},generateKey:function generateKey(e){for(var t="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=r.length,n=0;n<e;n++)t+=r.charAt(Math.floor(Math.random()*i));return t},resolveUri:function resolveUri(t){if(!t)return"";if(Array.isArray(t))return t.map(function(t){try{return t.split("/")[0]+"/"+encodeURIComponent(t.split("/").slice(1).join("/"))}catch(e){return t}});try{return t.split("/")[0]+"/"+encodeURIComponent(t.split("/").slice(1).join("/"))}catch(e){return t}},urlTemplate:function urlTemplate(t,r){var i;return r=r||{},Object.keys(r).forEach(function(e){i=new RegExp("{".concat(e,"}"),"g"),t=t.replace(i,r[e])}),t},toQueryString:function toQueryString(){var r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},i=[];return Object.keys(r).map(function(t){var e=r[t];"[object Array]"===Object.prototype.toString.call(e)?e.sort().forEach(function(e){i.push("".concat(t,"=").concat(encodeURIComponent(e)))}):i.push("".concat(t,"=").concat(encodeURIComponent(r[t])))}),i.join("&")},arrayToObject:function arrayToObject(e){var t={};return Array.isArray(e)&&e.forEach(function(e){t[e.Key.toLowerCase()]=e.Value}),t},supportChunked:function supportChunked(){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 supportXhr(){return!!window.FormData||window.ProgressEvent&&window.FileReader},supportCrc32:function supportCrc32(){var e=window.FileReader&&window.FileReader.prototype.readAsBinaryString;return"undefined"!=typeof Int32Array&&e&&(Blob.prototype.slice||Blob.prototype.webkitSlice||Blob.prototype.mozSlice)},storage:function storage(e){var r=e,e={removeItem:function removeItem(e){delete r.cache[e]},setItem:function setItem(e,t){r.cache[e]=t},getItem:function getItem(e){return r.cache[e]},clear:function clear(){delete r.cache,r.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 noop(){},getUnique:function getUnique(e){return"".concat(e,"_").concat((new Date).getTime(),"_").concat(parseInt(1e6*Math.random()))},getFileSliceLength:function getFileSliceLength(e,t){var r=e.size,i=1048576;return t&&"function"==typeof t?t(r)<5242880?5242880:t(r)||r:200*i<r?10*i:r<=200*i&&2*i<=r?5*i:e.size},getFileSuffix:function getFileSuffix(e){var t;if(e&&"[object String]"===Object.prototype.toString.call(e))return 0<(t=e.lastIndexOf("."))?"."+e.substring(t+1):""}};const x={crc32:function crc32(e,t){for(var r=[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],i=("undefined"!=typeof Int32Array&&(r=new Int32Array(r)),-1^~~t),n=(e=new Uint8Array(e)).length,o=0;o<n;o++)i=r[255&(i^e[o])]^i>>>8;return(-1^i)>>>0},dec2hex:function dec2hex(e){if(void 0!==e)return function toEight(e){return e.length<8?toEight(e="0".concat(e)):e}(Number(e).toString(16))}};function Crc32_typeof(e){return(Crc32_typeof="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 Crc32_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,function Crc32_toPropertyKey(e){e=function Crc32_toPrimitive(e,t){if("object"!==Crc32_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==Crc32_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===Crc32_typeof(e)?e:String(e)}(i.key),i)}}var de=function(){function Crc32(e,t,r,i){!function Crc32_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,Crc32),this.file=e,this.successProcess=r,this.failProcess=i,this.sliceLength=t,this.retryTime=0,this.fileSize=e.size,this.crc32Array=[]}return function Crc32_createClass(e,t,r){t&&Crc32_defineProperties(e.prototype,t),r&&Crc32_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(Crc32,[{key:"start",value:function start(){this.readFileCrc32(this.file)}},{key:"readFileCrc32",value:function readFileCrc32(t){var r=this,e=this.sliceLength,i=t.slice||t.webkitSlice||t.mozSlice,n=new FileReader,o=0,s=0,a=0;(function read(){s<t.size&&(s=Math.min(o+e,t.size),104857600<t.size)&&t.size-s<=5242880&&(s=t.size),n.readAsArrayBuffer(i.call(t,o,s)),n.onload=function(e){e=e.target.result;a=x.crc32(e,0),r.crc32Array.push({start:o,end:s,crc32:x.dec2hex(a),buffer:e}),(o=s)<t.size?read():r.success(r.crc32Array)}})()}},{key:"success",value:function success(e){this.successProcess(e)}},{key:"fail",value:function fail(e,t,r,i){3<=this.retryTime?this.failProcess():(this.readFileCrc32(e,t,r,i),this.retryTime++)}}]),Crc32}();function crc32_dec2hex(e){if(void 0!==e)return function crc32_toEight(e){return e.length<8?crc32_toEight(e="0".concat(e)):e}(Number(e).toString(16))}function lib_crc32(e,t){for(var r=[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],i=("undefined"!=typeof Int32Array&&(r=new Int32Array(r)),-1^~~t),n=(e=new Uint8Array(e)).length,o=0;o<n;o++)i=r[255&(i^e[o])]^i>>>8;return crc32_dec2hex((-1^i)>>>0)}var r=__webpack_require__(433),ye=__webpack_require__.n(r),r=__webpack_require__(452),ge=__webpack_require__.n(r),r=__webpack_require__(743),ve=__webpack_require__.n(r),r=__webpack_require__(568),_e=__webpack_require__.n(r),r=__webpack_require__(991),me=__webpack_require__.n(r);function cipher_imagex_encrypt(e){var t=e.key,r=e.iv,e=e.data;return function wordArray2ArrayBuffer(e){for(var t=e.words,r=e.sigBytes,i=new Uint8Array(r),n=0;n<r;n+=1)i[n]=t[n>>>2]>>>24-n%4*8&255;return i}(ge().encrypt(ye().create(e),ve().parse(t),{mode:_e(),padding:me(),iv:ve().parse(r)}).ciphertext).buffer}function FileCrc32_typeof(e){return(FileCrc32_typeof="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 FileCrc32_extends(){return(FileCrc32_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}function _toConsumableArray(e){return function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}(e)||function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function _unsupportedIterableToArray(e,t){var r;if(e)return"string"==typeof e?_arrayLikeToArray(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)?_arrayLikeToArray(e,t):void 0}(e)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function FileCrc32_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,function FileCrc32_toPropertyKey(e){e=function FileCrc32_toPrimitive(e,t){if("object"!==FileCrc32_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==FileCrc32_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===FileCrc32_typeof(e)?e:String(e)}(i.key),i)}}var be=function(){function FileCrc32(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};!function FileCrc32_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,FileCrc32),this.context=e.context,this.key=e.key,this.currFileCtx=this.context.tasks[this.key],this.isDirect=e.isDirect,this.isImageBatchUpload=e.isImageBatchUpload,this.serviceName=e.serviceName||_,this.file=e.file,this.sliceLength=b.getFileSliceLength(this.file,t.getSliceFunc),this.config=t}return function FileCrc32_createClass(e,t,r){t&&FileCrc32_defineProperties(e.prototype,t),r&&FileCrc32_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(FileCrc32,[{key:"start",value:function start(e,t,r){this.successProcess=t,this.failProcess=r,this._st=Date.now(),this.currFileCtx.imagexEnableEncrypt?this.imagex_encrypt(this.file):this.crc32(this.file,this.sliceLength)}},{key:"imagex_encrypt",value:function imagex_encrypt(e){var i=this,n=this.currFileCtx.imagexEncryptKey;if(this.isDirect){var o=this.isImageBatchUpload?e:[e],s=[];o.forEach(function(e,r){var t=new FileReader;t.readAsArrayBuffer(e),t.onload=function(e){var e=e.target.result,t=b.generateKey(16),e=cipher_imagex_encrypt({key:n,iv:t,data:e}),e=b.concatAb(b.str2ab("aes256cfb-direct"),b.str2ab(t),e);s[r]={data:e,iv:t},s.filter(function(e){return!!e}).length===o.length&&(e=s.map(function(e){return{start:0,end:e.data.byteLength,crc32:lib_crc32(e.data),buffer:e.data}}),i.success(e))},t.onerror=function(){i.fail({message:"Read file error."})}})}else{for(var t=new ArrayBuffer(36),r=new DataView(t),a=b.str2ab("aes-256-cfb-part"),c=new Uint8Array(a),u=0;u<16;u++)r.setUint8(u,c[u]);r.setUint16(16,0,!0),r.setUint16(18,0,!0),r.setUint32(20,this.sliceLength,!0),r.setUint32(24,0,!0),r.setUint32(28,0,!0),r.setUint32(32,0,!0);for(var a=b.generateKey(16),t=b.concatAb(t,b.str2ab(a)),l=[{crc32:lib_crc32(t,0),buffer:t,encryptMeta:!0,start:-52,end:0,iv:a}],p=this.sliceLength,f=e.size,h=0,d=0;d<f;)d=Math.min(h+p,f),l.push({start:h,end:d,crc32:0}),h=d;this.success(l)}}},{key:"crc32",value:function crc32(e,t){var r=this;if(this.isImageBatchUpload)for(var i=e.length,n=[],o=0;o<i;o++)new de(e[o],e[o].size,function(e){n.push(e[0]),n.length===i&&r.success(n)},function(e){r.fail(e)}).start();else!e||!e.size||e.size<=0?this.fail({message:"There is a problem with the input file or fileSize."}):this.isDirect?new de(e,e.size,function(e){r.success(e)},function(e){r.fail(e)}).start():this.sliceFile(e,t,function(e){r.success(e)},function(e){r.fail(e)})}},{key:"sliceFile",value:function sliceFile(e,t,r,i){for(var n=[],o=t,s=e.size,a=new FileReader,c=e.slice||e.webkitSlice||e.mozSlice,u=0,l=0,p=0;l<s;)l=Math.min(u+o,s),s-l<=5242880&&(l=s),n.push({start:u,end:l,crc32:0}),u=l;try{!function read(t){u=n[t].start,l=n[t].end,a.readAsArrayBuffer(c.call(e,u,l)),a.onload=function(e){e=e.target.result,p=x.dec2hex(x.crc32(e,0)),n[t].crc32=p,l===s?r(n):read(n.length-1)},a.onerror=function(e){i(e)}}(0)}catch(e){i(e)}}},{key:"getCrc32Key",value:function getCrc32Key(e,t){t="[object Array]"===Object.prototype.toString.call(t)?_toConsumableArray(t):[t];return t.push(e[0].crc32,e[e.length-1].crc32),t.join("_")}},{key:"success",value:function success(e){var t=this.context,r=this.key,i=[],n=[];if(this.isImageBatchUpload)for(var o=0;o<this.file.length;o++)i.push(this.file[o].size),n.push(this.file[o].name);else i=this.file.size,n=this.file.name;var s=this.getCrc32Key(e,i),t=FileCrc32_extends(t.tasks[r],{key:r,crc32Array:e,crc32Key:s,sdkVersion:"1.2.1",sliceLength:this.sliceLength,extra:{message:"get crc32 success"},stage:"crc32",type:"success",fileSize:i,fileName:n,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st,isDirect:this.isDirect,isImageBatchUpload:this.isImageBatchUpload});this.successProcess(t)}},{key:"fail",value:function fail(e){var t=this.context,r=this.key,e=e&&e.message?e.message:"get crc32 error",t=FileCrc32_extends(t.tasks[r],{extra:{message:e},type:"error",stage:"crc32",stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st});this.failProcess(t)}}]),FileCrc32}();function Transport_typeof(e){return(Transport_typeof="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 Transport_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,function Transport_toPropertyKey(e){e=function Transport_toPrimitive(e,t){if("object"!==Transport_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==Transport_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===Transport_typeof(e)?e:String(e)}(i.key),i)}}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function _createSuper(r){var i=function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(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}}();return function _createSuperInternal(){var e,t=_getPrototypeOf(r);return function _possibleConstructorReturn(e,t){{if(t&&("object"===Transport_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return function _assertThisInitialized(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(this,i?(e=_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var k=function(){!function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new 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&&_setPrototypeOf(e,t)}(Transport,n());var t=_createSuper(Transport);function Transport(){var e;return function Transport_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,Transport),(e=t.call(this)).xhr=new XMLHttpRequest,e._data=null,e}return function Transport_createClass(e,t,r){t&&Transport_defineProperties(e.prototype,t),r&&Transport_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(Transport,[{key:"_ajax",value:function _ajax(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=b.noop,r.onreadystatechange=b.noop,r.params=e,t._data&&t._data.url&&(r.currentUrl=t._data.url),200<=r.status&&r.status<300?t.emit("complete",r):400<=r.status&&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 send(t){var r=this;return this._data=t,this.xhr.open(t.method||"POST",t.url||"",!0),t.headers&&Object.keys(t.headers).forEach(function(e){r.xhr.setRequestHeader(e,t.headers[e])}),this.xhr.timeout=t.timeout||0,t.ontimeout&&(this.xhr.ontimeout=t.ontimeout),t.binary?this.sendAsBinary(t):t.custom?"object"===Transport_typeof(t.custom)?this.sendAsCustom(JSON.stringify(t.custom)):"none"===t.custom?(delete t.custom,this.sendAsCustom()):this.sendAsCustom(t.custom):this.sendAsFormData(t)}},{key:"sendAsBinary",value:function sendAsBinary(e){return this.xhr.setRequestHeader("Content-Type","application/octet-stream"),this._ajax(e.file)}},{key:"sendAsFormData",value:function sendAsFormData(e){t=(t=e.formData?"function"==typeof e.formData?e.formData():e.formData:t)||[];for(var t,r=new FormData,i=0,n=t.length;i<n;i++){var o=t[i];r.append(o.name,o.value)}return e.file&&r.append(e.field,e.file,e.name),this._ajax(r)}},{key:"sendAsCustom",value:function sendAsCustom(e){return this._ajax(e)}},{key:"abort",value:function abort(){this.xhr.onreadystatechange=b.noop,this.xhr.abort()}}]),Transport}(),r=__webpack_require__(10),w=__webpack_require__.n(r),r=__webpack_require__(153),xe=__webpack_require__.n(r);function signers_typeof(e){return(signers_typeof="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 signers_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,function signers_toPropertyKey(e){e=function signers_toPrimitive(e,t){if("object"!==signers_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==signers_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===signers_typeof(e)?e:String(e)}(i.key),i)}}var ke=["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id"],we=function uriEscape(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""}},Ce=function queryParamsToString(r){return Object.keys(r).sort().map(function(e){var t=r[e];if(null!=t){e=we(e);if(e)return Array.isArray(t)?"".concat(e,"=").concat(t.map(we).sort().join("&".concat(e,"="))):"".concat(e,"=").concat(we(t))}}).filter(function(e){return e}).join("&")},Se=function(){function AWSSignersV4(e,t,r){!function signers_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,AWSSignersV4),this.request=e,this.request.headers=e.headers||{},this.serviceName=t,this.signatureCache="boolean"!=typeof(r=r||{}).signatureCache||r.signatureCache,this.operation=r.operation,this.signatureVersion=r.signatureVersion,this.constant=r.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=r.bodySha256}return function signers_createClass(e,t,r){t&&signers_defineProperties(e.prototype,t),r&&signers_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(AWSSignersV4,[{key:"addAuthorization",value:function addAuthorization(e,t){t=this.iso8601(t).replace(/[:-]|\.\d{3}/g,"");this.addHeaders(e,t),this.request.headers.Authorization=this.authorization(e,t)}},{key:"addHeaders",value:function addHeaders(e,t){this.request.headers[this.constant.dateHeader]=t,e.sessionToken&&(this.request.headers[this.constant.tokenHeader]=e.sessionToken),this.request.body&&("string"!=typeof(t=this.request.body)&&(t=t instanceof URLSearchParams?t.toString():JSON.stringify(t)),this.request.headers[this.constant.contentSha256Header]=this.bodySha256||xe()(t).toString())}},{key:"authorization",value:function authorization(e,t){var r=[],i=this.credentialString(t);return r.push("".concat(this.constant.algorithm," Credential=").concat(e.accessKeyId,"/").concat(i)),r.push("SignedHeaders=".concat(this.signedHeaders())),r.push("Signature=".concat(this.signature(e,t))),r.join(", ")}},{key:"signature",value:function signature(e,t){e=this.getSigningKey(e,t.substr(0,8),this.request.region,this.serviceName,this.signatureCache);return w()(this.stringToSign(t),e)}},{key:"stringToSign",value:function stringToSign(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 canonicalString(){var e=[],t=this.request.pathname||"/";return e.push(this.request.method.toUpperCase()),e.push(t),e.push(Ce(this.request.params)||""),e.push("".concat(this.canonicalHeaders(),"\n")),e.push(this.signedHeaders()),e.push(this.hexEncodedBodyHash()),e.join("\n")}},{key:"canonicalHeaders",value:function canonicalHeaders(){var r=this,t=[],i=(Object.keys(this.request.headers).forEach(function(e){t.push([e,r.request.headers[e]])}),t.sort(function(e,t){return e[0].toLowerCase()<t[0].toLowerCase()?-1:1}),[]);return t.forEach(function(e){var t=e[0].toLowerCase();if(r.isSignableHeader(t)){e=e[1];if(null==e||"function"!=typeof e.toString)throw new Error("Header ".concat(t," contains invalid value"));i.push("".concat(t,":").concat(r.canonicalHeaderValues(e.toString())))}}),i.join("\n")}},{key:"canonicalHeaderValues",value:function canonicalHeaderValues(e){return e.replace(/\s+/g," ").replace(/^\s+|\s+$/g,"")}},{key:"signedHeaders",value:function signedHeaders(){var t=this,r=[];return Object.keys(this.request.headers).forEach(function(e){e=e.toLowerCase(),t.isSignableHeader(e)&&r.push(e)}),r.sort().join(";")}},{key:"credentialString",value:function credentialString(e){return this.createScope(e.substr(0,8),this.request.region,this.serviceName)}},{key:"hexEncodedHash",value:function hexEncodedHash(e){return xe()(e)}},{key:"hexEncodedBodyHash",value:function hexEncodedBodyHash(){return this.request.headers[this.constant.contentSha256Header]||(this.request.body?this.hexEncodedHash(Ce(this.request.body)):this.hexEncodedHash(""))}},{key:"isSignableHeader",value:function isSignableHeader(e){return 0===e.toLowerCase().indexOf("x-amz-")||ke.indexOf(e)<0}},{key:"iso8601",value:function iso8601(e){return(e=void 0===e?new Date:e).toISOString().replace(/\.\d{3}Z$/,"Z")}},{key:"getSigningKey",value:function getSigningKey(e,t,r,i){t=w()(t,"".concat(this.constant.kDatePrefix).concat(e.secretAccessKey)),e=w()(r,t),r=w()(i,e);return w()(this.constant.v4Identifier,r)}},{key:"createScope",value:function createScope(e,t,r){return[e.substr(0,8),t,r,this.constant.v4Identifier].join("/")}}]),AWSSignersV4}(),Oe=1000002,Ie=1001e3,Pe=1002e3,Ue=1003e3,Te=1003003,De=1004e3,je=1005e3,Ae="The format of stsToken is incorrect.",Ee="An error occurred reading the file";function ApplyUpload_typeof(e){return(ApplyUpload_typeof="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 ownKeys(t,e){var r,i=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)),i}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach(function(e){!function _defineProperty(e,t,r){(t=ApplyUpload_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function ApplyUpload_extends(){return(ApplyUpload_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}function ApplyUpload_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,ApplyUpload_toPropertyKey(i.key),i)}}function ApplyUpload_toPropertyKey(e){e=function ApplyUpload_toPrimitive(e,t){if("object"!==ApplyUpload_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==ApplyUpload_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===ApplyUpload_typeof(e)?e:String(e)}var Fe=function(){function ApplyUpload(e,t){!function ApplyUpload_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,ApplyUpload),this.options=e,this.config=t,this.uploaderCtx=e.context,this.currFileCtx=e.context.tasks[e.key],this.isImageBatchUpload=!!this.options.isImageBatchUpload,this.serviceName=e.serviceName||_,this.retryTaskTime=t.retryTaskTime}return function ApplyUpload_createClass(e,t,r){t&&ApplyUpload_defineProperties(e.prototype,t),r&&ApplyUpload_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(ApplyUpload,[{key:"start",value:function start(e,t,r){this.failProcess=r,this.successProcess=t,this.retryCount=0,this._st=Date.now();r=this.uploaderCtx._getCache(this.currFileCtx.crc32Key),t=r?JSON.parse(r):{};t.oid&&t.uploadID&&t.tosDomain?this.resumeFromCache(t):this.startPreUpload()}},{key:"startPreUpload",value:function startPreUpload(){var n=this,e=oe[this.config.region],t=new k,r=(t.on("complete",function(t){var e,r={};try{r=JSON.parse(t.response)}catch(e){return n.fail({error:"catch error:".concat(null==e?void 0:e.message),xhr:t})}null!=(e=r.ResponseMetadata)&&e.Error?n.fail({xhr:t,errorCode:r.ResponseMetadata.Error.CodeN,error:r.ResponseMetadata.Error.Code,message:r.ResponseMetadata.Error.Message,requestId:r.ResponseMetadata.RequestId}):n.success(r.Result,t)}),t.on("error",function(e){var t={error:"request fail: ".concat(e.statusText||e.errText||"UNKNOWN"),xhr:e};try{var r,i=JSON.parse(e.response);null!=(r=i.ResponseMetadata)&&r.Error&&(t.errorCode=i.ResponseMetadata.Error.CodeN,t.error=i.ResponseMetadata.Error.Code,t.message=i.ResponseMetadata.Error.Message,t.requestId=i.ResponseMetadata.RequestId)}catch(e){console.warn("[TTUploader]: ".concat(null==e?void 0:e.message))}n.fail(t)}),this.serviceName),i="",o={},s=(r===m?(i=this.config.imageHost||ae[e],o={Action:"ApplyImageUpload",Version:"2018-08-01",ServiceId:this.options.serviceId||this.config.imageConfig.serviceId},this.currFileCtx.fileSize&&1<this.currFileCtx.fileSize.length&&(o.UploadNum=this.currFileCtx.fileSize.length),this.options.storeKey&&(s=this.options.storeKey,"[object Array]"===Object.prototype.toString.call(s)?o.StoreKeys=s:"[object String]"===Object.prototype.toString.call(s)&&(o.StoreKeys=[s])),this.options.prefix&&(o.Prefix=this.options.prefix),this.options.overwrite&&(o.Overwrite=!0)):(s=this.config.videoConfig&&this.config.videoConfig.spaceName,this.options.type===d&&this.config.objectConfig&&this.config.objectConfig.spaceName&&(s=this.config.objectConfig.spaceName),i=this.config.videoHost||se[e],o={Action:"ApplyUploadInfo",Version:"2022-01-01",SpaceName:s,FileSize:this.currFileCtx.fileSize,FileType:this.options.type},this.options.fileName&&(o.FileName=this.options.fileName),this.options.fileExtension&&(o.FileExtension=this.options.fileExtension),this.options.storageClass&&(o.StorageClass=this.options.storageClass),this.config.enOID&&(o.EnOID=1)),this.config.useFileExtension&&this.currFileCtx.fileName&&(this.options.type===d||this.options.type===te)&&(s=this.currFileCtx.fileName,o.FileExtension=b.getFileSuffix(s)),this.options.fileExtension&&(o.FileExtension=this.options.fileExtension),this.config.accountId&&(o["X-Account-Id"]=this.config.accountId),o.s=Math.random().toString(36).substr(2),0<this.uploaderCtx.priorInfo.topExpires&&(o["X-Expires"]=this.uploaderCtx.priorInfo.topExpires),b.toQueryString(o)),i={method:"GET",url:"".concat(i,"?").concat(s),timeout:3e4,region:e,params:o},s=new Se(i,r,{isVolcengine:!0}),e=this.currFileCtx.proxyStsToken||this.config.stsToken,o=e.AccessKeyID,r=e.AccessKeyId,a=e.SecretAccessKey,c=e.SessionToken,e=e.CurrentTime,u=null,u=this.config.useServerCurrentTime?new Date(e):new Date(Date.now()+this.uploaderCtx.priorInfo.systemTimeGap);s.addAuthorization({accessKeyId:r||o,secretAccessKey:a,sessionToken:c},u),t.send(i)}},{key:"resumeFromCache",value:function resumeFromCache(i){var n=this,o=this.options.key,e=new k,t=(e.on("complete",function(e){var t,r={};try{r=JSON.parse(e.response)}catch(e){return n.startPreUpload()}0===r.success&&0<(null==(t=r.payload)||null==(t=t.partList)?void 0:t.length)?(t=n.confirmCache(r.payload.partList),r=!!i.hasMerge?5:t.isAllFinished?4:3,e=ApplyUpload_extends(n.currFileCtx,i,{key:o,xhr:e,extra:{message:"prepare upload from cache success"},stage:"preUpload",type:"success",percent:0,cacheTask:r,proxyStsToken:n.options.stsToken,currentTask:1,status:1,isBreak:1,crc32Array:t.crc32Array,stageStartTime:n._st,stageEndTime:Date.now(),duration:Date.now()-n._st,totalDuration:Date.now()-n._st+n.currFileCtx.totalDuration}),n.successProcess(e)):n.startPreUpload()}),e.on("error",function(e){400<=e.status?n.startPreUpload():n.fail({error:"request error",xhr:e})}),this.config.userId),r=ApplyUpload_extends(b.arrayToObject(i.UploadHeader),{"x-storage-mode":"gateway"});e.send({method:"get",url:b.urlTemplate(pe,{tosDomain:i.tosDomain,oid:i.oid,uploadId:i.uploadID}),headers:_objectSpread({authorization:i.signature,"x-storage-u":t},r),timeout:3e4})}},{key:"confirmCache",value:function confirmCache(e){var t=this.currFileCtx.crc32Array,r={},i=(e.forEach(function(e){var t=parseInt(e.partNumber)-1;isNaN(t)||void 0!==r[t]||(r[t]={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):i=!1,e});return{isAllFinished:i,crc32Array:e}}},{key:"fail",value:function fail(e){if(100006===e.errorCode){if(0===this.uploaderCtx.priorInfo.topExpires)return this.uploaderCtx.priorInfo.topExpires=604800,this.startPreUpload();if(0===this.uploaderCtx.priorInfo.systemTimeGap)return t=b.resolveLocalTimeDiff(e.requestId),this.uploaderCtx.priorInfo.systemTimeGap=t,this.startPreUpload()}if(this.retryCount<this.retryTaskTime)return this.retryCount+=1,this.startPreUpload();var t=e.xhr,r=e.errorCode||Ie,i="prepare upload error: UNKNOWN",i=(t&&(i=0===t.status?"prepare upload error: NETERROR":e.message||"prepare upload error: ".concat(t.status)),ApplyUpload_extends(this.currFileCtx,{extra:{message:i,error:e.error,errorCode:r},type:"error",stage:"preUpload",xhr:t,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(i)}},{key:"success",value:function success(e,t){var e=(this.serviceName===m?e:e.Data).UploadAddress,r=e.StoreInfos,i=e.UploadHosts,n=e.SessionKey,e=e.UploadHeader,e=void 0===e?[]:e,o=[],s=[],r=(this.isImageBatchUpload&&1<r.length?r.forEach(function(e){o.push(e.Auth),s.push(e.StoreUri)}):(o=r[0].Auth,s=r[0].StoreUri),ApplyUpload_extends(this.currFileCtx,{signature:o,type:"success",extra:{message:"prepare upload success"},stage:"preUpload",oid:b.resolveUri(s),tosDomain:"".concat(this.config.schema,"://").concat(i[0]),xhr:t,UploadHeader:e,SessionKey:n,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currFileCtx.totalDuration}));this.successProcess(r)}}]),ApplyUpload}();function InitUploadID_typeof(e){return(InitUploadID_typeof="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 InitUploadID_ownKeys(t,e){var r,i=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)),i}function InitUploadID_objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?InitUploadID_ownKeys(Object(r),!0).forEach(function(e){!function InitUploadID_defineProperty(e,t,r){(t=InitUploadID_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):InitUploadID_ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function InitUploadID_extends(){return(InitUploadID_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}function InitUploadID_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,InitUploadID_toPropertyKey(i.key),i)}}function InitUploadID_toPropertyKey(e){e=function InitUploadID_toPrimitive(e,t){if("object"!==InitUploadID_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==InitUploadID_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===InitUploadID_typeof(e)?e:String(e)}var Me=function(){function InitUploadID(e,t){!function InitUploadID_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,InitUploadID),this.options=e,this.config=t,this.transport=new k,this.uploaderCtx=e.context,this.currFileCtx=e.context.tasks[e.key],this.eventInit()}return function InitUploadID_createClass(e,t,r){t&&InitUploadID_defineProperties(e.prototype,t),r&&InitUploadID_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(InitUploadID,[{key:"initUpload",value:function initUpload(){var e=this.options.context,t=this.options.key,r={oid:e.tasks[t].oid,tosDomain:e.tasks[t].tosDomain},r=b.urlTemplate(ce,r),i=this.config.userId,n=InitUploadID_extends(b.arrayToObject(this.currFileCtx.UploadHeader),{"x-storage-mode":"gateway"});this.transport.send({method:"post",url:r,headers:InitUploadID_objectSpread({authorization:e.tasks[t].signature,"x-storage-u":i},n),timeout:3e4})}},{key:"start",value:function start(e,t,r){this.successProcess=t,this.failProcess=r,this._st=Date.now(),this.initUpload()}},{key:"eventInit",value:function eventInit(){var n=this,o=this.options.context,s=this.options.key;this.transport.on("complete",function(t){try{var e,r=JSON.parse(t.response),i=r.payload.uploadID;0===r.success&&i?(e=InitUploadID_extends(o.tasks[s],{uploadID:i,percent:0,type:"success",extra:{message:"init upload id success"},stage:"initUploadID",xhr:t,stageStartTime:n._st,stageEndTime:Date.now(),duration:Date.now()-n._st,totalDuration:Date.now()-n._st+n.currFileCtx.totalDuration}),n.successProcess(e)):n.fail({error:"fail! res.success: ".concat(r.success,", uploadId:").concat(i),xhr:t})}catch(e){n.fail({error:"catch error: ".concat(JSON.stringify(e)),xhr:t})}}),this.transport.on("error",function(e){n.fail({error:"request fail: ".concat(e.statusText||e.errText||"UNKNOWN"),xhr:e})})}},{key:"fail",value:function fail(e){var t=this.options.context,r=this.options.key,t=InitUploadID_extends(t.tasks[r],{extra:{message:"init upload id error, ".concat(e.error),errorCode:Pe},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)}}]),InitUploadID}();function Uploader_typeof(e){return(Uploader_typeof="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 Uploader_ownKeys(t,e){var r,i=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)),i}function Uploader_objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Uploader_ownKeys(Object(r),!0).forEach(function(e){!function Uploader_defineProperty(e,t,r){(t=Uploader_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Uploader_ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Uploader_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,Uploader_toPropertyKey(i.key),i)}}function Uploader_toPropertyKey(e){e=function Uploader_toPrimitive(e,t){if("object"!==Uploader_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==Uploader_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===Uploader_typeof(e)?e:String(e)}function Uploader_setPrototypeOf(e,t){return(Uploader_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function Uploader_createSuper(r){var i=function Uploader_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(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}}();return function _createSuperInternal(){var e,t=Uploader_getPrototypeOf(r);return function Uploader_possibleConstructorReturn(e,t){{if(t&&("object"===Uploader_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return function Uploader_assertThisInitialized(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(this,i?(e=Uploader_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function Uploader_getPrototypeOf(e){return(Uploader_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ne=function(){!function Uploader_inherits(e,t){if("function"!=typeof t&&null!==t)throw new 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&&Uploader_setPrototypeOf(e,t)}(Uploader,n());var u=Uploader_createSuper(Uploader);function Uploader(e){var t,r=e.sliceItem,i=e.crc32,n=e.url,o=e.signature,s=e.uploadHeader,a=e.userId,c=e.retryTime,c=void 0===c?0:c,e=e.method,e=void 0===e?"put":e;return function Uploader_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,Uploader),(t=u.call(this)).fileSlice=r,t.crc32=i,t.uploadUrl=n,t.uploadHeader=s,t.signature=o,t.userId=a,t.retryTime=c,t.method=e,t.retryCount=0,t.ready=!1,t.cancel=!1,t.transport=new k,t.eventInit(),t}return function Uploader_createClass(e,t,r){t&&Uploader_defineProperties(e.prototype,t),r&&Uploader_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(Uploader,[{key:"upload",value:function upload(){this.isParamsValid()&&(this._st=Date.now(),this.transport.send({method:this.method,url:this.uploadUrl,headers:Uploader_objectSpread({authorization:this.signature,"content-crc32":this.crc32,"x-storage-u":this.userId},this.uploadHeader),file:this.fileSlice,binary:1,timeout:18e5}))}},{key:"isParamsValid",value:function isParamsValid(){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 eventInit(){var t=this;this.transport.on("complete",function(e){t.success(e)}),this.transport.on("error",function(e){t.fail(e)}),this.transport.on("progress",function(e){t.process(e)})}},{key:"success",value:function success(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,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st})}},{key:"fail",value:function fail(e){var t,r=this;this.cancel||(e&&401===e.status?this.emit("error",{message:"slice upload failed: UNAUTHORIZED",crc32:this.crc32,size:this.fileSlice.size||this.fileSlice.byteLength,xhr:e,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st}):this.retryCount<this.retryTime?(setTimeout(function(){r.upload()},1e3),this.retryCount++):(t="slice upload failed: UNKNOWN",e&&(t=e.status?"slice upload failed: ".concat(e.status):"slice upload failed: NETERROR"),this.emit("error",{message:t,crc32:this.crc32,size:this.fileSlice.size||this.fileSlice.byteLength,xhr:e,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st})))}},{key:"process",value:function process(e){this.cancel||this.emit("progress",{crc32:this.crc32,loaded:e.loaded||0,total:e.total||0})}},{key:"abort",value:function abort(){this.transport&&(this.cancel=!0,this.transport.abort())}},{key:"destroy",value:function destroy(){this.transport=null}}]),Uploader}(),r=__webpack_require__(391),Re=__webpack_require__.n(r);function Upload_typeof(e){return(Upload_typeof="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 Upload_extends(){return(Upload_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}function Upload_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,function Upload_toPropertyKey(e){e=function Upload_toPrimitive(e,t){if("object"!==Upload_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==Upload_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===Upload_typeof(e)?e:String(e)}(i.key),i)}}var Be=function(){function Upload(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};!function Upload_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,Upload),this.file=e.file,this.context=e.context,this.key=e.key,this.config=t,this.finishArr=[],this.errorLength=0,this.finishSize=0,this.retryUploadTime=Number(t.retryUploadTime)||5,this.retryProcess=t.retryProcess,this.retryProcessTime=Number(t.retryProcessTime)||5,this.maxProcessPause=Number(t.maxProcessPause)||20,this.uploadSliceCount=Number(t.uploadSliceCount)||5,this.realtimeSpeedInterval=Number(t.realtimeSpeedInterval)||5,this.processRetry=0,this.lastFinishSize=-1,this.lastProcessPercent=-1,this.lastIntervalSize=-1,this.lastCalculateSpeedTime=-1,this.lastCalculateSpeedSize=0,this.uploadHandlers={}}return function Upload_createClass(e,t,r){t&&Upload_defineProperties(e.prototype,t),r&&Upload_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(Upload,[{key:"start",value:function start(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.imagexEncrypt=this.currentCtx.imagexEnableEncrypt,this.initWorker(),this.threadUpload()}},{key:"initWorker",value:function initWorker(){var n,o=this;this.worker||(this.worker=new(Re()),n=this.crc32Array,this.worker.onmessage=function(e){var t=e.data[0],r=e.data[2],i=n[r];i.crc32=e.data[1],o.upload(i,t,r)})}},{key:"read",value:function read(e,r){var t,i,n,o=this;e.encryptMeta?this.upload(e,e.buffer,r):(i=(t=this.file).slice||t.webkitSlice||t.mozSlice,(n=new FileReader).onload=function(e){var t;o.imagexEncrypt?(t=cipher_imagex_encrypt({iv:o.crc32Array[0].iv,key:o.currentCtx.imagexEncryptKey,data:e.target.result}),o.worker.postMessage([t,r],[t])):o.worker.postMessage([e.target.result,r],[e.target.result])},n.onerror=function(){o.stop(),o.fail({extra:{message:Ee,errorCode:Te}})},n.readAsArrayBuffer(i.call(t,e.start,e.end)))}},{key:"threadUpload",value:function threadUpload(){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 stop(){var t=this;Object.keys(this.uploadHandlers).forEach(function(e){t.uploadHandlers[e].abort()}),this.worker&&this.worker.terminate(),this.worker=null,this.clearMonitor()}},{key:"clearMonitor",value:function clearMonitor(){this.progressMonitorInterval&&clearInterval(this.progressMonitorInterval)}},{key:"upload",value:function upload(t,e,r){var i=this,n=t.crc32,o={number:r+1,uploadId:this.currentCtx.uploadID,oid:this.currentCtx.oid,tosDomain:this.currentCtx.tosDomain},o=b.urlTemplate(ue,o),s=this.config.userId,a=Upload_extends(b.arrayToObject(this.currentCtx.UploadHeader)),e=(this.imagexEncrypt||(a["x-storage-mode"]="gateway"),new Ne({sliceItem:e,crc32:n,url:o,signature:this.currentCtx.signature,uploadHeader:a,userId:s,retryTime:this.retryUploadTime}));e.on("complete",function(e){i.currentCtx.status===y&&(e.start=t.start,e.index=r,i.fileSliceSuccess(e))}),e.on("error",function(e){1===i.currentCtx.status&&(e.start=t.start,e.index=r,i.fail(e))}),e.on("progress",function(e){1===i.currentCtx.status&&(e.start=t.start,e.index=r,i.process(e))}),e.upload(),this.uploadHandlers[r]=e}},{key:"success",value:function success(e){this.finishArr=[];var t=Date.now()-this._st,t=this._uploadSize/t,t=Upload_extends(this.currentCtx,{type:"success",stage:"process",percent:99,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 fail(e){var t=this.currentCtx.totalDuration,r=Date.now()-this._st,i=e.crc32?{message:e.message,data:e.crc32,size:e.size}:e.extra,r=(i.errorCode=i.errorCode||Ue,Upload_extends(this.currentCtx,{extra:i,type:"error",stage:"process",req:{},res:{},totalDuration:r+t}));e.xhr&&(t=e.xhr,r.req={url:e.xhr.currentUrl},r.res={status:t.status,body:t.responseText,header:t.getAllResponseHeaders()},delete e.xhr),void 0!==e.statusCode&&Upload_extends(this.currentCtx,{statusCode:e.statusCode});try{var n,o,s,a=JSON.parse(e.xhr.response);i.message=null==a||null==(n=a.error)?void 0:n.message,i.error=null==a||null==(o=a.error)?void 0:o.error,i.errorCode=null==a||null==(s=a.error)?void 0:s.error_code}catch(e){console.warn("[TTUploader]:",null==e?void 0:e.message)}this.errorLength||(t=e.index,this.context.logger.send(Upload_extends({},r,{slice_index:t})),this.stop(),this.context._broadcast("error",r),this.currentCtx.isBreak?this.context._cancel(this.key):this.context._pause(this.key),this.errorLength++)}},{key:"fileSliceSuccess",value:function fileSliceSuccess(e){var t,r=e.index,i=Date.now(),n=(-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,n.currentUrl=t.currentUrl||"",Upload_extends(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(Upload_extends(this.currentCtx,{stage:"process",type:"success",slice_index:r,extra:n,totalDuration:i-this._lastSaveTime+this.currentCtx.totalDuration})),this._lastSaveTime=i,this.finishArr.length>=this.crc32Array.length?(this.stop(),this.success(e.xhr)):(this.uploading.splice(this.uploading.indexOf(r),1),this.uploadHandlers[r]&&delete this.uploadHandlers[r],this.threadUpload())}},{key:"getFinishSize",value:function getFinishSize(e,t){var r=t.crc32,i=0;return e.forEach(function(e){e.crc32===r?(e.loaded=t.loaded,i+=t.loaded):(e.loaded||(e.loaded=0),i+=e.loaded)}),i}},{key:"process",value:function process(e){var t=this.currentCtx.realtimeSpeed||0,r=this.currentCtx.fileSize,i=(this.finishSize=this.getFinishSize(this.crc32Array,e),this.finishSize>this.lastFinishSize&&((e=new Date).getTime()-this.lastCalculateSpeedTime>1e3*this.realtimeSpeedInterval&&(n=e.getTime()-this.lastCalculateSpeedTime,i=this.finishSize-this.lastCalculateSpeedSize,t=Math.floor(i/n),this.lastCalculateSpeedTime=e.getTime(),this.lastCalculateSpeedSize=this.finishSize),this.lastFinishSize=this.finishSize),Math.floor(this.finishSize/r*100*100)/100||0),i=Math.min(99,i),n=Upload_extends(this.currentCtx,{stage:"process",percent:i,realtimeSpeed:t});i>this.lastProcessPercent&&100!==i&&(this.lastProcessPercent=i,this.context._broadcast("progress",n))}}]),Upload}();function FileMerge_typeof(e){return(FileMerge_typeof="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 FileMerge_ownKeys(t,e){var r,i=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)),i}function FileMerge_objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?FileMerge_ownKeys(Object(r),!0).forEach(function(e){!function FileMerge_defineProperty(e,t,r){(t=FileMerge_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):FileMerge_ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function FileMerge_extends(){return(FileMerge_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}function FileMerge_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,FileMerge_toPropertyKey(i.key),i)}}function FileMerge_toPropertyKey(e){e=function FileMerge_toPrimitive(e,t){if("object"!==FileMerge_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==FileMerge_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===FileMerge_typeof(e)?e:String(e)}var ze=function(){function FileMerge(e,t){!function FileMerge_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,FileMerge),this.options=e,this.config=t,this.transport=new k,this.eventInit(),this.errorCount=0,this.uploaderCtx=e.context,this.currFileCtx=e.context.tasks[e.key]}return function FileMerge_createClass(e,t,r){t&&FileMerge_defineProperties(e.prototype,t),r&&FileMerge_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(FileMerge,[{key:"mergeFile",value:function mergeFile(){for(var e={oid:this.currFileCtx.oid,uploadId:this.currFileCtx.uploadID,tosDomain:this.currFileCtx.tosDomain},t=this.currFileCtx.crc32Array,r="",i=0;i<t.length;i++)r=(r?"".concat(r,","):"").concat(i+1,":").concat(t[i].crc32);var e=b.urlTemplate(le,e),n=this.config.userId,o=FileMerge_extends(b.arrayToObject(this.currFileCtx.UploadHeader));this.currFileCtx.imagexEnableEncrypt||(o["x-storage-mode"]="gateway"),this.transport.send({method:"post",url:e,headers:FileMerge_objectSpread({authorization:this.currFileCtx.signature,"x-storage-u":n},o),custom:r})}},{key:"start",value:function start(e,t,r){this.successProcess=t,this.failProcess=r,this._st=Date.now(),this.mergeFile()}},{key:"eventInit",value:function eventInit(){var r=this,i=this.options.stage;this.transport.on("complete",function(t){try{var e=JSON.parse(t.response);0===e.success&&e.payload.key?(FileMerge_extends(r.currFileCtx,{stage:i,type:"success",hasMerge:!0,extra:{message:"merge file success"},xhr:t,stageStartTime:r._st,stageEndTime:Date.now(),duration:Date.now()-r._st,totalDuration:Date.now()-r._st+r.currFileCtx.totalDuration}),r.successProcess(r.currFileCtx)):r.fail({error:"fail! result.success:".concat(e.success),xhr:t})}catch(e){r.fail({error:"response parse error: ".concat(JSON.stringify(e)),xhr:t})}}),this.transport.on("error",function(e){r.fail({error:"request fail: ".concat(e.statusText||e.errText),xhr:e})})}},{key:"getProcessIndex",value:function getProcessIndex(e){var r=0;return e.forEach(function(e,t){"process"===e.stage&&(r=t)}),r}},{key:"fail",value:function fail(e){var t={message:"merge file error,".concat(e.error),errorCode:De};try{var r,i,n=JSON.parse(e.xhr.response);t.message=null==n||null==(o=n.error)?void 0:o.message,t.error=null==n||null==(r=n.error)?void 0:r.error,t.errorCode=null==n||null==(i=n.error)?void 0:i.error_code}catch(e){}var o=FileMerge_extends(this.currFileCtx,{extra:t,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(o)}}]),FileMerge}();function DirectUpload_typeof(e){return(DirectUpload_typeof="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 DirectUpload_extends(){return(DirectUpload_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}function DirectUpload_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,function DirectUpload_toPropertyKey(e){e=function DirectUpload_toPrimitive(e,t){if("object"!==DirectUpload_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==DirectUpload_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===DirectUpload_typeof(e)?e:String(e)}(i.key),i)}}function DirectUpload_setPrototypeOf(e,t){return(DirectUpload_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function DirectUpload_createSuper(r){var i=function DirectUpload_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(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}}();return function _createSuperInternal(){var e,t=DirectUpload_getPrototypeOf(r);return function DirectUpload_possibleConstructorReturn(e,t){{if(t&&("object"===DirectUpload_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return function DirectUpload_assertThisInitialized(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(this,i?(e=DirectUpload_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function DirectUpload_getPrototypeOf(e){return(DirectUpload_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var He=function(){!function DirectUpload_inherits(e,t){if("function"!=typeof t&&null!==t)throw new 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&&DirectUpload_setPrototypeOf(e,t)}(DirectUpload,n());var i=DirectUpload_createSuper(DirectUpload);function DirectUpload(e){var t,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return function DirectUpload_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,DirectUpload),(t=i.call(this)).options=e,t.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)||5,t.processRetry=0,t.lastFinishSize=-1,t.lastProcessPercent=-1,t.lastIntervalSize=-1,t}return function DirectUpload_createClass(e,t,r){t&&DirectUpload_defineProperties(e.prototype,t),r&&DirectUpload_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(DirectUpload,[{key:"start",value:function start(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.file.size,this.uploadHandlers={},this._st=Date.now(),this.upload()}},{key:"upload",value:function upload(){for(var t=this,r=this.crc32Array.length,i=0,n=0,e=0;e<r;e++){var o=this.crc32Array[e],s=o.buffer,o=o.crc32,a=this.currentCtx.oid,c=this.currentCtx.signature,a={oid:"[object Array]"===Object.prototype.toString.call(a)?a[e]:a,tosDomain:this.currentCtx.tosDomain},a=b.urlTemplate(fe,a),u=this.config.userId,l=b.arrayToObject(this.currentCtx.UploadHeader),s=new Ne({sliceItem:s,crc32:o,url:a,signature:"[object Array]"===Object.prototype.toString.call(c)?c[e]:c,uploadHeader:l,userId:u,retryTime:this.retryUploadTime,method:"put"});s.on("complete",function(e){n+ ++i===r&&t.success(e.xhr)}),s.on("error",function(e){++n===r&&t.fail(e.xhr)}),s.on("progress",function(e){t.process(e)}),(this.uploadHandlers["".concat(o,"_").concat(Math.round(1e3*Math.random()))]=s).upload()}}},{key:"success",value:function success(e){this.finishArr=[];var t=Date.now()-this._st,t=this._uploadSize/t,t=DirectUpload_extends(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.successProcess(t)}},{key:"fail",value:function fail(e){var t={message:"direct upload error",errorCode:Ue};try{var r,i,n=JSON.parse(e.response);t.message=null==n||null==(o=n.error)?void 0:o.message,t.error=null==n||null==(r=n.error)?void 0:r.error,t.errorCode=null==n||null==(i=n.error)?void 0:i.error_code}catch(e){console.warn("[TTUploader]:",null==e?void 0:e.message)}var o=DirectUpload_extends(this.currentCtx,{extra:t,type:"error",stage:"process",xhr:e,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currentCtx.totalDuration});this.failProcess(o)}},{key:"process",value:function process(e){var t=this.currentCtx.fileSize,e=(this.finishSize=e.loaded,this.finishSize>this.lastFinishSize&&(this.lastFinishSize=this.finishSize),Math.floor(this.finishSize/t*100*100)/100||0),e=Math.min(99,e),t=DirectUpload_extends(this.currentCtx,{stage:"process",percent:e});e>this.lastProcessPercent&&100!==e&&(this.lastProcessPercent=e,this.context._broadcast("progress",t))}},{key:"stop",value:function stop(){Object.values(this.uploadHandlers).forEach(function(e){e.abort()})}}]),DirectUpload}();function CommitUpload_typeof(e){return(CommitUpload_typeof="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 CommitUpload_ownKeys(t,e){var r,i=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)),i}function CommitUpload_objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?CommitUpload_ownKeys(Object(r),!0).forEach(function(e){!function CommitUpload_defineProperty(e,t,r){(t=CommitUpload_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):CommitUpload_ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function CommitUpload_extends(){return(CommitUpload_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}function CommitUpload_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,CommitUpload_toPropertyKey(i.key),i)}}function CommitUpload_toPropertyKey(e){e=function CommitUpload_toPrimitive(e,t){if("object"!==CommitUpload_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==CommitUpload_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===CommitUpload_typeof(e)?e:String(e)}var Le=function(){function CommitUpload(e,t){!function CommitUpload_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,CommitUpload),this.options=e,this.config=t,this.uploaderCtx=e.context,this.currFileCtx=e.context.tasks[e.key],this.isImageBatchUpload=!!this.options.isImageBatchUpload,this.processAction=e.processAction,this.skipCommit=e.skipCommit,this.serviceName=this.currFileCtx.serviceType,this.retryTaskTime=t.retryTaskTime}return function CommitUpload_createClass(e,t,r){t&&CommitUpload_defineProperties(e.prototype,t),r&&CommitUpload_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(CommitUpload,[{key:"start",value:function start(e,t,r){if(this.successProcess=t,this.failProcess=r,this.retryCount=0,this._st=Date.now(),this.skipCommit)return this.successProcess(CommitUpload_extends(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}));this.commitUpload()}},{key:"commitUpload",value:function commitUpload(){var t,n=this,e=this.options.key,e=this.options.context.tasks[e],r=oe[this.config.region],i=new k,o=(i.on("complete",function(t){var e,r={};try{r=JSON.parse(t.response)}catch(e){return n.fail({error:"catch error:".concat(null==e?void 0:e.message),xhr:t})}null!=(e=r.ResponseMetadata)&&e.Error?n.fail({xhr:t,errorCode:r.ResponseMetadata.Error.CodeN,error:r.ResponseMetadata.Error.Code,message:r.ResponseMetadata.Error.Message,requestId:r.ResponseMetadata.RequestId}):n.success(r.Result,t)}),i.on("error",function(e){var t={error:"request fail: ".concat(e.statusText||e.errText||"UNKNOWN"),xhr:e};try{var r,i=JSON.parse(e.response);null!=(r=i.ResponseMetadata)&&r.Error&&(t.errorCode=i.ResponseMetadata.Error.CodeN,t.error=i.ResponseMetadata.Error.Code,t.message=i.ResponseMetadata.Error.Message,t.requestId=i.ResponseMetadata.RequestId)}catch(e){console.warn("[TTUploader]: ".concat(null==e?void 0:e.message))}n.fail(t)}),""),s={},a=this.serviceName,c=(a===m?(o=this.config.imageHost||ae[r],s={Action:"CommitImageUpload",Version:"2018-08-01",ServiceId:this.options.serviceId||(null==(u=this.config.imageConfig)?void 0:u.serviceId)},this.options.skipMeta&&(s.SkipMeta=this.options.skipMeta),t={SessionKey:e.SessionKey},this.processAction&&Array.isArray(this.processAction)&&0<this.processAction.length&&(t.Functions=this.processAction),c=(u=this.currFileCtx).imagexEnableEncrypt,u=u.imagexPublicKey,c&&u&&!this.options.skipMeta&&this.uploaderCtx.plugins.forEach(function(e){"imagex-encrypt-plugin"===(null==e?void 0:e._identifier)&&(t.DecryptKeys=e.apply(n.currFileCtx))})):(c=this.config.videoConfig&&this.config.videoConfig.spaceName,this.options.type===d&&this.config.objectConfig&&this.config.objectConfig.spaceName&&(c=this.config.objectConfig.spaceName),o=this.config.videoHost||se[r],s={Action:"CommitUploadInfo",Version:"2022-01-01"},t={SpaceName:c,SessionKey:e.SessionKey,Functions:[]},u=this.config.videoConfig&&this.config.videoConfig.processAction,this.options.type===d&&this.config.objectConfig&&this.config.objectConfig.processAction&&(u=this.config.objectConfig.processAction),this.processAction&&(u=this.processAction),Array.isArray(u)&&0<u.length&&(t.Functions=u),(this.config.videoConfig&&this.config.videoConfig.callbackArgs||this.options.callbackArgs)&&(t.CallbackArgs=this.options.callbackArgs||this.config.videoConfig.callbackArgs)),this.config.accountId&&(s["X-Account-Id"]=this.config.accountId),0<this.uploaderCtx.priorInfo.topExpires&&(s["X-Expires"]=this.uploaderCtx.priorInfo.topExpires),b.toQueryString(s)),e={method:"POST",url:"".concat(o,"?").concat(c),timeout:3e4,region:r,params:s,headers:{}},o=(a===_?(u=Object.keys(t).map(function(e){return"[object Array]"===Object.prototype.toString.call(t[e])||"[object Object]"===Object.prototype.toString.call(t[e])?"".concat(e,"=").concat(encodeURIComponent(JSON.stringify(t[e]))):"SessionKey"===e?"".concat(e,"=").concat(encodeURIComponent(t[e])):"".concat(e,"=").concat(t[e])}).join("&"),e.headers["Content-Type"]="application/x-www-form-urlencoded",e.body=u,e.custom=e.body):(e.custom=t,e.headers["Content-Type"]="application/json",e.body=t),new Se(e,a,{isVolcengine:!0})),c=this.currFileCtx.proxyStsToken||this.config.stsToken,r=c.AccessKeyID,s=c.AccessKeyId,u=c.SecretAccessKey,a=c.SessionToken,c=c.CurrentTime,l=null,l=this.config.useServerCurrentTime?new Date(new Date(c).getTime()+(this.currFileCtx.totalDuration||0)):new Date(Date.now()+this.uploaderCtx.priorInfo.systemTimeGap);o.addAuthorization({accessKeyId:s||r,secretAccessKey:u,sessionToken:a},l),i.send(e)}},{key:"fail",value:function fail(e){if(100006===e.errorCode){if(0===this.uploaderCtx.priorInfo.topExpires)return this.uploaderCtx.priorInfo.topExpires=604800,this.commitUpload();if(0===this.uploaderCtx.priorInfo.systemTimeGap)return t=b.resolveLocalTimeDiff(e.requestId),this.uploaderCtx.priorInfo.systemTimeGap=t,this.commitUpload()}if(this.retryCount<this.retryTaskTime)return this.retryCount+=1,this.commitUpload();var t=e.xhr,r=e.errorCode||je,i="commit upload error: UNKNOWN",i=(t&&(i=0===t.status?"commit upload error: NETERROR":e.message||"commit upload error: ".concat(t.status)),CommitUpload_extends(this.currFileCtx,{extra:{message:i,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}));this.failProcess(i)}},{key:"success",value:function success(e,t){var r,i,n={},e=(this.serviceName===m?this.isImageBatchUpload?(r=e.Results,i=e.PluginResult||[],r.forEach(function(e,t){r[t]=CommitUpload_objectSpread(CommitUpload_objectSpread({},r[t]),i[t])}),n=r):CommitUpload_extends(n=e.Results[0],e.PluginResult&&e.PluginResult[0]):n=e.Data,CommitUpload_extends(this.currFileCtx,{stage:"complete",type:"success",percent:100,extra:{message:"upload successful"},uploadResult:n,xhr:t,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currFileCtx.totalDuration}));return this.successProcess(e)}}]),CommitUpload}();function Queue_typeof(e){return(Queue_typeof="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 Queue_extends(){return(Queue_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}function Queue_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,function Queue_toPropertyKey(e){e=function Queue_toPrimitive(e,t){if("object"!==Queue_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==Queue_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===Queue_typeof(e)?e:String(e)}(i.key),i)}}function Queue_setPrototypeOf(e,t){return(Queue_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function Queue_createSuper(r){var i=function Queue_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(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}}();return function _createSuperInternal(){var e,t=Queue_getPrototypeOf(r);return function Queue_possibleConstructorReturn(e,t){{if(t&&("object"===Queue_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return function Queue_assertThisInitialized(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(this,i?(e=Queue_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function Queue_getPrototypeOf(e){return(Queue_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ke=function(){!function Queue_inherits(e,t){if("function"!=typeof t&&null!==t)throw new 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&&Queue_setPrototypeOf(e,t)}(Queue,n());var o=Queue_createSuper(Queue);function Queue(e){var t,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},i=2<arguments.length?arguments[2]:void 0,n=3<arguments.length?arguments[3]:void 0;return function Queue_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,Queue),(t=o.call(this,e)).tasks=e,t.config=r,t.key=n,t.uploaderCtx=i,t.current=0,t.length=t.tasks.length,t.taskError={},t.uploadList=[],t.retryTaskTime=r.retryTaskTime||3,t}return function Queue_createClass(e,t,r){t&&Queue_defineProperties(e.prototype,t),r&&Queue_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(Queue,[{key:"start",value:function start(){var e=this.tasks.shift();e&&(this.current=e.index,this.execTask(e))}},{key:"execTask",value:function execTask(i){var n=this,o=i.key,s=this.uploaderCtx,e=s.tasks[o].cacheTask,a=s.taskList[o].length;e&&0<i.index&&i.index<e?this.start():(s.tasks[o].currentTask=i.index,1===s.tasks[o].status&&i&&i.func.call(i.context,i.arg,function(e){var t=s.taskList[o][i.index+1],r=n.uploaderCtx.tasks[n.key];r.isDirect||r.imagexEnableEncrypt||(t&&0!==i.index&&n.config.useLocalStorage?s._saveTask(o,{currentTask:t.index,stage:t.stage}):i.index===a-1&&s._removeTaskCache(o)),n.success(e),0<n.tasks.length?n.start():s._queueSuccess(o)},function(e){if(1===i.index||5===i.index)return n.fail(e);e.xhr&&400<=e.xhr.status?n.fail(e):n.taskError[o]?n.taskError[o]<n.retryTaskTime?(n.taskError[o]++,n.execTask(i)):(e.key=o,n.fail(e)):(n.taskError[o]=1,n.execTask(i))}))}},{key:"addTask",value:function addTask(e){this.tasks.push(e)}},{key:"success",value:function success(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),Queue_extends(e,{type:"success"}),this.uploaderCtx._broadcast(e.stage,e),this.uploaderCtx.logger.send(e)}},{key:"fail",value:function fail(e){var t,r=this.uploaderCtx;e.xhr&&(t=e.xhr,e.req={url:t.currentUrl,param:t.params},e.res={status:t.status,header:t.getAllResponseHeaders(),body:t.responseText},e.extra&&(e.extra.req=e.req,e.extra.res=e.res),delete e.xhr),Queue_extends(e,{type:"error"}),r._broadcast("error",e),r.logger.send(e),1!==e.currentTask&&(r.tasks[e.key].isBreak?r._cancel(e.key):r._pause(e.key))}},{key:"cancel",value:function cancel(e){var t=this.key,r=this.uploaderCtx.tasks[t].currentTask,r=this.uploaderCtx.tasks[t].isDirect?this.uploaderCtx.taskList[t][r-1]:this.uploaderCtx.taskList[t][r];e?r&&3===r.index&&(e=r.context,Object.values(e.uploadHandlers).forEach(function(e){e.abort()})):(this.tasks=[],r&&3===r.index&&r.context.stop(),this.uploaderCtx._removeTaskCache(t))}},{key:"restart",value:function restart(){this.uploadList.forEach(function(e){e.cancel=!1}),this.start()}}]),Queue}();function MainClass_typeof(e){return(MainClass_typeof="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 _createForOfIteratorHelper(t,r){var i,o,a,c,u="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(u)return o=!(i=!0),{s:function s(){u=u.call(t)},n:function n(){var e=u.next();return i=e.done,e},e:function e(t){o=!0,a=t},f:function f(){try{i||null==u.return||u.return()}finally{if(o)throw a}}};if(Array.isArray(t)||(u=function MainClass_unsupportedIterableToArray(e,t){var r;if(e)return"string"==typeof e?MainClass_arrayLikeToArray(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)?MainClass_arrayLikeToArray(e,t):void 0}(t))||r&&t&&"number"==typeof t.length)return u&&(t=u),c=0,{s:r=function F(){},n:function n(){return c>=t.length?{done:!0}:{done:!1,value:t[c++]}},e:function e(t){throw t},f:r};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function MainClass_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function MainClass_extends(){return(MainClass_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}function MainClass_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,function MainClass_toPropertyKey(e){e=function MainClass_toPrimitive(e,t){if("object"!==MainClass_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==MainClass_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===MainClass_typeof(e)?e:String(e)}(i.key),i)}}function MainClass_setPrototypeOf(e,t){return(MainClass_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function MainClass_createSuper(r){var i=function MainClass_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(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}}();return function _createSuperInternal(){var e,t=MainClass_getPrototypeOf(r);return function MainClass_possibleConstructorReturn(e,t){{if(t&&("object"===MainClass_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return MainClass_assertThisInitialized(e)}(this,i?(e=MainClass_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function MainClass_assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function MainClass_getPrototypeOf(e){return(MainClass_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var qe=function(){!function MainClass_inherits(e,t){if("function"!=typeof t&&null!==t)throw new 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&&MainClass_setPrototypeOf(e,t)}(MainClass,n());var r=MainClass_createSuper(MainClass);function MainClass(e){var t;return function MainClass_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,MainClass),(t=r.call(this,e)).config=MainClass_extends({},C),t._mergeOptions(t.config,e),t.tasks={},t.taskList={},t.cache={},t.storage=b.storage(MainClass_assertThisInitialized(t),t.config.useLocalStorage),t.logger=t.config.noLog?{send:function send(){}}:new he(t.config,MainClass_assertThisInitialized(t)),t.plugins=[],t.priorInfo={systemTimeGap:0,topExpires:0},t}return function MainClass_createClass(e,t,r){t&&MainClass_defineProperties(e.prototype,t),r&&MainClass_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(MainClass,[{key:"_use",value:function _use(e){var t,r=!1,i=_createForOfIteratorHelper(this.plugins);try{for(i.s();!(t=i.n()).done;){var n=t.value;if((null==n?void 0:n.stage)===(null==e?void 0:e.stage)&&(null==n?void 0:n._identifier)===e._identifier){r=!0;break}}}catch(e){i.e(e)}finally{i.f()}r||this.plugins.push(e)}},{key:"_mergeOptions",value:function _mergeOptions(e,t){t&&"object"===MainClass_typeof(t)&&MainClass_extends(e,t)}},{key:"_addAllUploadProcess",value:function _addAllUploadProcess(e,t,r){var i,n=r===m&&"[object Array]"===Object.prototype.toString.call(e.file),o=(this.tasks[t]=this.tasks[t]||{},this.tasks[t]),s=(o.key=t,o.fileType=e.type||ee,o.fileSize=e.file&&e.file.size,o.proxyStsToken=e.stsToken,o.serviceType=r,o.duration=0,o.totalDuration=0,e.file.size<5242880||n),o=(o.isDirect=s,o.isImageBatchUpload=n,r===m&&(i=!(null==(i=this.config)||null==(i=i.imageConfig)||!i.imagexEnableEncrypt),o.imagexEnableEncrypt=i)&&(o.imagexEncryptKey=(null==(i=this.config)||null==(i=i.imageConfig)?void 0:i.imagexEncryptKey)||b.generateKey(32),o.imagexPublicKey=null==(i=this.config)||null==(i=i.imageConfig)?void 0:i.imagexPublicKey),this._addCrc32ProcessTask(e,t,{isDirect:s,isImageBatchUpload:n,serviceName:r}),this._addPreUploadTask(e,t,{isImageBatchUpload:n,serviceId:r===m?e.serviceId:null,serviceName:r}),s?this._addDirectUploadTask(e,t,{isImageBatchUpload:n}):(this._addInitUploadIDTask(e,t),this._addUploadProcessTask(e,t),this._mergeFileTask(e,t)),r===m&&e.skipCommit);this._getMetaInfoTask(e,t,{isImageBatchUpload:n,serviceId:r===m?e.serviceId:null,skipCommit:o,serviceName:r})}},{key:"_run",value:function _run(e){var t=this.tasks,r=navigator.userAgent.toLowerCase().match(/msie ([\d.]+)/);r&&r[1]&&Number(r[1])<=9?(this._broadcast("error",MainClass_extends(t[e],{key:e,status:0,stage:"browserError",extra:{message:"cannot support the browser below ie10"},type:"error"})),this.logger.send(t[e]),this._cancel(e)):t[e]?t[e].status===ne?this._restart(e):(r=new Date,t[e].startTime=r.getTime(),t[e].task&&t[e].status!==y&&t[e].task.tasks.length&&(t[e].status=y,this.logger.send(MainClass_extends({},t[e],{extra:{message:"start upload"},type:"start",key:e})),t[e].task.start())):console.warn("".concat(e," is not exit in object tasks, stop running..."))}},{key:"_setCache",value:function _setCache(e,t){this.storage.setItem(e,t)}},{key:"_getCache",value:function _getCache(e){return this.storage.getItem(e)}},{key:"_removeCache",value:function _removeCache(e){e?this.storage.removeItem(e):this.storage.clear()}},{key:"_addTask",value:function _addTask(e,t){var r=this.tasks,i=this.taskList;r[e]&&r[e].task?i[e].push(t):(i[e]=[],i[e].push(t),r[e]=r[e]||{},r[e].task=new Ke([],this.config,this,e)),r[e].task.addTask(t)}},{key:"_broadcast",value:function _broadcast(e,t){var r=this.tasks[t.key].status;r!==y&&0!==r||this.emit(e,t)}},{key:"_addCrc32ProcessTask",value:function _addCrc32ProcessTask(e,t,r){var i=r.isDirect,n=r.isImageBatchUpload,r=r.serviceName,e=new be({file:e.file,context:this,key:t,isDirect:i,isImageBatchUpload:n,serviceName:r},this.config),i={context:e,func:e.start,arg:{},key:t,index:0,stage:"crc32"};this._addTask(t,i)}},{key:"_addPreUploadTask",value:function _addPreUploadTask(e,t,r){var i=r.isImageBatchUpload,n=r.serviceId,r=r.serviceName,i={file:e.file,stsToken:e.stsToken,context:this,type:e.type||ee,preUploadUriParams:e.preUploadUriParams||{},key:t,isImageBatchUpload:i,fileName:e.fileName||null,fileExtension:e.fileExtension||null,storageClass:e.storageClass||null,serviceId:n,prefix:e.prefix,storeKey:e.storeKey,serviceName:r,overwrite:e.overwrite},n=new Fe(i,this.config),r={context:n,func:n.start,arg:{},key:t,index:1,stage:"preUpload"};this._addTask(t,r)}},{key:"_addDirectUploadTask",value:function _addDirectUploadTask(e,t,r){r=r.isImageBatchUpload,e=new He({file:e.file,context:this,key:t,isImageBatchUpload:r},this.config),r={context:e,func:e.start,arg:{},key:t,index:3,stage:"process"};this._addTask(t,r)}},{key:"_addInitUploadIDTask",value:function _addInitUploadIDTask(e,t){e=new Me({file:e.file,context:this,key:t},this.config),e={context:e,func:e.start,arg:{},key:t,index:2,stage:"initUploadID"};this._addTask(t,e)}},{key:"_addUploadProcessTask",value:function _addUploadProcessTask(e,t){e=new Be({file:e.file,context:this,key:t},this.config),e={context:e,func:e.start,arg:{},key:t,index:3,stage:"process"};this._addTask(t,e)}},{key:"_mergeFileTask",value:function _mergeFileTask(e,t){e=new ze({file:e.file,context:this,stage:"fileMerge",key:t},this.config),e={context:e,func:e.start,arg:{},key:t,index:4,stage:"fileMerge"};this._addTask(t,e)}},{key:"_getMetaInfoTask",value:function _getMetaInfoTask(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i=r.isImageBatchUpload,n=r.serviceId,o=r.skipCommit,r=r.serviceName,i={file:e.file,context:this,data:e.data,type:e.type||ee,callbackArgs:e.callbackArgs,key:t,isImageBatchUpload:void 0!==i&&i,serviceId:n,processAction:e.processAction,skipCommit:o,skipMeta:e.skipMeta,serviceName:r},n=new Le(i,this.config),o={context:n,func:n.start,arg:{},key:t,index:5,stage:"complete"};this._addTask(t,o)}},{key:"_restart",value:function _restart(r){var i,n,o=this,e=this.tasks;e[r]?(i=e[r].task,n=e[r].currentTask||0,this.taskList[r].forEach(function(e,t){e.index===n&&(i.tasks=o.taskList[r].slice(t))}),i&&e[r].status!==y&&i.tasks.length&&(e[r].status=y,i.restart())):console.warn("".concat(r," is not exit in object tasks"))}},{key:"_cancel",value:function _cancel(e){var t=this.tasks;t[e]?(t[e].status=ie,t[e].task.cancel(!1),this.taskList[e]=[]):console.warn("".concat(e," is not exit in object tasks"))}},{key:"_pause",value:function _pause(e){var t=this.tasks;t[e]?(t[e].status=ne,t[e].task.cancel(!0),t[e].isDirect||t[e].imagexEnableEncrypt||this._saveTask(e)):console.warn("".concat(e," is not exit in object tasks"))}},{key:"_removeTaskCache",value:function _removeTaskCache(e){var t=this.tasks;if(t[e]){t=t[e].crc32Key;if(t)try{this._removeCache(t)}catch(e){console.warn("[TTUploader]:",null==e?void 0:e.message)}}else console.warn("".concat(e," is not exit in object tasks"))}},{key:"_saveTask",value:function _saveTask(e,t){e=MainClass_extends({},this.tasks[e],t||{}),t=e.crc32Key;if(t){var r={SessionKey:e.SessionKey,UploadHeader:e.UploadHeader,fileName:e.fileName,oid:e.oid,uploadID:e.uploadID,signature:e.signature,tosDomain:e.tosDomain,hasMerge:e.hasMerge};Object.keys(r).forEach(function(e){r[e]||delete r[e]});try{this._setCache(t,JSON.stringify(r))}catch(e){return[!1,e.message]}return[!0,""]}}},{key:"_queueSuccess",value:function _queueSuccess(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,this.taskList[e]=[]):console.warn("".concat(e," is not exit in object tasks"))}},{key:"_removeFile",value:function _removeFile(e){delete this.tasks[e]}},{key:"_batchAction",value:function _batchAction(t){var e=this.tasks;Object.keys(e).forEach(function(e){t&&t(e)})}},{key:"_refreshStsToken",value:function _refreshStsToken(i){var n=this,o=this.tasks;Object.keys(o).forEach(function(e){var e=o[e],t=MainClass_extends({},e,{proxyStsToken:i}),r=(e.proxyStsToken=i,t.crc32Key);r&&(delete t.task,delete t.xhr,delete t.crc32Array,e.proxyStsToken=i,n._setCache(r,JSON.stringify(t)))})}},{key:"_setOption",value:function _setOption(e){this._mergeOptions(this.config,e)}},{key:"_setServiceId",value:function _setServiceId(e){!this.config.imageConfig&&e?this.config.imageConfig={serviceId:e}:this.config.imageConfig.serviceId=e}},{key:"_getServiceId",value:function _getServiceId(){var e;return null==(e=this.config.imageConfig)?void 0:e.serviceId}},{key:"_getOption",value:function _getOption(e){var t=MainClass_extends({},this.config);return e?t[e]:t}},{key:"_userCancel",value:function _userCancel(e){var t=this,r=this.tasks;e?(this._cancel(e),this.logger.send(MainClass_extends({},r[e],{type:"cancel"}))):Object.keys(r).forEach(function(e){t._cancel(e),t.logger.send(MainClass_extends({},r[e],{type:"cancel"}))})}},{key:"_userPause",value:function _userPause(e){var t=this,r=this.tasks;e?(this._pause(e),this.logger.send(MainClass_extends({},r[e],{type:"pause"}))):Object.keys(r).forEach(function(e){t._pause(e),t.logger.send(MainClass_extends({},r[e],{type:"pause"}))})}}]),MainClass}();const We={checkFile:function checkFile(e){return e instanceof Blob},checkStsToken:function checkStsToken(e){return!e||e.SessionToken&&e.SecretAccessKey&&(e.AccessKeyId||e.AccessKeyID)}};function entry_typeof(e){return(entry_typeof="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 entry_defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,function entry_toPropertyKey(e){e=function entry_toPrimitive(e,t){if("object"!==entry_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==entry_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===entry_typeof(e)?e:String(e)}(i.key),i)}}function entry_setPrototypeOf(e,t){return(entry_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function entry_createSuper(r){var i=function entry_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(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}}();return function _createSuperInternal(){var e,t=entry_getPrototypeOf(r);return function entry_possibleConstructorReturn(e,t){{if(t&&("object"===entry_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return function entry_assertThisInitialized(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(this,i?(e=entry_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function entry_getPrototypeOf(e){return(entry_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ge=function(){!function entry_inherits(e,t){if("function"!=typeof t&&null!==t)throw new 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&&entry_setPrototypeOf(e,t)}(TTUploader,qe);var e=entry_createSuper(TTUploader);function TTUploader(){return function entry_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,TTUploader),e.apply(this,arguments)}return function entry_createClass(e,t,r){t&&entry_defineProperties(e.prototype,t),r&&entry_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(TTUploader,[{key:"use",value:function use(e){this._use(e)}},{key:"start",value:function start(e){this.abort=!1,e?this._run(e):this._batchAction(this._run.bind(this))}},{key:"addFile",value:function addFile(e){var t;return e&&We.checkStsToken(e.stsToken)?e.file?(t=b.getUnique("file"),this._addAllUploadProcess(e,t,_),t):null:(this.emit("error",{extra:{message:Ae,errorCode:Oe}}),null)}},{key:"addImageFile",value:function addImageFile(e){var t;return e&&We.checkStsToken(e.stsToken)?e.file?(e.type=te,t=b.getUnique("file"),this._addAllUploadProcess(e,t,m),t):null:(this.emit("error",{extra:{message:Ae,errorCode:Oe}}),null)}},{key:"addImageXFile",value:function addImageXFile(e){return this.addImageFile(e)}},{key:"setServiceId",value:function setServiceId(e){this._setServiceId(e)}},{key:"getServiceId",value:function getServiceId(){return this._getServiceId()}},{key:"removeFile",value:function removeFile(e){e&&this._removeFile(e)}},{key:"cancel",value:function cancel(e){e?this._userCancel(e):this._batchAction(this._userCancel.bind(this))}},{key:"pause",value:function pause(e){this._userPause(e)}},{key:"restart",value:function restart(e){e?this._restart(e):this._batchAction(this._restart.bind(this))}},{key:"refreshAuth",value:function refreshAuth(e){this._refreshAuth(e)}},{key:"setOption",value:function setOption(e){this._setOption(e)}},{key:"getOption",value:function getOption(e){return this._getOption(e)}}]),TTUploader}()})(),Qe.default})());
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TTUploader=t()}(this,(function(){"use strict";function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function t(t){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?e(Object(i),!0).forEach((function(e){a(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function r(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function i(e){return(i="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 s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,r(s.key),s)}}function o(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t,i){return(t=r(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function c(e,t){if("function"!=typeof t&&null!==t)throw new 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&&l(e,t)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(N){return!1}}();return function(){var r,i=u(e);if(t){var s=u(this).constructor;r=Reflect.construct(i,arguments,s)}else r=i.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return h(e)}(this,r)}}function f(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||p(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,t){if(e){if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,t):void 0}}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}var y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function v(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function m(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];return r.push.apply(r,arguments),new(Function.bind.apply(t,r))}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})})),r}var _={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function n(e,t,i,n,o){if("function"!=typeof i)throw new TypeError("The listener must be a function");var a=new s(i,n||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,i,s=[];if(0===this._eventsCount)return s;for(i in e=this._events)t.call(e,i)&&s.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},a.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var s=0,n=i.length,o=new Array(n);s<n;s++)o[s]=i[s].fn;return o},a.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},a.prototype.emit=function(e,t,i,s,n,o){var a=r?r+e:e;if(!this._events[a])return!1;var c,u,l=this._events[a],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,i),!0;case 4:return l.fn.call(l.context,t,i,s),!0;case 5:return l.fn.call(l.context,t,i,s,n),!0;case 6:return l.fn.call(l.context,t,i,s,n,o),!0}for(u=1,c=new Array(h-1);u<h;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var d,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),h){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,i);break;case 4:l[u].fn.call(l[u].context,t,i,s);break;default:if(!c)for(d=1,c=new Array(h-1);d<h;d++)c[d-1]=arguments[d];l[u].fn.apply(l[u].context,c)}}return!0},a.prototype.on=function(e,t,r){return n(this,e,t,r,!1)},a.prototype.once=function(e,t,r){return n(this,e,t,r,!0)},a.prototype.removeListener=function(e,t,i,s){var n=r?r+e:e;if(!this._events[n])return this;if(!t)return o(this,n),this;var a=this._events[n];if(a.fn)a.fn!==t||s&&!a.once||i&&a.context!==i||o(this,n);else{for(var c=0,u=[],l=a.length;c<l;c++)(a[c].fn!==t||s&&!a[c].once||i&&a[c].context!==i)&&u.push(a[c]);u.length?this._events[n]=1===u.length?u[0]:u:o(this,n)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&o(this,t)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,e.exports=a}(_);var x=v(_.exports),k={region:"cn-north-1",getSliceFunc:null,uploadSliceCount:5,retryUploadTime:2,retryTaskTime:2,requestTimeout:3e5,uploadTimeout:18e5,retryInterval:1e3,schema:"https",useLocalStorage:!0,taskParallelLimit:3},M=function(){return(M=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)};function w(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,s,n=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o}function b(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(w(arguments[t]));return e}var T,N,C,D=function(e,t){var r,i,s=function(e){var t=document.createElement("a");return t.href=e,t},n=window.screen.width,o=window.screen.height,a=window.navigator.appVersion,c=window.navigator.userAgent,u=window.navigator.language,l=document.referrer,h=l?s(l).hostname:"",d=function(e){var t=s(e).search;t=t.slice(1);var r={};return t.split("&").forEach((function(e){var t,i,s=e.split("=");s.length&&(t=s[0],i=s[1]),i&&(i=i.replace(/\%/g,"%25")),r[t]=decodeURIComponent(void 0===i?"":i)})),r}(window.location.href),f="",p="",g="",y=""+parseFloat(a);-1!==(r=c.indexOf("Opera"))&&(g="Opera",y=c.substring(r+6),-1!==(r=c.indexOf("Version"))&&(y=c.substring(r+8))),-1!==(r=c.indexOf("Edge"))?(g="Microsoft Edge",y=c.substring(r+5)):-1!==(r=c.indexOf("MSIE"))?(g="Microsoft Internet Explorer",y=c.substring(r+5)):-1!==c.indexOf("Chrome")?-1!==(r=c.indexOf("MicroMessenger"))?(g="weixin",y=c.substring(r+15,r+20)):-1!==(r=c.indexOf("MQQBrowser"))?(g="qqbrowser",y=c.substring(r+11,r+15)):-1!==(r=c.indexOf("Chrome"))&&(g="Chrome",y=c.substring(r+7)):-1!==c.indexOf("Safari")?-1!==(r=c.indexOf("QQ"))?(g="qqbrowser",y=c.substring(r+10,r+16)):-1!==(r=c.indexOf("Safari"))&&(g="Safari",y=c.substring(r+7),-1!==(r=c.indexOf("Version"))&&(y=c.substring(r+8))):-1!==(r=c.indexOf("Firefox"))?(g="Firefox",y=c.substring(r+8)):-1!==(r=c.indexOf("MicroMessenger"))?(g="weixin",y=c.substring(r+15,r+20)):-1!==(r=c.indexOf("QQ"))&&(g="qqbrowser",y=c.substring(r+3,r+8)),-1!==(i=y.indexOf(";"))&&(y=y.substring(0,i)),-1!==(i=y.indexOf(" "))&&(y=y.substring(0,i)),-1!==(i=y.indexOf(")"))&&(y=y.substring(0,i));for(var v,m,_=/Mobile|htc|mini|Android|iP(ad|od|hone)/.test(a)?"wap":"web",x=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0)/},{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:"Sun OS",r:/SunOS/},{s:"Linux",r:/(Linux|X11)/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/}],k=0;k<x.length;k++){var M=x[k];if(M.r.test(c)){f=M.s;break}}function w(e,t){var r=e.exec(t);return r&&r[1]?r[1]:""}switch(/Windows/.test(f)&&(p=w(/Windows (.*)/,f),f="windows"),f){case"Mac OS X":p=w(/Mac OS X (10[\.\_\d]+)/,c),f="mac";break;case"Android":(m=w(/Android ([\.\_\d]+)/,v=c))||(m=w(/Android\/([\.\_\d]+)/,v)),p=m,f="android";break;case"iOS":p=(p=/OS (\d+)_(\d+)_?(\d+)?/.exec(a))?p[1]+"."+p[2]+"."+(0|p[3]):"",f="ios"}var b=e?function(){var e=t?"_tea_utm_cache_"+t:"_tea_utm_cache",r={},i={utm_source:d.utm_source,utm_medium:d.utm_medium,utm_campaign:d.utm_campaign,utm_term:d.utm_term,utm_content:d.utm_content};try{var s=window.sessionStorage,n=!1;for(var o in i)i[o]&&(r[o]=i[o],n=!0);if(n)s.setItem(e,JSON.stringify(r));else{var a=s.getItem(e);a&&(r=JSON.parse(a))}}catch(c){return i}return r}():{};return{browser:g,browser_version:y,platform:_,os_name:f,os_version:p,userAgent:c,screen_width:n,screen_height:o,device_model:function(e){var t="";try{if("android"===e)navigator.userAgent.split(";").forEach((function(e){e.indexOf("Build/")>-1&&(t=e.slice(0,e.indexOf("Build/")))}));else if("ios"===e||"mac"===e){var r=navigator.userAgent.replace("Mozilla/5.0 (",""),i=r.indexOf(";");t=r.slice(0,i)}}catch(s){}return t.trim()}(f),language:u,referrer:l,referrer_host:h,utm_source:b.utm_source,utm_medium:b.utm_medium,utm_campaign:b.utm_campaign,utm_term:b.utm_term,utm_content:b.utm_content,isSupportBeacon:("ios"!==f||"safari"!==g)&&(!(!window.navigator||!window.navigator.sendBeacon)||void 0)}},I=(N=T={exports:{}},C=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var r=arguments[e];for(var i in r)t[i]=r[i]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function r(i){function s(){}function n(t,r,n){if("undefined"!=typeof document){"number"==typeof(n=e({path:"/"},s.defaults,n)).expires&&(n.expires=new Date(1*new Date+864e5*n.expires)),n.expires=n.expires?n.expires.toUTCString():"";try{var o=JSON.stringify(r);/^[\{\[]/.test(o)&&(r=o)}catch(u){}r=i.write?i.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="";for(var c in n)n[c]&&(a+="; "+c,!0!==n[c]&&(a+="="+n[c].split(";")[0]));return document.cookie=t+"="+r+a}}function o(e,r){if("undefined"!=typeof document){for(var s={},n=document.cookie?document.cookie.split("; "):[],o=0;o<n.length;o++){var a=n[o].split("="),c=a.slice(1).join("=");r||'"'!==c.charAt(0)||(c=c.slice(1,-1));try{var u=t(a[0]);if(c=(i.read||i)(c,u)||t(c),r)try{c=JSON.parse(c)}catch(l){}if(s[u]=c,e===u)break}catch(l){}}return e?s[e]:s}}return s.set=n,s.get=function(e){return o(e,!1)},s.getJSON=function(e){return o(e,!0)},s.remove=function(t,r){n(t,"",e(r,{expires:-1}))},s.defaults={},s.withConverter=r,s}((function(){}))},N.exports=C(),T.exports),O=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}(),S={getItem:function(e){try{var t=localStorage.getItem(e),r=t;try{t&&"string"==typeof t&&(r=JSON.parse(t))}catch(i){}return r||void 0}catch(i){}},setItem:function(e,t){try{var r="string"==typeof t?t:JSON.stringify(t);localStorage.setItem(e,r)}catch(i){}},removeItem:function(e){try{localStorage.removeItem(e)}catch(t){}},getCookie:function(e){try{var t=document.cookie.match(new RegExp("(?:^|;)\\s*"+e+"=([^;]+)")),r=t?t[1]:"";return decodeURIComponent(r)}catch(i){return""}},setCookie:function(e,t,r){try{var i=+new Date+r;I.set(e,t,{expires:new Date(i),path:"/",domain:document.domain.split(".").slice(-2).join(".")})}catch(s){}},isSupportLS:function(){try{return localStorage.setItem("_ranger-test-key","hi"),localStorage.getItem("_ranger-test-key"),localStorage.removeItem("_ranger-test-key"),!0}catch(N){return!1}}()},E=function(){function e(e){this._storage=!e&&S.isSupportLS?S:new O}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){return this._storage.getCookie(e)},e.prototype.setCookie=function(e,t,r){this._storage.setCookie(e,t,r)},e.prototype.removeItem=function(e){this._storage.removeItem(e)},e}(),A={cn:"https://mcs.snssdk.com",sg:"https://sgali-mcs.byteoversea.com",va:"https://maliva-mcs.byteoversea.com"},z="/v1/user/webid",j=4001,U=4e3,R=4002,L=4003,P=500,F=function(e,t){return t?"__tea_cache_tokens_"+e:"__tea_cache_events_"+e},B=function(e,t,r,i){try{var s,n=e.match(/\/v\d\//);s=n?n[0]:-1!==e.indexOf("/v1/")?"/v1/":"/v2/";var o=e.split(s)[0];if(!o)return void i(e,t,j);t.forEach((function(s){var n=function(e){var t="";for(var r in e)e.hasOwnProperty(r)&&void 0!==e[r]&&(t+="&"+r+"="+encodeURIComponent(JSON.stringify(e[r])));return"&"===t[0]?t.slice(1):t}(s),a=new Image(1,1);a.onload=function(){a=null,r&&r()},a.onerror=function(){a=null,i&&i(e,t,U)},a.src=o+"/v1/gif?"+n}))}catch(a){i&&i(e,t,R,a.message)}},q=function(e,t,r,i,s,n,o,a){var c,u,l,h,d,f,p=window.navigator.userAgent,g=-1!==window.navigator.appName.indexOf("Microsoft Internet Explorer")&&(-1!==p.indexOf("MSIE 8.0")||-1!==p.indexOf("MSIE 9.0")),y=!!r;if(!y&&g)B(e,t,i,s);else if(!y&&o)return D(!1).isSupportBeacon?(a&&a(),void(window.navigator.sendBeacon(e,JSON.stringify(t))?i():s(e,t,L))):void B(e,t,i,s);n&&delete t.app_key,c=e,u=t,l=i,h=s,d=r,(f=new XMLHttpRequest).open("POST",""+c,!0),f.setRequestHeader("Content-Type","application/json; charset=utf-8"),d&&f.setRequestHeader("X-MCS-AppKey",""+d),f.onload=function(){if(l){var e=null;if(f.responseText){try{e=JSON.parse(f.responseText)}catch(t){e={}}l(e)}}},f.onerror=function(){f.abort(),h&&h(u,P)},f.send(JSON.stringify(u))};function H(e){return e?(e^16*Math.random()>>e/4).toString(10):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,H)}var K,Q=function(){return H().replace(/-/g,"").slice(0,19)},Y=function(){function e(e,t){this.browser=D(!0,e.app_id),this.config=e,this.cfg=t,this.storage=new E(!1),this.appInfo=e.app_key||e.app_id,this.isNoWebid=e.disable_webid,this.isNoSsid=e.disable_webid||e.disable_ssid,this.domain=e.channel_domain||A[e.channel],this.tokenReady=!1,this.checkExp=e.checkExp||!1,this.enableCookie=e.cross_subdomain||!1,this.expiresTime=this.enableCookie?94608e6:0,this.fetchUrl=""+this.domain+z}return e.prototype._getToken=function(){this.tokensKey=F(this.appInfo,!0),this.cookieKey="__tea_cookie_tokens_"+this.appInfo;var e=this.storage.getItem(this.tokensKey);if(this.enableCookie){var t=this.storage.getCookie(this.cookieKey);if(t){t=decodeURIComponent(t);var r=(t=JSON.parse(t)).user_unique_id,i=t.web_id,s=t.timestamp,n=t.ssid;this._setToken(i,r,n,s)}else{if(!e)return void this._requestWebId();this.storage.setCookie(this.cookieKey,encodeURIComponent(JSON.stringify(e)),this.expiresTime),this._checkLocal(e)}}else{if(!e)return void this._requestWebId();this._checkLocal(e)}},e.prototype._checkLocal=function(e){if(!e.web_id){var t=this.storage.getCookie("tt_webid"),r=this.storage.getCookie("__tea_sdk__ssid"),i=this.storage.getCookie("__tea_sdk__user_unique_id");if(t&&r&&i){var s={web_id:t,ssid:r,user_unique_id:i,timestamp:Date.now()};this.storage.setItem(this.tokensKey,s)}}var n=this.storage.getItem(this.tokensKey),o=(i=n.user_unique_id,t=n.web_id,n.timestamp);r=n.ssid,t&&i?this._setToken(t,i,r,o):this._requestWebId()},e.prototype._setToken=function(e,t,r,i){if(this.uuid=t,this.web_id=e,this.ssid=r,this.checkExp){var s=Date.now()-parseFloat(i);if(s>7344e6)return void this._requestWebId();if(s>432e7)return void this._updateWebId(e)}this._complete(e,t,r)},e.prototype._complete=function(e,t,r){this.cfg.envInfo.user.ssid=r,this.cfg.envInfo.user.web_id=e,this.cfg.envInfo.user.user_unique_id=t,this.tokenReady=!0},e.prototype._requestWebId=function(){this.isNoWebid?this._setwebId({web_id:Q(),ssid:""}):this._fetchWebId(this.fetchUrl,!1)},e.prototype._updateWebId=function(e){var t=""+this.domain+z+"/"+e+"/update";this._fetchWebId(t,!0)},e.prototype._fetchWebId=function(e,t){var r=this;this.isGetWebId=!0,q(e,{app_key:this.config.app_key,app_id:this.config.app_id,url:location.href,user_agent:this.browser.userAgent,referer:this.browser.referrer,user_unique_id:""},this.config.app_key,(function(e){if(e&&0===e.e)if(t){var i={web_id:r.web_id,ssid:r.ssid,user_unique_id:r.uuid,timestamp:Date.now()};r.enableCookie&&r.storage.setCookie(r.cookieKey,encodeURIComponent(JSON.stringify(i)),r.expiresTime),r.storage.setItem(r.tokensKey,i),r._complete(r.web_id,r.uuid,r.ssid),r.isGetSsid?r._requestSsId():r.callback&&r.callback()}else r.isGetWebId=!1,r._setwebId(e),r.isGetSsid?r._requestSsId():r.callback&&r.callback();else t?r._fetchWebId(r.fetchUrl,!1):r.isGetWebId=!1}),(function(){r.isGetWebId=!1}),!0)},e.prototype._setwebId=function(e){var t=this.cfg.envInfo.user.web_id||e.web_id,r={web_id:t,ssid:e.ssid,user_unique_id:this._uuid?this._uuid:t,timestamp:Date.now()};this.enableCookie&&this.storage.setCookie(this.cookieKey,encodeURIComponent(JSON.stringify(r)),this.expiresTime),this.storage.setItem(this.tokensKey,r),this.cfg.envInfo.user.ssid=e.ssid,this.cfg.envInfo.user.web_id=t,this.cfg.envInfo.user.user_unique_id=this._uuid?this._uuid:t,this.uuid=this._uuid?this._uuid:t,this.web_id=t,this.ssid=e.ssid,this.tokenReady=!0},e.prototype._getSsid=function(e){e&&-1===["0","Null","None","","undefined"].indexOf(e)&&(this.uuid===e&&this.web_id&&this.ssid?this.tokenReady=!0:(this._uuid=e,this.uuid=e,this.cfg.envInfo.user.user_unique_id=e,this.isGetSsid=!0,this.isNoSsid||this.isGetWebId?this.callback&&this.callback():(this.tokenReady=!1,this.isGetSsid=!1,this._requestSsId())))},e.prototype._requestSsId=function(){var e=this,t=this.domain+"/v1/user/ssid";q(t,{app_key:this.config.app_key,app_id:this.config.app_id,web_id:this.web_id,user_unique_id:this.uuid},this.config.app_key,(function(t){if(t&&0===t.e){e.cfg.envInfo.user.ssid=t.ssid;var r={web_id:e.web_id,ssid:t.ssid,user_unique_id:e.uuid,timestamp:Date.now()};e.enableCookie&&e.storage.setCookie(e.cookieKey,encodeURIComponent(JSON.stringify(r)),e.expiresTime),e.storage.setItem(e.tokensKey,r),e.tokenReady=!0}else e.tokenReady=!0;e.callback&&e.callback()}),(function(){e.tokenReady=!0,e.callback&&e.callback()}),!0)},e.prototype.isTokenReady=function(){return this.tokenReady},e}(),W=function(){function e(e,t,r,i){this.cfg=t,this.config=e,this._token=r,this.appInfo=e.app_key||e.app_id,this.debugMode=!!e.log,this.evtDataKey=F(this.appInfo,!1);var s=e.channel_domain||A[e.channel];this.reportUrl=e.report_url?e.report_url:s+"/v1/list",this.maxReport=e.max_report||20,this.storage=new E(!0),this.plugin=i,this.addListener()}return e.prototype.addListener=function(){var e=this;window.addEventListener("unload",(function(){e.report(!0)}),!1),window.addEventListener("beforeunload",(function(){e.report(!0)}),!1),document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&e.report(!0)}),!1)},e.prototype.setReady=function(){this.isReady=!0,this.report()},e.prototype.event=function(e,t){var r=this;void 0===e&&(e=[]),void 0===t&&(t=!1);var i=this.storage.getItem(this.evtDataKey)||[],s=t?b(e,i):b(i,e);this.storage.setItem(this.evtDataKey,s),this.reportTimer&&clearTimeout(this.reportTimer),s.length>=this.maxReport?this.report():this.reportTimer=setTimeout((function(){r.report(),r.reportTimer=null}),30)},e.prototype.report=function(e){if(void 0===e&&(e=!1),this._token.isTokenReady()&&this.isReady){var t=this.storage.getItem(this.evtDataKey)||[],r=this._mergeEvents(t);this.storage.removeItem(this.evtDataKey),this._dealData(r,e)}},e.prototype._mergeEvents=function(e){var t=this;if(!e.length)return e;var r=this.cfg.get();r.header.custom=JSON.stringify(r.header.custom);var i=[];return i.push(e),i.map((function(e){return{events:e.map((function(e){var r=M({},t.cfg.get("evtParams"),e.params);return delete r.__disable_storage__,M({},e,{params:JSON.stringify(r)})})),user:r.user,header:r.header,verbose:t.debugMode?1:void 0}}))},e.prototype._dealData=function(e,t){var r=this;if(!e.length)return e;e.map((function(e){var t=[];return t.push(e),t})).forEach((function(e){var i=Q();r._send(i,e,t)}))},e.prototype._send=function(e,t,r){var i=this;this.isSending=!0;var s=function(){i.isSending=!1};q(this.reportUrl,t,this.config.app_key,(function(){s()}),(function(e,t){s(),i.cfg.get("reportErrorCallback")(e,t)}),!1,r,s)},e}(),G=void 0,J=(new Date).getTimezoneOffset(),V=parseInt(""+-J/60,10),X=60*J,Z=function(){function e(e){var t=D(!0,e);this.envInfo={user:{user_unique_id:G,user_type:G,user_id:G,user_is_auth:G,user_is_login:G,device_id:G,web_id:G,ip_addr_id:G,ssid:G},header:{app_id:G,app_name:G,app_install_id:G,install_id:G,app_package:G,app_channel:G,app_version:G,os_name:t.os_name,os_version:t.os_version,device_model:t.device_model,ab_client:G,ab_version:G,ab_sdk_version:G,traffic_type:G,client_ip:G,device_brand:G,os_api:G,access:G,language:t.language,region:G,app_language:G,app_region:G,creative_id:G,ad_id:G,campaign_id:G,log_type:G,rnd:G,platform:t.platform,sdk_version:"4.1.15",province:G,city:G,timezone:V,tz_offset:X,tz_name:G,sim_region:G,carrier:G,resolution:t.screen_width+"x"+t.screen_height,browser:t.browser,browser_version:t.browser_version,referrer:t.referrer,referrer_host:t.referrer_host,width:t.screen_width,height:t.screen_height,screen_width:t.screen_width,screen_height:t.screen_height,utm_term:t.utm_term,utm_content:t.utm_content,utm_source:t.utm_source,utm_medium:t.utm_medium,utm_campaign:t.utm_campaign,custom:{}}},this.evtParams={},this.reportErrorCallback=function(){}}return e.prototype.set=function(e,t){var r=this;if("disable_auto_pv"!==e)if("evtParams"===e||"_staging_flag"===e){var i;i="evtParams"===e?t:{_staging_flag:Number(t)};var s=M({},i);Object.keys(s).forEach((function(e){r.evtParams[e]=s[e]}))}else if("reportErrorCallback"===e&&"function"==typeof t)this.reportErrorCallback=t;else{var n="";if(e.indexOf(".")>-1){var o=e.split(".");n=o[0],e=o[1]}if("user_unique_id"===e){if(!t)return;if(-1!==["0","Null","None","","undefined"].indexOf(t))return}if("os_version"===e&&(e=""+t),"web_id"===e){if(!t)return;(!this.envInfo.user.user_unique_id||this.envInfo.user.user_unique_id&&this.envInfo.user.user_unique_id===this.envInfo.user.web_id)&&(this.envInfo.user.user_unique_id=t)}n?"user"===n||"header"===n?this.envInfo[n][e]=t:this.envInfo.header.custom[e]=t:this.envInfo.user.hasOwnProperty(e)?["user_type","device_id","ip_addr_id"].indexOf(e)>-1?this.envInfo.user[e]=Number(t):["user_id","web_id","user_unique_id","ssid"].indexOf(e)>-1?this.envInfo.user[e]=String(t):["user_is_auth","user_is_login"].indexOf(e)>-1&&(this.envInfo.user[e]=Boolean(t)):this.envInfo.header.hasOwnProperty(e)?this.envInfo.header[e]=t:this.envInfo.header.custom[e]=t}},e.prototype.get=function(e){return e?"evtParams"===e?this.evtParams:"reportErrorCallback"===e?this.reportErrorCallback:JSON.parse(JSON.stringify(this.envInfo[e])):JSON.parse(JSON.stringify(this.envInfo))},e}(),$=function(){function e(e,t){this.isLog=t,this.name=e||""}var t=e.prototype;return t.info=function(e){this.isLog&&console.log(this.name+" "+e)},t.warn=function(e){this.isLog&&console.warn(this.name+" "+e)},t.error=function(e){this.isLog&&console.error(this.name+" "+e)},t.throw=function(e){throw this.error(this.name),new Error(e)},e}(),ee=b(["init","config","send","start"],[]),te=(K=+Date.now()+Number((""+Math.random()).slice(2,8)),function(){return K+=1}),re=function(){function e(e){var t=this;this.predefinePageView=function(e){void 0===e&&(e={});var r=M({title:document.title||location.pathname,url:location.href,url_path:location.pathname,time:Date.now(),referrer:window.document.referrer},t._event.closeStorage?{}:{__disable_storage__:1}),i=M({},r,e);t.event("predefine_pageview",i,!0)},this.name=e,this._isSend=!1,this.autoPV=!0}return e.prototype.init=function(e){var t=this;if(!this._inited){if(this._inited=!0,!e||"object"!=i(e))throw new Error("init参数有误,请检查");var r=e.app_id,s=e.app_key,n=e.log;this._config=new Z(r),this.logger=new $(this.name,n),s||r||this.logger.throw("没有传入 app_key 或 app_id "),r&&"number"!=typeof r&&this.logger.throw("app_id参数有误,请检查 "),s&&"string"!=typeof s&&this.logger.warn("app_key为空,如果有请传入"),e.channel_domain||-1!==["cn","sg","va"].indexOf(e.channel)||this.logger.throw("channel 变量只能是 `cn`, `sg`,`va`"),this._config.set("app_id",r),e.channel=e.channel?e.channel:"cn",this._initConfig=e,this._token=new Y(e,this._config),this._token.callback=function(){t.callbackSend&&t.start()},this._event=new W(e,this._config,this._token,this.plugin),this._token._getToken()}},e.prototype.config=function(e){if(this._inited)if(e&&"object"==i(e)){if(e.user_unique_id){if("string"!=typeof e.user_unique_id)throw new Error("user_unique_id 只能是string");this._token._getSsid(e.user_unique_id)}for(var t in e.disable_auto_pv&&(this.autoPV=!1),e)this._config.set(t,e[t])}else this.logger.warn("config参数有误,请检查");else this.logger.warn("config应在init之后调用")},e.prototype.send=function(){this.start()},e.prototype.start=function(){if(this._token.isTokenReady()){if(this._isSend)return;this._isSend=!0,this.logger.info("用户信息:"+JSON.stringify(this._config.get("user"))),this.autoPV&&this.predefinePageView(),this._event.setReady()}else this.callbackSend=!0},e.prototype.event=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="boolean"==typeof e[e.length-1]&&e[e.length-1],s="boolean"==typeof e[e.length-1]?e.slice(0,e.length-1):e,n=w(s,1)[0],o=[];"Array"!==Object.prototype.toString.call(n).slice(8,-1)?o[0]=s:o=s,o=o.map((function(e){return function(e,t){var r=e;/^event\./.test(e)&&(r=e.slice(6));var s=t;return"object"!=i(s)&&(s={}),s.event_index=te(),{event:r,params:s,local_time_ms:+new Date,is_bav:0}}(e[0],e[1])})),this._event.event(o,r)},e}();function ie(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var se=function(e){var t=this;return ie(this,"_exportCollect",(function(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];t._isProcess?t._executeCmd.apply(t,r):(t.cmdQueue.push(r),t._processCmd())})),ie(this,"_processCmd",(function(){if(0!==t.cmdQueue.length){var e,r,i=(e=t.cmdQueue,"init","0",r=-1,e.forEach((function(e,t){"init"===e[0]&&(r=t)})),r);-1!==i&&(t._isProcess=!0,t._executeCmd.apply(t,t.cmdQueue[i]),t.cmdQueue.forEach((function(e,r){r!==i&&t._executeCmd.apply(t,e)})),t.cmdQueue=[])}})),ie(this,"_executeCmd",(function(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];var s,n,o=r[0];ee.indexOf(o)>-1?(s=t.colloctor)[o].apply(s,r.slice(1)):(n=t.colloctor).event.apply(n,r)})),this.cmdQueue=[],this.name=e,this.colloctor=new re(e),this._isProcess=!1,this._alias={},this._processCmd(),ee.forEach((function(e){t._exportCollect[e]=t._exportCollect.bind(t,e)})),this._exportCollect},ne={},oe={},ae=function(e){return oe[e]||(oe[e]=[]),oe[e]},ce=function(e){var t=w(e),r=t[0],i=t.slice(1),s=r.split(".");if(1===s.length)ae("default").push(b([r],i));else if(2===s.length)"event"===s[0]?ae("default").push(b([r],i)):ae(s[0]).push(b([s[1]],i));else{var n=s[0],o=[s[1],s[2]].join(".");ae(n).push(b([o],i))}},ue=function(){le.q.forEach((function(e){var t=[].slice.call(e);"Array"===Object.prototype.toString.call(t[0]).slice(8,-1)?t.forEach((function(e){ce(e)})):ce(t)})),Object.keys(oe).forEach((function(e){oe[e].forEach((function(t){var r;(r=e,ne[r]||(ne[r]=new se(r)),ne[r]).apply(void 0,b(t))})),oe[e]=[]})),le.q=[]},le=function e(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];e.q.push(t),ue()};le.q=[],le.l=Date.now(),le._instanceMap=ne,le._instanceCmdMap=oe,ee.forEach((function(e){le[e]=le.bind(null,e)})),function(e){if("undefined"!=typeof window){var t=function(){if("undefined"!=typeof window)return window.TeaAnalyticsObject}();if(t&&window[t]){var r=window[t];r.init||(e.q=r.q||[],e.l=r.l||Date.now(),window[t]=e)}}}(le),ue();var he=1e3,de=1001,fe=1002,pe=1003,ge=1004,ye=1005,ve={1e3:"crc32",1001:"preUpload",1002:"initUploadID",1003:"process",1004:"fileMerge",1005:"complete",error:"error",progress:"progress"},me=0,_e=1,xe=2,ke=3,Me=4,we=5,be="video",Te="image",Ne="object",Ce={video:"video_upload",image:"image_upload",object:"object_upload"},De={IDLE:0,UPLOADING:1,CANCEL:2,PAUSE:3,SUCCESS:4,FAILED:5,WAITING:6},Ie="vod",Oe="imagex",Se={vod:"video",imagex:"image"},Ee="cn-north-1",Ae="https://vod.volcengineapi.com",ze="https://imagex.volcengineapi.com",je=5242880,Ue="{tosDomain}/{oid}?uploads",Re="{tosDomain}/{oid}?partNumber={number}&uploadID={uploadId}",Le="{tosDomain}/{oid}?uploadID={uploadId}",Pe="{tosDomain}/{oid}?uploadID={uploadId}",Fe="{tosDomain}/{oid}",Be=a(a(a(a(a(a(a({FILE_ERROR:1000001,STSTOKEN_FORMAT_ERROR:1000002,FILE_ERROR_UPLOADING:1003003},de,{NETWORK_ERROR:1001e3,GENERAL_ERROR:1001001,TIMEOUT_ERROR:1001002}),fe,{NETWORK_ERROR:1002e3,GENERAL_ERROR:1002001,TIMEOUT_ERROR:1002002}),"UPLOAD_NETWORK_ERROR",1003e3),"UPLOAD_GENERAL_ERROR",1003001),"UPLOAD_TIMEOUT_ERROR",1003002),ge,{NETWORK_ERROR:1004e3,GENERAL_ERROR:1004001,TIMEOUT_ERROR:1004002}),ye,{NETWORK_ERROR:1005e3,GENERAL_ERROR:1005001,TIMEOUT_ERROR:1005002}),qe="An error occurred reading the file.",He=function(){function e(t,r){s(this,e),this.options=t,this.context=r,this.teaLog=le,this.teaLog.init({app_id:2562,channel:"cn",log:!1,disable_sdk_monitor:!0}),this.teaLog.config({evtParams:{sdk_version:"1.3.0-bata.0",line_app_id:this.options.appId,page_url:window.location.href,toB:!0,imp:!1},user_unique_id:this.options.userId,disable_auto_pv:!0}),this.teaLog.start()}return o(e,[{key:"getBaseParams",value:function(e){var t=e.key,r=e.fileType,i=e.fileSize,s=e.serviceType,n=e.isDirect,o=e.isImageBatchUpload,a=e.extra,c=e.type,u=e.stage;return{type:c,log_type:Ce[r],stage:u,fk:t,fs:i,idu:n,ibu:o,idbp:e.isBreak,gwu:e.gatewayUpload,ss:e.sliceSize,sc:e.sliceCount,iie:e.imagexEnableEncrypt,ts:Math.round(Date.now()/1e3),msg:null==a?void 0:a.message,serviceType:s,omitInit:!!e.omitInit,pdur:e.pauseDuration}}},{key:"send",value:function(e){var r,i,s,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e){var o=e.stage,a=e.serviceType,c=e.extra,u=e.oid,l=e.tosDomain,h=e.uploadId,d=e.uploadHeader,f=e.req,p=e.res,g=this.getBaseParams(e);o>=de&&Object.assign(g,{oid:u,upload_host:l,uploadId:h,uh:d,req:f,res:p});var y="".concat(Se[a],"_").concat(o);if(o===pe&&!e.allFinish)return this.teaLog(y,Object.assign(g,n));var v=e.duration,m=e.totalDuration,_=e.stageStartTime,x=e.stageEndTime;Object.assign(g,{sst:_,set:x,dur:v,durs:Math.round(v/1e3),tdur:m,tdurs:Math.round(m/1e3)});var k=null==c?void 0:c.message,M=e.crc32Array,w=e.isDirect;switch(o){case he:k="crc32 stage.len:".concat(M.length,",direct:").concat(w,".");break;case de:k+=".stk:".concat(JSON.stringify(e.proxyStsToken));break;case fe:g.omitInit=!!e.omitInit;break;case pe:delete g.res,delete g.req,g.speed=e.speed,g.af=!0;break;case ge:g.speed=e.speed;break;case ye:k+=null!==(r=e.uploadResult)&&void 0!==r&&r.Vid?".vid:".concat(null===(i=e.uploadResult)||void 0===i?void 0:i.Vid):"",Object.assign(g,{speed:e.speed,skipCommit:!!e.skipCommit,vid:null===(s=e.uploadResult)||void 0===s?void 0:s.Vid,omitInit:!!e.omitInit})}g.ex=k,this.teaLog(y,t(t({},g),n))}}},{key:"sendErrorLog",value:function(e,r){var i=e.serviceType,s=e.extra,n=e.oid,o=e.tosDomain,a=e.uploadId,c=e.req,u=e.res,l=e.stageStartTime,h=e.stageEndTime,d=e.duration,f=e.totalDuration,p=this.getBaseParams(e);Object.assign(p,t({type:"error",req:c,res:u,oid:n,upload_host:o,uploadId:a,errc:null==s?void 0:s.errorCode,errmsg:null==s?void 0:s.message,err:null==s?void 0:s.error,ex:"errorCode:".concat(null==s?void 0:s.errorCode,",").concat(null==s?void 0:s.message),sst:l,set:h,dur:d,durs:Math.round(d/1e3),tdur:f,tdurs:Math.round(f/1e3)},r)),this.teaLog("".concat(Se[i],"_error"),p)}},{key:"sendLogBase",value:function(e,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.teaLog(e,t(t({},this.getBaseParams(r)),i))}}]),e}(),Ke=function(e){var t=Number(e.substring(0,4)),r=Number(e.substring(4,6)),i=Number(e.substring(6,8)),s=Number(e.substring(8,10)),n=Number(e.substring(10,12)),o=Number(e.substring(12,14));return Date.UTC(t,r-1,i,s-8,n,o)-Date.now()},Qe=function(){for(var e=0,t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];for(var s=0,n=r;s<n.length;s++){e+=n[s].byteLength}for(var o=new ArrayBuffer(e),a=new Uint8Array(o),c=0,u=0,l=r;u<l.length;u++){var h=l[u];a.set(new Uint8Array(h),c),c+=h.byteLength}return o},Ye=function(e){for(var t=e.length,r=new ArrayBuffer(t),i=new Uint8Array(r),s=0;s<t;s++)i[s]=e.charCodeAt(s);return r},We=function(e){for(var t="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=0;i<e;i++)t+=r.charAt(Math.floor(62*Math.random()));return t},Ge=function(e){if(!e)return"";if(Array.isArray(e))return e.map((function(e){try{return"".concat(e.split("/")[0],"/").concat(encodeURIComponent(e.split("/").slice(1).join("/")))}catch(t){return e}}));try{return"".concat(e.split("/")[0],"/").concat(encodeURIComponent(e.split("/").slice(1).join("/")))}catch(t){return e}},Je=function(e,t){var r;return t=t||{},Object.keys(t).forEach((function(i){r=new RegExp("{".concat(i,"}"),"g"),e=e.replace(r,t[i])})),e},Ve=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=[];return Object.keys(e).map((function(r){var i=e[r];"[object Array]"===Object.prototype.toString.call(i)?i.sort().forEach((function(e){t.push("".concat(r,"=").concat(encodeURIComponent(e)))})):t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))})),t.join("&")},Xe=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?{"x-storage-mode":"gateway"}:{};return Array.isArray(e)?(e.forEach((function(e){var r;e.Key&&e.Value&&(t[null===(r=e.Key)||void 0===r?void 0:r.toLowerCase()]=e.Value)})),t):"[object Object]"===Object.prototype.toString.call(e)?Object.assign(t,e):t},Ze=function(e){var t=e,r={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(!(!(arguments.length>1&&void 0!==arguments[1])||arguments[1]))return r;try{if(window.localStorage)return window.localStorage.setItem("",""),window.localStorage}catch(N){return r}return r},$e=function(){},et=function(e){return"".concat(e,"_").concat(parseInt(1e7*Math.random()),"_").concat(parseInt(1e7*Math.random()))},tt=function(e,t){var r=1048576;return t&&"function"==typeof t?t(e)<je?je:t(e)||e:e<=200*r?5*r:e<=500*r?8*r:10*r},rt=function(e){if(Array.isArray(e)&&(e=e[0]),!e||"[object String]"!==Object.prototype.toString.call(e))return null;var t=e.lastIndexOf(".");return t>0?".".concat(e.substring(t+1)):null};function it(e){return{req:{url:null==e?void 0:e.currentUrl,param:null==e?void 0:e.params},res:{status:null==e?void 0:e.status,body:null==e?void 0:e.responseText}}}function st(e,t,r){return r=r||e.size,new Promise((function(i,s){var n=new FileReader;n.readAsArrayBuffer(function(e,t,r){var i=e.slice||e.webkitSlice||e.mozSlice;return i.call(e,t,r)}(e,t,r)),n.onload=function(e){i(e.target.result)},n.onerror=function(e){var t,r,i,n,o="";null!==(t=e.target.error)&&void 0!==t&&t.name||null!==(r=e.target.error)&&void 0!==r&&r.message?o="".concat(null===(i=e.target.error)||void 0===i?void 0:i.name,":").concat(null===(n=e.target.error)||void 0===n?void 0:n.message,"."):o="read file error,invalid file or destoryed.";s(Error(o))}}))}var nt=function(e,t){var r=t.sliceIndex;return e[r].loaded=Math.max(e[r].loaded||0,t.loaded),e.reduce((function(e,t){return e+(t.loaded||0)}),0)};function ot(e){return e.length<8?ot(e="0".concat(e)):e}function at(e){if(void 0!==e)return ot(Number(e).toString(16))}function ct(e,t){var r=[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];"undefined"!=typeof Int32Array&&(r=new Int32Array(r));for(var i=-1^~~t,s=(e=new Uint8Array(e)).length,n=0;n<s;n++)i=r[255&(i^e[n])]^i>>>8;return at((-1^i)>>>0)}var ut={exports:{}};var lt,ht,dt={exports:{}},ft=new Proxy({},{get(e,t){throw new Error(`Module "" has been externalized for browser compatibility. Cannot access ".${t}" in client code. See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.`)}}),pt=m(Object.freeze({__proto__:null,default:ft}));function gt(){return lt||(lt=1,dt.exports=(e=e||function(e,t){var r;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!==y&&y.crypto&&(r=y.crypto),!r)try{r=pt}catch(g){}var i=function(){if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(g){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(g){}}throw new 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}}(),n={},o=n.lib={},a=o.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)}},c=o.WordArray=a.extend({init:function(e,r){e=this.words=e||[],this.sigBytes=r!=t?r:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,i=this.sigBytes,s=e.sigBytes;if(this.clamp(),i%4)for(var n=0;n<s;n++){var o=r[n>>>2]>>>24-n%4*8&255;t[i+n>>>2]|=o<<24-(i+n)%4*8}else for(var a=0;a<s;a+=4)t[i+a>>>2]=r[a>>>2];return this.sigBytes+=s,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=a.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 c.init(t,e)}}),u=n.enc={},l=u.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],s=0;s<r;s++){var n=t[s>>>2]>>>24-s%4*8&255;i.push((n>>>4).toString(16)),i.push((15&n).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i+=2)r[i>>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new c.init(r,t/2)}},h=u.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,i=[],s=0;s<r;s++){var n=t[s>>>2]>>>24-s%4*8&255;i.push(String.fromCharCode(n))}return i.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i++)r[i>>>2]|=(255&e.charCodeAt(i))<<24-i%4*8;return new c.init(r,t)}},d=u.Utf8={stringify:function(e){try{return decodeURIComponent(escape(h.stringify(e)))}catch(N){throw new Error("Malformed UTF-8 data")}},parse:function(e){return h.parse(unescape(encodeURIComponent(e)))}},f=o.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.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,i=this._data,s=i.words,n=i.sigBytes,o=this.blockSize,a=n/(4*o),u=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,l=e.min(4*u,n);if(u){for(var h=0;h<u;h+=o)this._doProcessBlock(s,h);r=s.splice(0,u),i.sigBytes-=l}return new c.init(r,l)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});o.Hasher=f.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.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 p.HMAC.init(e,r).finalize(t)}}});var p=n.algo={};return n}(Math),e)),dt.exports;var e}ut.exports=(ht=gt(),function(){if("function"==typeof ArrayBuffer){var e=ht.lib.WordArray,t=e.init,r=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,i=[],s=0;s<r;s++)i[s>>>2]|=e[s]<<24-s%4*8;t.call(this,i,r)}else t.apply(this,arguments)};r.prototype=e}}(),ht.lib.WordArray);var yt,vt=v(ut.exports),mt={exports:{}},_t={exports:{}};function xt(){return yt||(yt=1,function(e,t){e.exports=function(e){return function(){var t=e,r=t.lib.WordArray;function i(e,t,i){for(var s=[],n=0,o=0;o<t;o++)if(o%4){var a=i[e.charCodeAt(o-1)]<<o%4*2|i[e.charCodeAt(o)]>>>6-o%4*2;s[n>>>2]|=a<<24-n%4*8,n++}return r.create(s,n)}t.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,i=this._map;e.clamp();for(var s=[],n=0;n<r;n+=3)for(var o=(t[n>>>2]>>>24-n%4*8&255)<<16|(t[n+1>>>2]>>>24-(n+1)%4*8&255)<<8|t[n+2>>>2]>>>24-(n+2)%4*8&255,a=0;a<4&&n+.75*a<r;a++)s.push(i.charAt(o>>>6*(3-a)&63));var c=i.charAt(64);if(c)for(;s.length%4;)s.push(c);return s.join("")},parse:function(e){var t=e.length,r=this._map,s=this._reverseMap;if(!s){s=this._reverseMap=[];for(var n=0;n<r.length;n++)s[r.charCodeAt(n)]=n}var o=r.charAt(64);if(o){var a=e.indexOf(o);-1!==a&&(t=a)}return i(e,t,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),e.enc.Base64}(gt())}(_t)),_t.exports}var kt,Mt={exports:{}};function wt(){return kt||(kt=1,function(e,t){e.exports=function(e){return function(t){var r=e,i=r.lib,s=i.WordArray,n=i.Hasher,o=r.algo,a=[];!function(){for(var e=0;e<64;e++)a[e]=4294967296*t.abs(t.sin(e+1))|0}();var c=o.MD5=n.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var i=t+r,s=e[i];e[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var n=this._hash.words,o=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],g=e[t+4],y=e[t+5],v=e[t+6],m=e[t+7],_=e[t+8],x=e[t+9],k=e[t+10],M=e[t+11],w=e[t+12],b=e[t+13],T=e[t+14],N=e[t+15],C=n[0],D=n[1],I=n[2],O=n[3];C=u(C,D,I,O,o,7,a[0]),O=u(O,C,D,I,c,12,a[1]),I=u(I,O,C,D,f,17,a[2]),D=u(D,I,O,C,p,22,a[3]),C=u(C,D,I,O,g,7,a[4]),O=u(O,C,D,I,y,12,a[5]),I=u(I,O,C,D,v,17,a[6]),D=u(D,I,O,C,m,22,a[7]),C=u(C,D,I,O,_,7,a[8]),O=u(O,C,D,I,x,12,a[9]),I=u(I,O,C,D,k,17,a[10]),D=u(D,I,O,C,M,22,a[11]),C=u(C,D,I,O,w,7,a[12]),O=u(O,C,D,I,b,12,a[13]),I=u(I,O,C,D,T,17,a[14]),C=l(C,D=u(D,I,O,C,N,22,a[15]),I,O,c,5,a[16]),O=l(O,C,D,I,v,9,a[17]),I=l(I,O,C,D,M,14,a[18]),D=l(D,I,O,C,o,20,a[19]),C=l(C,D,I,O,y,5,a[20]),O=l(O,C,D,I,k,9,a[21]),I=l(I,O,C,D,N,14,a[22]),D=l(D,I,O,C,g,20,a[23]),C=l(C,D,I,O,x,5,a[24]),O=l(O,C,D,I,T,9,a[25]),I=l(I,O,C,D,p,14,a[26]),D=l(D,I,O,C,_,20,a[27]),C=l(C,D,I,O,b,5,a[28]),O=l(O,C,D,I,f,9,a[29]),I=l(I,O,C,D,m,14,a[30]),C=h(C,D=l(D,I,O,C,w,20,a[31]),I,O,y,4,a[32]),O=h(O,C,D,I,_,11,a[33]),I=h(I,O,C,D,M,16,a[34]),D=h(D,I,O,C,T,23,a[35]),C=h(C,D,I,O,c,4,a[36]),O=h(O,C,D,I,g,11,a[37]),I=h(I,O,C,D,m,16,a[38]),D=h(D,I,O,C,k,23,a[39]),C=h(C,D,I,O,b,4,a[40]),O=h(O,C,D,I,o,11,a[41]),I=h(I,O,C,D,p,16,a[42]),D=h(D,I,O,C,v,23,a[43]),C=h(C,D,I,O,x,4,a[44]),O=h(O,C,D,I,w,11,a[45]),I=h(I,O,C,D,N,16,a[46]),C=d(C,D=h(D,I,O,C,f,23,a[47]),I,O,o,6,a[48]),O=d(O,C,D,I,m,10,a[49]),I=d(I,O,C,D,T,15,a[50]),D=d(D,I,O,C,y,21,a[51]),C=d(C,D,I,O,w,6,a[52]),O=d(O,C,D,I,p,10,a[53]),I=d(I,O,C,D,k,15,a[54]),D=d(D,I,O,C,c,21,a[55]),C=d(C,D,I,O,_,6,a[56]),O=d(O,C,D,I,N,10,a[57]),I=d(I,O,C,D,v,15,a[58]),D=d(D,I,O,C,b,21,a[59]),C=d(C,D,I,O,g,6,a[60]),O=d(O,C,D,I,M,10,a[61]),I=d(I,O,C,D,f,15,a[62]),D=d(D,I,O,C,x,21,a[63]),n[0]=n[0]+C|0,n[1]=n[1]+D|0,n[2]=n[2]+I|0,n[3]=n[3]+O|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;r[s>>>5]|=128<<24-s%32;var n=t.floor(i/4294967296),o=i;r[15+(s+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),r[14+(s+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),e.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,i,s,n,o){var a=e+(t&r|~t&i)+s+o;return(a<<n|a>>>32-n)+t}function l(e,t,r,i,s,n,o){var a=e+(t&i|r&~i)+s+o;return(a<<n|a>>>32-n)+t}function h(e,t,r,i,s,n,o){var a=e+(t^r^i)+s+o;return(a<<n|a>>>32-n)+t}function d(e,t,r,i,s,n,o){var a=e+(r^(t|~i))+s+o;return(a<<n|a>>>32-n)+t}r.MD5=n._createHelper(c),r.HmacMD5=n._createHmacHelper(c)}(Math),e.MD5}(gt())}(Mt)),Mt.exports}var bt,Tt={exports:{}},Nt={exports:{}};function Ct(){return bt||(bt=1,function(e,t){e.exports=function(e){return r=(t=e).lib,i=r.WordArray,s=r.Hasher,n=t.algo,o=[],a=n.SHA1=s.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,i=r[0],s=r[1],n=r[2],a=r[3],c=r[4],u=0;u<80;u++){if(u<16)o[u]=0|e[t+u];else{var l=o[u-3]^o[u-8]^o[u-14]^o[u-16];o[u]=l<<1|l>>>31}var h=(i<<5|i>>>27)+c+o[u];h+=u<20?1518500249+(s&n|~s&a):u<40?1859775393+(s^n^a):u<60?(s&n|s&a|n&a)-1894007588:(s^n^a)-899497514,c=a,a=n,n=s<<30|s>>>2,s=i,i=h}r[0]=r[0]+i|0,r[1]=r[1]+s|0,r[2]=r[2]+n|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;return t[i>>>5]|=128<<24-i%32,t[14+(i+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(i+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),t.SHA1=s._createHelper(a),t.HmacSHA1=s._createHmacHelper(a),e.SHA1;var t,r,i,s,n,o,a}(gt())}(Nt)),Nt.exports}var Dt,It,Ot={exports:{}};function St(){return Dt||(Dt=1,function(e,t){e.exports=function(e){var t,r,i;r=(t=e).lib.Base,i=t.enc.Utf8,t.algo.HMAC=r.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var r=e.blockSize,s=4*r;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(var n=this._oKey=t.clone(),o=this._iKey=t.clone(),a=n.words,c=o.words,u=0;u<r;u++)a[u]^=1549556828,c[u]^=909522486;n.sigBytes=o.sigBytes=s,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))}})}(gt())}(Ot)),Ot.exports}function Et(){return It||(It=1,function(e,t){e.exports=function(e){return r=(t=e).lib,i=r.Base,s=r.WordArray,n=t.algo,o=n.MD5,a=n.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:o,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,i=this.cfg,n=i.hasher.create(),o=s.create(),a=o.words,c=i.keySize,u=i.iterations;a.length<c;){r&&n.update(r),r=n.update(e).finalize(t),n.reset();for(var l=1;l<u;l++)r=n.finalize(r),n.reset();o.concat(r)}return o.sigBytes=4*c,o}}),t.EvpKDF=function(e,t,r){return a.create(r).compute(e,t)},e.EvpKDF;var t,r,i,s,n,o,a}(gt(),Ct(),St())}(Tt)),Tt.exports}var At,zt={exports:{}};function jt(){return At||(At=1,function(e,t){e.exports=function(e){e.lib.Cipher||function(t){var r=e,i=r.lib,s=i.Base,n=i.WordArray,o=i.BufferedBlockAlgorithm,a=r.enc;a.Utf8;var c=a.Base64,u=r.algo.EvpKDF,l=i.Cipher=o.extend({cfg:s.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?_:v}return function(t){return{encrypt:function(r,i,s){return e(i).encrypt(t,r,i,s)},decrypt:function(r,i,s){return e(i).decrypt(t,r,i,s)}}}}()});i.StreamCipher=l.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var h=r.mode={},d=i.BlockCipherMode=s.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),f=h.CBC=function(){var e=d.extend();function r(e,r,i){var s,n=this._iv;n?(s=n,this._iv=t):s=this._prevBlock;for(var o=0;o<i;o++)e[r+o]^=s[o]}return e.Encryptor=e.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize;r.call(this,e,t,s),i.encryptBlock(e,t),this._prevBlock=e.slice(t,t+s)}}),e.Decryptor=e.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize,n=e.slice(t,t+s);i.decryptBlock(e,t),r.call(this,e,t,s),this._prevBlock=n}}),e}(),p=(r.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,i=r-e.sigBytes%r,s=i<<24|i<<16|i<<8|i,o=[],a=0;a<i;a+=4)o.push(s);var c=n.create(o,i);e.concat(c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};i.BlockCipher=l.extend({cfg:l.cfg.extend({mode:f,padding:p}),reset:function(){var e;l.reset.call(this);var t=this.cfg,r=t.iv,i=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=i.createEncryptor:(e=i.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(i,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4});var g=i.CipherParams=s.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),y=(r.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,r=e.salt;return(r?n.create([1398893684,1701076831]).concat(r).concat(t):t).toString(c)},parse:function(e){var t,r=c.parse(e),i=r.words;return 1398893684==i[0]&&1701076831==i[1]&&(t=n.create(i.slice(2,4)),i.splice(0,4),r.sigBytes-=16),g.create({ciphertext:r,salt:t})}},v=i.SerializableCipher=s.extend({cfg:s.extend({format:y}),encrypt:function(e,t,r,i){i=this.cfg.extend(i);var s=e.createEncryptor(r,i),n=s.finalize(t),o=s.cfg;return g.create({ciphertext:n,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:i.format})},decrypt:function(e,t,r,i){return i=this.cfg.extend(i),t=this._parse(t,i.format),e.createDecryptor(r,i).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),m=(r.kdf={}).OpenSSL={execute:function(e,t,r,i,s){if(i||(i=n.random(8)),s)o=u.create({keySize:t+r,hasher:s}).compute(e,i);else var o=u.create({keySize:t+r}).compute(e,i);var a=n.create(o.words.slice(t),4*r);return o.sigBytes=4*t,g.create({key:o,iv:a,salt:i})}},_=i.PasswordBasedCipher=v.extend({cfg:v.cfg.extend({kdf:m}),encrypt:function(e,t,r,i){var s=(i=this.cfg.extend(i)).kdf.execute(r,e.keySize,e.ivSize,i.salt,i.hasher);i.iv=s.iv;var n=v.encrypt.call(this,e,t,s.key,i);return n.mixIn(s),n},decrypt:function(e,t,r,i){i=this.cfg.extend(i),t=this._parse(t,i.format);var s=i.kdf.execute(r,e.keySize,e.ivSize,t.salt,i.hasher);return i.iv=s.iv,v.decrypt.call(this,e,t,s.key,i)}})}()}(gt(),Et())}(zt)),zt.exports}!function(e,t){e.exports=function(e){return function(){var t=e,r=t.lib.BlockCipher,i=t.algo,s=[],n=[],o=[],a=[],c=[],u=[],l=[],h=[],d=[],f=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,i=0;for(t=0;t<256;t++){var p=i^i<<1^i<<2^i<<3^i<<4;p=p>>>8^255&p^99,s[r]=p,n[p]=r;var g=e[r],y=e[g],v=e[y],m=257*e[p]^16843008*p;o[r]=m<<24|m>>>8,a[r]=m<<16|m>>>16,c[r]=m<<8|m>>>24,u[r]=m,m=16843009*v^65537*y^257*g^16843008*r,l[p]=m<<24|m>>>8,h[p]=m<<16|m>>>16,d[p]=m<<8|m>>>24,f[p]=m,r?(r=g^e[e[e[v^g]]],i^=e[e[i]]):r=i=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],g=i.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,i=4*((this._nRounds=r+6)+1),n=this._keySchedule=[],o=0;o<i;o++)o<r?n[o]=t[o]:(u=n[o-1],o%r?r>6&&o%r==4&&(u=s[u>>>24]<<24|s[u>>>16&255]<<16|s[u>>>8&255]<<8|s[255&u]):(u=s[(u=u<<8|u>>>24)>>>24]<<24|s[u>>>16&255]<<16|s[u>>>8&255]<<8|s[255&u],u^=p[o/r|0]<<24),n[o]=n[o-r]^u);for(var a=this._invKeySchedule=[],c=0;c<i;c++){if(o=i-c,c%4)var u=n[o];else u=n[o-4];a[c]=c<4||o<=4?u:l[s[u>>>24]]^h[s[u>>>16&255]]^d[s[u>>>8&255]]^f[s[255&u]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,a,c,u,s)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,l,h,d,f,n),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,i,s,n,o,a){for(var c=this._nRounds,u=e[t]^r[0],l=e[t+1]^r[1],h=e[t+2]^r[2],d=e[t+3]^r[3],f=4,p=1;p<c;p++){var g=i[u>>>24]^s[l>>>16&255]^n[h>>>8&255]^o[255&d]^r[f++],y=i[l>>>24]^s[h>>>16&255]^n[d>>>8&255]^o[255&u]^r[f++],v=i[h>>>24]^s[d>>>16&255]^n[u>>>8&255]^o[255&l]^r[f++],m=i[d>>>24]^s[u>>>16&255]^n[l>>>8&255]^o[255&h]^r[f++];u=g,l=y,h=v,d=m}g=(a[u>>>24]<<24|a[l>>>16&255]<<16|a[h>>>8&255]<<8|a[255&d])^r[f++],y=(a[l>>>24]<<24|a[h>>>16&255]<<16|a[d>>>8&255]<<8|a[255&u])^r[f++],v=(a[h>>>24]<<24|a[d>>>16&255]<<16|a[u>>>8&255]<<8|a[255&l])^r[f++],m=(a[d>>>24]<<24|a[u>>>16&255]<<16|a[l>>>8&255]<<8|a[255&h])^r[f++],e[t]=g,e[t+1]=y,e[t+2]=v,e[t+3]=m},keySize:8});t.AES=r._createHelper(g)}(),e.AES}(gt(),xt(),wt(),Et(),jt())}(mt);var Ut=v(mt.exports),Rt={exports:{}};!function(e,t){e.exports=function(e){return e.enc.Utf8}(gt())}(Rt);var Lt=v(Rt.exports),Pt={exports:{}};!function(e,t){e.exports=function(e){return e.mode.CFB=function(){var t=e.lib.BlockCipherMode.extend();function r(e,t,r,i){var s,n=this._iv;n?(s=n.slice(0),this._iv=void 0):s=this._prevBlock,i.encryptBlock(s,0);for(var o=0;o<r;o++)e[t+o]^=s[o]}return t.Encryptor=t.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize;r.call(this,e,t,s,i),this._prevBlock=e.slice(t,t+s)}}),t.Decryptor=t.extend({processBlock:function(e,t){var i=this._cipher,s=i.blockSize,n=e.slice(t,t+s);r.call(this,e,t,s,i),this._prevBlock=n}}),t}(),e.mode.CFB}(gt(),jt())}(Pt);var Ft=v(Pt.exports),Bt={exports:{}};!function(e,t){e.exports=function(e){return e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding}(gt(),jt())}(Bt);var qt=v(Bt.exports);function Ht(e){var t=e.key,r=e.iv,i=e.data,s=function(e){for(var t=e.words,r=e.sigBytes,i=new Uint8Array(r),s=0;s<r;s+=1)i[s]=t[s>>>2]>>>24-s%4*8&255;return i}(Ut.encrypt(vt.create(i),Lt.parse(t),{mode:Ft,padding:qt,iv:Lt.parse(r)}).ciphertext);return s.buffer}var Kt,Qt=function(){function e(t,r){s(this,e),this.uploaderCtx=t.context,this.currFileCtx=this.uploaderCtx.tasks[t.key],this.config=r,this.isDirect=this.currFileCtx.isDirect,this.isImageBatchUpload=this.currFileCtx.isImageBatchUpload,this.serviceName=this.currFileCtx.serviceType||Ie,this.file=t.file,this.sliceLength=this.currFileCtx.sliceSize}return o(e,[{key:"start",value:function(e,t){this.successProcess=e,this.failProcess=t,this.currFileCtx.imagexEnableEncrypt&&this.isDirect?this.handleImagexEncryptDirect(this.file):this.currFileCtx.imagexEnableEncrypt&&!this.isDirect?this.handleImagexEncryptSlice(this.file,this.sliceLength):!this.currFileCtx.imagexEnableEncrypt&&this.isDirect?this.handleDirect(this.file):this.handleSlice(this.file,this.sliceLength)}},{key:"handleDirect",value:function(e){var t=this,r=this.isImageBatchUpload?e:[e];Promise.all(r.map((function(e){return st(e,0)}))).then((function(e){var r=e.map((function(e){return{start:0,end:e.byteLength,crc32:ct(e,0),buffer:e}}));t.success(r)}),(function(e){t.fail({errorCode:Be.FILE_ERROR,message:null==e?void 0:e.message,error:null==e?void 0:e.message})}))}},{key:"handleSlice",value:function(e,t){for(var r=this,i=[],s=e.size,n=0,o=0;o<s;)o=Math.min(n+t,s),s-o<=5242880&&(o=s),i.push({start:n,end:o,crc32:0}),n=o;if(this.currFileCtx.enableDiskBreakPoint&&i.length>2){var a=i.length;Promise.all([st(e,i[0].start,i[0].end),st(e,i[a-1].start,i[a-1].end)]).then((function(e){i[0].crc32=ct(e[0],0),i[a-1].crc32=ct(e[1],0),r.currFileCtx.crc32Key=r.getCrc32Key(i,s)})).catch((function(e){console.warn("[TTUploader]:",null==e?void 0:e.message),r.currFileCtx.enableDiskBreakPoint=!1})).finally((function(){r.success(i)}))}else this.success(i)}},{key:"handleImagexEncryptDirect",value:function(e){var t=this,r=this.currFileCtx.imagexEncryptKey,i=this.isImageBatchUpload?e:[e];Promise.all(i.map((function(e){return st(e,0)}))).then((function(e){var i=We(16),s=e.map((function(e){var t=Ht({key:r,iv:i,data:e}),s=Qe(Ye("aes256cfb-direct"),Ye(i),t);return{start:0,end:s.byteLength,crc32:ct(s,0),buffer:s}}));t.success(s)}),(function(e){t.fail({errorCode:Be.FILE_ERROR,message:null==e?void 0:e.message,error:null==e?void 0:e.message})}))}},{key:"handleImagexEncryptSlice",value:function(e,t){for(var r=new ArrayBuffer(36),i=new DataView(r),s=Ye("aes-256-cfb-part"),n=new Uint8Array(s),o=0;o<16;o++)i.setUint8(o,n[o]);i.setUint16(16,0,!0),i.setUint16(18,0,!0),i.setUint32(20,t,!0),i.setUint32(24,0,!0),i.setUint32(28,0,!0),i.setUint32(32,0,!0);for(var a=We(16),c=Qe(r,Ye(a)),u=[{crc32:ct(c,0),buffer:c,encryptMeta:!0,start:-52,end:0,iv:a}],l=e.size,h=0,d=0;d<l;)d=Math.min(h+t,l),u.push({start:h,end:d,crc32:0}),h=d;this.success(u)}},{key:"getCrc32Key",value:function(e,t){var r=[t];return r.push(e[0].crc32,e[e.length-1].crc32),r.join("_")}},{key:"success",value:function(e){var t=Object.assign(this.currFileCtx,{crc32Array:e,extra:{message:"crc32 stage success."}});this.successProcess(t)}},{key:"fail",value:function(e){var t=Object.assign(this.currFileCtx,{extra:{message:(null==e?void 0:e.message)||"crc32 stage error.",errorCode:e.errorCode||Be.FILE_ERROR,error:e.error||"%s"}});this.failProcess(t)}}]),e}(),Yt=globalThis,Wt=function(e){c(r,e);var t=d(r);function r(){var e;return s(this,r),(e=t.call(this)).xhr=new XMLHttpRequest,e._data=null,e}return o(r,[{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=$e,r.onreadystatechange=$e,r.params=e,r.currentUrl=t._data.url,r.status>=200&&r.status<300?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("timeout",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.binary?(this.xhr.setRequestHeader("Content-Type","application/octet-stream"),this._ajax(e.file)):e.custom?this._ajax(e.custom):this._ajax(null)}},{key:"abort",value:function(){this.xhr.onreadystatechange=$e,this.xhr.abort()}}]),r}(x),Gt=function(e,t){var r=new Wt;return new Promise((function(i,s){r.on("complete",(function(e){var r,n={};try{n=JSON.parse(e.response)}catch(c){var o={errorCode:Be[t].GENERAL_ERROR,message:"Parse response error:".concat(t),error:"".concat((null==c?void 0:c.message)||""),xhr:e};s(o)}if(null!==(r=n.ResponseMetadata)&&void 0!==r&&r.Error){var a={xhr:e,errorCode:n.ResponseMetadata.Error.CodeN,error:n.ResponseMetadata.Error.Code,message:n.ResponseMetadata.Error.Message,requestId:n.ResponseMetadata.RequestId};s(a)}else i({result:n.Result,xhr:e})})),r.on("error",(function(e){var r={errorCode:Be[t].NETWORK_ERROR,message:"Request failed: NETERROR.",error:"HttpStatus:".concat(e.status,".Request fail at ").concat(e.currentUrl),xhr:e};if(0!==e.status)try{var i,n=JSON.parse(e.response);null!==(i=n.ResponseMetadata)&&void 0!==i&&i.Error&&(r.errorCode=n.ResponseMetadata.Error.CodeN,r.error=n.ResponseMetadata.Error.Code,r.message=n.ResponseMetadata.Error.Message,r.requestId=n.ResponseMetadata.RequestId)}catch(o){r.errorCode=Be[t].GENERAL_ERROR,r.message="Parse response error.",r.error="".concat((null==o?void 0:o.message)||"")}s(r)})),r.on("timeout",(function(e){var r={errorCode:Be[t].TIMEOUT_ERROR,message:"Request timeout.",error:"HttpStatus:".concat(e.status,".Request fail at ").concat(e.currentUrl),xhr:e};s(r)})),r.send(e)}))},Jt=function(e,t){var r=new Wt;return new Promise((function(i,s){r.on("complete",(function(e){var r={};try{r=JSON.parse(e.response)}catch(N){var n={errorCode:Be[t].GENERAL_ERROR,message:"Parse server response error:".concat(t),error:"".concat((null==N?void 0:N.message)||""),xhr:e};s(n)}if(0===r.success){var o,a=null;if(t===fe)a=null===(o=r.payload)||void 0===o?void 0:o.uploadID;else if(t===de){var c;a=null===(c=r.payload)||void 0===c?void 0:c.partList}i({result:a,xhr:e})}else{var u,l,h,d={errorCode:(null===(u=r.error)||void 0===u?void 0:u.error_code)||Be[t].GENERAL_ERROR,message:null===(l=r.error)||void 0===l?void 0:l.message,error:null===(h=r)||void 0===h||null===(h=h.error)||void 0===h?void 0:h.error,xhr:e};Yt.fail(d)}})),r.on("error",(function(e){var r={errorCode:Be[t].NETWORK_ERROR,message:"Upload failed: NETERROR.",error:"HttpStatus:".concat(e.status,".Failed at ").concat(e.currentUrl),xhr:e};if(0!==e.status)try{var i,n,o,a=JSON.parse(e.response);r.errorCode=null===(i=a.error)||void 0===i?void 0:i.error_code,r.message=null===(n=a.error)||void 0===n?void 0:n.message,r.error=null==a||null===(o=a.error)||void 0===o?void 0:o.error}catch(N){r.errorCode=Be[t].GENERAL_ERROR,r.message="Parse server response error:".concat(t),r.error="".concat((null==N?void 0:N.message)||"")}s(r)})),r.on("timeout",(function(e){var r={errorCode:Be[t].TIMEOUT_ERROR,message:"Request timeout:".concat(t),error:"HttpStatus:".concat(e.status,".Failed at ").concat(e.currentUrl),xhr:e};s(r)})),r.send(e)}))},Vt={exports:{}},Xt={exports:{}};function Zt(){return Kt||(Kt=1,function(e,t){e.exports=function(e){return function(t){var r=e,i=r.lib,s=i.WordArray,n=i.Hasher,o=r.algo,a=[],c=[];!function(){function e(e){for(var r=t.sqrt(e),i=2;i<=r;i++)if(!(e%i))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var i=2,s=0;s<64;)e(i)&&(s<8&&(a[s]=r(t.pow(i,.5))),c[s]=r(t.pow(i,1/3)),s++),i++}();var u=[],l=o.SHA256=n.extend({_doReset:function(){this._hash=new s.init(a.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,i=r[0],s=r[1],n=r[2],o=r[3],a=r[4],l=r[5],h=r[6],d=r[7],f=0;f<64;f++){if(f<16)u[f]=0|e[t+f];else{var p=u[f-15],g=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=u[f-2],v=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;u[f]=g+u[f-7]+v+u[f-16]}var m=i&s^i&n^s&n,_=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),x=d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&h)+c[f]+u[f];d=h,h=l,l=a,a=o+x|0,o=n,n=s,s=i,i=x+(_+m)|0}r[0]=r[0]+i|0,r[1]=r[1]+s|0,r[2]=r[2]+n|0,r[3]=r[3]+o|0,r[4]=r[4]+a|0,r[5]=r[5]+l|0,r[6]=r[6]+h|0,r[7]=r[7]+d|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;return r[s>>>5]|=128<<24-s%32,r[14+(s+64>>>9<<4)]=t.floor(i/4294967296),r[15+(s+64>>>9<<4)]=i,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});r.SHA256=n._createHelper(l),r.HmacSHA256=n._createHmacHelper(l)}(Math),e.SHA256}(gt())}(Xt)),Xt.exports}!function(e,t){e.exports=function(e){return e.HmacSHA256}(gt(),Zt(),St())}(Vt);var $t=v(Vt.exports),er=v(Zt()),tr=["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id"],rr=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(N){return""}},ir=function(e){return Object.keys(e).sort().map((function(t){var r=e[t];if(null!=r){var i=rr(t);if(i)return Array.isArray(r)?"".concat(i,"=").concat(r.map(rr).sort().join("&".concat(i,"="))):"".concat(i,"=").concat(rr(r))}})).filter((function(e){return e})).join("&")},sr=function(){function e(t,r,i){s(this,e),this.request=t,this.request.headers=t.headers||{},this.serviceName=r,i=i||{},this.signatureCache="boolean"!=typeof i.signatureCache||i.signatureCache,this.operation=i.operation,this.signatureVersion=i.signatureVersion,this.constant=i.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=i.bodySha256}return o(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&&(r=r instanceof URLSearchParams?r.toString():JSON.stringify(r)),this.request.headers[this.constant.contentSha256Header]=this.bodySha256||er(r).toString()}}},{key:"authorization",value:function(e,t){var r=[],i=this.credentialString(t);return r.push("".concat(this.constant.algorithm," Credential=").concat(e.accessKeyId,"/").concat(i)),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 $t(this.stringToSign(t),r)}},{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(ir(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 i=t[0].toLowerCase();if(e.isSignableHeader(i)){var s=t[1];if(null==s||"function"!=typeof s.toString)throw new Error("Header ".concat(i," contains invalid value"));r.push("".concat(i,":").concat(e.canonicalHeaderValues(s.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 er(e)}},{key:"hexEncodedBodyHash",value:function(){return this.request.headers[this.constant.contentSha256Header]?this.request.headers[this.constant.contentSha256Header]:this.request.body?this.hexEncodedHash(ir(this.request.body)):this.hexEncodedHash("")}},{key:"isSignableHeader",value:function(e){return 0===e.toLowerCase().indexOf("x-amz-")||tr.indexOf(e)<0}},{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,i){var s=$t(t,"".concat(this.constant.kDatePrefix).concat(e.secretAccessKey)),n=$t(r,s),o=$t(i,n);return $t(this.constant.v4Identifier,o)}},{key:"createScope",value:function(e,t,r){return[e.substr(0,8),t,r,this.constant.v4Identifier].join("/")}}]),e}(),nr=function(){function e(t,r){s(this,e),this.options=t,this.config=r,this.uploaderCtx=t.context,this.currFileCtx=this.uploaderCtx.tasks[t.key],this.isImageBatchUpload=!!this.currFileCtx.isImageBatchUpload,this.serviceName=this.currFileCtx.serviceType,this.retryTime=r.retryTaskTime,this.retryCount=0}return o(e,[{key:"start",value:function(e,t){this.failProcess=t,this.successProcess=e;var r=this.uploaderCtx._getCache(this.currFileCtx.crc32Key),i={};try{i=r?JSON.parse(r):{}}catch(s){console.warn("[TTUploader]:","Parse cacheInfo from storage failed.")}i.oid&&i.uploadId&&i.tosDomain?this.resumeFromCache(i):this.startPreUpload()}},{key:"startPreUpload",value:function(){var e=this.createReqParamsByService(this.serviceName),t=e.host,r=e.params;if(this.config.useFileExtension){var i=rt(this.currFileCtx.fileName);i&&(r.FileExtension=i)}this.options.fileExtension&&(r.FileExtension=this.options.fileExtension),this.config.accountId&&(r["X-Account-Id"]=this.config.accountId),r.s=Math.random().toString(36).substr(2),this.uploaderCtx.priorInfo.topExpires>0&&(r["X-Expires"]=this.uploaderCtx.priorInfo.topExpires);var s=Ve(r),n={method:"GET",url:"".concat(t,"?").concat(s),timeout:this.config.requestTimeout,region:this.config.region||Ee,params:r},o=new sr(n,this.serviceName,{isVolcengine:!0}),a=this.currFileCtx.proxyStsToken||this.config.stsToken,c=a.AccessKeyID,u=a.AccessKeyId,l=a.SecretAccessKey,h=a.SessionToken,d=a.CurrentTime,f=null;f=this.config.useServerCurrentTime?new Date(d):new Date(Date.now()+this.uploaderCtx.priorInfo.systemTimeGap),o.addAuthorization({accessKeyId:u||c,secretAccessKey:l,sessionToken:h},f),this.request(n)}},{key:"createReqParamsByService",value:function(e){var t={};if(e===Ie){var r,i;t.host=this.config.videoHost||Ae;var s,n=null===(r=this.config.videoConfig)||void 0===r?void 0:r.spaceName;if(this.currFileCtx.fileType===Ne&&null!==(i=this.config.objectConfig)&&void 0!==i&&i.spaceName)n=null===(s=this.config.objectConfig)||void 0===s?void 0:s.spaceName;t.params={Action:"ApplyUploadInfo",Version:"2022-01-01",SpaceName:n,FileSize:this.currFileCtx.fileSize,FileType:this.currFileCtx.fileType},this.options.fileName&&(t.params.FileName=this.options.fileName),this.options.fileExtension&&(t.params.FileExtension=this.options.fileExtension),this.options.storageClass&&(t.params.StorageClass=this.options.storageClass)}else{var o;if(t.host=this.config.imageHost||ze,t.params={Action:"ApplyImageUpload",Version:"2018-08-01",ServiceId:this.options.serviceId||(null===(o=this.config.imageConfig)||void 0===o?void 0:o.serviceId)},Array.isArray(this.currFileCtx.fileName)&&(t.params.UploadNum=this.currFileCtx.fileName.length),this.options.storeKey){var a=this.options.storeKey;t.params.StoreKeys=Array.isArray(a)?a:[a]}this.options.prefix&&(t.params.Prefix=this.options.prefix),this.options.overwrite&&(t.params.Overwrite=!0)}return t}},{key:"request",value:function(e){var t=this;Gt(e,de).then((function(e){var r=e.result,i=e.xhr;t.success(r,i)}),(function(e,r){t.fail(e,r)}))}},{key:"resumeFromCache",value:function(e){var r=this,i={method:"GET",url:Je(Pe,{tosDomain:e.tosDomain,oid:e.oid,uploadId:e.uploadId}),headers:t({authorization:e.signature},e.uploadHeader),timeout:this.config.requestTimeout};Jt(i,de).then((function(t){var i=t.result,s=t.xhr;if(i&&i.length>0){var n=r.confirmCache(i),o=!!e.merged?we:n.isAllFinished?Me:ke,a=Object.assign(r.currFileCtx,e,{extra:{message:"resume upload from disk cache."},percent:0,cacheTaskIdx:o,isBreak:1,xhr:s});r.successProcess(a)}else r.startPreUpload()}),(function(e){var t=it(e.xhr),i=t.res,s=t.req;r.uploaderCtx.logger.sendLogBase("".concat(Se[r.currFileCtx.serviceType],"_999"),r.currFileCtx,{type:"warning",ex:"Resume from disk cache failed.",res:i,req:s,errc:null==e?void 0:e.errorCode,errmsg:null==e?void 0:e.message,err:null==e?void 0:e.error}),r.startPreUpload()}))}},{key:"confirmCache",value:function(e){var t=this.currFileCtx.crc32Array,r={};e.forEach((function(e){var t=parseInt(e.partNumber)-1;Number.isNaN(t)||void 0!==r[t]||(r[t]={tag:!0,crc32:e.crc32})}));var i=!0,s=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):i=!1,e}));return{isAllFinished:i,crc32Array:s}}},{key:"success",value:function(e,t){var r=this.serviceName===Oe?e.UploadAddress:e.Data.UploadAddress,i=r.StoreInfos,s=r.UploadHosts,n=r.SessionKey,o=r.UploadHeader,a=[],c=[];this.isImageBatchUpload&&i.length>1?i.forEach((function(e){a.push(e.Auth),c.push(e.StoreUri)})):(a=i[0].Auth,c=i[0].StoreUri);var u=Object.assign(this.currFileCtx,{signature:a,extra:{message:"prepare upload success"},oid:Ge(c),tosDomain:"".concat(this.config.schema,"://").concat(s[0]),xhr:t,uploadHeader:Xe(o,this.currFileCtx.gatewayUpload),sessionKey:n});this.successProcess(u)}},{key:"fail",value:function(e){if(100006===e.errorCode){if(0===this.uploaderCtx.priorInfo.topExpires){return this.uploaderCtx.priorInfo.topExpires=604800,this.startPreUpload()}if(0===this.uploaderCtx.priorInfo.systemTimeGap){var t=Ke(e.requestId);return this.uploaderCtx.priorInfo.systemTimeGap=t,this.startPreUpload()}}if(this.retryCount<this.retryTime)return this.retryCount+=1,this.startPreUpload();var r=Object.assign(this.currFileCtx,{extra:{message:e.message,errorCode:e.errorCode,error:e.error},xhr:e.xhr});this.failProcess(r)}}]),e}(),or=function(){function e(t,r){s(this,e),this.options=t,this.config=r,this.uploaderCtx=t.context,this.currFileCtx=this.uploaderCtx.tasks[t.key],this.retryTime=r.retryTaskTime,this.req=null}return o(e,[{key:"start",value:function(e,t){this.successProcess=e,this.failProcess=t,this.retryCount=0,this.initUpload()}},{key:"initUpload",value:function(){var e={oid:this.currFileCtx.oid,tosDomain:this.currFileCtx.tosDomain},r={method:"POST",url:Je(Ue,e),headers:t({authorization:this.currFileCtx.signature},this.currFileCtx.uploadHeader),timeout:this.config.requestTimeout};this.req=r,this.request(r)}},{key:"request",value:function(e){var t=this;Jt(e,fe).then((function(e){var r=e.result,i=e.xhr;t.success(r,i)}),(function(e){t.fail(e)}))}},{key:"success",value:function(e,t){var r=Object.assign(this.currFileCtx,{uploadId:e,extra:{message:"init upload id success."},xhr:t});this.successProcess(r)}},{key:"fail",value:function(e){if(this.retryCount<this.retryTime&&this.req)return this.retryCount+=1,this.request(this.req);var t=Object.assign(this.currFileCtx,{extra:{errorCode:e.errorCode,message:e.message,error:e.error},xhr:e.xhr});this.failProcess(t)}}]),e}(),ar=function(e){c(i,e);var r=d(i);function i(e){var t,n=e.sliceBuffer,o=e.crc32,a=e.url,c=e.signature,u=e.uploadHeader,l=e.retryTime,h=e.sliceIndex,d=e.uploadTimeout;return s(this,i),(t=r.call(this)).sliceBuffer=n,t.crc32=o,t.uploadUrl=a,t.uploadHeader=u,t.signature=c,t.sliceIndex=h,t.retryCount=0,t.retryTime=l,t.uploadTimeout=d,t.cancel=!1,t._st=Date.now(),t}return o(i,[{key:"upload",value:function(){var e=this;this.transport=null,this.transport=new Wt,this.transport.on("complete",(function(t){e.success(t)})),this.transport.on("error",(function(t){e.fail(t)})),this.transport.on("timeout",(function(t){e.fail(t,!0)})),this.transport.on("progress",(function(t){e.process(t)}));var r={method:this.method,url:this.uploadUrl,headers:t({authorization:this.signature,"content-crc32":this.crc32},this.uploadHeader),file:this.sliceBuffer,binary:1,timeout:this.uploadTimeout};this.transport.send(r)}},{key:"success",value:function(e){var t=this.sliceBuffer.size||this.sliceBuffer.byteLength;this.emit("complete",{crc32:this.crc32,size:t,xhr:e,duration:Date.now()-this._st,sliceIndex:this.sliceIndex})}},{key:"fail",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.cancel){var i={errorCode:Be.UPLOAD_NETWORK_ERROR,message:"Upload failed: NETERROR.",error:"HttpStatus:".concat(e.status,".Request fail at ").concat(this.uploadUrl)};if(r)i.errorCode=Be.UPLOAD_TIMEOUT_ERROR,i.message="Upload failed: Timeout.",i.error="HttpStatus:".concat(e.status,".Request fail at ").concat(this.uploadUrl);else if(0!==e.status)try{var s,n,o,a=JSON.parse(e.response);i.errorCode=null==a||null===(s=a.error)||void 0===s?void 0:s.error_code,i.message=null==a||null===(n=a.error)||void 0===n?void 0:n.message,i.error=null==a||null===(o=a.error)||void 0===o?void 0:o.error}catch(u){i.errorCode=Be.UPLOAD_GENERAL_ERROR,i.message="Parse response error.",i.error="".concat((null==u?void 0:u.message)||"")}var c=t({crc32:this.crc32,size:this.sliceBuffer.size||this.sliceBuffer.byteLength,xhr:e,duration:Date.now()-this._st,sliceIndex:this.sliceIndex,retryCount:this.retryCount},i);if(this.retryCount<this.retryTime)return this.retryCount+=1,this.emit("retry",c),void this.upload();this.emit("error",c)}}},{key:"process",value:function(e){this.cancel||this.emit("progress",{crc32:this.crc32,loaded:e.loaded||0,total:e.total||0,sliceIndex:this.sliceIndex})}},{key:"abort",value:function(){var e;this.transport&&(this.cancel=!0,null===(e=this.transport)||void 0===e||e.abort())}},{key:"destroy",value:function(){this.transport=null}}]),i}(x),cr="IWZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIG4odCl7cmV0dXJuIHQubGVuZ3RoPDg/bih0PSIwIi5jb25jYXQodCkpOnR9ZnVuY3Rpb24gdCh0KXtpZih2b2lkIDAhPT10KXJldHVybiBuKE51bWJlcih0KS50b1N0cmluZygxNikpfXNlbGYub25tZXNzYWdlPWZ1bmN0aW9uKG4pe3ZhciByPW4uZGF0YSxlPXJbMF0sbz1yWzFdLGE9ZnVuY3Rpb24obixyKXt2YXIgZT1bMCwxOTk2OTU5ODk0LDM5OTM5MTk3ODgsMjU2NzUyNDc5NCwxMjQ2MzQxMzcsMTg4NjA1NzYxNSwzOTE1NjIxNjg1LDI2NTczOTIwMzUsMjQ5MjY4Mjc0LDIwNDQ1MDgzMjQsMzc3MjExNTIzMCwyNTQ3MTc3ODY0LDE2Mjk0MTk5NSwyMTI1NTYxMDIxLDM4ODc2MDcwNDcsMjQyODQ0NDA0OSw0OTg1MzY1NDgsMTc4OTkyNzY2Niw0MDg5MDE2NjQ4LDIyMjcwNjEyMTQsNDUwNTQ4ODYxLDE4NDMyNTg2MDMsNDEwNzU4MDc1MywyMjExNjc3NjM5LDMyNTg4Mzk5MCwxNjg0Nzc3MTUyLDQyNTExMjIwNDIsMjMyMTkyNjYzNiwzMzU2MzM0ODcsMTY2MTM2NTQ2NSw0MTk1MzAyNzU1LDIzNjYxMTUzMTcsOTk3MDczMDk2LDEyODE5NTM4ODYsMzU3OTg1NTMzMiwyNzI0Njg4MjQyLDEwMDY4ODgxNDUsMTI1ODYwNzY4NywzNTI0MTAxNjI5LDI3Njg5NDI0NDMsOTAxMDk3NzIyLDExMTkwMDA2ODQsMzY4NjUxNzIwNiwyODk4MDY1NzI4LDg1MzA0NDQ1MSwxMTcyMjY2MTAxLDM3MDUwMTU3NTksMjg4MjYxNjY2NSw2NTE3Njc5ODAsMTM3MzUwMzU0NiwzMzY5NTU0MzA0LDMyMTgxMDQ1OTgsNTY1NTA3MjUzLDE0NTQ2MjE3MzEsMzQ4NTExMTcwNSwzMDk5NDM2MzAzLDY3MTI2Njk3NCwxNTk0MTk4MDI0LDMzMjI3MzA5MzAsMjk3MDM0NzgxMiw3OTU4MzU1MjcsMTQ4MzIzMDIyNSwzMjQ0MzY3Mjc1LDMwNjAxNDk1NjUsMTk5NDE0NjE5MiwzMTE1ODUzNCwyNTYzOTA3NzcyLDQwMjM3MTc5MzAsMTkwNzQ1OTQ2NSwxMTI2MzcyMTUsMjY4MDE1MzI1MywzOTA0NDI3MDU5LDIwMTM3NzYyOTAsMjUxNzIyMDM2LDI1MTcyMTUzNzQsMzc3NTgzMDA0MCwyMTM3NjU2NzYzLDE0MTM3NjgxMywyNDM5Mjc3NzE5LDM4NjUyNzEyOTcsMTgwMjE5NTQ0NCw0NzY4NjQ4NjYsMjIzODAwMTM2OCw0MDY2NTA4ODc4LDE4MTIzNzA5MjUsNDUzMDkyNzMxLDIxODE2MjUwMjUsNDExMTQ1MTIyMywxNzA2MDg4OTAyLDMxNDA0MjcwNCwyMzQ0NTMyMjAyLDQyNDAwMTc1MzIsMTY1ODY1ODI3MSwzNjY2MTk5NzcsMjM2MjY3MDMyMyw0MjI0OTk0NDA1LDEzMDM1MzU5NjAsOTg0OTYxNDg2LDI3NDcwMDcwOTIsMzU2OTAzNzUzOCwxMjU2MTcwODE3LDEwMzc2MDQzMTEsMjc2NTIxMDczMywzNTU0MDc5OTk1LDExMzEwMTQ1MDYsODc5Njc5OTk2LDI5MDkyNDM0NjIsMzY2Mzc3MTg1NiwxMTQxMTI0NDY3LDg1NTg0MjI3NywyODUyODAxNjMxLDM3MDg2NDg2NDksMTM0MjUzMzk0OCw2NTQ0NTkzMDYsMzE4ODM5NjA0OCwzMzczMDE1MTc0LDE0NjY0Nzk5MDksNTQ0MTc5NjM1LDMxMTA1MjM5MTMsMzQ2MjUyMjAxNSwxNTkxNjcxMDU0LDcwMjEzODc3NiwyOTY2NDYwNDUwLDMzNTI3OTk0MTIsMTUwNDkxODgwNyw3ODM1NTE4NzMsMzA4MjY0MDQ0MywzMjMzNDQyOTg5LDM5ODgyOTIzODQsMjU5NjI1NDY0Niw2MjMxNzA2OCwxOTU3ODEwODQyLDM5Mzk4NDU5NDUsMjY0NzgxNjExMSw4MTQ3MDk5NywxOTQzODAzNTIzLDM4MTQ5MTg5MzAsMjQ4OTU5NjgwNCwyMjUyNzQ0MzAsMjA1Mzc5MDM3NiwzODI2MTc1NzU1LDI0NjY5MDYwMTMsMTY3ODE2NzQzLDIwOTc2NTEzNzcsNDAyNzU1MjU4MCwyMjY1NDkwMzg2LDUwMzQ0NDA3MiwxNzYyMDUwODE0LDQxNTA0MTcyNDUsMjE1NDEyOTM1NSw0MjY1MjIyMjUsMTg1MjUwNzg3OSw0Mjc1MzEzNTI2LDIzMTIzMTc5MjAsMjgyNzUzNjI2LDE3NDI1NTU4NTIsNDE4OTcwODE0MywyMzk0ODc3OTQ1LDM5NzkxNzc2MywxNjIyMTgzNjM3LDM2MDQzOTA4ODgsMjcxNDg2NjU1OCw5NTM3Mjk3MzIsMTM0MDA3NjYyNiwzNTE4NzE5OTg1LDI3OTczNjA5OTksMTA2ODgyODM4MSwxMjE5NjM4ODU5LDM2MjQ3NDE4NTAsMjkzNjY3NTE0OCw5MDYxODU0NjIsMTA5MDgxMjUxMiwzNzQ3NjcyMDAzLDI4MjUzNzk2NjksODI5MzI5MTM1LDExODEzMzUxNjEsMzQxMjE3NzgwNCwzMTYwODM0ODQyLDYyODA4NTQwOCwxMzgyNjA1MzY2LDM0MjMzNjkxMDksMzEzODA3ODQ2Nyw1NzA1NjIyMzMsMTQyNjQwMDgxNSwzMzE3MzE2NTQyLDI5OTg3MzM2MDgsNzMzMjM5OTU0LDE1NTUyNjE5NTYsMzI2ODkzNTU5MSwzMDUwMzYwNjI1LDc1MjQ1OTQwMywxNTQxMzIwMjIxLDI2MDcwNzE5MjAsMzk2NTk3MzAzMCwxOTY5OTIyOTcyLDQwNzM1NDk4LDI2MTc4MzcyMjUsMzk0MzU3NzE1MSwxOTEzMDg3ODc3LDgzOTA4MzcxLDI1MTIzNDE2MzQsMzgwMzc0MDY5MiwyMDc1MjA4NjIyLDIxMzI2MTExMiwyNDYzMjcyNjAzLDM4NTU5OTAyODUsMjA5NDg1NDA3MSwxOTg5NTg4ODEsMjI2MjAyOTAxMiw0MDU3MjYwNjEwLDE3NTkzNTk5OTIsNTM0NDE0MTkwLDIxNzY3MTg1NDEsNDEzOTMyOTExNSwxODczODM2MDAxLDQxNDY2NDU2NywyMjgyMjQ4OTM0LDQyNzkyMDAzNjgsMTcxMTY4NDU1NCwyODUyODExMTYsMjQwNTgwMTcyNyw0MTY3MjE2NzQ1LDE2MzQ0Njc3OTUsMzc2MjI5NzAxLDI2ODUwNjc4OTYsMzYwODAwNzQwNiwxMzA4OTE4NjEyLDk1NjU0MzkzOCwyODA4NTU1MTA1LDM0OTU5NTgyNjMsMTIzMTYzNjMwMSwxMDQ3NDI3MDM1LDI5MzI5NTk4MTgsMzY1NDcwMzgzNiwxMDg4MzU5MjcwLDkzNjkxOGUzLDI4NDc3MTQ4OTksMzczNjgzNzgyOSwxMjAyOTAwODYzLDgxNzIzMzg5NywzMTgzMzQyMTA4LDM0MDEyMzcxMzAsMTQwNDI3NzU1Miw2MTU4MTgxNTAsMzEzNDIwNzQ5MywzNDUzNDIxMjAzLDE0MjM4NTc0NDksNjAxNDUwNDMxLDMwMDk4Mzc2MTQsMzI5NDcxMDQ1NiwxNTY3MTAzNzQ2LDcxMTkyODcyNCwzMDIwNjY4NDcxLDMyNzIzODAwNjUsMTUxMDMzNDIzNSw3NTUxNjcxMTddOyJ1bmRlZmluZWQiIT10eXBlb2YgSW50MzJBcnJheSYmKGU9bmV3IEludDMyQXJyYXkoZSkpO2Zvcih2YXIgbz0tMV5+fnIsYT0obj1uZXcgVWludDhBcnJheShuKSkubGVuZ3RoLGk9MDtpPGE7aSsrKW89ZVsyNTUmKG9ebltpXSldXm8+Pj44O3JldHVybiB0KCgtMV5vKT4+PjApfShlLDApO3Bvc3RNZXNzYWdlKFtlLGEsb10sW2VdKX19KCk7Cg==",ur="undefined"!=typeof window&&window.Blob&&new Blob([atob(cr)],{type:"text/javascript;charset=utf-8"});function lr(){var e;try{if(!(e=ur&&(window.URL||window.webkitURL).createObjectURL(ur)))throw"";return new Worker(e)}catch(N){return new Worker("data:application/javascript;base64,"+cr)}finally{!("undefined"!=typeof window&&navigator.userAgent.indexOf("Trident/")>0)&&e&&(window.URL||window.webkitlRL).revokeObjectURL(e)}}var hr=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};s(this,e),this.file=t.file,this.uploaderCtx=t.context,this.key=t.key,this.config=r,this.finishArr=[],this.finishSize=0,this.retryUploadTime=Number(r.retryUploadTime),this.writenStorage=!1,this.uploadHandlers={}}return o(e,[{key:"start",value:function(e,t){this.failProcess=t,this.successProcess=e,this.currFileCtx=this.uploaderCtx.tasks[this.key],this.crc32Array=this.currFileCtx.crc32Array,this.uploadSliceCount=Math.min(this.crc32Array.length,Number(this.config.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.imagexEncrypt=this.currFileCtx.imagexEnableEncrypt,this.initWorker(),this.threadUpload()}},{key:"initWorker",value:function(){var e=this;if(!this.worker){try{this.worker=new lr}catch(r){return console.warn("[TTUploader]:worker not supported!"),void this.uploaderCtx.logger.sendLogBase("".concat(Se[this.currFileCtx.serviceType],"_999"),this.currFileCtx,{type:"warning",stage:pe,ex:"init worker failed:".concat(null==r?void 0:r.message),msg:"worker not supported."})}var t=this.crc32Array;this.worker.onmessage=function(r){var i=r.data[0],s=r.data[2],n=t[s];n.crc32=r.data[1],e.upload(n,i,s)}}}},{key:"read",value:function(e,t){var r=this;e.encryptMeta?this.upload(e,e.buffer,t):st(this.file,e.start,e.end).then((function(i){r.imagexEncrypt&&(i=Ht({iv:r.crc32Array[0].iv,key:r.currFileCtx.imagexEncryptKey,data:i})),r.worker?r.worker.postMessage([i,t],[i]):(e.crc32=ct(i,0),r.upload(e,i,t))}),(function(e){r.stop(),r.fail({extra:{errorCode:Be.FILE_ERROR_UPLOADING,message:qe,error:null==e?void 0:e.message}})}))}},{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:"upload",value:function(e,t,r){var i=this,s=e.crc32,n={number:r+1,uploadId:this.currFileCtx.uploadId,oid:this.currFileCtx.oid,tosDomain:this.currFileCtx.tosDomain},o=Je(Re,n),a=Object.assign({},this.currFileCtx.uploadHeader),c=new ar({sliceBuffer:t,crc32:s,url:o,signature:this.currFileCtx.signature,uploadHeader:a,retryTime:this.retryUploadTime,sliceIndex:r});c.on("complete",(function(t){t.start=e.start,i.singleSliceSuccess(t)})),c.on("error",(function(t){i.currFileCtx.status===De.UPLOADING&&(t.start=e.start,i.fail(t))})),c.on("progress",(function(t){i.currFileCtx.status===De.UPLOADING&&(t.start=e.start,i.process(t))})),c.on("retry",(function(e){var t=it(e.xhr),r=t.req,s=t.res;i.uploaderCtx.logger.sendLogBase("".concat(Se[i.currFileCtx.serviceType],"_retry"),i.currFileCtx,{type:"retry",ex:"upload retry, retry count:".concat(e.retryCount,",errorCode:").concat(e.errorCode),req:r,res:s,si:e.sliceIndex+1,errc:e.errorCode,err:e.error,errmsg:e.errmsg})})),c.upload(),this.uploadHandlers[r]=c}},{key:"singleSliceSuccess",value:function(e){var t=e.sliceIndex;-1===this.finishArr.indexOf(e.start)&&this.finishArr.push(e.start),this.crc32Array[t].finished=!0;var r=it(e.xhr),i=r.res,s=r.req;if(this.uploaderCtx.logger.send(this.currFileCtx,{type:"success",si:t+1,af:!1,ss:e.size,sldur:e.duration,ex:"Slice upload:".concat(t+1," success:").concat(e.crc32,",total:").concat(this.crc32Array.length,"."),req:s,res:i}),!this.writenStorage&&this.currFileCtx.enableDiskBreakPoint&&(this.writenStorage=!0,this.uploaderCtx._saveTask(this.key)),this.uploading.splice(this.uploading.indexOf(t),1),this.uploadHandlers[t]&&delete this.uploadHandlers[t],this.currFileCtx.status===De.UPLOADING)return this.finishArr.length>=this.crc32Array.length?(this.stop(),void this.success(e.xhr)):void(this.currFileCtx.status===De.UPLOADING&&this.threadUpload())}},{key:"process",value:function(e){var t=this.currFileCtx.fileSize;this.finishSize=Math.max(nt(this.crc32Array,e),this.finishSize);var r=Math.min(Math.round(this.finishSize/t*100),99);r>this.currFileCtx.percent&&(this.currFileCtx.percent=r,this.uploaderCtx._broadcast("progress",this.currFileCtx))}},{key:"success",value:function(e){var t,r;this.finishArr=[];var i=Date.now()-this._st,s=Math.round(this._uploadSize/1024)/(i/1e3),n=Object.assign(this.currFileCtx,{percent:99,extra:{message:"upload all slice success."},speed:s,allFinish:!0});null===(t=this.worker)||void 0===t||null===(r=t.terminate)||void 0===r||r.call(t),this.successProcess(n)}},{key:"fail",value:function(e){this.stop();var t={errorCode:e.errorCode,message:e.message,error:e.error},r=Object.assign(this.currFileCtx,{extra:t,type:"error",allFinish:!1});this.failProcess(r)}},{key:"stop",value:function(){var e,t;Object.values(this.uploadHandlers).forEach((function(e){null==e||e.abort()})),null===(e=this.worker)||void 0===e||null===(t=e.terminate)||void 0===t||t.call(e),this.worker=null}}]),e}(),dr=function(){function e(t,r){s(this,e),this.options=t,this.config=r,this.uploaderCtx=t.context,this.currFileCtx=this.uploaderCtx.tasks[t.key],this.retryTime=r.retryTaskTime,this.req=null}return o(e,[{key:"start",value:function(e,t){this.successProcess=e,this.failProcess=t,this.retryCount=0,this.mergeFile()}},{key:"mergeFile",value:function(){for(var e={oid:this.currFileCtx.oid,uploadId:this.currFileCtx.uploadId,tosDomain:this.currFileCtx.tosDomain},r=this.currFileCtx.crc32Array,i="",s=0;s<r.length;s++)i=i?"".concat(i,",").concat(s+1,":").concat(r[s].crc32):"".concat(s+1,":").concat(r[s].crc32);var n=Je(Le,e),o=Object.assign({},this.currFileCtx.uploadHeader),a={method:"POST",url:n,headers:t({authorization:this.currFileCtx.signature},o),custom:i};this.req=a,this.request(a)}},{key:"request",value:function(e){var t=this;Jt(e,ge).then((function(e){var r=e.result,i=e.xhr;t.success(r,i)}),(function(e){t.fail(e)}))}},{key:"success",value:function(e,t){var r=Object.assign(this.currFileCtx,{merged:!0,extra:{message:"merge file success."},xhr:t});this.uploaderCtx._saveTask(this.options.key),this.successProcess(r)}},{key:"fail",value:function(e){if(this.retryCount<this.retryTime&&this.req)return this.retryCount+=1,this.request(this.req);var t=Object.assign(this.currFileCtx,{extra:{errorCode:e.errorCode,message:e.message,error:e.error},xhr:e.xhr});this.failProcess(t)}}]),e}(),fr=function(){function e(t,r){s(this,e),this.options=t,this.file=t.file,this.uploaderCtx=t.context,this.key=t.key,this.config=r,this.finishSize=0,this.retryUploadTime=Number(r.retryUploadTime),this.uploadSuccessNum=0,this.uploadFailNum=0}return o(e,[{key:"start",value:function(e,t){this.failProcess=t,this.successProcess=e,this.currFileCtx=this.uploaderCtx.tasks[this.key],this.crc32Array=this.currFileCtx.crc32Array,this._uploadSize=this.currFileCtx.fileSize,this.uploadHandlers={},this._st=Date.now(),this.upload()}},{key:"upload",value:function(){for(var e=this,t=this.crc32Array.length,r=0;r<t;r++){var i=this.crc32Array[r];if(!i.finished){var s=i.buffer,n=i.crc32,o=this.currFileCtx.oid,a=this.currFileCtx.signature,c={oid:Array.isArray(o)?o[r]:o,tosDomain:this.currFileCtx.tosDomain},u=Je(Fe,c),l=new ar({sliceBuffer:s,crc32:n,url:u,signature:Array.isArray(a)?a[r]:a,uploadHeader:this.currFileCtx.uploadHeader,retryTime:this.retryUploadTime,sliceIndex:r});l.on("complete",(function(t){e.singleSliceSuccess(t)})),l.on("error",(function(t){e.singleSliceFailed(t)})),l.on("progress",(function(t){e.process(t)})),l.on("retry",(function(t){var r=it(t.xhr),i=r.req,s=r.res;e.uploaderCtx.logger.sendLogBase("".concat(Se[e.currFileCtx.serviceType],"_retry"),e.currFileCtx,{type:"retry",ex:"upload retry, retry count:".concat(t.retryCount,",errorCode:").concat(t.errorCode),req:i,res:s,si:t.sliceIndex+1,errc:t.errorCode,err:t.error,errmsg:t.errmsg})})),this.uploadHandlers["".concat(n,"_").concat(Math.round(1e3*Math.random()))]=l,l.upload()}}}},{key:"process",value:function(e){var t=this.currFileCtx.fileSize;this.finishSize=nt(this.currFileCtx.crc32Array,e);var r=Math.min(Math.round(this.finishSize/t*100),99);r>this.currFileCtx.percent&&(this.currFileCtx.percent=r),this.currFileCtx.status===De.UPLOADING&&this.uploaderCtx._broadcast("progress",this.currFileCtx)}},{key:"singleSliceSuccess",value:function(e){var t=e.sliceIndex;if(!this.crc32Array[t].finished){this.crc32Array[t].finished=!0,this.uploadSuccessNum+=1;var r=it(e.xhr),i=r.res,s=r.req;this.uploaderCtx.logger.send(this.currFileCtx,{type:"success",si:t+1,af:!1,ss:e.size,sldur:e.duration,ex:"Direct upload:".concat(t+1," success:").concat(e.crc32,",total:").concat(this.crc32Array.length,",batch:").concat(this.currFileCtx.isImageBatchUpload),req:s,res:i})}this.uploadSuccessNum+this.uploadFailNum===this.crc32Array.length&&this.success(e)}},{key:"singleSliceFailed",value:function(e){this.uploadFailNum+=1;var t=it(e.xhr),r=t.res,i=t.req;this.uploaderCtx.logger.sendLogBase("".concat(Se[this.currFileCtx.serviceType],"_999"),this.currFileCtx,{type:"warning",si:e.sliceIndex+1,ss:e.size,ex:"warning:direct upload idx:".concat(e.sliceIndex+1," failed,total:").concat(this.crc32Array.length,",batch:").concat(this.currFileCtx.isImageBatchUpload),req:i,res:r}),this.uploadFailNum===this.crc32Array.length&&this.fail(e)}},{key:"success",value:function(e){var t=Date.now()-this._st,r=Math.round(this._uploadSize/t),i=Object.assign(this.currFileCtx,{percent:99,extra:{message:"direct upload success"},speed:r,xhr:e.xhr,allFinish:!0});this.successProcess(i)}},{key:"fail",value:function(e){var t=Object.assign(this.currFileCtx,{extra:{errorCode:e.errorCode,message:e.message,error:e.error},xhr:e.xhr});this.failProcess(t)}},{key:"stop",value:function(){Object.values(this.uploadHandlers).forEach((function(e){null==e||e.abort()}))}}]),e}(),pr=function(){function e(t,r){s(this,e),this.options=t,this.config=r,this.uploaderCtx=t.context,this.currFileCtx=this.uploaderCtx.tasks[t.key],this.processAction=t.processAction,this.skipCommit=t.skipCommit,this.serviceName=this.currFileCtx.serviceType,this.isImageBatchUpload=!!this.currFileCtx.isImageBatchUpload,this.retryTime=r.retryTaskTime,this.retryCount=0}return o(e,[{key:"start",value:function(e,t){if(this.successProcess=e,this.failProcess=t,this.skipCommit){var r=Object.assign(this.currFileCtx,{type:"success",percent:100,extra:{message:"upload successful, skip commit."}});return this.successProcess(r)}this.commitUpload()}},{key:"commitUpload",value:function(){var e=this.config.region||Ee,t=this.createReqParamsByService(this.serviceName),r=t.host,i=t.params,s=t.body;t.data,this.config.accountId&&(i["X-Account-Id"]=this.config.accountId),this.uploaderCtx.priorInfo.topExpires>0&&(i["X-Expires"]=this.uploaderCtx.priorInfo.topExpires);var n=Ve(i),o={method:"POST",url:"".concat(r,"?").concat(n),timeout:this.config.requestTimeout,region:e,params:i,headers:{}};if(this.serviceName===Ie){var a=Object.keys(s).map((function(e){return"[object Array]"===Object.prototype.toString.call(s[e])||"[object Object]"===Object.prototype.toString.call(s[e])?"".concat(e,"=").concat(encodeURIComponent(JSON.stringify(s[e]))):"SessionKey"===e?"".concat(e,"=").concat(encodeURIComponent(s[e])):"".concat(e,"=").concat(s[e])})).join("&");o.headers["Content-Type"]="application/x-www-form-urlencoded",o.body=a,o.custom=o.body}else o.custom=JSON.stringify(s),o.headers["Content-Type"]="application/json",o.body=s;var c=new sr(o,this.serviceName,{isVolcengine:!0}),u=this.currFileCtx.proxyStsToken||this.config.stsToken,l=u.AccessKeyID,h=u.AccessKeyId,d=u.SecretAccessKey,f=u.SessionToken,p=u.CurrentTime,g=null;g=this.config.useServerCurrentTime?new Date(new Date(p).getTime()+(this.currFileCtx.totalDuration||0)):new Date(Date.now()+this.uploaderCtx.priorInfo.systemTimeGap),c.addAuthorization({accessKeyId:h||l,secretAccessKey:d,sessionToken:f},g),this.request(o)}},{key:"createReqParamsByService",value:function(e){var t=this,r={body:{SessionKey:this.currFileCtx.sessionKey}};if(e===Ie){var i,s,n,o;r.host=this.config.videoHost||Ae;var a,c=null===(i=this.config.videoConfig)||void 0===i?void 0:i.spaceName;if(this.currFileCtx.fileType===Ne&&null!==(s=this.config.objectConfig)&&void 0!==s&&s.spaceName)c=null===(a=this.config.objectConfig)||void 0===a?void 0:a.spaceName;r.params={Action:"CommitUploadInfo",Version:"2022-01-01",SpaceName:c};var u,l=null===(n=this.config.videoConfig)||void 0===n?void 0:n.processAction;if(this.currFileCtx.fileType===Ne&&null!==(o=this.config.objectConfig)&&void 0!==o&&o.processAction)l=null===(u=this.config.objectConfig)||void 0===u?void 0:u.processAction;this.processAction&&(l=this.processAction),Array.isArray(l)&&l.length>0&&(r.body.Functions=l),(this.config.videoConfig&&this.config.videoConfig.callbackArgs||this.options.callbackArgs)&&(r.body.CallbackArgs=this.options.callbackArgs||this.config.videoConfig.callbackArgs)}else{var h;r.host=this.config.imageHost||ze,r.params={Action:"CommitImageUpload",Version:"2018-08-01",ServiceId:this.options.serviceId||(null===(h=this.config.imageConfig)||void 0===h?void 0:h.serviceId)},this.options.skipMeta&&(r.params.SkipMeta=this.options.skipMeta),this.processAction&&Array.isArray(this.processAction)&&this.processAction.length>0&&(r.body.Functions=this.processAction);var d=this.currFileCtx,f=d.imagexEnableEncrypt,p=d.imagexPublicKey;f&&p&&!this.options.skipMeta&&this.uploaderCtx.plugins.forEach((function(e){if("imagex-encrypt-plugin"===(null==e?void 0:e._identifier))try{r.body.DecryptKeys=e.apply(t.currFileCtx)}catch(i){console.warn("[TTUploader]:",null==i?void 0:i.message)}}))}return r.data=JSON.stringify(r.body),r}},{key:"request",value:function(e){var t=this;Gt(e,ye).then((function(e){var r=e.result,i=e.xhr;t.success(r,i)}),(function(e){t.fail(e)}))}},{key:"fail",value:function(e){if(100006===e.errorCode){if(0===this.uploaderCtx.priorInfo.topExpires){return this.uploaderCtx.priorInfo.topExpires=604800,this.commitUpload()}if(0===this.uploaderCtx.priorInfo.systemTimeGap){var t=Ke(e.requestId);return this.uploaderCtx.priorInfo.systemTimeGap=t,this.commitUpload()}}if(this.retryCount<this.retryTime)return this.retryCount+=1,this.commitUpload();var r=Object.assign(this.currFileCtx,{extra:{errorCode:e.errorCode,message:e.message,error:e.error},xhr:e.xhr});this.failProcess(r)}},{key:"success",value:function(e,r){var i={};if(this.serviceName===Oe)if(this.isImageBatchUpload){var s=e.Results,n=e.PluginResult||[];s.forEach((function(e,r){s[r]=t(t({},s[r]),n[r])})),i=s}else i=e.Results[0],Object.assign(i,e.PluginResult&&e.PluginResult[0]);else i=e.Data;var o=Object.assign(this.currFileCtx,{percent:100,extra:{message:"upload successful."},uploadResult:i,xhr:r});return this.successProcess(o)}}]),e}(),gr=function(){function e(t,r,i){s(this,e),this.config=t,this.key=i,this.uploaderCtx=r,this.tasks=[]}return o(e,[{key:"addSubTask",value:function(e){this.tasks.push(e)}},{key:"start",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.uploaderCtx.tasks[this.key];if(e){var r;if(t.requestPending)return;if(t.curTaskIdx===ke&&(null===(r=this.tasks[0])||void 0===r?void 0:r.index)===Me){var i=this.uploaderCtx.taskList[this.key].find((function(e){return e.index===ke}));i&&this.execTask(i)}else{var s=this.tasks.shift();s&&this.execTask(s)}}else{var n=this.tasks.shift();n&&this.execTask(n)}}},{key:"execTask",value:function(e){var t,r=this,i=e.key,s=this.uploaderCtx.tasks[i],n=s.cacheTaskIdx;n&&e.index>0&&e.index<n?this.start():(s.curTaskIdx=e.index,s.stage=e.stage,s.status===De.UPLOADING&&(s.stageStartTime=Date.now(),s.requestPending=!0,null==e||null===(t=e.func)||void 0===t||t.call(e.context,(function(e){r.finishTask(e,!0)}),(function(e){r.finishTask(e,!1)}))))}},{key:"finishTask",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=e.stageStartTime;if(e.stageEndTime=Date.now(),e.duration=Date.now()-r,e.totalDuration+=Date.now()-r,e.requestPending=!1,e.xhr){var i=it(e.xhr),s=i.req,n=i.res;e.req=s,e.res=n,delete e.xhr}t?this.success(e):this.fail(e)}},{key:"success",value:function(e){if(Object.assign(e,{type:"success"}),this.uploaderCtx.logger.send(e),this.tasks.length>0)this.start();else{if(this.uploaderCtx._taskFinish(e.key,!0),e.status===De.PAUSE||e.status===De.CANCEL)return;this.uploaderCtx._broadcast(e.stage,e)}}},{key:"fail",value:function(e){Object.assign(e,{type:"error"}),this.uploaderCtx.logger.sendErrorLog(e),this.uploaderCtx._taskFinish(e.key,!1),e.status!==De.PAUSE&&e.status!==De.CANCEL&&this.uploaderCtx._broadcast("error",e)}},{key:"cancel",value:function(e){var t=this.key,r=this.uploaderCtx.tasks[t];if(r&&(!e||!r.isDirect)){var i,s;if(r.stage===pe)null===(i=this.uploaderCtx.taskList[t].find((function(e){return e.index===ke})).context)||void 0===i||null===(s=i.stop)||void 0===s||s.call(i),r.requestPending=!1;e||(this.tasks=[])}}}]),e}(),yr=function(e){c(r,e);var t=d(r);function r(e){var i;return s(this,r),(i=t.call(this,e)).config=Object.assign({},k,e),i.tasks={},i.taskList={},i.cache={},i._schedulerMap=a(a(a(a(a(a(a({},De.IDLE,[]),De.UPLOADING,new Set),De.PAUSE,[]),De.WAITING,[]),De.CANCEL,[]),De.SUCCESS,[]),De.FAILED,[]),i.storage=Ze(h(i),i.config.useLocalStorage),i.logger=i.config.noLog?{send:function(){}}:new He(i.config,h(i)),i.plugins=[],i.priorInfo={systemTimeGap:0,topExpires:0},i}return o(r,[{key:"_use",value:function(e){var t,r=!1,i=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=p(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,s=function(){};return{s:s,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,n=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw n}}}}(this.plugins);try{for(i.s();!(t=i.n()).done;){var s=t.value;if((null==s?void 0:s.stage)===(null==e?void 0:e.stage)&&(null==s?void 0:s._identifier)===e._identifier){r=!0;break}}}catch(n){i.e(n)}finally{i.f()}r||this.plugins.push(e)}},{key:"_mergeOptions",value:function(e,t){t&&"object"===i(t)&&Object.assign(e,t)}},{key:"_addAllUploadProcess",value:function(e,t,r){this.taskList[t]=[];var i={key:t,task:new gr(this.config,this,t),fileType:e.type||be,proxyStsToken:e.stsToken,serviceType:r,duration:0,totalDuration:0,percent:0,pauseDuration:0,skipCommit:r===Oe&&e.skipCommit,sliceSize:0,sliceCount:this.config.uploadSliceCount,requestPending:!1,taskAllFinish:!1},s=r===Oe&&Array.isArray(e.file);if(i.isImageBatchUpload=s,s?(i.fileSize=e.file.reduce((function(e,t){return e+t.size}),0),i.fileName=e.file.map((function(e){return e.name}))):(i.fileSize=e.file.size,i.fileName=e.file.name),!s){var n=this.config.sliceSize||tt(i.fileSize,this.config.getSliceFunc);i.sliceSize=n}var o=!1;if(o=!!s||i.fileSize<5242880,i.isDirect=o,r===Oe){var a,c,u,l=!(null===(a=this.config)||void 0===a||null===(a=a.imageConfig)||void 0===a||!a.imagexEnableEncrypt);if(i.imagexEnableEncrypt=l,l)i.imagexEncryptKey=(null===(c=this.config)||void 0===c||null===(c=c.imageConfig)||void 0===c?void 0:c.imagexEncryptKey)||We(32),i.imagexPublicKey=null===(u=this.config)||void 0===u||null===(u=u.imageConfig)||void 0===u?void 0:u.imagexPublicKey}o||i.imagexEnableEncrypt||(i.gatewayUpload=!0),o||i.imagexEnableEncrypt||!this.config.useLocalStorage||(i.enableDiskBreakPoint=!0),i.status=De.IDLE,this.tasks[t]=i,this._schedulerMap[De.IDLE].push(t),this._addCrc32ProcessTask(e,t),this._addPreUploadTask(e,t),o?this._addDirectUploadTask(e,t):(this._addInitUploadIDTask(t),this._addUploadProcessTask(e,t),this._mergeFileTask(t)),this._getMetaInfoTask(e,t)}},{key:"_addTask",value:function(e,t){var r=this.tasks;this.taskList[e].push(t),r[e].task.addSubTask(t)}},{key:"_addCrc32ProcessTask",value:function(e,t){var r=new Qt({file:e.file,context:this,key:t},this.config),i={context:r,func:r.start,key:t,index:me,stage:he};this._addTask(t,i)}},{key:"_addPreUploadTask",value:function(e,t){var r={context:this,key:t,fileName:e.fileName||null,fileExtension:e.fileExtension||null,storageClass:e.storageClass||null,serviceId:e.serviceId||null,prefix:e.prefix,storeKey:e.storeKey,overwrite:e.overwrite},i=new nr(r,this.config),s={context:i,func:i.start,key:t,index:_e,stage:de};this._addTask(t,s)}},{key:"_addInitUploadIDTask",value:function(e){var t=new or({context:this,key:e},this.config),r={context:t,func:t.start,key:e,index:xe,stage:fe};this._addTask(e,r)}},{key:"_addDirectUploadTask",value:function(e,t){var r=new fr({file:e.file,context:this,key:t},this.config),i={context:r,func:r.start,key:t,index:ke,stage:pe};this._addTask(t,i)}},{key:"_addUploadProcessTask",value:function(e,t){var r=new hr({file:e.file,context:this,key:t},this.config),i={context:r,func:r.start,key:t,index:ke,stage:pe};this._addTask(t,i)}},{key:"_mergeFileTask",value:function(e){var t=new dr({context:this,key:e},this.config),r={context:t,func:t.start,key:e,index:Me,stage:ge};this._addTask(e,r)}},{key:"_getMetaInfoTask",value:function(e,t){var r={context:this,key:t,callbackArgs:e.callbackArgs,serviceId:e.serviceId||null,processAction:e.processAction,skipMeta:e.skipMeta},i=new pr(r,this.config),s={context:i,func:i.start,key:t,index:we,stage:ye};this._addTask(t,s)}},{key:"_start",value:function(e){var t=this;(e?[e]:f(this._schedulerMap[De.IDLE])).forEach((function(e){var r=t.tasks[e];r?r.status===De.IDLE&&(r.status=De.WAITING,t._updateSchduelerMap(e,De.IDLE,De.WAITING)):console.warn("[TTUploader]:".concat(e," is not exit in tasks."))})),this._taskStart()}},{key:"_pause",value:function(e){var t=this;(e?[e]:f(this._schedulerMap[De.UPLOADING])).forEach((function(e){var r,i=t.tasks[e];if(i){if(i.status===De.UPLOADING){var s="".concat(Se[i.serviceType],"_999");t.logger.sendLogBase(s,i,{type:"pause",ex:"pause upload.".concat(e)}),i.pauseTime=Date.now(),i.status=De.PAUSE,null===(r=i.task)||void 0===r||r.cancel(!0),t._updateSchduelerMap(e,De.UPLOADING,De.PAUSE)}}else console.warn("[TTUploader]:".concat(e," is not exit in upload tasks."))})),e&&this._taskStart()}},{key:"_cancel",value:function(e){var t=this;(e?[e]:[].concat(f(this._schedulerMap[De.UPLOADING]),f(this._schedulerMap[De.IDLE]),f(this._schedulerMap[De.WAITING]),f(this._schedulerMap[De.PAUSE]))).forEach((function(e){var r,i=t.tasks[e];if(i){var s=i.status;if(![De.SUCCESS,De.FAILED,De.CANCEL].includes(s)){var n="".concat(Se[i.serviceType],"_999");t.logger.sendLogBase(n,i,{type:"cancel",ex:"cancel upload.".concat(e)}),null===(r=i.task)||void 0===r||r.cancel(!1),t._updateSchduelerMap(e,s,De.CANCEL),i.status=De.CANCEL,delete t.taskList[e],delete t.tasks[e],t._removeTaskCache(e)}}else console.warn("[TTUploader]:".concat(e," is not exit in upload tasks."))}))}},{key:"_restart",value:function(e){var t=this;(e?[e]:f(this._schedulerMap[De.PAUSE])).forEach((function(e){var r=t.tasks[e];r?r.status===De.PAUSE&&(r.status=De.WAITING,t._updateSchduelerMap(e,De.PAUSE,De.WAITING)):console.warn("[TTUploader]:".concat(e," is not exit in upload tasks."))})),this._taskStart()}},{key:"_taskStart",value:function(){for(var e,t=this,r=Math.min(this.config.taskParallelLimit-this._schedulerMap[De.UPLOADING].size,this._schedulerMap[De.WAITING].length),i=function(){var e=t._schedulerMap[De.WAITING][0],r=t.tasks[e];if(r.status=De.UPLOADING,t._updateSchduelerMap(e,De.WAITING,De.UPLOADING),r.taskAllFinish){var i="success"===r.type?De.SUCCESS:De.FAILED;if(t._updateSchduelerMap(e,De.UPLOADING,i),r.status=i,t._broadcast(r.stage,r),t._schedulerMap[De.WAITING].length>0)return{v:t._taskStart()}}var s=r.task,n=null,o=!1;if(r.pauseTime){o=!0;var a=r.curTaskIdx;r.requestPending||(s.tasks=t.taskList[e].slice(t.taskList[e].findIndex((function(e){return e.index===a})))),n={type:"resume",ex:"resume upload."},r.pauseDuration+=Date.now()-r.pauseTime}else r.startTime=Date.now(),n={type:"start",ex:"start upload.".concat(e)};var c="".concat(Se[r.serviceType],"_999");t.logger.sendLogBase(c,r,n),s.start(o)},s=0;s<r;s++)if(e=i())return e.v}},{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:"_broadcast",value:function(e,t){this.emit(ve[e],t)}},{key:"_removeTaskCache",value:function(e){var t=this.tasks[e];if(t){var r=t.crc32Key;if(r)try{this._removeCache(r)}catch(i){console.warn("[TTUploader]:",null==i?void 0:i.message)}}}},{key:"_saveTask",value:function(e){var t=this.tasks[e],r=t.crc32Key;if(r){var i={sessionKey:t.sessionKey,uploadHeader:t.uploadHeader,fileName:t.fileName,oid:t.oid,uploadId:t.uploadId,signature:t.signature,tosDomain:t.tosDomain,merged:t.merged};Object.keys(i).forEach((function(e){i[e]||delete i[e]}));try{this._setCache(r,JSON.stringify(i))}catch(N){this.logger.sendLogBase("".concat(Se[t.serviceType],"_999"),t,{type:"warning",ex:"Save to cache error:".concat(null==N?void 0:N.message)})}}}},{key:"_taskFinish",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.tasks[e];r&&(r.endTime=Date.now(),r.time=r.endTime-r.startTime,r.taskAllFinish=!0,r.status===De.UPLOADING&&(t?(this.taskList[e]=[],r.status=De.SUCCESS,this._updateSchduelerMap(e,De.UPLOADING,De.SUCCESS),this._removeTaskCache(e)):(r.status=De.FAILED,this._updateSchduelerMap(e,De.UPLOADING,De.FAILED)),this._schedulerMap[De.WAITING].length>0&&this._taskStart()))}},{key:"_updateSchduelerMap",value:function(e,t,r){if(t===De.UPLOADING)this._schedulerMap[t].delete(e);else{var i=this._schedulerMap[t].indexOf(e);if(i<0)return;this._schedulerMap[t].splice(i,1)}r===De.UPLOADING?this._schedulerMap[r].add(e):this._schedulerMap[r].push(e)}},{key:"_removeFile",value:function(e){this.tasks.delete(e)}},{key:"_refreshStsToken",value:function(e){var t=this,r=this.tasks;Object.keys(r).forEach((function(i){var s=r[i],n=Object.assign({},s,{proxyStsToken:e});s.proxyStsToken=e;var o=n.crc32Key;o&&(delete n.task,delete n.xhr,delete n.crc32Array,s.proxyStsToken=e,t._setCache(o,JSON.stringify(n)))}))}},{key:"_setOption",value:function(e){this._mergeOptions(this.config,e)}},{key:"_setServiceId",value:function(e){!this.config.imageConfig&&e?this.config.imageConfig={serviceId:e}:this.config.imageConfig.serviceId=e}},{key:"_getServiceId",value:function(){var e;return null===(e=this.config.imageConfig)||void 0===e?void 0:e.serviceId}},{key:"_getOption",value:function(e){var t=Object.assign({},this.config);return e?t[e]:t}}]),r}(x),vr=function(e){c(r,e);var t=d(r);function r(){return s(this,r),t.apply(this,arguments)}return o(r,[{key:"use",value:function(e){this._use(e)}},{key:"addFile",value:function(e){if(e.file){var t=et(Ie);return this._addAllUploadProcess(e,t,Ie),t}return null}},{key:"addVodFile",value:function(e){return this.addFile(e)}},{key:"addImageFile",value:function(e){if(e.file){e.type=Te;var t=et(Oe);return this._addAllUploadProcess(e,t,Oe),t}return null}},{key:"addImageXFile",value:function(e){return this.addImageFile(e)}},{key:"setServiceId",value:function(e){this._setServiceId(e)}},{key:"getServiceId",value:function(){return this._getServiceId()}},{key:"removeFile",value:function(e){e&&this._removeFile(e)}},{key:"start",value:function(e){return this._start(e)}},{key:"restart",value:function(e){return this._restart(e)}},{key:"cancel",value:function(e){return this._cancel(e)}},{key:"pause",value:function(e){return this._pause(e)}},{key:"refreshAuth",value:function(e){this._refreshAuth(e)}},{key:"setOption",value:function(e){this._setOption(e)}},{key:"getOption",value:function(e){return this._getOption(e)}}]),r}(yr);return vr}));