@byteplus/uploader 1.1.2 → 1.1.3
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 +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function webpackUniversalModuleDefinition(u,f){"object"==typeof exports&&"object"==typeof module?module.exports=f():"function"==typeof define&&define.amd?define([],f):"object"==typeof exports?exports.BytePlusUploader=f():u.BytePlusUploader=f()}("undefined"!=typeof self?self:this,function(){return function(u){var f={};function __webpack_require__(y){if(f[y])return f[y].exports;var _=f[y]={i:y,l:!1,exports:{}};return u[y].call(_.exports,_,_.exports,__webpack_require__),_.l=!0,_.exports}return __webpack_require__.m=u,__webpack_require__.c=f,__webpack_require__.d=function(u,f,y){__webpack_require__.o(u,f)||Object.defineProperty(u,f,{enumerable:!0,get:y})},__webpack_require__.r=function(u){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(u,"__esModule",{value:!0})},__webpack_require__.t=function(u,f){if(1&f&&(u=__webpack_require__(u)),8&f)return u;if(4&f&&"object"==typeof u&&u&&u.__esModule)return u;var y=Object.create(null);if(__webpack_require__.r(y),Object.defineProperty(y,"default",{enumerable:!0,value:u}),2&f&&"string"!=typeof u)for(var _ in u)__webpack_require__.d(y,_,function(f){return u[f]}.bind(null,_));return y},__webpack_require__.n=function(u){var f=u&&u.__esModule?function getDefault(){return u.default}:function getModuleExports(){return u};return __webpack_require__.d(f,"a",f),f},__webpack_require__.o=function(u,f){return Object.prototype.hasOwnProperty.call(u,f)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=9)}([function(u,f,y){"use strict";var _,m="object"==typeof Reflect?Reflect:null,v=m&&"function"==typeof m.apply?m.apply:function ReflectApply(u,f,y){return Function.prototype.apply.call(u,f,y)};_=m&&"function"==typeof m.ownKeys?m.ownKeys:Object.getOwnPropertySymbols?function ReflectOwnKeys(u){return Object.getOwnPropertyNames(u).concat(Object.getOwnPropertySymbols(u))}:function ReflectOwnKeys(u){return Object.getOwnPropertyNames(u)};var b=Number.isNaN||function NumberIsNaN(u){return u!=u};function EventEmitter(){EventEmitter.init.call(this)}u.exports=EventEmitter,u.exports.once=function once(u,f){return new Promise(function(y,_){function errorListener(y){u.removeListener(f,resolver),_(y)}function resolver(){"function"==typeof u.removeListener&&u.removeListener("error",errorListener),y([].slice.call(arguments))}eventTargetAgnosticAddListener(u,f,resolver,{once:!0}),"error"!==f&&function addErrorHandlerIfEventEmitter(u,f,y){"function"==typeof u.on&&eventTargetAgnosticAddListener(u,"error",f,y)}(u,errorListener,{once:!0})})},EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._eventsCount=0,EventEmitter.prototype._maxListeners=void 0;var w=10;function checkListener(u){if("function"!=typeof u)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof u)}function _getMaxListeners(u){return void 0===u._maxListeners?EventEmitter.defaultMaxListeners:u._maxListeners}function _addListener(u,f,y,_){var m,v,b;if(checkListener(y),void 0===(v=u._events)?(v=u._events=Object.create(null),u._eventsCount=0):(void 0!==v.newListener&&(u.emit("newListener",f,y.listener?y.listener:y),v=u._events),b=v[f]),void 0===b)b=v[f]=y,++u._eventsCount;else if("function"==typeof b?b=v[f]=_?[y,b]:[b,y]:_?b.unshift(y):b.push(y),(m=_getMaxListeners(u))>0&&b.length>m&&!b.warned){b.warned=!0;var w=new Error("Possible EventEmitter memory leak detected. "+b.length+" "+String(f)+" listeners added. Use emitter.setMaxListeners() to increase limit");w.name="MaxListenersExceededWarning",w.emitter=u,w.type=f,w.count=b.length,function ProcessEmitWarning(u){console&&console.warn&&console.warn(u)}(w)}return u}function onceWrapper(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _onceWrap(u,f,y){var _={fired:!1,wrapFn:void 0,target:u,type:f,listener:y},m=onceWrapper.bind(_);return m.listener=y,_.wrapFn=m,m}function _listeners(u,f,y){var _=u._events;if(void 0===_)return[];var m=_[f];return void 0===m?[]:"function"==typeof m?y?[m.listener||m]:[m]:y?function unwrapListeners(u){for(var f=new Array(u.length),y=0;y<f.length;++y)f[y]=u[y].listener||u[y];return f}(m):arrayClone(m,m.length)}function listenerCount(u){var f=this._events;if(void 0!==f){var y=f[u];if("function"==typeof y)return 1;if(void 0!==y)return y.length}return 0}function arrayClone(u,f){for(var y=new Array(f),_=0;_<f;++_)y[_]=u[_];return y}function eventTargetAgnosticAddListener(u,f,y,_){if("function"==typeof u.on)_.once?u.once(f,y):u.on(f,y);else{if("function"!=typeof u.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof u);u.addEventListener(f,function wrapListener(m){_.once&&u.removeEventListener(f,wrapListener),y(m)})}}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:!0,get:function(){return w},set:function(u){if("number"!=typeof u||u<0||b(u))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+u+".");w=u}}),EventEmitter.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},EventEmitter.prototype.setMaxListeners=function setMaxListeners(u){if("number"!=typeof u||u<0||b(u))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+u+".");return this._maxListeners=u,this},EventEmitter.prototype.getMaxListeners=function getMaxListeners(){return _getMaxListeners(this)},EventEmitter.prototype.emit=function emit(u){for(var f=[],y=1;y<arguments.length;y++)f.push(arguments[y]);var _="error"===u,m=this._events;if(void 0!==m)_=_&&void 0===m.error;else if(!_)return!1;if(_){var b;if(f.length>0&&(b=f[0]),b instanceof Error)throw b;var w=new Error("Unhandled error."+(b?" ("+b.message+")":""));throw w.context=b,w}var S=m[u];if(void 0===S)return!1;if("function"==typeof S)v(S,this,f);else{var k=S.length,E=arrayClone(S,k);for(y=0;y<k;++y)v(E[y],this,f)}return!0},EventEmitter.prototype.addListener=function addListener(u,f){return _addListener(this,u,f,!1)},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.prependListener=function prependListener(u,f){return _addListener(this,u,f,!0)},EventEmitter.prototype.once=function once(u,f){return checkListener(f),this.on(u,_onceWrap(this,u,f)),this},EventEmitter.prototype.prependOnceListener=function prependOnceListener(u,f){return checkListener(f),this.prependListener(u,_onceWrap(this,u,f)),this},EventEmitter.prototype.removeListener=function removeListener(u,f){var y,_,m,v,b;if(checkListener(f),void 0===(_=this._events))return this;if(void 0===(y=_[u]))return this;if(y===f||y.listener===f)0===--this._eventsCount?this._events=Object.create(null):(delete _[u],_.removeListener&&this.emit("removeListener",u,y.listener||f));else if("function"!=typeof y){for(m=-1,v=y.length-1;v>=0;v--)if(y[v]===f||y[v].listener===f){b=y[v].listener,m=v;break}if(m<0)return this;0===m?y.shift():function spliceOne(u,f){for(;f+1<u.length;f++)u[f]=u[f+1];u.pop()}(y,m),1===y.length&&(_[u]=y[0]),void 0!==_.removeListener&&this.emit("removeListener",u,b||f)}return this},EventEmitter.prototype.off=EventEmitter.prototype.removeListener,EventEmitter.prototype.removeAllListeners=function removeAllListeners(u){var f,y,_;if(void 0===(y=this._events))return this;if(void 0===y.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==y[u]&&(0===--this._eventsCount?this._events=Object.create(null):delete y[u]),this;if(0===arguments.length){var m,v=Object.keys(y);for(_=0;_<v.length;++_)"removeListener"!==(m=v[_])&&this.removeAllListeners(m);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(f=y[u]))this.removeListener(u,f);else if(void 0!==f)for(_=f.length-1;_>=0;_--)this.removeListener(u,f[_]);return this},EventEmitter.prototype.listeners=function listeners(u){return _listeners(this,u,!0)},EventEmitter.prototype.rawListeners=function rawListeners(u){return _listeners(this,u,!1)},EventEmitter.listenerCount=function(u,f){return"function"==typeof u.listenerCount?u.listenerCount(f):listenerCount.call(u,f)},EventEmitter.prototype.listenerCount=listenerCount,EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?_(this._events):[]}},function(u,f,y){u.exports=function(u){return function(f){var y=u,_=y.lib,m=_.WordArray,v=_.Hasher,b=y.algo,w=[],S=[];!function(){function isPrime(u){for(var y=f.sqrt(u),_=2;_<=y;_++)if(!(u%_))return!1;return!0}function getFractionalBits(u){return 4294967296*(u-(0|u))|0}for(var u=2,y=0;y<64;)isPrime(u)&&(y<8&&(w[y]=getFractionalBits(f.pow(u,.5))),S[y]=getFractionalBits(f.pow(u,1/3)),y++),u++}();var k=[],E=b.SHA256=v.extend({_doReset:function(){this._hash=new m.init(w.slice(0))},_doProcessBlock:function(u,f){for(var y=this._hash.words,_=y[0],m=y[1],v=y[2],b=y[3],w=y[4],E=y[5],C=y[6],x=y[7],O=0;O<64;O++){if(O<16)k[O]=0|u[f+O];else{var P=k[O-15],U=(P<<25|P>>>7)^(P<<14|P>>>18)^P>>>3,D=k[O-2],I=(D<<15|D>>>17)^(D<<13|D>>>19)^D>>>10;k[O]=U+k[O-7]+I+k[O-16]}var T=_&m^_&v^m&v,A=(_<<30|_>>>2)^(_<<19|_>>>13)^(_<<10|_>>>22),z=x+((w<<26|w>>>6)^(w<<21|w>>>11)^(w<<7|w>>>25))+(w&E^~w&C)+S[O]+k[O];x=C,C=E,E=w,w=b+z|0,b=v,v=m,m=_,_=z+(A+T)|0}y[0]=y[0]+_|0,y[1]=y[1]+m|0,y[2]=y[2]+v|0,y[3]=y[3]+b|0,y[4]=y[4]+w|0,y[5]=y[5]+E|0,y[6]=y[6]+C|0,y[7]=y[7]+x|0},_doFinalize:function(){var u=this._data,y=u.words,_=8*this._nDataBytes,m=8*u.sigBytes;return y[m>>>5]|=128<<24-m%32,y[14+(m+64>>>9<<4)]=f.floor(_/4294967296),y[15+(m+64>>>9<<4)]=_,u.sigBytes=4*y.length,this._process(),this._hash},clone:function(){var u=v.clone.call(this);return u._hash=this._hash.clone(),u}});y.SHA256=v._createHelper(E),y.HmacSHA256=v._createHmacHelper(E)}(Math),u.SHA256}(y(3))},function(u,f,y){u.exports=function(u){return u.HmacSHA256}(y(3),y(1),y(7))},function(u,f,y){(function(f){u.exports=function(){var u=u||function(u,_){var m;if("undefined"!=typeof window&&window.crypto&&(m=window.crypto),"undefined"!=typeof self&&self.crypto&&(m=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(m=globalThis.crypto),!m&&"undefined"!=typeof window&&window.msCrypto&&(m=window.msCrypto),!m&&void 0!==f&&f.crypto&&(m=f.crypto),!m)try{m=y(6)}catch(u){}var cryptoSecureRandomInt=function(){if(m){if("function"==typeof m.getRandomValues)try{return m.getRandomValues(new Uint32Array(1))[0]}catch(u){}if("function"==typeof m.randomBytes)try{return m.randomBytes(4).readInt32LE()}catch(u){}}throw new Error("Native crypto module could not be used to get secure random number.")},v=Object.create||function(){function F(){}return function(u){var f;return F.prototype=u,f=new F,F.prototype=null,f}}(),b={},w=b.lib={},S=w.Base={extend:function(u){var f=v(this);return u&&f.mixIn(u),f.hasOwnProperty("init")&&this.init!==f.init||(f.init=function(){f.$super.init.apply(this,arguments)}),f.init.prototype=f,f.$super=this,f},create:function(){var u=this.extend();return u.init.apply(u,arguments),u},init:function(){},mixIn:function(u){for(var f in u)u.hasOwnProperty(f)&&(this[f]=u[f]);u.hasOwnProperty("toString")&&(this.toString=u.toString)},clone:function(){return this.init.prototype.extend(this)}},k=w.WordArray=S.extend({init:function(u,f){u=this.words=u||[],this.sigBytes=f!=_?f:4*u.length},toString:function(u){return(u||C).stringify(this)},concat:function(u){var f=this.words,y=u.words,_=this.sigBytes,m=u.sigBytes;if(this.clamp(),_%4)for(var v=0;v<m;v++){var b=y[v>>>2]>>>24-v%4*8&255;f[_+v>>>2]|=b<<24-(_+v)%4*8}else for(var w=0;w<m;w+=4)f[_+w>>>2]=y[w>>>2];return this.sigBytes+=m,this},clamp:function(){var f=this.words,y=this.sigBytes;f[y>>>2]&=4294967295<<32-y%4*8,f.length=u.ceil(y/4)},clone:function(){var u=S.clone.call(this);return u.words=this.words.slice(0),u},random:function(u){for(var f=[],y=0;y<u;y+=4)f.push(cryptoSecureRandomInt());return new k.init(f,u)}}),E=b.enc={},C=E.Hex={stringify:function(u){for(var f=u.words,y=u.sigBytes,_=[],m=0;m<y;m++){var v=f[m>>>2]>>>24-m%4*8&255;_.push((v>>>4).toString(16)),_.push((15&v).toString(16))}return _.join("")},parse:function(u){for(var f=u.length,y=[],_=0;_<f;_+=2)y[_>>>3]|=parseInt(u.substr(_,2),16)<<24-_%8*4;return new k.init(y,f/2)}},x=E.Latin1={stringify:function(u){for(var f=u.words,y=u.sigBytes,_=[],m=0;m<y;m++){var v=f[m>>>2]>>>24-m%4*8&255;_.push(String.fromCharCode(v))}return _.join("")},parse:function(u){for(var f=u.length,y=[],_=0;_<f;_++)y[_>>>2]|=(255&u.charCodeAt(_))<<24-_%4*8;return new k.init(y,f)}},O=E.Utf8={stringify:function(u){try{return decodeURIComponent(escape(x.stringify(u)))}catch(u){throw new Error("Malformed UTF-8 data")}},parse:function(u){return x.parse(unescape(encodeURIComponent(u)))}},P=w.BufferedBlockAlgorithm=S.extend({reset:function(){this._data=new k.init,this._nDataBytes=0},_append:function(u){"string"==typeof u&&(u=O.parse(u)),this._data.concat(u),this._nDataBytes+=u.sigBytes},_process:function(f){var y,_=this._data,m=_.words,v=_.sigBytes,b=this.blockSize,w=v/(4*b),S=(w=f?u.ceil(w):u.max((0|w)-this._minBufferSize,0))*b,E=u.min(4*S,v);if(S){for(var C=0;C<S;C+=b)this._doProcessBlock(m,C);y=m.splice(0,S),_.sigBytes-=E}return new k.init(y,E)},clone:function(){var u=S.clone.call(this);return u._data=this._data.clone(),u},_minBufferSize:0}),U=(w.Hasher=P.extend({cfg:S.extend(),init:function(u){this.cfg=this.cfg.extend(u),this.reset()},reset:function(){P.reset.call(this),this._doReset()},update:function(u){return this._append(u),this._process(),this},finalize:function(u){return u&&this._append(u),this._doFinalize()},blockSize:16,_createHelper:function(u){return function(f,y){return new u.init(y).finalize(f)}},_createHmacHelper:function(u){return function(f,y){return new U.HMAC.init(u,y).finalize(f)}}}),b.algo={});return b}(Math);return u}()}).call(this,y(5))},function(u,f,y){u.exports=function(){return y(8)('!function(e){var r={};function __webpack_require__(_){if(r[_])return r[_].exports;var t=r[_]={i:_,l:!1,exports:{}};return e[_].call(t.exports,t,t.exports,__webpack_require__),t.l=!0,t.exports}__webpack_require__.m=e,__webpack_require__.c=r,__webpack_require__.d=function(e,r,_){__webpack_require__.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:_})},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.t=function(e,r){if(1&r&&(e=__webpack_require__(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var _=Object.create(null);if(__webpack_require__.r(_),Object.defineProperty(_,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var t in e)__webpack_require__.d(_,t,function(r){return e[r]}.bind(null,t));return _},__webpack_require__.n=function(e){var r=e&&e.__esModule?function getDefault(){return e.default}:function getModuleExports(){return e};return __webpack_require__.d(r,"a",r),r},__webpack_require__.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=0)}([function(e,r){function toEight(e){return e.length<8?toEight(e="0".concat(e)):e}function dec2hex(e){if(void 0!==e)return toEight(Number(e).toString(16))}self.onmessage=function(e){var r=e.data,_=r[0],t=r[1],n=function crc32(e,r){var _=[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&&(_=new Int32Array(_));for(var t=-1^r,n=(e=new Uint8Array(e)).length,u=0;u<n;u++)t=_[255&(t^e[u])]^t>>>8;return(-1^t)>>>0}(_,0);postMessage([_,dec2hex(n),t],[_])}}]);',null)}},function(u,f){var y;y=function(){return this}();try{y=y||new Function("return this")()}catch(u){"object"==typeof window&&(y=window)}u.exports=y},function(u,f){},function(u,f,y){u.exports=function(u){!function(){var f=u,y=f.lib.Base,_=f.enc.Utf8;f.algo.HMAC=y.extend({init:function(u,f){u=this._hasher=new u.init,"string"==typeof f&&(f=_.parse(f));var y=u.blockSize,m=4*y;f.sigBytes>m&&(f=u.finalize(f)),f.clamp();for(var v=this._oKey=f.clone(),b=this._iKey=f.clone(),w=v.words,S=b.words,k=0;k<y;k++)w[k]^=1549556828,S[k]^=909522486;v.sigBytes=b.sigBytes=m,this.reset()},reset:function(){var u=this._hasher;u.reset(),u.update(this._iKey)},update:function(u){return this._hasher.update(u),this},finalize:function(u){var f=this._hasher,y=f.finalize(u);return f.reset(),f.finalize(this._oKey.clone().concat(y))}})}()}(y(3))},function(u,f,y){"use strict";var _=window.URL||window.webkitURL;u.exports=function(u,f){try{try{var y;try{(y=new(window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder)).append(u),y=y.getBlob()}catch(f){y=new Blob([u])}return new Worker(_.createObjectURL(y))}catch(f){return new Worker("data:application/javascript,"+encodeURIComponent(u))}}catch(u){if(!f)throw Error("Inline worker is not supported");return new Worker(f)}}},function(u,f,y){"use strict";y.r(f),y.d(f,"default",function(){return Et});var _=y(0),m=y.n(_),v={debug:!1,initUploadFileUrl:"{tosDomain}/{oid}?uploads",uploadChunkedUrl:"{tosDomain}/{oid}?partNumber={number}&uploadID={uploadId}",uploadMergeUrl:"{tosDomain}/{oid}?uploadID={uploadId}",getUploadListUrl:"{tosDomain}/{oid}?uploadID={uploadId}",directUploadFileUrl:"{tosDomain}/{oid}",external:{},getSliceFunc:null,uploadSliceCount:5,retryUploadTime:2,retryProcess:!0,retryProcessTime:3,retryTaskTime:2,maxProcessPause:20,schema:"https",useLocalStorage:!0,useFileNameInCacheKey:!1,enableDebugLog:!1,log:{external:{},appId:"",userId:"",video_id:"",upload_video_url:"",upload_id:"",type:"",stage:"",video_size:0,part_count:0,slice_index:0,extra:{},msg:""},replace:{}};function _typeof(u){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},_typeof(u)}function _extends(){return _extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},_extends.apply(null,arguments)}var b=function e(){return(b=Object.assign||function(u){for(var f,y=1,_=arguments.length;y<_;y++)for(var m in f=arguments[y])Object.prototype.hasOwnProperty.call(f,m)&&(u[m]=f[m]);return u}).apply(this,arguments)};function t(u,f){var y="function"==typeof Symbol&&u[Symbol.iterator];if(!y)return u;var _,m,v=y.call(u),b=[];try{for(;(void 0===f||f-- >0)&&!(_=v.next()).done;)b.push(_.value)}catch(u){m={error:u}}finally{try{_&&!_.done&&(y=v.return)&&y.call(v)}finally{if(m)throw m.error}}return b}function index_base_min_i(){for(var u=[],f=0;f<arguments.length;f++)u=u.concat(t(arguments[f]));return u}var w,S,k,E,C=function(){function e(){this._hooks={},this._cache=[],this._hooksCache={}}return e.prototype.on=function(u,f){u&&f&&"function"==typeof f&&(this._hooks[u]||(this._hooks[u]=[]),this._hooks[u].push(f))},e.prototype.once=function(u,f){var y=this;u&&f&&"function"==typeof f&&this.on(u,function o(_){f(_),y.off(u,o)})},e.prototype.off=function(u,f){if(u&&this._hooks[u]&&this._hooks[u].length)if(f){var y=this._hooks[u].indexOf(f);-1!==y&&this._hooks[u].splice(y,1)}else this._hooks[u]=[]},e.prototype.emit=function(u,f,y){if(y){if(!u)return;-1!==this._cache.indexOf(y)?this._emit(u,f):(this._hooksCache.hasOwnProperty(y)||(this._hooksCache[y]={}),this._hooksCache[y].hasOwnProperty(u)||(this._hooksCache[y][u]=[]),this._hooksCache[y][u].push(f))}else this._emit(u,f)},e.prototype._emit=function(u,f){u&&this._hooks[u]&&this._hooks[u].length&&index_base_min_i(this._hooks[u]).forEach(function(u){try{u(f)}catch(u){}})},e.prototype.set=function(u){u&&-1===this._cache.indexOf(u)&&this._cache.push(u)},e}(),x=function r(u){return null!=u&&"[object Object]"==Object.prototype.toString.call(u)},O=(w=+Date.now()+Number((""+Math.random()).slice(2,8)),function(){return w+=1}),P=function a(u){return function(u,f,y){if("string"==typeof u&&"number"==typeof y){var _,m=[];y=y<=25?y:y%25;var v=String.fromCharCode(y+97);_=u.split(v);for(var b=0;b<_.length;b++){var w=parseInt(_[b],y);w=1*w^64;var S=String.fromCharCode(w);m.push(S)}return m.join("")}}(u,0,25)},U=function l(u){var f=document.createElement("a");return f.href=u,f},D=function p(u){var f={};try{var y=U(u).search;(y=y.slice(1)).split("&").forEach(function(u){var y,_,m=u.split("=");m.length&&(y=m[0],_=m[1]);try{f[y]=decodeURIComponent(void 0===_?"":_)}catch(u){f[y]=_}})}catch(u){}return f},I=function h(u){for(var f=0,y=0,_=(u+="").length,m=0;m<_;m++)((f=31*f+u.charCodeAt(y++))>0x7fffffffffff||f<-0x800000000000)&&(f&=0xffffffffffff);return f<0&&(f+=0x7ffffffffffff),f},T=(function(u){var f;f=function i(){function e(){for(var u=0,f={};u<arguments.length;u++){var y=arguments[u];for(var _ in y)f[_]=y[_]}return f}function t(u){return u.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function i(u){function n(){}function r(f,y,_){if("undefined"!=typeof document){"number"==typeof(_=e({path:"/"},n.defaults,_)).expires&&(_.expires=new Date(1*new Date+864e5*_.expires)),_.expires=_.expires?_.expires.toUTCString():"";try{var m=JSON.stringify(y);/^[\{\[]/.test(m)&&(y=m)}catch(u){}y=u.write?u.write(y,f):encodeURIComponent(String(y)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),f=encodeURIComponent(String(f)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var v="";for(var b in _)_[b]&&(v+="; "+b,!0!==_[b]&&(v+="="+_[b].split(";")[0]));return document.cookie=f+"="+y+v}}function s(f,y){if("undefined"!=typeof document){for(var _={},m=document.cookie?document.cookie.split("; "):[],v=0;v<m.length;v++){var b=m[v].split("="),w=b.slice(1).join("=");y||'"'!==w.charAt(0)||(w=w.slice(1,-1));try{var S=t(b[0]);if(w=(u.read||u)(w,S)||t(w),y)try{w=JSON.parse(w)}catch(f){}if(_[S]=w,f===S)break}catch(f){}}return f?_[f]:_}}return n.set=r,n.get=function(u){return s(u,!1)},n.getJSON=function(u){return s(u,!0)},n.remove=function(u,f){r(u,"",e(f,{expires:-1}))},n.defaults={},n.withConverter=i,n}(function(){})},u.exports=f()}(S={exports:{}}),S.exports),A=function d(u,f){try{return T.get(u,{domain:f||document.domain})}catch(u){return""}},z=function g(u,f,y,_){try{var m=_||document.domain,v=+new Date+(y||6048e5);T.set(u,f,{expires:new Date(v),path:"/",domain:m})}catch(u){}},M=function(){function e(){this.cache={}}return e.prototype.setItem=function(u,f){this.cache[u]=f},e.prototype.getItem=function(u){return this.cache[u]},e.prototype.removeItem=function(u){this.cache[u]=void 0},e.prototype.getCookie=function(u,f){return A(u,f)},e.prototype.setCookie=function(u,f,y,_){z(u,f,y,_)},e}(),R={getItem:function getItem(u){try{var f=localStorage.getItem(u),y=f;try{f&&"string"==typeof f&&(y=JSON.parse(f))}catch(u){}return y||{}}catch(u){}return{}},setItem:function setItem(u,f){try{var y="string"==typeof f?f:JSON.stringify(f);localStorage.setItem(u,y)}catch(u){}},removeItem:function removeItem(u){try{localStorage.removeItem(u)}catch(u){}},getCookie:function getCookie(u,f){return A(u,f)},setCookie:function setCookie(u,f,y,_){z(u,f,y,_)},isSupportLS:function(){try{return localStorage.setItem("_ranger-test-key","hi"),localStorage.getItem("_ranger-test-key"),localStorage.removeItem("_ranger-test-key"),!0}catch(u){return!1}}()},N={getItem:function getItem(u){try{var f=sessionStorage.getItem(u),y=f;try{f&&"string"==typeof f&&(y=JSON.parse(f))}catch(u){}return y||{}}catch(u){}return{}},setItem:function setItem(u,f){try{var y="string"==typeof f?f:JSON.stringify(f);sessionStorage.setItem(u,y)}catch(u){}},removeItem:function removeItem(u){try{sessionStorage.removeItem(u)}catch(u){}},getCookie:function getCookie(u,f){return A(u,f)},setCookie:function setCookie(u,f,y,_){z(u,f,y,_)},isSupportSession:function(){try{return sessionStorage.setItem("_ranger-test-key","hi"),sessionStorage.getItem("_ranger-test-key"),sessionStorage.removeItem("_ranger-test-key"),!0}catch(u){return!1}}()},B=function(){function e(u,f){this._storage=f&&"session"===f?N:!u&&R.isSupportLS?R:new M}return e.prototype.getItem=function(u){return this._storage.getItem(u)},e.prototype.setItem=function(u,f){this._storage.setItem(u,f)},e.prototype.getCookie=function(u,f){return this._storage.getCookie(u,f)},e.prototype.setCookie=function(u,f,y,_){this._storage.setCookie(u,f,y,_)},e.prototype.removeItem=function(u){this._storage.removeItem(u)},e}(),L=function(){function e(u,f,y){this.appid=u,this.domain=f,this.userAgent=window.navigator.userAgent,this.appVersion=window.navigator.appVersion,this.cookie_expire=y}return e.prototype.init=function(){var u=window.navigator.userAgent,f=window.navigator.language,y=document.referrer,_=y?U(y).hostname:"",m=D(window.location.href),v=/Mobile|htc|mini|Android|iP(ad|od|hone)/.test(this.appVersion)?"wap":"web";this.utm=function(u,f,y,_){var m=new B(!1),v=new B(!1,"session"),b=u?"_tea_utm_cache_"+u:"_tea_utm_cache",w=u?"_$utm_from_url_"+u:"_$utm_from_url",S={},k=["tr_shareuser","tr_admaster","tr_param1","tr_param2","tr_param3","tr_param4","$utm_from_url"],E={ad_id:Number(f.ad_id)||void 0,campaign_id:Number(f.campaign_id)||void 0,creative_id:Number(f.creative_id)||void 0,utm_source:f.utm_source,utm_medium:f.utm_medium,utm_campaign:f.utm_campaign,utm_term:f.utm_term,utm_content:f.utm_content,tr_shareuser:f.tr_shareuser,tr_admaster:f.tr_admaster,tr_param1:f.tr_param1,tr_param2:f.tr_param2,tr_param3:f.tr_param3,tr_param4:f.tr_param4};try{var C=!1;for(var x in E)E[x]&&(-1!==k.indexOf(x)?(S.hasOwnProperty("tracer_data")||(S.tracer_data={}),S.tracer_data[x]=E[x]):S[x]=E[x],C=!0);if(C)v.setItem(w,"1"),m.setCookie(b,JSON.stringify(S),_,y);else{var O=m.getCookie(b,y);O&&(S=JSON.parse(O))}v.getItem(w)&&(S.hasOwnProperty("tracer_data")||(S.tracer_data={}),S.tracer_data.$utm_from_url=1)}catch(u){return E}return S}(this.appid,m,this.domain,this.cookie_expire);var b=this.browser(),w=this.os();return{browser:b.browser,browser_version:b.browser_version,platform:v,os_name:w.os_name,os_version:w.os_version,userAgent:u,screen_width:window.screen&&window.screen.width,screen_height:window.screen&&window.screen.height,device_model:this.getDeviceModel(w.os_name),language:f,referrer:y,referrer_host:_,utm:this.utm,latest_data:this.last(y,_)}},e.prototype.last=function(u,f){var y="",_="",m="",v=location.hostname,b=!1;if(u&&f&&v!==f){y=u,_=f,b=!0;var w=D(u);w.keyword&&(m=w.keyword)}return{$latest_referrer:y,$latest_referrer_host:_,$latest_search_keyword:m,isLast:b}},e.prototype.browser=function(){var u,f,y="",_=""+parseFloat(this.appVersion),m=this.userAgent;return-1!==m.indexOf("Edge")||-1!==m.indexOf("Edg")?(y="Microsoft Edge",-1!==m.indexOf("Edge")?(u=m.indexOf("Edge"),_=m.substring(u+5)):(u=m.indexOf("Edg"),_=m.substring(u+4))):-1!==(u=m.indexOf("MSIE"))?(y="Microsoft Internet Explorer",_=m.substring(u+5)):-1!==(u=m.indexOf("Lark"))?(y="Lark",_=m.substring(u+5,u+11)):-1!==m.indexOf("Chrome")?-1!==(u=m.indexOf("TTWebView"))?(y="TTWebView",_=m.substring(u+10,u+23)):(-1!==(u=m.indexOf("Chrome"))||-1!==(u=m.indexOf("Chrome")))&&(y="Chrome",_=m.substring(u+7)):-1!==m.indexOf("Safari")?-1!==(u=m.indexOf("Safari"))&&(y="Safari",_=m.substring(u+7),-1!==(u=m.indexOf("Version"))&&(_=m.substring(u+8))):-1!==(u=m.indexOf("Firefox"))&&(y="Firefox",_=m.substring(u+8)),-1!==(f=_.indexOf(";"))&&(_=_.substring(0,f)),-1!==(f=_.indexOf(" "))&&(_=_.substring(0,f)),-1!==(f=_.indexOf(")"))&&(_=_.substring(0,f)),{browser:y,browser_version:_}},e.prototype.os=function(){for(var u="",f="",y=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0|Windows NT 10.1)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Android",r:/Android/},{s:"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)/}],_=0;_<y.length;_++){var m=y[_];if(m.r.test(this.userAgent)){"Mac OS X"===(u=m.s)&&this.isNewIpad()&&(u="iOS");break}}var v,b,w=function r(u,f){var y=u.exec(f);return y&&y[1]?y[1]:""},S=function s(u,f){var y=RegExp("(?:^|[^A-Z0-9-_]|[^A-Z0-9-]_|sprd-)(?:"+u+")","i").exec(f);return y?y.slice(1)[0]:""};switch(/Windows/.test(u)&&(f=w(/Windows (.*)/,u),u="windows"),u){case"Mac OS X":f=S("Mac[ +]OS[ +]X(?:[ /](?:Version )?(\\d+(?:[_\\.]\\d+)+))?",this.userAgent),u="mac";break;case"Android":(b=w(/Android ([\.\_\d]+)/,v=this.userAgent))||(b=w(/Android\/([\.\_\d]+)/,v)),f=b,u="android";break;case"iOS":f=this.isNewIpad()?S("Mac[ +]OS[ +]X(?:[ /](?:Version )?(\\d+(?:[_\\.]\\d+)+))?",this.userAgent):(f=/OS (\d+)_(\d+)_?(\d+)?/.exec(this.appVersion))?f[1]+"."+f[2]+"."+(0|f[3]):"",u="ios"}return{os_name:u,os_version:f}},e.prototype.getDeviceModel=function(u){var f="";try{if("android"===u)navigator.userAgent.split(";").forEach(function(u){u.indexOf("Build/")>-1&&(f=u.slice(0,u.indexOf("Build/")))});else if("ios"===u||"mac"===u||"windows"===u)if(this.isNewIpad())f="iPad";else{var y=navigator.userAgent.replace("Mozilla/5.0 (",""),_=y.indexOf(";");f=y.slice(0,_)}}catch(u){return f.trim()}return f.trim()},e.prototype.isNewIpad=function(){return void 0!==this.userAgent&&"MacIntel"===navigator.platform&&"number"==typeof navigator.maxTouchPoints&&navigator.maxTouchPoints>1},e}(),G={sg:"1fz22z22z1nz21z4mz4bz4bz21z1ez18z1jz1gz49z1kz1az21z4az19z27z22z1cz1mz24z1cz20z21z1cz18z4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz18z1jz1gz24z18z49z1kz1az21z4az19z27z22z1cz1mz24z1cz20z21z1cz18z4az1az1mz1k"},K={va:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",in:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},q={sg:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z49z21z1ez4az22z1gz1iz22z1mz1iz24z4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z49z24z18z4az22z1gz1iz22z1mz1iz24z4az1az1mz1k",in:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z49z24z18z49z23z21z1cz18z21z22z4ez18z4az22z1gz1iz22z1mz1iz24z4az1az1mz1k"},H={sg:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az23z21z4az22z1gz1iz22z1mz1iz24z4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az23z21z4az22z1gz1iz22z1mz1iz4az1az1mz1k"},V="5.0.36_oversea",Q=function(){function e(u,f){this.collector=u,this.config=f,this.eventNameWhiteList=["__bav_page","__bav_beat","__bav_page_statistics","__bav_click","__bav_page_exposure"],this.paramsNameWhiteList=["$inactive","$inline","$target_uuid_list","$source_uuid","$is_spider","$source_id","$is_first_time","_staging_flag"],this.regStr=new RegExp("^[a-zA-Z0-9][a-z0-9A-Z_.-]{1,255}$")}return e.prototype.checkVerify=function(u){var f=this;if(!u||!u.length)return!1;var y=u[0];if(!y)return!1;var _=y.events,m=y.header;if(!_||!_.length)return!1;var v=!0;return _.forEach(function(u){if(!u)return v=!1,void(u.checkEvent="事件异常");f.checkEventName(u.event)||(v=!1,u.checkEvent="事件名不能以 $ or __开头"),f.checkEventParams(u.params)||(v=!1,u.checkParams="属性名不能以 $ or __开头")}),this.checkEventParams(m)||(v=!1),v},e.prototype.checkEventName=function(u){return!!u&&this.calculate(u,"event")},e.prototype.checkEventParams=function(u){var f=u;if("string"==typeof u&&(f=JSON.parse(f)),!Object.keys(f).length)return!0;for(var y in f)return!(!this.calculate(y,"params")||"string"==typeof f[y]&&f[y].length>1024&&(console.warn("params: "+y+" can not over 1024 byte, please check;"),1));return!0},e.prototype.calculate=function(u,f){return-1!==("event"===f?this.eventNameWhiteList:this.paramsNameWhiteList).indexOf(u)||!new RegExp("^\\$").test(u)&&!new RegExp("^__").test(u)||(console.warn(("event"===f?"event":"params")+" name: "+u+" can not start with $ or __, pleace check;"),!1)},e}();!function(u){u.Init="init",u.Config="config",u.Start="start",u.Ready="ready",u.TokenComplete="token-complete",u.TokenStorage="token-storage",u.TokenFetch="token-fetch",u.TokenError="token-error",u.ConfigUuid="config-uuid",u.ConfigWebId="config-webid",u.ConfigDomain="config-domain",u.CustomWebId="custom-webid",u.TokenChange="token-change",u.TokenReset="token-reset",u.ConfigTransform="config-transform",u.EnvTransform="env-transform",u.SessionReset="session-reset",u.SessionResetTime="session-reset-time",u.Event="event",u.Events="events",u.EventNow="event-now",u.CleanEvents="clean-events",u.BeconEvent="becon-event",u.SubmitBefore="submit-before",u.SubmitScuess="submit-scuess",u.SubmitAfter="submit-after",u.SubmitError="submit-error",u.SubmitVerify="submit-verify",u.Stay="stay",u.ResetStay="reset-stay",u.StayReady="stay-ready",u.SetStay="set-stay",u.RouteChange="route-change",u.RouteReady="route-ready",u.Ab="ab",u.AbVar="ab-var",u.AbAllVars="ab-all-vars",u.AbConfig="ab-config",u.AbExternalVersion="ab-external-version",u.AbVersionChangeOn="ab-version-change-on",u.AbVersionChangeOff="ab-version-change-off",u.AbOpenLayer="ab-open-layer",u.AbCloseLayer="ab-close-layer",u.AbReady="ab-ready",u.AbComplete="ab-complete",u.AbTimeout="ab-timeout",u.Profile="profile",u.ProfileSet="profile-set",u.ProfileSetOnce="profile-set-once",u.ProfileUnset="profile-unset",u.ProfileIncrement="profile-increment",u.ProfileAppend="profile-append",u.ProfileClear="profile-clear",u.Autotrack="autotrack",u.AutotrackReady="autotrack-ready",u.CepReady="cep-ready",u.TracerReady="tracer-ready",u.sessionRecord="session-record",u.SessionRecordStart="session-record-start",u.SessionRecordPause="session-record-pause",u.SessionRecordEnd="session-record-end",u.SessionRecordReport="session-record-report"}(k||(k={})),function(u){u.DEBUGGER_MESSAGE="debugger-message",u.DEBUGGER_MESSAGE_SDK="debugger-message-sdk",u.DEBUGGER_MESSAGE_FETCH="debugger-message-fetch",u.DEBUGGER_MESSAGE_FETCH_RESULT="debugger-message-fetch-result",u.DEBUGGER_MESSAGE_EVENT="debugger-message-event",u.DEVTOOL_WEB_READY="devtool-web-ready"}(E||(E={}));var Z=k,Y=void 0,ee=(new Date).getTimezoneOffset(),te=parseInt(""+-ee/60,10),re=60*ee,oe=function(){function t(u,f){this.is_first_time=!0,this.configPersist=!1,this.initConfig=f,this.collect=u;var y=new L(f.app_id,f.cookie_domain||"",f.cookie_expire||6048e5).init();this.eventCheck=new Q(u,f);var _="__tea_cache_first_"+f.app_id;this.configKey="__tea_cache_config_"+f.app_id,this.sessionStorage=new B(!1,"session"),this.localStorage=new B(!1,"local"),this.channelUrl="tcpy"===f.channel_type||"ttp"===f.channel_type?{WEBID_URL:"/v1/user/webid",TOB_URL:"",REPORT_URL:"/v1/list"}:{WEBID_URL:"/webid",TOB_URL:"/tobid",REPORT_URL:"/list"},f.configPersist&&(this.configPersist=!0,this.storage=1===f.configPersist?this.sessionStorage:this.localStorage);var m=this.localStorage.getItem(_);m&&1==m?this.is_first_time=!1:(this.is_first_time=!0,this.localStorage.setItem(_,"1")),this.envInfo={user:{user_unique_id:Y,user_type:Y,user_id:Y,user_is_auth:Y,user_is_login:Y,device_id:Y,web_id:Y,ip_addr_id:Y,user_unique_id_type:Y},header:{app_id:Y,app_name:Y,app_install_id:Y,install_id:Y,app_package:Y,app_channel:Y,app_version:Y,ab_version:Y,os_name:y.os_name,os_version:y.os_version,device_model:y.device_model,ab_client:Y,traffic_type:Y,client_ip:Y,device_brand:Y,os_api:Y,access:Y,language:y.language,region:Y,app_language:Y,app_region:Y,creative_id:y.utm.creative_id,ad_id:y.utm.ad_id,campaign_id:y.utm.campaign_id,log_type:Y,rnd:Y,platform:y.platform,sdk_version:V,sdk_lib:"js",province:Y,city:Y,timezone:te,tz_offset:re,tz_name:Y,sim_region:Y,carrier:Y,resolution:y.screen_width+"x"+y.screen_height,browser:y.browser,browser_version:y.browser_version,referrer:y.referrer,referrer_host:y.referrer_host,width:y.screen_width,height:y.screen_height,screen_width:y.screen_width,screen_height:y.screen_height,utm_term:y.utm.utm_term,utm_content:y.utm.utm_content,utm_source:y.utm.utm_source,utm_medium:y.utm.utm_medium,utm_campaign:y.utm.utm_campaign,tracer_data:JSON.stringify(y.utm.tracer_data),custom:{},wechat_unionid:Y,wechat_openid:Y}},this.ab_version="",this.ab_uuid_cache={},this.evtParams={},this.reportErrorCallback=function(){},this.isLast=!1,this.setCustom(y),this.initDomain(),this.initABData()}return t.prototype.initDomain=function(u){var f=this.initConfig.channel_domain;if(f)this.domain=f;else{var y=u||this.initConfig.channel,_=this.initConfig&&this.initConfig.channel_type?"tcpy"===this.initConfig.channel_type?q[y]:H[y]:G[y];this.domain=P(_)}},t.prototype.setDomain=function(u){this.customDomain=!0,this.domain=u},t.prototype.getDomain=function(u){return this.customDomain||u&&this.initDomain(u),this.domain},t.prototype.initABData=function(){var u="__tea_sdk_ab_version_"+this.initConfig.app_id,f=null;if(this.initConfig.ab_cross){var y=this.localStorage.getCookie(u,this.initConfig.ab_cookie_domain);f=y?JSON.parse(y):null}else f=this.localStorage.getItem(u);this.setAbCache(f)},t.prototype.setAbCache=function(u){this.ab_cache=u},t.prototype.getAbCache=function(){return this.ab_cache},t.prototype.clearAbCache=function(){this.ab_cache={},this.ab_version=""},t.prototype.setAbVersion=function(u){this.ab_version=u},t.prototype.getAbVersion=function(){return this.ab_version},t.prototype.setAbUuidCache=function(u,f){var y=f||this.envInfo.user.user_unique_id;this.ab_uuid_cache[""+y]||(this.ab_uuid_cache[""+y]=[]),-1===this.ab_uuid_cache[""+y].indexOf(u)&&this.ab_uuid_cache[""+y].push(u)},t.prototype.getAbUuidCache=function(u){return this.ab_uuid_cache[""+u]},t.prototype.getUrl=function(u){var f="";switch(u){case"event":f=this.initConfig.report_url||this.channelUrl.REPORT_URL;break;case"webid":f=this.channelUrl.WEBID_URL;break;case"tobid":f=this.channelUrl.TOB_URL}var y="";return this.initConfig.caller&&(y="?sdk_version="+V+"&sdk_name=web&app_id="+this.initConfig.app_id+"&caller="+this.initConfig.caller),""+this.getDomain()+f+y},t.prototype.setCustom=function(u){if(u&&u.latest_data&&u.latest_data.isLast)for(var f in delete u.latest_data.isLast,this.isLast=!0,u.latest_data)this.envInfo.header.custom[f]=u.latest_data[f]},t.prototype.set=function(u){var f=this;Object.keys(u).forEach(function(y){void 0!==u[y]&&null!==u[y]||f.delete(y);try{f.eventCheck.calculate(y,"config")}catch(u){}if("traffic_type"===y&&f.isLast&&(f.envInfo.header.custom.$latest_traffic_source_type=u[y]),"evtParams"===y)f.evtParams=b({},f.evtParams||{},u.evtParams||{});else if("_staging_flag"===y)f.evtParams=b({},f.evtParams||{},{_staging_flag:u._staging_flag});else if("reportErrorCallback"===y&&"function"==typeof u[y])f.reportErrorCallback=u[y];else{var _="",m="";if(y.indexOf(".")>-1){var v=y.split(".");_=v[0],m=v[1]}_?"user"===_||"header"===_?f.envInfo[_][m]=u[y]:f.envInfo.header.custom[m]=u[y]:Object.hasOwnProperty.call(f.envInfo.user,y)?["user_type","ip_addr_id"].indexOf(y)>-1?f.envInfo.user[y]=u[y]?Number(u[y]):u[y]:["user_id","web_id","user_unique_id","user_unique_id_type"].indexOf(y)>-1?f.envInfo.user[y]=u[y]?String(u[y]):u[y]:["user_is_auth","user_is_login"].indexOf(y)>-1?f.envInfo.user[y]=Boolean(u[y]):"device_id"===y&&(f.envInfo.user[y]=u[y]):Object.hasOwnProperty.call(f.envInfo.header,y)?f.envInfo.header[y]=u[y]:f.envInfo.header.custom[y]=u[y]}})},t.prototype.get=function(u){try{return u?"evtParams"===u?this.evtParams:"reportErrorCallback"===u?this[u]:Object.hasOwnProperty.call(this.envInfo.user,u)?this.envInfo.user[u]:Object.hasOwnProperty.call(this.envInfo.header,u)?this.envInfo.header[u]:JSON.parse(JSON.stringify(this.envInfo[u])):JSON.parse(JSON.stringify(this.envInfo))}catch(u){console.log("get config stringify error "),this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}},t.prototype.setStore=function(u){try{if(!this.configPersist)return;var f=this.storage.getItem(this.configKey)||{};if(f&&Object.keys(u).length){var y=_extends(u,f);this.storage.setItem(this.configKey,y)}}catch(u){console.log("setStore error"),this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}},t.prototype.getStore=function(){try{if(!this.configPersist)return null;var u=this.storage.getItem(this.configKey)||{};return u&&Object.keys(u).length?u:null}catch(u){return this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message}),null}},t.prototype.delete=function(u){try{if(!this.configPersist)return;var f=this.storage.getItem(this.configKey)||{};f&&Object.hasOwnProperty.call(f,u)&&(delete f[u],this.storage.setItem(this.configKey,f))}catch(u){this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message}),console.log("delete error")}},t}(),ne=function(){function e(u,f){this.isLog=f||!1,this.name=u||""}return e.prototype.info=function(u){this.isLog&&console.log("%c %s","color: yellow; background-color: black;","[instance: "+this.name+"] "+u)},e.prototype.warn=function(u){this.isLog&&console.warn("[instance: "+this.name+"] "+u)},e.prototype.error=function(u){this.isLog&&console.error("[instance: "+this.name+"] "+u)},e.prototype.throw=function(u){throw this.error(this.name),new Error(u)},e}(),ie=function(){function e(){this.spiderBot=["Baiduspider","googlebot","360Spider","haosouspider","YoudaoBot","Sogou News Spider","Yisouspider","Googlebot","Headless","Applebot","Bingbot","PetalBot"]}return e.prototype.checkSpider=function(u){if(!u.enable_spider)return!1;var f=window.navigator.userAgent;if(!f)return!0;var y=!1;return this.spiderBot.forEach(function(u){-1!==f.indexOf(u)&&(y=!0)}),y},e}(),se=function(){function e(u,f){this.collect=u,this.native=f}var u=e.prototype;return u.bridgeInject=function(){try{return!!this.native&&(AppLogBridge?(console.log("AppLogBridge is injected"),!0):(console.log("AppLogBridge is not inject"),!1))}catch(u){return console.log("AppLogBridge is not inject"),!1}},u.bridgeReady=function(){var u=this;return new Promise(function(f,y){try{u.bridgeInject()?AppLogBridge.hasStarted(function(u){console.log("AppLogBridge is started? : "+u),u?f(!0):y(!1)}):y(!1)}catch(u){console.log("AppLogBridge, error:"+JSON.stringify(u.stack)),y(!1)}})},u.setNativeAppId=function(u){try{AppLogBridge.setNativeAppId(JSON.stringify(u)),console.log("change bridge appid, event report with appid: "+u)}catch(u){console.error("setNativeAppId error")}},u.setConfig=function(u){var f=this;try{Object.keys(u).forEach(function(y){"user_unique_id"===y?f.setUserUniqueId(u[y]):u[y]?f.addHeaderInfo(y,u[y]):f.removeHeaderInfo(y)})}catch(u){console.error("setConfig error")}},u.setUserUniqueId=function(u){try{AppLogBridge.setUserUniqueId(u)}catch(u){console.error("setUserUniqueId error")}},u.addHeaderInfo=function(u,f){try{AppLogBridge.addHeaderInfo(u,f)}catch(u){console.error("addHeaderInfo error")}},u.setHeaderInfo=function(u){try{AppLogBridge.setHeaderInfo(JSON.stringify(u))}catch(u){console.error("setHeaderInfo error")}},u.removeHeaderInfo=function(u){try{AppLogBridge.removeHeaderInfo(u)}catch(u){console.error("removeHeaderInfo error")}},u.reportPv=function(u){this.onEventV3("predefine_pageview",u)},u.onEventV3=function(u,f){try{AppLogBridge.onEventV3(u,f),this.collect.emit(DebuggerMesssge.DEBUGGER_MESSAGE,{type:DebuggerMesssge.DEBUGGER_MESSAGE_EVENT,info:"bridge埋点上报",time:Date.now(),data:[{events:[{event:u,params:f}]}],code:200,status:"success"})}catch(u){console.error("onEventV3 error")}},u.profileSet=function(u){try{AppLogBridge.profileSet(u)}catch(u){console.error("profileSet error")}},u.profileSetOnce=function(u){try{AppLogBridge.profileSetOnce(u)}catch(u){console.error("profileSetOnce error")}},u.profileIncrement=function(u){try{AppLogBridge.profileIncrement(u)}catch(u){console.error("profileIncrement error")}},u.profileUnset=function(u){try{AppLogBridge.profileUnset(u)}catch(u){console.error("profileUnset error")}},u.profileAppend=function(u){try{AppLogBridge.profileAppend(u)}catch(u){console.error("profileAppend error")}},e}(),ae=500,ce=5005;function j(u,f,y,_,m,v,b,w,S){try{var k=new XMLHttpRequest,E=w||"POST";k.open(E,""+u,!0),k.setRequestHeader("Content-Type","application/json; charset=utf-8"),b&&k.setRequestHeader("X-MCS-AppKey",""+b),_&&(k.withCredentials=!0),k.onload=function(){if(m){var u=null;if(k.responseText){try{u=JSON.parse(k.responseText)}catch(f){u={}}m(u,f)}}},y&&(k.timeout=y,k.ontimeout=function(){v&&v(f,ce)}),k.onerror=function(){k.abort(),v&&v(f,ae)},S?k.send(f):k.send(JSON.stringify(f))}catch(u){}}var le=function W(u,f,y,_){try{var m,v=u.match(/\/v\d\//);m=v?v[0]:-1!==u.indexOf("/v1/")?"/v1/":"/v2/";var b=u.split(m)[0];if(!b)return void _(u,f,4001);f.forEach(function(m){var v=function(u){var f="";for(var y in u)u.hasOwnProperty(y)&&void 0!==u[y]&&(f+="&"+y+"="+encodeURIComponent(JSON.stringify(u[y])));return"&"===f[0]?f.slice(1):f}(m),w=new Image(1,1);w.onload=function(){w=null,y&&y()},w.onerror=function(){w=null,_&&_(u,f,4e3)},w.src=b+"/gif?"+v})}catch(y){_&&_(u,f,4002,y.message)}},ue=function J(u,f,y,_,m,v,b,w){var S=window.navigator.userAgent;if(-1===window.navigator.appName.indexOf("Microsoft Internet Explorer")||-1===S.indexOf("MSIE 8.0")&&-1===S.indexOf("MSIE 9.0")){if(b)return window.navigator&&window.navigator.sendBeacon?void(window.navigator.sendBeacon(u,JSON.stringify(f))?m():v(u,f,4003)):void le(u,f,m,v)}else le(u,f,m,v);j(u,f,y,_,m,v,"","",w)},pe=function(){function t(){this.eventLimit=50,this.enable_ttwebid=!1,this.eventCache=[],this.beconEventCache=[]}return t.prototype.apply=function(u,f){var y=this;this.collect=u,this.config=f,this.configManager=u.configManager,this.eventCheck=new Q(u,f),this.cacheStorgae=new B(!0),this.localStorage=new B(!1),this.maxReport=f.max_report||10,this.reportTime=f.reportTime||30,this.timeout=f.timeout||1e5,this.enable_ttwebid=f.enable_ttwebid,this.reportUrl=this.configManager.getUrl("event"),this.eventKey="__tea_cache_events_"+this.configManager.get("app_id"),this.beconKey="__tea_cache_events_becon_"+this.configManager.get("app_id"),this.abKey="__tea_sdk_ab_version_"+this.configManager.get("app_id"),this.collect.on(Z.Ready,function(){y.reportAll(!1)}),this.collect.on(Z.ConfigDomain,function(){y.reportUrl=y.configManager.getUrl("event")}),this.collect.on(Z.Event,function(u){y.event(u)}),this.collect.on(Z.BeconEvent,function(u){y.beconEvent(u)}),this.collect.on(Z.CleanEvents,function(){y.reportAll(!1)}),this.linster()},t.prototype.linster=function(){var u=this;window.addEventListener("unload",function(){u.reportAll(!0)},!1),function(u){navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)?window.addEventListener("pagehide",u,!1):window.addEventListener("beforeunload",u,!1)}(function(){u.reportAll(!0)}),document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&u.reportAll(!0)},!1)},t.prototype.reportAll=function(u){this.report(u),this.reportBecon()},t.prototype.event=function(u){var f=this;try{var y=index_base_min_i(u,this.cacheStorgae.getItem(this.eventKey)||[]);if(this.cacheStorgae.setItem(this.eventKey,y),this.reportTimeout&&clearTimeout(this.reportTimeout),y.length>=this.maxReport)this.report(!1);else{var _=this.reportTime;this.reportTimeout=setTimeout(function(){f.report(!1),f.reportTimeout=null},_)}}catch(u){this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}},t.prototype.beconEvent=function(u){var f=index_base_min_i(u,this.cacheStorgae.getItem(this.beconKey)||[]);this.cacheStorgae.setItem(this.beconKey,f),this.collect.destroyInstance||this.collect.tokenManager.getReady()&&this.collect.sdkReady&&(this.cacheStorgae.removeItem(this.beconKey),this.send(this.split(this.merge(f)),!0))},t.prototype.reportBecon=function(){if(!this.collect.destroyInstance&&this.collect.tokenManager.getReady()&&this.collect.sdkReady){var u=this.cacheStorgae.getItem(this.beconKey)||[];u&&u.length&&(this.cacheStorgae.removeItem(this.beconKey),this.send(this.split(this.merge(u)),!0))}},t.prototype.report=function(u){if(!this.collect.destroyInstance&&this.collect.tokenManager.getReady()&&this.collect.sdkReady){var f=this.cacheStorgae.getItem(this.eventKey)||[];f.length&&(this.cacheStorgae.removeItem(this.eventKey),this.sliceEvent(f,u))}},t.prototype.sliceEvent=function(u,f){if(u.length>this.eventLimit)for(var y=0;y<u.length;y+=this.eventLimit){var _;_=u.slice(y,y+this.eventLimit);var m=this.split(this.merge(_));this.send(m,f)}else m=this.split(this.merge(u)),this.send(m,f)},t.prototype.merge=function(u,f){var y=this,_=this.configManager.get(),m=_.header,v=_.user;m.custom=JSON.stringify(m.custom);var w=this.configManager.get("evtParams"),S=this.configManager.get("user_unique_id_type"),k=u.map(function(u){try{Object.keys(w).length&&!f&&(u.params=b({},w,u.params)),S&&(u.params.$user_unique_id_type=S);var _=y.configManager.getAbCache(),m=y.configManager.getAbUuidCache(v.user_unique_id);if(_&&_.uuid&&_.uuid===v.user_unique_id){var k=y.configManager.getAbVersion();if(y.config.enable_ab_uuid){if(m&&m.length){var C=m.join(",");k&&k.includes(C)&&(u.ab_sdk_version=k)}}else k&&(u.ab_sdk_version=k)}return u.session_id=y.collect.sessionManager.getSessionId(),u.params=JSON.stringify(u.params),u}catch(f){return y.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:f.message}),u}}),C=JSON.parse(JSON.stringify({events:k,user:v,header:m}));C.local_time=Math.floor(Date.now()/1e3),C.user_unique_type=this.config.enable_ttwebid?this.config.user_unique_type:void 0,C.verbose=1;var x=[];return x.push(C),x},t.prototype.split=function(u){return u.map(function(u){var f=[];return f.push(u),f})},t.prototype.send=function(u,f){var y=this;u.length&&(this.config.disable_track_event||u.forEach(function(u){try{var _=JSON.parse(JSON.stringify(u));y.config.filter&&((_=y.config.filter(_))||console.warn("filter must return data !!")),y.collect.eventFilter&&_&&((_=y.collect.eventFilter(_))||console.warn("filterEvent api must return data !!"));var m=_||u,v=JSON.parse(JSON.stringify(m));if(y.eventCheck.checkVerify(v),!m.length)return;y.collect.emit(Z.SubmitBefore,m),y.collect.emit(Z.SubmitVerify,m),ue(y.reportUrl,m,y.timeout,y.enable_ttwebid,function(u,f){u&&0!==u.e?(y.collect.emit(Z.SubmitError,{type:"f_data",eventData:f,errorCode:u.e,response:u}),y.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_EVENT,info:"埋点上报失败",time:Date.now(),data:v,code:u.e,failType:"数据异常",status:"fail"})):(y.collect.emit(Z.SubmitScuess,{eventData:f,res:u}),y.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:v,code:200,status:"success"}))},function(u,f){y.configManager.get("reportErrorCallback")(u,f),y.collect.emit(Z.SubmitError,{type:"f_net",eventData:u,errorCode:f}),y.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_EVENT,info:"埋点上报网络异常",time:Date.now(),data:v,code:f,failType:"网络异常",status:"fail"})},f,!1),y.collect.emit(Z.SubmitAfter,m)}catch(u){console.warn("something error, "+JSON.stringify(u.stack)),y.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}}))},t}(),fe=function $(){return function e(u){return u?(u^16*Math.random()>>u/4).toString(10):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e)}().replace(/-/g,"").slice(0,19)},de=function(){function e(){this.cacheToken={},this.enableCookie=!1,this.enable_ttwebid=!1,this.enableCustomWebid=!1}return e.prototype.apply=function(u,f){var y=this;this.collect=u,this.config=f,this.configManager=this.collect.configManager,this.storage=new B(!1),this.tokenKey="__tea_cache_tokens_"+f.app_id,this.enable_ttwebid=f.enable_ttwebid,this.enableCustomWebid=f.enable_custom_webid,this.collect.on(Z.ConfigUuid,function(u){y.setUuid(u)}),this.collect.on(Z.ConfigWebId,function(u){y.setWebId(u)}),this.enableCookie=f.cross_subdomain,this.expiresTime=f.cookie_expire||6048e5,this.cookieDomain=f.cookie_domain||"",this.checkStorage()},e.prototype.checkStorage=function(){var u=this;if(this.enableCookie){var f=this.storage.getCookie(this.tokenKey,this.cookieDomain);this.cacheToken=f&&"string"==typeof f?JSON.parse(f):{}}else this.cacheToken=this.storage.getItem(this.tokenKey)||{};this.tokenType=this.cacheToken&&this.cacheToken._type_?this.cacheToken._type_:"default","custom"!==this.tokenType||this.enableCustomWebid?this.enableCustomWebid?this.collect.on(Z.CustomWebId,function(){u.tokenReady=!0,u.collect.emit(Z.TokenComplete)}):this.checkEnv()||(this.enable_ttwebid?this.completeTtWid(this.cacheToken):this.check()):this.remoteWebid()},e.prototype.check=function(){this.cacheToken&&this.cacheToken.web_id?this.complete(this.cacheToken):this.config.disable_webid?this.complete({web_id:fe(),user_unique_id:this.configManager.get("user_unique_id")||fe()}):this.remoteWebid()},e.prototype.checkEnv=function(){var u=window.navigator.userAgent;if(-1!==u.indexOf("miniProgram")||-1!==u.indexOf("MiniProgram")){var f=D(window.location.href);return!(!f||!f.Web_ID||(this.complete({web_id:""+f.Web_ID,user_unique_id:this.configManager.get("user_unique_id")||""+f.Web_ID}),0))}return!1},e.prototype.remoteWebid=function(){var u=this,f=this.configManager.getUrl("webid"),y={app_key:this.config.app_key,app_id:this.config.app_id,url:location.href,user_agent:window.navigator.userAgent,referer:document.referrer,user_unique_id:""};this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 发起WEBID请求",logType:"fetch",level:"info",time:Date.now(),data:y});var _=fe();j(f,y,3e5,!1,function(f){var y;f&&0===f.e?(y=f.web_id,u.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"WEBID请求成功",logType:"fetch",level:"info",time:Date.now(),data:f})):(y=_,u.collect.configManager.set({localWebId:_}),u.collect.emit(Z.TokenError),u.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"WEBID请求返回值异常",logType:"fetch",level:"warn",time:Date.now(),data:f}),u.collect.logger.warn("appid: "+u.config.app_id+" get webid error, use local webid~")),u.complete({web_id:u.configManager.get("web_id")||y,user_unique_id:u.configManager.get("user_unique_id")||y})},function(){u.complete({web_id:u.configManager.get("web_id")||_,user_unique_id:u.configManager.get("user_unique_id")||_}),u.collect.configManager.set({localWebId:_}),u.collect.emit(Z.TokenError),u.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"WEBID请求网络异常",logType:"fetch",level:"error",time:Date.now(),data:null}),u.collect.logger.warn("appid: "+u.config.app_id+", get webid error, use local webid~")})},e.prototype.complete=function(u){var f=u.web_id,y=u.user_unique_id;u.timestamp=Date.now(),this.collect.configManager.set({web_id:f,user_unique_id:y}),this.setStorage(u),this.tokenReady=!0,this.collect.emit(Z.TokenComplete)},e.prototype.completeTtWid=function(u){var f=u.user_unique_id||"",y=this.configManager.get("user_unique_id");(y||f)&&this.configManager.set({user_unique_id:y||f}),this.setStorage(u),this.tokenReady=!0,this.collect.emit(Z.TokenComplete)},e.prototype.setUuid=function(u){if(u&&-1===["null","undefined","Null","None"].indexOf(u)){var f=String(u),y=this.configManager.get("user_unique_id"),_=this.cacheToken&&this.cacheToken.user_unique_id;if(f===y&&f===_)return;this.configManager.set({user_unique_id:f}),this.cacheToken||(this.cacheToken={}),this.cacheToken.user_unique_id=f,this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken),this.collect.emit(Z.TokenChange,"uuid"),this.collect.emit(Z.SessionReset)}else this.clearUuid()},e.prototype.clearUuid=function(){this.config.enable_ttwebid||this.configManager.get("web_id")&&(this.configManager.set({user_unique_id:this.configManager.get("web_id")}),this.cacheToken&&this.cacheToken.web_id&&(this.cacheToken.user_unique_id=this.cacheToken.web_id,this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken)),this.collect.emit(Z.TokenReset))},e.prototype.setWebId=function(u){if(u&&!this.config.enable_ttwebid){this.cacheToken&&this.cacheToken.web_id?this.cacheToken.web_id!==u&&(this.cacheToken.user_unique_id=this.cacheToken.web_id===this.cacheToken.user_unique_id?u:this.cacheToken.user_unique_id,this.cacheToken.web_id=u):(this.cacheToken={},this.cacheToken.web_id=u,this.cacheToken.user_unique_id=u),this.cacheToken.timestamp=Date.now();var f=this.configManager.get("web_id"),y=this.configManager.get("user_unique_id");y&&y!==f||(this.configManager.set({user_unique_id:u}),this.collect.emit(Z.TokenChange,"uuid")),f!==u&&(this.configManager.set({web_id:u}),this.collect.emit(Z.TokenChange,"webid")),this.setStorage(this.cacheToken)}},e.prototype.setStorage=function(u){u._type_=this.enableCustomWebid?"custom":"default",delete u["diss".split("").reverse().join("")],this.enableCookie||this.enable_ttwebid?(this.storage.setCookie(this.tokenKey,u,this.expiresTime,this.cookieDomain),this.enable_ttwebid&&(delete u.web_id,this.storage.setItem(this.tokenKey,u))):this.storage.setItem(this.tokenKey,u),this.cacheToken=u},e.prototype.getReady=function(){return this.tokenReady},e.prototype.getTobId=function(){var u=this,f=this.configManager.getUrl("tobid");return new Promise(function(y){j(f,{app_id:u.config.app_id,user_unique_id:u.configManager.get("user_unique_id"),web_id:u.configManager.get("web_id"),user_unique_id_type:u.configManager.get("user_unique_id_type")},3e4,u.enable_ttwebid,function(u){u&&0===u.e?y(u.tobid):y("")},function(){y("")})})},e}(),he=function X(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(u){var f=16*Math.random()|0;return("x"===u?f:3&f|8).toString(16)})},ye=function(){function e(){}return e.prototype.apply=function(u,f){var y=this;this.collect=u,this.storage=new B(!1,"session"),this.sessionKey="__tea_session_id_"+f.app_id,this.expireTime=f.expireTime||18e5,this.disableSession=f.disable_session,this.disableSession||(this.setSessionId(),this.collect.on(Z.SessionReset,function(){y.resetSessionId()}),this.collect.on(Z.SessionResetTime,function(){y.updateSessionIdTime()}))},e.prototype.updateSessionIdTime=function(){var u=this.storage.getItem(this.sessionKey);if(u&&u.sessionId){var f=u.timestamp;Date.now()-f>this.expireTime?u={sessionId:he(),timestamp:Date.now()}:u.timestamp=Date.now(),this.storage.setItem(this.sessionKey,u),this.resetExpTime()}},e.prototype.setSessionId=function(){var u=this,f=this.storage.getItem(this.sessionKey);f&&f.sessionId?f.timestamp=Date.now():f={sessionId:he(),timestamp:Date.now()},this.storage.setItem(this.sessionKey,f),this.sessionExp=setInterval(function(){u.checkEXp()},this.expireTime)},e.prototype.getSessionId=function(){var u=this.storage.getItem(this.sessionKey);return this.disableSession?"":u&&u.sessionId?u.sessionId:""},e.prototype.resetExpTime=function(){var u=this;this.sessionExp&&(clearInterval(this.sessionExp),this.sessionExp=setInterval(function(){u.checkEXp()},this.expireTime))},e.prototype.resetSessionId=function(){var u={sessionId:he(),timestamp:Date.now()};this.storage.setItem(this.sessionKey,u)},e.prototype.checkEXp=function(){var u=this.storage.getItem(this.sessionKey);u&&u.sessionId&&Date.now()-u.timestamp+30>=this.expireTime&&(u={sessionId:he(),timestamp:Date.now()},this.storage.setItem(this.sessionKey,u))},e}(),ge=function(){function e(u,f){this.devToolReady=!1,this.devToolOrigin="*",this.sendAlready=!1,this.collect=u,this.config=f,this.app_id=f.app_id,this.filterEvent=["__bav_page","__bav_beat","__bav_page_statistics","__bav_click","__bav_page_exposure","bav2b_page","bav2b_beat","bav2b_page_statistics","bav2b_click","bav2b_page_exposure","_be_active","predefine_pageview","__profile_set","__profile_set_once","__profile_increment","__profile_unset","__profile_append","predefine_page_alive","predefine_page_close","abtest_exposure"],f.enable_debug&&this.load()}return e.prototype.loadScript=function(u){try{var f=document.createElement("script");f.src=u,f.onerror=function(){console.log("load DevTool render fail")},f.onload=function(){console.log("load DevTool render success")},document.getElementsByTagName("body")[0].appendChild(f)}catch(u){console.log("devTool load fail, "+u.message)}},e.prototype.load=function(){try{this.loadBaseInfo(),this.loadHook();var u=D(window.location.href);if(!u.open_devtool_web||parseInt(u.app_id)!==this.app_id)return;this.addLintener(),this.loadDebuggerModule(),this.loadDevTool()}catch(u){console.log("debug fail, "+u.message)}},e.prototype.loadDevTool=function(){this.loadScript("https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/devtool/debug-web.js")},e.prototype.loadBaseInfo=function(){var u=this;this.info=[{title:"基本信息",type:1,infoName:{app_id:this.config.app_id,channel:this.config.channel,"上报域名":this.collect.configManager.getDomain(),"SDK版本":V,"SDK引入方式":"npm"}},{title:"用户信息",type:2,infoName:{uuid:this.collect.configManager.get("user").user_unique_id||"",web_id:this.collect.configManager.get("user").web_id||"",ssid:"点击获取SSID"}},{title:"公共参数信息",type:2,infoName:{"浏览器":this.collect.configManager.get("browser"),"浏览器版本":this.collect.configManager.get("browser_version"),"平台":this.collect.configManager.get("platform"),"设备型号":this.collect.configManager.get("device_model"),"操作系统":this.collect.configManager.get("os_name"),"操作系统版本":this.collect.configManager.get("os_version"),"屏幕分辨率":this.collect.configManager.get("os_version"),"来源":this.collect.configManager.get("referrer"),"自定义信息":""}},{title:"配置信息",type:3,infoName:{"全埋点":!!this.config.autotrack,"停留时长":!!this.config.enable_stay_duration}},{title:"A/B配置信息",type:4,infoName:{"A/B实验":!!this.config.enable_ab_test}},{title:"客户端信息",type:3,infoName:{"打通开关":!!this.config.Native}}],this.log=[],this.event=[],this.collect.on(Z.Ready,function(){u.info[1].infoName.uuid=u.collect.configManager.get("user").user_unique_id,u.info[1].infoName.web_id=u.collect.configManager.get("user").web_id,u.info[2].infoName["自定义信息"]=JSON.stringify(u.collect.configManager.get("custom")),u.config.enable_ab_test&&(u.info[4].infoName["已曝光VID"]=u.collect.configManager.getAbVersion(),u.info[4].infoName["A/B域名"]=u.config.ab_channel_domain||P(K[u.config.channel]),u.info[4].infoName["全部配置"]=u.collect.configManager.getAbData()),u.config.Native&&(u.info[5].infoName["是否打通"]=!!u.collect.bridgeReport)})},e.prototype.loadHook=function(){var u=this;this.collect.on(E.DEBUGGER_MESSAGE,function(f){switch(f.type){case E.DEBUGGER_MESSAGE_SDK:var y={time:f.time,type:f.logType||"sdk",level:f.level,name:f.info,show:!0,levelShow:!0,needDesc:!!f.data};return f.data&&(y.desc={content:JSON.stringify(f.data)}),u.updateLog(y),f.secType&&"AB"===f.secType?(u.info[4].infoName["已曝光VID"]=u.collect.configManager.getAbVersion(),u.info[4].infoName["全部配置"]=u.collect.configManager.getAbData()):"USER"===f.secType&&(u.info[1].infoName.uuid=u.collect.configManager.get("user").user_unique_id,u.info[1].infoName.web_id=u.collect.configManager.get("user").web_id),void u.updateInfo();case E.DEBUGGER_MESSAGE_EVENT:if(f.data&&f.data.length){var _=f.data[0],m=_.events;if(!m.length)return;m.forEach(function(y){y.checkShow=!0,y.searchShow=!0,y.success=f.status,y.type=-1!==u.filterEvent.indexOf(y.event)?"sdk":"cus",y.type=u.collect.bridgeReport?"bridge":y.type,y.info="","fail"===f.status&&(y.info={message:"code: "+f.code+", msg: "+f.failType})}),u.updateEvent(_)}return}})},e.prototype.addLintener=function(){var u=this;window.addEventListener("message",function(f){if(f.origin===location.origin){if(f&&f.data&&"devtool:web:ready"===f.data.type){if(u.devToolOrigin=f.origin,u.devToolReady=!0,u.sendAlready)return;console.log("inittttt"),u.sendData("devtool:web:init",{info:u.info,log:u.log,event:u.event}),u.sendAlready=!0}f&&f.data&&"devtool:web:ssid"===f.data.type&&u.collect.getToken(function(f){u.info[1].infoName.ssid=f.tobid,u.updateInfo()})}})},e.prototype.sendData=function(u,f){try{var y={type:u,payload:f};(window.opener||window.parent).postMessage(y,this.devToolOrigin)}catch(u){}},e.prototype.updateInfo=function(){this.devToolReady&&this.sendData("devtool:web:info",this.info)},e.prototype.updateLog=function(u){this.devToolReady?this.sendData("devtool:web:log",u):this.log.push(u)},e.prototype.updateEvent=function(u){this.devToolReady?this.sendData("devtool:web:event",u):this.event.push(u)},e.prototype.loadDebuggerModule=function(){var u=document.head||document.getElementsByTagName("head")[0],f=document.createElement("style");f.appendChild(document.createTextNode("#debugger-applog-web {\n position: absolute;\n width: 90px;\n height: 30px;\n background: #23c243;\n border-radius: 6px;\n color: #fff;\n font-size: 12px;\n bottom: 5%;\n right: 10%;\n text-align: center;\n line-height: 30px;\n cursor: pointer;\n z-index:100;\n }")),u.appendChild(f);var y=document.createElement("div");y.innerHTML='<div id="debugger-applog-web" class="debugger-applog-web">AppLog调试</div>';var _=document.createElement("div");_.innerHTML='<div id="debugger-container" class="debugger-container"></div>',document.getElementsByTagName("body")[0].appendChild(y),document.getElementsByTagName("body")[0].appendChild(_),document.getElementById("debugger-applog-web").addEventListener("click",function(){(window.opener||window.parent).postMessage({type:"devtool:web:open-draw"},location.origin)})},e}(),_e=function(){function t(u){this.disableAutoPageView=!1,this.bridgeReport=!1,this.staging=!1,this.pluginInstances=[],this.sended=!1,this.started=!1,this.destroyInstance=!1,this.sdkReady=!1,this.adapters={},this.loadType="base",this.name=u,this.hook=new C,this.remotePlugin=new Map,this.Types=Z,this.adapters.fetch=j,this.adapters.storage=B}return t.usePlugin=function(u,f,y){if(f){for(var _=!1,m=0,v=t.plugins.length;m<v;m++)if(t.plugins[m].name===f){t.plugins[m].plugin=u,t.plugins[m].options=y||{},_=!0;break}_||t.plugins.push({name:f,plugin:u,options:y})}else t.plugins.push({plugin:u})},t.prototype.usePlugin=function(u,f,y){u&&("full"===this.loadType&&this.remotePlugin.get(u)?console.info("your sdk version has "+u+" already ~"):f?"string"==typeof f?this.remotePlugin.get(u)||this.remotePlugin.set(u,{src:f,call:y}):this.remotePlugin.get(u)||this.remotePlugin.set(u,{instance:f}):this.remotePlugin.get(u)||this.remotePlugin.set(u,"sdk"))},t.prototype.init=function(u){var f,y=this;if(this.logger=new ne(this.name,u.log),this.inited)this.logger.warn("[instance: "+this.name+"], every instance's api: init, can be call only one time!");else if(u&&x(u))if(u.app_id&&"number"==typeof(f=u.app_id)&&!isNaN(f))if(!u.app_key||function(u){return"string"==typeof u}(u.app_key)){var _=u.channel_type&&"tcpy"===u.channel_type?["sg","va","in"]:["sg","va"];u.channel_domain||-1!==_.indexOf(u.channel)||(this.logger.warn("channel must "+_.join(" ,")+"!!!"),u.channel="sg"),this.spider=new ie,this.spider.checkSpider(u)?this.logger.warn("The current environment may be a spider, can not report!"):(this.logger=new ne(this.name,u.log),this.appBridge=new se(this,u.enable_native),this.bridgeReport=this.appBridge.bridgeInject(),this.configManager=new oe(this,u),this.debugger=new ge(this,u),this.initConfig=u,this.emit(Z.Init),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 执行INIT",data:u,level:"info",time:Date.now()}),u.disable_auto_pv&&(this.disableAutoPageView=!0),this.bridgeReport||(this.configManager.set({app_id:u.app_id}),this.eventManager=new pe,this.tokenManager=new de,this.sessionManager=new ye,Promise.all([new Promise(function(u){y.once(Z.TokenComplete,function(){u(!0)})}),new Promise(function(u){y.once(Z.Start,function(){u(!0)})})]).then(function(){try{t.plugins.reduce(function(u,f){var _=f.plugin,m=f.options,v=_extends(y.initConfig,m),b=new _;return b.apply(y,v),u.push(b),u},y.pluginInstances)}catch(u){y.logger.log("load plugin error, "+u.message),y.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}y.sdkReady=!0,y.emit(Z.Ready),y.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 初始化完成",time:Date.now(),level:"info",data:y.configManager.get("user")}),y.logger.info("appid: "+u.app_id+", userInfo:"+JSON.stringify(y.configManager.get("user"))),y.logger.info("appid: "+u.app_id+", sdk is ready, version is "+V+", you can report now !!!"),u.disable_auto_pv&&(y.disableAutoPageView=!0);try{("full"===y.loadType&&u.enable_ab_test||u.autotrack)&&(window.opener||window.parent).postMessage("[tea-sdk]ready","*")}catch(u){y.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}y.pageView(),y.on(Z.TokenChange,function(f){"webid"===f&&y.pageView(),y.logger.info("appid: "+u.app_id+" token change, new userInfo:"+JSON.stringify(y.configManager.get("user"))),y.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 设置了用户信息",time:Date.now(),secType:"USER",level:"info",data:y.configManager.get("user")})}),y.on(Z.TokenReset,function(){y.logger.info("appid: "+u.app_id+" token reset, new userInfo:"+JSON.stringify(y.configManager.get("user"))),y.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 重置了用户信息",time:Date.now(),secType:"USER",level:"info",data:y.configManager.get("user")})}),y.on(Z.RouteChange,function(f){f.init||u.disable_route_report||y.pageView()})}),this.tokenManager.apply(this,u),this.eventManager.apply(this,u),this.sessionManager.apply(this,u)),this.inited=!0)}else this.logger.warn("app_key param is error, must be string, please check!");else this.logger.warn("app_id param is error, must be number, please check!");else this.logger.warn("init params error,please check")},t.prototype.config=function(u){if(this.inited)if(u&&x(u))if(this.bridgeReport)this.appBridge.setConfig(u);else{u._staging_flag&&1===u._staging_flag&&(this.staging=!0),u.disable_auto_pv&&(this.disableAutoPageView=!0,delete u.disable_auto_pv);var f=b({},u);if(this.initConfig&&this.initConfig.configPersist){var y=this.configManager.getStore();y&&(f=_extends(y,u)),this.configManager.setStore(u)}f.web_id,f.user_unique_id;var _=function(u,f){var y={};for(var _ in u)Object.prototype.hasOwnProperty.call(u,_)&&f.indexOf(_)<0&&(y[_]=u[_]);if(null!=u&&"function"==typeof Object.getOwnPropertySymbols){var m=0;for(_=Object.getOwnPropertySymbols(u);m<_.length;m++)f.indexOf(_[m])<0&&(y[_[m]]=u[_[m]])}return y}(f,["web_id","user_unique_id"]);f.hasOwnProperty("web_id")&&this.emit(Z.ConfigWebId,f.web_id),f.hasOwnProperty("user_unique_id")&&this.emit(Z.ConfigUuid,f.user_unique_id),this.configManager.set(_),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 执行CONFIG",level:"info",time:Date.now(),data:f})}else this.logger.warn("config params is error, please check");else this.logger.warn("config must be use after function init")},t.prototype.setDomain=function(u){this.configManager&&this.configManager.setDomain(u),this.emit(Z.ConfigDomain)},t.prototype.getConfig=function(u){return this.configManager.get(u)},t.prototype.send=function(){this.start()},t.prototype.start=function(){this.inited&&!this.sended&&(this.sended=!0,this.emit(Z.Start),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 执行START",level:"info",time:Date.now()}),this.bridgeReport&&(this.pageView(),this.emit(Z.Ready)))},t.prototype.event=function(u,f){var y=this;try{var _=[];if(Array.isArray(u))u.forEach(function(u){var f=y.processEvent(u[0],u[1]||{});f&&_.push(f)});else{var m=this.processEvent(u,f);if(!m)return;_.push(m)}this.bridgeReport?_.forEach(function(u){var f=u.event,_=u.params;y.appBridge.onEventV3(f,JSON.stringify(_))}):_.length&&(this.emit(Z.Event,_),this.emit(Z.SessionResetTime))}catch(u){this.logger.warn("something error, please check"),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}},t.prototype.beconEvent=function(u,f){if(Array.isArray(u))this.logger.warn("beconEvent not support batch report, please check");else{var y=[],_=this.processEvent(u,f||{});_&&(y.push(_),y.length&&(this.emit(Z.BeconEvent,y),this.emit(Z.SessionResetTime)))}},t.prototype.processEvent=function(u,f){void 0===f&&(f={});try{if(!u)return this.logger.warn("eventName is null, please check"),null;var y=u;/^event\./.test(u)&&(y=u.slice(6));var _=f;"object"!=_typeof(_)&&(_={}),_.profile?delete _.profile:_.event_index=O();var m=void 0;return _.local_ms?(m=_.local_ms,delete _.local_ms):m=+new Date,{event:y,params:_,local_time_ms:m,is_bav:this.initConfig&&this.initConfig.autotrack?1:0}}catch(y){return this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:y.message}),{event:u,params:f}}},t.prototype.filterEvent=function(u){this.eventFilter=u},t.prototype.on=function(u,f){this.hook.on(u,f)},t.prototype.once=function(u,f){this.hook.once(u,f)},t.prototype.off=function(u,f){this.hook.off(u,f)},t.prototype.emit=function(u,f,y){this.hook.emit(u,f,y)},t.prototype.set=function(u){this.hook.set(u)},t.prototype.pageView=function(){this.disableAutoPageView||this.predefinePageView()},t.prototype.predefinePageView=function(u){if(void 0===u&&(u={}),this.inited){var f={title:document.title||location.pathname,url:location.href,url_path:location.pathname,time:Date.now(),referrer:window.document.referrer,$is_first_time:""+(this.configManager&&this.configManager.is_first_time||!1)},y=b({},f,u);this.event("predefine_pageview",y)}else this.logger.warn("predefinePageView should call after init")},t.prototype.clearEventCache=function(){this.emit(Z.CleanEvents)},t.prototype.setWebIDviaUnionID=function(u){if(u){var f=I(u);this.config({web_id:""+f,wechat_unionid:u}),this.emit(Z.CustomWebId)}},t.prototype.setWebId=function(u){this.config({web_id:""+u})},t.prototype.setWebIDviaOpenID=function(u){if(u){var f=I(u);this.config({web_id:""+f,wechat_openid:u}),this.emit(Z.CustomWebId)}},t.prototype.setNativeAppId=function(u){this.bridgeReport&&this.appBridge.setNativeAppId(u)},t.prototype.resetStayDuration=function(u,f,y){this.emit(Z.ResetStay,{url_path:u,title:f,url:y},Z.Stay)},t.prototype.resetStayParams=function(u,f,y){void 0===u&&(u=""),void 0===f&&(f=""),void 0===y&&(y=""),this.emit(Z.SetStay,{url_path:u,title:f,url:y},Z.Stay)},t.prototype.getToken=function(u,f){var y=this;if(this.inited){var _=!1,m=function r(f){if(!_){_=!0;var r=y.configManager.get().user;return f&&(r.tobid=f,r["diss".split("").reverse().join("")]=f),u(b({},r))}},v=function s(){y.tokenManager.getTobId().then(function(u){m(u)})};this.sdkReady?v():(f&&setTimeout(function(){m()},f),this.on(Z.Ready,function(){v()}))}else this.logger.warn("predefinePageView should call after init")},t.prototype.profileSet=function(u){this.bridgeReport?this.appBridge.profileSet(JSON.stringify(u)):this.emit(Z.ProfileSet,u,Z.Profile),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileSet",level:"info",time:Date.now(),data:u})},t.prototype.profileSetOnce=function(u){this.bridgeReport?this.appBridge.profileSetOnce(JSON.stringify(u)):this.emit(Z.ProfileSetOnce,u,Z.Profile),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileSetOnce",level:"info",time:Date.now(),data:u})},t.prototype.profileIncrement=function(u){this.bridgeReport?this.appBridge.profileIncrement(JSON.stringify(u)):this.emit(Z.ProfileIncrement,u,Z.Profile),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileIncrement",level:"info",time:Date.now(),data:u})},t.prototype.profileUnset=function(u){this.bridgeReport?this.appBridge.profileUnset(u):this.emit(Z.ProfileUnset,u,Z.Profile),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileUnset",level:"info",time:Date.now(),data:u})},t.prototype.profileAppend=function(u){this.bridgeReport?this.appBridge.profileAppend(JSON.stringify(u)):this.emit(Z.ProfileAppend,u,Z.Profile),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileAppend",level:"info",time:Date.now(),data:u})},t.prototype.setExternalAbVersion=function(u){this.emit(Z.AbExternalVersion,"string"==typeof u&&u?(""+u).trim():null,Z.Ab)},t.prototype.getVar=function(u,f,y,_){this.emit(Z.AbVar,{name:u,defaultValue:f,callback:y,uuid:_},Z.Ab)},t.prototype.getABconfig=function(u,f){this.emit(Z.AbConfig,{params:u,callback:f},Z.Ab)},t.prototype.getAbSdkVersion=function(){return this.configManager.getAbVersion()},t.prototype.onAbSdkVersionChange=function(u){var f=this;return this.emit(Z.AbVersionChangeOn,u,Z.Ab),function(){f.emit(Z.AbVersionChangeOff,u,Z.Ab)}},t.prototype.offAbSdkVersionChange=function(u){this.emit(Z.AbVersionChangeOff,u,Z.Ab)},t.prototype.openOverlayer=function(){this.emit(Z.AbOpenLayer,"",Z.Ab)},t.prototype.closeOverlayer=function(){this.emit(Z.AbCloseLayer,"",Z.Ab)},t.prototype.getAllVars=function(u){this.emit(Z.AbAllVars,u,Z.Ab)},t.prototype.autoInitializationRangers=function(u){var f,y,_,m,v,b,w,S;y=(f=u).app_id,_=f.channel,m=f.onTokenReady,v=G[_]+"/webid",b=new B(!1),w="__tea_cache_tokens_"+y,(S=b.getItem(w))&&S.web_id?m(S.web_id):ue(v,{app_key:"",app_id:y,url:location.href,user_agent:window.navigator.userAgent,referer:document.referrer},3e3,!1,function(u){if(u&&0===u.e){m(u.web_id);var f={web_id:u.web_id,user_unique_id:u.web_id,timestamp:Date.now()};b.setItem(w,f)}else m("")},function(){m("")},!0)},t.prototype.destoryInstace=function(){this.destroyInstance||(this.destroyInstance=!0,this.off(Z.TokenComplete))},t.plugins=[],t}(),me=function(){function e(){}return e.prototype.apply=function(u,f){var y=this,_=u.adapters.fetch;if(f.event_verify_url)if("string"==typeof f.event_verify_url){if(this.url=f.event_verify_url+"/v1/list_test",this.url){var m=u.Types;u.on(m.SubmitBefore,function(u){_(y.url,u,3e4)})}}else console.log("please use correct et_test url")},e}(),ve=function(){function t(){}return t.prototype.apply=function(u,f){var y=this;this.collect=u,this.config=f,this.duration=6e4,this.reportUrl=u.configManager.getDomain()+"/profile/list";var _=u.Types,m=u.adapters.fetch;this.eventCheck=new Q(u,f),this.fetch=m,this.cache={},this.collect.on(_.ProfileSet,function(u){y.setProfile(u)}),this.collect.on(_.ProfileSetOnce,function(u){y.setOnceProfile(u)}),this.collect.on(_.ProfileUnset,function(u){y.unsetProfile(u)}),this.collect.on(_.ProfileIncrement,function(u){y.incrementProfile(u)}),this.collect.on(_.ProfileAppend,function(u){y.appendProfile(u)}),this.collect.on(_.ProfileClear,function(){y.cache={}}),this.ready(_.Profile)},t.prototype.ready=function(u){var f=this;if(this.collect.set(u),this.collect.hook._hooksCache.hasOwnProperty(u)){var y=this.collect.hook._hooksCache[u];if(!Object.keys(y).length)return;var _=function o(u){y[u].length&&y[u].forEach(function(y){f.collect.hook.emit(u,y)})};for(var m in y)_(m)}},t.prototype.report=function(u,f){void 0===f&&(f={});try{if(this.config.disable_track_event)return;var y=[];y.push(this.collect.processEvent(u,f));var _=this.collect.eventManager.merge(y);this.fetch(this.reportUrl,_),this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:_,code:200,status:"success"})}catch(u){this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}},t.prototype.setProfile=function(u){var f=this.formatParams(u);f&&Object.keys(f).length&&(this.pushCache(f),this.report("__profile_set",b({},f,{profile:!0})))},t.prototype.setOnceProfile=function(u){var f=this.formatParams(u,!0);f&&Object.keys(f).length&&(this.pushCache(f),this.report("__profile_set_once",b({},f,{profile:!0})))},t.prototype.incrementProfile=function(u){u?this.report("__profile_increment",b({},u,{profile:!0})):console.warn("please check the params, must be object!!!")},t.prototype.unsetProfile=function(u){if(u){var f={};f[u]="1",this.report("__profile_unset",b({},f,{profile:!0}))}else console.warn("please check the key, must be string!!!")},t.prototype.appendProfile=function(u){if(u){var f={};for(var y in u)"string"==typeof u[y]||"Array"===Object.prototype.toString.call(u[y]).slice(8,-1)?f[y]=u[y]:console.warn("please check the value of param: "+y+", must be string or array !!!");Object.keys(f).length&&this.report("__profile_append",b({},f,{profile:!0}))}else console.warn("please check the params, must be object!!!")},t.prototype.pushCache=function(u){var f=this;Object.keys(u).forEach(function(y){f.cache[y]={val:f.clone(u[y]),timestamp:Date.now()}})},t.prototype.formatParams=function(u,f){var y=this;void 0===f&&(f=!1);try{if(!u||"[object Object]"!==Object.prototype.toString.call(u))return void console.warn("please check the params type, must be object !!!");var _={};for(var m in u)"string"==typeof u[m]||"number"==typeof u[m]||"Array"===Object.prototype.toString.call(u[m]).slice(8,-1)?_[m]=u[m]:console.warn("please check the value of params:"+m+", must be string,number,Array !!!");var v=Object.keys(_);if(!v.length)return;if(!this.eventCheck.checkEventParams(_))return;var b=Date.now();return v.filter(function(_){var m=y.cache[_];return f?!m:!(m&&y.compare(m.val,u[_])&&b-m.timestamp<y.duration)}).reduce(function(u,f){return u[f]=_[f],u},{})}catch(u){this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message}),console.log("error")}},t.prototype.compare=function(u,f){try{return JSON.stringify(u)===JSON.stringify(f)}catch(u){return this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message}),!1}},t.prototype.clone=function(u){try{return JSON.parse(JSON.stringify(u))}catch(f){return this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:f.message}),u}},t.prototype.unReady=function(){console.warn("sdk is not ready, please use this api after start")},t}(),be=function(){function e(){var u=this;this.setInterval=function(){u.clearIntervalFunc=function c(u,f){void 0===u&&(u=function e(){}),void 0===f&&(f=1e3);var y,_=Date.now()+f;return y=window.setTimeout(function n(){var m=Date.now()-_;u(),_+=f,y=window.setTimeout(n,Math.max(0,f-m))},f),function(){window.clearTimeout(y)}}(function(){u.isSessionhasEvent&&u.endCurrentSession()},u.sessionInterval)},this.clearInterval=function(){u.clearIntervalFunc&&u.clearIntervalFunc()}}return e.prototype.apply=function(u,f){var y=this;if(this.collect=u,!f.disable_heartbeat){this.sessionInterval=6e4,this.startTime=0,this.lastTime=0,this.setInterval();var _=this.collect.Types;this.collect.on(_.SessionReset,function(){y.process()})}},e.prototype.endCurrentSession=function(){this.collect.event("_be_active",{start_time:this.startTime,end_time:this.lastTime,url:window.location.href,referrer:window.document.referrer,title:document.title||location.pathname}),this.isSessionhasEvent=!1,this.startTime=0},e.prototype.process=function(){this.isSessionhasEvent||(this.isSessionhasEvent=!0,this.startTime=+new Date);var u=this.lastTime||+new Date;this.lastTime=+new Date,this.lastTime-u>this.sessionInterval&&(this.clearInterval(),this.endCurrentSession(),this.setInterval())},e}(),we=function(){function e(){}return e.prototype.apply=function(u,f){var y=this;if(this.collect=u,this.config=f,!this.config.channel_domain&&!f.disable_track_event&&!f.disable_sdk_monitor){var _=u.adapters.fetch;this.fetch=_,this.url=u.configManager.getUrl("event");var m=this.collect.Types;this.collect.on(m.Ready,function(){y.sdkOnload()}),this.collect.on(m.SubmitError,function(u){var f=u.type,_=u.eventData,m=u.errorCode;"f_data"===f&&y.sdkError(_,m)})}},e.prototype.sdkOnload=function(){var u=this;try{var f=this.collect.configManager.get(),y=f.header,_=f.user,m=y.app_id,v=y.app_name,b=y.sdk_version,w=_.web_id,S={events:[{event:"onload",params:JSON.stringify({app_id:m,app_name:v||"",sdk_version:b,sdk_type:"npm",sdk_config:this.config,sdk_desc:"TOC_OVERSEA"}),local_time_ms:Date.now()}],user:{user_unique_id:w},header:{}};setTimeout(function(){u.fetch(u.url,[S],3e4,!1,function(){},function(){},"566f58151b0ed37e")},16)}catch(u){}},e.prototype.sdkError=function(u,f){var y=this;try{var _=u[0],m=_.user,v=_.header,b=[];u.forEach(function(u){u.events.forEach(function(u){b.push(u)})});var w={events:b.map(function(u){return{event:"on_error",params:JSON.stringify({error_code:f,app_id:v.app_id,app_name:v.app_name||"",error_event:u.event,sdk_version:v.sdk_version,local_time_ms:u.local_time_ms,tea_event_index:Date.now(),params:u.params,header:JSON.stringify(v),user:JSON.stringify(m)}),local_time_ms:Date.now()}}),user:{user_unique_id:m.user_unique_id},header:{}};setTimeout(function(){y.fetch(y.url,[w],3e4,!1,function(){},function(){},"566f58151b0ed37e")},16)}catch(u){}},e}(),Se={autotrack:{src:{sg:"https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/autotrack.js",va:"https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/autotrack.js"},object:"LogAutoTrack"},ab:{src:{sg:"https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/ab.js",va:"https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/ab.js"},object:"LogAb"},stay:{src:{sg:"https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/stay.js",va:"https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/stay.js"},object:"LogStay"},route:{src:{sg:"https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/route.js",va:"https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/route.js"},object:"LogRoute"},cep:{src:{sg:"https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/cep.js",va:"https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/cep.js"},object:"LogCep"},tracer:{src:{sg:"https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/tracer.js",va:"https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/tracer.js"},object:"LogTracer"},visual:{src:{sg:"https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/visual.js",va:"https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/visual.js"},object:"LogVisual"}},ke="undefined"!=typeof window?(window.LogPluginObject||(window.LogPluginObject={}),window.LogPluginObject):null,Ee=function(){function e(){}return e.prototype.apply=function(u,f){this._plugin={},this.config=f,this.collect=u,this.channel=f.channel||"cn",this.loadExtend()},e.prototype.loadExtend=function(){var u=this;try{this.collect.remotePlugin.forEach(function(f,y){if("sdk"===f)if(Se.hasOwnProperty(y)){var _=Se[y].object,m=""+Se[y].src[u.channel];u.exist(y,_,m)}else console.warn("your "+y+" is not exist,please check plugin name");else"object"==_typeof(f)&&(f.src?u.exist(y,f.call,f.src):u.process(y,f.instance,"INSTANCE"))})}catch(u){this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message}),console.log("load extend error")}},e.prototype.exist=function(u,f,y){var _=this;ke[f]?(this.process(u,ke[f]),console.log("已有"+u+"插件,避免重复加载~")):this.loadPlugin(u,y,function(){_.process(u,ke[f]),console.log(" %c %s %s %s","color: yellow; background-color: black;","–","load plugin:"+u+" success","-")},function(){console.log(" %c %s %s %s","color: red; background-color: yellow;","–","load plugin:"+u+" error","-")})},e.prototype.process=function(u,f,y){try{if(y){var _=new f;_.apply&&_.apply(this.collect,this.config),console.log("excude "+u+" success")}else f&&f(this.collect,this.config)}catch(f){this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:f.message}),console.log("excude "+u+" error, message:"+f.message)}},e.prototype.loadPlugin=function(u,f,y,_){var m=this;try{var v=document.createElement("script");v.src=f,this._plugin[u]||(this._plugin[u]=[]),this._plugin[u].push(y),v.onerror=function(){_(f)},v.onload=function(){m._plugin[u].forEach(function(u){u()})},document.getElementsByTagName("head")[0].appendChild(v)}catch(u){this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}},e}();_e.usePlugin(Ee,"extend"),_e.usePlugin(me,"et"),_e.usePlugin(ve,"profile"),_e.usePlugin(be,"heartbeat"),_e.usePlugin(we,"monitor");var Ce=new _e("default"),xe=Ce,Oe={browserError:1e3,crc32:1e3,preUpload:1001,initUploadID:1002,process:1003,fileMerge:1004,complete:1005},Pe="video",Ue="image",De={video:"video_upload",image:"image_upload",object:"object_upload"},Ie=1,Te=2,Ae=3,je="vod",ze={"ap-singapore-1":"ap-singapore-1","ap-southeast-1":"ap-southeast-1"},Me="https://vod.byteplusapi.com",Re=5242880;function LoggerV5_typeof(u){return LoggerV5_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},LoggerV5_typeof(u)}function LoggerV5_extends(){return LoggerV5_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},LoggerV5_extends.apply(null,arguments)}function _defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,_toPropertyKey(_.key),_)}}function _toPropertyKey(u){var f=function _toPrimitive(u,f){if("object"!=LoggerV5_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=LoggerV5_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==LoggerV5_typeof(f)?f:f+""}var Ne=function(){return function _createClass(u,f,y){return f&&_defineProperties(u.prototype,f),y&&_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(function Logger(u,f){if(function _classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,Logger),this.options=u,this.context=f,this.teaLog=xe,this.tea_app_id=2643,this.tea_channel="sg","us"===this.options.region)this.tea_channel="va";else this.tea_channel="sg";this.teaLog.init({app_id:this.tea_app_id,channel:this.tea_channel,log:!1,disable_sdk_monitor:!0,disable_auto_pv:!0,disable_webid:!0,disable_session:!0}),this.teaLog.config({evtParams:{sdk_version:"1.1.2",line_app_id:this.options.appId+"",toB:!0},user_unique_id:this.options.userId}),this.teaLog.start()},[{key:"send",value:function send(u){var f=this.context,y=u.key,_=f.tasks[y],m=Oe[u.stage]||999,v=u.fileType||_.fileType,b=u.fileSize||0,w={log_type:De[v],stage:m,fk:y,fs:b,req:u.req,res:u.res,ts:Math.round(Date.now()/1e3),sst:u.stageStartTime,set:u.stageEndTime,dur:u.duration,tdur:u.totalDuration,isDirect:Number(!!u.isDirect)},S="".concat("image"===v?"image":"video","_")+("error"===u.type?"error":m);switch(m){case 1e3:this.teaLog.event(S,LoggerV5_extends({},w,{type:u.type,ex:JSON.stringify({errc:u.extra&&u.extra.errorCode,msg:u.extra&&u.extra.message,crc32Array:u.crc32Array,isDirect:u.isDirect})}));break;case 1001:this.teaLog.event(S,LoggerV5_extends({},w,{type:u.type,oid:u.oid,upload_host:u.tosDomain,ex:JSON.stringify({errc:u.extra&&u.extra.errorCode,err:u.extra&&u.extra.error,msg:u.extra&&u.extra.message,sig:u.signature,reqid:u.extra&&u.extra.requestId})}));break;case 1002:this.teaLog.event(S,LoggerV5_extends({},w,{type:u.type,oid:u.oid,upload_host:u.tosDomain,ex:JSON.stringify({errc:u.extra&&u.extra.errorCode,msg:u.extra&&u.extra.message,upid:u.uploadID,reqid:u.extra&&u.extra.requestId}),upload_id:u.uploadID}));break;case 1003:u.isAllFinish||u.isDirect||(delete w.sst,delete w.set,delete w.dur,delete w.isDirect),this.teaLog.event(S,LoggerV5_extends({},w,{type:u.type,oid:u.oid,upload_host:u.tosDomain,ex:JSON.stringify({errc:u.extra&&u.extra.errorCode,msg:u.extra&&u.extra.message,si:u.slice_index,af:u.isAllFinish,reqid:u.extra&&u.extra.requestId}),upload_id:u.uploadID,si:u.slice_index,al:u.isAllFinish}));break;case 1004:this.teaLog.event(S,LoggerV5_extends({},w,{type:u.type,oid:u.oid,upload_host:u.tosDomain,ex:JSON.stringify({errc:u.extra&&u.extra.errorCode,msg:u.extra&&u.extra.message,reqid:u.extra&&u.extra.requestId}),upload_id:u.uploadID}));break;case 1005:this.teaLog.event(S,LoggerV5_extends({},w,{type:u.type,oid:u.oid,upload_host:u.tosDomain,ex:JSON.stringify({errc:u.extra&&u.extra.errorCode,err:u.extra&&u.extra.error,msg:u.extra&&u.extra.message,vid:u.uploadResult&&u.uploadResult.Vid,reqid:u.extra&&u.extra.requestId}),vid:u.uploadResult&&u.uploadResult.Vid}));break;default:this.teaLog.event(S,LoggerV5_extends({},w,{type:u.type,oid:u.oid,upload_host:u.tosDomain,ex:JSON.stringify({errc:u.extra&&u.extra.errorCode,msg:u.extra&&u.extra.message})}))}}},{key:"console",value:function(u){function console(f){return u.apply(this,arguments)}return console.toString=function(){return u.toString()},console}(function(u){this.options.debug&&console.log(u)})}])}(),Be=y(2),Le=y.n(Be),Ge=y(1),Fe=y.n(Ge),Ke={resolveUri:function resolveUri(u){if(!u)return"";if(Array.isArray(u))return u.map(function(u){try{return u.split("/")[0]+"/"+encodeURIComponent(u.split("/").slice(1).join("/"))}catch(f){return u}});try{return u.split("/")[0]+"/"+encodeURIComponent(u.split("/").slice(1).join("/"))}catch(f){return u}},urlTemplate:function urlTemplate(u,f){var y;return f=f||{},Object.keys(f).forEach(function(_){y=new RegExp("{".concat(_,"}"),"g"),u=u.replace(y,f[_])}),u},toQueryString:function toQueryString(){var u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},f=[];return Object.keys(u).map(function(y){var _=u[y];"[object Array]"===Object.prototype.toString.call(_)?_.forEach(function(u){f.push("".concat(y,"=").concat(encodeURIComponent(u)))}):f.push("".concat(y,"=").concat(encodeURIComponent(u[y])))}),f.join("&")},arrayToObject:function arrayToObject(u){var f={};return u&&u.forEach(function(u){f[u.Key.toLowerCase()]=u.Value}),f},supportChunked:function supportChunked(){var u=window.Blob||window.WebKitBlob;try{var f=u.prototype;return!(!FormData||!(f.slice||f.webkitSlice||f.mozSlice))}catch(u){return!1}},supportXhr:function supportXhr(){return!!window.FormData||window.ProgressEvent&&window.FileReader},supportCrc32:function supportCrc32(){var u=window.FileReader&&window.FileReader.prototype.readAsBinaryString;return"undefined"!=typeof Int32Array&&u&&(Blob.prototype.slice||Blob.prototype.webkitSlice||Blob.prototype.mozSlice)},storage:function storage(u){var f=u,y={removeItem:function removeItem(u){delete f.cache[u]},setItem:function setItem(u,y){f.cache[u]=y},getItem:function getItem(u){return f.cache[u]},clear:function clear(){delete f.cache,f.cache={}}};if(!(!(arguments.length>1&&void 0!==arguments[1])||arguments[1]))return y;try{if(window.localStorage)return window.localStorage.setItem("",""),window.localStorage}catch(u){return y}return y},noop:function noop(){},getUnique:function getUnique(u){return"".concat(u,"_").concat((new Date).getTime(),"_").concat(parseInt(1e6*Math.random()))},getFileSliceLength:function getFileSliceLength(u,f){var y=u.size;return f&&"function"==typeof f?f(y)<Re?Re:f(y)||y:y>419430400?10485760:y<=419430400&&y>=2097152?5242880:u.size},getFileSuffix:function getFileSuffix(u){if(u&&"[object String]"===Object.prototype.toString.call(u)){var f=u.lastIndexOf(".");return f>0?"."+u.substring(f+1):void 0}},crypto:{hmac:function hmac(u,f){return Le()(f,u)},sha256:function sha256(u){return Fe()(u)}},date:{iso8601:function iso8601(u){return void 0===u&&(u=Ke.date.getDate()),u.toISOString().replace(/\.\d{3}Z$/,"Z")}},Buffer:Uint8Array,buffer:{toBuffer:function toBuffer(u,f){return"function"==typeof Ke.Buffer.from&&Ke.Buffer.from!==Uint8Array.from?Ke.Buffer.from(u,f):new Ke.Buffer(u,f)},alloc:function alloc(u,f,y){if("number"!=typeof u)throw new Error("size passed to alloc must be a number.");if("function"==typeof Ke.Buffer.alloc)return Ke.Buffer.alloc(u,f,y);var _=new Ke.Buffer(u);return void 0!==f&&"function"==typeof _.fill&&_.fill(f,void 0,void 0,y),_},toStream:function toStream(u){Ke.Buffer.isBuffer(u)||(u=Ke.buffer.toBuffer(u));var f=new Ke.stream.Readable,y=0;return f._read=function(_){if(y>=u.length)return f.push(null);var m=y+_;m>u.length&&(m=u.length),f.push(u.slice(y,m)),y=m},f},concat:function concat(u){var f,y,_=0,m=0;for(y=0;y<u.length;y++)_+=u[y].length;for(f=Ke.buffer.alloc(_),y=0;y<u.length;y++)u[y].copy(f,m),m+=u[y].length;return f}}};function debugLog(){var u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"log",f=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{if("undefined"!=typeof window&&window.localStorage){var y=window.localStorage.getItem("$byteplus-uploader_enable_debug_log");null!==y&&(f="true"===y)}}catch(u){}if(f){for(var _,m=["log","warn","error","info","debug","trace"].includes(u)?u:"log",v=arguments.length,b=new Array(v>2?v-2:0),w=2;w<v;w++)b[w-2]=arguments[w];(_=console)[m].apply(_,["[BytePlus-Uploader]"].concat(b))}}var qe=Ke;function toEight(u){return u.length<8?toEight(u="0".concat(u)):u}var He={crc32:function encrypt_crc32(u,f){var y=[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&&(y=new Int32Array(y));for(var _=-1^f,m=(u=new Uint8Array(u)).length,v=0;v<m;v++)_=y[255&(_^u[v])]^_>>>8;return(-1^_)>>>0},dec2hex:function dec2hex(u){if(void 0!==u)return toEight(Number(u).toString(16))}};function Crc32_typeof(u){return Crc32_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},Crc32_typeof(u)}function Crc32_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,Crc32_toPropertyKey(_.key),_)}}function Crc32_toPropertyKey(u){var f=function Crc32_toPrimitive(u,f){if("object"!=Crc32_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=Crc32_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==Crc32_typeof(f)?f:f+""}var Ve=function(){return function Crc32_createClass(u,f,y){return f&&Crc32_defineProperties(u.prototype,f),y&&Crc32_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(function Crc32(u,f,y,_){!function Crc32_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,Crc32),this.file=u,this.successProcess=y,this.failProcess=_,this.sliceLength=f,this.retryTime=0,this.fileSize=u.size,this.crc32Array=[]},[{key:"start",value:function start(){this.readFileCrc32(this.file)}},{key:"readFileCrc32",value:function readFileCrc32(u){var f=this,y=this.sliceLength,_=u.slice||u.webkitSlice||u.mozSlice,m=new FileReader,v=0,b=0,w=0;!function read(){b<u.size&&(b=Math.min(v+y,u.size),u.size>104857600&&u.size-b<=5242880&&(b=u.size)),m.readAsArrayBuffer(_.call(u,v,b)),m.onload=function(y){var _=y.target.result;w=He.crc32(_,0),f.crc32Array.push({start:v,end:b,crc32:He.dec2hex(w),buffer:_}),v=b,b<u.size?read():f.success(f.crc32Array)}}()}},{key:"success",value:function success(u){this.successProcess(u)}},{key:"fail",value:function fail(u,f,y,_){this.retryTime>=3?this.failProcess():(this.readFileCrc32(u,f,y,_),this.retryTime++)}}])}();function FileCrc32_typeof(u){return FileCrc32_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},FileCrc32_typeof(u)}function FileCrc32_extends(){return FileCrc32_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},FileCrc32_extends.apply(null,arguments)}function _toConsumableArray(u){return function _arrayWithoutHoles(u){if(Array.isArray(u))return _arrayLikeToArray(u)}(u)||function _iterableToArray(u){if("undefined"!=typeof Symbol&&null!=u[Symbol.iterator]||null!=u["@@iterator"])return Array.from(u)}(u)||function _unsupportedIterableToArray(u,f){if(u){if("string"==typeof u)return _arrayLikeToArray(u,f);var y={}.toString.call(u).slice(8,-1);return"Object"===y&&u.constructor&&(y=u.constructor.name),"Map"===y||"Set"===y?Array.from(u):"Arguments"===y||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(y)?_arrayLikeToArray(u,f):void 0}}(u)||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(u,f){(null==f||f>u.length)&&(f=u.length);for(var y=0,_=Array(f);y<f;y++)_[y]=u[y];return _}function FileCrc32_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,FileCrc32_toPropertyKey(_.key),_)}}function FileCrc32_toPropertyKey(u){var f=function FileCrc32_toPrimitive(u,f){if("object"!=FileCrc32_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=FileCrc32_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==FileCrc32_typeof(f)?f:f+""}var We=function(){return function FileCrc32_createClass(u,f,y){return f&&FileCrc32_defineProperties(u.prototype,f),y&&FileCrc32_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(function FileCrc32(u){var f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function FileCrc32_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,FileCrc32),this.context=u.context,this.key=u.key,this.isDirect=u.isDirect,this.isImageBatchUpload=u.isImageBatchUpload,this.file=u.file,this.type=(this.isImageBatchUpload?this.file[0].type:this.file.type)||"",this.sliceLength=qe.getFileSliceLength(this.file,f.getSliceFunc),this.config=f},[{key:"start",value:function start(u,f,y){this.successProcess=f,this.failProcess=y,this._st=Date.now(),this.crc32(this.file,this.sliceLength)}},{key:"crc32",value:function crc32(u,f){var y=this;if(this.isImageBatchUpload)for(var _=u.length,m=[],v=0;v<_;v++){var crc32=new Ve(u[v],u[v].size,function(u){m.push(u[0]),m.length===_&&y.success(m)},function(u){y.fail(u)});crc32.start()}else{if(!u||!u.size||u.size<=0)return void this.fail({message:"There is a problem with the input file or fileSize."});if(this.isDirect){var b=new Ve(u,u.size,function(u){y.success(u)},function(u){y.fail(u)});b.start()}else this.sliceFile(u,f,function(u){y.success(u)},function(u){y.fail(u)})}}},{key:"sliceFile",value:function sliceFile(u,f,y,_){for(var m=[],v=f,b=u.size,w=new FileReader,S=u.slice||u.webkitSlice||u.mozSlice,k=0,E=0,C=0;E<b;)E=Math.min(k+v,b),b-E<=5242880&&(E=b),m.push({start:k,end:E,crc32:0}),k=E;try{!function read(f){k=m[f].start,E=m[f].end,w.readAsArrayBuffer(S.call(u,k,E)),w.onload=function(u){var _=u.target.result;C=He.dec2hex(He.crc32(_,0)),m[f].crc32=C,E===b?y(m):read(m.length-1)},w.onerror=function(u){_(u)}}(0)}catch(u){_(u)}}},{key:"getCrc32Key",value:function getCrc32Key(u,f,y){var _,m;((_="[object Array]"===Object.prototype.toString.call(f)?_toConsumableArray(f):[f]).push(u[0].crc32,u[u.length-1].crc32),this.config.useFileNameInCacheKey)&&(Array.isArray(y)?(m=_).push.apply(m,_toConsumableArray(y)):_.push(y));return _.join("_")}},{key:"success",value:function success(u){var f=this.context,y=this.key,_=[],m=[];if(this.isImageBatchUpload)for(var v=0;v<this.file.length;v++)_.push(this.file[v].size),m.push(this.file[v].name);else _=this.file.size,m=this.file.name;var b=this.getCrc32Key(u,_,m),w=f.tasks[y];w&&this.successProcess(FileCrc32_extends(w,{key:y,crc32Array:u,crc32Key:b,sdkVersion:"1.1.2",sliceLength:this.sliceLength,extra:{message:"get crc32 success"},stage:"crc32",type:"success",fileSize:_,fileName:m,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st,isDirect:this.isDirect,isImageBatchUpload:this.isImageBatchUpload}))}},{key:"fail",value:function fail(u){var f=this.context,y=this.key,_=u&&u.message?u.message:"get crc32 error",m=FileCrc32_extends(f.tasks[y],{extra:{message:_},type:"error",stage:"crc32",stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st});this.failProcess(m)}}])}();function Transport_typeof(u){return Transport_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},Transport_typeof(u)}function Transport_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,Transport_toPropertyKey(_.key),_)}}function Transport_toPropertyKey(u){var f=function Transport_toPrimitive(u,f){if("object"!=Transport_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=Transport_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==Transport_typeof(f)?f:f+""}function _callSuper(u,f,y){return f=_getPrototypeOf(f),function _possibleConstructorReturn(u,f){if(f&&("object"==Transport_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,_isNativeReflectConstruct()?Reflect.construct(f,y||[],_getPrototypeOf(u).constructor):f.apply(u,y))}function _isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function _getPrototypeOf(u){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},_getPrototypeOf(u)}function _setPrototypeOf(u,f){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},_setPrototypeOf(u,f)}var Je=function(u){function Transport(){var u;return function Transport_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,Transport),(u=_callSuper(this,Transport)).xhr=new XMLHttpRequest,u._data=null,u}return function _inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&_setPrototypeOf(u,f)}(Transport,u),function Transport_createClass(u,f,y){return f&&Transport_defineProperties(u.prototype,f),y&&Transport_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(Transport,[{key:"_ajax",value:function _ajax(u){var f=this,y=this.xhr;y.upload.onprogress=function(u){f.emit("progress",u)},y.onreadystatechange=function(){4===y.readyState&&(y.upload.onprogress=qe.noop,y.onreadystatechange=qe.noop,y.params=u,f._data&&f._data.url&&(y.currentUrl=f._data.url),y.status>=200&&y.status<300?f.emit("complete",y):y.status>=400&&f.emit("error",y))},y.onerror=function(){y.errText="unknow net error",f.emit("error",y)},y.ontimeout=function(){y.errText="timeout",f.emit("error",y)},y.onabort=function(){y.errText="abort",f.emit("error",y)},y.send(u)}},{key:"send",value:function send(u){var f=this;return this._data=u,this.xhr.open(u.method||"POST",u.url||"",!0),u.headers&&Object.keys(u.headers).forEach(function(y){f.xhr.setRequestHeader(y,u.headers[y])}),this.xhr.timeout=u.timeout||0,u.ontimeout&&(this.xhr.ontimeout=u.ontimeout),u.binary?this.sendAsBinary(u):u.custom?"object"===Transport_typeof(u.custom)?this.sendAsCustom(JSON.stringify(u.custom)):"none"===u.custom?(delete u.custom,this.sendAsCustom()):this.sendAsCustom(u.custom):this.sendAsFormData(u)}},{key:"sendAsBinary",value:function sendAsBinary(u){return this.xhr.setRequestHeader("Content-Type","application/octet-stream"),this.xhr.setRequestHeader("Content-Disposition",'attachment; filename="'.concat(encodeURI(u.filename),'"')),this._ajax(u.file)}},{key:"sendAsFormData",value:function sendAsFormData(u){var f;u.formData&&(f="function"==typeof u.formData?u.formData():u.formData),f||(f=[]);for(var y=new FormData,_=0,m=f.length;_<m;_++){var v=f[_];y.append(v.name,v.value)}return u.file&&y.append(u.field,u.file,u.name),this._ajax(y)}},{key:"sendAsCustom",value:function sendAsCustom(u){return this._ajax(u)}},{key:"abort",value:function abort(){this.xhr.onreadystatechange=qe.noop,this.xhr.abort()}},{key:"getResponse",value:function getResponse(){return this.xhr.response}},{key:"getText",value:function getText(){return this.xhr.responseText}},{key:"getJson",value:function getJson(){return JSON.parse(this.xhr.responseText)}}])}(m.a),Qe={hmac:function hmac(u,f){return Le()(f,u)},sha256:function sha256(u){return Fe()(u)}};function awsv4_typeof(u){return awsv4_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},awsv4_typeof(u)}function awsv4_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,awsv4_toPropertyKey(_.key),_)}}function awsv4_toPropertyKey(u){var f=function awsv4_toPrimitive(u,f){if("object"!=awsv4_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=awsv4_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==awsv4_typeof(f)?f:f+""}var $e=["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id"],Xe=function uriEscape(u){try{return encodeURIComponent(u).replace(/[^A-Za-z0-9_.~\-%]+/g,escape).replace(/[*]/g,function(u){return"%".concat(u.charCodeAt(0).toString(16).toUpperCase())})}catch(u){return""}},Ze=function queryParamsToString(u){return Object.keys(u).sort().map(function(f){var y=u[f];if(null!=y){var _=Xe(f);if(_)return Array.isArray(y)?"".concat(_,"=").concat(y.map(Xe).sort().join("&".concat(_,"="))):"".concat(_,"=").concat(Xe(y))}}).filter(function(u){return u}).join("&")},Ye=function(){return function awsv4_createClass(u,f,y){return f&&awsv4_defineProperties(u.prototype,f),y&&awsv4_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(function AWSSignersV4(u,f,y){!function awsv4_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,AWSSignersV4),this.request=u,this.request.headers=u.headers||{},this.serviceName=f,y=y||{},this.signatureCache="boolean"!=typeof y.signatureCache||y.signatureCache,this.operation=y.operation,this.signatureVersion=y.signatureVersion,this.constant=y.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=y.bodySha256,this.shouldSerializeBody="boolean"!=typeof y.shouldSerializeBody||y.shouldSerializeBody},[{key:"addAuthorization",value:function addAuthorization(u,f){var y=this.iso8601(f).replace(/[:\-]|\.\d{3}/g,"");this.addHeaders(u,y),this.request.headers.Authorization=this.authorization(u,y)}},{key:"addHeaders",value:function addHeaders(u,f){if(this.request.headers[this.constant.dateHeader]=f,u.sessionToken&&(this.request.headers[this.constant.tokenHeader]=u.sessionToken),this.request.body){var y=this.request.body;"string"!=typeof y&&this.shouldSerializeBody&&(y=y instanceof URLSearchParams?y.toString():JSON.stringify(y)),this.request.headers[this.constant.contentSha256Header]=this.bodySha256||Qe.sha256(y).toString()}}},{key:"authorization",value:function authorization(u,f){var y=[],_=this.credentialString(f);return y.push("".concat(this.constant.algorithm," Credential=").concat(u.accessKeyId,"/").concat(_)),y.push("SignedHeaders=".concat(this.signedHeaders())),y.push("Signature=".concat(this.signature(u,f))),y.join(", ")}},{key:"signature",value:function signature(u,f){var y=this.getSigningKey(u,f.substr(0,8),this.request.region,this.serviceName,this.signatureCache);return Qe.hmac(y,this.stringToSign(f),"hex")}},{key:"stringToSign",value:function stringToSign(u){var f=[];return f.push(this.constant.algorithm),f.push(u),f.push(this.credentialString(u)),f.push(this.hexEncodedHash(this.canonicalString())),f.join("\n")}},{key:"canonicalString",value:function canonicalString(){var u=[],f=this.request.pathname||"/";return u.push(this.request.method.toUpperCase()),u.push(f),u.push(Ze(this.request.params)||""),u.push("".concat(this.canonicalHeaders(),"\n")),u.push(this.signedHeaders()),u.push(this.hexEncodedBodyHash()),u.join("\n")}},{key:"canonicalHeaders",value:function canonicalHeaders(){var u=this,f=[];Object.keys(this.request.headers).forEach(function(y){f.push([y,u.request.headers[y]])}),f.sort(function(u,f){return u[0].toLowerCase()<f[0].toLowerCase()?-1:1});var y=[];return f.forEach(function(f){var _=f[0].toLowerCase();if(u.isSignableHeader(_)){var m=f[1];if(null==m||"function"!=typeof m.toString)throw new Error("Header ".concat(_," contains invalid value"));y.push("".concat(_,":").concat(u.canonicalHeaderValues(m.toString())))}}),y.join("\n")}},{key:"canonicalHeaderValues",value:function canonicalHeaderValues(u){return u.replace(/\s+/g," ").replace(/^\s+|\s+$/g,"")}},{key:"signedHeaders",value:function signedHeaders(){var u=this,f=[];return Object.keys(this.request.headers).forEach(function(y){y=y.toLowerCase(),u.isSignableHeader(y)&&f.push(y)}),f.sort().join(";")}},{key:"credentialString",value:function credentialString(u){return this.createScope(u.substr(0,8),this.request.region,this.serviceName)}},{key:"hexEncodedHash",value:function hexEncodedHash(u){return Qe.sha256(u)}},{key:"hexEncodedBodyHash",value:function hexEncodedBodyHash(){return this.request.headers[this.constant.contentSha256Header]?this.request.headers[this.constant.contentSha256Header]:this.request.body?this.hexEncodedHash(Ze(this.request.body)):this.hexEncodedHash("")}},{key:"isSignableHeader",value:function isSignableHeader(u){return 0===u.toLowerCase().indexOf("x-amz-")||$e.indexOf(u)<0}},{key:"iso8601",value:function iso8601(u){return void 0===u&&(u=new Date),u.toISOString().replace(/\.\d{3}Z$/,"Z")}},{key:"getSigningKey",value:function getSigningKey(u,f,y,_){var m=Qe.hmac("".concat(this.constant.kDatePrefix).concat(u.secretAccessKey),f),v=Qe.hmac(m,y),b=Qe.hmac(v,_);return Qe.hmac(b,this.constant.v4Identifier)}},{key:"createScope",value:function createScope(u,f,y){return[u.substr(0,8),f,y,this.constant.v4Identifier].join("/")}}])}(),et=1000001,tt=1000002,rt=1001e3,ot=1002e3,nt=1003e3,it=1003003,st=1005e3,at=4025,ct=4024,lt="The file is not an instance of Blob ",ut="The format of stsToken is incorrect.",pt="An error occurred reading the file";function ApplyUpload_typeof(u){return ApplyUpload_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},ApplyUpload_typeof(u)}function ApplyUpload_toConsumableArray(u){return function ApplyUpload_arrayWithoutHoles(u){if(Array.isArray(u))return ApplyUpload_arrayLikeToArray(u)}(u)||function ApplyUpload_iterableToArray(u){if("undefined"!=typeof Symbol&&null!=u[Symbol.iterator]||null!=u["@@iterator"])return Array.from(u)}(u)||function ApplyUpload_unsupportedIterableToArray(u,f){if(u){if("string"==typeof u)return ApplyUpload_arrayLikeToArray(u,f);var y={}.toString.call(u).slice(8,-1);return"Object"===y&&u.constructor&&(y=u.constructor.name),"Map"===y||"Set"===y?Array.from(u):"Arguments"===y||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(y)?ApplyUpload_arrayLikeToArray(u,f):void 0}}(u)||function ApplyUpload_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 ApplyUpload_arrayLikeToArray(u,f){(null==f||f>u.length)&&(f=u.length);for(var y=0,_=Array(f);y<f;y++)_[y]=u[y];return _}function ownKeys(u,f){var y=Object.keys(u);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(u);f&&(_=_.filter(function(f){return Object.getOwnPropertyDescriptor(u,f).enumerable})),y.push.apply(y,_)}return y}function _objectSpread(u){for(var f=1;f<arguments.length;f++){var y=null!=arguments[f]?arguments[f]:{};f%2?ownKeys(Object(y),!0).forEach(function(f){_defineProperty(u,f,y[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(y)):ownKeys(Object(y)).forEach(function(f){Object.defineProperty(u,f,Object.getOwnPropertyDescriptor(y,f))})}return u}function _defineProperty(u,f,y){return(f=ApplyUpload_toPropertyKey(f))in u?Object.defineProperty(u,f,{value:y,enumerable:!0,configurable:!0,writable:!0}):u[f]=y,u}function ApplyUpload_extends(){return ApplyUpload_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},ApplyUpload_extends.apply(null,arguments)}function ApplyUpload_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,ApplyUpload_toPropertyKey(_.key),_)}}function ApplyUpload_toPropertyKey(u){var f=function ApplyUpload_toPrimitive(u,f){if("object"!=ApplyUpload_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=ApplyUpload_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==ApplyUpload_typeof(f)?f:f+""}function ApplyUpload_callSuper(u,f,y){return f=ApplyUpload_getPrototypeOf(f),function ApplyUpload_possibleConstructorReturn(u,f){if(f&&("object"==ApplyUpload_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function ApplyUpload_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,ApplyUpload_isNativeReflectConstruct()?Reflect.construct(f,y||[],ApplyUpload_getPrototypeOf(u).constructor):f.apply(u,y))}function ApplyUpload_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(ApplyUpload_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function ApplyUpload_getPrototypeOf(u){return ApplyUpload_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},ApplyUpload_getPrototypeOf(u)}function ApplyUpload_setPrototypeOf(u,f){return ApplyUpload_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},ApplyUpload_setPrototypeOf(u,f)}var ft=function(u){function ApplyUpload(u,f){var y;return function ApplyUpload_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,ApplyUpload),(y=ApplyUpload_callSuper(this,ApplyUpload)).options=u,y.config=f,y.uploaderCtx=u.context,y.currFileCtx=u.context.tasks[u.key],y.isImageBatchUpload=!!y.options.isImageBatchUpload,y.serviceName=u.serviceName||je,y}return function ApplyUpload_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&ApplyUpload_setPrototypeOf(u,f)}(ApplyUpload,u),function ApplyUpload_createClass(u,f,y){return f&&ApplyUpload_defineProperties(u.prototype,f),y&&ApplyUpload_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(ApplyUpload,[{key:"start",value:function start(u,f,y){this.failProcess=y,this.successProcess=f,this._st=Date.now();var _=this.uploaderCtx._getCache(this.currFileCtx.crc32Key),m=_?JSON.parse(_):{};m.oid&&m.uploadID&&m.tosDomain?this.resumeFromCache(m):this.startPreUpload()}},{key:"startPreUpload",value:function startPreUpload(){var u=this,f=ze[this.config.region],y="",_={};if(this.serviceName===je){var m=this.config.videoConfig.spaceName;y=this.config.videoHost||Me,_={Action:"ApplyUploadInfo",Version:"2023-01-01",SpaceName:m,FileSize:this.currFileCtx.fileSize,FileType:this.options.type},this.options.fileName&&(_.FileName=this.options.fileName),this.options.storageClass&&(_.StorageClass=this.options.storageClass),this.config.enOID&&(_.EnOID=1)}else if(y=Me,_={Action:"ApplyImageUpload",Version:"2018-08-01",ServiceId:this.options.serviceId||this.config.imageConfig.serviceId},this.currFileCtx.fileSize&&this.currFileCtx.fileSize.length>1&&(_.UploadNum=this.currFileCtx.fileSize.length),this.options.storeKey){var v=this.options.storeKey;"[object Array]"===Object.prototype.toString.call(v)?_.StoreKeys=v:"[object String]"===Object.prototype.toString.call(v)&&(_.StoreKeys=[v])}if(this.config.useFileExtension&&this.currFileCtx.fileName){var b=this.currFileCtx.fileName,w=qe.getFileSuffix(b);w&&(_.FileExtension=w)}this.options.fileExtension&&(_.FileExtension=this.options.fileExtension),this.config.accountId&&(_["X-Account-Id"]=this.config.accountId),_.s=Math.random().toString(36).substr(2);var S=this.currFileCtx.proxyStsToken||this.config.stsToken,k=qe.toQueryString(_),E={method:"GET",url:"".concat(y,"?").concat(k),timeout:3e4,region:f,params:_};if(this.config.useConsoleMode)this.config.apply(_).then(function(f){if(f.errorCode||f.error)u.fail(f);else{var y=f.result,_=f.xhr;u.success(y,_)}},function(f){u.fail(f)});else{var C=new Je;C.on("complete",function(f){if(!f.response)return u.fail({error:"request fail: ".concat(f.statusText||f.errText||"UNKNOWN"),xhr:f});try{var y=JSON.parse(f.response);if(y.ResponseMetadata.Error)return u.fail({xhr:f,errorCode:y.ResponseMetadata.Error.CodeN,error:y.ResponseMetadata.Error.Code,message:y.ResponseMetadata.Error.Message});var _=y.Result;u.success(_,f)}catch(y){return u.fail({error:"catch error: ".concat(y.toString()),xhr:f})}}),C.on("error",function(f){var y={error:"request fail: ".concat(f.statusText||f.errText||"UNKNOWN"),xhr:f};if(f.response){var _=JSON.parse(f.response);_.ResponseMetadata&&_.ResponseMetadata.Error&&(y.errorCode=_.ResponseMetadata.Error.CodeN,y.error=_.ResponseMetadata.Error.Code,y.message=_.ResponseMetadata.Error.Message)}u.fail(y)});var x=new Ye(E,this.serviceName,{isVolcengine:!0}),O=S.AccessKeyID,P=S.AccessKeyId,U=S.SecretAccessKey,D=S.SessionToken;x.addAuthorization({accessKeyId:P||O,secretAccessKey:U,sessionToken:D},new Date),C.send(E)}}},{key:"resumeFromCache",value:function resumeFromCache(u){var f=this,y=this.options.key,_=new Je;_.on("complete",function(_){try{var m=JSON.parse(_.response);if(!(0===m.success&&m.payload.partList.length>0))return f.startPreUpload();var v=f.confirmCache(m.payload.partList),b=!!u.hasMerge?5:v.isAllFinished?4:3,w=ApplyUpload_extends(f.currFileCtx,u,{key:y,xhr:_,extra:{message:"prepare upload from disk cache success"},stage:"preUpload",type:"success",percent:0,cacheTask:b,proxyStsToken:f.options.stsToken,currentTask:1,status:1,isBreak:1,crc32Array:v.crc32Array,stageStartTime:f._st,stageEndTime:Date.now(),duration:Date.now()-f._st,totalDuration:Date.now()-f._st+f.currFileCtx.totalDuration});f.successProcess&&f.successProcess(w)}catch(u){return f.startPreUpload()}}),_.on("error",function(u){return u.status>=400?f.startPreUpload():f.fail({error:"request error",xhr:u})});var m=this.config.userId,v=ApplyUpload_extends(qe.arrayToObject(u.UploadHeader),{"x-storage-mode":"gateway"});_.send({method:"GET",url:qe.urlTemplate(this.config.getUploadListUrl,{tosDomain:u.tosDomain,oid:u.oid,uploadId:u.uploadID}),headers:_objectSpread({authorization:u.signature,"x-storage-u":m},v),timeout:3e4})}},{key:"confirmCache",value:function confirmCache(u){var f=this.currFileCtx.crc32Array,y={};u.forEach(function(u){var f=parseInt(u.partNumber)-1;isNaN(f)||void 0!==y[f]||(y[f]={tag:!0,crc32:u.crc32})});var _=!0,m=f.map(function(u,f){return y[f]&&y[f].tag?(u.crc32=y[f].crc32,u.finished=!0,u.loaded=u.end-u.start):_=!1,u});return{isAllFinished:_,crc32Array:m}}},{key:"success",value:function success(u,f){var y,_,m,v;this.serviceName===je?y=null!==(_=null===(m=u.Data)||void 0===m||null===(m=m.CandidateUploadAddresses)||void 0===m||null===(m=m.MainUploadAddresses)||void 0===m?void 0:m[0])&&void 0!==_?_:null===(v=u.Data)||void 0===v?void 0:v.UploadAddress:y=u.UploadAddress;var b=y,w=b.StoreInfos,S=b.UploadHosts,k=b.SessionKey,E=b.UploadHeader,C=void 0===E?[]:E,x=[],O=[];this.isImageBatchUpload&&w.length>1?w.forEach(function(u){x.push(u.Auth),O.push(u.StoreUri)}):(x=w[0].Auth,O=w[0].StoreUri);var P,U=[];if(this.serviceName===je){var D,I=(null===(D=u.Data)||void 0===D?void 0:D.CandidateUploadAddresses)||{},T=I.BackupUploadAddresses,A=void 0===T?[]:T,z=I.FallbackUploadAddresses,M=void 0===z?[]:z,R=A.concat(M);R.length&&R.length>0&&(U=R.map(function(u){var f=u.Cloud,y=u.SessionKey,_=u.StoreInfos,m=u.UploadHeader,v=u.UploadHosts;return{Cloud:f,SessionKey:y,UploadHeader:m,StoreInfo:_[0],UploadHost:v[0]}}))}this.config.uploadHost?(P="".concat(this.config.schema,"://").concat(this.config.uploadHost),U=U?[{SessionKey:k,UploadHeader:C,StoreInfo:w[0],UploadHost:S[0]}].concat(ApplyUpload_toConsumableArray(U)):[{SessionKey:k,UploadHeader:C,StoreInfo:w[0],UploadHost:S[0]}]):P="".concat(this.config.schema,"://").concat(S[0]);var N=ApplyUpload_extends(this.currFileCtx,{signature:x,type:"success",extra:{message:"prepare upload success"},stage:"preUpload",oid:qe.resolveUri(O),tosDomain:P,xhr:f,UploadHeader:C,SessionKey:k,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currFileCtx.totalDuration,fallbackStoreInfoList:U});return this.successProcess(N)}},{key:"fail",value:function fail(u){var f=u.xhr,y=u.errorCode||rt,_="prepare upload error: UNKNOWN";f&&(_=0===f.status?"prepare upload error: NETERROR":u.message||"prepare upload error: ".concat(f.status));var m=ApplyUpload_extends(this.currFileCtx,{extra:{message:_,error:u.error,errorCode:y,requestId:u.requestId},type:"error",stage:"preUpload",xhr:f,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(m)}}])}(m.a);function InitUploadID_typeof(u){return InitUploadID_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},InitUploadID_typeof(u)}function InitUploadID_ownKeys(u,f){var y=Object.keys(u);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(u);f&&(_=_.filter(function(f){return Object.getOwnPropertyDescriptor(u,f).enumerable})),y.push.apply(y,_)}return y}function InitUploadID_objectSpread(u){for(var f=1;f<arguments.length;f++){var y=null!=arguments[f]?arguments[f]:{};f%2?InitUploadID_ownKeys(Object(y),!0).forEach(function(f){InitUploadID_defineProperty(u,f,y[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(y)):InitUploadID_ownKeys(Object(y)).forEach(function(f){Object.defineProperty(u,f,Object.getOwnPropertyDescriptor(y,f))})}return u}function InitUploadID_defineProperty(u,f,y){return(f=InitUploadID_toPropertyKey(f))in u?Object.defineProperty(u,f,{value:y,enumerable:!0,configurable:!0,writable:!0}):u[f]=y,u}function InitUploadID_extends(){return InitUploadID_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},InitUploadID_extends.apply(null,arguments)}function InitUploadID_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,InitUploadID_toPropertyKey(_.key),_)}}function InitUploadID_toPropertyKey(u){var f=function InitUploadID_toPrimitive(u,f){if("object"!=InitUploadID_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=InitUploadID_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==InitUploadID_typeof(f)?f:f+""}function InitUploadID_callSuper(u,f,y){return f=InitUploadID_getPrototypeOf(f),function InitUploadID_possibleConstructorReturn(u,f){if(f&&("object"==InitUploadID_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function InitUploadID_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,InitUploadID_isNativeReflectConstruct()?Reflect.construct(f,y||[],InitUploadID_getPrototypeOf(u).constructor):f.apply(u,y))}function InitUploadID_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(InitUploadID_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function InitUploadID_getPrototypeOf(u){return InitUploadID_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},InitUploadID_getPrototypeOf(u)}function InitUploadID_setPrototypeOf(u,f){return InitUploadID_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},InitUploadID_setPrototypeOf(u,f)}var dt=function(u){function InitUploadID(u,f){var y;return function InitUploadID_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,InitUploadID),(y=InitUploadID_callSuper(this,InitUploadID)).options=u,y.config=f,y.transport=new Je,y.uploaderCtx=u.context,y.currFileCtx=u.context.tasks[u.key],y.eventInit(),y}return function InitUploadID_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&InitUploadID_setPrototypeOf(u,f)}(InitUploadID,u),function InitUploadID_createClass(u,f,y){return f&&InitUploadID_defineProperties(u.prototype,f),y&&InitUploadID_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(InitUploadID,[{key:"initUpload",value:function initUpload(){var u=this.options.context,f=this.options.key,y={oid:u.tasks[f].oid,tosDomain:u.tasks[f].tosDomain},_=qe.urlTemplate(this.config.initUploadFileUrl,y),m=this.config.userId,v=InitUploadID_extends(qe.arrayToObject(this.currFileCtx.UploadHeader),{"x-storage-mode":"gateway"});this.transport.send({method:"post",url:_,headers:InitUploadID_objectSpread({authorization:u.tasks[f].signature,"x-storage-u":m},v),timeout:3e4})}},{key:"start",value:function start(u,f,y){this.successProcess=f,this.failProcess=y,this._st=Date.now(),this.initUpload()}},{key:"eventInit",value:function eventInit(){var u=this,f=this.options.context,y=this.options.key;this.transport.on("complete",function(_){try{var m=JSON.parse(_.response),v=m.payload.uploadID;if(0===m.success&&v){var b=InitUploadID_extends(f.tasks[y],{uploadID:v,percent:0,type:"success",extra:{message:"init upload id success"},stage:"initUploadID",xhr:_,stageStartTime:u._st,stageEndTime:Date.now(),duration:Date.now()-u._st,totalDuration:Date.now()-u._st+u.currFileCtx.totalDuration});u.successProcess(b)}else u.fail({error:"fail! res.success: ".concat(m.success,", uploadId:").concat(v),xhr:_})}catch(f){u.fail({error:"catch error: ".concat(JSON.stringify(f)),xhr:_})}}),this.transport.on("error",function(f){u.fail({error:"request fail: ".concat(f.statusText||f.errText||"UNKNOWN"),xhr:f})})}},{key:"fail",value:function fail(u){var f=this.options.context,y=this.options.key,_=InitUploadID_extends(f.tasks[y],{extra:{message:"init upload id error, ".concat(u.error),errorCode:ot},type:"error",stage:"initUploadID",xhr:u.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(_)}}])}(m.a);function Uploader_typeof(u){return Uploader_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},Uploader_typeof(u)}function Uploader_ownKeys(u,f){var y=Object.keys(u);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(u);f&&(_=_.filter(function(f){return Object.getOwnPropertyDescriptor(u,f).enumerable})),y.push.apply(y,_)}return y}function Uploader_objectSpread(u){for(var f=1;f<arguments.length;f++){var y=null!=arguments[f]?arguments[f]:{};f%2?Uploader_ownKeys(Object(y),!0).forEach(function(f){Uploader_defineProperty(u,f,y[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(y)):Uploader_ownKeys(Object(y)).forEach(function(f){Object.defineProperty(u,f,Object.getOwnPropertyDescriptor(y,f))})}return u}function Uploader_defineProperty(u,f,y){return(f=Uploader_toPropertyKey(f))in u?Object.defineProperty(u,f,{value:y,enumerable:!0,configurable:!0,writable:!0}):u[f]=y,u}function Uploader_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,Uploader_toPropertyKey(_.key),_)}}function Uploader_toPropertyKey(u){var f=function Uploader_toPrimitive(u,f){if("object"!=Uploader_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=Uploader_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==Uploader_typeof(f)?f:f+""}function Uploader_callSuper(u,f,y){return f=Uploader_getPrototypeOf(f),function Uploader_possibleConstructorReturn(u,f){if(f&&("object"==Uploader_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function Uploader_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,Uploader_isNativeReflectConstruct()?Reflect.construct(f,y||[],Uploader_getPrototypeOf(u).constructor):f.apply(u,y))}function Uploader_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(Uploader_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function Uploader_getPrototypeOf(u){return Uploader_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},Uploader_getPrototypeOf(u)}function Uploader_setPrototypeOf(u,f){return Uploader_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},Uploader_setPrototypeOf(u,f)}var ht=function(u){function Uploader(u){var f,y=u.sliceItem,_=u.crc32,m=u.url,v=u.signature,b=u.uploadHeader,w=u.userId,S=u.retryTime,k=void 0===S?0:S,E=u.method,C=void 0===E?"put":E;return function Uploader_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,Uploader),(f=Uploader_callSuper(this,Uploader)).fileSlice=y,f.crc32=_,f.uploadUrl=m,f.uploadHeader=b,f.signature=v,f.userId=w,f.retryTime=k,f.method=C,f.retryCount=0,f.ready=!1,f.cancel=!1,f.transport=new Je,f.eventInit(),f}return function Uploader_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&Uploader_setPrototypeOf(u,f)}(Uploader,u),function Uploader_createClass(u,f,y){return f&&Uploader_defineProperties(u.prototype,f),y&&Uploader_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(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 u=this;this.transport.on("complete",function(f){u.success(f)}),this.transport.on("error",function(f){u.fail(f)}),this.transport.on("progress",function(f){u.process(f)})}},{key:"success",value:function success(u){this.ready=!0;var f=Date.now()-this._st,y=this.fileSlice.size||this.fileSlice.byteLength,_=y/f;this.emit("complete",{crc32:this.crc32,size:y,speed:_,xhr:u,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st})}},{key:"fail",value:function fail(u){if(!this.cancel)if(u&&401===u.status)this.emit("error",{message:"slice upload failed: UNAUTHORIZED",crc32:this.crc32,size:this.fileSlice.size||this.fileSlice.byteLength,xhr:u,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st});else{var f="slice upload failed: UNKNOWN";u&&(f=u.status?"slice upload failed: ".concat(u.status):"slice upload failed: NETERROR"),this.emit("error",{message:f,crc32:this.crc32,size:this.fileSlice.size||this.fileSlice.byteLength,xhr:u,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st})}}},{key:"process",value:function process(u){this.cancel||this.emit("progress",{crc32:this.crc32,loaded:u.loaded||0,total:u.total||0})}},{key:"abort",value:function abort(){this.transport&&(this.cancel=!0,this.transport.abort())}},{key:"destroy",value:function destroy(){this.transport=null}}])}(m.a),yt=y(4),gt=y.n(yt);function Upload_typeof(u){return Upload_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},Upload_typeof(u)}function Upload_extends(){return Upload_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},Upload_extends.apply(null,arguments)}function Upload_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,Upload_toPropertyKey(_.key),_)}}function Upload_toPropertyKey(u){var f=function Upload_toPrimitive(u,f){if("object"!=Upload_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=Upload_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==Upload_typeof(f)?f:f+""}function Upload_callSuper(u,f,y){return f=Upload_getPrototypeOf(f),function Upload_possibleConstructorReturn(u,f){if(f&&("object"==Upload_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function Upload_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,Upload_isNativeReflectConstruct()?Reflect.construct(f,y||[],Upload_getPrototypeOf(u).constructor):f.apply(u,y))}function Upload_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(Upload_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function Upload_getPrototypeOf(u){return Upload_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},Upload_getPrototypeOf(u)}function Upload_setPrototypeOf(u,f){return Upload_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},Upload_setPrototypeOf(u,f)}var _t=function(u){function Upload(u){var f,y=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function Upload_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,Upload),(f=Upload_callSuper(this,Upload)).file=u.file,f.context=u.context,f.key=u.key,f.config=y,f.finishArr=[],f.errorLength=0,f.finishSize=0,f.retryUploadTime=Number(y.retryUploadTime)||5,f.retryProcess=y.retryProcess,f.retryProcessTime=Number(y.retryProcessTime)||5,f.maxProcessPause=Number(y.maxProcessPause)||20,f.uploadSliceCount=Number(y.uploadSliceCount)||5,f.realtimeSpeedInterval=Number(y.realtimeSpeedInterval)||5,f.processRetry=0,f.lastFinishSize=-1,f.lastProcessPercent=-1,f.lastIntervalSize=-1,f.lastCalculateSpeedTime=-1,f.lastCalculateSpeedSize=0,f.writenStorage=!1,f.uploadHandlers={},f}return function Upload_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&Upload_setPrototypeOf(u,f)}(Upload,u),function Upload_createClass(u,f,y){return f&&Upload_defineProperties(u.prototype,f),y&&Upload_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(Upload,[{key:"start",value:function start(u,f,y){this.failProcess=y,this.successProcess=f,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(u,f){return u+(f.finished?0:f.end-f.start)},0),this._st=Date.now(),this._lastSaveTime=Date.now(),this.lastCalculateSpeedTime=this._st,this.initWorker(),this.threadUpload()}},{key:"initWorker",value:function initWorker(){var u=this;if(!this.worker){var f=this.crc32Array;this.worker=new gt.a,this.worker.onmessage=function(y){var _=y.data[0],m=y.data[2],v=f[m];v.crc32=y.data[1],u.upload(v,_,m)}}}},{key:"read",value:function read(u,f){var y=this,_=this.file,m=_.slice||_.webkitSlice||_.mozSlice,v=new FileReader;v.onload=function(u){y.worker.postMessage([u.target.result,f],[u.target.result])},v.onerror=function(){y.stop(),y.fail({extra:{message:pt,errorCode:it}})},v.readAsArrayBuffer(m.call(_,u.start,u.end))}},{key:"threadUpload",value:function threadUpload(){if(this.uploading.length<this.uploadSliceCount){var u=this.lastIndex,f=this.crc32Array[u];if(f){if(f.finished){if(-1===this.finishArr.indexOf(f.start)&&(this.finishArr.push(f.start),this.finishArr.length>=this.crc32Array.length))return this.stop(),void this.success()}else f.loaded=0,this.uploading.push(u),this.read(f,u);this.lastIndex++,this.threadUpload()}}}},{key:"stop",value:function stop(){var u=this;Object.keys(this.uploadHandlers).forEach(function(f){u.uploadHandlers[f].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(u,f,y){var _=this,m=u.crc32,v={number:y+1,uploadId:this.currentCtx.uploadID,oid:this.currentCtx.oid,tosDomain:this.currentCtx.tosDomain},b=qe.urlTemplate(this.config.uploadChunkedUrl,v),w=this.config.userId,S=Upload_extends(qe.arrayToObject(this.currentCtx.UploadHeader),{"x-storage-mode":"gateway"}),k=new ht({sliceItem:f,crc32:m,url:b,signature:this.currentCtx.signature,uploadHeader:S,userId:w,retryTime:this.retryUploadTime,enableDebugLog:this.config.enableDebugLog,uploaderCtx:this.context,key:this.key});k.on("complete",function(f){_.currentCtx.status===Ie&&(f.start=u.start,f.index=y,_.fileSliceSuccess(f))}),k.on("error",function(f){1===_.currentCtx.status&&(f.start=u.start,f.index=y,_.fail(f))}),k.on("progress",function(f){1===_.currentCtx.status&&(f.start=u.start,f.index=y,_.process(f))}),k.upload(),this.uploadHandlers[y]=k}},{key:"success",value:function success(u){this.finishArr=[];var f=Date.now()-this._st,y=this._uploadSize/f,_=Upload_extends(this.currentCtx,{type:"success",stage:"process",percent:100,extra:{message:"upload all success"},speed:y,xhr:u,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(_)}},{key:"fail",value:function fail(u){var f=this.currentCtx.totalDuration,y=Date.now()-this._st,_=u.crc32?{message:u.message,data:u.crc32,size:u.size}:u.extra;_.errorCode=_.errorCode||nt;var m=Upload_extends(this.currentCtx,{extra:_,type:"error",stage:"process",req:{},res:{},totalDuration:y+f});if(u.xhr){var v=u.xhr;m.req={url:u.xhr.currentUrl},m.res={status:v.status,body:v.responseText,header:v.getAllResponseHeaders()},delete u.xhr}if(void 0!==u.statusCode&&Upload_extends(this.currentCtx,{statusCode:u.statusCode}),!this.errorLength){var b=u.index;this.context.logger.send(Upload_extends({},m,{slice_index:b})),this.stop(),this.context._broadcast("error",m),this.currentCtx.isBreak?this.context._cancel(this.key):this.context._pause(this.key),this.errorLength++}}},{key:"fileSliceSuccess",value:function fileSliceSuccess(u){var f=u.index,y=Date.now();-1===this.finishArr.indexOf(u.start)&&this.finishArr.push(u.start),this.crc32Array[f].finished=!0,this.crc32Array[f].speed=u.speed;var _={message:"slice upload success"};if(u.xhr){var m=u.xhr;_.currentUrl=m.currentUrl||"",Upload_extends(this.currentCtx,{req:{url:m.currentUrl,param:m.params},res:{status:m.status,body:m.responseText,header:m.getAllResponseHeaders()}}),delete u.xhr}if(this.context.logger.send(Upload_extends(this.currentCtx,{stage:"process",type:"success",slice_index:f,extra:_,totalDuration:y-this._lastSaveTime+this.currentCtx.totalDuration})),this._lastSaveTime=y,!this.writenStorage&&this.currentCtx.enableDiskBreakPoint&&(this.writenStorage=!0,this.context._saveTask(this.key)),this.finishArr.length>=this.crc32Array.length)return this.stop(),void this.success(u.xhr);this.uploading.splice(this.uploading.indexOf(f),1),this.uploadHandlers[f]&&delete this.uploadHandlers[f],this.threadUpload()}},{key:"getFinishSize",value:function getFinishSize(u,f){var y=f.crc32,_=0;return u.forEach(function(u){u.crc32===y?(u.loaded=f.loaded,_+=f.loaded):(u.loaded||(u.loaded=0),_+=u.loaded)}),_}},{key:"process",value:function process(u){var f=this.currentCtx.realtimeSpeed||0,y=this.currentCtx.fileSize;if(this.finishSize=this.getFinishSize(this.crc32Array,u),this.finishSize>this.lastFinishSize){var _=new Date;if(_.getTime()-this.lastCalculateSpeedTime>1e3*this.realtimeSpeedInterval){var m=_.getTime()-this.lastCalculateSpeedTime,v=this.finishSize-this.lastCalculateSpeedSize;f=Math.floor(v/m),this.lastCalculateSpeedTime=_.getTime(),this.lastCalculateSpeedSize=this.finishSize}this.lastFinishSize=this.finishSize}var b=Math.floor(this.finishSize/y*100*100)/100||0,w=Upload_extends(this.currentCtx,{stage:"process",percent:b,realtimeSpeed:f});b>this.lastProcessPercent&&100!==b&&(this.lastProcessPercent=b,this.context._broadcast("progress",w))}}])}(m.a);function FileMerge_typeof(u){return FileMerge_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},FileMerge_typeof(u)}function FileMerge_ownKeys(u,f){var y=Object.keys(u);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(u);f&&(_=_.filter(function(f){return Object.getOwnPropertyDescriptor(u,f).enumerable})),y.push.apply(y,_)}return y}function FileMerge_objectSpread(u){for(var f=1;f<arguments.length;f++){var y=null!=arguments[f]?arguments[f]:{};f%2?FileMerge_ownKeys(Object(y),!0).forEach(function(f){FileMerge_defineProperty(u,f,y[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(y)):FileMerge_ownKeys(Object(y)).forEach(function(f){Object.defineProperty(u,f,Object.getOwnPropertyDescriptor(y,f))})}return u}function FileMerge_defineProperty(u,f,y){return(f=FileMerge_toPropertyKey(f))in u?Object.defineProperty(u,f,{value:y,enumerable:!0,configurable:!0,writable:!0}):u[f]=y,u}function FileMerge_extends(){return FileMerge_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},FileMerge_extends.apply(null,arguments)}function FileMerge_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,FileMerge_toPropertyKey(_.key),_)}}function FileMerge_toPropertyKey(u){var f=function FileMerge_toPrimitive(u,f){if("object"!=FileMerge_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=FileMerge_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==FileMerge_typeof(f)?f:f+""}function FileMerge_callSuper(u,f,y){return f=FileMerge_getPrototypeOf(f),function FileMerge_possibleConstructorReturn(u,f){if(f&&("object"==FileMerge_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function FileMerge_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,FileMerge_isNativeReflectConstruct()?Reflect.construct(f,y||[],FileMerge_getPrototypeOf(u).constructor):f.apply(u,y))}function FileMerge_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(FileMerge_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function FileMerge_getPrototypeOf(u){return FileMerge_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},FileMerge_getPrototypeOf(u)}function FileMerge_setPrototypeOf(u,f){return FileMerge_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},FileMerge_setPrototypeOf(u,f)}var mt=function(u){function FileMerge(u,f){var y;return function FileMerge_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,FileMerge),(y=FileMerge_callSuper(this,FileMerge)).options=u,y.config=f,y.transport=new Je,y.eventInit(),y.errorCount=0,y.uploaderCtx=u.context,y.currFileCtx=u.context.tasks[u.key],y}return function FileMerge_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&FileMerge_setPrototypeOf(u,f)}(FileMerge,u),function FileMerge_createClass(u,f,y){return f&&FileMerge_defineProperties(u.prototype,f),y&&FileMerge_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(FileMerge,[{key:"mergeFile",value:function mergeFile(){for(var u={oid:this.currFileCtx.oid,uploadId:this.currFileCtx.uploadID,tosDomain:this.currFileCtx.tosDomain},f=this.currFileCtx.crc32Array,y="",_=0;_<f.length;_++)y=y?"".concat(y,",").concat(_+1,":").concat(f[_].crc32):"".concat(_+1,":").concat(f[_].crc32);var m=qe.urlTemplate(this.config.uploadMergeUrl,u),v=this.config.userId,b=FileMerge_extends(qe.arrayToObject(this.currFileCtx.UploadHeader),{"x-storage-mode":"gateway"});this.transport.send({method:"post",url:m,headers:FileMerge_objectSpread({authorization:this.currFileCtx.signature,"x-storage-u":v},b),custom:y})}},{key:"start",value:function start(u,f,y){this.successProcess=f,this.failProcess=y,this._st=Date.now(),this.mergeFile()}},{key:"eventInit",value:function eventInit(){var u=this,f=this.options.stage;this.transport.on("complete",function(y){try{var _=JSON.parse(y.response);0===_.success&&_.payload.key?(FileMerge_extends(u.currFileCtx,{stage:f,type:"success",hasMerge:!0,extra:{message:"merge file success"},xhr:y,stageStartTime:u._st,stageEndTime:Date.now(),duration:Date.now()-u._st,totalDuration:Date.now()-u._st+u.currFileCtx.totalDuration}),u.successProcess(u.currFileCtx)):u.fail({error:"fail! result.success:".concat(_.success),xhr:y})}catch(f){u.fail({error:"response parse error: ".concat(JSON.stringify(f)),xhr:y})}}),this.transport.on("error",function(f){var y,_;try{if(f.responseText||f.response){var m,v,b=JSON.parse(f.responseText||f.response);if(b.error)y=null===(m=b.error)||void 0===m?void 0:m.error_code,_=null===(v=b.error)||void 0===v?void 0:v.message}}catch(u){}u.fail({error:"request fail: ".concat(f.statusText||f.errText||_),errorCode:y,message:_,xhr:f})})}},{key:"getProcessIndex",value:function getProcessIndex(u){var f=0;return u.forEach(function(u,y){"process"===u.stage&&(f=y)}),f}},{key:"fail",value:function fail(u){u.errorCode!==at&&u.errorCode!==ct||debugLog(this.config.enableDebugLog,"log","Merge阶段错误码 ".concat(u.errorCode,",跳过重试,直接结束:"),{stage:"MERGE",errorCode:u.errorCode,message:u.message,error:u.error,requestId:u.requestId});var f=FileMerge_extends(this.currFileCtx,{extra:{error:u.error,message:"merge file error, ".concat(u.message),errorCode:u.errorCode},type:"error",stage:this.options.stage,xhr:u.xhr,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currFileCtx.totalDuration});this.failProcess(f)}}])}(m.a);function DirectUpload_typeof(u){return DirectUpload_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},DirectUpload_typeof(u)}function DirectUpload_extends(){return DirectUpload_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},DirectUpload_extends.apply(null,arguments)}function DirectUpload_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,DirectUpload_toPropertyKey(_.key),_)}}function DirectUpload_toPropertyKey(u){var f=function DirectUpload_toPrimitive(u,f){if("object"!=DirectUpload_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=DirectUpload_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==DirectUpload_typeof(f)?f:f+""}function DirectUpload_callSuper(u,f,y){return f=DirectUpload_getPrototypeOf(f),function DirectUpload_possibleConstructorReturn(u,f){if(f&&("object"==DirectUpload_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function DirectUpload_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,DirectUpload_isNativeReflectConstruct()?Reflect.construct(f,y||[],DirectUpload_getPrototypeOf(u).constructor):f.apply(u,y))}function DirectUpload_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(DirectUpload_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function DirectUpload_getPrototypeOf(u){return DirectUpload_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},DirectUpload_getPrototypeOf(u)}function DirectUpload_setPrototypeOf(u,f){return DirectUpload_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},DirectUpload_setPrototypeOf(u,f)}var vt=function(u){function DirectUpload(u){var f,y=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function DirectUpload_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,DirectUpload),(f=DirectUpload_callSuper(this,DirectUpload)).options=u,f.file=u.file,f.context=u.context,f.key=u.key,f.config=y,f.finishArr=[],f.errorLength=0,f.finishSize=0,f.retryUploadTime=Number(y.retryUploadTime)||5,f.processRetry=0,f.lastFinishSize=-1,f.lastProcessPercent=-1,f.lastIntervalSize=-1,f}return function DirectUpload_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&DirectUpload_setPrototypeOf(u,f)}(DirectUpload,u),function DirectUpload_createClass(u,f,y){return f&&DirectUpload_defineProperties(u.prototype,f),y&&DirectUpload_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(DirectUpload,[{key:"start",value:function start(u,f,y){this.failProcess=y,this.successProcess=f,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 u=this,f=this.crc32Array.length,y=0,_=0,m=0;m<f;m++){var v=this.crc32Array[m],b=v.buffer,w=v.crc32,S=this.currentCtx.oid,k=this.currentCtx.signature,E={oid:"[object Array]"===Object.prototype.toString.call(S)?S[m]:S,tosDomain:this.currentCtx.tosDomain},C=qe.urlTemplate(this.config.directUploadFileUrl,E),x=this.config.userId,O=qe.arrayToObject(this.currentCtx.UploadHeader),P=new ht({sliceItem:b,crc32:w,url:C,signature:"[object Array]"===Object.prototype.toString.call(k)?k[m]:k,uploadHeader:O,userId:x,retryTime:this.retryUploadTime,method:"put",enableDebugLog:this.config.enableDebugLog,uploaderCtx:this.context,key:this.key});P.on("complete",function(m){y++,_+y===f&&u.success(m.xhr)}),P.on("error",function(y){++_===f&&u.fail(y.xhr)}),P.on("progress",function(f){u.process(f)}),this.uploadHandlers["".concat(w,"_").concat(Math.round(1e3*Math.random()))]=P,P.upload()}}},{key:"success",value:function success(u){this.finishArr=[];var f=Date.now()-this._st,y=this._uploadSize/f,_=DirectUpload_extends(this.currentCtx,{type:"success",stage:"process",percent:100,extra:{message:"direct upload success"},speed:y,xhr:u,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currentCtx.totalDuration});this.successProcess(_)}},{key:"fail",value:function fail(u){var f=DirectUpload_extends(this.currentCtx,{extra:{message:"direct upload error",errorCode:nt},type:"error",stage:"process",xhr:u,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currentCtx.totalDuration});this.failProcess(f)}},{key:"process",value:function process(u){var f=this.currentCtx.fileSize;this.finishSize=u.loaded,this.finishSize>this.lastFinishSize&&(this.lastFinishSize=this.finishSize);var y=Math.floor(this.finishSize/f*100*100)/100||0,_=DirectUpload_extends(this.currentCtx,{stage:"process",percent:y});y>this.lastProcessPercent&&100!==y&&(this.lastProcessPercent=y,this.context._broadcast("progress",_))}},{key:"stop",value:function stop(){Object.values(this.uploadHandlers).forEach(function(u){u.abort()})}}])}(m.a);function CommitUpload_typeof(u){return CommitUpload_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},CommitUpload_typeof(u)}function CommitUpload_extends(){return CommitUpload_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},CommitUpload_extends.apply(null,arguments)}function CommitUpload_ownKeys(u,f){var y=Object.keys(u);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(u);f&&(_=_.filter(function(f){return Object.getOwnPropertyDescriptor(u,f).enumerable})),y.push.apply(y,_)}return y}function CommitUpload_objectSpread(u){for(var f=1;f<arguments.length;f++){var y=null!=arguments[f]?arguments[f]:{};f%2?CommitUpload_ownKeys(Object(y),!0).forEach(function(f){CommitUpload_defineProperty(u,f,y[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(y)):CommitUpload_ownKeys(Object(y)).forEach(function(f){Object.defineProperty(u,f,Object.getOwnPropertyDescriptor(y,f))})}return u}function CommitUpload_defineProperty(u,f,y){return(f=CommitUpload_toPropertyKey(f))in u?Object.defineProperty(u,f,{value:y,enumerable:!0,configurable:!0,writable:!0}):u[f]=y,u}function CommitUpload_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,CommitUpload_toPropertyKey(_.key),_)}}function CommitUpload_toPropertyKey(u){var f=function CommitUpload_toPrimitive(u,f){if("object"!=CommitUpload_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=CommitUpload_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==CommitUpload_typeof(f)?f:f+""}function CommitUpload_callSuper(u,f,y){return f=CommitUpload_getPrototypeOf(f),function CommitUpload_possibleConstructorReturn(u,f){if(f&&("object"==CommitUpload_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function CommitUpload_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,CommitUpload_isNativeReflectConstruct()?Reflect.construct(f,y||[],CommitUpload_getPrototypeOf(u).constructor):f.apply(u,y))}function CommitUpload_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(CommitUpload_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function CommitUpload_getPrototypeOf(u){return CommitUpload_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},CommitUpload_getPrototypeOf(u)}function CommitUpload_setPrototypeOf(u,f){return CommitUpload_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},CommitUpload_setPrototypeOf(u,f)}var bt=function(u){function CommitUpload(u,f){var y;return function CommitUpload_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,CommitUpload),(y=CommitUpload_callSuper(this,CommitUpload)).options=u,y.config=f,y.uploaderCtx=u.context,y.currFileCtx=u.context.tasks[u.key],y.isImageBatchUpload=!!y.options.isImageBatchUpload,y.serviceName=u.serviceName||je,y.transport=new Je,y.eventInit(),y}return function CommitUpload_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&CommitUpload_setPrototypeOf(u,f)}(CommitUpload,u),function CommitUpload_createClass(u,f,y){return f&&CommitUpload_defineProperties(u.prototype,f),y&&CommitUpload_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(CommitUpload,[{key:"commitUpload",value:function commitUpload(){var u,f=this,y=this.options.key,_=this.options.context.tasks[y],m=ze[this.config.region],v="",b={};if(this.serviceName===je){var w=this.config.videoConfig.spaceName;v=this.config.videoHost||Me,b={Action:"CommitUploadInfo",Version:"2023-01-01"},u={SpaceName:w,SessionKey:_.SessionKey};var S=this.options.processAction;S&&Array.isArray(S)&&S.length>0&&(u.Functions=this.options.processAction),this.options.callbackArgs&&(u.CallbackArgs=this.options.callbackArgs)}else b={Action:"CommitImageUpload",Version:"2018-08-01",SessionKey:_.SessionKey},this.options.serviceId||this.config.imageConfig&&this.config.imageConfig.serviceId?b.ServiceId=this.options.serviceId||this.config.imageConfig.serviceId:b.SpaceName=this.config.videoConfig&&this.config.videoConfig.spaceName;this.config.accountId&&(b["X-Account-Id"]=this.config.accountId);var k=qe.toQueryString(b),E=this.currFileCtx.proxyStsToken||this.config.stsToken,C={method:"POST",url:"".concat(v,"?").concat(k),timeout:3e4,region:m,params:b,headers:{}};if(this.config.useConsoleMode)this.config.commit(b,u).then(function(u){if(u.errorCode||u.error)f.fail(u);else{var y=u.result,_=u.xhr;f.success(y,_)}},function(u){f.fail(u)});else{if(this.serviceName===je){var x=Object.keys(u).map(function(f){return"[object Array]"===Object.prototype.toString.call(u[f])||"[object Object]"===Object.prototype.toString.call(u[f])?"".concat(f,"=").concat(encodeURIComponent(JSON.stringify(u[f]))):"SessionKey"===f?"".concat(f,"=").concat(encodeURIComponent(u[f])):"".concat(f,"=").concat(u[f])}).join("&");C.headers["Content-Type"]="application/x-www-form-urlencoded",C.body=x,C.custom=C.body}else C.custom="none",C.headers["Content-Type"]="application/json";var O=new Ye(C,this.serviceName,{isVolcengine:!0}),P=E.AccessKeyID,U=E.AccessKeyId,D=E.SecretAccessKey,I=E.SessionToken;O.addAuthorization({accessKeyId:U||P,secretAccessKey:D,sessionToken:I},new Date),this.transport.send(C)}}},{key:"start",value:function start(u,f,y){this.successProcess=f,this.failProcess=y,this._st=Date.now();try{this.commitUpload()}catch(u){this.fail({error:"catch error: ".concat(u.toString())})}}},{key:"eventInit",value:function eventInit(){var u=this;this.transport.on("complete",function(f){try{var y=JSON.parse(f.response);if(y.ResponseMetadata.Error)u.fail({xhr:f,errorCode:y.ResponseMetadata.Error.CodeN,error:y.ResponseMetadata.Error.Code,message:y.ResponseMetadata.Error.Message});else{var _=y.Result;u.success(_,f)}}catch(y){u.fail({error:"catch error: ".concat(y.toString()),xhr:f})}}),this.transport.on("error",function(f){var y={error:"request fail: ".concat(f.statusText||f.errText||"UNKNOWN"),xhr:f};if(f.response)try{var _=JSON.parse(f.response);_.ResponseMetadata&&_.ResponseMetadata.Error&&(y.errorCode=_.ResponseMetadata.Error.CodeN,y.error=_.ResponseMetadata.Error.Code,y.message=_.ResponseMetadata.Error.Message)}catch(u){}u.fail(y)})}},{key:"success",value:function success(u,f){var y={};if(this.options.type===Ue&&this.config.imageConfig&&this.config.imageConfig.serviceId)if(this.isImageBatchUpload){var _=u.Results,m=u.PluginResult||[];_.forEach(function(u,f){_[f]=CommitUpload_objectSpread(CommitUpload_objectSpread({},_[f]),m[f])}),y=_}else CommitUpload_extends(y=u.Results[0],u.PluginResult&&u.PluginResult[0]);else y=u.Data;var v=CommitUpload_extends(this.currFileCtx,{stage:"complete",type:"success",percent:100,extra:{message:"upload successful"},uploadResult:y,xhr:f,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currFileCtx.totalDuration});this.successProcess&&this.successProcess(v)}},{key:"fail",value:function fail(u){var f=this.options.context,y=this.options.key,_=u.xhr,m=u.errorCode||st,v="commit upload error: UNKNOWN";_&&(v=0===_.status?"commit upload error: NETERROR":u.message||"commit upload error: ".concat(_.status));var b=CommitUpload_extends(f.tasks[y],{extra:{message:v,error:u.error,errorCode:m,requestId:u.requestId},type:"error",stage:"complete",xhr:_,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currFileCtx.totalDuration});this.failProcess(b)}}])}(m.a);function Queue_typeof(u){return Queue_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},Queue_typeof(u)}function Queue_extends(){return Queue_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},Queue_extends.apply(null,arguments)}function Queue_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,Queue_toPropertyKey(_.key),_)}}function Queue_toPropertyKey(u){var f=function Queue_toPrimitive(u,f){if("object"!=Queue_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=Queue_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==Queue_typeof(f)?f:f+""}function Queue_callSuper(u,f,y){return f=Queue_getPrototypeOf(f),function Queue_possibleConstructorReturn(u,f){if(f&&("object"==Queue_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function Queue_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,Queue_isNativeReflectConstruct()?Reflect.construct(f,y||[],Queue_getPrototypeOf(u).constructor):f.apply(u,y))}function Queue_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(Queue_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function Queue_getPrototypeOf(u){return Queue_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},Queue_getPrototypeOf(u)}function Queue_setPrototypeOf(u,f){return Queue_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},Queue_setPrototypeOf(u,f)}var wt=function(u){function Queue(u){var f,y=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},_=arguments.length>2?arguments[2]:void 0,m=arguments.length>3?arguments[3]:void 0;return function Queue_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,Queue),(f=Queue_callSuper(this,Queue,[u])).tasks=u,f.config=y,f.key=m,f.uploaderCtx=_,f.current=0,f.length=f.tasks.length,f.taskError={},f.uploadList=[],f.retryTaskTime=y.retryTaskTime||3,f}return function Queue_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&Queue_setPrototypeOf(u,f)}(Queue,u),function Queue_createClass(u,f,y){return f&&Queue_defineProperties(u.prototype,f),y&&Queue_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(Queue,[{key:"start",value:function start(){var u=this.tasks.shift();u&&(this.current=u.index,this.execTask(u))}},{key:"execTask",value:function execTask(u){var f=this,y=u.key,_=this.uploaderCtx,m=_.tasks[y],v=m.cacheTask,b=_.taskList[y].length;v&&u.index>0&&u.index<v?this.start():(m.currentTask=u.index,1===m.status&&u&&u.func.call(u.context,u.arg,function(v){var w=m[u.index+1];w&&0!==u.index?_._saveTask(y,{currentTask:w.index,stage:w.stage}):u.index===b-1&&_._removeTaskCache(y),f.success(v),f.tasks.length>0?f.start():_._queueSuccess(y)},function(v){var b,w,S,k,E,C,x;if(debugLog(f.config.enableDebugLog,"log","错误码 ".concat(null===(b=v.extra)||void 0===b?void 0:b.errorCode,", (阶段: ").concat(v.stage||u.stage,"):"),{stage:v.stage||u.stage,errorCode:null===(w=v.extra)||void 0===w?void 0:w.errorCode,message:null===(S=v.extra)||void 0===S?void 0:S.message,error:null===(k=v.extra)||void 0===k?void 0:k.error}),v.xhr&&v.xhr.status>=400)f.fail(v);else{var O,P,U,D;if((null===(E=v.extra)||void 0===E?void 0:E.errorCode)===at||(null===(C=v.extra)||void 0===C?void 0:C.errorCode)===ct)return debugLog(f.config.enableDebugLog,"warn","错误码 ".concat(null===(O=v.extra)||void 0===O?void 0:O.errorCode,",跳过重试和容灾 (阶段: ").concat(v.stage||u.stage,"):"),{stage:v.stage||u.stage,errorCode:null===(P=v.extra)||void 0===P?void 0:P.errorCode,message:null===(U=v.extra)||void 0===U?void 0:U.message,error:null===(D=v.extra)||void 0===D?void 0:D.error}),_._removeTaskCache(y),v.key=y,void f.fail(v);if(f.taskError[y])if(f.taskError[y]<f.retryTaskTime)f.taskError[y]++,f.execTask(u),debugLog(f.config.enableDebugLog,"log","重试次数 ".concat(f.taskError[y],",重试任务 (阶段: ").concat(u.stage,"):"),{stage:u.stage,retryCount:f.taskError[y]});else if((null==m||null===(x=m.fallbackStoreInfoList)||void 0===x?void 0:x.length)>0){debugLog(f.config.enableDebugLog,"log","使用备用节点重试 (阶段: ".concat(u.stage,"):"),{stage:u.stage,retryCount:f.taskError[y]});var I=m.fallbackStoreInfoList.shift();m.tosDomain="".concat(f.config.schema,"://").concat(I.UploadHost),m.oid=I.StoreInfo.StoreUri,m.signature=I.StoreInfo.Auth,m.SessionKey=I.SessionKey,m.UploadID=I.StoreInfo.UploadID,m.useFallback=!0,f.taskError[y]=0,f.execTask(u)}else v.key=y,f.fail(v);else f.taskError[y]=1,f.execTask(u),debugLog(f.config.enableDebugLog,"log","重试次数 ".concat(f.taskError[y],",重试任务 (阶段: ").concat(u.stage,"):"),{stage:u.stage,retryCount:f.taskError[y]})}}))}},{key:"addTask",value:function addTask(u){this.tasks.push(u)}},{key:"success",value:function success(u){if(u.xhr){var f=u.xhr;u.req={url:f.currentUrl,param:f.params},u.res={status:f.status,header:f.getAllResponseHeaders(),body:f.responseText},delete u.xhr}Queue_extends(u,{type:"success"});try{this.uploaderCtx._broadcast(u.stage,u)}catch(u){}this.uploaderCtx.logger.send(u)}},{key:"fail",value:function fail(u){var f,y,_=this.uploaderCtx;if(u.xhr){var m=u.xhr;u.req={url:m.currentUrl,param:m.params},u.res={status:m.status,header:m.getAllResponseHeaders(),body:m.responseText},u.extra&&(u.extra.req=u.req,u.extra.res=u.res),delete u.xhr}Queue_extends(u,{type:"error"});try{_._broadcast("error",u)}catch(u){}_.logger.send(u),1!==u.currentTask&&((null===(f=u.extra)||void 0===f?void 0:f.errorCode)!==at&&(null===(y=u.extra)||void 0===y?void 0:y.errorCode)!==ct?_.tasks[u.key].isBreak?_._cancel(u.key):_._pause(u.key):_._cancel(u.key))}},{key:"cancel",value:function cancel(u){var f=this.key,y=this.uploaderCtx.tasks[f].currentTask,_=this.uploaderCtx.tasks[f].isDirect?this.uploaderCtx.taskList[f][y-1]:this.uploaderCtx.taskList[f][y];if(u){if(_&&3===_.index){var m=_.context;Object.values(m.uploadHandlers).forEach(function(u){u.abort()})}}else{if(this.tasks=[],_&&3===_.index)_.context.stop();this.uploaderCtx._removeTaskCache(f)}}},{key:"restart",value:function restart(){this.uploadList.forEach(function(u){u.cancel=!1}),this.start()}}])}(m.a);function MainClass_typeof(u){return MainClass_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},MainClass_typeof(u)}function MainClass_extends(){return MainClass_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},MainClass_extends.apply(null,arguments)}function MainClass_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,MainClass_toPropertyKey(_.key),_)}}function MainClass_toPropertyKey(u){var f=function MainClass_toPrimitive(u,f){if("object"!=MainClass_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=MainClass_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==MainClass_typeof(f)?f:f+""}function MainClass_possibleConstructorReturn(u,f){if(f&&("object"==MainClass_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function MainClass_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}function MainClass_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(MainClass_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function MainClass_getPrototypeOf(u){return MainClass_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},MainClass_getPrototypeOf(u)}function MainClass_setPrototypeOf(u,f){return MainClass_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},MainClass_setPrototypeOf(u,f)}var St=function(u){function MainClass(u){var f;return function MainClass_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,MainClass),f=function MainClass_callSuper(u,f,y){return f=MainClass_getPrototypeOf(f),MainClass_possibleConstructorReturn(u,MainClass_isNativeReflectConstruct()?Reflect.construct(f,y||[],MainClass_getPrototypeOf(u).constructor):f.apply(u,y))}(this,MainClass,[u]),u.region?Object.keys(ze).includes(u.region)?(f.config=MainClass_extends({},v),f._mergeOptions(f.config,u),f.tasks={},f.taskList={},f.cache={},f.storage=qe.storage(f,f.config.useLocalStorage),f.logger=f.config.noLog?{send:function send(){}}:new Ne(f.config,f),f):(console.error("unknown region: ".concat(u.region)),MainClass_possibleConstructorReturn(f)):(console.error("region is required"),MainClass_possibleConstructorReturn(f))}return function MainClass_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&MainClass_setPrototypeOf(u,f)}(MainClass,u),function MainClass_createClass(u,f,y){return f&&MainClass_defineProperties(u.prototype,f),y&&MainClass_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(MainClass,[{key:"_mergeOptions",value:function _mergeOptions(u,f){f&&"object"===MainClass_typeof(f)&&(MainClass_extends(u,f),u.log.userId=f.userId||u.userId,u.log.appId=f.appId||u.appId,f.hasOwnProperty("useFileNameInCacheKey")&&(u.useFileNameInCacheKey=f.useFileNameInCacheKey),Object.keys(f).forEach(function(y){"vodDomain"===y&&(u.replace[y]=f[y])}))}},{key:"_setCache",value:function _setCache(u,f){this.storage.setItem(u,f)}},{key:"_getCache",value:function _getCache(u){return this.storage.getItem(u)}},{key:"_removeCache",value:function _removeCache(u){u?this.storage.removeItem(u):this.storage.clear()}},{key:"_addTask",value:function _addTask(u,f){var y=this.tasks,_=this.taskList;y[u]&&y[u].task?(_[u].push(f),y[u].task.addTask(f)):(_[u]=[],_[u].push(f),y[u]=y[u]||{},y[u].task=new wt([],this.config,this,u),y[u].task.addTask(f))}},{key:"_broadcast",value:function _broadcast(u,f){var y=this.tasks[f.key].status;if(y===Ie||0===y)try{this.emit(u,f)}catch(u){var _=!("[object Error]"!==Object.prototype.toString.call(u));if(!_||_&&"Error"===u.name)throw u}}},{key:"_addCrc32ProcessTask",value:function _addCrc32ProcessTask(u,f,y){var _=y.isDirect,m=y.isImageBatchUpload,v=new We({file:u.file,context:this,key:f,isDirect:_,isImageBatchUpload:m},this.config),b={context:v,func:v.start,arg:{},key:f,index:0,stage:"crc32"};this._addTask(f,b)}},{key:"_addPreUploadTask",value:function _addPreUploadTask(u,f,y){var _=y.isImageBatchUpload,m=y.serviceName,v={file:u.file,stsToken:u.stsToken,context:this,type:u.type||Pe,preUploadUriParams:u.preUploadUriParams?u.preUploadUriParams:{},storeKey:u.storeKey,key:f,isImageBatchUpload:_,fileName:u.fileName||null,fileExtension:u.fileExtension||null,storageClass:u.storageClass||null,serviceName:m},b=new ft(v,this.config),w={context:b,func:b.start,arg:{},key:f,index:1,stage:"preUpload"};this._addTask(f,w)}},{key:"_addDirectUploadTask",value:function _addDirectUploadTask(u,f,y){var _=y.isImageBatchUpload,m=new vt({file:u.file,context:this,key:f,isImageBatchUpload:_},this.config),v={context:m,func:m.start,arg:{},key:f,index:3,stage:"process"};this._addTask(f,v)}},{key:"_addInitUploadIDTask",value:function _addInitUploadIDTask(u,f){var y=new dt({file:u.file,context:this,key:f},this.config),_={context:y,func:y.start,arg:{},key:f,index:2,stage:"initUploadID"};this._addTask(f,_)}},{key:"_addUploadProcessTask",value:function _addUploadProcessTask(u,f){var y=new _t({file:u.file,context:this,key:f},this.config),_={context:y,func:y.start,arg:{},key:f,index:3,stage:"process"};this._addTask(f,_)}},{key:"_mergeFileTask",value:function _mergeFileTask(u,f){var y=new mt({file:u.file,context:this,stage:"fileMerge",key:f},this.config),_={context:y,func:y.start,arg:{},key:f,index:4,stage:"fileMerge"};this._addTask(f,_)}},{key:"_getMetaInfoTask",value:function _getMetaInfoTask(u,f){var y=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},_=y.isImageBatchUpload,m=void 0!==_&&_,v=y.serviceName,b={file:u.file,context:this,data:u.data,type:u.type||Pe,callbackArgs:u.callbackArgs,key:f,isImageBatchUpload:m,serviceName:v,processAction:u.processAction},w=new bt(b,this.config),S={context:w,func:w.start,arg:{},key:f,index:5,stage:"complete"};this._addTask(f,S)}},{key:"_addAllUploadProcess",value:function _addAllUploadProcess(u,f,y){var _=u.type===Ue&&"[object Array]"===Object.prototype.toString.call(u.file);this.tasks[f]=this.tasks[f]||{},this.tasks[f].fileType=u.type||Pe,this.tasks[f].fileSize=u.file&&u.file.size,this.tasks[f].proxyStsToken=u.stsToken;var m=u.file.size<10485760||_;this._addCrc32ProcessTask(u,f,{isDirect:m,isImageBatchUpload:_}),this._addPreUploadTask(u,f,{isImageBatchUpload:_,serviceName:y}),this.config.useLocalStorage&&(this.tasks[f].enableDiskBreakPoint=!0),m?this._addDirectUploadTask(u,f,{isImageBatchUpload:_}):(this._addInitUploadIDTask(u,f),this._addUploadProcessTask(u,f),this._mergeFileTask(u,f)),this._getMetaInfoTask(u,f,{isImageBatchUpload:_,serviceName:y})}},{key:"_run",value:function _run(u){var f=this.tasks,y=navigator.userAgent.toLowerCase().match(/msie ([\d.]+)/);if(y&&y[1]&&Number(y[1])<=9)return this._broadcast("error",MainClass_extends(f[u],{key:u,status:0,stage:"browserError",extra:{message:"cannot support the browser below ie10"},type:"error"})),this.logger.send(f[u]),void this._cancel(u);if(f[u])if(f[u].status===Ae)this._restart(u);else{var _=new Date;f[u].startTime=_.getTime(),f[u].task&&f[u].status!==Ie&&f[u].task.tasks.length&&(f[u].status=Ie,this.logger.send(MainClass_extends({},f[u],{extra:{message:"start upload"},type:"start",key:u})),f[u].task.start())}else console.warn("".concat(u," is not exit in object tasks, stop running..."))}},{key:"_restart",value:function _restart(u){var f=this,y=this.tasks;if(y[u]){var _=y[u].task,m=y[u].currentTask||0;this.taskList[u].forEach(function(y,v){y.index===m&&(_.tasks=f.taskList[u].slice(v))}),_&&y[u].status!==Ie&&_.tasks.length&&(y[u].status=Ie,_.restart())}else console.warn("".concat(u," is not exit in object tasks"))}},{key:"_cancel",value:function _cancel(u){var f=this.tasks;f[u]?(f[u].status=Te,f[u].task.cancel(!1),this.taskList[u]=[]):console.warn("".concat(u," is not exit in object tasks"))}},{key:"_pause",value:function _pause(u){var f=this.tasks;f[u]?(f[u].status=Ae,f[u].task.cancel(!0)):console.warn("".concat(u," is not exit in object tasks"))}},{key:"_removeTaskCache",value:function _removeTaskCache(u){var f=this.tasks;if(f[u]){var y=f[u].crc32Key;y&&this._removeCache(y)}else console.warn("".concat(u," is not exit in object tasks"))}},{key:"_saveTask",value:function _saveTask(u,f){var y=MainClass_extends({},this.tasks[u],f||{}),_=y.crc32Key;if(_){var m={SessionKey:y.SessionKey,UploadHeader:y.UploadHeader,fileName:y.fileName,oid:y.oid,uploadID:y.uploadID,signature:y.signature,tosDomain:y.tosDomain,hasMerge:y.hasMerge};Object.keys(m).forEach(function(u){m[u]||delete m[u]});try{this._setCache(_,JSON.stringify(m))}catch(u){return[!1,u.message]}return[!0,""]}}},{key:"_queueSuccess",value:function _queueSuccess(u){var f=this.tasks;if(f[u]){var y=new Date;f[u].endTime=y.getTime(),f[u].time=f[u].endTime-f[u].startTime,f[u].status=0,this.taskList[u]=[]}else console.warn("".concat(u," is not exit in object tasks"))}},{key:"_removeFile",value:function _removeFile(u){delete this.tasks[u]}},{key:"_batchAction",value:function _batchAction(u){var f=this.tasks;Object.keys(f).forEach(function(f){u&&u(f)})}},{key:"_refreshStsToken",value:function _refreshStsToken(u){var f=this,y=this.tasks;Object.keys(y).forEach(function(_){var m=y[_],v=MainClass_extends({},m,{proxyStsToken:u});m.proxyStsToken=u;var b=v.crc32Key;b&&(delete v.task,delete v.xhr,delete v.crc32Array,m.proxyStsToken=u,f._setCache(b,JSON.stringify(v)))})}},{key:"_setOption",value:function _setOption(u){this._mergeOptions(this.config,u)}},{key:"_setServiceId",value:function _setServiceId(u){!this.config.imageConfig&&u?this.config.imageConfig={serviceId:u}:this.config.imageConfig.serviceId=u}},{key:"_getServiceId",value:function _getServiceId(){var u;return null===(u=this.config.imageConfig)||void 0===u?void 0:u.serviceId}},{key:"_getOption",value:function _getOption(u){var f=MainClass_extends({},this.config);return Object.keys(f).forEach(function(u){(u.indexOf("Url")>-1||"replace"===u||"log"===u)&&delete f[u]}),u?f[u]:f}},{key:"_userCancel",value:function _userCancel(u){var f=this,y=this.tasks;u?(this._cancel(u),this.logger.send(MainClass_extends({},y[u],{type:"cancel"}))):Object.keys(y).forEach(function(u){f._cancel(u),f.logger.send(MainClass_extends({},y[u],{type:"cancel"}))})}},{key:"_userPause",value:function _userPause(u){var f=this,y=this.tasks;u?(this._pause(u),this.logger.send(MainClass_extends({},y[u],{type:"pause"}))):Object.keys(y).forEach(function(u){f._pause(u),f.logger.send(MainClass_extends({},y[u],{type:"pause"}))})}}])}(m.a),kt={checkFile:function checkFile(){},checkStsToken:function checkStsToken(u){return!u||u.SessionToken&&u.SecretAccessKey&&(u.AccessKeyId||u.AccessKeyID)}};function entry_typeof(u){return entry_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},entry_typeof(u)}function entry_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,entry_toPropertyKey(_.key),_)}}function entry_toPropertyKey(u){var f=function entry_toPrimitive(u,f){if("object"!=entry_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=entry_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==entry_typeof(f)?f:f+""}function entry_callSuper(u,f,y){return f=entry_getPrototypeOf(f),function entry_possibleConstructorReturn(u,f){if(f&&("object"==entry_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function entry_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,entry_isNativeReflectConstruct()?Reflect.construct(f,y||[],entry_getPrototypeOf(u).constructor):f.apply(u,y))}function entry_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(entry_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function entry_getPrototypeOf(u){return entry_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},entry_getPrototypeOf(u)}function entry_setPrototypeOf(u,f){return entry_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},entry_setPrototypeOf(u,f)}var Et=function(u){function BytePlusUploader(){return function entry_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,BytePlusUploader),entry_callSuper(this,BytePlusUploader,arguments)}return function entry_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&entry_setPrototypeOf(u,f)}(BytePlusUploader,u),function entry_createClass(u,f,y){return f&&entry_defineProperties(u.prototype,f),y&&entry_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(BytePlusUploader,[{key:"start",value:function start(u){this.abort=!1,u?this._run(u):this._batchAction(this._run.bind(this))}},{key:"addFile",value:function addFile(u){if(!(this.config.useConsoleMode||u&&kt.checkStsToken(u.stsToken)))return this.emit("error",{extra:{message:ut,errorCode:tt}}),null;if(u.file&&u.file instanceof Blob){var f=qe.getUnique("file");return this._addAllUploadProcess(u,f,je),f}return this.emit("error",{extra:{message:lt,errorCode:et}}),null}},{key:"removeFile",value:function removeFile(u){u&&this._removeFile(u)}},{key:"cancel",value:function cancel(u){u?this._userCancel(u):this._batchAction(this._userCancel.bind(this))}},{key:"pause",value:function pause(u){this._userPause(u)}},{key:"restart",value:function restart(u){u?this._restart(u):this._batchAction(this._restart.bind(this))}},{key:"refreshStsToken",value:function refreshStsToken(u){this._refreshStsToken(u)}},{key:"setOption",value:function setOption(u){this._setOption(u)}},{key:"getOption",value:function getOption(u){return this._getOption(u)}}])}(St)}]).default});
|
|
1
|
+
!function webpackUniversalModuleDefinition(u,f){"object"==typeof exports&&"object"==typeof module?module.exports=f():"function"==typeof define&&define.amd?define([],f):"object"==typeof exports?exports.BytePlusUploader=f():u.BytePlusUploader=f()}("undefined"!=typeof self?self:this,function(){return function(u){var f={};function __webpack_require__(y){if(f[y])return f[y].exports;var _=f[y]={i:y,l:!1,exports:{}};return u[y].call(_.exports,_,_.exports,__webpack_require__),_.l=!0,_.exports}return __webpack_require__.m=u,__webpack_require__.c=f,__webpack_require__.d=function(u,f,y){__webpack_require__.o(u,f)||Object.defineProperty(u,f,{enumerable:!0,get:y})},__webpack_require__.r=function(u){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(u,"__esModule",{value:!0})},__webpack_require__.t=function(u,f){if(1&f&&(u=__webpack_require__(u)),8&f)return u;if(4&f&&"object"==typeof u&&u&&u.__esModule)return u;var y=Object.create(null);if(__webpack_require__.r(y),Object.defineProperty(y,"default",{enumerable:!0,value:u}),2&f&&"string"!=typeof u)for(var _ in u)__webpack_require__.d(y,_,function(f){return u[f]}.bind(null,_));return y},__webpack_require__.n=function(u){var f=u&&u.__esModule?function getDefault(){return u.default}:function getModuleExports(){return u};return __webpack_require__.d(f,"a",f),f},__webpack_require__.o=function(u,f){return Object.prototype.hasOwnProperty.call(u,f)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=9)}([function(u,f,y){"use strict";var _,m="object"==typeof Reflect?Reflect:null,v=m&&"function"==typeof m.apply?m.apply:function ReflectApply(u,f,y){return Function.prototype.apply.call(u,f,y)};_=m&&"function"==typeof m.ownKeys?m.ownKeys:Object.getOwnPropertySymbols?function ReflectOwnKeys(u){return Object.getOwnPropertyNames(u).concat(Object.getOwnPropertySymbols(u))}:function ReflectOwnKeys(u){return Object.getOwnPropertyNames(u)};var b=Number.isNaN||function NumberIsNaN(u){return u!=u};function EventEmitter(){EventEmitter.init.call(this)}u.exports=EventEmitter,u.exports.once=function once(u,f){return new Promise(function(y,_){function errorListener(y){u.removeListener(f,resolver),_(y)}function resolver(){"function"==typeof u.removeListener&&u.removeListener("error",errorListener),y([].slice.call(arguments))}eventTargetAgnosticAddListener(u,f,resolver,{once:!0}),"error"!==f&&function addErrorHandlerIfEventEmitter(u,f,y){"function"==typeof u.on&&eventTargetAgnosticAddListener(u,"error",f,y)}(u,errorListener,{once:!0})})},EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._eventsCount=0,EventEmitter.prototype._maxListeners=void 0;var w=10;function checkListener(u){if("function"!=typeof u)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof u)}function _getMaxListeners(u){return void 0===u._maxListeners?EventEmitter.defaultMaxListeners:u._maxListeners}function _addListener(u,f,y,_){var m,v,b;if(checkListener(y),void 0===(v=u._events)?(v=u._events=Object.create(null),u._eventsCount=0):(void 0!==v.newListener&&(u.emit("newListener",f,y.listener?y.listener:y),v=u._events),b=v[f]),void 0===b)b=v[f]=y,++u._eventsCount;else if("function"==typeof b?b=v[f]=_?[y,b]:[b,y]:_?b.unshift(y):b.push(y),(m=_getMaxListeners(u))>0&&b.length>m&&!b.warned){b.warned=!0;var w=new Error("Possible EventEmitter memory leak detected. "+b.length+" "+String(f)+" listeners added. Use emitter.setMaxListeners() to increase limit");w.name="MaxListenersExceededWarning",w.emitter=u,w.type=f,w.count=b.length,function ProcessEmitWarning(u){console&&console.warn&&console.warn(u)}(w)}return u}function onceWrapper(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _onceWrap(u,f,y){var _={fired:!1,wrapFn:void 0,target:u,type:f,listener:y},m=onceWrapper.bind(_);return m.listener=y,_.wrapFn=m,m}function _listeners(u,f,y){var _=u._events;if(void 0===_)return[];var m=_[f];return void 0===m?[]:"function"==typeof m?y?[m.listener||m]:[m]:y?function unwrapListeners(u){for(var f=new Array(u.length),y=0;y<f.length;++y)f[y]=u[y].listener||u[y];return f}(m):arrayClone(m,m.length)}function listenerCount(u){var f=this._events;if(void 0!==f){var y=f[u];if("function"==typeof y)return 1;if(void 0!==y)return y.length}return 0}function arrayClone(u,f){for(var y=new Array(f),_=0;_<f;++_)y[_]=u[_];return y}function eventTargetAgnosticAddListener(u,f,y,_){if("function"==typeof u.on)_.once?u.once(f,y):u.on(f,y);else{if("function"!=typeof u.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof u);u.addEventListener(f,function wrapListener(m){_.once&&u.removeEventListener(f,wrapListener),y(m)})}}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:!0,get:function(){return w},set:function(u){if("number"!=typeof u||u<0||b(u))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+u+".");w=u}}),EventEmitter.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},EventEmitter.prototype.setMaxListeners=function setMaxListeners(u){if("number"!=typeof u||u<0||b(u))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+u+".");return this._maxListeners=u,this},EventEmitter.prototype.getMaxListeners=function getMaxListeners(){return _getMaxListeners(this)},EventEmitter.prototype.emit=function emit(u){for(var f=[],y=1;y<arguments.length;y++)f.push(arguments[y]);var _="error"===u,m=this._events;if(void 0!==m)_=_&&void 0===m.error;else if(!_)return!1;if(_){var b;if(f.length>0&&(b=f[0]),b instanceof Error)throw b;var w=new Error("Unhandled error."+(b?" ("+b.message+")":""));throw w.context=b,w}var S=m[u];if(void 0===S)return!1;if("function"==typeof S)v(S,this,f);else{var k=S.length,E=arrayClone(S,k);for(y=0;y<k;++y)v(E[y],this,f)}return!0},EventEmitter.prototype.addListener=function addListener(u,f){return _addListener(this,u,f,!1)},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.prependListener=function prependListener(u,f){return _addListener(this,u,f,!0)},EventEmitter.prototype.once=function once(u,f){return checkListener(f),this.on(u,_onceWrap(this,u,f)),this},EventEmitter.prototype.prependOnceListener=function prependOnceListener(u,f){return checkListener(f),this.prependListener(u,_onceWrap(this,u,f)),this},EventEmitter.prototype.removeListener=function removeListener(u,f){var y,_,m,v,b;if(checkListener(f),void 0===(_=this._events))return this;if(void 0===(y=_[u]))return this;if(y===f||y.listener===f)0===--this._eventsCount?this._events=Object.create(null):(delete _[u],_.removeListener&&this.emit("removeListener",u,y.listener||f));else if("function"!=typeof y){for(m=-1,v=y.length-1;v>=0;v--)if(y[v]===f||y[v].listener===f){b=y[v].listener,m=v;break}if(m<0)return this;0===m?y.shift():function spliceOne(u,f){for(;f+1<u.length;f++)u[f]=u[f+1];u.pop()}(y,m),1===y.length&&(_[u]=y[0]),void 0!==_.removeListener&&this.emit("removeListener",u,b||f)}return this},EventEmitter.prototype.off=EventEmitter.prototype.removeListener,EventEmitter.prototype.removeAllListeners=function removeAllListeners(u){var f,y,_;if(void 0===(y=this._events))return this;if(void 0===y.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==y[u]&&(0===--this._eventsCount?this._events=Object.create(null):delete y[u]),this;if(0===arguments.length){var m,v=Object.keys(y);for(_=0;_<v.length;++_)"removeListener"!==(m=v[_])&&this.removeAllListeners(m);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(f=y[u]))this.removeListener(u,f);else if(void 0!==f)for(_=f.length-1;_>=0;_--)this.removeListener(u,f[_]);return this},EventEmitter.prototype.listeners=function listeners(u){return _listeners(this,u,!0)},EventEmitter.prototype.rawListeners=function rawListeners(u){return _listeners(this,u,!1)},EventEmitter.listenerCount=function(u,f){return"function"==typeof u.listenerCount?u.listenerCount(f):listenerCount.call(u,f)},EventEmitter.prototype.listenerCount=listenerCount,EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?_(this._events):[]}},function(u,f,y){u.exports=function(u){return function(f){var y=u,_=y.lib,m=_.WordArray,v=_.Hasher,b=y.algo,w=[],S=[];!function(){function isPrime(u){for(var y=f.sqrt(u),_=2;_<=y;_++)if(!(u%_))return!1;return!0}function getFractionalBits(u){return 4294967296*(u-(0|u))|0}for(var u=2,y=0;y<64;)isPrime(u)&&(y<8&&(w[y]=getFractionalBits(f.pow(u,.5))),S[y]=getFractionalBits(f.pow(u,1/3)),y++),u++}();var k=[],E=b.SHA256=v.extend({_doReset:function(){this._hash=new m.init(w.slice(0))},_doProcessBlock:function(u,f){for(var y=this._hash.words,_=y[0],m=y[1],v=y[2],b=y[3],w=y[4],E=y[5],C=y[6],x=y[7],O=0;O<64;O++){if(O<16)k[O]=0|u[f+O];else{var P=k[O-15],U=(P<<25|P>>>7)^(P<<14|P>>>18)^P>>>3,D=k[O-2],I=(D<<15|D>>>17)^(D<<13|D>>>19)^D>>>10;k[O]=U+k[O-7]+I+k[O-16]}var T=_&m^_&v^m&v,A=(_<<30|_>>>2)^(_<<19|_>>>13)^(_<<10|_>>>22),z=x+((w<<26|w>>>6)^(w<<21|w>>>11)^(w<<7|w>>>25))+(w&E^~w&C)+S[O]+k[O];x=C,C=E,E=w,w=b+z|0,b=v,v=m,m=_,_=z+(A+T)|0}y[0]=y[0]+_|0,y[1]=y[1]+m|0,y[2]=y[2]+v|0,y[3]=y[3]+b|0,y[4]=y[4]+w|0,y[5]=y[5]+E|0,y[6]=y[6]+C|0,y[7]=y[7]+x|0},_doFinalize:function(){var u=this._data,y=u.words,_=8*this._nDataBytes,m=8*u.sigBytes;return y[m>>>5]|=128<<24-m%32,y[14+(m+64>>>9<<4)]=f.floor(_/4294967296),y[15+(m+64>>>9<<4)]=_,u.sigBytes=4*y.length,this._process(),this._hash},clone:function(){var u=v.clone.call(this);return u._hash=this._hash.clone(),u}});y.SHA256=v._createHelper(E),y.HmacSHA256=v._createHmacHelper(E)}(Math),u.SHA256}(y(3))},function(u,f,y){u.exports=function(u){return u.HmacSHA256}(y(3),y(1),y(7))},function(u,f,y){(function(f){u.exports=function(){var u=u||function(u,_){var m;if("undefined"!=typeof window&&window.crypto&&(m=window.crypto),"undefined"!=typeof self&&self.crypto&&(m=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(m=globalThis.crypto),!m&&"undefined"!=typeof window&&window.msCrypto&&(m=window.msCrypto),!m&&void 0!==f&&f.crypto&&(m=f.crypto),!m)try{m=y(6)}catch(u){}var cryptoSecureRandomInt=function(){if(m){if("function"==typeof m.getRandomValues)try{return m.getRandomValues(new Uint32Array(1))[0]}catch(u){}if("function"==typeof m.randomBytes)try{return m.randomBytes(4).readInt32LE()}catch(u){}}throw new Error("Native crypto module could not be used to get secure random number.")},v=Object.create||function(){function F(){}return function(u){var f;return F.prototype=u,f=new F,F.prototype=null,f}}(),b={},w=b.lib={},S=w.Base={extend:function(u){var f=v(this);return u&&f.mixIn(u),f.hasOwnProperty("init")&&this.init!==f.init||(f.init=function(){f.$super.init.apply(this,arguments)}),f.init.prototype=f,f.$super=this,f},create:function(){var u=this.extend();return u.init.apply(u,arguments),u},init:function(){},mixIn:function(u){for(var f in u)u.hasOwnProperty(f)&&(this[f]=u[f]);u.hasOwnProperty("toString")&&(this.toString=u.toString)},clone:function(){return this.init.prototype.extend(this)}},k=w.WordArray=S.extend({init:function(u,f){u=this.words=u||[],this.sigBytes=f!=_?f:4*u.length},toString:function(u){return(u||C).stringify(this)},concat:function(u){var f=this.words,y=u.words,_=this.sigBytes,m=u.sigBytes;if(this.clamp(),_%4)for(var v=0;v<m;v++){var b=y[v>>>2]>>>24-v%4*8&255;f[_+v>>>2]|=b<<24-(_+v)%4*8}else for(var w=0;w<m;w+=4)f[_+w>>>2]=y[w>>>2];return this.sigBytes+=m,this},clamp:function(){var f=this.words,y=this.sigBytes;f[y>>>2]&=4294967295<<32-y%4*8,f.length=u.ceil(y/4)},clone:function(){var u=S.clone.call(this);return u.words=this.words.slice(0),u},random:function(u){for(var f=[],y=0;y<u;y+=4)f.push(cryptoSecureRandomInt());return new k.init(f,u)}}),E=b.enc={},C=E.Hex={stringify:function(u){for(var f=u.words,y=u.sigBytes,_=[],m=0;m<y;m++){var v=f[m>>>2]>>>24-m%4*8&255;_.push((v>>>4).toString(16)),_.push((15&v).toString(16))}return _.join("")},parse:function(u){for(var f=u.length,y=[],_=0;_<f;_+=2)y[_>>>3]|=parseInt(u.substr(_,2),16)<<24-_%8*4;return new k.init(y,f/2)}},x=E.Latin1={stringify:function(u){for(var f=u.words,y=u.sigBytes,_=[],m=0;m<y;m++){var v=f[m>>>2]>>>24-m%4*8&255;_.push(String.fromCharCode(v))}return _.join("")},parse:function(u){for(var f=u.length,y=[],_=0;_<f;_++)y[_>>>2]|=(255&u.charCodeAt(_))<<24-_%4*8;return new k.init(y,f)}},O=E.Utf8={stringify:function(u){try{return decodeURIComponent(escape(x.stringify(u)))}catch(u){throw new Error("Malformed UTF-8 data")}},parse:function(u){return x.parse(unescape(encodeURIComponent(u)))}},P=w.BufferedBlockAlgorithm=S.extend({reset:function(){this._data=new k.init,this._nDataBytes=0},_append:function(u){"string"==typeof u&&(u=O.parse(u)),this._data.concat(u),this._nDataBytes+=u.sigBytes},_process:function(f){var y,_=this._data,m=_.words,v=_.sigBytes,b=this.blockSize,w=v/(4*b),S=(w=f?u.ceil(w):u.max((0|w)-this._minBufferSize,0))*b,E=u.min(4*S,v);if(S){for(var C=0;C<S;C+=b)this._doProcessBlock(m,C);y=m.splice(0,S),_.sigBytes-=E}return new k.init(y,E)},clone:function(){var u=S.clone.call(this);return u._data=this._data.clone(),u},_minBufferSize:0}),U=(w.Hasher=P.extend({cfg:S.extend(),init:function(u){this.cfg=this.cfg.extend(u),this.reset()},reset:function(){P.reset.call(this),this._doReset()},update:function(u){return this._append(u),this._process(),this},finalize:function(u){return u&&this._append(u),this._doFinalize()},blockSize:16,_createHelper:function(u){return function(f,y){return new u.init(y).finalize(f)}},_createHmacHelper:function(u){return function(f,y){return new U.HMAC.init(u,y).finalize(f)}}}),b.algo={});return b}(Math);return u}()}).call(this,y(5))},function(u,f,y){u.exports=function(){return y(8)('!function(e){var r={};function __webpack_require__(_){if(r[_])return r[_].exports;var t=r[_]={i:_,l:!1,exports:{}};return e[_].call(t.exports,t,t.exports,__webpack_require__),t.l=!0,t.exports}__webpack_require__.m=e,__webpack_require__.c=r,__webpack_require__.d=function(e,r,_){__webpack_require__.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:_})},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.t=function(e,r){if(1&r&&(e=__webpack_require__(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var _=Object.create(null);if(__webpack_require__.r(_),Object.defineProperty(_,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var t in e)__webpack_require__.d(_,t,function(r){return e[r]}.bind(null,t));return _},__webpack_require__.n=function(e){var r=e&&e.__esModule?function getDefault(){return e.default}:function getModuleExports(){return e};return __webpack_require__.d(r,"a",r),r},__webpack_require__.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=0)}([function(e,r){function toEight(e){return e.length<8?toEight(e="0".concat(e)):e}function dec2hex(e){if(void 0!==e)return toEight(Number(e).toString(16))}self.onmessage=function(e){var r=e.data,_=r[0],t=r[1],n=function crc32(e,r){var _=[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&&(_=new Int32Array(_));for(var t=-1^r,n=(e=new Uint8Array(e)).length,u=0;u<n;u++)t=_[255&(t^e[u])]^t>>>8;return(-1^t)>>>0}(_,0);postMessage([_,dec2hex(n),t],[_])}}]);',null)}},function(u,f){var y;y=function(){return this}();try{y=y||new Function("return this")()}catch(u){"object"==typeof window&&(y=window)}u.exports=y},function(u,f){},function(u,f,y){u.exports=function(u){!function(){var f=u,y=f.lib.Base,_=f.enc.Utf8;f.algo.HMAC=y.extend({init:function(u,f){u=this._hasher=new u.init,"string"==typeof f&&(f=_.parse(f));var y=u.blockSize,m=4*y;f.sigBytes>m&&(f=u.finalize(f)),f.clamp();for(var v=this._oKey=f.clone(),b=this._iKey=f.clone(),w=v.words,S=b.words,k=0;k<y;k++)w[k]^=1549556828,S[k]^=909522486;v.sigBytes=b.sigBytes=m,this.reset()},reset:function(){var u=this._hasher;u.reset(),u.update(this._iKey)},update:function(u){return this._hasher.update(u),this},finalize:function(u){var f=this._hasher,y=f.finalize(u);return f.reset(),f.finalize(this._oKey.clone().concat(y))}})}()}(y(3))},function(u,f,y){"use strict";var _=window.URL||window.webkitURL;u.exports=function(u,f){try{try{var y;try{(y=new(window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder)).append(u),y=y.getBlob()}catch(f){y=new Blob([u])}return new Worker(_.createObjectURL(y))}catch(f){return new Worker("data:application/javascript,"+encodeURIComponent(u))}}catch(u){if(!f)throw Error("Inline worker is not supported");return new Worker(f)}}},function(u,f,y){"use strict";y.r(f),y.d(f,"default",function(){return Et});var _=y(0),m=y.n(_),v={debug:!1,initUploadFileUrl:"{tosDomain}/{oid}?uploads",uploadChunkedUrl:"{tosDomain}/{oid}?partNumber={number}&uploadID={uploadId}",uploadMergeUrl:"{tosDomain}/{oid}?uploadID={uploadId}",getUploadListUrl:"{tosDomain}/{oid}?uploadID={uploadId}",directUploadFileUrl:"{tosDomain}/{oid}",external:{},getSliceFunc:null,uploadSliceCount:5,retryUploadTime:2,retryProcess:!0,retryProcessTime:3,retryTaskTime:2,maxProcessPause:20,schema:"https",useLocalStorage:!0,useFileNameInCacheKey:!1,enableDebugLog:!1,log:{external:{},appId:"",userId:"",video_id:"",upload_video_url:"",upload_id:"",type:"",stage:"",video_size:0,part_count:0,slice_index:0,extra:{},msg:""},replace:{}};function _typeof(u){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},_typeof(u)}function _extends(){return _extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},_extends.apply(null,arguments)}var b=function e(){return(b=Object.assign||function(u){for(var f,y=1,_=arguments.length;y<_;y++)for(var m in f=arguments[y])Object.prototype.hasOwnProperty.call(f,m)&&(u[m]=f[m]);return u}).apply(this,arguments)};function t(u,f){var y="function"==typeof Symbol&&u[Symbol.iterator];if(!y)return u;var _,m,v=y.call(u),b=[];try{for(;(void 0===f||f-- >0)&&!(_=v.next()).done;)b.push(_.value)}catch(u){m={error:u}}finally{try{_&&!_.done&&(y=v.return)&&y.call(v)}finally{if(m)throw m.error}}return b}function index_base_min_i(){for(var u=[],f=0;f<arguments.length;f++)u=u.concat(t(arguments[f]));return u}var w,S,k,E,C=function(){function e(){this._hooks={},this._cache=[],this._hooksCache={}}return e.prototype.on=function(u,f){u&&f&&"function"==typeof f&&(this._hooks[u]||(this._hooks[u]=[]),this._hooks[u].push(f))},e.prototype.once=function(u,f){var y=this;u&&f&&"function"==typeof f&&this.on(u,function o(_){f(_),y.off(u,o)})},e.prototype.off=function(u,f){if(u&&this._hooks[u]&&this._hooks[u].length)if(f){var y=this._hooks[u].indexOf(f);-1!==y&&this._hooks[u].splice(y,1)}else this._hooks[u]=[]},e.prototype.emit=function(u,f,y){if(y){if(!u)return;-1!==this._cache.indexOf(y)?this._emit(u,f):(this._hooksCache.hasOwnProperty(y)||(this._hooksCache[y]={}),this._hooksCache[y].hasOwnProperty(u)||(this._hooksCache[y][u]=[]),this._hooksCache[y][u].push(f))}else this._emit(u,f)},e.prototype._emit=function(u,f){u&&this._hooks[u]&&this._hooks[u].length&&index_base_min_i(this._hooks[u]).forEach(function(u){try{u(f)}catch(u){}})},e.prototype.set=function(u){u&&-1===this._cache.indexOf(u)&&this._cache.push(u)},e}(),x=function r(u){return null!=u&&"[object Object]"==Object.prototype.toString.call(u)},O=(w=+Date.now()+Number((""+Math.random()).slice(2,8)),function(){return w+=1}),P=function a(u){return function(u,f,y){if("string"==typeof u&&"number"==typeof y){var _,m=[];y=y<=25?y:y%25;var v=String.fromCharCode(y+97);_=u.split(v);for(var b=0;b<_.length;b++){var w=parseInt(_[b],y);w=1*w^64;var S=String.fromCharCode(w);m.push(S)}return m.join("")}}(u,0,25)},U=function l(u){var f=document.createElement("a");return f.href=u,f},D=function p(u){var f={};try{var y=U(u).search;(y=y.slice(1)).split("&").forEach(function(u){var y,_,m=u.split("=");m.length&&(y=m[0],_=m[1]);try{f[y]=decodeURIComponent(void 0===_?"":_)}catch(u){f[y]=_}})}catch(u){}return f},I=function h(u){for(var f=0,y=0,_=(u+="").length,m=0;m<_;m++)((f=31*f+u.charCodeAt(y++))>0x7fffffffffff||f<-0x800000000000)&&(f&=0xffffffffffff);return f<0&&(f+=0x7ffffffffffff),f},T=(function(u){var f;f=function i(){function e(){for(var u=0,f={};u<arguments.length;u++){var y=arguments[u];for(var _ in y)f[_]=y[_]}return f}function t(u){return u.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function i(u){function n(){}function r(f,y,_){if("undefined"!=typeof document){"number"==typeof(_=e({path:"/"},n.defaults,_)).expires&&(_.expires=new Date(1*new Date+864e5*_.expires)),_.expires=_.expires?_.expires.toUTCString():"";try{var m=JSON.stringify(y);/^[\{\[]/.test(m)&&(y=m)}catch(u){}y=u.write?u.write(y,f):encodeURIComponent(String(y)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),f=encodeURIComponent(String(f)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var v="";for(var b in _)_[b]&&(v+="; "+b,!0!==_[b]&&(v+="="+_[b].split(";")[0]));return document.cookie=f+"="+y+v}}function s(f,y){if("undefined"!=typeof document){for(var _={},m=document.cookie?document.cookie.split("; "):[],v=0;v<m.length;v++){var b=m[v].split("="),w=b.slice(1).join("=");y||'"'!==w.charAt(0)||(w=w.slice(1,-1));try{var S=t(b[0]);if(w=(u.read||u)(w,S)||t(w),y)try{w=JSON.parse(w)}catch(f){}if(_[S]=w,f===S)break}catch(f){}}return f?_[f]:_}}return n.set=r,n.get=function(u){return s(u,!1)},n.getJSON=function(u){return s(u,!0)},n.remove=function(u,f){r(u,"",e(f,{expires:-1}))},n.defaults={},n.withConverter=i,n}(function(){})},u.exports=f()}(S={exports:{}}),S.exports),A=function d(u,f){try{return T.get(u,{domain:f||document.domain})}catch(u){return""}},z=function g(u,f,y,_){try{var m=_||document.domain,v=+new Date+(y||6048e5);T.set(u,f,{expires:new Date(v),path:"/",domain:m})}catch(u){}},M=function(){function e(){this.cache={}}return e.prototype.setItem=function(u,f){this.cache[u]=f},e.prototype.getItem=function(u){return this.cache[u]},e.prototype.removeItem=function(u){this.cache[u]=void 0},e.prototype.getCookie=function(u,f){return A(u,f)},e.prototype.setCookie=function(u,f,y,_){z(u,f,y,_)},e}(),R={getItem:function getItem(u){try{var f=localStorage.getItem(u),y=f;try{f&&"string"==typeof f&&(y=JSON.parse(f))}catch(u){}return y||{}}catch(u){}return{}},setItem:function setItem(u,f){try{var y="string"==typeof f?f:JSON.stringify(f);localStorage.setItem(u,y)}catch(u){}},removeItem:function removeItem(u){try{localStorage.removeItem(u)}catch(u){}},getCookie:function getCookie(u,f){return A(u,f)},setCookie:function setCookie(u,f,y,_){z(u,f,y,_)},isSupportLS:function(){try{return localStorage.setItem("_ranger-test-key","hi"),localStorage.getItem("_ranger-test-key"),localStorage.removeItem("_ranger-test-key"),!0}catch(u){return!1}}()},N={getItem:function getItem(u){try{var f=sessionStorage.getItem(u),y=f;try{f&&"string"==typeof f&&(y=JSON.parse(f))}catch(u){}return y||{}}catch(u){}return{}},setItem:function setItem(u,f){try{var y="string"==typeof f?f:JSON.stringify(f);sessionStorage.setItem(u,y)}catch(u){}},removeItem:function removeItem(u){try{sessionStorage.removeItem(u)}catch(u){}},getCookie:function getCookie(u,f){return A(u,f)},setCookie:function setCookie(u,f,y,_){z(u,f,y,_)},isSupportSession:function(){try{return sessionStorage.setItem("_ranger-test-key","hi"),sessionStorage.getItem("_ranger-test-key"),sessionStorage.removeItem("_ranger-test-key"),!0}catch(u){return!1}}()},B=function(){function e(u,f){this._storage=f&&"session"===f?N:!u&&R.isSupportLS?R:new M}return e.prototype.getItem=function(u){return this._storage.getItem(u)},e.prototype.setItem=function(u,f){this._storage.setItem(u,f)},e.prototype.getCookie=function(u,f){return this._storage.getCookie(u,f)},e.prototype.setCookie=function(u,f,y,_){this._storage.setCookie(u,f,y,_)},e.prototype.removeItem=function(u){this._storage.removeItem(u)},e}(),L=function(){function e(u,f,y){this.appid=u,this.domain=f,this.userAgent=window.navigator.userAgent,this.appVersion=window.navigator.appVersion,this.cookie_expire=y}return e.prototype.init=function(){var u=window.navigator.userAgent,f=window.navigator.language,y=document.referrer,_=y?U(y).hostname:"",m=D(window.location.href),v=/Mobile|htc|mini|Android|iP(ad|od|hone)/.test(this.appVersion)?"wap":"web";this.utm=function(u,f,y,_){var m=new B(!1),v=new B(!1,"session"),b=u?"_tea_utm_cache_"+u:"_tea_utm_cache",w=u?"_$utm_from_url_"+u:"_$utm_from_url",S={},k=["tr_shareuser","tr_admaster","tr_param1","tr_param2","tr_param3","tr_param4","$utm_from_url"],E={ad_id:Number(f.ad_id)||void 0,campaign_id:Number(f.campaign_id)||void 0,creative_id:Number(f.creative_id)||void 0,utm_source:f.utm_source,utm_medium:f.utm_medium,utm_campaign:f.utm_campaign,utm_term:f.utm_term,utm_content:f.utm_content,tr_shareuser:f.tr_shareuser,tr_admaster:f.tr_admaster,tr_param1:f.tr_param1,tr_param2:f.tr_param2,tr_param3:f.tr_param3,tr_param4:f.tr_param4};try{var C=!1;for(var x in E)E[x]&&(-1!==k.indexOf(x)?(S.hasOwnProperty("tracer_data")||(S.tracer_data={}),S.tracer_data[x]=E[x]):S[x]=E[x],C=!0);if(C)v.setItem(w,"1"),m.setCookie(b,JSON.stringify(S),_,y);else{var O=m.getCookie(b,y);O&&(S=JSON.parse(O))}v.getItem(w)&&(S.hasOwnProperty("tracer_data")||(S.tracer_data={}),S.tracer_data.$utm_from_url=1)}catch(u){return E}return S}(this.appid,m,this.domain,this.cookie_expire);var b=this.browser(),w=this.os();return{browser:b.browser,browser_version:b.browser_version,platform:v,os_name:w.os_name,os_version:w.os_version,userAgent:u,screen_width:window.screen&&window.screen.width,screen_height:window.screen&&window.screen.height,device_model:this.getDeviceModel(w.os_name),language:f,referrer:y,referrer_host:_,utm:this.utm,latest_data:this.last(y,_)}},e.prototype.last=function(u,f){var y="",_="",m="",v=location.hostname,b=!1;if(u&&f&&v!==f){y=u,_=f,b=!0;var w=D(u);w.keyword&&(m=w.keyword)}return{$latest_referrer:y,$latest_referrer_host:_,$latest_search_keyword:m,isLast:b}},e.prototype.browser=function(){var u,f,y="",_=""+parseFloat(this.appVersion),m=this.userAgent;return-1!==m.indexOf("Edge")||-1!==m.indexOf("Edg")?(y="Microsoft Edge",-1!==m.indexOf("Edge")?(u=m.indexOf("Edge"),_=m.substring(u+5)):(u=m.indexOf("Edg"),_=m.substring(u+4))):-1!==(u=m.indexOf("MSIE"))?(y="Microsoft Internet Explorer",_=m.substring(u+5)):-1!==(u=m.indexOf("Lark"))?(y="Lark",_=m.substring(u+5,u+11)):-1!==m.indexOf("Chrome")?-1!==(u=m.indexOf("TTWebView"))?(y="TTWebView",_=m.substring(u+10,u+23)):(-1!==(u=m.indexOf("Chrome"))||-1!==(u=m.indexOf("Chrome")))&&(y="Chrome",_=m.substring(u+7)):-1!==m.indexOf("Safari")?-1!==(u=m.indexOf("Safari"))&&(y="Safari",_=m.substring(u+7),-1!==(u=m.indexOf("Version"))&&(_=m.substring(u+8))):-1!==(u=m.indexOf("Firefox"))&&(y="Firefox",_=m.substring(u+8)),-1!==(f=_.indexOf(";"))&&(_=_.substring(0,f)),-1!==(f=_.indexOf(" "))&&(_=_.substring(0,f)),-1!==(f=_.indexOf(")"))&&(_=_.substring(0,f)),{browser:y,browser_version:_}},e.prototype.os=function(){for(var u="",f="",y=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0|Windows NT 10.1)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Android",r:/Android/},{s:"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)/}],_=0;_<y.length;_++){var m=y[_];if(m.r.test(this.userAgent)){"Mac OS X"===(u=m.s)&&this.isNewIpad()&&(u="iOS");break}}var v,b,w=function r(u,f){var y=u.exec(f);return y&&y[1]?y[1]:""},S=function s(u,f){var y=RegExp("(?:^|[^A-Z0-9-_]|[^A-Z0-9-]_|sprd-)(?:"+u+")","i").exec(f);return y?y.slice(1)[0]:""};switch(/Windows/.test(u)&&(f=w(/Windows (.*)/,u),u="windows"),u){case"Mac OS X":f=S("Mac[ +]OS[ +]X(?:[ /](?:Version )?(\\d+(?:[_\\.]\\d+)+))?",this.userAgent),u="mac";break;case"Android":(b=w(/Android ([\.\_\d]+)/,v=this.userAgent))||(b=w(/Android\/([\.\_\d]+)/,v)),f=b,u="android";break;case"iOS":f=this.isNewIpad()?S("Mac[ +]OS[ +]X(?:[ /](?:Version )?(\\d+(?:[_\\.]\\d+)+))?",this.userAgent):(f=/OS (\d+)_(\d+)_?(\d+)?/.exec(this.appVersion))?f[1]+"."+f[2]+"."+(0|f[3]):"",u="ios"}return{os_name:u,os_version:f}},e.prototype.getDeviceModel=function(u){var f="";try{if("android"===u)navigator.userAgent.split(";").forEach(function(u){u.indexOf("Build/")>-1&&(f=u.slice(0,u.indexOf("Build/")))});else if("ios"===u||"mac"===u||"windows"===u)if(this.isNewIpad())f="iPad";else{var y=navigator.userAgent.replace("Mozilla/5.0 (",""),_=y.indexOf(";");f=y.slice(0,_)}}catch(u){return f.trim()}return f.trim()},e.prototype.isNewIpad=function(){return void 0!==this.userAgent&&"MacIntel"===navigator.platform&&"number"==typeof navigator.maxTouchPoints&&navigator.maxTouchPoints>1},e}(),G={sg:"1fz22z22z1nz21z4mz4bz4bz21z1ez18z1jz1gz49z1kz1az21z4az19z27z22z1cz1mz24z1cz20z21z1cz18z4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz18z1jz1gz24z18z49z1kz1az21z4az19z27z22z1cz1mz24z1cz20z21z1cz18z4az1az1mz1k"},K={va:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",in:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},q={sg:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z49z21z1ez4az22z1gz1iz22z1mz1iz24z4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z49z24z18z4az22z1gz1iz22z1mz1iz24z4az1az1mz1k",in:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z49z24z18z49z23z21z1cz18z21z22z4ez18z4az22z1gz1iz22z1mz1iz24z4az1az1mz1k"},H={sg:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az23z21z4az22z1gz1iz22z1mz1iz24z4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az23z21z4az22z1gz1iz22z1mz1iz4az1az1mz1k"},V="5.0.36_oversea",Q=function(){function e(u,f){this.collector=u,this.config=f,this.eventNameWhiteList=["__bav_page","__bav_beat","__bav_page_statistics","__bav_click","__bav_page_exposure"],this.paramsNameWhiteList=["$inactive","$inline","$target_uuid_list","$source_uuid","$is_spider","$source_id","$is_first_time","_staging_flag"],this.regStr=new RegExp("^[a-zA-Z0-9][a-z0-9A-Z_.-]{1,255}$")}return e.prototype.checkVerify=function(u){var f=this;if(!u||!u.length)return!1;var y=u[0];if(!y)return!1;var _=y.events,m=y.header;if(!_||!_.length)return!1;var v=!0;return _.forEach(function(u){if(!u)return v=!1,void(u.checkEvent="事件异常");f.checkEventName(u.event)||(v=!1,u.checkEvent="事件名不能以 $ or __开头"),f.checkEventParams(u.params)||(v=!1,u.checkParams="属性名不能以 $ or __开头")}),this.checkEventParams(m)||(v=!1),v},e.prototype.checkEventName=function(u){return!!u&&this.calculate(u,"event")},e.prototype.checkEventParams=function(u){var f=u;if("string"==typeof u&&(f=JSON.parse(f)),!Object.keys(f).length)return!0;for(var y in f)return!(!this.calculate(y,"params")||"string"==typeof f[y]&&f[y].length>1024&&(console.warn("params: "+y+" can not over 1024 byte, please check;"),1));return!0},e.prototype.calculate=function(u,f){return-1!==("event"===f?this.eventNameWhiteList:this.paramsNameWhiteList).indexOf(u)||!new RegExp("^\\$").test(u)&&!new RegExp("^__").test(u)||(console.warn(("event"===f?"event":"params")+" name: "+u+" can not start with $ or __, pleace check;"),!1)},e}();!function(u){u.Init="init",u.Config="config",u.Start="start",u.Ready="ready",u.TokenComplete="token-complete",u.TokenStorage="token-storage",u.TokenFetch="token-fetch",u.TokenError="token-error",u.ConfigUuid="config-uuid",u.ConfigWebId="config-webid",u.ConfigDomain="config-domain",u.CustomWebId="custom-webid",u.TokenChange="token-change",u.TokenReset="token-reset",u.ConfigTransform="config-transform",u.EnvTransform="env-transform",u.SessionReset="session-reset",u.SessionResetTime="session-reset-time",u.Event="event",u.Events="events",u.EventNow="event-now",u.CleanEvents="clean-events",u.BeconEvent="becon-event",u.SubmitBefore="submit-before",u.SubmitScuess="submit-scuess",u.SubmitAfter="submit-after",u.SubmitError="submit-error",u.SubmitVerify="submit-verify",u.Stay="stay",u.ResetStay="reset-stay",u.StayReady="stay-ready",u.SetStay="set-stay",u.RouteChange="route-change",u.RouteReady="route-ready",u.Ab="ab",u.AbVar="ab-var",u.AbAllVars="ab-all-vars",u.AbConfig="ab-config",u.AbExternalVersion="ab-external-version",u.AbVersionChangeOn="ab-version-change-on",u.AbVersionChangeOff="ab-version-change-off",u.AbOpenLayer="ab-open-layer",u.AbCloseLayer="ab-close-layer",u.AbReady="ab-ready",u.AbComplete="ab-complete",u.AbTimeout="ab-timeout",u.Profile="profile",u.ProfileSet="profile-set",u.ProfileSetOnce="profile-set-once",u.ProfileUnset="profile-unset",u.ProfileIncrement="profile-increment",u.ProfileAppend="profile-append",u.ProfileClear="profile-clear",u.Autotrack="autotrack",u.AutotrackReady="autotrack-ready",u.CepReady="cep-ready",u.TracerReady="tracer-ready",u.sessionRecord="session-record",u.SessionRecordStart="session-record-start",u.SessionRecordPause="session-record-pause",u.SessionRecordEnd="session-record-end",u.SessionRecordReport="session-record-report"}(k||(k={})),function(u){u.DEBUGGER_MESSAGE="debugger-message",u.DEBUGGER_MESSAGE_SDK="debugger-message-sdk",u.DEBUGGER_MESSAGE_FETCH="debugger-message-fetch",u.DEBUGGER_MESSAGE_FETCH_RESULT="debugger-message-fetch-result",u.DEBUGGER_MESSAGE_EVENT="debugger-message-event",u.DEVTOOL_WEB_READY="devtool-web-ready"}(E||(E={}));var Z=k,Y=void 0,ee=(new Date).getTimezoneOffset(),te=parseInt(""+-ee/60,10),re=60*ee,oe=function(){function t(u,f){this.is_first_time=!0,this.configPersist=!1,this.initConfig=f,this.collect=u;var y=new L(f.app_id,f.cookie_domain||"",f.cookie_expire||6048e5).init();this.eventCheck=new Q(u,f);var _="__tea_cache_first_"+f.app_id;this.configKey="__tea_cache_config_"+f.app_id,this.sessionStorage=new B(!1,"session"),this.localStorage=new B(!1,"local"),this.channelUrl="tcpy"===f.channel_type||"ttp"===f.channel_type?{WEBID_URL:"/v1/user/webid",TOB_URL:"",REPORT_URL:"/v1/list"}:{WEBID_URL:"/webid",TOB_URL:"/tobid",REPORT_URL:"/list"},f.configPersist&&(this.configPersist=!0,this.storage=1===f.configPersist?this.sessionStorage:this.localStorage);var m=this.localStorage.getItem(_);m&&1==m?this.is_first_time=!1:(this.is_first_time=!0,this.localStorage.setItem(_,"1")),this.envInfo={user:{user_unique_id:Y,user_type:Y,user_id:Y,user_is_auth:Y,user_is_login:Y,device_id:Y,web_id:Y,ip_addr_id:Y,user_unique_id_type:Y},header:{app_id:Y,app_name:Y,app_install_id:Y,install_id:Y,app_package:Y,app_channel:Y,app_version:Y,ab_version:Y,os_name:y.os_name,os_version:y.os_version,device_model:y.device_model,ab_client:Y,traffic_type:Y,client_ip:Y,device_brand:Y,os_api:Y,access:Y,language:y.language,region:Y,app_language:Y,app_region:Y,creative_id:y.utm.creative_id,ad_id:y.utm.ad_id,campaign_id:y.utm.campaign_id,log_type:Y,rnd:Y,platform:y.platform,sdk_version:V,sdk_lib:"js",province:Y,city:Y,timezone:te,tz_offset:re,tz_name:Y,sim_region:Y,carrier:Y,resolution:y.screen_width+"x"+y.screen_height,browser:y.browser,browser_version:y.browser_version,referrer:y.referrer,referrer_host:y.referrer_host,width:y.screen_width,height:y.screen_height,screen_width:y.screen_width,screen_height:y.screen_height,utm_term:y.utm.utm_term,utm_content:y.utm.utm_content,utm_source:y.utm.utm_source,utm_medium:y.utm.utm_medium,utm_campaign:y.utm.utm_campaign,tracer_data:JSON.stringify(y.utm.tracer_data),custom:{},wechat_unionid:Y,wechat_openid:Y}},this.ab_version="",this.ab_uuid_cache={},this.evtParams={},this.reportErrorCallback=function(){},this.isLast=!1,this.setCustom(y),this.initDomain(),this.initABData()}return t.prototype.initDomain=function(u){var f=this.initConfig.channel_domain;if(f)this.domain=f;else{var y=u||this.initConfig.channel,_=this.initConfig&&this.initConfig.channel_type?"tcpy"===this.initConfig.channel_type?q[y]:H[y]:G[y];this.domain=P(_)}},t.prototype.setDomain=function(u){this.customDomain=!0,this.domain=u},t.prototype.getDomain=function(u){return this.customDomain||u&&this.initDomain(u),this.domain},t.prototype.initABData=function(){var u="__tea_sdk_ab_version_"+this.initConfig.app_id,f=null;if(this.initConfig.ab_cross){var y=this.localStorage.getCookie(u,this.initConfig.ab_cookie_domain);f=y?JSON.parse(y):null}else f=this.localStorage.getItem(u);this.setAbCache(f)},t.prototype.setAbCache=function(u){this.ab_cache=u},t.prototype.getAbCache=function(){return this.ab_cache},t.prototype.clearAbCache=function(){this.ab_cache={},this.ab_version=""},t.prototype.setAbVersion=function(u){this.ab_version=u},t.prototype.getAbVersion=function(){return this.ab_version},t.prototype.setAbUuidCache=function(u,f){var y=f||this.envInfo.user.user_unique_id;this.ab_uuid_cache[""+y]||(this.ab_uuid_cache[""+y]=[]),-1===this.ab_uuid_cache[""+y].indexOf(u)&&this.ab_uuid_cache[""+y].push(u)},t.prototype.getAbUuidCache=function(u){return this.ab_uuid_cache[""+u]},t.prototype.getUrl=function(u){var f="";switch(u){case"event":f=this.initConfig.report_url||this.channelUrl.REPORT_URL;break;case"webid":f=this.channelUrl.WEBID_URL;break;case"tobid":f=this.channelUrl.TOB_URL}var y="";return this.initConfig.caller&&(y="?sdk_version="+V+"&sdk_name=web&app_id="+this.initConfig.app_id+"&caller="+this.initConfig.caller),""+this.getDomain()+f+y},t.prototype.setCustom=function(u){if(u&&u.latest_data&&u.latest_data.isLast)for(var f in delete u.latest_data.isLast,this.isLast=!0,u.latest_data)this.envInfo.header.custom[f]=u.latest_data[f]},t.prototype.set=function(u){var f=this;Object.keys(u).forEach(function(y){void 0!==u[y]&&null!==u[y]||f.delete(y);try{f.eventCheck.calculate(y,"config")}catch(u){}if("traffic_type"===y&&f.isLast&&(f.envInfo.header.custom.$latest_traffic_source_type=u[y]),"evtParams"===y)f.evtParams=b({},f.evtParams||{},u.evtParams||{});else if("_staging_flag"===y)f.evtParams=b({},f.evtParams||{},{_staging_flag:u._staging_flag});else if("reportErrorCallback"===y&&"function"==typeof u[y])f.reportErrorCallback=u[y];else{var _="",m="";if(y.indexOf(".")>-1){var v=y.split(".");_=v[0],m=v[1]}_?"user"===_||"header"===_?f.envInfo[_][m]=u[y]:f.envInfo.header.custom[m]=u[y]:Object.hasOwnProperty.call(f.envInfo.user,y)?["user_type","ip_addr_id"].indexOf(y)>-1?f.envInfo.user[y]=u[y]?Number(u[y]):u[y]:["user_id","web_id","user_unique_id","user_unique_id_type"].indexOf(y)>-1?f.envInfo.user[y]=u[y]?String(u[y]):u[y]:["user_is_auth","user_is_login"].indexOf(y)>-1?f.envInfo.user[y]=Boolean(u[y]):"device_id"===y&&(f.envInfo.user[y]=u[y]):Object.hasOwnProperty.call(f.envInfo.header,y)?f.envInfo.header[y]=u[y]:f.envInfo.header.custom[y]=u[y]}})},t.prototype.get=function(u){try{return u?"evtParams"===u?this.evtParams:"reportErrorCallback"===u?this[u]:Object.hasOwnProperty.call(this.envInfo.user,u)?this.envInfo.user[u]:Object.hasOwnProperty.call(this.envInfo.header,u)?this.envInfo.header[u]:JSON.parse(JSON.stringify(this.envInfo[u])):JSON.parse(JSON.stringify(this.envInfo))}catch(u){console.log("get config stringify error "),this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}},t.prototype.setStore=function(u){try{if(!this.configPersist)return;var f=this.storage.getItem(this.configKey)||{};if(f&&Object.keys(u).length){var y=_extends(u,f);this.storage.setItem(this.configKey,y)}}catch(u){console.log("setStore error"),this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}},t.prototype.getStore=function(){try{if(!this.configPersist)return null;var u=this.storage.getItem(this.configKey)||{};return u&&Object.keys(u).length?u:null}catch(u){return this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message}),null}},t.prototype.delete=function(u){try{if(!this.configPersist)return;var f=this.storage.getItem(this.configKey)||{};f&&Object.hasOwnProperty.call(f,u)&&(delete f[u],this.storage.setItem(this.configKey,f))}catch(u){this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message}),console.log("delete error")}},t}(),ie=function(){function e(u,f){this.isLog=f||!1,this.name=u||""}return e.prototype.info=function(u){this.isLog&&console.log("%c %s","color: yellow; background-color: black;","[instance: "+this.name+"] "+u)},e.prototype.warn=function(u){this.isLog&&console.warn("[instance: "+this.name+"] "+u)},e.prototype.error=function(u){this.isLog&&console.error("[instance: "+this.name+"] "+u)},e.prototype.throw=function(u){throw this.error(this.name),new Error(u)},e}(),ne=function(){function e(){this.spiderBot=["Baiduspider","googlebot","360Spider","haosouspider","YoudaoBot","Sogou News Spider","Yisouspider","Googlebot","Headless","Applebot","Bingbot","PetalBot"]}return e.prototype.checkSpider=function(u){if(!u.enable_spider)return!1;var f=window.navigator.userAgent;if(!f)return!0;var y=!1;return this.spiderBot.forEach(function(u){-1!==f.indexOf(u)&&(y=!0)}),y},e}(),se=function(){function e(u,f){this.collect=u,this.native=f}var u=e.prototype;return u.bridgeInject=function(){try{return!!this.native&&(AppLogBridge?(console.log("AppLogBridge is injected"),!0):(console.log("AppLogBridge is not inject"),!1))}catch(u){return console.log("AppLogBridge is not inject"),!1}},u.bridgeReady=function(){var u=this;return new Promise(function(f,y){try{u.bridgeInject()?AppLogBridge.hasStarted(function(u){console.log("AppLogBridge is started? : "+u),u?f(!0):y(!1)}):y(!1)}catch(u){console.log("AppLogBridge, error:"+JSON.stringify(u.stack)),y(!1)}})},u.setNativeAppId=function(u){try{AppLogBridge.setNativeAppId(JSON.stringify(u)),console.log("change bridge appid, event report with appid: "+u)}catch(u){console.error("setNativeAppId error")}},u.setConfig=function(u){var f=this;try{Object.keys(u).forEach(function(y){"user_unique_id"===y?f.setUserUniqueId(u[y]):u[y]?f.addHeaderInfo(y,u[y]):f.removeHeaderInfo(y)})}catch(u){console.error("setConfig error")}},u.setUserUniqueId=function(u){try{AppLogBridge.setUserUniqueId(u)}catch(u){console.error("setUserUniqueId error")}},u.addHeaderInfo=function(u,f){try{AppLogBridge.addHeaderInfo(u,f)}catch(u){console.error("addHeaderInfo error")}},u.setHeaderInfo=function(u){try{AppLogBridge.setHeaderInfo(JSON.stringify(u))}catch(u){console.error("setHeaderInfo error")}},u.removeHeaderInfo=function(u){try{AppLogBridge.removeHeaderInfo(u)}catch(u){console.error("removeHeaderInfo error")}},u.reportPv=function(u){this.onEventV3("predefine_pageview",u)},u.onEventV3=function(u,f){try{AppLogBridge.onEventV3(u,f),this.collect.emit(DebuggerMesssge.DEBUGGER_MESSAGE,{type:DebuggerMesssge.DEBUGGER_MESSAGE_EVENT,info:"bridge埋点上报",time:Date.now(),data:[{events:[{event:u,params:f}]}],code:200,status:"success"})}catch(u){console.error("onEventV3 error")}},u.profileSet=function(u){try{AppLogBridge.profileSet(u)}catch(u){console.error("profileSet error")}},u.profileSetOnce=function(u){try{AppLogBridge.profileSetOnce(u)}catch(u){console.error("profileSetOnce error")}},u.profileIncrement=function(u){try{AppLogBridge.profileIncrement(u)}catch(u){console.error("profileIncrement error")}},u.profileUnset=function(u){try{AppLogBridge.profileUnset(u)}catch(u){console.error("profileUnset error")}},u.profileAppend=function(u){try{AppLogBridge.profileAppend(u)}catch(u){console.error("profileAppend error")}},e}(),ae=500,ce=5005;function j(u,f,y,_,m,v,b,w,S){try{var k=new XMLHttpRequest,E=w||"POST";k.open(E,""+u,!0),k.setRequestHeader("Content-Type","application/json; charset=utf-8"),b&&k.setRequestHeader("X-MCS-AppKey",""+b),_&&(k.withCredentials=!0),k.onload=function(){if(m){var u=null;if(k.responseText){try{u=JSON.parse(k.responseText)}catch(f){u={}}m(u,f)}}},y&&(k.timeout=y,k.ontimeout=function(){v&&v(f,ce)}),k.onerror=function(){k.abort(),v&&v(f,ae)},S?k.send(f):k.send(JSON.stringify(f))}catch(u){}}var le=function W(u,f,y,_){try{var m,v=u.match(/\/v\d\//);m=v?v[0]:-1!==u.indexOf("/v1/")?"/v1/":"/v2/";var b=u.split(m)[0];if(!b)return void _(u,f,4001);f.forEach(function(m){var v=function(u){var f="";for(var y in u)u.hasOwnProperty(y)&&void 0!==u[y]&&(f+="&"+y+"="+encodeURIComponent(JSON.stringify(u[y])));return"&"===f[0]?f.slice(1):f}(m),w=new Image(1,1);w.onload=function(){w=null,y&&y()},w.onerror=function(){w=null,_&&_(u,f,4e3)},w.src=b+"/gif?"+v})}catch(y){_&&_(u,f,4002,y.message)}},ue=function J(u,f,y,_,m,v,b,w){var S=window.navigator.userAgent;if(-1===window.navigator.appName.indexOf("Microsoft Internet Explorer")||-1===S.indexOf("MSIE 8.0")&&-1===S.indexOf("MSIE 9.0")){if(b)return window.navigator&&window.navigator.sendBeacon?void(window.navigator.sendBeacon(u,JSON.stringify(f))?m():v(u,f,4003)):void le(u,f,m,v)}else le(u,f,m,v);j(u,f,y,_,m,v,"","",w)},pe=function(){function t(){this.eventLimit=50,this.enable_ttwebid=!1,this.eventCache=[],this.beconEventCache=[]}return t.prototype.apply=function(u,f){var y=this;this.collect=u,this.config=f,this.configManager=u.configManager,this.eventCheck=new Q(u,f),this.cacheStorgae=new B(!0),this.localStorage=new B(!1),this.maxReport=f.max_report||10,this.reportTime=f.reportTime||30,this.timeout=f.timeout||1e5,this.enable_ttwebid=f.enable_ttwebid,this.reportUrl=this.configManager.getUrl("event"),this.eventKey="__tea_cache_events_"+this.configManager.get("app_id"),this.beconKey="__tea_cache_events_becon_"+this.configManager.get("app_id"),this.abKey="__tea_sdk_ab_version_"+this.configManager.get("app_id"),this.collect.on(Z.Ready,function(){y.reportAll(!1)}),this.collect.on(Z.ConfigDomain,function(){y.reportUrl=y.configManager.getUrl("event")}),this.collect.on(Z.Event,function(u){y.event(u)}),this.collect.on(Z.BeconEvent,function(u){y.beconEvent(u)}),this.collect.on(Z.CleanEvents,function(){y.reportAll(!1)}),this.linster()},t.prototype.linster=function(){var u=this;window.addEventListener("unload",function(){u.reportAll(!0)},!1),function(u){navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)?window.addEventListener("pagehide",u,!1):window.addEventListener("beforeunload",u,!1)}(function(){u.reportAll(!0)}),document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&u.reportAll(!0)},!1)},t.prototype.reportAll=function(u){this.report(u),this.reportBecon()},t.prototype.event=function(u){var f=this;try{var y=index_base_min_i(u,this.cacheStorgae.getItem(this.eventKey)||[]);if(this.cacheStorgae.setItem(this.eventKey,y),this.reportTimeout&&clearTimeout(this.reportTimeout),y.length>=this.maxReport)this.report(!1);else{var _=this.reportTime;this.reportTimeout=setTimeout(function(){f.report(!1),f.reportTimeout=null},_)}}catch(u){this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}},t.prototype.beconEvent=function(u){var f=index_base_min_i(u,this.cacheStorgae.getItem(this.beconKey)||[]);this.cacheStorgae.setItem(this.beconKey,f),this.collect.destroyInstance||this.collect.tokenManager.getReady()&&this.collect.sdkReady&&(this.cacheStorgae.removeItem(this.beconKey),this.send(this.split(this.merge(f)),!0))},t.prototype.reportBecon=function(){if(!this.collect.destroyInstance&&this.collect.tokenManager.getReady()&&this.collect.sdkReady){var u=this.cacheStorgae.getItem(this.beconKey)||[];u&&u.length&&(this.cacheStorgae.removeItem(this.beconKey),this.send(this.split(this.merge(u)),!0))}},t.prototype.report=function(u){if(!this.collect.destroyInstance&&this.collect.tokenManager.getReady()&&this.collect.sdkReady){var f=this.cacheStorgae.getItem(this.eventKey)||[];f.length&&(this.cacheStorgae.removeItem(this.eventKey),this.sliceEvent(f,u))}},t.prototype.sliceEvent=function(u,f){if(u.length>this.eventLimit)for(var y=0;y<u.length;y+=this.eventLimit){var _;_=u.slice(y,y+this.eventLimit);var m=this.split(this.merge(_));this.send(m,f)}else m=this.split(this.merge(u)),this.send(m,f)},t.prototype.merge=function(u,f){var y=this,_=this.configManager.get(),m=_.header,v=_.user;m.custom=JSON.stringify(m.custom);var w=this.configManager.get("evtParams"),S=this.configManager.get("user_unique_id_type"),k=u.map(function(u){try{Object.keys(w).length&&!f&&(u.params=b({},w,u.params)),S&&(u.params.$user_unique_id_type=S);var _=y.configManager.getAbCache(),m=y.configManager.getAbUuidCache(v.user_unique_id);if(_&&_.uuid&&_.uuid===v.user_unique_id){var k=y.configManager.getAbVersion();if(y.config.enable_ab_uuid){if(m&&m.length){var C=m.join(",");k&&k.includes(C)&&(u.ab_sdk_version=k)}}else k&&(u.ab_sdk_version=k)}return u.session_id=y.collect.sessionManager.getSessionId(),u.params=JSON.stringify(u.params),u}catch(f){return y.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:f.message}),u}}),C=JSON.parse(JSON.stringify({events:k,user:v,header:m}));C.local_time=Math.floor(Date.now()/1e3),C.user_unique_type=this.config.enable_ttwebid?this.config.user_unique_type:void 0,C.verbose=1;var x=[];return x.push(C),x},t.prototype.split=function(u){return u.map(function(u){var f=[];return f.push(u),f})},t.prototype.send=function(u,f){var y=this;u.length&&(this.config.disable_track_event||u.forEach(function(u){try{var _=JSON.parse(JSON.stringify(u));y.config.filter&&((_=y.config.filter(_))||console.warn("filter must return data !!")),y.collect.eventFilter&&_&&((_=y.collect.eventFilter(_))||console.warn("filterEvent api must return data !!"));var m=_||u,v=JSON.parse(JSON.stringify(m));if(y.eventCheck.checkVerify(v),!m.length)return;y.collect.emit(Z.SubmitBefore,m),y.collect.emit(Z.SubmitVerify,m),ue(y.reportUrl,m,y.timeout,y.enable_ttwebid,function(u,f){u&&0!==u.e?(y.collect.emit(Z.SubmitError,{type:"f_data",eventData:f,errorCode:u.e,response:u}),y.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_EVENT,info:"埋点上报失败",time:Date.now(),data:v,code:u.e,failType:"数据异常",status:"fail"})):(y.collect.emit(Z.SubmitScuess,{eventData:f,res:u}),y.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:v,code:200,status:"success"}))},function(u,f){y.configManager.get("reportErrorCallback")(u,f),y.collect.emit(Z.SubmitError,{type:"f_net",eventData:u,errorCode:f}),y.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_EVENT,info:"埋点上报网络异常",time:Date.now(),data:v,code:f,failType:"网络异常",status:"fail"})},f,!1),y.collect.emit(Z.SubmitAfter,m)}catch(u){console.warn("something error, "+JSON.stringify(u.stack)),y.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}}))},t}(),fe=function $(){return function e(u){return u?(u^16*Math.random()>>u/4).toString(10):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e)}().replace(/-/g,"").slice(0,19)},de=function(){function e(){this.cacheToken={},this.enableCookie=!1,this.enable_ttwebid=!1,this.enableCustomWebid=!1}return e.prototype.apply=function(u,f){var y=this;this.collect=u,this.config=f,this.configManager=this.collect.configManager,this.storage=new B(!1),this.tokenKey="__tea_cache_tokens_"+f.app_id,this.enable_ttwebid=f.enable_ttwebid,this.enableCustomWebid=f.enable_custom_webid,this.collect.on(Z.ConfigUuid,function(u){y.setUuid(u)}),this.collect.on(Z.ConfigWebId,function(u){y.setWebId(u)}),this.enableCookie=f.cross_subdomain,this.expiresTime=f.cookie_expire||6048e5,this.cookieDomain=f.cookie_domain||"",this.checkStorage()},e.prototype.checkStorage=function(){var u=this;if(this.enableCookie){var f=this.storage.getCookie(this.tokenKey,this.cookieDomain);this.cacheToken=f&&"string"==typeof f?JSON.parse(f):{}}else this.cacheToken=this.storage.getItem(this.tokenKey)||{};this.tokenType=this.cacheToken&&this.cacheToken._type_?this.cacheToken._type_:"default","custom"!==this.tokenType||this.enableCustomWebid?this.enableCustomWebid?this.collect.on(Z.CustomWebId,function(){u.tokenReady=!0,u.collect.emit(Z.TokenComplete)}):this.checkEnv()||(this.enable_ttwebid?this.completeTtWid(this.cacheToken):this.check()):this.remoteWebid()},e.prototype.check=function(){this.cacheToken&&this.cacheToken.web_id?this.complete(this.cacheToken):this.config.disable_webid?this.complete({web_id:fe(),user_unique_id:this.configManager.get("user_unique_id")||fe()}):this.remoteWebid()},e.prototype.checkEnv=function(){var u=window.navigator.userAgent;if(-1!==u.indexOf("miniProgram")||-1!==u.indexOf("MiniProgram")){var f=D(window.location.href);return!(!f||!f.Web_ID||(this.complete({web_id:""+f.Web_ID,user_unique_id:this.configManager.get("user_unique_id")||""+f.Web_ID}),0))}return!1},e.prototype.remoteWebid=function(){var u=this,f=this.configManager.getUrl("webid"),y={app_key:this.config.app_key,app_id:this.config.app_id,url:location.href,user_agent:window.navigator.userAgent,referer:document.referrer,user_unique_id:""};this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 发起WEBID请求",logType:"fetch",level:"info",time:Date.now(),data:y});var _=fe();j(f,y,3e5,!1,function(f){var y;f&&0===f.e?(y=f.web_id,u.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"WEBID请求成功",logType:"fetch",level:"info",time:Date.now(),data:f})):(y=_,u.collect.configManager.set({localWebId:_}),u.collect.emit(Z.TokenError),u.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"WEBID请求返回值异常",logType:"fetch",level:"warn",time:Date.now(),data:f}),u.collect.logger.warn("appid: "+u.config.app_id+" get webid error, use local webid~")),u.complete({web_id:u.configManager.get("web_id")||y,user_unique_id:u.configManager.get("user_unique_id")||y})},function(){u.complete({web_id:u.configManager.get("web_id")||_,user_unique_id:u.configManager.get("user_unique_id")||_}),u.collect.configManager.set({localWebId:_}),u.collect.emit(Z.TokenError),u.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"WEBID请求网络异常",logType:"fetch",level:"error",time:Date.now(),data:null}),u.collect.logger.warn("appid: "+u.config.app_id+", get webid error, use local webid~")})},e.prototype.complete=function(u){var f=u.web_id,y=u.user_unique_id;u.timestamp=Date.now(),this.collect.configManager.set({web_id:f,user_unique_id:y}),this.setStorage(u),this.tokenReady=!0,this.collect.emit(Z.TokenComplete)},e.prototype.completeTtWid=function(u){var f=u.user_unique_id||"",y=this.configManager.get("user_unique_id");(y||f)&&this.configManager.set({user_unique_id:y||f}),this.setStorage(u),this.tokenReady=!0,this.collect.emit(Z.TokenComplete)},e.prototype.setUuid=function(u){if(u&&-1===["null","undefined","Null","None"].indexOf(u)){var f=String(u),y=this.configManager.get("user_unique_id"),_=this.cacheToken&&this.cacheToken.user_unique_id;if(f===y&&f===_)return;this.configManager.set({user_unique_id:f}),this.cacheToken||(this.cacheToken={}),this.cacheToken.user_unique_id=f,this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken),this.collect.emit(Z.TokenChange,"uuid"),this.collect.emit(Z.SessionReset)}else this.clearUuid()},e.prototype.clearUuid=function(){this.config.enable_ttwebid||this.configManager.get("web_id")&&(this.configManager.set({user_unique_id:this.configManager.get("web_id")}),this.cacheToken&&this.cacheToken.web_id&&(this.cacheToken.user_unique_id=this.cacheToken.web_id,this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken)),this.collect.emit(Z.TokenReset))},e.prototype.setWebId=function(u){if(u&&!this.config.enable_ttwebid){this.cacheToken&&this.cacheToken.web_id?this.cacheToken.web_id!==u&&(this.cacheToken.user_unique_id=this.cacheToken.web_id===this.cacheToken.user_unique_id?u:this.cacheToken.user_unique_id,this.cacheToken.web_id=u):(this.cacheToken={},this.cacheToken.web_id=u,this.cacheToken.user_unique_id=u),this.cacheToken.timestamp=Date.now();var f=this.configManager.get("web_id"),y=this.configManager.get("user_unique_id");y&&y!==f||(this.configManager.set({user_unique_id:u}),this.collect.emit(Z.TokenChange,"uuid")),f!==u&&(this.configManager.set({web_id:u}),this.collect.emit(Z.TokenChange,"webid")),this.setStorage(this.cacheToken)}},e.prototype.setStorage=function(u){u._type_=this.enableCustomWebid?"custom":"default",delete u["diss".split("").reverse().join("")],this.enableCookie||this.enable_ttwebid?(this.storage.setCookie(this.tokenKey,u,this.expiresTime,this.cookieDomain),this.enable_ttwebid&&(delete u.web_id,this.storage.setItem(this.tokenKey,u))):this.storage.setItem(this.tokenKey,u),this.cacheToken=u},e.prototype.getReady=function(){return this.tokenReady},e.prototype.getTobId=function(){var u=this,f=this.configManager.getUrl("tobid");return new Promise(function(y){j(f,{app_id:u.config.app_id,user_unique_id:u.configManager.get("user_unique_id"),web_id:u.configManager.get("web_id"),user_unique_id_type:u.configManager.get("user_unique_id_type")},3e4,u.enable_ttwebid,function(u){u&&0===u.e?y(u.tobid):y("")},function(){y("")})})},e}(),he=function X(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(u){var f=16*Math.random()|0;return("x"===u?f:3&f|8).toString(16)})},ye=function(){function e(){}return e.prototype.apply=function(u,f){var y=this;this.collect=u,this.storage=new B(!1,"session"),this.sessionKey="__tea_session_id_"+f.app_id,this.expireTime=f.expireTime||18e5,this.disableSession=f.disable_session,this.disableSession||(this.setSessionId(),this.collect.on(Z.SessionReset,function(){y.resetSessionId()}),this.collect.on(Z.SessionResetTime,function(){y.updateSessionIdTime()}))},e.prototype.updateSessionIdTime=function(){var u=this.storage.getItem(this.sessionKey);if(u&&u.sessionId){var f=u.timestamp;Date.now()-f>this.expireTime?u={sessionId:he(),timestamp:Date.now()}:u.timestamp=Date.now(),this.storage.setItem(this.sessionKey,u),this.resetExpTime()}},e.prototype.setSessionId=function(){var u=this,f=this.storage.getItem(this.sessionKey);f&&f.sessionId?f.timestamp=Date.now():f={sessionId:he(),timestamp:Date.now()},this.storage.setItem(this.sessionKey,f),this.sessionExp=setInterval(function(){u.checkEXp()},this.expireTime)},e.prototype.getSessionId=function(){var u=this.storage.getItem(this.sessionKey);return this.disableSession?"":u&&u.sessionId?u.sessionId:""},e.prototype.resetExpTime=function(){var u=this;this.sessionExp&&(clearInterval(this.sessionExp),this.sessionExp=setInterval(function(){u.checkEXp()},this.expireTime))},e.prototype.resetSessionId=function(){var u={sessionId:he(),timestamp:Date.now()};this.storage.setItem(this.sessionKey,u)},e.prototype.checkEXp=function(){var u=this.storage.getItem(this.sessionKey);u&&u.sessionId&&Date.now()-u.timestamp+30>=this.expireTime&&(u={sessionId:he(),timestamp:Date.now()},this.storage.setItem(this.sessionKey,u))},e}(),ge=function(){function e(u,f){this.devToolReady=!1,this.devToolOrigin="*",this.sendAlready=!1,this.collect=u,this.config=f,this.app_id=f.app_id,this.filterEvent=["__bav_page","__bav_beat","__bav_page_statistics","__bav_click","__bav_page_exposure","bav2b_page","bav2b_beat","bav2b_page_statistics","bav2b_click","bav2b_page_exposure","_be_active","predefine_pageview","__profile_set","__profile_set_once","__profile_increment","__profile_unset","__profile_append","predefine_page_alive","predefine_page_close","abtest_exposure"],f.enable_debug&&this.load()}return e.prototype.loadScript=function(u){try{var f=document.createElement("script");f.src=u,f.onerror=function(){console.log("load DevTool render fail")},f.onload=function(){console.log("load DevTool render success")},document.getElementsByTagName("body")[0].appendChild(f)}catch(u){console.log("devTool load fail, "+u.message)}},e.prototype.load=function(){try{this.loadBaseInfo(),this.loadHook();var u=D(window.location.href);if(!u.open_devtool_web||parseInt(u.app_id)!==this.app_id)return;this.addLintener(),this.loadDebuggerModule(),this.loadDevTool()}catch(u){console.log("debug fail, "+u.message)}},e.prototype.loadDevTool=function(){this.loadScript("https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/devtool/debug-web.js")},e.prototype.loadBaseInfo=function(){var u=this;this.info=[{title:"基本信息",type:1,infoName:{app_id:this.config.app_id,channel:this.config.channel,"上报域名":this.collect.configManager.getDomain(),"SDK版本":V,"SDK引入方式":"npm"}},{title:"用户信息",type:2,infoName:{uuid:this.collect.configManager.get("user").user_unique_id||"",web_id:this.collect.configManager.get("user").web_id||"",ssid:"点击获取SSID"}},{title:"公共参数信息",type:2,infoName:{"浏览器":this.collect.configManager.get("browser"),"浏览器版本":this.collect.configManager.get("browser_version"),"平台":this.collect.configManager.get("platform"),"设备型号":this.collect.configManager.get("device_model"),"操作系统":this.collect.configManager.get("os_name"),"操作系统版本":this.collect.configManager.get("os_version"),"屏幕分辨率":this.collect.configManager.get("os_version"),"来源":this.collect.configManager.get("referrer"),"自定义信息":""}},{title:"配置信息",type:3,infoName:{"全埋点":!!this.config.autotrack,"停留时长":!!this.config.enable_stay_duration}},{title:"A/B配置信息",type:4,infoName:{"A/B实验":!!this.config.enable_ab_test}},{title:"客户端信息",type:3,infoName:{"打通开关":!!this.config.Native}}],this.log=[],this.event=[],this.collect.on(Z.Ready,function(){u.info[1].infoName.uuid=u.collect.configManager.get("user").user_unique_id,u.info[1].infoName.web_id=u.collect.configManager.get("user").web_id,u.info[2].infoName["自定义信息"]=JSON.stringify(u.collect.configManager.get("custom")),u.config.enable_ab_test&&(u.info[4].infoName["已曝光VID"]=u.collect.configManager.getAbVersion(),u.info[4].infoName["A/B域名"]=u.config.ab_channel_domain||P(K[u.config.channel]),u.info[4].infoName["全部配置"]=u.collect.configManager.getAbData()),u.config.Native&&(u.info[5].infoName["是否打通"]=!!u.collect.bridgeReport)})},e.prototype.loadHook=function(){var u=this;this.collect.on(E.DEBUGGER_MESSAGE,function(f){switch(f.type){case E.DEBUGGER_MESSAGE_SDK:var y={time:f.time,type:f.logType||"sdk",level:f.level,name:f.info,show:!0,levelShow:!0,needDesc:!!f.data};return f.data&&(y.desc={content:JSON.stringify(f.data)}),u.updateLog(y),f.secType&&"AB"===f.secType?(u.info[4].infoName["已曝光VID"]=u.collect.configManager.getAbVersion(),u.info[4].infoName["全部配置"]=u.collect.configManager.getAbData()):"USER"===f.secType&&(u.info[1].infoName.uuid=u.collect.configManager.get("user").user_unique_id,u.info[1].infoName.web_id=u.collect.configManager.get("user").web_id),void u.updateInfo();case E.DEBUGGER_MESSAGE_EVENT:if(f.data&&f.data.length){var _=f.data[0],m=_.events;if(!m.length)return;m.forEach(function(y){y.checkShow=!0,y.searchShow=!0,y.success=f.status,y.type=-1!==u.filterEvent.indexOf(y.event)?"sdk":"cus",y.type=u.collect.bridgeReport?"bridge":y.type,y.info="","fail"===f.status&&(y.info={message:"code: "+f.code+", msg: "+f.failType})}),u.updateEvent(_)}return}})},e.prototype.addLintener=function(){var u=this;window.addEventListener("message",function(f){if(f.origin===location.origin){if(f&&f.data&&"devtool:web:ready"===f.data.type){if(u.devToolOrigin=f.origin,u.devToolReady=!0,u.sendAlready)return;console.log("inittttt"),u.sendData("devtool:web:init",{info:u.info,log:u.log,event:u.event}),u.sendAlready=!0}f&&f.data&&"devtool:web:ssid"===f.data.type&&u.collect.getToken(function(f){u.info[1].infoName.ssid=f.tobid,u.updateInfo()})}})},e.prototype.sendData=function(u,f){try{var y={type:u,payload:f};(window.opener||window.parent).postMessage(y,this.devToolOrigin)}catch(u){}},e.prototype.updateInfo=function(){this.devToolReady&&this.sendData("devtool:web:info",this.info)},e.prototype.updateLog=function(u){this.devToolReady?this.sendData("devtool:web:log",u):this.log.push(u)},e.prototype.updateEvent=function(u){this.devToolReady?this.sendData("devtool:web:event",u):this.event.push(u)},e.prototype.loadDebuggerModule=function(){var u=document.head||document.getElementsByTagName("head")[0],f=document.createElement("style");f.appendChild(document.createTextNode("#debugger-applog-web {\n position: absolute;\n width: 90px;\n height: 30px;\n background: #23c243;\n border-radius: 6px;\n color: #fff;\n font-size: 12px;\n bottom: 5%;\n right: 10%;\n text-align: center;\n line-height: 30px;\n cursor: pointer;\n z-index:100;\n }")),u.appendChild(f);var y=document.createElement("div");y.innerHTML='<div id="debugger-applog-web" class="debugger-applog-web">AppLog调试</div>';var _=document.createElement("div");_.innerHTML='<div id="debugger-container" class="debugger-container"></div>',document.getElementsByTagName("body")[0].appendChild(y),document.getElementsByTagName("body")[0].appendChild(_),document.getElementById("debugger-applog-web").addEventListener("click",function(){(window.opener||window.parent).postMessage({type:"devtool:web:open-draw"},location.origin)})},e}(),_e=function(){function t(u){this.disableAutoPageView=!1,this.bridgeReport=!1,this.staging=!1,this.pluginInstances=[],this.sended=!1,this.started=!1,this.destroyInstance=!1,this.sdkReady=!1,this.adapters={},this.loadType="base",this.name=u,this.hook=new C,this.remotePlugin=new Map,this.Types=Z,this.adapters.fetch=j,this.adapters.storage=B}return t.usePlugin=function(u,f,y){if(f){for(var _=!1,m=0,v=t.plugins.length;m<v;m++)if(t.plugins[m].name===f){t.plugins[m].plugin=u,t.plugins[m].options=y||{},_=!0;break}_||t.plugins.push({name:f,plugin:u,options:y})}else t.plugins.push({plugin:u})},t.prototype.usePlugin=function(u,f,y){u&&("full"===this.loadType&&this.remotePlugin.get(u)?console.info("your sdk version has "+u+" already ~"):f?"string"==typeof f?this.remotePlugin.get(u)||this.remotePlugin.set(u,{src:f,call:y}):this.remotePlugin.get(u)||this.remotePlugin.set(u,{instance:f}):this.remotePlugin.get(u)||this.remotePlugin.set(u,"sdk"))},t.prototype.init=function(u){var f,y=this;if(this.logger=new ie(this.name,u.log),this.inited)this.logger.warn("[instance: "+this.name+"], every instance's api: init, can be call only one time!");else if(u&&x(u))if(u.app_id&&"number"==typeof(f=u.app_id)&&!isNaN(f))if(!u.app_key||function(u){return"string"==typeof u}(u.app_key)){var _=u.channel_type&&"tcpy"===u.channel_type?["sg","va","in"]:["sg","va"];u.channel_domain||-1!==_.indexOf(u.channel)||(this.logger.warn("channel must "+_.join(" ,")+"!!!"),u.channel="sg"),this.spider=new ne,this.spider.checkSpider(u)?this.logger.warn("The current environment may be a spider, can not report!"):(this.logger=new ie(this.name,u.log),this.appBridge=new se(this,u.enable_native),this.bridgeReport=this.appBridge.bridgeInject(),this.configManager=new oe(this,u),this.debugger=new ge(this,u),this.initConfig=u,this.emit(Z.Init),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 执行INIT",data:u,level:"info",time:Date.now()}),u.disable_auto_pv&&(this.disableAutoPageView=!0),this.bridgeReport||(this.configManager.set({app_id:u.app_id}),this.eventManager=new pe,this.tokenManager=new de,this.sessionManager=new ye,Promise.all([new Promise(function(u){y.once(Z.TokenComplete,function(){u(!0)})}),new Promise(function(u){y.once(Z.Start,function(){u(!0)})})]).then(function(){try{t.plugins.reduce(function(u,f){var _=f.plugin,m=f.options,v=_extends(y.initConfig,m),b=new _;return b.apply(y,v),u.push(b),u},y.pluginInstances)}catch(u){y.logger.log("load plugin error, "+u.message),y.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}y.sdkReady=!0,y.emit(Z.Ready),y.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 初始化完成",time:Date.now(),level:"info",data:y.configManager.get("user")}),y.logger.info("appid: "+u.app_id+", userInfo:"+JSON.stringify(y.configManager.get("user"))),y.logger.info("appid: "+u.app_id+", sdk is ready, version is "+V+", you can report now !!!"),u.disable_auto_pv&&(y.disableAutoPageView=!0);try{("full"===y.loadType&&u.enable_ab_test||u.autotrack)&&(window.opener||window.parent).postMessage("[tea-sdk]ready","*")}catch(u){y.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}y.pageView(),y.on(Z.TokenChange,function(f){"webid"===f&&y.pageView(),y.logger.info("appid: "+u.app_id+" token change, new userInfo:"+JSON.stringify(y.configManager.get("user"))),y.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 设置了用户信息",time:Date.now(),secType:"USER",level:"info",data:y.configManager.get("user")})}),y.on(Z.TokenReset,function(){y.logger.info("appid: "+u.app_id+" token reset, new userInfo:"+JSON.stringify(y.configManager.get("user"))),y.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 重置了用户信息",time:Date.now(),secType:"USER",level:"info",data:y.configManager.get("user")})}),y.on(Z.RouteChange,function(f){f.init||u.disable_route_report||y.pageView()})}),this.tokenManager.apply(this,u),this.eventManager.apply(this,u),this.sessionManager.apply(this,u)),this.inited=!0)}else this.logger.warn("app_key param is error, must be string, please check!");else this.logger.warn("app_id param is error, must be number, please check!");else this.logger.warn("init params error,please check")},t.prototype.config=function(u){if(this.inited)if(u&&x(u))if(this.bridgeReport)this.appBridge.setConfig(u);else{u._staging_flag&&1===u._staging_flag&&(this.staging=!0),u.disable_auto_pv&&(this.disableAutoPageView=!0,delete u.disable_auto_pv);var f=b({},u);if(this.initConfig&&this.initConfig.configPersist){var y=this.configManager.getStore();y&&(f=_extends(y,u)),this.configManager.setStore(u)}f.web_id,f.user_unique_id;var _=function(u,f){var y={};for(var _ in u)Object.prototype.hasOwnProperty.call(u,_)&&f.indexOf(_)<0&&(y[_]=u[_]);if(null!=u&&"function"==typeof Object.getOwnPropertySymbols){var m=0;for(_=Object.getOwnPropertySymbols(u);m<_.length;m++)f.indexOf(_[m])<0&&(y[_[m]]=u[_[m]])}return y}(f,["web_id","user_unique_id"]);f.hasOwnProperty("web_id")&&this.emit(Z.ConfigWebId,f.web_id),f.hasOwnProperty("user_unique_id")&&this.emit(Z.ConfigUuid,f.user_unique_id),this.configManager.set(_),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 执行CONFIG",level:"info",time:Date.now(),data:f})}else this.logger.warn("config params is error, please check");else this.logger.warn("config must be use after function init")},t.prototype.setDomain=function(u){this.configManager&&this.configManager.setDomain(u),this.emit(Z.ConfigDomain)},t.prototype.getConfig=function(u){return this.configManager.get(u)},t.prototype.send=function(){this.start()},t.prototype.start=function(){this.inited&&!this.sended&&(this.sended=!0,this.emit(Z.Start),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 执行START",level:"info",time:Date.now()}),this.bridgeReport&&(this.pageView(),this.emit(Z.Ready)))},t.prototype.event=function(u,f){var y=this;try{var _=[];if(Array.isArray(u))u.forEach(function(u){var f=y.processEvent(u[0],u[1]||{});f&&_.push(f)});else{var m=this.processEvent(u,f);if(!m)return;_.push(m)}this.bridgeReport?_.forEach(function(u){var f=u.event,_=u.params;y.appBridge.onEventV3(f,JSON.stringify(_))}):_.length&&(this.emit(Z.Event,_),this.emit(Z.SessionResetTime))}catch(u){this.logger.warn("something error, please check"),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}},t.prototype.beconEvent=function(u,f){if(Array.isArray(u))this.logger.warn("beconEvent not support batch report, please check");else{var y=[],_=this.processEvent(u,f||{});_&&(y.push(_),y.length&&(this.emit(Z.BeconEvent,y),this.emit(Z.SessionResetTime)))}},t.prototype.processEvent=function(u,f){void 0===f&&(f={});try{if(!u)return this.logger.warn("eventName is null, please check"),null;var y=u;/^event\./.test(u)&&(y=u.slice(6));var _=f;"object"!=_typeof(_)&&(_={}),_.profile?delete _.profile:_.event_index=O();var m=void 0;return _.local_ms?(m=_.local_ms,delete _.local_ms):m=+new Date,{event:y,params:_,local_time_ms:m,is_bav:this.initConfig&&this.initConfig.autotrack?1:0}}catch(y){return this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:y.message}),{event:u,params:f}}},t.prototype.filterEvent=function(u){this.eventFilter=u},t.prototype.on=function(u,f){this.hook.on(u,f)},t.prototype.once=function(u,f){this.hook.once(u,f)},t.prototype.off=function(u,f){this.hook.off(u,f)},t.prototype.emit=function(u,f,y){this.hook.emit(u,f,y)},t.prototype.set=function(u){this.hook.set(u)},t.prototype.pageView=function(){this.disableAutoPageView||this.predefinePageView()},t.prototype.predefinePageView=function(u){if(void 0===u&&(u={}),this.inited){var f={title:document.title||location.pathname,url:location.href,url_path:location.pathname,time:Date.now(),referrer:window.document.referrer,$is_first_time:""+(this.configManager&&this.configManager.is_first_time||!1)},y=b({},f,u);this.event("predefine_pageview",y)}else this.logger.warn("predefinePageView should call after init")},t.prototype.clearEventCache=function(){this.emit(Z.CleanEvents)},t.prototype.setWebIDviaUnionID=function(u){if(u){var f=I(u);this.config({web_id:""+f,wechat_unionid:u}),this.emit(Z.CustomWebId)}},t.prototype.setWebId=function(u){this.config({web_id:""+u})},t.prototype.setWebIDviaOpenID=function(u){if(u){var f=I(u);this.config({web_id:""+f,wechat_openid:u}),this.emit(Z.CustomWebId)}},t.prototype.setNativeAppId=function(u){this.bridgeReport&&this.appBridge.setNativeAppId(u)},t.prototype.resetStayDuration=function(u,f,y){this.emit(Z.ResetStay,{url_path:u,title:f,url:y},Z.Stay)},t.prototype.resetStayParams=function(u,f,y){void 0===u&&(u=""),void 0===f&&(f=""),void 0===y&&(y=""),this.emit(Z.SetStay,{url_path:u,title:f,url:y},Z.Stay)},t.prototype.getToken=function(u,f){var y=this;if(this.inited){var _=!1,m=function r(f){if(!_){_=!0;var r=y.configManager.get().user;return f&&(r.tobid=f,r["diss".split("").reverse().join("")]=f),u(b({},r))}},v=function s(){y.tokenManager.getTobId().then(function(u){m(u)})};this.sdkReady?v():(f&&setTimeout(function(){m()},f),this.on(Z.Ready,function(){v()}))}else this.logger.warn("predefinePageView should call after init")},t.prototype.profileSet=function(u){this.bridgeReport?this.appBridge.profileSet(JSON.stringify(u)):this.emit(Z.ProfileSet,u,Z.Profile),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileSet",level:"info",time:Date.now(),data:u})},t.prototype.profileSetOnce=function(u){this.bridgeReport?this.appBridge.profileSetOnce(JSON.stringify(u)):this.emit(Z.ProfileSetOnce,u,Z.Profile),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileSetOnce",level:"info",time:Date.now(),data:u})},t.prototype.profileIncrement=function(u){this.bridgeReport?this.appBridge.profileIncrement(JSON.stringify(u)):this.emit(Z.ProfileIncrement,u,Z.Profile),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileIncrement",level:"info",time:Date.now(),data:u})},t.prototype.profileUnset=function(u){this.bridgeReport?this.appBridge.profileUnset(u):this.emit(Z.ProfileUnset,u,Z.Profile),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileUnset",level:"info",time:Date.now(),data:u})},t.prototype.profileAppend=function(u){this.bridgeReport?this.appBridge.profileAppend(JSON.stringify(u)):this.emit(Z.ProfileAppend,u,Z.Profile),this.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileAppend",level:"info",time:Date.now(),data:u})},t.prototype.setExternalAbVersion=function(u){this.emit(Z.AbExternalVersion,"string"==typeof u&&u?(""+u).trim():null,Z.Ab)},t.prototype.getVar=function(u,f,y,_){this.emit(Z.AbVar,{name:u,defaultValue:f,callback:y,uuid:_},Z.Ab)},t.prototype.getABconfig=function(u,f){this.emit(Z.AbConfig,{params:u,callback:f},Z.Ab)},t.prototype.getAbSdkVersion=function(){return this.configManager.getAbVersion()},t.prototype.onAbSdkVersionChange=function(u){var f=this;return this.emit(Z.AbVersionChangeOn,u,Z.Ab),function(){f.emit(Z.AbVersionChangeOff,u,Z.Ab)}},t.prototype.offAbSdkVersionChange=function(u){this.emit(Z.AbVersionChangeOff,u,Z.Ab)},t.prototype.openOverlayer=function(){this.emit(Z.AbOpenLayer,"",Z.Ab)},t.prototype.closeOverlayer=function(){this.emit(Z.AbCloseLayer,"",Z.Ab)},t.prototype.getAllVars=function(u){this.emit(Z.AbAllVars,u,Z.Ab)},t.prototype.autoInitializationRangers=function(u){var f,y,_,m,v,b,w,S;y=(f=u).app_id,_=f.channel,m=f.onTokenReady,v=G[_]+"/webid",b=new B(!1),w="__tea_cache_tokens_"+y,(S=b.getItem(w))&&S.web_id?m(S.web_id):ue(v,{app_key:"",app_id:y,url:location.href,user_agent:window.navigator.userAgent,referer:document.referrer},3e3,!1,function(u){if(u&&0===u.e){m(u.web_id);var f={web_id:u.web_id,user_unique_id:u.web_id,timestamp:Date.now()};b.setItem(w,f)}else m("")},function(){m("")},!0)},t.prototype.destoryInstace=function(){this.destroyInstance||(this.destroyInstance=!0,this.off(Z.TokenComplete))},t.plugins=[],t}(),me=function(){function e(){}return e.prototype.apply=function(u,f){var y=this,_=u.adapters.fetch;if(f.event_verify_url)if("string"==typeof f.event_verify_url){if(this.url=f.event_verify_url+"/v1/list_test",this.url){var m=u.Types;u.on(m.SubmitBefore,function(u){_(y.url,u,3e4)})}}else console.log("please use correct et_test url")},e}(),ve=function(){function t(){}return t.prototype.apply=function(u,f){var y=this;this.collect=u,this.config=f,this.duration=6e4,this.reportUrl=u.configManager.getDomain()+"/profile/list";var _=u.Types,m=u.adapters.fetch;this.eventCheck=new Q(u,f),this.fetch=m,this.cache={},this.collect.on(_.ProfileSet,function(u){y.setProfile(u)}),this.collect.on(_.ProfileSetOnce,function(u){y.setOnceProfile(u)}),this.collect.on(_.ProfileUnset,function(u){y.unsetProfile(u)}),this.collect.on(_.ProfileIncrement,function(u){y.incrementProfile(u)}),this.collect.on(_.ProfileAppend,function(u){y.appendProfile(u)}),this.collect.on(_.ProfileClear,function(){y.cache={}}),this.ready(_.Profile)},t.prototype.ready=function(u){var f=this;if(this.collect.set(u),this.collect.hook._hooksCache.hasOwnProperty(u)){var y=this.collect.hook._hooksCache[u];if(!Object.keys(y).length)return;var _=function o(u){y[u].length&&y[u].forEach(function(y){f.collect.hook.emit(u,y)})};for(var m in y)_(m)}},t.prototype.report=function(u,f){void 0===f&&(f={});try{if(this.config.disable_track_event)return;var y=[];y.push(this.collect.processEvent(u,f));var _=this.collect.eventManager.merge(y);this.fetch(this.reportUrl,_),this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:_,code:200,status:"success"})}catch(u){this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}},t.prototype.setProfile=function(u){var f=this.formatParams(u);f&&Object.keys(f).length&&(this.pushCache(f),this.report("__profile_set",b({},f,{profile:!0})))},t.prototype.setOnceProfile=function(u){var f=this.formatParams(u,!0);f&&Object.keys(f).length&&(this.pushCache(f),this.report("__profile_set_once",b({},f,{profile:!0})))},t.prototype.incrementProfile=function(u){u?this.report("__profile_increment",b({},u,{profile:!0})):console.warn("please check the params, must be object!!!")},t.prototype.unsetProfile=function(u){if(u){var f={};f[u]="1",this.report("__profile_unset",b({},f,{profile:!0}))}else console.warn("please check the key, must be string!!!")},t.prototype.appendProfile=function(u){if(u){var f={};for(var y in u)"string"==typeof u[y]||"Array"===Object.prototype.toString.call(u[y]).slice(8,-1)?f[y]=u[y]:console.warn("please check the value of param: "+y+", must be string or array !!!");Object.keys(f).length&&this.report("__profile_append",b({},f,{profile:!0}))}else console.warn("please check the params, must be object!!!")},t.prototype.pushCache=function(u){var f=this;Object.keys(u).forEach(function(y){f.cache[y]={val:f.clone(u[y]),timestamp:Date.now()}})},t.prototype.formatParams=function(u,f){var y=this;void 0===f&&(f=!1);try{if(!u||"[object Object]"!==Object.prototype.toString.call(u))return void console.warn("please check the params type, must be object !!!");var _={};for(var m in u)"string"==typeof u[m]||"number"==typeof u[m]||"Array"===Object.prototype.toString.call(u[m]).slice(8,-1)?_[m]=u[m]:console.warn("please check the value of params:"+m+", must be string,number,Array !!!");var v=Object.keys(_);if(!v.length)return;if(!this.eventCheck.checkEventParams(_))return;var b=Date.now();return v.filter(function(_){var m=y.cache[_];return f?!m:!(m&&y.compare(m.val,u[_])&&b-m.timestamp<y.duration)}).reduce(function(u,f){return u[f]=_[f],u},{})}catch(u){this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message}),console.log("error")}},t.prototype.compare=function(u,f){try{return JSON.stringify(u)===JSON.stringify(f)}catch(u){return this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message}),!1}},t.prototype.clone=function(u){try{return JSON.parse(JSON.stringify(u))}catch(f){return this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:f.message}),u}},t.prototype.unReady=function(){console.warn("sdk is not ready, please use this api after start")},t}(),be=function(){function e(){var u=this;this.setInterval=function(){u.clearIntervalFunc=function c(u,f){void 0===u&&(u=function e(){}),void 0===f&&(f=1e3);var y,_=Date.now()+f;return y=window.setTimeout(function n(){var m=Date.now()-_;u(),_+=f,y=window.setTimeout(n,Math.max(0,f-m))},f),function(){window.clearTimeout(y)}}(function(){u.isSessionhasEvent&&u.endCurrentSession()},u.sessionInterval)},this.clearInterval=function(){u.clearIntervalFunc&&u.clearIntervalFunc()}}return e.prototype.apply=function(u,f){var y=this;if(this.collect=u,!f.disable_heartbeat){this.sessionInterval=6e4,this.startTime=0,this.lastTime=0,this.setInterval();var _=this.collect.Types;this.collect.on(_.SessionReset,function(){y.process()})}},e.prototype.endCurrentSession=function(){this.collect.event("_be_active",{start_time:this.startTime,end_time:this.lastTime,url:window.location.href,referrer:window.document.referrer,title:document.title||location.pathname}),this.isSessionhasEvent=!1,this.startTime=0},e.prototype.process=function(){this.isSessionhasEvent||(this.isSessionhasEvent=!0,this.startTime=+new Date);var u=this.lastTime||+new Date;this.lastTime=+new Date,this.lastTime-u>this.sessionInterval&&(this.clearInterval(),this.endCurrentSession(),this.setInterval())},e}(),we=function(){function e(){}return e.prototype.apply=function(u,f){var y=this;if(this.collect=u,this.config=f,!this.config.channel_domain&&!f.disable_track_event&&!f.disable_sdk_monitor){var _=u.adapters.fetch;this.fetch=_,this.url=u.configManager.getUrl("event");var m=this.collect.Types;this.collect.on(m.Ready,function(){y.sdkOnload()}),this.collect.on(m.SubmitError,function(u){var f=u.type,_=u.eventData,m=u.errorCode;"f_data"===f&&y.sdkError(_,m)})}},e.prototype.sdkOnload=function(){var u=this;try{var f=this.collect.configManager.get(),y=f.header,_=f.user,m=y.app_id,v=y.app_name,b=y.sdk_version,w=_.web_id,S={events:[{event:"onload",params:JSON.stringify({app_id:m,app_name:v||"",sdk_version:b,sdk_type:"npm",sdk_config:this.config,sdk_desc:"TOC_OVERSEA"}),local_time_ms:Date.now()}],user:{user_unique_id:w},header:{}};setTimeout(function(){u.fetch(u.url,[S],3e4,!1,function(){},function(){},"566f58151b0ed37e")},16)}catch(u){}},e.prototype.sdkError=function(u,f){var y=this;try{var _=u[0],m=_.user,v=_.header,b=[];u.forEach(function(u){u.events.forEach(function(u){b.push(u)})});var w={events:b.map(function(u){return{event:"on_error",params:JSON.stringify({error_code:f,app_id:v.app_id,app_name:v.app_name||"",error_event:u.event,sdk_version:v.sdk_version,local_time_ms:u.local_time_ms,tea_event_index:Date.now(),params:u.params,header:JSON.stringify(v),user:JSON.stringify(m)}),local_time_ms:Date.now()}}),user:{user_unique_id:m.user_unique_id},header:{}};setTimeout(function(){y.fetch(y.url,[w],3e4,!1,function(){},function(){},"566f58151b0ed37e")},16)}catch(u){}},e}(),Se={autotrack:{src:{sg:"https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/autotrack.js",va:"https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/autotrack.js"},object:"LogAutoTrack"},ab:{src:{sg:"https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/ab.js",va:"https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/ab.js"},object:"LogAb"},stay:{src:{sg:"https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/stay.js",va:"https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/stay.js"},object:"LogStay"},route:{src:{sg:"https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/route.js",va:"https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/route.js"},object:"LogRoute"},cep:{src:{sg:"https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/cep.js",va:"https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/cep.js"},object:"LogCep"},tracer:{src:{sg:"https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/tracer.js",va:"https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/tracer.js"},object:"LogTracer"},visual:{src:{sg:"https://sf16-scmcdn-sg.ibytedtos.com/obj/static-sg/log-sdk/collect/5.0/plugin/visual.js",va:"https://sf16-scmcdn-va.ibytedtos.com/obj/static-us/log-sdk/collect/5.0/plugin/visual.js"},object:"LogVisual"}},ke="undefined"!=typeof window?(window.LogPluginObject||(window.LogPluginObject={}),window.LogPluginObject):null,Ee=function(){function e(){}return e.prototype.apply=function(u,f){this._plugin={},this.config=f,this.collect=u,this.channel=f.channel||"cn",this.loadExtend()},e.prototype.loadExtend=function(){var u=this;try{this.collect.remotePlugin.forEach(function(f,y){if("sdk"===f)if(Se.hasOwnProperty(y)){var _=Se[y].object,m=""+Se[y].src[u.channel];u.exist(y,_,m)}else console.warn("your "+y+" is not exist,please check plugin name");else"object"==_typeof(f)&&(f.src?u.exist(y,f.call,f.src):u.process(y,f.instance,"INSTANCE"))})}catch(u){this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message}),console.log("load extend error")}},e.prototype.exist=function(u,f,y){var _=this;ke[f]?(this.process(u,ke[f]),console.log("已有"+u+"插件,避免重复加载~")):this.loadPlugin(u,y,function(){_.process(u,ke[f]),console.log(" %c %s %s %s","color: yellow; background-color: black;","–","load plugin:"+u+" success","-")},function(){console.log(" %c %s %s %s","color: red; background-color: yellow;","–","load plugin:"+u+" error","-")})},e.prototype.process=function(u,f,y){try{if(y){var _=new f;_.apply&&_.apply(this.collect,this.config),console.log("excude "+u+" success")}else f&&f(this.collect,this.config)}catch(f){this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:f.message}),console.log("excude "+u+" error, message:"+f.message)}},e.prototype.loadPlugin=function(u,f,y,_){var m=this;try{var v=document.createElement("script");v.src=f,this._plugin[u]||(this._plugin[u]=[]),this._plugin[u].push(y),v.onerror=function(){_(f)},v.onload=function(){m._plugin[u].forEach(function(u){u()})},document.getElementsByTagName("head")[0].appendChild(v)}catch(u){this.collect.emit(E.DEBUGGER_MESSAGE,{type:E.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:u.message})}},e}();_e.usePlugin(Ee,"extend"),_e.usePlugin(me,"et"),_e.usePlugin(ve,"profile"),_e.usePlugin(be,"heartbeat"),_e.usePlugin(we,"monitor");var Ce=new _e("default"),xe=Ce,Oe={browserError:1e3,crc32:1e3,preUpload:1001,initUploadID:1002,process:1003,fileMerge:1004,complete:1005},Pe="video",Ue="image",De={video:"video_upload",image:"image_upload",object:"object_upload"},Ie=1,Te=2,Ae=3,je="vod",ze={"ap-singapore-1":"ap-singapore-1","ap-southeast-1":"ap-southeast-1"},Me="https://vod.byteplusapi.com",Re=5242880;function LoggerV5_typeof(u){return LoggerV5_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},LoggerV5_typeof(u)}function LoggerV5_extends(){return LoggerV5_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},LoggerV5_extends.apply(null,arguments)}function _defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,_toPropertyKey(_.key),_)}}function _toPropertyKey(u){var f=function _toPrimitive(u,f){if("object"!=LoggerV5_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=LoggerV5_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==LoggerV5_typeof(f)?f:f+""}var Ne=function(){return function _createClass(u,f,y){return f&&_defineProperties(u.prototype,f),y&&_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(function Logger(u,f){if(function _classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,Logger),this.options=u,this.context=f,this.teaLog=xe,this.tea_app_id=2643,this.tea_channel="sg","us"===this.options.region)this.tea_channel="va";else this.tea_channel="sg";this.teaLog.init({app_id:this.tea_app_id,channel:this.tea_channel,log:!1,disable_sdk_monitor:!0,disable_auto_pv:!0,disable_webid:!0,disable_session:!0}),this.teaLog.config({evtParams:{sdk_version:"1.1.3",line_app_id:this.options.appId+"",toB:!0},user_unique_id:this.options.userId}),this.teaLog.start()},[{key:"send",value:function send(u){var f=this.context,y=u.key,_=f.tasks[y],m=Oe[u.stage]||999,v=u.fileType||_.fileType,b=u.fileSize||0,w={log_type:De[v],stage:m,fk:y,fs:b,req:u.req,res:u.res,ts:Math.round(Date.now()/1e3),sst:u.stageStartTime,set:u.stageEndTime,dur:u.duration,tdur:u.totalDuration,isDirect:Number(!!u.isDirect)},S="".concat("image"===v?"image":"video","_")+("error"===u.type?"error":m);switch(m){case 1e3:this.teaLog.event(S,LoggerV5_extends({},w,{type:u.type,ex:JSON.stringify({errc:u.extra&&u.extra.errorCode,msg:u.extra&&u.extra.message,crc32Array:u.crc32Array,isDirect:u.isDirect})}));break;case 1001:this.teaLog.event(S,LoggerV5_extends({},w,{type:u.type,oid:u.oid,upload_host:u.tosDomain,ex:JSON.stringify({errc:u.extra&&u.extra.errorCode,err:u.extra&&u.extra.error,msg:u.extra&&u.extra.message,sig:u.signature,reqid:u.extra&&u.extra.requestId})}));break;case 1002:this.teaLog.event(S,LoggerV5_extends({},w,{type:u.type,oid:u.oid,upload_host:u.tosDomain,ex:JSON.stringify({errc:u.extra&&u.extra.errorCode,msg:u.extra&&u.extra.message,upid:u.uploadID,reqid:u.extra&&u.extra.requestId}),upload_id:u.uploadID}));break;case 1003:u.isAllFinish||u.isDirect||(delete w.sst,delete w.set,delete w.dur,delete w.isDirect),this.teaLog.event(S,LoggerV5_extends({},w,{type:u.type,oid:u.oid,upload_host:u.tosDomain,ex:JSON.stringify({errc:u.extra&&u.extra.errorCode,msg:u.extra&&u.extra.message,si:u.slice_index,af:u.isAllFinish,reqid:u.extra&&u.extra.requestId}),upload_id:u.uploadID,si:u.slice_index,al:u.isAllFinish}));break;case 1004:this.teaLog.event(S,LoggerV5_extends({},w,{type:u.type,oid:u.oid,upload_host:u.tosDomain,ex:JSON.stringify({errc:u.extra&&u.extra.errorCode,msg:u.extra&&u.extra.message,reqid:u.extra&&u.extra.requestId}),upload_id:u.uploadID}));break;case 1005:this.teaLog.event(S,LoggerV5_extends({},w,{type:u.type,oid:u.oid,upload_host:u.tosDomain,ex:JSON.stringify({errc:u.extra&&u.extra.errorCode,err:u.extra&&u.extra.error,msg:u.extra&&u.extra.message,vid:u.uploadResult&&u.uploadResult.Vid,reqid:u.extra&&u.extra.requestId}),vid:u.uploadResult&&u.uploadResult.Vid}));break;default:this.teaLog.event(S,LoggerV5_extends({},w,{type:u.type,oid:u.oid,upload_host:u.tosDomain,ex:JSON.stringify({errc:u.extra&&u.extra.errorCode,msg:u.extra&&u.extra.message})}))}}},{key:"console",value:function(u){function console(f){return u.apply(this,arguments)}return console.toString=function(){return u.toString()},console}(function(u){this.options.debug&&console.log(u)})}])}(),Be=y(2),Le=y.n(Be),Ge=y(1),Fe=y.n(Ge),Ke={resolveUri:function resolveUri(u){if(!u)return"";if(Array.isArray(u))return u.map(function(u){try{return u.split("/")[0]+"/"+encodeURIComponent(u.split("/").slice(1).join("/"))}catch(f){return u}});try{return u.split("/")[0]+"/"+encodeURIComponent(u.split("/").slice(1).join("/"))}catch(f){return u}},urlTemplate:function urlTemplate(u,f){var y;return f=f||{},Object.keys(f).forEach(function(_){y=new RegExp("{".concat(_,"}"),"g"),u=u.replace(y,f[_])}),u},toQueryString:function toQueryString(){var u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},f=[];return Object.keys(u).map(function(y){var _=u[y];"[object Array]"===Object.prototype.toString.call(_)?_.forEach(function(u){f.push("".concat(y,"=").concat(encodeURIComponent(u)))}):f.push("".concat(y,"=").concat(encodeURIComponent(u[y])))}),f.join("&")},arrayToObject:function arrayToObject(u){var f={};return u&&u.forEach(function(u){f[u.Key.toLowerCase()]=u.Value}),f},supportChunked:function supportChunked(){var u=window.Blob||window.WebKitBlob;try{var f=u.prototype;return!(!FormData||!(f.slice||f.webkitSlice||f.mozSlice))}catch(u){return!1}},supportXhr:function supportXhr(){return!!window.FormData||window.ProgressEvent&&window.FileReader},supportCrc32:function supportCrc32(){var u=window.FileReader&&window.FileReader.prototype.readAsBinaryString;return"undefined"!=typeof Int32Array&&u&&(Blob.prototype.slice||Blob.prototype.webkitSlice||Blob.prototype.mozSlice)},storage:function storage(u){var f=u,y={removeItem:function removeItem(u){delete f.cache[u]},setItem:function setItem(u,y){f.cache[u]=y},getItem:function getItem(u){return f.cache[u]},clear:function clear(){delete f.cache,f.cache={}}};if(!(!(arguments.length>1&&void 0!==arguments[1])||arguments[1]))return y;try{if(window.localStorage)return window.localStorage.setItem("",""),window.localStorage}catch(u){return y}return y},noop:function noop(){},getUnique:function getUnique(u){return"".concat(u,"_").concat((new Date).getTime(),"_").concat(parseInt(1e6*Math.random()))},getFileSliceLength:function getFileSliceLength(u,f){var y=u.size;return f&&"function"==typeof f?f(y)<Re?Re:f(y)||y:y>419430400?10485760:y<=419430400&&y>=2097152?5242880:u.size},getFileSuffix:function getFileSuffix(u){if(u&&"[object String]"===Object.prototype.toString.call(u)){var f=u.lastIndexOf(".");return f>0?"."+u.substring(f+1):void 0}},crypto:{hmac:function hmac(u,f){return Le()(f,u)},sha256:function sha256(u){return Fe()(u)}},date:{iso8601:function iso8601(u){return void 0===u&&(u=Ke.date.getDate()),u.toISOString().replace(/\.\d{3}Z$/,"Z")}},Buffer:Uint8Array,buffer:{toBuffer:function toBuffer(u,f){return"function"==typeof Ke.Buffer.from&&Ke.Buffer.from!==Uint8Array.from?Ke.Buffer.from(u,f):new Ke.Buffer(u,f)},alloc:function alloc(u,f,y){if("number"!=typeof u)throw new Error("size passed to alloc must be a number.");if("function"==typeof Ke.Buffer.alloc)return Ke.Buffer.alloc(u,f,y);var _=new Ke.Buffer(u);return void 0!==f&&"function"==typeof _.fill&&_.fill(f,void 0,void 0,y),_},toStream:function toStream(u){Ke.Buffer.isBuffer(u)||(u=Ke.buffer.toBuffer(u));var f=new Ke.stream.Readable,y=0;return f._read=function(_){if(y>=u.length)return f.push(null);var m=y+_;m>u.length&&(m=u.length),f.push(u.slice(y,m)),y=m},f},concat:function concat(u){var f,y,_=0,m=0;for(y=0;y<u.length;y++)_+=u[y].length;for(f=Ke.buffer.alloc(_),y=0;y<u.length;y++)u[y].copy(f,m),m+=u[y].length;return f}}};function debugLog(){var u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"log",f=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{if("undefined"!=typeof window&&window.localStorage){var y=window.localStorage.getItem("$byteplus-uploader_enable_debug_log");null!==y&&(f="true"===y)}}catch(u){}if(f){for(var _,m=["log","warn","error","info","debug","trace"].includes(u)?u:"log",v=arguments.length,b=new Array(v>2?v-2:0),w=2;w<v;w++)b[w-2]=arguments[w];(_=console)[m].apply(_,["[BytePlus-Uploader]"].concat(b))}}var qe=Ke;function toEight(u){return u.length<8?toEight(u="0".concat(u)):u}var He={crc32:function encrypt_crc32(u,f){var y=[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&&(y=new Int32Array(y));for(var _=-1^f,m=(u=new Uint8Array(u)).length,v=0;v<m;v++)_=y[255&(_^u[v])]^_>>>8;return(-1^_)>>>0},dec2hex:function dec2hex(u){if(void 0!==u)return toEight(Number(u).toString(16))}};function Crc32_typeof(u){return Crc32_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},Crc32_typeof(u)}function Crc32_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,Crc32_toPropertyKey(_.key),_)}}function Crc32_toPropertyKey(u){var f=function Crc32_toPrimitive(u,f){if("object"!=Crc32_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=Crc32_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==Crc32_typeof(f)?f:f+""}var Ve=function(){return function Crc32_createClass(u,f,y){return f&&Crc32_defineProperties(u.prototype,f),y&&Crc32_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(function Crc32(u,f,y,_){!function Crc32_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,Crc32),this.file=u,this.successProcess=y,this.failProcess=_,this.sliceLength=f,this.retryTime=0,this.fileSize=u.size,this.crc32Array=[]},[{key:"start",value:function start(){this.readFileCrc32(this.file)}},{key:"readFileCrc32",value:function readFileCrc32(u){var f=this,y=this.sliceLength,_=u.slice||u.webkitSlice||u.mozSlice,m=new FileReader,v=0,b=0,w=0;!function read(){b<u.size&&(b=Math.min(v+y,u.size),u.size>104857600&&u.size-b<=5242880&&(b=u.size)),m.readAsArrayBuffer(_.call(u,v,b)),m.onload=function(y){var _=y.target.result;w=He.crc32(_,0),f.crc32Array.push({start:v,end:b,crc32:He.dec2hex(w),buffer:_}),v=b,b<u.size?read():f.success(f.crc32Array)}}()}},{key:"success",value:function success(u){this.successProcess(u)}},{key:"fail",value:function fail(u,f,y,_){this.retryTime>=3?this.failProcess():(this.readFileCrc32(u,f,y,_),this.retryTime++)}}])}();function FileCrc32_typeof(u){return FileCrc32_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},FileCrc32_typeof(u)}function FileCrc32_extends(){return FileCrc32_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},FileCrc32_extends.apply(null,arguments)}function _toConsumableArray(u){return function _arrayWithoutHoles(u){if(Array.isArray(u))return _arrayLikeToArray(u)}(u)||function _iterableToArray(u){if("undefined"!=typeof Symbol&&null!=u[Symbol.iterator]||null!=u["@@iterator"])return Array.from(u)}(u)||function _unsupportedIterableToArray(u,f){if(u){if("string"==typeof u)return _arrayLikeToArray(u,f);var y={}.toString.call(u).slice(8,-1);return"Object"===y&&u.constructor&&(y=u.constructor.name),"Map"===y||"Set"===y?Array.from(u):"Arguments"===y||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(y)?_arrayLikeToArray(u,f):void 0}}(u)||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(u,f){(null==f||f>u.length)&&(f=u.length);for(var y=0,_=Array(f);y<f;y++)_[y]=u[y];return _}function FileCrc32_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,FileCrc32_toPropertyKey(_.key),_)}}function FileCrc32_toPropertyKey(u){var f=function FileCrc32_toPrimitive(u,f){if("object"!=FileCrc32_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=FileCrc32_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==FileCrc32_typeof(f)?f:f+""}var We=function(){return function FileCrc32_createClass(u,f,y){return f&&FileCrc32_defineProperties(u.prototype,f),y&&FileCrc32_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(function FileCrc32(u){var f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function FileCrc32_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,FileCrc32),this.context=u.context,this.key=u.key,this.isDirect=u.isDirect,this.isImageBatchUpload=u.isImageBatchUpload,this.file=u.file,this.type=(this.isImageBatchUpload?this.file[0].type:this.file.type)||"",this.sliceLength=qe.getFileSliceLength(this.file,f.getSliceFunc),this.config=f},[{key:"start",value:function start(u,f,y){this.successProcess=f,this.failProcess=y,this._st=Date.now(),this.crc32(this.file,this.sliceLength)}},{key:"crc32",value:function crc32(u,f){var y=this;if(this.isImageBatchUpload)for(var _=u.length,m=[],v=0;v<_;v++){var crc32=new Ve(u[v],u[v].size,function(u){m.push(u[0]),m.length===_&&y.success(m)},function(u){y.fail(u)});crc32.start()}else{if(!u||!u.size||u.size<=0)return void this.fail({message:"There is a problem with the input file or fileSize."});if(this.isDirect){var b=new Ve(u,u.size,function(u){y.success(u)},function(u){y.fail(u)});b.start()}else this.sliceFile(u,f,function(u){y.success(u)},function(u){y.fail(u)})}}},{key:"sliceFile",value:function sliceFile(u,f,y,_){for(var m=[],v=f,b=u.size,w=new FileReader,S=u.slice||u.webkitSlice||u.mozSlice,k=0,E=0,C=0;E<b;)E=Math.min(k+v,b),b-E<=5242880&&(E=b),m.push({start:k,end:E,crc32:0}),k=E;try{!function read(f){k=m[f].start,E=m[f].end,w.readAsArrayBuffer(S.call(u,k,E)),w.onload=function(u){var _=u.target.result;C=He.dec2hex(He.crc32(_,0)),m[f].crc32=C,E===b?y(m):read(m.length-1)},w.onerror=function(u){_(u)}}(0)}catch(u){_(u)}}},{key:"getCrc32Key",value:function getCrc32Key(u,f,y){var _,m;((_="[object Array]"===Object.prototype.toString.call(f)?_toConsumableArray(f):[f]).push(u[0].crc32,u[u.length-1].crc32),this.config.useFileNameInCacheKey)&&(Array.isArray(y)?(m=_).push.apply(m,_toConsumableArray(y)):_.push(y));return _.join("_")}},{key:"success",value:function success(u){var f=this.context,y=this.key,_=[],m=[];if(this.isImageBatchUpload)for(var v=0;v<this.file.length;v++)_.push(this.file[v].size),m.push(this.file[v].name);else _=this.file.size,m=this.file.name;var b=this.getCrc32Key(u,_,m),w=f.tasks[y];w&&this.successProcess(FileCrc32_extends(w,{key:y,crc32Array:u,crc32Key:b,sdkVersion:"1.1.3",sliceLength:this.sliceLength,extra:{message:"get crc32 success"},stage:"crc32",type:"success",fileSize:_,fileName:m,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st,isDirect:this.isDirect,isImageBatchUpload:this.isImageBatchUpload}))}},{key:"fail",value:function fail(u){var f=this.context,y=this.key,_=u&&u.message?u.message:"get crc32 error",m=FileCrc32_extends(f.tasks[y],{extra:{message:_},type:"error",stage:"crc32",stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st});this.failProcess(m)}}])}();function Transport_typeof(u){return Transport_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},Transport_typeof(u)}function Transport_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,Transport_toPropertyKey(_.key),_)}}function Transport_toPropertyKey(u){var f=function Transport_toPrimitive(u,f){if("object"!=Transport_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=Transport_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==Transport_typeof(f)?f:f+""}function _callSuper(u,f,y){return f=_getPrototypeOf(f),function _possibleConstructorReturn(u,f){if(f&&("object"==Transport_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,_isNativeReflectConstruct()?Reflect.construct(f,y||[],_getPrototypeOf(u).constructor):f.apply(u,y))}function _isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function _getPrototypeOf(u){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},_getPrototypeOf(u)}function _setPrototypeOf(u,f){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},_setPrototypeOf(u,f)}var Je=function(u){function Transport(){var u;return function Transport_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,Transport),(u=_callSuper(this,Transport)).xhr=new XMLHttpRequest,u._data=null,u}return function _inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&_setPrototypeOf(u,f)}(Transport,u),function Transport_createClass(u,f,y){return f&&Transport_defineProperties(u.prototype,f),y&&Transport_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(Transport,[{key:"_ajax",value:function _ajax(u){var f=this,y=this.xhr;y.upload.onprogress=function(u){f.emit("progress",u)},y.onreadystatechange=function(){4===y.readyState&&(y.upload.onprogress=qe.noop,y.onreadystatechange=qe.noop,y.params=u,f._data&&f._data.url&&(y.currentUrl=f._data.url),y.status>=200&&y.status<300?f.emit("complete",y):y.status>=400&&f.emit("error",y))},y.onerror=function(){y.errText="unknow net error",f.emit("error",y)},y.ontimeout=function(){y.errText="timeout",f.emit("error",y)},y.onabort=function(){y.errText="abort",f.emit("error",y)},y.send(u)}},{key:"send",value:function send(u){var f=this;return this._data=u,this.xhr.open(u.method||"POST",u.url||"",!0),u.headers&&Object.keys(u.headers).forEach(function(y){f.xhr.setRequestHeader(y,u.headers[y])}),this.xhr.timeout=u.timeout||0,u.ontimeout&&(this.xhr.ontimeout=u.ontimeout),u.binary?this.sendAsBinary(u):u.custom?"object"===Transport_typeof(u.custom)?this.sendAsCustom(JSON.stringify(u.custom)):"none"===u.custom?(delete u.custom,this.sendAsCustom()):this.sendAsCustom(u.custom):this.sendAsFormData(u)}},{key:"sendAsBinary",value:function sendAsBinary(u){return this.xhr.setRequestHeader("Content-Type","application/octet-stream"),this.xhr.setRequestHeader("Content-Disposition",'attachment; filename="'.concat(encodeURI(u.filename),'"')),this._ajax(u.file)}},{key:"sendAsFormData",value:function sendAsFormData(u){var f;u.formData&&(f="function"==typeof u.formData?u.formData():u.formData),f||(f=[]);for(var y=new FormData,_=0,m=f.length;_<m;_++){var v=f[_];y.append(v.name,v.value)}return u.file&&y.append(u.field,u.file,u.name),this._ajax(y)}},{key:"sendAsCustom",value:function sendAsCustom(u){return this._ajax(u)}},{key:"abort",value:function abort(){this.xhr.onreadystatechange=qe.noop,this.xhr.abort()}},{key:"getResponse",value:function getResponse(){return this.xhr.response}},{key:"getText",value:function getText(){return this.xhr.responseText}},{key:"getJson",value:function getJson(){return JSON.parse(this.xhr.responseText)}}])}(m.a),Qe={hmac:function hmac(u,f){return Le()(f,u)},sha256:function sha256(u){return Fe()(u)}};function awsv4_typeof(u){return awsv4_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},awsv4_typeof(u)}function awsv4_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,awsv4_toPropertyKey(_.key),_)}}function awsv4_toPropertyKey(u){var f=function awsv4_toPrimitive(u,f){if("object"!=awsv4_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=awsv4_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==awsv4_typeof(f)?f:f+""}var $e=["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id"],Xe=function uriEscape(u){try{return encodeURIComponent(u).replace(/[^A-Za-z0-9_.~\-%]+/g,escape).replace(/[*]/g,function(u){return"%".concat(u.charCodeAt(0).toString(16).toUpperCase())})}catch(u){return""}},Ze=function queryParamsToString(u){return Object.keys(u).sort().map(function(f){var y=u[f];if(null!=y){var _=Xe(f);if(_)return Array.isArray(y)?"".concat(_,"=").concat(y.map(Xe).sort().join("&".concat(_,"="))):"".concat(_,"=").concat(Xe(y))}}).filter(function(u){return u}).join("&")},Ye=function(){return function awsv4_createClass(u,f,y){return f&&awsv4_defineProperties(u.prototype,f),y&&awsv4_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(function AWSSignersV4(u,f,y){!function awsv4_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,AWSSignersV4),this.request=u,this.request.headers=u.headers||{},this.serviceName=f,y=y||{},this.signatureCache="boolean"!=typeof y.signatureCache||y.signatureCache,this.operation=y.operation,this.signatureVersion=y.signatureVersion,this.constant=y.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=y.bodySha256,this.shouldSerializeBody="boolean"!=typeof y.shouldSerializeBody||y.shouldSerializeBody},[{key:"addAuthorization",value:function addAuthorization(u,f){var y=this.iso8601(f).replace(/[:\-]|\.\d{3}/g,"");this.addHeaders(u,y),this.request.headers.Authorization=this.authorization(u,y)}},{key:"addHeaders",value:function addHeaders(u,f){if(this.request.headers[this.constant.dateHeader]=f,u.sessionToken&&(this.request.headers[this.constant.tokenHeader]=u.sessionToken),this.request.body){var y=this.request.body;"string"!=typeof y&&this.shouldSerializeBody&&(y=y instanceof URLSearchParams?y.toString():JSON.stringify(y)),this.request.headers[this.constant.contentSha256Header]=this.bodySha256||Qe.sha256(y).toString()}}},{key:"authorization",value:function authorization(u,f){var y=[],_=this.credentialString(f);return y.push("".concat(this.constant.algorithm," Credential=").concat(u.accessKeyId,"/").concat(_)),y.push("SignedHeaders=".concat(this.signedHeaders())),y.push("Signature=".concat(this.signature(u,f))),y.join(", ")}},{key:"signature",value:function signature(u,f){var y=this.getSigningKey(u,f.substr(0,8),this.request.region,this.serviceName,this.signatureCache);return Qe.hmac(y,this.stringToSign(f),"hex")}},{key:"stringToSign",value:function stringToSign(u){var f=[];return f.push(this.constant.algorithm),f.push(u),f.push(this.credentialString(u)),f.push(this.hexEncodedHash(this.canonicalString())),f.join("\n")}},{key:"canonicalString",value:function canonicalString(){var u=[],f=this.request.pathname||"/";return u.push(this.request.method.toUpperCase()),u.push(f),u.push(Ze(this.request.params)||""),u.push("".concat(this.canonicalHeaders(),"\n")),u.push(this.signedHeaders()),u.push(this.hexEncodedBodyHash()),u.join("\n")}},{key:"canonicalHeaders",value:function canonicalHeaders(){var u=this,f=[];Object.keys(this.request.headers).forEach(function(y){f.push([y,u.request.headers[y]])}),f.sort(function(u,f){return u[0].toLowerCase()<f[0].toLowerCase()?-1:1});var y=[];return f.forEach(function(f){var _=f[0].toLowerCase();if(u.isSignableHeader(_)){var m=f[1];if(null==m||"function"!=typeof m.toString)throw new Error("Header ".concat(_," contains invalid value"));y.push("".concat(_,":").concat(u.canonicalHeaderValues(m.toString())))}}),y.join("\n")}},{key:"canonicalHeaderValues",value:function canonicalHeaderValues(u){return u.replace(/\s+/g," ").replace(/^\s+|\s+$/g,"")}},{key:"signedHeaders",value:function signedHeaders(){var u=this,f=[];return Object.keys(this.request.headers).forEach(function(y){y=y.toLowerCase(),u.isSignableHeader(y)&&f.push(y)}),f.sort().join(";")}},{key:"credentialString",value:function credentialString(u){return this.createScope(u.substr(0,8),this.request.region,this.serviceName)}},{key:"hexEncodedHash",value:function hexEncodedHash(u){return Qe.sha256(u)}},{key:"hexEncodedBodyHash",value:function hexEncodedBodyHash(){return this.request.headers[this.constant.contentSha256Header]?this.request.headers[this.constant.contentSha256Header]:this.request.body?this.hexEncodedHash(Ze(this.request.body)):this.hexEncodedHash("")}},{key:"isSignableHeader",value:function isSignableHeader(u){return 0===u.toLowerCase().indexOf("x-amz-")||$e.indexOf(u)<0}},{key:"iso8601",value:function iso8601(u){return void 0===u&&(u=new Date),u.toISOString().replace(/\.\d{3}Z$/,"Z")}},{key:"getSigningKey",value:function getSigningKey(u,f,y,_){var m=Qe.hmac("".concat(this.constant.kDatePrefix).concat(u.secretAccessKey),f),v=Qe.hmac(m,y),b=Qe.hmac(v,_);return Qe.hmac(b,this.constant.v4Identifier)}},{key:"createScope",value:function createScope(u,f,y){return[u.substr(0,8),f,y,this.constant.v4Identifier].join("/")}}])}(),et=1000001,tt=1000002,rt=1001e3,ot=1002e3,it=1003e3,nt=1003003,st=1005e3,at=4025,ct=4024,lt="The file is not an instance of Blob ",ut="The format of stsToken is incorrect.",pt="An error occurred reading the file";function ApplyUpload_typeof(u){return ApplyUpload_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},ApplyUpload_typeof(u)}function ApplyUpload_toConsumableArray(u){return function ApplyUpload_arrayWithoutHoles(u){if(Array.isArray(u))return ApplyUpload_arrayLikeToArray(u)}(u)||function ApplyUpload_iterableToArray(u){if("undefined"!=typeof Symbol&&null!=u[Symbol.iterator]||null!=u["@@iterator"])return Array.from(u)}(u)||function ApplyUpload_unsupportedIterableToArray(u,f){if(u){if("string"==typeof u)return ApplyUpload_arrayLikeToArray(u,f);var y={}.toString.call(u).slice(8,-1);return"Object"===y&&u.constructor&&(y=u.constructor.name),"Map"===y||"Set"===y?Array.from(u):"Arguments"===y||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(y)?ApplyUpload_arrayLikeToArray(u,f):void 0}}(u)||function ApplyUpload_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 ApplyUpload_arrayLikeToArray(u,f){(null==f||f>u.length)&&(f=u.length);for(var y=0,_=Array(f);y<f;y++)_[y]=u[y];return _}function ownKeys(u,f){var y=Object.keys(u);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(u);f&&(_=_.filter(function(f){return Object.getOwnPropertyDescriptor(u,f).enumerable})),y.push.apply(y,_)}return y}function _objectSpread(u){for(var f=1;f<arguments.length;f++){var y=null!=arguments[f]?arguments[f]:{};f%2?ownKeys(Object(y),!0).forEach(function(f){_defineProperty(u,f,y[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(y)):ownKeys(Object(y)).forEach(function(f){Object.defineProperty(u,f,Object.getOwnPropertyDescriptor(y,f))})}return u}function _defineProperty(u,f,y){return(f=ApplyUpload_toPropertyKey(f))in u?Object.defineProperty(u,f,{value:y,enumerable:!0,configurable:!0,writable:!0}):u[f]=y,u}function ApplyUpload_extends(){return ApplyUpload_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},ApplyUpload_extends.apply(null,arguments)}function ApplyUpload_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,ApplyUpload_toPropertyKey(_.key),_)}}function ApplyUpload_toPropertyKey(u){var f=function ApplyUpload_toPrimitive(u,f){if("object"!=ApplyUpload_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=ApplyUpload_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==ApplyUpload_typeof(f)?f:f+""}function ApplyUpload_callSuper(u,f,y){return f=ApplyUpload_getPrototypeOf(f),function ApplyUpload_possibleConstructorReturn(u,f){if(f&&("object"==ApplyUpload_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function ApplyUpload_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,ApplyUpload_isNativeReflectConstruct()?Reflect.construct(f,y||[],ApplyUpload_getPrototypeOf(u).constructor):f.apply(u,y))}function ApplyUpload_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(ApplyUpload_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function ApplyUpload_getPrototypeOf(u){return ApplyUpload_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},ApplyUpload_getPrototypeOf(u)}function ApplyUpload_setPrototypeOf(u,f){return ApplyUpload_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},ApplyUpload_setPrototypeOf(u,f)}var ft=function(u){function ApplyUpload(u,f){var y;return function ApplyUpload_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,ApplyUpload),(y=ApplyUpload_callSuper(this,ApplyUpload)).options=u,y.config=f,y.uploaderCtx=u.context,y.currFileCtx=u.context.tasks[u.key],y.isImageBatchUpload=!!y.options.isImageBatchUpload,y.serviceName=u.serviceName||je,y}return function ApplyUpload_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&ApplyUpload_setPrototypeOf(u,f)}(ApplyUpload,u),function ApplyUpload_createClass(u,f,y){return f&&ApplyUpload_defineProperties(u.prototype,f),y&&ApplyUpload_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(ApplyUpload,[{key:"start",value:function start(u,f,y){this.failProcess=y,this.successProcess=f,this._st=Date.now();var _=this.uploaderCtx._getCache(this.currFileCtx.crc32Key),m=_?JSON.parse(_):{};m.oid&&m.uploadID&&m.tosDomain?this.resumeFromCache(m):this.startPreUpload()}},{key:"startPreUpload",value:function startPreUpload(){var u=this,f=ze[this.config.region],y="",_={};if(this.serviceName===je){var m=this.config.videoConfig.spaceName;y=this.config.videoHost||Me,_={Action:"ApplyUploadInfo",Version:"2023-01-01",SpaceName:m,FileSize:this.currFileCtx.fileSize,FileType:this.options.type},this.options.fileName&&(_.FileName=this.options.fileName),this.options.storageClass&&(_.StorageClass=this.options.storageClass),this.config.enOID&&(_.EnOID=1)}else if(y=Me,_={Action:"ApplyImageUpload",Version:"2018-08-01",ServiceId:this.options.serviceId||this.config.imageConfig.serviceId},this.currFileCtx.fileSize&&this.currFileCtx.fileSize.length>1&&(_.UploadNum=this.currFileCtx.fileSize.length),this.options.storeKey){var v=this.options.storeKey;"[object Array]"===Object.prototype.toString.call(v)?_.StoreKeys=v:"[object String]"===Object.prototype.toString.call(v)&&(_.StoreKeys=[v])}if(this.config.useFileExtension&&this.currFileCtx.fileName){var b=this.currFileCtx.fileName,w=qe.getFileSuffix(b);w&&(_.FileExtension=w)}this.options.fileExtension&&(_.FileExtension=this.options.fileExtension),this.config.accountId&&(_["X-Account-Id"]=this.config.accountId),_.s=Math.random().toString(36).substr(2);var S=this.currFileCtx.proxyStsToken||this.config.stsToken,k=qe.toQueryString(_),E={method:"GET",url:"".concat(y,"?").concat(k),timeout:3e4,region:f,params:_};if(this.config.useConsoleMode)this.config.apply(_).then(function(f){if(f.errorCode||f.error)u.fail(f);else{var y=f.result,_=f.xhr;y&&(u.serviceName===je&&y.Data||u.serviceName!==je&&y.UploadAddress)?u.success(y,_):u.fail({error:"apply result is invalid",message:"apply upload result信息缺失"})}},function(f){u.fail(f)});else{var C=new Je;C.on("complete",function(f){if(!f.response)return u.fail({error:"request fail: ".concat(f.statusText||f.errText||"UNKNOWN"),xhr:f});try{var y=JSON.parse(f.response);if(y.ResponseMetadata.Error)return u.fail({xhr:f,errorCode:y.ResponseMetadata.Error.CodeN,error:y.ResponseMetadata.Error.Code,message:y.ResponseMetadata.Error.Message});var _=y.Result;u.success(_,f)}catch(y){return u.fail({error:"catch error: ".concat(y.toString()),xhr:f})}}),C.on("error",function(f){var y={error:"request fail: ".concat(f.statusText||f.errText||"UNKNOWN"),xhr:f};if(f.response){var _=JSON.parse(f.response);_.ResponseMetadata&&_.ResponseMetadata.Error&&(y.errorCode=_.ResponseMetadata.Error.CodeN,y.error=_.ResponseMetadata.Error.Code,y.message=_.ResponseMetadata.Error.Message)}u.fail(y)});var x=new Ye(E,this.serviceName,{isVolcengine:!0}),O=S.AccessKeyID,P=S.AccessKeyId,U=S.SecretAccessKey,D=S.SessionToken;x.addAuthorization({accessKeyId:P||O,secretAccessKey:U,sessionToken:D},new Date),C.send(E)}}},{key:"resumeFromCache",value:function resumeFromCache(u){var f=this,y=this.options.key,_=new Je;_.on("complete",function(_){try{var m=JSON.parse(_.response);if(!(0===m.success&&m.payload.partList.length>0))return f.startPreUpload();var v=f.confirmCache(m.payload.partList),b=!!u.hasMerge?5:v.isAllFinished?4:3,w=ApplyUpload_extends(f.currFileCtx,u,{key:y,xhr:_,extra:{message:"prepare upload from disk cache success"},stage:"preUpload",type:"success",percent:0,cacheTask:b,proxyStsToken:f.options.stsToken,currentTask:1,status:1,isBreak:1,crc32Array:v.crc32Array,stageStartTime:f._st,stageEndTime:Date.now(),duration:Date.now()-f._st,totalDuration:Date.now()-f._st+f.currFileCtx.totalDuration});f.successProcess&&f.successProcess(w)}catch(u){return f.startPreUpload()}}),_.on("error",function(u){return u.status>=400?f.startPreUpload():f.fail({error:"request error",xhr:u})});var m=this.config.userId,v=ApplyUpload_extends(qe.arrayToObject(u.UploadHeader),{"x-storage-mode":"gateway"});_.send({method:"GET",url:qe.urlTemplate(this.config.getUploadListUrl,{tosDomain:u.tosDomain,oid:u.oid,uploadId:u.uploadID}),headers:_objectSpread({authorization:u.signature,"x-storage-u":m},v),timeout:3e4})}},{key:"confirmCache",value:function confirmCache(u){var f=this.currFileCtx.crc32Array,y={};u.forEach(function(u){var f=parseInt(u.partNumber)-1;isNaN(f)||void 0!==y[f]||(y[f]={tag:!0,crc32:u.crc32})});var _=!0,m=f.map(function(u,f){return y[f]&&y[f].tag?(u.crc32=y[f].crc32,u.finished=!0,u.loaded=u.end-u.start):_=!1,u});return{isAllFinished:_,crc32Array:m}}},{key:"success",value:function success(u,f){var y,_,m,v;this.serviceName===je?y=null!==(_=null===(m=u.Data)||void 0===m||null===(m=m.CandidateUploadAddresses)||void 0===m||null===(m=m.MainUploadAddresses)||void 0===m?void 0:m[0])&&void 0!==_?_:null===(v=u.Data)||void 0===v?void 0:v.UploadAddress:y=u.UploadAddress;var b=y,w=b.StoreInfos,S=b.UploadHosts,k=b.SessionKey,E=b.UploadHeader,C=void 0===E?[]:E,x=[],O=[];this.isImageBatchUpload&&w.length>1?w.forEach(function(u){x.push(u.Auth),O.push(u.StoreUri)}):(x=w[0].Auth,O=w[0].StoreUri);var P,U=[];if(this.serviceName===je){var D,I=(null===(D=u.Data)||void 0===D?void 0:D.CandidateUploadAddresses)||{},T=I.BackupUploadAddresses,A=void 0===T?[]:T,z=I.FallbackUploadAddresses,M=void 0===z?[]:z,R=A.concat(M);R.length&&R.length>0&&(U=R.map(function(u){var f=u.Cloud,y=u.SessionKey,_=u.StoreInfos,m=u.UploadHeader,v=u.UploadHosts;return{Cloud:f,SessionKey:y,UploadHeader:m,StoreInfo:_[0],UploadHost:v[0]}}))}this.config.uploadHost?(P="".concat(this.config.schema,"://").concat(this.config.uploadHost),U=U?[{SessionKey:k,UploadHeader:C,StoreInfo:w[0],UploadHost:S[0]}].concat(ApplyUpload_toConsumableArray(U)):[{SessionKey:k,UploadHeader:C,StoreInfo:w[0],UploadHost:S[0]}]):P="".concat(this.config.schema,"://").concat(S[0]);var N=ApplyUpload_extends(this.currFileCtx,{signature:x,type:"success",extra:{message:"prepare upload success"},stage:"preUpload",oid:qe.resolveUri(O),tosDomain:P,xhr:f,UploadHeader:C,SessionKey:k,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currFileCtx.totalDuration,fallbackStoreInfoList:U});return this.successProcess(N)}},{key:"fail",value:function fail(u){var f=u.xhr,y=u.errorCode||rt,_="prepare upload error: UNKNOWN";f&&(_=0===f.status?"prepare upload error: NETERROR":u.message||"prepare upload error: ".concat(f.status));var m=ApplyUpload_extends(this.currFileCtx,{extra:{message:_,error:u.error,errorCode:y,requestId:u.requestId},type:"error",stage:"preUpload",xhr:f,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(m)}}])}(m.a);function InitUploadID_typeof(u){return InitUploadID_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},InitUploadID_typeof(u)}function InitUploadID_ownKeys(u,f){var y=Object.keys(u);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(u);f&&(_=_.filter(function(f){return Object.getOwnPropertyDescriptor(u,f).enumerable})),y.push.apply(y,_)}return y}function InitUploadID_objectSpread(u){for(var f=1;f<arguments.length;f++){var y=null!=arguments[f]?arguments[f]:{};f%2?InitUploadID_ownKeys(Object(y),!0).forEach(function(f){InitUploadID_defineProperty(u,f,y[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(y)):InitUploadID_ownKeys(Object(y)).forEach(function(f){Object.defineProperty(u,f,Object.getOwnPropertyDescriptor(y,f))})}return u}function InitUploadID_defineProperty(u,f,y){return(f=InitUploadID_toPropertyKey(f))in u?Object.defineProperty(u,f,{value:y,enumerable:!0,configurable:!0,writable:!0}):u[f]=y,u}function InitUploadID_extends(){return InitUploadID_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},InitUploadID_extends.apply(null,arguments)}function InitUploadID_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,InitUploadID_toPropertyKey(_.key),_)}}function InitUploadID_toPropertyKey(u){var f=function InitUploadID_toPrimitive(u,f){if("object"!=InitUploadID_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=InitUploadID_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==InitUploadID_typeof(f)?f:f+""}function InitUploadID_callSuper(u,f,y){return f=InitUploadID_getPrototypeOf(f),function InitUploadID_possibleConstructorReturn(u,f){if(f&&("object"==InitUploadID_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function InitUploadID_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,InitUploadID_isNativeReflectConstruct()?Reflect.construct(f,y||[],InitUploadID_getPrototypeOf(u).constructor):f.apply(u,y))}function InitUploadID_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(InitUploadID_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function InitUploadID_getPrototypeOf(u){return InitUploadID_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},InitUploadID_getPrototypeOf(u)}function InitUploadID_setPrototypeOf(u,f){return InitUploadID_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},InitUploadID_setPrototypeOf(u,f)}var dt=function(u){function InitUploadID(u,f){var y;return function InitUploadID_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,InitUploadID),(y=InitUploadID_callSuper(this,InitUploadID)).options=u,y.config=f,y.transport=new Je,y.uploaderCtx=u.context,y.currFileCtx=u.context.tasks[u.key],y.eventInit(),y}return function InitUploadID_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&InitUploadID_setPrototypeOf(u,f)}(InitUploadID,u),function InitUploadID_createClass(u,f,y){return f&&InitUploadID_defineProperties(u.prototype,f),y&&InitUploadID_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(InitUploadID,[{key:"initUpload",value:function initUpload(){var u=this.options.context,f=this.options.key,y={oid:u.tasks[f].oid,tosDomain:u.tasks[f].tosDomain},_=qe.urlTemplate(this.config.initUploadFileUrl,y),m=this.config.userId,v=InitUploadID_extends(qe.arrayToObject(this.currFileCtx.UploadHeader),{"x-storage-mode":"gateway"});this.transport.send({method:"post",url:_,headers:InitUploadID_objectSpread({authorization:u.tasks[f].signature,"x-storage-u":m},v),timeout:3e4})}},{key:"start",value:function start(u,f,y){this.successProcess=f,this.failProcess=y,this._st=Date.now(),this.initUpload()}},{key:"eventInit",value:function eventInit(){var u=this,f=this.options.context,y=this.options.key;this.transport.on("complete",function(_){try{var m=JSON.parse(_.response),v=m.payload.uploadID;if(0===m.success&&v){var b=InitUploadID_extends(f.tasks[y],{uploadID:v,percent:0,type:"success",extra:{message:"init upload id success"},stage:"initUploadID",xhr:_,stageStartTime:u._st,stageEndTime:Date.now(),duration:Date.now()-u._st,totalDuration:Date.now()-u._st+u.currFileCtx.totalDuration});u.successProcess(b)}else u.fail({error:"fail! res.success: ".concat(m.success,", uploadId:").concat(v),xhr:_})}catch(f){u.fail({error:"catch error: ".concat(JSON.stringify(f)),xhr:_})}}),this.transport.on("error",function(f){u.fail({error:"request fail: ".concat(f.statusText||f.errText||"UNKNOWN"),xhr:f})})}},{key:"fail",value:function fail(u){var f=this.options.context,y=this.options.key,_=InitUploadID_extends(f.tasks[y],{extra:{message:"init upload id error, ".concat(u.error),errorCode:ot},type:"error",stage:"initUploadID",xhr:u.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(_)}}])}(m.a);function Uploader_typeof(u){return Uploader_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},Uploader_typeof(u)}function Uploader_ownKeys(u,f){var y=Object.keys(u);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(u);f&&(_=_.filter(function(f){return Object.getOwnPropertyDescriptor(u,f).enumerable})),y.push.apply(y,_)}return y}function Uploader_objectSpread(u){for(var f=1;f<arguments.length;f++){var y=null!=arguments[f]?arguments[f]:{};f%2?Uploader_ownKeys(Object(y),!0).forEach(function(f){Uploader_defineProperty(u,f,y[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(y)):Uploader_ownKeys(Object(y)).forEach(function(f){Object.defineProperty(u,f,Object.getOwnPropertyDescriptor(y,f))})}return u}function Uploader_defineProperty(u,f,y){return(f=Uploader_toPropertyKey(f))in u?Object.defineProperty(u,f,{value:y,enumerable:!0,configurable:!0,writable:!0}):u[f]=y,u}function Uploader_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,Uploader_toPropertyKey(_.key),_)}}function Uploader_toPropertyKey(u){var f=function Uploader_toPrimitive(u,f){if("object"!=Uploader_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=Uploader_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==Uploader_typeof(f)?f:f+""}function Uploader_callSuper(u,f,y){return f=Uploader_getPrototypeOf(f),function Uploader_possibleConstructorReturn(u,f){if(f&&("object"==Uploader_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function Uploader_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,Uploader_isNativeReflectConstruct()?Reflect.construct(f,y||[],Uploader_getPrototypeOf(u).constructor):f.apply(u,y))}function Uploader_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(Uploader_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function Uploader_getPrototypeOf(u){return Uploader_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},Uploader_getPrototypeOf(u)}function Uploader_setPrototypeOf(u,f){return Uploader_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},Uploader_setPrototypeOf(u,f)}var ht=function(u){function Uploader(u){var f,y=u.sliceItem,_=u.crc32,m=u.url,v=u.signature,b=u.uploadHeader,w=u.userId,S=u.retryTime,k=void 0===S?0:S,E=u.method,C=void 0===E?"put":E;return function Uploader_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,Uploader),(f=Uploader_callSuper(this,Uploader)).fileSlice=y,f.crc32=_,f.uploadUrl=m,f.uploadHeader=b,f.signature=v,f.userId=w,f.retryTime=k,f.method=C,f.retryCount=0,f.ready=!1,f.cancel=!1,f.transport=new Je,f.eventInit(),f}return function Uploader_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&Uploader_setPrototypeOf(u,f)}(Uploader,u),function Uploader_createClass(u,f,y){return f&&Uploader_defineProperties(u.prototype,f),y&&Uploader_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(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 u=this;this.transport.on("complete",function(f){u.success(f)}),this.transport.on("error",function(f){u.fail(f)}),this.transport.on("progress",function(f){u.process(f)})}},{key:"success",value:function success(u){this.ready=!0;var f=Date.now()-this._st,y=this.fileSlice.size||this.fileSlice.byteLength,_=y/f;this.emit("complete",{crc32:this.crc32,size:y,speed:_,xhr:u,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st})}},{key:"fail",value:function fail(u){if(!this.cancel)if(u&&401===u.status)this.emit("error",{message:"slice upload failed: UNAUTHORIZED",crc32:this.crc32,size:this.fileSlice.size||this.fileSlice.byteLength,xhr:u,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st});else{var f="slice upload failed: UNKNOWN";u&&(f=u.status?"slice upload failed: ".concat(u.status):"slice upload failed: NETERROR"),this.emit("error",{message:f,crc32:this.crc32,size:this.fileSlice.size||this.fileSlice.byteLength,xhr:u,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st})}}},{key:"process",value:function process(u){this.cancel||this.emit("progress",{crc32:this.crc32,loaded:u.loaded||0,total:u.total||0})}},{key:"abort",value:function abort(){this.transport&&(this.cancel=!0,this.transport.abort())}},{key:"destroy",value:function destroy(){this.transport=null}}])}(m.a),yt=y(4),gt=y.n(yt);function Upload_typeof(u){return Upload_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},Upload_typeof(u)}function Upload_extends(){return Upload_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},Upload_extends.apply(null,arguments)}function Upload_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,Upload_toPropertyKey(_.key),_)}}function Upload_toPropertyKey(u){var f=function Upload_toPrimitive(u,f){if("object"!=Upload_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=Upload_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==Upload_typeof(f)?f:f+""}function Upload_callSuper(u,f,y){return f=Upload_getPrototypeOf(f),function Upload_possibleConstructorReturn(u,f){if(f&&("object"==Upload_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function Upload_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,Upload_isNativeReflectConstruct()?Reflect.construct(f,y||[],Upload_getPrototypeOf(u).constructor):f.apply(u,y))}function Upload_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(Upload_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function Upload_getPrototypeOf(u){return Upload_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},Upload_getPrototypeOf(u)}function Upload_setPrototypeOf(u,f){return Upload_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},Upload_setPrototypeOf(u,f)}var _t=function(u){function Upload(u){var f,y=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function Upload_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,Upload),(f=Upload_callSuper(this,Upload)).file=u.file,f.context=u.context,f.key=u.key,f.config=y,f.finishArr=[],f.errorLength=0,f.finishSize=0,f.retryUploadTime=Number(y.retryUploadTime)||5,f.retryProcess=y.retryProcess,f.retryProcessTime=Number(y.retryProcessTime)||5,f.maxProcessPause=Number(y.maxProcessPause)||20,f.uploadSliceCount=Number(y.uploadSliceCount)||5,f.realtimeSpeedInterval=Number(y.realtimeSpeedInterval)||5,f.processRetry=0,f.lastFinishSize=-1,f.lastProcessPercent=-1,f.lastIntervalSize=-1,f.lastCalculateSpeedTime=-1,f.lastCalculateSpeedSize=0,f.writenStorage=!1,f.uploadHandlers={},f}return function Upload_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&Upload_setPrototypeOf(u,f)}(Upload,u),function Upload_createClass(u,f,y){return f&&Upload_defineProperties(u.prototype,f),y&&Upload_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(Upload,[{key:"start",value:function start(u,f,y){this.failProcess=y,this.successProcess=f,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(u,f){return u+(f.finished?0:f.end-f.start)},0),this._st=Date.now(),this._lastSaveTime=Date.now(),this.lastCalculateSpeedTime=this._st,this.initWorker(),this.threadUpload()}},{key:"initWorker",value:function initWorker(){var u=this;if(!this.worker){var f=this.crc32Array;this.worker=new gt.a,this.worker.onmessage=function(y){var _=y.data[0],m=y.data[2],v=f[m];v.crc32=y.data[1],u.upload(v,_,m)}}}},{key:"read",value:function read(u,f){var y=this,_=this.file,m=_.slice||_.webkitSlice||_.mozSlice,v=new FileReader;v.onload=function(u){y.worker.postMessage([u.target.result,f],[u.target.result])},v.onerror=function(){y.stop(),y.fail({extra:{message:pt,errorCode:nt}})},v.readAsArrayBuffer(m.call(_,u.start,u.end))}},{key:"threadUpload",value:function threadUpload(){if(this.uploading.length<this.uploadSliceCount){var u=this.lastIndex,f=this.crc32Array[u];if(f){if(f.finished){if(-1===this.finishArr.indexOf(f.start)&&(this.finishArr.push(f.start),this.finishArr.length>=this.crc32Array.length))return this.stop(),void this.success()}else f.loaded=0,this.uploading.push(u),this.read(f,u);this.lastIndex++,this.threadUpload()}}}},{key:"stop",value:function stop(){var u=this;Object.keys(this.uploadHandlers).forEach(function(f){u.uploadHandlers[f].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(u,f,y){var _=this,m=u.crc32,v={number:y+1,uploadId:this.currentCtx.uploadID,oid:this.currentCtx.oid,tosDomain:this.currentCtx.tosDomain},b=qe.urlTemplate(this.config.uploadChunkedUrl,v),w=this.config.userId,S=Upload_extends(qe.arrayToObject(this.currentCtx.UploadHeader),{"x-storage-mode":"gateway"}),k=new ht({sliceItem:f,crc32:m,url:b,signature:this.currentCtx.signature,uploadHeader:S,userId:w,retryTime:this.retryUploadTime,enableDebugLog:this.config.enableDebugLog,uploaderCtx:this.context,key:this.key});k.on("complete",function(f){_.currentCtx.status===Ie&&(f.start=u.start,f.index=y,_.fileSliceSuccess(f))}),k.on("error",function(f){1===_.currentCtx.status&&(f.start=u.start,f.index=y,_.fail(f))}),k.on("progress",function(f){1===_.currentCtx.status&&(f.start=u.start,f.index=y,_.process(f))}),k.upload(),this.uploadHandlers[y]=k}},{key:"success",value:function success(u){this.finishArr=[];var f=Date.now()-this._st,y=this._uploadSize/f,_=Upload_extends(this.currentCtx,{type:"success",stage:"process",percent:100,extra:{message:"upload all success"},speed:y,xhr:u,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(_)}},{key:"fail",value:function fail(u){var f=this.currentCtx.totalDuration,y=Date.now()-this._st,_=u.crc32?{message:u.message,data:u.crc32,size:u.size}:u.extra;_.errorCode=_.errorCode||it;var m=Upload_extends(this.currentCtx,{extra:_,type:"error",stage:"process",req:{},res:{},totalDuration:y+f});if(u.xhr){var v=u.xhr;m.req={url:u.xhr.currentUrl},m.res={status:v.status,body:v.responseText,header:v.getAllResponseHeaders()},delete u.xhr}if(void 0!==u.statusCode&&Upload_extends(this.currentCtx,{statusCode:u.statusCode}),!this.errorLength){var b=u.index;this.context.logger.send(Upload_extends({},m,{slice_index:b})),this.stop(),this.context._broadcast("error",m),this.currentCtx.isBreak?this.context._cancel(this.key):this.context._pause(this.key),this.errorLength++}}},{key:"fileSliceSuccess",value:function fileSliceSuccess(u){var f=u.index,y=Date.now();-1===this.finishArr.indexOf(u.start)&&this.finishArr.push(u.start),this.crc32Array[f].finished=!0,this.crc32Array[f].speed=u.speed;var _={message:"slice upload success"};if(u.xhr){var m=u.xhr;_.currentUrl=m.currentUrl||"",Upload_extends(this.currentCtx,{req:{url:m.currentUrl,param:m.params},res:{status:m.status,body:m.responseText,header:m.getAllResponseHeaders()}}),delete u.xhr}if(this.context.logger.send(Upload_extends(this.currentCtx,{stage:"process",type:"success",slice_index:f,extra:_,totalDuration:y-this._lastSaveTime+this.currentCtx.totalDuration})),this._lastSaveTime=y,!this.writenStorage&&this.currentCtx.enableDiskBreakPoint&&(this.writenStorage=!0,this.context._saveTask(this.key)),this.finishArr.length>=this.crc32Array.length)return this.stop(),void this.success(u.xhr);this.uploading.splice(this.uploading.indexOf(f),1),this.uploadHandlers[f]&&delete this.uploadHandlers[f],this.threadUpload()}},{key:"getFinishSize",value:function getFinishSize(u,f){var y=f.crc32,_=0;return u.forEach(function(u){u.crc32===y?(u.loaded=f.loaded,_+=f.loaded):(u.loaded||(u.loaded=0),_+=u.loaded)}),_}},{key:"process",value:function process(u){var f=this.currentCtx.realtimeSpeed||0,y=this.currentCtx.fileSize;if(this.finishSize=this.getFinishSize(this.crc32Array,u),this.finishSize>this.lastFinishSize){var _=new Date;if(_.getTime()-this.lastCalculateSpeedTime>1e3*this.realtimeSpeedInterval){var m=_.getTime()-this.lastCalculateSpeedTime,v=this.finishSize-this.lastCalculateSpeedSize;f=Math.floor(v/m),this.lastCalculateSpeedTime=_.getTime(),this.lastCalculateSpeedSize=this.finishSize}this.lastFinishSize=this.finishSize}var b=Math.floor(this.finishSize/y*100*100)/100||0,w=Upload_extends(this.currentCtx,{stage:"process",percent:b,realtimeSpeed:f});b>this.lastProcessPercent&&100!==b&&(this.lastProcessPercent=b,this.context._broadcast("progress",w))}}])}(m.a);function FileMerge_typeof(u){return FileMerge_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},FileMerge_typeof(u)}function FileMerge_ownKeys(u,f){var y=Object.keys(u);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(u);f&&(_=_.filter(function(f){return Object.getOwnPropertyDescriptor(u,f).enumerable})),y.push.apply(y,_)}return y}function FileMerge_objectSpread(u){for(var f=1;f<arguments.length;f++){var y=null!=arguments[f]?arguments[f]:{};f%2?FileMerge_ownKeys(Object(y),!0).forEach(function(f){FileMerge_defineProperty(u,f,y[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(y)):FileMerge_ownKeys(Object(y)).forEach(function(f){Object.defineProperty(u,f,Object.getOwnPropertyDescriptor(y,f))})}return u}function FileMerge_defineProperty(u,f,y){return(f=FileMerge_toPropertyKey(f))in u?Object.defineProperty(u,f,{value:y,enumerable:!0,configurable:!0,writable:!0}):u[f]=y,u}function FileMerge_extends(){return FileMerge_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},FileMerge_extends.apply(null,arguments)}function FileMerge_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,FileMerge_toPropertyKey(_.key),_)}}function FileMerge_toPropertyKey(u){var f=function FileMerge_toPrimitive(u,f){if("object"!=FileMerge_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=FileMerge_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==FileMerge_typeof(f)?f:f+""}function FileMerge_callSuper(u,f,y){return f=FileMerge_getPrototypeOf(f),function FileMerge_possibleConstructorReturn(u,f){if(f&&("object"==FileMerge_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function FileMerge_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,FileMerge_isNativeReflectConstruct()?Reflect.construct(f,y||[],FileMerge_getPrototypeOf(u).constructor):f.apply(u,y))}function FileMerge_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(FileMerge_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function FileMerge_getPrototypeOf(u){return FileMerge_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},FileMerge_getPrototypeOf(u)}function FileMerge_setPrototypeOf(u,f){return FileMerge_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},FileMerge_setPrototypeOf(u,f)}var mt=function(u){function FileMerge(u,f){var y;return function FileMerge_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,FileMerge),(y=FileMerge_callSuper(this,FileMerge)).options=u,y.config=f,y.transport=new Je,y.eventInit(),y.errorCount=0,y.uploaderCtx=u.context,y.currFileCtx=u.context.tasks[u.key],y}return function FileMerge_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&FileMerge_setPrototypeOf(u,f)}(FileMerge,u),function FileMerge_createClass(u,f,y){return f&&FileMerge_defineProperties(u.prototype,f),y&&FileMerge_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(FileMerge,[{key:"mergeFile",value:function mergeFile(){for(var u={oid:this.currFileCtx.oid,uploadId:this.currFileCtx.uploadID,tosDomain:this.currFileCtx.tosDomain},f=this.currFileCtx.crc32Array,y="",_=0;_<f.length;_++)y=y?"".concat(y,",").concat(_+1,":").concat(f[_].crc32):"".concat(_+1,":").concat(f[_].crc32);var m=qe.urlTemplate(this.config.uploadMergeUrl,u),v=this.config.userId,b=FileMerge_extends(qe.arrayToObject(this.currFileCtx.UploadHeader),{"x-storage-mode":"gateway"});this.transport.send({method:"post",url:m,headers:FileMerge_objectSpread({authorization:this.currFileCtx.signature,"x-storage-u":v},b),custom:y})}},{key:"start",value:function start(u,f,y){this.successProcess=f,this.failProcess=y,this._st=Date.now(),this.mergeFile()}},{key:"eventInit",value:function eventInit(){var u=this,f=this.options.stage;this.transport.on("complete",function(y){try{var _=JSON.parse(y.response);0===_.success&&_.payload.key?(FileMerge_extends(u.currFileCtx,{stage:f,type:"success",hasMerge:!0,extra:{message:"merge file success"},xhr:y,stageStartTime:u._st,stageEndTime:Date.now(),duration:Date.now()-u._st,totalDuration:Date.now()-u._st+u.currFileCtx.totalDuration}),u.successProcess(u.currFileCtx)):u.fail({error:"fail! result.success:".concat(_.success),xhr:y})}catch(f){u.fail({error:"response parse error: ".concat(JSON.stringify(f)),xhr:y})}}),this.transport.on("error",function(f){var y,_;try{if(f.responseText||f.response){var m,v,b=JSON.parse(f.responseText||f.response);if(b.error)y=null===(m=b.error)||void 0===m?void 0:m.error_code,_=null===(v=b.error)||void 0===v?void 0:v.message}}catch(u){}u.fail({error:"request fail: ".concat(f.statusText||f.errText||_),errorCode:y,message:_,xhr:f})})}},{key:"getProcessIndex",value:function getProcessIndex(u){var f=0;return u.forEach(function(u,y){"process"===u.stage&&(f=y)}),f}},{key:"fail",value:function fail(u){u.errorCode!==at&&u.errorCode!==ct||debugLog(this.config.enableDebugLog,"log","Merge阶段错误码 ".concat(u.errorCode,",跳过重试,直接结束:"),{stage:"MERGE",errorCode:u.errorCode,message:u.message,error:u.error,requestId:u.requestId});var f=FileMerge_extends(this.currFileCtx,{extra:{error:u.error,message:"merge file error, ".concat(u.message),errorCode:u.errorCode},type:"error",stage:this.options.stage,xhr:u.xhr,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currFileCtx.totalDuration});this.failProcess(f)}}])}(m.a);function DirectUpload_typeof(u){return DirectUpload_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},DirectUpload_typeof(u)}function DirectUpload_extends(){return DirectUpload_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},DirectUpload_extends.apply(null,arguments)}function DirectUpload_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,DirectUpload_toPropertyKey(_.key),_)}}function DirectUpload_toPropertyKey(u){var f=function DirectUpload_toPrimitive(u,f){if("object"!=DirectUpload_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=DirectUpload_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==DirectUpload_typeof(f)?f:f+""}function DirectUpload_callSuper(u,f,y){return f=DirectUpload_getPrototypeOf(f),function DirectUpload_possibleConstructorReturn(u,f){if(f&&("object"==DirectUpload_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function DirectUpload_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,DirectUpload_isNativeReflectConstruct()?Reflect.construct(f,y||[],DirectUpload_getPrototypeOf(u).constructor):f.apply(u,y))}function DirectUpload_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(DirectUpload_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function DirectUpload_getPrototypeOf(u){return DirectUpload_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},DirectUpload_getPrototypeOf(u)}function DirectUpload_setPrototypeOf(u,f){return DirectUpload_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},DirectUpload_setPrototypeOf(u,f)}var vt=function(u){function DirectUpload(u){var f,y=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function DirectUpload_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,DirectUpload),(f=DirectUpload_callSuper(this,DirectUpload)).options=u,f.file=u.file,f.context=u.context,f.key=u.key,f.config=y,f.finishArr=[],f.errorLength=0,f.finishSize=0,f.retryUploadTime=Number(y.retryUploadTime)||5,f.processRetry=0,f.lastFinishSize=-1,f.lastProcessPercent=-1,f.lastIntervalSize=-1,f}return function DirectUpload_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&DirectUpload_setPrototypeOf(u,f)}(DirectUpload,u),function DirectUpload_createClass(u,f,y){return f&&DirectUpload_defineProperties(u.prototype,f),y&&DirectUpload_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(DirectUpload,[{key:"start",value:function start(u,f,y){this.failProcess=y,this.successProcess=f,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 u=this,f=this.crc32Array.length,y=0,_=0,m=0;m<f;m++){var v=this.crc32Array[m],b=v.buffer,w=v.crc32,S=this.currentCtx.oid,k=this.currentCtx.signature,E={oid:"[object Array]"===Object.prototype.toString.call(S)?S[m]:S,tosDomain:this.currentCtx.tosDomain},C=qe.urlTemplate(this.config.directUploadFileUrl,E),x=this.config.userId,O=qe.arrayToObject(this.currentCtx.UploadHeader),P=new ht({sliceItem:b,crc32:w,url:C,signature:"[object Array]"===Object.prototype.toString.call(k)?k[m]:k,uploadHeader:O,userId:x,retryTime:this.retryUploadTime,method:"put",enableDebugLog:this.config.enableDebugLog,uploaderCtx:this.context,key:this.key});P.on("complete",function(m){y++,_+y===f&&u.success(m.xhr)}),P.on("error",function(y){++_===f&&u.fail(y.xhr)}),P.on("progress",function(f){u.process(f)}),this.uploadHandlers["".concat(w,"_").concat(Math.round(1e3*Math.random()))]=P,P.upload()}}},{key:"success",value:function success(u){this.finishArr=[];var f=Date.now()-this._st,y=this._uploadSize/f,_=DirectUpload_extends(this.currentCtx,{type:"success",stage:"process",percent:100,extra:{message:"direct upload success"},speed:y,xhr:u,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currentCtx.totalDuration});this.successProcess(_)}},{key:"fail",value:function fail(u){var f=DirectUpload_extends(this.currentCtx,{extra:{message:"direct upload error",errorCode:it},type:"error",stage:"process",xhr:u,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currentCtx.totalDuration});this.failProcess(f)}},{key:"process",value:function process(u){var f=this.currentCtx.fileSize;this.finishSize=u.loaded,this.finishSize>this.lastFinishSize&&(this.lastFinishSize=this.finishSize);var y=Math.floor(this.finishSize/f*100*100)/100||0,_=DirectUpload_extends(this.currentCtx,{stage:"process",percent:y});y>this.lastProcessPercent&&100!==y&&(this.lastProcessPercent=y,this.context._broadcast("progress",_))}},{key:"stop",value:function stop(){Object.values(this.uploadHandlers).forEach(function(u){u.abort()})}}])}(m.a);function CommitUpload_typeof(u){return CommitUpload_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},CommitUpload_typeof(u)}function CommitUpload_extends(){return CommitUpload_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},CommitUpload_extends.apply(null,arguments)}function CommitUpload_ownKeys(u,f){var y=Object.keys(u);if(Object.getOwnPropertySymbols){var _=Object.getOwnPropertySymbols(u);f&&(_=_.filter(function(f){return Object.getOwnPropertyDescriptor(u,f).enumerable})),y.push.apply(y,_)}return y}function CommitUpload_objectSpread(u){for(var f=1;f<arguments.length;f++){var y=null!=arguments[f]?arguments[f]:{};f%2?CommitUpload_ownKeys(Object(y),!0).forEach(function(f){CommitUpload_defineProperty(u,f,y[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(y)):CommitUpload_ownKeys(Object(y)).forEach(function(f){Object.defineProperty(u,f,Object.getOwnPropertyDescriptor(y,f))})}return u}function CommitUpload_defineProperty(u,f,y){return(f=CommitUpload_toPropertyKey(f))in u?Object.defineProperty(u,f,{value:y,enumerable:!0,configurable:!0,writable:!0}):u[f]=y,u}function CommitUpload_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,CommitUpload_toPropertyKey(_.key),_)}}function CommitUpload_toPropertyKey(u){var f=function CommitUpload_toPrimitive(u,f){if("object"!=CommitUpload_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=CommitUpload_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==CommitUpload_typeof(f)?f:f+""}function CommitUpload_callSuper(u,f,y){return f=CommitUpload_getPrototypeOf(f),function CommitUpload_possibleConstructorReturn(u,f){if(f&&("object"==CommitUpload_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function CommitUpload_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,CommitUpload_isNativeReflectConstruct()?Reflect.construct(f,y||[],CommitUpload_getPrototypeOf(u).constructor):f.apply(u,y))}function CommitUpload_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(CommitUpload_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function CommitUpload_getPrototypeOf(u){return CommitUpload_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},CommitUpload_getPrototypeOf(u)}function CommitUpload_setPrototypeOf(u,f){return CommitUpload_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},CommitUpload_setPrototypeOf(u,f)}var bt=function(u){function CommitUpload(u,f){var y;return function CommitUpload_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,CommitUpload),(y=CommitUpload_callSuper(this,CommitUpload)).options=u,y.config=f,y.uploaderCtx=u.context,y.currFileCtx=u.context.tasks[u.key],y.isImageBatchUpload=!!y.options.isImageBatchUpload,y.serviceName=u.serviceName||je,y.transport=new Je,y.eventInit(),y}return function CommitUpload_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&CommitUpload_setPrototypeOf(u,f)}(CommitUpload,u),function CommitUpload_createClass(u,f,y){return f&&CommitUpload_defineProperties(u.prototype,f),y&&CommitUpload_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(CommitUpload,[{key:"commitUpload",value:function commitUpload(){var u,f=this,y=this.options.key,_=this.options.context.tasks[y],m=ze[this.config.region],v="",b={};if(this.serviceName===je){var w=this.config.videoConfig.spaceName;v=this.config.videoHost||Me,b={Action:"CommitUploadInfo",Version:"2023-01-01"},u={SpaceName:w,SessionKey:_.SessionKey};var S=this.options.processAction;S&&Array.isArray(S)&&S.length>0&&(u.Functions=this.options.processAction),this.options.callbackArgs&&(u.CallbackArgs=this.options.callbackArgs)}else b={Action:"CommitImageUpload",Version:"2018-08-01",SessionKey:_.SessionKey},this.options.serviceId||this.config.imageConfig&&this.config.imageConfig.serviceId?b.ServiceId=this.options.serviceId||this.config.imageConfig.serviceId:b.SpaceName=this.config.videoConfig&&this.config.videoConfig.spaceName;this.config.accountId&&(b["X-Account-Id"]=this.config.accountId);var k=qe.toQueryString(b),E=this.currFileCtx.proxyStsToken||this.config.stsToken,C={method:"POST",url:"".concat(v,"?").concat(k),timeout:3e4,region:m,params:b,headers:{}};if(this.config.useConsoleMode)this.config.commit(b,u).then(function(u){if(u.errorCode||u.error)f.fail(u);else{var y=u.result,_=u.xhr;y&&(f.options.type===Ue&&f.config.imageConfig&&f.config.imageConfig.serviceId?y.Results:y.Data)?f.success(y,_):f.fail({error:"commit result is invalid",message:"commit upload result信息缺失"})}},function(u){f.fail(u)});else{if(this.serviceName===je){var x=Object.keys(u).map(function(f){return"[object Array]"===Object.prototype.toString.call(u[f])||"[object Object]"===Object.prototype.toString.call(u[f])?"".concat(f,"=").concat(encodeURIComponent(JSON.stringify(u[f]))):"SessionKey"===f?"".concat(f,"=").concat(encodeURIComponent(u[f])):"".concat(f,"=").concat(u[f])}).join("&");C.headers["Content-Type"]="application/x-www-form-urlencoded",C.body=x,C.custom=C.body}else C.custom="none",C.headers["Content-Type"]="application/json";var O=new Ye(C,this.serviceName,{isVolcengine:!0}),P=E.AccessKeyID,U=E.AccessKeyId,D=E.SecretAccessKey,I=E.SessionToken;O.addAuthorization({accessKeyId:U||P,secretAccessKey:D,sessionToken:I},new Date),this.transport.send(C)}}},{key:"start",value:function start(u,f,y){this.successProcess=f,this.failProcess=y,this._st=Date.now();try{this.commitUpload()}catch(u){this.fail({error:"catch error: ".concat(u.toString())})}}},{key:"eventInit",value:function eventInit(){var u=this;this.transport.on("complete",function(f){try{var y=JSON.parse(f.response);if(y.ResponseMetadata.Error)u.fail({xhr:f,errorCode:y.ResponseMetadata.Error.CodeN,error:y.ResponseMetadata.Error.Code,message:y.ResponseMetadata.Error.Message});else{var _=y.Result;u.success(_,f)}}catch(y){u.fail({error:"catch error: ".concat(y.toString()),xhr:f})}}),this.transport.on("error",function(f){var y={error:"request fail: ".concat(f.statusText||f.errText||"UNKNOWN"),xhr:f};if(f.response)try{var _=JSON.parse(f.response);_.ResponseMetadata&&_.ResponseMetadata.Error&&(y.errorCode=_.ResponseMetadata.Error.CodeN,y.error=_.ResponseMetadata.Error.Code,y.message=_.ResponseMetadata.Error.Message)}catch(u){}u.fail(y)})}},{key:"success",value:function success(u,f){var y={};if(this.options.type===Ue&&this.config.imageConfig&&this.config.imageConfig.serviceId)if(this.isImageBatchUpload){var _=u.Results,m=u.PluginResult||[];_.forEach(function(u,f){_[f]=CommitUpload_objectSpread(CommitUpload_objectSpread({},_[f]),m[f])}),y=_}else CommitUpload_extends(y=u.Results[0],u.PluginResult&&u.PluginResult[0]);else y=u.Data;var v=CommitUpload_extends(this.currFileCtx,{stage:"complete",type:"success",percent:100,extra:{message:"upload successful"},uploadResult:y,xhr:f,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currFileCtx.totalDuration});this.successProcess&&this.successProcess(v)}},{key:"fail",value:function fail(u){var f=this.options.context,y=this.options.key,_=u.xhr,m=u.errorCode||st,v="commit upload error: UNKNOWN";_&&(v=0===_.status?"commit upload error: NETERROR":u.message||"commit upload error: ".concat(_.status));var b=CommitUpload_extends(f.tasks[y],{extra:{message:v,error:u.error,errorCode:m,requestId:u.requestId},type:"error",stage:"complete",xhr:_,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currFileCtx.totalDuration});this.failProcess(b)}}])}(m.a);function Queue_typeof(u){return Queue_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},Queue_typeof(u)}function Queue_extends(){return Queue_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},Queue_extends.apply(null,arguments)}function Queue_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,Queue_toPropertyKey(_.key),_)}}function Queue_toPropertyKey(u){var f=function Queue_toPrimitive(u,f){if("object"!=Queue_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=Queue_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==Queue_typeof(f)?f:f+""}function Queue_callSuper(u,f,y){return f=Queue_getPrototypeOf(f),function Queue_possibleConstructorReturn(u,f){if(f&&("object"==Queue_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function Queue_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,Queue_isNativeReflectConstruct()?Reflect.construct(f,y||[],Queue_getPrototypeOf(u).constructor):f.apply(u,y))}function Queue_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(Queue_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function Queue_getPrototypeOf(u){return Queue_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},Queue_getPrototypeOf(u)}function Queue_setPrototypeOf(u,f){return Queue_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},Queue_setPrototypeOf(u,f)}var wt=function(u){function Queue(u){var f,y=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},_=arguments.length>2?arguments[2]:void 0,m=arguments.length>3?arguments[3]:void 0;return function Queue_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,Queue),(f=Queue_callSuper(this,Queue,[u])).tasks=u,f.config=y,f.key=m,f.uploaderCtx=_,f.current=0,f.length=f.tasks.length,f.taskError={},f.uploadList=[],f.retryTaskTime=y.retryTaskTime||3,f}return function Queue_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&Queue_setPrototypeOf(u,f)}(Queue,u),function Queue_createClass(u,f,y){return f&&Queue_defineProperties(u.prototype,f),y&&Queue_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(Queue,[{key:"start",value:function start(){var u=this.tasks.shift();u&&(this.current=u.index,this.execTask(u))}},{key:"execTask",value:function execTask(u){var f=this,y=u.key,_=this.uploaderCtx,m=_.tasks[y],v=m.cacheTask,b=_.taskList[y].length;v&&u.index>0&&u.index<v?this.start():(m.currentTask=u.index,1===m.status&&u&&u.func.call(u.context,u.arg,function(v){var w=m[u.index+1];w&&0!==u.index?_._saveTask(y,{currentTask:w.index,stage:w.stage}):u.index===b-1&&_._removeTaskCache(y),f.success(v),f.tasks.length>0?f.start():_._queueSuccess(y)},function(v){var b,w,S,k,E,C,x;if(debugLog(f.config.enableDebugLog,"log","错误码 ".concat(null===(b=v.extra)||void 0===b?void 0:b.errorCode,", (阶段: ").concat(v.stage||u.stage,"):"),{stage:v.stage||u.stage,errorCode:null===(w=v.extra)||void 0===w?void 0:w.errorCode,message:null===(S=v.extra)||void 0===S?void 0:S.message,error:null===(k=v.extra)||void 0===k?void 0:k.error}),v.xhr&&v.xhr.status>=400)f.fail(v);else{var O,P,U,D;if((null===(E=v.extra)||void 0===E?void 0:E.errorCode)===at||(null===(C=v.extra)||void 0===C?void 0:C.errorCode)===ct)return debugLog(f.config.enableDebugLog,"warn","错误码 ".concat(null===(O=v.extra)||void 0===O?void 0:O.errorCode,",跳过重试和容灾 (阶段: ").concat(v.stage||u.stage,"):"),{stage:v.stage||u.stage,errorCode:null===(P=v.extra)||void 0===P?void 0:P.errorCode,message:null===(U=v.extra)||void 0===U?void 0:U.message,error:null===(D=v.extra)||void 0===D?void 0:D.error}),_._removeTaskCache(y),v.key=y,void f.fail(v);if(f.taskError[y])if(f.taskError[y]<f.retryTaskTime)f.taskError[y]++,f.execTask(u),debugLog(f.config.enableDebugLog,"log","重试次数 ".concat(f.taskError[y],",重试任务 (阶段: ").concat(u.stage,"):"),{stage:u.stage,retryCount:f.taskError[y]});else if((null==m||null===(x=m.fallbackStoreInfoList)||void 0===x?void 0:x.length)>0){debugLog(f.config.enableDebugLog,"log","使用备用节点重试 (阶段: ".concat(u.stage,"):"),{stage:u.stage,retryCount:f.taskError[y]});var I=m.fallbackStoreInfoList.shift();m.tosDomain="".concat(f.config.schema,"://").concat(I.UploadHost),m.oid=I.StoreInfo.StoreUri,m.signature=I.StoreInfo.Auth,m.SessionKey=I.SessionKey,m.UploadID=I.StoreInfo.UploadID,m.useFallback=!0,f.taskError[y]=0,f.execTask(u)}else v.key=y,f.fail(v);else f.taskError[y]=1,f.execTask(u),debugLog(f.config.enableDebugLog,"log","重试次数 ".concat(f.taskError[y],",重试任务 (阶段: ").concat(u.stage,"):"),{stage:u.stage,retryCount:f.taskError[y]})}}))}},{key:"addTask",value:function addTask(u){this.tasks.push(u)}},{key:"success",value:function success(u){if(u.xhr){var f=u.xhr;u.req={url:f.currentUrl,param:f.params},u.res={status:f.status,header:f.getAllResponseHeaders(),body:f.responseText},delete u.xhr}Queue_extends(u,{type:"success"});try{this.uploaderCtx._broadcast(u.stage,u)}catch(u){}this.uploaderCtx.logger.send(u)}},{key:"fail",value:function fail(u){var f,y,_=this.uploaderCtx;if(u.xhr){var m=u.xhr;u.req={url:m.currentUrl,param:m.params},u.res={status:m.status,header:m.getAllResponseHeaders(),body:m.responseText},u.extra&&(u.extra.req=u.req,u.extra.res=u.res),delete u.xhr}Queue_extends(u,{type:"error"});try{_._broadcast("error",u)}catch(u){}_.logger.send(u),1!==u.currentTask&&((null===(f=u.extra)||void 0===f?void 0:f.errorCode)!==at&&(null===(y=u.extra)||void 0===y?void 0:y.errorCode)!==ct?_.tasks[u.key].isBreak?_._cancel(u.key):_._pause(u.key):_._cancel(u.key))}},{key:"cancel",value:function cancel(u){var f=this.key,y=this.uploaderCtx.tasks[f].currentTask,_=this.uploaderCtx.tasks[f].isDirect?this.uploaderCtx.taskList[f][y-1]:this.uploaderCtx.taskList[f][y];if(u){if(_&&3===_.index){var m=_.context;Object.values(m.uploadHandlers).forEach(function(u){u.abort()})}}else{if(this.tasks=[],_&&3===_.index)_.context.stop();this.uploaderCtx._removeTaskCache(f)}}},{key:"restart",value:function restart(){this.uploadList.forEach(function(u){u.cancel=!1}),this.start()}}])}(m.a);function MainClass_typeof(u){return MainClass_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},MainClass_typeof(u)}function MainClass_extends(){return MainClass_extends=Object.assign?Object.assign.bind():function(u){for(var f=1;f<arguments.length;f++){var y=arguments[f];for(var _ in y)({}).hasOwnProperty.call(y,_)&&(u[_]=y[_])}return u},MainClass_extends.apply(null,arguments)}function MainClass_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,MainClass_toPropertyKey(_.key),_)}}function MainClass_toPropertyKey(u){var f=function MainClass_toPrimitive(u,f){if("object"!=MainClass_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=MainClass_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==MainClass_typeof(f)?f:f+""}function MainClass_possibleConstructorReturn(u,f){if(f&&("object"==MainClass_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function MainClass_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}function MainClass_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(MainClass_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function MainClass_getPrototypeOf(u){return MainClass_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},MainClass_getPrototypeOf(u)}function MainClass_setPrototypeOf(u,f){return MainClass_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},MainClass_setPrototypeOf(u,f)}var St=function(u){function MainClass(u){var f;return function MainClass_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,MainClass),f=function MainClass_callSuper(u,f,y){return f=MainClass_getPrototypeOf(f),MainClass_possibleConstructorReturn(u,MainClass_isNativeReflectConstruct()?Reflect.construct(f,y||[],MainClass_getPrototypeOf(u).constructor):f.apply(u,y))}(this,MainClass,[u]),u.region?Object.keys(ze).includes(u.region)?(f.config=MainClass_extends({},v),f._mergeOptions(f.config,u),f.tasks={},f.taskList={},f.cache={},f.storage=qe.storage(f,f.config.useLocalStorage),f.logger=f.config.noLog?{send:function send(){}}:new Ne(f.config,f),f):(console.error("unknown region: ".concat(u.region)),MainClass_possibleConstructorReturn(f)):(console.error("region is required"),MainClass_possibleConstructorReturn(f))}return function MainClass_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&MainClass_setPrototypeOf(u,f)}(MainClass,u),function MainClass_createClass(u,f,y){return f&&MainClass_defineProperties(u.prototype,f),y&&MainClass_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(MainClass,[{key:"_mergeOptions",value:function _mergeOptions(u,f){f&&"object"===MainClass_typeof(f)&&(MainClass_extends(u,f),u.log.userId=f.userId||u.userId,u.log.appId=f.appId||u.appId,f.hasOwnProperty("useFileNameInCacheKey")&&(u.useFileNameInCacheKey=f.useFileNameInCacheKey),Object.keys(f).forEach(function(y){"vodDomain"===y&&(u.replace[y]=f[y])}))}},{key:"_setCache",value:function _setCache(u,f){this.storage.setItem(u,f)}},{key:"_getCache",value:function _getCache(u){return this.storage.getItem(u)}},{key:"_removeCache",value:function _removeCache(u){u?this.storage.removeItem(u):this.storage.clear()}},{key:"_addTask",value:function _addTask(u,f){var y=this.tasks,_=this.taskList;y[u]&&y[u].task?(_[u].push(f),y[u].task.addTask(f)):(_[u]=[],_[u].push(f),y[u]=y[u]||{},y[u].task=new wt([],this.config,this,u),y[u].task.addTask(f))}},{key:"_broadcast",value:function _broadcast(u,f){var y=this.tasks[f.key].status;if(y===Ie||0===y)try{this.emit(u,f)}catch(u){var _=!("[object Error]"!==Object.prototype.toString.call(u));if(!_||_&&"Error"===u.name)throw u}}},{key:"_addCrc32ProcessTask",value:function _addCrc32ProcessTask(u,f,y){var _=y.isDirect,m=y.isImageBatchUpload,v=new We({file:u.file,context:this,key:f,isDirect:_,isImageBatchUpload:m},this.config),b={context:v,func:v.start,arg:{},key:f,index:0,stage:"crc32"};this._addTask(f,b)}},{key:"_addPreUploadTask",value:function _addPreUploadTask(u,f,y){var _=y.isImageBatchUpload,m=y.serviceName,v={file:u.file,stsToken:u.stsToken,context:this,type:u.type||Pe,preUploadUriParams:u.preUploadUriParams?u.preUploadUriParams:{},storeKey:u.storeKey,key:f,isImageBatchUpload:_,fileName:u.fileName||null,fileExtension:u.fileExtension||null,storageClass:u.storageClass||null,serviceName:m},b=new ft(v,this.config),w={context:b,func:b.start,arg:{},key:f,index:1,stage:"preUpload"};this._addTask(f,w)}},{key:"_addDirectUploadTask",value:function _addDirectUploadTask(u,f,y){var _=y.isImageBatchUpload,m=new vt({file:u.file,context:this,key:f,isImageBatchUpload:_},this.config),v={context:m,func:m.start,arg:{},key:f,index:3,stage:"process"};this._addTask(f,v)}},{key:"_addInitUploadIDTask",value:function _addInitUploadIDTask(u,f){var y=new dt({file:u.file,context:this,key:f},this.config),_={context:y,func:y.start,arg:{},key:f,index:2,stage:"initUploadID"};this._addTask(f,_)}},{key:"_addUploadProcessTask",value:function _addUploadProcessTask(u,f){var y=new _t({file:u.file,context:this,key:f},this.config),_={context:y,func:y.start,arg:{},key:f,index:3,stage:"process"};this._addTask(f,_)}},{key:"_mergeFileTask",value:function _mergeFileTask(u,f){var y=new mt({file:u.file,context:this,stage:"fileMerge",key:f},this.config),_={context:y,func:y.start,arg:{},key:f,index:4,stage:"fileMerge"};this._addTask(f,_)}},{key:"_getMetaInfoTask",value:function _getMetaInfoTask(u,f){var y=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},_=y.isImageBatchUpload,m=void 0!==_&&_,v=y.serviceName,b={file:u.file,context:this,data:u.data,type:u.type||Pe,callbackArgs:u.callbackArgs,key:f,isImageBatchUpload:m,serviceName:v,processAction:u.processAction},w=new bt(b,this.config),S={context:w,func:w.start,arg:{},key:f,index:5,stage:"complete"};this._addTask(f,S)}},{key:"_addAllUploadProcess",value:function _addAllUploadProcess(u,f,y){var _=u.type===Ue&&"[object Array]"===Object.prototype.toString.call(u.file);this.tasks[f]=this.tasks[f]||{},this.tasks[f].fileType=u.type||Pe,this.tasks[f].fileSize=u.file&&u.file.size,this.tasks[f].proxyStsToken=u.stsToken;var m=u.file.size<10485760||_;this._addCrc32ProcessTask(u,f,{isDirect:m,isImageBatchUpload:_}),this._addPreUploadTask(u,f,{isImageBatchUpload:_,serviceName:y}),this.config.useLocalStorage&&(this.tasks[f].enableDiskBreakPoint=!0),m?this._addDirectUploadTask(u,f,{isImageBatchUpload:_}):(this._addInitUploadIDTask(u,f),this._addUploadProcessTask(u,f),this._mergeFileTask(u,f)),this._getMetaInfoTask(u,f,{isImageBatchUpload:_,serviceName:y})}},{key:"_run",value:function _run(u){var f=this.tasks,y=navigator.userAgent.toLowerCase().match(/msie ([\d.]+)/);if(y&&y[1]&&Number(y[1])<=9)return this._broadcast("error",MainClass_extends(f[u],{key:u,status:0,stage:"browserError",extra:{message:"cannot support the browser below ie10"},type:"error"})),this.logger.send(f[u]),void this._cancel(u);if(f[u])if(f[u].status===Ae)this._restart(u);else{var _=new Date;f[u].startTime=_.getTime(),f[u].task&&f[u].status!==Ie&&f[u].task.tasks.length&&(f[u].status=Ie,this.logger.send(MainClass_extends({},f[u],{extra:{message:"start upload"},type:"start",key:u})),f[u].task.start())}else console.warn("".concat(u," is not exit in object tasks, stop running..."))}},{key:"_restart",value:function _restart(u){var f=this,y=this.tasks;if(y[u]){var _=y[u].task,m=y[u].currentTask||0;this.taskList[u].forEach(function(y,v){y.index===m&&(_.tasks=f.taskList[u].slice(v))}),_&&y[u].status!==Ie&&_.tasks.length&&(y[u].status=Ie,_.restart())}else console.warn("".concat(u," is not exit in object tasks"))}},{key:"_cancel",value:function _cancel(u){var f=this.tasks;f[u]?(f[u].status=Te,f[u].task.cancel(!1),this.taskList[u]=[]):console.warn("".concat(u," is not exit in object tasks"))}},{key:"_pause",value:function _pause(u){var f=this.tasks;f[u]?(f[u].status=Ae,f[u].task.cancel(!0)):console.warn("".concat(u," is not exit in object tasks"))}},{key:"_removeTaskCache",value:function _removeTaskCache(u){var f=this.tasks;if(f[u]){var y=f[u].crc32Key;y&&this._removeCache(y)}else console.warn("".concat(u," is not exit in object tasks"))}},{key:"_saveTask",value:function _saveTask(u,f){var y=MainClass_extends({},this.tasks[u],f||{}),_=y.crc32Key;if(_){var m={SessionKey:y.SessionKey,UploadHeader:y.UploadHeader,fileName:y.fileName,oid:y.oid,uploadID:y.uploadID,signature:y.signature,tosDomain:y.tosDomain,hasMerge:y.hasMerge};Object.keys(m).forEach(function(u){m[u]||delete m[u]});try{this._setCache(_,JSON.stringify(m))}catch(u){return[!1,u.message]}return[!0,""]}}},{key:"_queueSuccess",value:function _queueSuccess(u){var f=this.tasks;if(f[u]){var y=new Date;f[u].endTime=y.getTime(),f[u].time=f[u].endTime-f[u].startTime,f[u].status=0,this.taskList[u]=[]}else console.warn("".concat(u," is not exit in object tasks"))}},{key:"_removeFile",value:function _removeFile(u){delete this.tasks[u]}},{key:"_batchAction",value:function _batchAction(u){var f=this.tasks;Object.keys(f).forEach(function(f){u&&u(f)})}},{key:"_refreshStsToken",value:function _refreshStsToken(u){var f=this,y=this.tasks;Object.keys(y).forEach(function(_){var m=y[_],v=MainClass_extends({},m,{proxyStsToken:u});m.proxyStsToken=u;var b=v.crc32Key;b&&(delete v.task,delete v.xhr,delete v.crc32Array,m.proxyStsToken=u,f._setCache(b,JSON.stringify(v)))})}},{key:"_setOption",value:function _setOption(u){this._mergeOptions(this.config,u)}},{key:"_setServiceId",value:function _setServiceId(u){!this.config.imageConfig&&u?this.config.imageConfig={serviceId:u}:this.config.imageConfig.serviceId=u}},{key:"_getServiceId",value:function _getServiceId(){var u;return null===(u=this.config.imageConfig)||void 0===u?void 0:u.serviceId}},{key:"_getOption",value:function _getOption(u){var f=MainClass_extends({},this.config);return Object.keys(f).forEach(function(u){(u.indexOf("Url")>-1||"replace"===u||"log"===u)&&delete f[u]}),u?f[u]:f}},{key:"_userCancel",value:function _userCancel(u){var f=this,y=this.tasks;u?(this._cancel(u),this.logger.send(MainClass_extends({},y[u],{type:"cancel"}))):Object.keys(y).forEach(function(u){f._cancel(u),f.logger.send(MainClass_extends({},y[u],{type:"cancel"}))})}},{key:"_userPause",value:function _userPause(u){var f=this,y=this.tasks;u?(this._pause(u),this.logger.send(MainClass_extends({},y[u],{type:"pause"}))):Object.keys(y).forEach(function(u){f._pause(u),f.logger.send(MainClass_extends({},y[u],{type:"pause"}))})}}])}(m.a),kt={checkFile:function checkFile(){},checkStsToken:function checkStsToken(u){return!u||u.SessionToken&&u.SecretAccessKey&&(u.AccessKeyId||u.AccessKeyID)}};function entry_typeof(u){return entry_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u},entry_typeof(u)}function entry_defineProperties(u,f){for(var y=0;y<f.length;y++){var _=f[y];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(u,entry_toPropertyKey(_.key),_)}}function entry_toPropertyKey(u){var f=function entry_toPrimitive(u,f){if("object"!=entry_typeof(u)||!u)return u;var y=u[Symbol.toPrimitive];if(void 0!==y){var _=y.call(u,f||"default");if("object"!=entry_typeof(_))return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===f?String:Number)(u)}(u,"string");return"symbol"==entry_typeof(f)?f:f+""}function entry_callSuper(u,f,y){return f=entry_getPrototypeOf(f),function entry_possibleConstructorReturn(u,f){if(f&&("object"==entry_typeof(f)||"function"==typeof f))return f;if(void 0!==f)throw new TypeError("Derived constructors may only return object or undefined");return function entry_assertThisInitialized(u){if(void 0===u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}(u)}(u,entry_isNativeReflectConstruct()?Reflect.construct(f,y||[],entry_getPrototypeOf(u).constructor):f.apply(u,y))}function entry_isNativeReflectConstruct(){try{var u=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(u){}return(entry_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!u})()}function entry_getPrototypeOf(u){return entry_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(u){return u.__proto__||Object.getPrototypeOf(u)},entry_getPrototypeOf(u)}function entry_setPrototypeOf(u,f){return entry_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,f){return u.__proto__=f,u},entry_setPrototypeOf(u,f)}var Et=function(u){function BytePlusUploader(){return function entry_classCallCheck(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}(this,BytePlusUploader),entry_callSuper(this,BytePlusUploader,arguments)}return function entry_inherits(u,f){if("function"!=typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function");u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),Object.defineProperty(u,"prototype",{writable:!1}),f&&entry_setPrototypeOf(u,f)}(BytePlusUploader,u),function entry_createClass(u,f,y){return f&&entry_defineProperties(u.prototype,f),y&&entry_defineProperties(u,y),Object.defineProperty(u,"prototype",{writable:!1}),u}(BytePlusUploader,[{key:"start",value:function start(u){this.abort=!1,u?this._run(u):this._batchAction(this._run.bind(this))}},{key:"addFile",value:function addFile(u){if(!(this.config.useConsoleMode||u&&kt.checkStsToken(u.stsToken)))return this.emit("error",{extra:{message:ut,errorCode:tt}}),null;if(u.file&&u.file instanceof Blob){var f=qe.getUnique("file");return this._addAllUploadProcess(u,f,je),f}return this.emit("error",{extra:{message:lt,errorCode:et}}),null}},{key:"removeFile",value:function removeFile(u){u&&this._removeFile(u)}},{key:"cancel",value:function cancel(u){u?this._userCancel(u):this._batchAction(this._userCancel.bind(this))}},{key:"pause",value:function pause(u){this._userPause(u)}},{key:"restart",value:function restart(u){u?this._restart(u):this._batchAction(this._restart.bind(this))}},{key:"refreshStsToken",value:function refreshStsToken(u){this._refreshStsToken(u)}},{key:"setOption",value:function setOption(u){this._setOption(u)}},{key:"getOption",value:function getOption(u){return this._getOption(u)}}])}(St)}]).default});
|