@byteplus/uploader 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD-3-Clause License
2
+
3
+ Copyright (c) 2023 BytePlus Pte. Ltd. All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification,
6
+ are permitted provided that the following conditions are met:
7
+
8
+ * Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ * Redistributions in binary form must reproduce the above copyright notice, this
12
+ list of conditions and the following disclaimer in the documentation and/or
13
+ other materials provided with the distribution.
14
+
15
+ * Neither the name of the {organization} nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # BytePlus
2
+ By integrating @byteplus/uploader, you can upload files to BytePlus VOD. For more information, see [What is BytePlus VOD](https://docs.byteplus.com/en/byteplus-vod/docs/what-is-byteplus-vod).
3
+
4
+ [Upload SDK overview](https://docs.byteplus.com/en/byteplus-vod/docs/upload-sdk-overview)
5
+ ## Installation
6
+ ```bash
7
+ $ npm install @byteplus/uploader --save
8
+ ```
9
+ ## API Documentation
10
+ - [Web SDK Overview](https://docs.byteplus.com/en/byteplus-vod/docs/web_1#f9648941)
11
+ - [API Reference](https://docs.byteplus.com/en/byteplus-vod/docs/web_1#d6a70e98)
12
+ - [Events](https://docs.byteplus.com/en/byteplus-vod/docs/web_1#e50f2686)
13
+ - [Error Code](https://docs.byteplus.com/en/byteplus-vod/docs/web_1#4c1854a8)
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ !function webpackUniversalModuleDefinition(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.TTUploader=t():e.TTUploader=t()}("undefined"!=typeof self?self:this,function(){return function(r){var o={};function __webpack_require__(e){var t;return(o[e]||(t=o[e]={i:e,l:!1,exports:{}},r[e].call(t.exports,t,t.exports,__webpack_require__),t.l=!0,t)).exports}return __webpack_require__.m=r,__webpack_require__.c=o,__webpack_require__.d=function(e,t,r){__webpack_require__.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},__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(t,e){if(1&e&&(t=__webpack_require__(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(__webpack_require__.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)__webpack_require__.d(r,o,function(e){return t[e]}.bind(null,o));return r},__webpack_require__.n=function(e){var t=e&&e.__esModule?function getDefault(){return e.default}:function getModuleExports(){return e};return __webpack_require__.d(t,"a",t),t},__webpack_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=9)}([function(e,t,r){"use strict";var o="object"==typeof Reflect?Reflect:null,c=o&&"function"==typeof o.apply?o.apply:function ReflectApply(e,t,r){return Function.prototype.apply.call(e,t,r)};var n=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function ReflectOwnKeys(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function ReflectOwnKeys(e){return Object.getOwnPropertyNames(e)},i=Number.isNaN||function NumberIsNaN(e){return e!=e};function EventEmitter(){EventEmitter.init.call(this)}e.exports=EventEmitter,e.exports.once=function once(r,o){return new Promise(function(e,t){function errorListener(e){r.removeListener(o,resolver),t(e)}function resolver(){"function"==typeof r.removeListener&&r.removeListener("error",errorListener),e([].slice.call(arguments))}eventTargetAgnosticAddListener(r,o,resolver,{once:!0}),"error"!==o&&function addErrorHandlerIfEventEmitter(e,t,r){"function"==typeof e.on&&eventTargetAgnosticAddListener(e,"error",t,r)}(r,errorListener,{once:!0})})},(EventEmitter.EventEmitter=EventEmitter).prototype._events=void 0,EventEmitter.prototype._eventsCount=0,EventEmitter.prototype._maxListeners=void 0;var s=10;function checkListener(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function _getMaxListeners(e){return void 0===e._maxListeners?EventEmitter.defaultMaxListeners:e._maxListeners}function _addListener(e,t,r,o){var n,i;return checkListener(r),void 0===(n=e._events)?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,r.listener||r),n=e._events),i=n[t]),void 0===i?(i=n[t]=r,++e._eventsCount):("function"==typeof i?i=n[t]=o?[r,i]:[i,r]:o?i.unshift(r):i.push(r),0<(n=_getMaxListeners(e))&&i.length>n&&!i.warned&&(i.warned=!0,(o=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit")).name="MaxListenersExceededWarning",o.emitter=e,o.type=t,o.count=i.length,function ProcessEmitWarning(e){console&&console.warn&&console.warn(e)}(o))),e}function _onceWrap(e,t,r){e={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},t=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)}.bind(e);return t.listener=r,e.wrapFn=t}function _listeners(e,t,r){var e=e._events;return void 0===e||void 0===(e=e[t])?[]:"function"==typeof e?r?[e.listener||e]:[e]:r?function unwrapListeners(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(e):arrayClone(e,e.length)}function listenerCount(e){var t=this._events;if(void 0!==t){t=t[e];if("function"==typeof t)return 1;if(void 0!==t)return t.length}return 0}function arrayClone(e,t){for(var r=new Array(t),o=0;o<t;++o)r[o]=e[o];return r}function eventTargetAgnosticAddListener(t,r,o,n){if("function"==typeof t.on)n.once?t.once(r,o):t.on(r,o);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(r,function wrapListener(e){n.once&&t.removeEventListener(r,wrapListener),o(e)})}}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),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(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},EventEmitter.prototype.getMaxListeners=function getMaxListeners(){return _getMaxListeners(this)},EventEmitter.prototype.emit=function emit(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var o="error"===e,n=this._events;if(void 0!==n)o=o&&void 0===n.error;else if(!o)return!1;if(o){if((i=0<t.length?t[0]:i)instanceof Error)throw i;o=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw o.context=i,o}var i=n[e];if(void 0===i)return!1;if("function"==typeof i)c(i,this,t);else for(var s=i.length,a=arrayClone(i,s),r=0;r<s;++r)c(a[r],this,t);return!0},EventEmitter.prototype.on=EventEmitter.prototype.addListener=function addListener(e,t){return _addListener(this,e,t,!1)},EventEmitter.prototype.prependListener=function prependListener(e,t){return _addListener(this,e,t,!0)},EventEmitter.prototype.once=function once(e,t){return checkListener(t),this.on(e,_onceWrap(this,e,t)),this},EventEmitter.prototype.prependOnceListener=function prependOnceListener(e,t){return checkListener(t),this.prependListener(e,_onceWrap(this,e,t)),this},EventEmitter.prototype.off=EventEmitter.prototype.removeListener=function removeListener(e,t){var r,o,n,i,s;if(checkListener(t),void 0!==(o=this._events)&&void 0!==(r=o[e]))if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(n=-1,i=r.length-1;0<=i;i--)if(r[i]===t||r[i].listener===t){s=r[i].listener,n=i;break}if(n<0)return this;0===n?r.shift():function spliceOne(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,n),1===r.length&&(o[e]=r[0]),void 0!==o.removeListener&&this.emit("removeListener",e,s||t)}return this},EventEmitter.prototype.removeAllListeners=function removeAllListeners(e){var t,r=this._events;if(void 0!==r)if(void 0===r.removeListener)0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]);else if(0===arguments.length){for(var o,n=Object.keys(r),i=0;i<n.length;++i)"removeListener"!==(o=n[i])&&this.removeAllListeners(o);this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0}else if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;0<=i;i--)this.removeListener(e,t[i]);return this},EventEmitter.prototype.listeners=function listeners(e){return _listeners(this,e,!0)},EventEmitter.prototype.rawListeners=function rawListeners(e){return _listeners(this,e,!1)},EventEmitter.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):listenerCount.call(e,t)},EventEmitter.prototype.listenerCount=listenerCount,EventEmitter.prototype.eventNames=function eventNames(){return 0<this._eventsCount?n(this._events):[]}},function(e,t,r){e.exports=function(c){return function(n){var e=c;var t=e.lib;var r=t.WordArray;var o=t.Hasher;var i=e.algo;var s=[];var S=[];(function(){function isPrime(e){var t=n.sqrt(e);for(var r=2;r<=t;r++)if(!(e%r))return false;return true}function getFractionalBits(e){return(e-(e|0))*4294967296|0}var e=2;var t=0;while(t<64){if(isPrime(e)){if(t<8)s[t]=getFractionalBits(n.pow(e,1/2));S[t]=getFractionalBits(n.pow(e,1/3));t++}e++}})();var k=[];var a=i.SHA256=o.extend({_doReset:function(){this._hash=new r.init(s.slice(0))},_doProcessBlock:function(e,t){var r=this._hash.words;var o=r[0];var n=r[1];var i=r[2];var s=r[3];var a=r[4];var c=r[5];var u=r[6];var l=r[7];for(var p=0;p<64;p++){if(p<16)k[p]=e[t+p]|0;else{var f=k[p-15];var d=(f<<25|f>>>7)^(f<<14|f>>>18)^f>>>3;var h=k[p-2];var y=(h<<15|h>>>17)^(h<<13|h>>>19)^h>>>10;k[p]=d+k[p-7]+y+k[p-16]}var g=a&c^~a&u;var _=o&n^o&i^n&i;var m=(o<<30|o>>>2)^(o<<19|o>>>13)^(o<<10|o>>>22);var v=(a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25);var b=l+v+g+S[p]+k[p];var w=m+_;l=u;u=c;c=a;a=s+b|0;s=i;i=n;n=o;o=b+w|0}r[0]=r[0]+o|0;r[1]=r[1]+n|0;r[2]=r[2]+i|0;r[3]=r[3]+s|0;r[4]=r[4]+a|0;r[5]=r[5]+c|0;r[6]=r[6]+u|0;r[7]=r[7]+l|0},_doFinalize:function(){var e=this._data;var t=e.words;var r=this._nDataBytes*8;var o=e.sigBytes*8;t[o>>>5]|=128<<24-o%32;t[(o+64>>>9<<4)+14]=n.floor(r/4294967296);t[(o+64>>>9<<4)+15]=r;e.sigBytes=t.length*4;this._process();return this._hash},clone:function(){var e=o.clone.call(this);e._hash=this._hash.clone();return e}});e.SHA256=o._createHelper(a);e.HmacSHA256=o._createHmacHelper(a)}(Math),c.SHA256}(r(3))},function(e,t,r){e.exports=function(e){return e.HmacSHA256}(r(3),(r(1),r(7)))},function(e,t,_){!function(g){e.exports=function(){var e=e||function(p,r){var e;if(typeof window!=="undefined"&&window.crypto)e=window.crypto;if(typeof self!=="undefined"&&self.crypto)e=self.crypto;if(typeof globalThis!=="undefined"&&globalThis.crypto)e=globalThis.crypto;if(!e&&typeof window!=="undefined"&&window.msCrypto)e=window.msCrypto;if(!e&&typeof g!=="undefined"&&g.crypto)e=g.crypto;if(!e&&"function"==="function")try{e=_(6)}catch(e){}var o=function(){if(e){if(typeof e.getRandomValues==="function")try{return e.getRandomValues(new Uint32Array(1))[0]}catch(e){}if(typeof e.randomBytes==="function")try{return e.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")};var n=Object.create||function(){function F(){}return function(e){var t;F.prototype=e;t=new F;F.prototype=null;return t}}();var t={};var i=t.lib={};var s=i.Base=function(){return{extend:function(e){var t=n(this);if(e)t.mixIn(e);if(!t.hasOwnProperty("init")||this.init===t.init)t.init=function(){t.$super.init.apply(this,arguments)};t.init.prototype=t;t.$super=this;return t},create:function(){var e=this.extend();e.init.apply(e,arguments);return e},init:function(){},mixIn:function(e){for(var t in e)if(e.hasOwnProperty(t))this[t]=e[t];if(e.hasOwnProperty("toString"))this.toString=e.toString},clone:function(){return this.init.prototype.extend(this)}}}();var f=i.WordArray=s.extend({init:function(e,t){e=this.words=e||[];if(t!=r)this.sigBytes=t;else this.sigBytes=e.length*4},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words;var r=e.words;var o=this.sigBytes;var n=e.sigBytes;this.clamp();if(o%4)for(var i=0;i<n;i++){var s=r[i>>>2]>>>24-i%4*8&255;t[o+i>>>2]|=s<<24-(o+i)%4*8}else for(var a=0;a<n;a+=4)t[o+a>>>2]=r[a>>>2];this.sigBytes+=n;return this},clamp:function(){var e=this.words;var t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8;e.length=p.ceil(t/4)},clone:function(){var e=s.clone.call(this);e.words=this.words.slice(0);return e},random:function(e){var t=[];for(var r=0;r<e;r+=4)t.push(o());return new f.init(t,e)}});var a=t.enc={};var c=a.Hex={stringify:function(e){var t=e.words;var r=e.sigBytes;var o=[];for(var n=0;n<r;n++){var i=t[n>>>2]>>>24-n%4*8&255;o.push((i>>>4).toString(16));o.push((i&15).toString(16))}return o.join("")},parse:function(e){var t=e.length;var r=[];for(var o=0;o<t;o+=2)r[o>>>3]|=parseInt(e.substr(o,2),16)<<24-o%8*4;return new f.init(r,t/2)}};var u=a.Latin1={stringify:function(e){var t=e.words;var r=e.sigBytes;var o=[];for(var n=0;n<r;n++){var i=t[n>>>2]>>>24-n%4*8&255;o.push(String.fromCharCode(i))}return o.join("")},parse:function(e){var t=e.length;var r=[];for(var o=0;o<t;o++)r[o>>>2]|=(e.charCodeAt(o)&255)<<24-o%4*8;return new f.init(r,t)}};var l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}};var d=i.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new f.init;this._nDataBytes=0},_append:function(e){if(typeof e=="string")e=l.parse(e);this._data.concat(e);this._nDataBytes+=e.sigBytes},_process:function(e){var t;var r=this._data;var o=r.words;var n=r.sigBytes;var i=this.blockSize;var s=i*4;var a=n/s;if(e)a=p.ceil(a);else a=p.max((a|0)-this._minBufferSize,0);var c=a*i;var u=p.min(c*4,n);if(c){for(var l=0;l<c;l+=i)this._doProcessBlock(o,l);t=o.splice(0,c);r.sigBytes-=u}return new f.init(t,u)},clone:function(){var e=s.clone.call(this);e._data=this._data.clone();return e},_minBufferSize:0});var h=i.Hasher=d.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e);this.reset()},reset:function(){d.reset.call(this);this._doReset()},update:function(e){this._append(e);this._process();return this},finalize:function(e){if(e)this._append(e);var t=this._doFinalize();return t},blockSize:512/32,_createHelper:function(r){return function(e,t){return new r.init(t).finalize(e)}},_createHmacHelper:function(r){return function(e,t){return new y.HMAC.init(r,t).finalize(e)}}});var y=t.algo={};return t}(Math);return e}()}.call(this,_(5))},function(e,t,r){e.exports=function(){return r(8)('!function(_){var t={};function __webpack_require__(e){var r;return(t[e]||(r=t[e]={i:e,l:!1,exports:{}},_[e].call(r.exports,r,r.exports,__webpack_require__),r.l=!0,r)).exports}__webpack_require__.m=_,__webpack_require__.c=t,__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(r,e){if(1&e&&(r=__webpack_require__(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var _=Object.create(null);if(__webpack_require__.r(_),Object.defineProperty(_,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var t in r)__webpack_require__.d(_,t,function(e){return r[e]}.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 dec2hex(e){if(void 0!==e)return function toEight(e){return e.length<8?toEight(e="0".concat(e)):e}(Number(e).toString(16))}self.onmessage=function(e){var e=e.data,r=e[0],e=e[1],_=function crc32(e,r){for(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],t=("undefined"!=typeof Int32Array&&(_=new Int32Array(_)),-1^~~r),n=(e=new Uint8Array(e)).length,u=0;u<n;u++)t=_[255&(t^e[u])]^t>>>8;return(-1^t)>>>0}(r,0);postMessage([r,dec2hex(_),e],[r])}}]);',null)}},function(e,t){var r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t){},function(e,t,r){e.exports=function(s){(function(){var e=s;var t=e.lib;var r=t.Base;var o=e.enc;var u=o.Utf8;var n=e.algo;var i=n.HMAC=r.extend({init:function(e,t){e=this._hasher=new e.init;if(typeof t=="string")t=u.parse(t);var r=e.blockSize;var o=r*4;if(t.sigBytes>o)t=e.finalize(t);t.clamp();var n=this._oKey=t.clone();var i=this._iKey=t.clone();var s=n.words;var a=i.words;for(var c=0;c<r;c++){s[c]^=1549556828;a[c]^=909522486}n.sigBytes=i.sigBytes=o;this.reset()},reset:function(){var e=this._hasher;e.reset();e.update(this._iKey)},update:function(e){this._hasher.update(e);return this},finalize:function(e){var t=this._hasher;var r=t.finalize(e);t.reset();var o=t.finalize(this._oKey.clone().concat(r));return o}})})()}(r(3))},function(e,t,r){"use strict";var n=window.URL||window.webkitURL;e.exports=function(t,r){try{try{var o;try{(o=new(window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder)).append(t),o=o.getBlob()}catch(e){o=new Blob([t])}return new Worker(n.createObjectURL(o))}catch(e){return new Worker("data:application/javascript,"+encodeURIComponent(t))}}catch(e){if(r)return new Worker(r);throw Error("Inline worker is not supported")}}},function(E,o,n){"use strict";n.r(o),n.d(o,"default",function(){return it});var o=n(0),s=n.n(o),O={debug:!1,region:"i18n",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:3,retryProcess:!0,retryProcessTime:3,retryTaskTime:3,maxProcessPause:20,schema:"https",useLocalStorage:!0,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(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _extends(){return(_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,o=arguments[t];for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}var l=function e(){return(l=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function index_base_min_i(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(function t(e,r){var o="function"==typeof Symbol&&e[Symbol.iterator];if(!o)return e;var n,i,s=o.call(e),a=[];try{for(;(void 0===r||0<r--)&&!(n=s.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}return a}(arguments[t]));return e}var x,f,C=function(){function e(){this._hooks={},this._cache=[],this._hooksCache={}}return e.prototype.on=function(e,t){e&&t&&"function"==typeof t&&(this._hooks[e]||(this._hooks[e]=[]),this._hooks[e].push(t))},e.prototype.once=function(t,r){var n=this;t&&r&&"function"==typeof r&&this.on(t,function o(e){r(e),n.off(t,o)})},e.prototype.off=function(e,t){e&&this._hooks[e]&&this._hooks[e].length&&(t?-1!==(t=this._hooks[e].indexOf(t))&&this._hooks[e].splice(t,1):this._hooks[e]=[])},e.prototype.emit=function(e,t,r){r?e&&(-1!==this._cache.indexOf(r)?this._emit(e,t):(this._hooksCache.hasOwnProperty(r)||(this._hooksCache[r]={}),this._hooksCache[r].hasOwnProperty(e)||(this._hooksCache[r][e]=[]),this._hooksCache[r][e].push(t))):this._emit(e,t)},e.prototype._emit=function(e,t){e&&this._hooks[e]&&this._hooks[e].length&&index_base_min_i(this._hooks[e]).forEach(function(e){try{e(t)}catch(e){}})},e.prototype.set=function(e){e&&-1===this._cache.indexOf(e)&&this._cache.push(e)},e}(),P=function r(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)},D=(x=+Date.now()+Number((""+Math.random()).slice(2,8)),function a(e){return function(e){if("string"==typeof e){for(var t=[],r=String.fromCharCode(122),o=e.split(r),n=0;n<o.length;n++){var i=64^+parseInt(o[n],25),i=String.fromCharCode(i);t.push(i)}return t.join("")}}(e)}),U=function c(t,r){void 0===t&&(t=function e(){}),void 0===r&&(r=1e3);var o=Date.now()+r,i=window.setTimeout(function n(){var e=Date.now()-o;t(),o+=r,i=window.setTimeout(n,Math.max(0,r-e))},r);return function(){window.clearTimeout(i)}},T=function l(e){var t=document.createElement("a");return t.href=e,t},a=function p(e){var n={};try{T(e).search.slice(1).split("&").forEach(function(e){var t,r,o=e.split("=");o.length&&(t=o[0],r=o[1]);try{n[t]=decodeURIComponent(void 0===r?"":r)}catch(e){n[t]=r}})}catch(e){}return n},I=function h(e){for(var t=0,r=0,o=(e+="").length,n=0;n<o;n++)(0x7fffffffffff<(t=31*t+e.charCodeAt(r++))||t<-0x800000000000)&&(t&=0xffffffffffff);return t<0&&(t+=0x7ffffffffffff),t},A=(function(e){e.exports=function i(){function e(){for(var e=0,t={};e<arguments.length;e++){var r,o=arguments[e];for(r in o)t[r]=o[r]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function i(u){function n(){}function r(t,r,o){if("undefined"!=typeof document){"number"==typeof(o=e({path:"/"},n.defaults,o)).expires&&(o.expires=new Date(+new Date+864e5*o.expires)),o.expires=o.expires?o.expires.toUTCString():"";try{var i=JSON.stringify(r);/^[\{\[]/.test(i)&&(r=i)}catch(e){}r=u.write?u.write(r,t):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var s,a="";for(s in o)o[s]&&(a+="; "+s,!0!==o[s])&&(a+="="+o[s].split(";")[0]);return document.cookie=t+"="+r+a}}function s(e,r){if("undefined"!=typeof document){for(var o={},n=document.cookie?document.cookie.split("; "):[],i=0;i<n.length;i++){var s=n[i].split("="),a=s.slice(1).join("=");r||'"'!==a.charAt(0)||(a=a.slice(1,-1));try{var c=t(s[0]),a=(u.read||u)(a,c)||t(a);if(r)try{a=JSON.parse(a)}catch(e){}if(o[c]=a,e===c)break}catch(e){}}return e?o[e]:o}}return n.set=r,n.get=function(e){return s(e,!1)},n.getJSON=function(e){return s(e,!0)},n.remove=function(t,o){r(t,"",e(o,{expires:-1}))},n.defaults={},n.withConverter=i,n}(function(){})}()}(o={exports:{}}),o.exports),z=function d(e,t){try{return A.get(e,{domain:t||document.domain})}catch(e){return""}},M=function g(e,t,r,o){try{var n=o||document.domain,i=+new Date+(r||6048e5);A.set(e,t,{expires:new Date(i),path:"/",domain:n})}catch(e){}},R=function(){function e(){this.cache={}}return e.prototype.setItem=function(e,t){this.cache[e]=t},e.prototype.getItem=function(e){return this.cache[e]},e.prototype.removeItem=function(e){this.cache[e]=void 0},e.prototype.getCookie=function(e,t){return z(e,t)},e.prototype.setCookie=function(e,t,r,o){M(e,t,r,o)},e}(),B={getItem:function getItem(e){try{var t=localStorage.getItem(e),r=t;try{t&&"string"==typeof t&&(r=JSON.parse(t))}catch(e){}return r||{}}catch(e){}return{}},setItem:function setItem(e,t){try{var r="string"==typeof t?t:JSON.stringify(t);localStorage.setItem(e,r)}catch(e){}},removeItem:function removeItem(e){try{localStorage.removeItem(e)}catch(e){}},getCookie:function getCookie(e,t){return z(e,t)},setCookie:function setCookie(e,t,r,o){M(e,t,r,o)},isSupportLS:function(){try{return localStorage.setItem("_ranger-test-key","hi"),localStorage.getItem("_ranger-test-key"),localStorage.removeItem("_ranger-test-key"),!0}catch(e){return!1}}()},N={getItem:function getItem(e){try{var t=sessionStorage.getItem(e),r=t;try{t&&"string"==typeof t&&(r=JSON.parse(t))}catch(e){}return r||{}}catch(e){}return{}},setItem:function setItem(e,t){try{var r="string"==typeof t?t:JSON.stringify(t);sessionStorage.setItem(e,r)}catch(e){}},removeItem:function removeItem(e){try{sessionStorage.removeItem(e)}catch(e){}},getCookie:function getCookie(e,t){return z(e,t)},setCookie:function setCookie(e,t,r,o){M(e,t,r,o)},isSupportSession:function(){try{return sessionStorage.setItem("_ranger-test-key","hi"),sessionStorage.getItem("_ranger-test-key"),sessionStorage.removeItem("_ranger-test-key"),!0}catch(e){return!1}}()},h=function(){function e(e,t){this._storage=t&&"session"===t?N:!e&&B.isSupportLS?B:new R}return e.prototype.getItem=function(e){return this._storage.getItem(e)},e.prototype.setItem=function(e,t){this._storage.setItem(e,t)},e.prototype.getCookie=function(e,t){return this._storage.getCookie(e,t)},e.prototype.setCookie=function(e,t,r,o){this._storage.setCookie(e,t,r,o)},e.prototype.removeItem=function(e){this._storage.removeItem(e)},e}(),G=function(){function e(e,t,r){this.appid=e,this.domain=t,this.userAgent=window.navigator.userAgent,this.appVersion=window.navigator.appVersion,this.cookie_expire=r}return e.prototype.init=function(){var e=window.navigator.userAgent,t=window.navigator.language,r=document.referrer,o=r?T(r).hostname:"",n=a(window.location.href),i=/Mobile|htc|mini|Android|iP(ad|od|hone)/.test(this.appVersion)?"wap":"web",n=(this.utm=function(e,t,r,o){var n=new h(!1),i=new h(!1,"session"),s=e?"_tea_utm_cache_"+e:"_tea_utm_cache",a=e?"_$utm_from_url_"+e:"_$utm_from_url",c={},u=["tr_shareuser","tr_admaster","tr_param1","tr_param2","tr_param3","tr_param4","$utm_from_url"],l={ad_id:Number(t.ad_id)||void 0,campaign_id:Number(t.campaign_id)||void 0,creative_id:Number(t.creative_id)||void 0,utm_source:t.utm_source,utm_medium:t.utm_medium,utm_campaign:t.utm_campaign,utm_term:t.utm_term,utm_content:t.utm_content,tr_shareuser:t.tr_shareuser,tr_admaster:t.tr_admaster,tr_param1:t.tr_param1,tr_param2:t.tr_param2,tr_param3:t.tr_param3,tr_param4:t.tr_param4};try{var p,f,d=!1;for(p in l)l[p]&&(-1!==u.indexOf(p)?(c.hasOwnProperty("tracer_data")||(c.tracer_data={}),c.tracer_data[p]=l[p]):c[p]=l[p],d=!0);d?(i.setItem(a,"1"),n.setCookie(s,JSON.stringify(c),o,r)):(f=n.getCookie(s,r))&&(c=JSON.parse(f)),i.getItem(a)&&(c.hasOwnProperty("tracer_data")||(c.tracer_data={}),c.tracer_data.$utm_from_url=1)}catch(e){return l}return c}(this.appid,n,this.domain,this.cookie_expire),this.browser()),s=this.os();return{browser:n.browser,browser_version:n.browser_version,platform:i,os_name:s.os_name,os_version:s.os_version,userAgent:e,screen_width:window.screen&&window.screen.width,screen_height:window.screen&&window.screen.height,device_model:this.getDeviceModel(s.os_name),language:t,referrer:r,referrer_host:o,utm:this.utm,latest_data:this.last(r,o)}},e.prototype.last=function(e,t){var r="",o="",n="",i=location.hostname,s=!1;return e&&t&&i!==t&&(o=t,s=!0,(i=a(r=e)).keyword)&&(n=i.keyword),{$latest_referrer:r,$latest_referrer_host:o,$latest_search_keyword:n,isLast:s}},e.prototype.browser=function(){var e,t="",r=""+parseFloat(this.appVersion),o=this.userAgent;return-1!==o.indexOf("Edge")||-1!==o.indexOf("Edg")?(t="Microsoft Edge",r=-1!==o.indexOf("Edge")?(e=o.indexOf("Edge"),o.substring(e+5)):(e=o.indexOf("Edg"),o.substring(e+4))):-1!==(e=o.indexOf("MSIE"))?(t="Microsoft Internet Explorer",r=o.substring(e+5)):-1!==(e=o.indexOf("Lark"))?(t="Lark",r=o.substring(e+5,e+11)):-1!==o.indexOf("Chrome")?-1!==(e=o.indexOf("TTWebView"))?(t="TTWebView",r=o.substring(e+10,e+23)):-1===(e=o.indexOf("Chrome"))&&-1===(e=o.indexOf("Chrome"))||(t="Chrome",r=o.substring(e+7)):-1!==o.indexOf("Safari")?-1!==(e=o.indexOf("Safari"))&&(t="Safari",r=o.substring(e+7),-1!==(e=o.indexOf("Version")))&&(r=o.substring(e+8)):-1!==(e=o.indexOf("Firefox"))&&(t="Firefox",r=o.substring(e+8)),{browser:t,browser_version:r=-1!==(o=(r=-1!==(o=(r=-1!==(o=r.indexOf(";"))?r.substring(0,o):r).indexOf(" "))?r.substring(0,o):r).indexOf(")"))?r.substring(0,o):r}},e.prototype.os=function(){for(var e="",t="",r=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0|Windows NT 10.1)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Android",r:/Android/},{s:"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)/}],o=0;o<r.length;o++){var n=r[o];if(n.r.test(this.userAgent)){"Mac OS X"===(e=n.s)&&this.isNewIpad()&&(e="iOS");break}}var i,s=function r(e,t){e=e.exec(t);return e&&e[1]?e[1]:""},a=function s(e,t){e=RegExp("(?:^|[^A-Z0-9-_]|[^A-Z0-9-]_|sprd-)(?:"+e+")","i").exec(t);return e?e.slice(1)[0]:""};switch(/Windows/.test(e)&&(t=s(/Windows (.*)/,e),e="windows"),e){case"Mac OS X":t=a("Mac[ +]OS[ +]X(?:[ /](?:Version )?(\\d+(?:[_\\.]\\d+)+))?",this.userAgent),e="mac";break;case"Android":t=s(/Android ([\.\_\d]+)/,i=this.userAgent)||s(/Android\/([\.\_\d]+)/,i),e="android";break;case"iOS":t=this.isNewIpad()?a("Mac[ +]OS[ +]X(?:[ /](?:Version )?(\\d+(?:[_\\.]\\d+)+))?",this.userAgent):(t=/OS (\d+)_(\d+)_?(\d+)?/.exec(this.appVersion))?t[1]+"."+t[2]+"."+(0|t[3]):"",e="ios"}return{os_name:e,os_version:t}},e.prototype.getDeviceModel=function(e){var t,r,o="";try{"android"===e?navigator.userAgent.split(";").forEach(function(e){-1<e.indexOf("Build/")&&(o=e.slice(0,e.indexOf("Build/")))}):"ios"!==e&&"mac"!==e&&"windows"!==e||(o=this.isNewIpad()?"iPad":(r=(t=navigator.userAgent.replace("Mozilla/5.0 (","")).indexOf(";"),t.slice(0,r)))}catch(e){}return o.trim()},e.prototype.isNewIpad=function(){return void 0!==this.userAgent&&"MacIntel"===navigator.platform&&"number"==typeof navigator.maxTouchPoints&&1<navigator.maxTouchPoints},e}(),L={sg:"1fz22z22z1nz21z4mz4bz4bz21z1ez18z1jz1gz49z1kz1az21z4az19z27z22z1cz1mz24z1cz20z21z1cz18z4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz18z1jz1gz24z18z49z1kz1az21z4az19z27z22z1cz1mz24z1cz20z21z1cz18z4az1az1mz1k"},F={va:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",in:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},K={sg:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z49z21z1ez4az22z1gz1iz22z1mz1iz24z4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z49z24z18z4az22z1gz1iz22z1mz1iz24z4az1az1mz1k",in:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z49z24z18z49z23z21z1cz18z21z22z4ez18z4az22z1gz1iz22z1mz1iz24z4az1az1mz1k"},q={sg:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az23z21z4az22z1gz1iz22z1mz1iz24z4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az23z21z4az22z1gz1iz22z1mz1iz4az1az1mz1k"},i="5.0.36_oversea",H=function(){function e(e,t){this.collector=e,this.config=t,this.eventNameWhiteList=["__bav_page","__bav_beat","__bav_page_statistics","__bav_click","__bav_page_exposure"],this.paramsNameWhiteList=["$inactive","$inline","$target_uuid_list","$source_uuid","$is_spider","$source_id","$is_first_time","_staging_flag"],this.regStr=new RegExp("^[a-zA-Z0-9][a-z0-9A-Z_.-]{1,255}$")}return e.prototype.checkVerify=function(e){var t,r,o,n=this;return!!(e&&e.length&&(e=e[0])&&(t=e.events,r=e.header,t)&&t.length)&&(o=!0,t.forEach(function(e){e?(n.checkEventName(e.event)||(o=!1,e.checkEvent="事件名不能以 $ or __开头"),n.checkEventParams(e.params)||(o=!1,e.checkParams="属性名不能以 $ or __开头")):(o=!1,e.checkEvent="事件异常")}),o=!!this.checkEventParams(r)&&o)},e.prototype.checkEventName=function(e){return!!e&&this.calculate(e,"event")},e.prototype.checkEventParams=function(e){var t=e;if("string"==typeof e&&(t=JSON.parse(t)),Object.keys(t).length)for(var r in t)return!(!this.calculate(r,"params")||"string"==typeof t[r]&&1024<t[r].length&&(console.warn("params: "+r+" can not over 1024 byte, please check;"),1));return!0},e.prototype.calculate=function(e,t){return-1!==("event"===t?this.eventNameWhiteList:this.paramsNameWhiteList).indexOf(e)||!new RegExp("^\\$").test(e)&&!new RegExp("^__").test(e)||(console.warn(("event"===t?"event":"params")+" name: "+e+" can not start with $ or __, pleace check;"),!1)},e}(),c=(!function(e){e.Init="init",e.Config="config",e.Start="start",e.Ready="ready",e.TokenComplete="token-complete",e.TokenStorage="token-storage",e.TokenFetch="token-fetch",e.TokenError="token-error",e.ConfigUuid="config-uuid",e.ConfigWebId="config-webid",e.ConfigDomain="config-domain",e.CustomWebId="custom-webid",e.TokenChange="token-change",e.TokenReset="token-reset",e.ConfigTransform="config-transform",e.EnvTransform="env-transform",e.SessionReset="session-reset",e.SessionResetTime="session-reset-time",e.Event="event",e.Events="events",e.EventNow="event-now",e.CleanEvents="clean-events",e.BeconEvent="becon-event",e.SubmitBefore="submit-before",e.SubmitScuess="submit-scuess",e.SubmitAfter="submit-after",e.SubmitError="submit-error",e.SubmitVerify="submit-verify",e.Stay="stay",e.ResetStay="reset-stay",e.StayReady="stay-ready",e.SetStay="set-stay",e.RouteChange="route-change",e.RouteReady="route-ready",e.Ab="ab",e.AbVar="ab-var",e.AbAllVars="ab-all-vars",e.AbConfig="ab-config",e.AbExternalVersion="ab-external-version",e.AbVersionChangeOn="ab-version-change-on",e.AbVersionChangeOff="ab-version-change-off",e.AbOpenLayer="ab-open-layer",e.AbCloseLayer="ab-close-layer",e.AbReady="ab-ready",e.AbComplete="ab-complete",e.AbTimeout="ab-timeout",e.Profile="profile",e.ProfileSet="profile-set",e.ProfileSetOnce="profile-set-once",e.ProfileUnset="profile-unset",e.ProfileIncrement="profile-increment",e.ProfileAppend="profile-append",e.ProfileClear="profile-clear",e.Autotrack="autotrack",e.AutotrackReady="autotrack-ready",e.CepReady="cep-ready",e.TracerReady="tracer-ready",e.sessionRecord="session-record",e.SessionRecordStart="session-record-start",e.SessionRecordPause="session-record-pause",e.SessionRecordEnd="session-record-end",e.SessionRecordReport="session-record-report"}(_=_||{}),function(e){e.DEBUGGER_MESSAGE="debugger-message",e.DEBUGGER_MESSAGE_SDK="debugger-message-sdk",e.DEBUGGER_MESSAGE_FETCH="debugger-message-fetch",e.DEBUGGER_MESSAGE_FETCH_RESULT="debugger-message-fetch-result",e.DEBUGGER_MESSAGE_EVENT="debugger-message-event",e.DEVTOOL_WEB_READY="devtool-web-ready"}(f=f||{}),_),u=void 0,o=(new Date).getTimezoneOffset(),V=parseInt(""+-o/60,10),Q=60*o,$=function(){function t(e,t){this.is_first_time=!0,this.configPersist=!1,this.initConfig=t,this.collect=e;var r=new G(t.app_id,t.cookie_domain||"",t.cookie_expire||6048e5).init(),e=(this.eventCheck=new H(e,t),"__tea_cache_first_"+t.app_id),t=(this.configKey="__tea_cache_config_"+t.app_id,this.sessionStorage=new h(!1,"session"),this.localStorage=new h(!1,"local"),this.channelUrl="tcpy"===t.channel_type||"ttp"===t.channel_type?{WEBID_URL:"/v1/user/webid",TOB_URL:"",REPORT_URL:"/v1/list"}:{WEBID_URL:"/webid",TOB_URL:"/tobid",REPORT_URL:"/list"},t.configPersist&&(this.configPersist=!0,this.storage=1===t.configPersist?this.sessionStorage:this.localStorage),this.localStorage.getItem(e));t&&1==t?this.is_first_time=!1:(this.is_first_time=!0,this.localStorage.setItem(e,"1")),this.envInfo={user:{user_unique_id:u,user_type:u,user_id:u,user_is_auth:u,user_is_login:u,device_id:u,web_id:u,ip_addr_id:u,user_unique_id_type:u},header:{app_id:u,app_name:u,app_install_id:u,install_id:u,app_package:u,app_channel:u,app_version:u,ab_version:u,os_name:r.os_name,os_version:r.os_version,device_model:r.device_model,ab_client:u,traffic_type:u,client_ip:u,device_brand:u,os_api:u,access:u,language:r.language,region:u,app_language:u,app_region:u,creative_id:r.utm.creative_id,ad_id:r.utm.ad_id,campaign_id:r.utm.campaign_id,log_type:u,rnd:u,platform:r.platform,sdk_version:i,sdk_lib:"js",province:u,city:u,timezone:V,tz_offset:Q,tz_name:u,sim_region:u,carrier:u,resolution:r.screen_width+"x"+r.screen_height,browser:r.browser,browser_version:r.browser_version,referrer:r.referrer,referrer_host:r.referrer_host,width:r.screen_width,height:r.screen_height,screen_width:r.screen_width,screen_height:r.screen_height,utm_term:r.utm.utm_term,utm_content:r.utm.utm_content,utm_source:r.utm.utm_source,utm_medium:r.utm.utm_medium,utm_campaign:r.utm.utm_campaign,tracer_data:JSON.stringify(r.utm.tracer_data),custom:{},wechat_unionid:u,wechat_openid:u}},this.ab_version="",this.ab_uuid_cache={},this.evtParams={},this.reportErrorCallback=function(){},this.isLast=!1,this.setCustom(r),this.initDomain(),this.initABData()}return t.prototype.initDomain=function(e){var t=this.initConfig.channel_domain;t?this.domain=t:(t=e||this.initConfig.channel,e=(this.initConfig&&this.initConfig.channel_type?"tcpy"===this.initConfig.channel_type?K:q:L)[t],this.domain=D(e))},t.prototype.setDomain=function(e){this.customDomain=!0,this.domain=e},t.prototype.getDomain=function(e){return this.customDomain||e&&this.initDomain(e),this.domain},t.prototype.initABData=function(){var e,t="__tea_sdk_ab_version_"+this.initConfig.app_id,r=null;r=this.initConfig.ab_cross?(e=this.localStorage.getCookie(t,this.initConfig.ab_cookie_domain))?JSON.parse(e):null:this.localStorage.getItem(t),this.setAbCache(r)},t.prototype.setAbCache=function(e){this.ab_cache=e},t.prototype.getAbCache=function(){return this.ab_cache},t.prototype.clearAbCache=function(){this.ab_cache={},this.ab_version=""},t.prototype.setAbVersion=function(e){this.ab_version=e},t.prototype.getAbVersion=function(){return this.ab_version},t.prototype.setAbUuidCache=function(e,t){t=t||this.envInfo.user.user_unique_id;this.ab_uuid_cache[""+t]||(this.ab_uuid_cache[""+t]=[]),-1===this.ab_uuid_cache[""+t].indexOf(e)&&this.ab_uuid_cache[""+t].push(e)},t.prototype.getAbUuidCache=function(e){return this.ab_uuid_cache[""+e]},t.prototype.getUrl=function(e){var t="";switch(e){case"event":t=this.initConfig.report_url||this.channelUrl.REPORT_URL;break;case"webid":t=this.channelUrl.WEBID_URL;break;case"tobid":t=this.channelUrl.TOB_URL}e="";return this.initConfig.caller&&(e="?sdk_version="+i+"&sdk_name=web&app_id="+this.initConfig.app_id+"&caller="+this.initConfig.caller),""+this.getDomain()+t+e},t.prototype.setCustom=function(e){if(e&&e.latest_data&&e.latest_data.isLast)for(var t in delete e.latest_data.isLast,this.isLast=!0,e.latest_data)this.envInfo.header.custom[t]=e.latest_data[t]},t.prototype.set=function(n){var i=this;Object.keys(n).forEach(function(e){void 0!==n[e]&&null!==n[e]||i.delete(e);try{i.eventCheck.calculate(e,"config")}catch(e){}var t,r,o;"traffic_type"===e&&i.isLast&&(i.envInfo.header.custom.$latest_traffic_source_type=n[e]),"evtParams"===e?i.evtParams=l({},i.evtParams||{},n.evtParams||{}):"_staging_flag"===e?i.evtParams=l({},i.evtParams||{},{_staging_flag:n._staging_flag}):"reportErrorCallback"===e&&"function"==typeof n[e]?i.reportErrorCallback=n[e]:(o=r="",-1<e.indexOf(".")&&(r=(t=e.split("."))[0],o=t[1]),r?"user"===r||"header"===r?i.envInfo[r][o]=n[e]:i.envInfo.header.custom[o]=n[e]:Object.hasOwnProperty.call(i.envInfo.user,e)?-1<["user_type","ip_addr_id"].indexOf(e)?i.envInfo.user[e]=n[e]&&Number(n[e]):-1<["user_id","web_id","user_unique_id","user_unique_id_type"].indexOf(e)?i.envInfo.user[e]=n[e]&&String(n[e]):-1<["user_is_auth","user_is_login"].indexOf(e)?i.envInfo.user[e]=Boolean(n[e]):"device_id"===e&&(i.envInfo.user[e]=n[e]):Object.hasOwnProperty.call(i.envInfo.header,e)?i.envInfo.header[e]=n[e]:i.envInfo.header.custom[e]=n[e])})},t.prototype.get=function(e){try{return e?"evtParams"===e?this.evtParams:"reportErrorCallback"===e?this[e]:Object.hasOwnProperty.call(this.envInfo.user,e)?this.envInfo.user[e]:Object.hasOwnProperty.call(this.envInfo.header,e)?this.envInfo.header[e]:JSON.parse(JSON.stringify(this.envInfo[e])):JSON.parse(JSON.stringify(this.envInfo))}catch(e){console.log("get config stringify error "),this.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message})}},t.prototype.setStore=function(e){try{var t,r;this.configPersist&&(t=this.storage.getItem(this.configKey)||{})&&Object.keys(e).length&&(r=_extends(e,t),this.storage.setItem(this.configKey,r))}catch(e){console.log("setStore error"),this.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message})}},t.prototype.getStore=function(){try{var e;return this.configPersist?(e=this.storage.getItem(this.configKey)||{})&&Object.keys(e).length?e:null:null}catch(e){return this.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message}),null}},t.prototype.delete=function(e){try{var t;this.configPersist&&(t=this.storage.getItem(this.configKey)||{})&&Object.hasOwnProperty.call(t,e)&&(delete t[e],this.storage.setItem(this.configKey,t))}catch(e){this.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message}),console.log("delete error")}},t}(),X=function(){function e(e,t){this.isLog=t||!1,this.name=e||""}return e.prototype.info=function(e){this.isLog&&console.log("%c %s","color: yellow; background-color: black;","[instance: "+this.name+"] "+e)},e.prototype.warn=function(e){this.isLog&&console.warn("[instance: "+this.name+"] "+e)},e.prototype.error=function(e){this.isLog&&console.error("[instance: "+this.name+"] "+e)},e.prototype.throw=function(e){throw this.error(this.name),new Error(e)},e}(),Z=function(){function e(){this.spiderBot=["Baiduspider","googlebot","360Spider","haosouspider","YoudaoBot","Sogou News Spider","Yisouspider","Googlebot","Headless","Applebot","Bingbot","PetalBot"]}return e.prototype.checkSpider=function(e){var t,r;return!!e.enable_spider&&(!(t=window.navigator.userAgent)||(r=!1,this.spiderBot.forEach(function(e){-1!==t.indexOf(e)&&(r=!0)}),r))},e}(),Y=function(){function e(e,t){this.collect=e,this.native=t}var t=e.prototype;return t.bridgeInject=function(){try{return!!this.native&&(AppLogBridge?(console.log("AppLogBridge is injected"),!0):(console.log("AppLogBridge is not inject"),!1))}catch(e){return console.log("AppLogBridge is not inject"),!1}},t.bridgeReady=function(){var e=this;return new Promise(function(t,r){try{e.bridgeInject()?AppLogBridge.hasStarted(function(e){console.log("AppLogBridge is started? : "+e),e?t(!0):r(!1)}):r(!1)}catch(e){console.log("AppLogBridge, error:"+JSON.stringify(e.stack)),r(!1)}})},t.setNativeAppId=function(e){try{AppLogBridge.setNativeAppId(JSON.stringify(e)),console.log("change bridge appid, event report with appid: "+e)}catch(e){console.error("setNativeAppId error")}},t.setConfig=function(t){var r=this;try{Object.keys(t).forEach(function(e){"user_unique_id"===e?r.setUserUniqueId(t[e]):t[e]?r.addHeaderInfo(e,t[e]):r.removeHeaderInfo(e)})}catch(t){console.error("setConfig error")}},t.setUserUniqueId=function(e){try{AppLogBridge.setUserUniqueId(e)}catch(e){console.error("setUserUniqueId error")}},t.addHeaderInfo=function(e,t){try{AppLogBridge.addHeaderInfo(e,t)}catch(e){console.error("addHeaderInfo error")}},t.setHeaderInfo=function(e){try{AppLogBridge.setHeaderInfo(JSON.stringify(e))}catch(e){console.error("setHeaderInfo error")}},t.removeHeaderInfo=function(e){try{AppLogBridge.removeHeaderInfo(e)}catch(e){console.error("removeHeaderInfo error")}},t.reportPv=function(e){this.onEventV3("predefine_pageview",e)},t.onEventV3=function(e,t){try{AppLogBridge.onEventV3(e,t),this.collect.emit(DebuggerMesssge.DEBUGGER_MESSAGE,{type:DebuggerMesssge.DEBUGGER_MESSAGE_EVENT,info:"bridge埋点上报",time:Date.now(),data:[{events:[{event:e,params:t}]}],code:200,status:"success"})}catch(e){console.error("onEventV3 error")}},t.profileSet=function(e){try{AppLogBridge.profileSet(e)}catch(e){console.error("profileSet error")}},t.profileSetOnce=function(e){try{AppLogBridge.profileSetOnce(e)}catch(e){console.error("profileSetOnce error")}},t.profileIncrement=function(e){try{AppLogBridge.profileIncrement(e)}catch(e){console.error("profileIncrement error")}},t.profileUnset=function(e){try{AppLogBridge.profileUnset(e)}catch(e){console.error("profileUnset error")}},t.profileAppend=function(e){try{AppLogBridge.profileAppend(e)}catch(e){console.error("profileAppend error")}},e}(),ee={NO_URL:4001,IMG_ON:4e3,IMG_CATCH:4002,BEACON_FALSE:4003,XHR_ON:500,RESPONSE:5001,TIMEOUT:5005};function j(e,r,t,o,n,i,s,a,c){try{var u=new XMLHttpRequest,l=a||"POST";u.open(l,""+e,!0),u.setRequestHeader("Content-Type","application/json; charset=utf-8"),s&&u.setRequestHeader("X-MCS-AppKey",""+s),o&&(u.withCredentials=!0),u.onload=function(){if(n){var t=null;if(u.responseText){try{t=JSON.parse(u.responseText)}catch(e){t={}}n(t,r)}}},t&&(u.timeout=t,u.ontimeout=function(){i&&i(r,ee.TIMEOUT)}),u.onerror=function(){u.abort(),i&&i(r,ee.XHR_ON)},c?u.send(r):u.send(JSON.stringify(r))}catch(e){}}var te=4001,re=4e3,oe=4002,ne=function W(r,o,n,i){try{var e=r.match(/\/v\d\//),t=e?e[0]:-1!==r.indexOf("/v1/")?"/v1/":"/v2/",s=r.split(t)[0];s?o.forEach(function(e){var e=function(e){var t,r="";for(t in e)e.hasOwnProperty(t)&&void 0!==e[t]&&(r+="&"+t+"="+encodeURIComponent(JSON.stringify(e[t])));return"&"===r[0]?r.slice(1):r}(e),t=new Image(1,1);t.onload=function(){t=null,n&&n()},t.onerror=function(){t=null,i&&i(r,o,re)},t.src=s+"/gif?"+e}):i(r,o,te)}catch(n){i&&i(r,o,oe,n.message)}},ie=function J(e,t,r,o,n,i,s,a){var c=window.navigator.userAgent;if(-1===window.navigator.appName.indexOf("Microsoft Internet Explorer")||-1===c.indexOf("MSIE 8.0")&&-1===c.indexOf("MSIE 9.0")){if(s)return window.navigator&&window.navigator.sendBeacon?void(window.navigator.sendBeacon(e,JSON.stringify(t))?n():i(e,t,4003)):void ne(e,t,n,i)}else ne(e,t,n,i);j(e,t,r,o,n,i,"","",a)},se=function(){function t(){this.eventLimit=50,this.enable_ttwebid=!1,this.eventCache=[],this.beconEventCache=[]}return t.prototype.apply=function(e,t){var r=this;this.collect=e,this.config=t,this.configManager=e.configManager,this.eventCheck=new H(e,t),this.cacheStorgae=new h(!0),this.localStorage=new h(!1),this.maxReport=t.max_report||10,this.reportTime=t.reportTime||30,this.timeout=t.timeout||1e5,this.enable_ttwebid=t.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(c.Ready,function(){r.reportAll(!1)}),this.collect.on(c.ConfigDomain,function(){r.reportUrl=r.configManager.getUrl("event")}),this.collect.on(c.Event,function(e){r.event(e)}),this.collect.on(c.BeconEvent,function(e){r.beconEvent(e)}),this.collect.on(c.CleanEvents,function(){r.reportAll(!1)}),this.linster()},t.prototype.linster=function(){var e=this;window.addEventListener("unload",function(){e.reportAll(!0)},!1),function(e){navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)?window.addEventListener("pagehide",e,!1):window.addEventListener("beforeunload",e,!1)}(function(){e.reportAll(!0)}),document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&e.reportAll(!0)},!1)},t.prototype.reportAll=function(e){this.report(e),this.reportBecon()},t.prototype.event=function(e){var t=this;try{var r,o=index_base_min_i(e,this.cacheStorgae.getItem(this.eventKey)||[]);this.cacheStorgae.setItem(this.eventKey,o),this.reportTimeout&&clearTimeout(this.reportTimeout),o.length>=this.maxReport?this.report(!1):(r=this.reportTime,this.reportTimeout=setTimeout(function(){t.report(!1),t.reportTimeout=null},r))}catch(e){this.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message})}},t.prototype.beconEvent=function(e){e=index_base_min_i(e,this.cacheStorgae.getItem(this.beconKey)||[]);this.cacheStorgae.setItem(this.beconKey,e),this.collect.destroyInstance||this.collect.tokenManager.getReady()&&this.collect.sdkReady&&(this.cacheStorgae.removeItem(this.beconKey),this.send(this.split(this.merge(e)),!0))},t.prototype.reportBecon=function(){var e;!this.collect.destroyInstance&&this.collect.tokenManager.getReady()&&this.collect.sdkReady&&(e=this.cacheStorgae.getItem(this.beconKey)||[])&&e.length&&(this.cacheStorgae.removeItem(this.beconKey),this.send(this.split(this.merge(e)),!0))},t.prototype.report=function(e){var t;!this.collect.destroyInstance&&this.collect.tokenManager.getReady()&&this.collect.sdkReady&&(t=this.cacheStorgae.getItem(this.eventKey)||[]).length&&(this.cacheStorgae.removeItem(this.eventKey),this.sliceEvent(t,e))},t.prototype.sliceEvent=function(e,t){if(e.length>this.eventLimit)for(var r=0;r<e.length;r+=this.eventLimit){var o=e.slice(r,r+this.eventLimit),n=this.split(this.merge(o));this.send(n,t)}else n=this.split(this.merge(e)),this.send(n,t)},t.prototype.merge=function(e,i){var s=this,t=this.configManager.get(),r=t.header,a=t.user,c=(r.custom=JSON.stringify(r.custom),this.configManager.get("evtParams")),u=this.configManager.get("user_unique_id_type"),t=e.map(function(t){try{Object.keys(c).length&&!i&&(t.params=l({},c,t.params)),u&&(t.params.$user_unique_id_type=u);var e,r,o=s.configManager.getAbCache(),n=s.configManager.getAbUuidCache(a.user_unique_id);return o&&o.uuid&&o.uuid===a.user_unique_id&&(e=s.configManager.getAbVersion(),s.config.enable_ab_uuid?n&&n.length&&(r=n.join(","),e)&&e.includes(r)&&(t.ab_sdk_version=e):e&&(t.ab_sdk_version=e)),t.session_id=s.collect.sessionManager.getSessionId(),t.params=JSON.stringify(t.params),t}catch(e){return s.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message}),t}}),e=JSON.parse(JSON.stringify({events:t,user:a,header:r})),t=(e.local_time=Math.floor(Date.now()/1e3),e.user_unique_type=this.config.enable_ttwebid?this.config.user_unique_type:void 0,e.verbose=1,[]);return t.push(e),t},t.prototype.split=function(e){return e.map(function(e){var t=[];return t.push(e),t})},t.prototype.send=function(e,n){var i=this;e.length&&!this.config.disable_track_event&&e.forEach(function(e){try{var t=JSON.parse(JSON.stringify(e)),r=(i.config.filter&&!(t=i.config.filter(t))&&console.warn("filter must return data !!"),i.collect.eventFilter&&t&&((t=i.collect.eventFilter(t))||console.warn("filterEvent api must return data !!")),t||e),o=JSON.parse(JSON.stringify(r));i.eventCheck.checkVerify(o),r.length&&(i.collect.emit(c.SubmitBefore,r),i.collect.emit(c.SubmitVerify,r),ie(i.reportUrl,r,i.timeout,i.enable_ttwebid,function(e,t){e&&0!==e.e?(i.collect.emit(c.SubmitError,{type:"f_data",eventData:t,errorCode:e.e,response:e}),i.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_EVENT,info:"埋点上报失败",time:Date.now(),data:o,code:e.e,failType:"数据异常",status:"fail"})):(i.collect.emit(c.SubmitScuess,{eventData:t,res:e}),i.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:o,code:200,status:"success"}))},function(e,t){i.configManager.get("reportErrorCallback")(e,t),i.collect.emit(c.SubmitError,{type:"f_net",eventData:e,errorCode:t}),i.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_EVENT,info:"埋点上报网络异常",time:Date.now(),data:o,code:t,failType:"网络异常",status:"fail"})},n,!1),i.collect.emit(c.SubmitAfter,r))}catch(e){console.warn("something error, "+JSON.stringify(e.stack)),i.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message})}})},t}(),ae=function $(){return function e(t){return t?(t^16*Math.random()>>t/4).toString(10):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e)}().replace(/-/g,"").slice(0,19)},ce=function(){function e(){this.cacheToken={},this.enableCookie=!1,this.enable_ttwebid=!1,this.enableCustomWebid=!1}return e.prototype.apply=function(e,t){var r=this;this.collect=e,this.config=t,this.configManager=this.collect.configManager,this.storage=new h(!1),this.tokenKey="__tea_cache_tokens_"+t.app_id,this.enable_ttwebid=t.enable_ttwebid,this.enableCustomWebid=t.enable_custom_webid,this.collect.on(c.ConfigUuid,function(e){r.setUuid(e)}),this.collect.on(c.ConfigWebId,function(e){r.setWebId(e)}),this.enableCookie=t.cross_subdomain,this.expiresTime=t.cookie_expire||6048e5,this.cookieDomain=t.cookie_domain||"",this.checkStorage()},e.prototype.checkStorage=function(){var e,t=this;this.enableCookie?(e=this.storage.getCookie(this.tokenKey,this.cookieDomain),this.cacheToken=e&&"string"==typeof e?JSON.parse(e):{}):this.cacheToken=this.storage.getItem(this.tokenKey)||{},this.tokenType=this.cacheToken&&this.cacheToken._type_?this.cacheToken._type_:"default","custom"!==this.tokenType||this.enableCustomWebid?this.enableCustomWebid?this.collect.on(c.CustomWebId,function(){t.tokenReady=!0,t.collect.emit(c.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:ae(),user_unique_id:this.configManager.get("user_unique_id")||ae()}):this.remoteWebid()},e.prototype.checkEnv=function(){var e=window.navigator.userAgent;return(-1!==e.indexOf("miniProgram")||-1!==e.indexOf("MiniProgram"))&&!(!(e=a(window.location.href))||!e.Web_ID||(this.complete({web_id:""+e.Web_ID,user_unique_id:this.configManager.get("user_unique_id")||""+e.Web_ID}),0))},e.prototype.remoteWebid=function(){var r=this,e=this.configManager.getUrl("webid"),t={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:""},o=(this.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"SDK 发起WEBID请求",logType:"fetch",level:"info",time:Date.now(),data:t}),ae());j(e,t,3e5,!1,function(e){var t;e&&0===e.e?(t=e.web_id,r.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"WEBID请求成功",logType:"fetch",level:"info",time:Date.now(),data:e})):(r.collect.configManager.set({localWebId:t=o}),r.collect.emit(c.TokenError),r.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"WEBID请求返回值异常",logType:"fetch",level:"warn",time:Date.now(),data:e}),r.collect.logger.warn("appid: "+r.config.app_id+" get webid error, use local webid~")),r.complete({web_id:r.configManager.get("web_id")||t,user_unique_id:r.configManager.get("user_unique_id")||t})},function(){r.complete({web_id:r.configManager.get("web_id")||o,user_unique_id:r.configManager.get("user_unique_id")||o}),r.collect.configManager.set({localWebId:o}),r.collect.emit(c.TokenError),r.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"WEBID请求网络异常",logType:"fetch",level:"error",time:Date.now(),data:null}),r.collect.logger.warn("appid: "+r.config.app_id+", get webid error, use local webid~")})},e.prototype.complete=function(e){var t=e.web_id,r=e.user_unique_id;e.timestamp=Date.now(),this.collect.configManager.set({web_id:t,user_unique_id:r}),this.setStorage(e),this.tokenReady=!0,this.collect.emit(c.TokenComplete)},e.prototype.completeTtWid=function(e){var t=e.user_unique_id||"",r=this.configManager.get("user_unique_id");(r||t)&&this.configManager.set({user_unique_id:r||t}),this.setStorage(e),this.tokenReady=!0,this.collect.emit(c.TokenComplete)},e.prototype.setUuid=function(e){var t,r;e&&-1===["null","undefined","Null","None"].indexOf(e)?(e=String(e),t=this.configManager.get("user_unique_id"),r=this.cacheToken&&this.cacheToken.user_unique_id,e===t&&e===r||(this.configManager.set({user_unique_id:e}),this.cacheToken||(this.cacheToken={}),this.cacheToken.user_unique_id=e,this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken),this.collect.emit(c.TokenChange,"uuid"),this.collect.emit(c.SessionReset))):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(c.TokenReset))},e.prototype.setWebId=function(e){var t,r;e&&!this.config.enable_ttwebid&&(this.cacheToken&&this.cacheToken.web_id?this.cacheToken.web_id!==e&&(this.cacheToken.user_unique_id=this.cacheToken.web_id===this.cacheToken.user_unique_id?e:this.cacheToken.user_unique_id,this.cacheToken.web_id=e):(this.cacheToken={},this.cacheToken.web_id=e,this.cacheToken.user_unique_id=e),this.cacheToken.timestamp=Date.now(),t=this.configManager.get("web_id"),(r=this.configManager.get("user_unique_id"))&&r!==t||(this.configManager.set({user_unique_id:e}),this.collect.emit(c.TokenChange,"uuid")),t!==e&&(this.configManager.set({web_id:e}),this.collect.emit(c.TokenChange,"webid")),this.setStorage(this.cacheToken))},e.prototype.setStorage=function(e){e._type_=this.enableCustomWebid?"custom":"default",delete e["diss".split("").reverse().join("")],this.enableCookie||this.enable_ttwebid?(this.storage.setCookie(this.tokenKey,e,this.expiresTime,this.cookieDomain),this.enable_ttwebid&&(delete e.web_id,this.storage.setItem(this.tokenKey,e))):this.storage.setItem(this.tokenKey,e),this.cacheToken=e},e.prototype.getReady=function(){return this.tokenReady},e.prototype.getTobId=function(){var e=this,r=this.configManager.getUrl("tobid");return new Promise(function(t){j(r,{app_id:e.config.app_id,user_unique_id:e.configManager.get("user_unique_id"),web_id:e.configManager.get("web_id"),user_unique_id_type:e.configManager.get("user_unique_id_type")},3e4,e.enable_ttwebid,function(e){e&&0===e.e?t(e.tobid):t("")},function(){t("")})})},e}(),y=function X(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},ue=function(){function e(){}return e.prototype.apply=function(e,t){var r=this;this.collect=e,this.storage=new h(!1,"session"),this.sessionKey="__tea_session_id_"+t.app_id,this.expireTime=t.expireTime||18e5,this.disableSession=t.disable_session,this.disableSession||(this.setSessionId(),this.collect.on(c.SessionReset,function(){r.resetSessionId()}),this.collect.on(c.SessionResetTime,function(){r.updateSessionIdTime()}))},e.prototype.updateSessionIdTime=function(){var e,t=this.storage.getItem(this.sessionKey);t&&t.sessionId&&(e=t.timestamp,Date.now()-e>this.expireTime?t={sessionId:y(),timestamp:Date.now()}:t.timestamp=Date.now(),this.storage.setItem(this.sessionKey,t),this.resetExpTime())},e.prototype.setSessionId=function(){var e=this,t=this.storage.getItem(this.sessionKey);t&&t.sessionId?t.timestamp=Date.now():t={sessionId:y(),timestamp:Date.now()},this.storage.setItem(this.sessionKey,t),this.sessionExp=setInterval(function(){e.checkEXp()},this.expireTime)},e.prototype.getSessionId=function(){var e=this.storage.getItem(this.sessionKey);return!this.disableSession&&e&&e.sessionId?e.sessionId:""},e.prototype.resetExpTime=function(){var e=this;this.sessionExp&&(clearInterval(this.sessionExp),this.sessionExp=setInterval(function(){e.checkEXp()},this.expireTime))},e.prototype.resetSessionId=function(){var e={sessionId:y(),timestamp:Date.now()};this.storage.setItem(this.sessionKey,e)},e.prototype.checkEXp=function(){var e=this.storage.getItem(this.sessionKey);e&&e.sessionId&&Date.now()-e.timestamp+30>=this.expireTime&&(e={sessionId:y(),timestamp:Date.now()},this.storage.setItem(this.sessionKey,e))},e}(),le=function(){function e(e,t){this.devToolReady=!1,this.devToolOrigin="*",this.sendAlready=!1,this.collect=e,this.config=t,this.app_id=t.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"],t.enable_debug&&this.load()}return e.prototype.loadScript=function(e){try{var t=document.createElement("script");t.src=e,t.onerror=function(){console.log("load DevTool render fail")},t.onload=function(){console.log("load DevTool render success")},document.getElementsByTagName("body")[0].appendChild(t)}catch(e){console.log("devTool load fail, "+e.message)}},e.prototype.load=function(){try{this.loadBaseInfo(),this.loadHook();var e=a(window.location.href);e.open_devtool_web&&parseInt(e.app_id)===this.app_id&&(this.addLintener(),this.loadDebuggerModule(),this.loadDevTool())}catch(e){console.log("debug fail, "+e.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 e=this;this.info=[{title:"基本信息",type:1,infoName:{app_id:this.config.app_id,channel:this.config.channel,"上报域名":this.collect.configManager.getDomain(),"SDK版本":i,"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(c.Ready,function(){e.info[1].infoName.uuid=e.collect.configManager.get("user").user_unique_id,e.info[1].infoName.web_id=e.collect.configManager.get("user").web_id,e.info[2].infoName["自定义信息"]=JSON.stringify(e.collect.configManager.get("custom")),e.config.enable_ab_test&&(e.info[4].infoName["已曝光VID"]=e.collect.configManager.getAbVersion(),e.info[4].infoName["A/B域名"]=e.config.ab_channel_domain||D(F[e.config.channel]),e.info[4].infoName["全部配置"]=e.collect.configManager.getAbData()),e.config.Native&&(e.info[5].infoName["是否打通"]=!!e.collect.bridgeReport)})},e.prototype.loadHook=function(){var o=this;this.collect.on(f.DEBUGGER_MESSAGE,function(t){switch(t.type){case f.DEBUGGER_MESSAGE_SDK:var e={time:t.time,type:t.logType||"sdk",level:t.level,name:t.info,show:!0,levelShow:!0,needDesc:!!t.data};return t.data&&(e.desc={content:JSON.stringify(t.data)}),o.updateLog(e),t.secType&&"AB"===t.secType?(o.info[4].infoName["已曝光VID"]=o.collect.configManager.getAbVersion(),o.info[4].infoName["全部配置"]=o.collect.configManager.getAbData()):"USER"===t.secType&&(o.info[1].infoName.uuid=o.collect.configManager.get("user").user_unique_id,o.info[1].infoName.web_id=o.collect.configManager.get("user").web_id),void o.updateInfo();case f.DEBUGGER_MESSAGE_EVENT:if(t.data&&t.data.length){var e=t.data[0],r=e.events;if(!r.length)return;r.forEach(function(e){e.checkShow=!0,e.searchShow=!0,e.success=t.status,e.type=-1!==o.filterEvent.indexOf(e.event)?"sdk":"cus",e.type=o.collect.bridgeReport?"bridge":e.type,e.info="","fail"===t.status&&(e.info={message:"code: "+t.code+", msg: "+t.failType})}),o.updateEvent(e)}return}})},e.prototype.addLintener=function(){var t=this;window.addEventListener("message",function(e){if(e.origin===location.origin){if(e&&e.data&&"devtool:web:ready"===e.data.type){if(t.devToolOrigin=e.origin,t.devToolReady=!0,t.sendAlready)return;console.log("inittttt"),t.sendData("devtool:web:init",{info:t.info,log:t.log,event:t.event}),t.sendAlready=!0}e&&e.data&&"devtool:web:ssid"===e.data.type&&t.collect.getToken(function(e){t.info[1].infoName.ssid=e.tobid,t.updateInfo()})}})},e.prototype.sendData=function(e,t){try{var r={type:e,payload:t};(window.opener||window.parent).postMessage(r,this.devToolOrigin)}catch(e){}},e.prototype.updateInfo=function(){this.devToolReady&&this.sendData("devtool:web:info",this.info)},e.prototype.updateLog=function(e){this.devToolReady?this.sendData("devtool:web:log",e):this.log.push(e)},e.prototype.updateEvent=function(e){this.devToolReady?this.sendData("devtool:web:event",e):this.event.push(e)},e.prototype.loadDebuggerModule=function(){var e=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style"),e=(t.appendChild(document.createTextNode("#debugger-applog-web {\n position: 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 }")),e.appendChild(t),document.createElement("div")),t=(e.innerHTML='<div id="debugger-applog-web" class="debugger-applog-web">AppLog调试</div>',document.createElement("div"));t.innerHTML='<div id="debugger-container" class="debugger-container"></div>',document.getElementsByTagName("body")[0].appendChild(e),document.getElementsByTagName("body")[0].appendChild(t),document.getElementById("debugger-applog-web").addEventListener("click",function(){(window.opener||window.parent).postMessage({type:"devtool:web:open-draw"},location.origin)})},e}(),_=function(){function t(e){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=e,this.hook=new C,this.remotePlugin=new Map,this.Types=c,this.adapters.fetch=j,this.adapters.storage=h}return t.usePlugin=function(e,r,o){if(r){for(var n=!1,i=0,s=t.plugins.length;i<s;i++)if(t.plugins[i].name===r){t.plugins[i].plugin=e,t.plugins[i].options=o||{},n=!0;break}n||t.plugins.push({name:r,plugin:e,options:o})}else t.plugins.push({plugin:e})},t.prototype.usePlugin=function(e,t,r){e&&("full"===this.loadType&&this.remotePlugin.get(e)?console.info("your sdk version has "+e+" already ~"):t?"string"==typeof t?this.remotePlugin.get(e)||this.remotePlugin.set(e,{src:t,call:r}):this.remotePlugin.get(e)||this.remotePlugin.set(e,{instance:t}):this.remotePlugin.get(e)||this.remotePlugin.set(e,"sdk"))},t.prototype.init=function(r){var e,o=this;this.logger=new X(this.name,r.log),this.inited?this.logger.warn("[instance: "+this.name+"], every instance's api: init, can be call only one time!"):r&&P(r)?r.app_id&&"number"==typeof(e=r.app_id)&&!isNaN(e)?r.app_key&&"string"!=typeof r.app_key?this.logger.warn("app_key param is error, must be string, please check!"):(e=r.channel_type&&"tcpy"===r.channel_type?["sg","va","in"]:["sg","va"],r.channel_domain||-1!==e.indexOf(r.channel)||(this.logger.warn("channel must "+e.join(" ,")+"!!!"),r.channel="sg"),this.spider=new Z,this.spider.checkSpider(r)?this.logger.warn("The current environment may be a spider, can not report!"):(this.logger=new X(this.name,r.log),this.appBridge=new Y(this,r.enable_native),this.bridgeReport=this.appBridge.bridgeInject(),this.configManager=new $(this,r),this.debugger=new le(this,r),this.initConfig=r,this.emit(c.Init),this.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"SDK 执行INIT",data:r,level:"info",time:Date.now()}),r.disable_auto_pv&&(this.disableAutoPageView=!0),this.bridgeReport||(this.configManager.set({app_id:r.app_id}),this.eventManager=new se,this.tokenManager=new ce,this.sessionManager=new ue,Promise.all([new Promise(function(e){o.once(c.TokenComplete,function(){e(!0)})}),new Promise(function(e){o.once(c.Start,function(){e(!0)})})]).then(function(){try{t.plugins.reduce(function(e,t){var r=t.plugin,t=t.options,t=_extends(o.initConfig,t),r=new r;return r.apply(o,t),e.push(r),e},o.pluginInstances)}catch(e){o.logger.log("load plugin error, "+e.message),o.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message})}o.sdkReady=!0,o.emit(c.Ready),o.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"SDK 初始化完成",time:Date.now(),level:"info",data:o.configManager.get("user")}),o.logger.info("appid: "+r.app_id+", userInfo:"+JSON.stringify(o.configManager.get("user"))),o.logger.info("appid: "+r.app_id+", sdk is ready, version is "+i+", you can report now !!!"),r.disable_auto_pv&&(o.disableAutoPageView=!0);try{("full"===o.loadType&&r.enable_ab_test||r.autotrack)&&(window.opener||window.parent).postMessage("[tea-sdk]ready","*")}catch(e){o.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message})}o.pageView(),o.on(c.TokenChange,function(e){"webid"===e&&o.pageView(),o.logger.info("appid: "+r.app_id+" token change, new userInfo:"+JSON.stringify(o.configManager.get("user"))),o.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"SDK 设置了用户信息",time:Date.now(),secType:"USER",level:"info",data:o.configManager.get("user")})}),o.on(c.TokenReset,function(){o.logger.info("appid: "+r.app_id+" token reset, new userInfo:"+JSON.stringify(o.configManager.get("user"))),o.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"SDK 重置了用户信息",time:Date.now(),secType:"USER",level:"info",data:o.configManager.get("user")})}),o.on(c.RouteChange,function(e){e.init||r.disable_route_report||o.pageView()})}),this.tokenManager.apply(this,r),this.eventManager.apply(this,r),this.sessionManager.apply(this,r)),this.inited=!0)):this.logger.warn("app_id param is error, must be number, please check!"):this.logger.warn("init params error,please check")},t.prototype.config=function(e){var t,r;this.inited?e&&P(e)?this.bridgeReport?this.appBridge.setConfig(e):(e._staging_flag&&1===e._staging_flag&&(this.staging=!0),e.disable_auto_pv&&(this.disableAutoPageView=!0,delete e.disable_auto_pv),t=l({},e),this.initConfig&&this.initConfig.configPersist&&((r=this.configManager.getStore())&&(t=_extends(r,e)),this.configManager.setStore(e)),t.web_id,t.user_unique_id,r=function(e,t){var r={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&(r[n[o]]=e[n[o]]);return r}(t,["web_id","user_unique_id"]),t.hasOwnProperty("web_id")&&this.emit(c.ConfigWebId,t.web_id),t.hasOwnProperty("user_unique_id")&&this.emit(c.ConfigUuid,t.user_unique_id),this.configManager.set(r),this.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"SDK 执行CONFIG",level:"info",time:Date.now(),data:t})):this.logger.warn("config params is error, please check"):this.logger.warn("config must be use after function init")},t.prototype.setDomain=function(e){this.configManager&&this.configManager.setDomain(e),this.emit(c.ConfigDomain)},t.prototype.getConfig=function(e){return this.configManager.get(e)},t.prototype.send=function(){this.start()},t.prototype.start=function(){this.inited&&!this.sended&&(this.sended=!0,this.emit(c.Start),this.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"SDK 执行START",level:"info",time:Date.now()}),this.bridgeReport)&&(this.pageView(),this.emit(c.Ready))},t.prototype.event=function(e,t){var r=this;try{var o=[];if(Array.isArray(e))e.forEach(function(e){e=r.processEvent(e[0],e[1]||{});e&&o.push(e)});else{var n=this.processEvent(e,t);if(!n)return;o.push(n)}this.bridgeReport?o.forEach(function(e){var t=e.event,e=e.params;r.appBridge.onEventV3(t,JSON.stringify(e))}):o.length&&(this.emit(c.Event,o),this.emit(c.SessionResetTime))}catch(e){this.logger.warn("something error, please check"),this.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message})}},t.prototype.beconEvent=function(e,t){var r;Array.isArray(e)?this.logger.warn("beconEvent not support batch report, please check"):(r=[],(e=this.processEvent(e,t||{}))&&(r.push(e),r.length)&&(this.emit(c.BeconEvent,r),this.emit(c.SessionResetTime)))},t.prototype.processEvent=function(e,t){void 0===t&&(t={});try{var r,o,n;return e?(/^event\./.test(r=e)&&(r=e.slice(6)),n=void((o="object"!=_typeof(o=t)?{}:o).profile?delete o.profile:o.event_index=x+=1),o.local_ms?(n=o.local_ms,delete o.local_ms):n=+new Date,{event:r,params:o,local_time_ms:n,is_bav:this.initConfig&&this.initConfig.autotrack?1:0}):(this.logger.warn("eventName is null, please check"),null)}catch(r){return this.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:r.message}),{event:e,params:t}}},t.prototype.filterEvent=function(e){this.eventFilter=e},t.prototype.on=function(e,t){this.hook.on(e,t)},t.prototype.once=function(e,t){this.hook.once(e,t)},t.prototype.off=function(e,t){this.hook.off(e,t)},t.prototype.emit=function(e,t,r){this.hook.emit(e,t,r)},t.prototype.set=function(e){this.hook.set(e)},t.prototype.pageView=function(){this.disableAutoPageView||this.predefinePageView()},t.prototype.predefinePageView=function(e){var t;void 0===e&&(e={}),this.inited?(t={title:document.title||location.pathname,url:location.href,url_path:location.pathname,time:Date.now(),referrer:window.document.referrer,$is_first_time:""+(this.configManager&&this.configManager.is_first_time||!1)},t=l({},t,e),this.event("predefine_pageview",t)):this.logger.warn("predefinePageView should call after init")},t.prototype.clearEventCache=function(){this.emit(c.CleanEvents)},t.prototype.setWebIDviaUnionID=function(e){var t;e&&(t=I(e),this.config({web_id:""+t,wechat_unionid:e}),this.emit(c.CustomWebId))},t.prototype.setWebId=function(e){this.config({web_id:""+e})},t.prototype.setWebIDviaOpenID=function(e){var t;e&&(t=I(e),this.config({web_id:""+t,wechat_openid:e}),this.emit(c.CustomWebId))},t.prototype.setNativeAppId=function(e){this.bridgeReport&&this.appBridge.setNativeAppId(e)},t.prototype.resetStayDuration=function(e,t,r){this.emit(c.ResetStay,{url_path:e,title:t,url:r},c.Stay)},t.prototype.resetStayParams=function(e,t,r){this.emit(c.SetStay,{url_path:e=void 0===e?"":e,title:t=void 0===t?"":t,url:r=void 0===r?"":r},c.Stay)},t.prototype.getToken=function(t,e){var o,n,i,a=this;this.inited?(o=!1,n=function r(e){var r;if(!o)return o=!0,r=a.configManager.get().user,e&&(r.tobid=e,r["diss".split("").reverse().join("")]=e),t(l({},r))},i=function s(){a.tokenManager.getTobId().then(function(e){n(e)})},this.sdkReady?i():(e&&setTimeout(function(){n()},e),this.on(c.Ready,function(){i()}))):this.logger.warn("predefinePageView should call after init")},t.prototype.profileSet=function(e){this.bridgeReport?this.appBridge.profileSet(JSON.stringify(e)):this.emit(c.ProfileSet,e,c.Profile),this.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileSet",level:"info",time:Date.now(),data:e})},t.prototype.profileSetOnce=function(e){this.bridgeReport?this.appBridge.profileSetOnce(JSON.stringify(e)):this.emit(c.ProfileSetOnce,e,c.Profile),this.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileSetOnce",level:"info",time:Date.now(),data:e})},t.prototype.profileIncrement=function(e){this.bridgeReport?this.appBridge.profileIncrement(JSON.stringify(e)):this.emit(c.ProfileIncrement,e,c.Profile),this.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileIncrement",level:"info",time:Date.now(),data:e})},t.prototype.profileUnset=function(e){this.bridgeReport?this.appBridge.profileUnset(e):this.emit(c.ProfileUnset,e,c.Profile),this.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileUnset",level:"info",time:Date.now(),data:e})},t.prototype.profileAppend=function(e){this.bridgeReport?this.appBridge.profileAppend(JSON.stringify(e)):this.emit(c.ProfileAppend,e,c.Profile),this.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileAppend",level:"info",time:Date.now(),data:e})},t.prototype.setExternalAbVersion=function(e){this.emit(c.AbExternalVersion,"string"==typeof e&&e?(""+e).trim():null,c.Ab)},t.prototype.getVar=function(e,t,r,o){this.emit(c.AbVar,{name:e,defaultValue:t,callback:r,uuid:o},c.Ab)},t.prototype.getABconfig=function(e,t){this.emit(c.AbConfig,{params:e,callback:t},c.Ab)},t.prototype.getAbSdkVersion=function(){return this.configManager.getAbVersion()},t.prototype.onAbSdkVersionChange=function(e){var t=this;return this.emit(c.AbVersionChangeOn,e,c.Ab),function(){t.emit(c.AbVersionChangeOff,e,c.Ab)}},t.prototype.offAbSdkVersionChange=function(e){this.emit(c.AbVersionChangeOff,e,c.Ab)},t.prototype.openOverlayer=function(){this.emit(c.AbOpenLayer,"",c.Ab)},t.prototype.closeOverlayer=function(){this.emit(c.AbCloseLayer,"",c.Ab)},t.prototype.getAllVars=function(e){this.emit(c.AbAllVars,e,c.Ab)},t.prototype.autoInitializationRangers=function(e){var t=e.app_id,r=e.channel,o=e.onTokenReady,e=L[r]+"/webid",n=new h(!1),i="__tea_cache_tokens_"+t;(r=n.getItem(i))&&r.web_id?o(r.web_id):ie(e,{app_key:"",app_id:t,url:location.href,user_agent:window.navigator.userAgent,referer:document.referrer},3e3,!1,function(e){e&&0===e.e?(o(e.web_id),e={web_id:e.web_id,user_unique_id:e.web_id,timestamp:Date.now()},n.setItem(i,e)):o("")},function(){o("")},!0)},t.prototype.destoryInstace=function(){this.destroyInstance||(this.destroyInstance=!0,this.off(c.TokenComplete))},t.plugins=[],t}(),o=function(){function e(){}return e.prototype.apply=function(e,t){var r=this,o=e.adapters.fetch;t.event_verify_url&&("string"==typeof t.event_verify_url?(this.url=t.event_verify_url+"/v1/list_test",this.url&&(t=e.Types,e.on(t.SubmitBefore,function(e){o(r.url,e,3e4)}))):console.log("please use correct et_test url"))},e}(),pe=function(){function t(){}return t.prototype.apply=function(e,t){var r=this,o=(this.collect=e,this.config=t,this.duration=6e4,this.reportUrl=e.configManager.getDomain()+"/profile/list",e.Types),n=e.adapters.fetch;this.eventCheck=new H(e,t),this.fetch=n,this.cache={},this.collect.on(o.ProfileSet,function(e){r.setProfile(e)}),this.collect.on(o.ProfileSetOnce,function(e){r.setOnceProfile(e)}),this.collect.on(o.ProfileUnset,function(e){r.unsetProfile(e)}),this.collect.on(o.ProfileIncrement,function(e){r.incrementProfile(e)}),this.collect.on(o.ProfileAppend,function(e){r.appendProfile(e)}),this.collect.on(o.ProfileClear,function(){r.cache={}}),this.ready(o.Profile)},t.prototype.ready=function(e){var r=this;if(this.collect.set(e),this.collect.hook._hooksCache.hasOwnProperty(e)){var n=this.collect.hook._hooksCache[e];if(Object.keys(n).length){var t,i=function o(t){n[t].length&&n[t].forEach(function(e){r.collect.hook.emit(t,e)})};for(t in n)i(t)}}},t.prototype.report=function(e,t){void 0===t&&(t={});try{var r,o;this.config.disable_track_event||((r=[]).push(this.collect.processEvent(e,t)),o=this.collect.eventManager.merge(r),this.fetch(this.reportUrl,o),this.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:o,code:200,status:"success"}))}catch(e){this.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message})}},t.prototype.setProfile=function(e){e=this.formatParams(e);e&&Object.keys(e).length&&(this.pushCache(e),this.report("__profile_set",l({},e,{profile:!0})))},t.prototype.setOnceProfile=function(e){e=this.formatParams(e,!0);e&&Object.keys(e).length&&(this.pushCache(e),this.report("__profile_set_once",l({},e,{profile:!0})))},t.prototype.incrementProfile=function(e){e?this.report("__profile_increment",l({},e,{profile:!0})):console.warn("please check the params, must be object!!!")},t.prototype.unsetProfile=function(e){var t;e?((t={})[e]="1",this.report("__profile_unset",l({},t,{profile:!0}))):console.warn("please check the key, must be string!!!")},t.prototype.appendProfile=function(e){if(e){var t,r={};for(t in e)"string"==typeof e[t]||"Array"===Object.prototype.toString.call(e[t]).slice(8,-1)?r[t]=e[t]:console.warn("please check the value of param: "+t+", must be string or array !!!");Object.keys(r).length&&this.report("__profile_append",l({},r,{profile:!0}))}else console.warn("please check the params, must be object!!!")},t.prototype.pushCache=function(t){var r=this;Object.keys(t).forEach(function(e){r.cache[e]={val:r.clone(t[e]),timestamp:Date.now()}})},t.prototype.formatParams=function(r,o){var n=this;void 0===o&&(o=!1);try{if(r&&"[object Object]"===Object.prototype.toString.call(r)){var e,i={};for(e in r)"string"==typeof r[e]||"number"==typeof r[e]||"Array"===Object.prototype.toString.call(r[e]).slice(8,-1)?i[e]=r[e]:console.warn("please check the value of params:"+e+", must be string,number,Array !!!");var s,t=Object.keys(i);if(t.length)if(this.eventCheck.checkEventParams(i))return s=Date.now(),t.filter(function(e){var t=n.cache[e];return o?!t:!(t&&n.compare(t.val,r[e])&&s-t.timestamp<n.duration)}).reduce(function(e,t){return e[t]=i[t],e},{})}else console.warn("please check the params type, must be object !!!")}catch(r){this.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:r.message}),console.log("error")}},t.prototype.compare=function(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch(e){return this.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message}),!1}},t.prototype.clone=function(t){try{return JSON.parse(JSON.stringify(t))}catch(e){return this.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message}),t}},t.prototype.unReady=function(){console.warn("sdk is not ready, please use this api after start")},t}(),fe=function(){function e(){var e=this;this.setInterval=function(){e.clearIntervalFunc=U(function(){e.isSessionhasEvent&&e.endCurrentSession()},e.sessionInterval)},this.clearInterval=function(){e.clearIntervalFunc&&e.clearIntervalFunc()}}return e.prototype.apply=function(e,t){var r=this;this.collect=e,t.disable_heartbeat||(this.sessionInterval=6e4,this.startTime=0,this.lastTime=0,this.setInterval(),e=this.collect.Types,this.collect.on(e.SessionReset,function(){r.process()}))},e.prototype.endCurrentSession=function(){this.collect.event("_be_active",{start_time:this.startTime,end_time:this.lastTime,url:window.location.href,referrer:window.document.referrer,title:document.title||location.pathname}),this.isSessionhasEvent=!1,this.startTime=0},e.prototype.process=function(){this.isSessionhasEvent||(this.isSessionhasEvent=!0,this.startTime=+new Date);var e=this.lastTime||+new Date;this.lastTime=+new Date,this.lastTime-e>this.sessionInterval&&(this.clearInterval(),this.endCurrentSession(),this.setInterval())},e}(),de=function(){function e(){}return e.prototype.apply=function(e,t){var o=this;this.collect=e,this.config=t,this.config.channel_domain||t.disable_track_event||t.disable_sdk_monitor||(t=e.adapters.fetch,this.fetch=t,this.url=e.configManager.getUrl("event"),t=this.collect.Types,this.collect.on(t.Ready,function(){o.sdkOnload()}),this.collect.on(t.SubmitError,function(e){var t=e.type,r=e.eventData,e=e.errorCode;"f_data"===t&&o.sdkError(r,e)}))},e.prototype.sdkOnload=function(){var e=this;try{var t=this.collect.configManager.get(),r=t.header,o=t.user,n=r.app_id,i=r.app_name,s=r.sdk_version,a=o.web_id,c={events:[{event:"onload",params:JSON.stringify({app_id:n,app_name:i||"",sdk_version:s,sdk_type:"npm",sdk_config:this.config,sdk_desc:"TOC_OVERSEA"}),local_time_ms:Date.now()}],user:{user_unique_id:a},header:{}};setTimeout(function(){e.fetch(e.url,[c],3e4,!1,function(){},function(){},"566f58151b0ed37e")},16)}catch(e){}},e.prototype.sdkError=function(e,t){var r=this;try{var o=e[0],n=o.user,i=o.header,s=[],a=(e.forEach(function(e){e.events.forEach(function(e){s.push(e)})}),{events:s.map(function(e){return{event:"on_error",params:JSON.stringify({error_code:t,app_id:i.app_id,app_name:i.app_name||"",error_event:e.event,sdk_version:i.sdk_version,local_time_ms:e.local_time_ms,tea_event_index:Date.now(),params:e.params,header:JSON.stringify(i),user:JSON.stringify(n)}),local_time_ms:Date.now()}}),user:{user_unique_id:n.user_unique_id},header:{}});setTimeout(function(){r.fetch(r.url,[a],3e4,!1,function(){},function(){},"566f58151b0ed37e")},16)}catch(e){}},e}(),he={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"}},ye="undefined"!=typeof window?(window.LogPluginObject||(window.LogPluginObject={}),window.LogPluginObject):null,ge=function(){function e(){}return e.prototype.apply=function(e,t){this._plugin={},this.config=t,this.collect=e,this.channel=t.channel||"cn",this.loadExtend()},e.prototype.loadExtend=function(){var n=this;try{this.collect.remotePlugin.forEach(function(e,t){var r,o;"sdk"===e?he.hasOwnProperty(t)?(r=he[t].object,o=""+he[t].src[n.channel],n.exist(t,r,o)):console.warn("your "+t+" is not exist,please check plugin name"):"object"==_typeof(e)&&(e.src?n.exist(t,e.call,e.src):n.process(t,e.instance,"INSTANCE"))})}catch(n){this.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:n.message}),console.log("load extend error")}},e.prototype.exist=function(e,t,r){var o=this;ye[t]?(this.process(e,ye[t]),console.log("已有"+e+"插件,避免重复加载~")):this.loadPlugin(e,r,function(){o.process(e,ye[t]),console.log(" %c %s %s %s","color: yellow; background-color: black;","–","load plugin:"+e+" success","-")},function(){console.log(" %c %s %s %s","color: red; background-color: yellow;","–","load plugin:"+e+" error","-")})},e.prototype.process=function(e,t,r){try{var o;r?((o=new t).apply&&o.apply(this.collect,this.config),console.log("excude "+e+" success")):t&&t(this.collect,this.config)}catch(t){this.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),console.log("excude "+e+" error, message:"+t.message)}},e.prototype.loadPlugin=function(e,t,r,o){var n=this;try{var i=document.createElement("script");i.src=t,this._plugin[e]||(this._plugin[e]=[]),this._plugin[e].push(r),i.onerror=function(){o(t)},i.onload=function(){n._plugin[e].forEach(function(e){e()})},document.getElementsByTagName("head")[0].appendChild(i)}catch(e){this.collect.emit(f.DEBUGGER_MESSAGE,{type:f.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message})}},e}(),ge=(_.usePlugin(ge,"extend"),_.usePlugin(o,"et"),_.usePlugin(pe,"profile"),_.usePlugin(fe,"heartbeat"),_.usePlugin(de,"monitor"),new _("default")),_e=ge,me={browserError:1e3,crc32:1e3,preUpload:1001,initUploadID:1002,process:1003,fileMerge:1004,complete:1005},ve="video",be="image",we="object",Se={video:"video_upload",image:"image_upload",object:"object_upload"},m=1,ke=2,Ee=3,v="vod",Oe={"us-east-1":"us-east-1","ap-singapore-1":"ap-singapore-1",i18n:"i18n"},xe="https://vod.byteplusapi.com";function LoggerV5_typeof(e){return(LoggerV5_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function LoggerV5_extends(){return(LoggerV5_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,o=arguments[t];for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,function _toPropertyKey(e){e=function _toPrimitive(e,t){if("object"!==LoggerV5_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==LoggerV5_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===LoggerV5_typeof(e)?e:String(e)}(o.key),o)}}var Ce=function(){function Logger(e,t){!function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,Logger),this.options=e,this.context=t,this.teaLog=_e,this.tea_app_id=2643,this.tea_channel="sg","us"===this.options.region?this.tea_channel="va":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:"0.0.1-beta",line_app_id:this.options.appId+"",toB:!0},user_unique_id:this.options.userId}),this.teaLog.start()}return function _createClass(e,t,r){t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(Logger,[{key:"send",value:function send(e){var t=this.context,r=e.key,t=t.tasks[r],o=me[e.stage]||999,t=e.fileType||t.fileType,n=e.fileSize||0,i={log_type:Se[t],stage:o,fk:r,fs:n,req:e.req,res:e.res,ts:Math.round(Date.now()/1e3),sst:e.stageStartTime,set:e.stageEndTime,dur:e.duration,tdur:e.totalDuration,isDirect:Number(!!e.isDirect)},s="".concat("image"===t?"image":"video","_")+("error"===e.type?"error":o);switch(o){case 1e3:this.teaLog.event(s,LoggerV5_extends({},i,{type:e.type,ex:JSON.stringify({errc:e.extra&&e.extra.errorCode,msg:e.extra&&e.extra.message,crc32Array:e.crc32Array,isDirect:e.isDirect})}));break;case 1001:this.teaLog.event(s,LoggerV5_extends({},i,{type:e.type,oid:e.oid,upload_host:e.tosDomain,ex:JSON.stringify({errc:e.extra&&e.extra.errorCode,err:e.extra&&e.extra.error,msg:e.extra&&e.extra.message,sig:e.signature})}));break;case 1002:this.teaLog.event(s,LoggerV5_extends({},i,{type:e.type,oid:e.oid,upload_host:e.tosDomain,ex:JSON.stringify({errc:e.extra&&e.extra.errorCode,msg:e.extra&&e.extra.message,upid:e.uploadID}),upload_id:e.uploadID}));break;case 1003:e.isAllFinish||e.isDirect||(delete i.sst,delete i.set,delete i.dur,delete i.isDirect),this.teaLog.event(s,LoggerV5_extends({},i,{type:e.type,oid:e.oid,upload_host:e.tosDomain,ex:JSON.stringify({errc:e.extra&&e.extra.errorCode,msg:e.extra&&e.extra.message,si:e.slice_index,af:e.isAllFinish}),upload_id:e.uploadID,si:e.slice_index,al:e.isAllFinish}));break;case 1004:this.teaLog.event(s,LoggerV5_extends({},i,{type:e.type,oid:e.oid,upload_host:e.tosDomain,ex:JSON.stringify({errc:e.extra&&e.extra.errorCode,msg:e.extra&&e.extra.message}),upload_id:e.uploadID}));break;case 1005:this.teaLog.event(s,LoggerV5_extends({},i,{type:e.type,oid:e.oid,upload_host:e.tosDomain,ex:JSON.stringify({errc:e.extra&&e.extra.errorCode,err:e.extra&&e.extra.error,msg:e.extra&&e.extra.message,vid:e.uploadResult&&e.uploadResult.Vid}),vid:e.uploadResult&&e.uploadResult.Vid}));break;default:this.teaLog.event(s,LoggerV5_extends({},i,{type:e.type,oid:e.oid,upload_host:e.tosDomain,ex:JSON.stringify({errc:e.extra&&e.extra.errorCode,msg:e.extra&&e.extra.message})}))}}},{key:"console",value:function(t){function console(e){return t.apply(this,arguments)}return console.toString=function(){return t.toString()},console}(function(e){this.options.debug&&console.log(e)})}]),Logger}(),o=n(2),Pe=n.n(o),pe=n(1),De=n.n(pe),b={resolveUri:function resolveUri(t){if(!t)return"";if(Array.isArray(t))return t.map(function(t){try{return t.split("/")[0]+"/"+encodeURIComponent(t.split("/").slice(1).join("/"))}catch(e){return t}});try{return t.split("/")[0]+"/"+encodeURIComponent(t.split("/").slice(1).join("/"))}catch(e){return t}},urlTemplate:function urlTemplate(t,r){var o;return r=r||{},Object.keys(r).forEach(function(e){o=new RegExp("{".concat(e,"}"),"g"),t=t.replace(o,r[e])}),t},toQueryString:function toQueryString(){var r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},o=[];return Object.keys(r).map(function(t){var e=r[t];"[object Array]"===Object.prototype.toString.call(e)?e.forEach(function(e){o.push("".concat(t,"=").concat(encodeURIComponent(e)))}):o.push("".concat(t,"=").concat(encodeURIComponent(r[t])))}),o.join("&")},arrayToObject:function arrayToObject(e){var t={};return e&&e.forEach(function(e){t[e.Key.toLowerCase()]=e.Value}),t},supportChunked:function supportChunked(){var e=window.Blob||window.WebKitBlob;try{var t=e.prototype;return!(!FormData||!(t.slice||t.webkitSlice||t.mozSlice))}catch(e){return!1}},supportXhr:function supportXhr(){return!!window.FormData||window.ProgressEvent&&window.FileReader},supportCrc32:function supportCrc32(){var e=window.FileReader&&window.FileReader.prototype.readAsBinaryString;return"undefined"!=typeof Int32Array&&e&&(Blob.prototype.slice||Blob.prototype.webkitSlice||Blob.prototype.mozSlice)},storage:function storage(e){var r=e,e={removeItem:function removeItem(e){delete r.cache[e]},setItem:function setItem(e,t){r.cache[e]=t},getItem:function getItem(e){return r.cache[e]},clear:function clear(){delete r.cache,r.cache={}}};if(!(1<arguments.length&&void 0!==arguments[1])||arguments[1])try{if(window.localStorage)return window.localStorage.setItem("",""),window.localStorage}catch(e){}return e},noop:function noop(){},getUnique:function getUnique(e){return"".concat(e,"_").concat((new Date).getTime(),"_").concat(parseInt(1e6*Math.random()))},getFileSliceLength:function getFileSliceLength(e,t){var r=e.size,o=1048576;return t&&"function"==typeof t?t(r)<5242880?5242880:t(r)||r:400*o<r?10*o:r<=400*o&&2*o<=r?5*o:e.size},getFileSuffix:function getFileSuffix(e){var t;return e&&"[object String]"===Object.prototype.toString.call(e)&&0<(t=e.lastIndexOf("."))?"."+e.substring(t+1):void 0},crypto:{hmac:function hmac(e,t){return Pe()(t,e)},sha256:function sha256(e){return De()(e)}},date:{iso8601:function iso8601(e){return(e=void 0===e?b.date.getDate():e).toISOString().replace(/\.\d{3}Z$/,"Z")}},Buffer:Uint8Array,buffer:{toBuffer:function toBuffer(e,t){return"function"==typeof b.Buffer.from&&b.Buffer.from!==Uint8Array.from?b.Buffer.from(e,t):new b.Buffer(e,t)},alloc:function alloc(e,t,r){if("number"!=typeof e)throw new Error("size passed to alloc must be a number.");return"function"==typeof b.Buffer.alloc?b.Buffer.alloc(e,t,r):(e=new b.Buffer(e),void 0!==t&&"function"==typeof e.fill&&e.fill(t,void 0,void 0,r),e)},toStream:function toStream(t){b.Buffer.isBuffer(t)||(t=b.buffer.toBuffer(t));var r=new b.stream.Readable,o=0;return r._read=function(e){if(o>=t.length)return r.push(null);e=o+e;e>t.length&&(e=t.length),r.push(t.slice(o,e)),o=e},r},concat:function concat(e){for(var t,r=0,o=0,n=0;n<e.length;n++)r+=e[n].length;for(t=b.buffer.alloc(r),n=0;n<e.length;n++)e[n].copy(t,o),o+=e[n].length;return t}}},w=b;var Ue={crc32:function encrypt_crc32(e,t){for(var r=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],o=("undefined"!=typeof Int32Array&&(r=new Int32Array(r)),-1^~~t),n=(e=new Uint8Array(e)).length,i=0;i<n;i++)o=r[255&(o^e[i])]^o>>>8;return(-1^o)>>>0},dec2hex:function dec2hex(e){if(void 0!==e)return function toEight(e){return e.length<8?toEight(e="0".concat(e)):e}(Number(e).toString(16))}};function Crc32_typeof(e){return(Crc32_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Crc32_defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,function Crc32_toPropertyKey(e){e=function Crc32_toPrimitive(e,t){if("object"!==Crc32_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==Crc32_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===Crc32_typeof(e)?e:String(e)}(o.key),o)}}var Te=function(){function Crc32(e,t,r,o){!function Crc32_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,Crc32),this.file=e,this.successProcess=r,this.failProcess=o,this.sliceLength=t,this.retryTime=0,this.fileSize=e.size,this.crc32Array=[]}return function Crc32_createClass(e,t,r){t&&Crc32_defineProperties(e.prototype,t),r&&Crc32_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(Crc32,[{key:"start",value:function start(){this.readFileCrc32(this.file)}},{key:"readFileCrc32",value:function readFileCrc32(t){var r=this,e=this.sliceLength,o=t.slice||t.webkitSlice||t.mozSlice,n=new FileReader,i=0,s=0,a=0;(function read(){s<t.size&&(s=Math.min(i+e,t.size),104857600<t.size)&&t.size-s<=5242880&&(s=t.size),n.readAsArrayBuffer(o.call(t,i,s)),n.onload=function(e){e=e.target.result;a=Ue.crc32(e,0),r.crc32Array.push({start:i,end:s,crc32:Ue.dec2hex(a),buffer:e}),(i=s)<t.size?read():r.success(r.crc32Array)}})()}},{key:"success",value:function success(e){this.successProcess(e)}},{key:"fail",value:function fail(e,t,r,o){3<=this.retryTime?this.failProcess():(this.readFileCrc32(e,t,r,o),this.retryTime++)}}]),Crc32}();function FileCrc32_typeof(e){return(FileCrc32_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function FileCrc32_extends(){return(FileCrc32_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,o=arguments[t];for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}function _toConsumableArray(e){return function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}(e)||function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function _unsupportedIterableToArray(e,t){var r;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(r="Object"===(r=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}(e)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function FileCrc32_defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,function FileCrc32_toPropertyKey(e){e=function FileCrc32_toPrimitive(e,t){if("object"!==FileCrc32_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==FileCrc32_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===FileCrc32_typeof(e)?e:String(e)}(o.key),o)}}var Ie=function(){function FileCrc32(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};!function FileCrc32_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,FileCrc32),this.context=e.context,this.key=e.key,this.isDirect=e.isDirect,this.isImageBatchUpload=e.isImageBatchUpload,this.file=e.file,this.type=(this.isImageBatchUpload?this.file[0]:this.file).type||"",this.sliceLength=w.getFileSliceLength(this.file,t.getSliceFunc),this.config=t}return function FileCrc32_createClass(e,t,r){t&&FileCrc32_defineProperties(e.prototype,t),r&&FileCrc32_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(FileCrc32,[{key:"start",value:function start(e,t,r){this.successProcess=t,this.failProcess=r,this._st=Date.now(),this.crc32(this.file,this.sliceLength)}},{key:"crc32",value:function crc32(e,t){var r=this;if(this.isImageBatchUpload)for(var o=e.length,n=[],i=0;i<o;i++)new Te(e[i],e[i].size,function(e){n.push(e[0]),n.length===o&&r.success(n)},function(e){r.fail(e)}).start();else!e||!e.size||e.size<=0?this.fail({message:"There is a problem with the input file or fileSize."}):this.isDirect?new Te(e,e.size,function(e){r.success(e)},function(e){r.fail(e)}).start():this.sliceFile(e,t,function(e){r.success(e)},function(e){r.fail(e)})}},{key:"sliceFile",value:function sliceFile(e,t,r,o){for(var n=[],i=t,s=e.size,a=new FileReader,c=e.slice||e.webkitSlice||e.mozSlice,u=0,l=0,p=0;l<s;)l=Math.min(u+i,s),s-l<=5242880&&(l=s),n.push({start:u,end:l,crc32:0}),u=l;try{!function read(t){u=n[t].start,l=n[t].end,a.readAsArrayBuffer(c.call(e,u,l)),a.onload=function(e){e=e.target.result,p=Ue.dec2hex(Ue.crc32(e,0)),n[t].crc32=p,l===s?r(n):read(n.length-1)},a.onerror=function(e){o(e)}}(0)}catch(e){o(e)}}},{key:"getCrc32Key",value:function getCrc32Key(e,t){t="[object Array]"===Object.prototype.toString.call(t)?_toConsumableArray(t):[t];return t.push(e[0].crc32,e[e.length-1].crc32),t.join("_")}},{key:"success",value:function success(e){var t=this.context,r=this.key,o=[],n=[];if(this.isImageBatchUpload)for(var i=0;i<this.file.length;i++)o.push(this.file[i].size),n.push(this.file[i].name);else o=this.file.size,n=this.file.name;var s=this.getCrc32Key(e,o),t=t.tasks[r];t&&this.successProcess(FileCrc32_extends(t,{key:r,crc32Array:e,crc32Key:s,sdkVersion:"0.0.1-beta",sliceLength:this.sliceLength,extra:{message:"get crc32 success"},stage:"crc32",type:"success",fileSize:o,fileName:n,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(e){var t=this.context,r=this.key,e=e&&e.message?e.message:"get crc32 error",t=FileCrc32_extends(t.tasks[r],{extra:{message:e},type:"error",stage:"crc32",stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st});this.failProcess(t)}}]),FileCrc32}();function Transport_typeof(e){return(Transport_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Transport_defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,function Transport_toPropertyKey(e){e=function Transport_toPrimitive(e,t){if("object"!==Transport_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==Transport_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===Transport_typeof(e)?e:String(e)}(o.key),o)}}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function _createSuper(r){var o=function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function _createSuperInternal(){var e,t=_getPrototypeOf(r);return function _possibleConstructorReturn(e,t){{if(t&&("object"===Transport_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return function _assertThisInitialized(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(this,o?(e=_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var S=function(){!function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}(Transport,s.a);var t=_createSuper(Transport);function Transport(){var e;return function Transport_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,Transport),(e=t.call(this)).xhr=new XMLHttpRequest,e._data=null,e}return function Transport_createClass(e,t,r){t&&Transport_defineProperties(e.prototype,t),r&&Transport_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(Transport,[{key:"_ajax",value:function _ajax(e){var t=this,r=this.xhr;r.upload.onprogress=function(e){t.emit("progress",e)},r.onreadystatechange=function(){4===r.readyState&&(r.upload.onprogress=w.noop,r.onreadystatechange=w.noop,r.params=e,t._data&&t._data.url&&(r.currentUrl=t._data.url),200<=r.status&&r.status<300?t.emit("complete",r):400<=r.status&&t.emit("error",r))},r.onerror=function(){r.errText="unknow net error",t.emit("error",r)},r.ontimeout=function(){r.errText="timeout",t.emit("error",r)},r.onabort=function(){r.errText="abort",t.emit("error",r)},r.send(e)}},{key:"send",value:function send(t){var r=this;return this._data=t,this.xhr.open(t.method||"POST",t.url||"",!0),t.headers&&Object.keys(t.headers).forEach(function(e){r.xhr.setRequestHeader(e,t.headers[e])}),this.xhr.timeout=t.timeout||0,t.ontimeout&&(this.xhr.ontimeout=t.ontimeout),t.binary?this.sendAsBinary(t):t.custom?"object"===Transport_typeof(t.custom)?this.sendAsCustom(JSON.stringify(t.custom)):"none"===t.custom?(delete t.custom,this.sendAsCustom()):this.sendAsCustom(t.custom):this.sendAsFormData(t)}},{key:"sendAsBinary",value:function sendAsBinary(e){return this.xhr.setRequestHeader("Content-Type","application/octet-stream"),this.xhr.setRequestHeader("Content-Disposition",'attachment; filename="'.concat(encodeURI(e.filename),'"')),this._ajax(e.file)}},{key:"sendAsFormData",value:function sendAsFormData(e){t=(t=e.formData?"function"==typeof e.formData?e.formData():e.formData:t)||[];for(var t,r=new FormData,o=0,n=t.length;o<n;o++){var i=t[o];r.append(i.name,i.value)}return e.file&&r.append(e.field,e.file,e.name),this._ajax(r)}},{key:"sendAsCustom",value:function sendAsCustom(e){return this._ajax(e)}},{key:"abort",value:function abort(){this.xhr.onreadystatechange=w.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)}}]),Transport}(),k={hmac:function hmac(e,t){return Pe()(t,e)},sha256:function sha256(e){return De()(e)}};function awsv4_typeof(e){return(awsv4_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function awsv4_defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,function awsv4_toPropertyKey(e){e=function awsv4_toPrimitive(e,t){if("object"!==awsv4_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==awsv4_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===awsv4_typeof(e)?e:String(e)}(o.key),o)}}var je=["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id"],Ae=function uriEscape(e){try{return encodeURIComponent(e).replace(/[^A-Za-z0-9_.~\-%]+/g,escape).replace(/[*]/g,function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())})}catch(e){return""}},ze=function queryParamsToString(r){return Object.keys(r).sort().map(function(e){var t=r[e];if(null!=t){e=Ae(e);if(e)return Array.isArray(t)?"".concat(e,"=").concat(t.map(Ae).sort().join("&".concat(e,"="))):"".concat(e,"=").concat(Ae(t))}}).filter(function(e){return e}).join("&")},Me=function(){function AWSSignersV4(e,t,r){!function awsv4_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,AWSSignersV4),this.request=e,this.request.headers=e.headers||{},this.serviceName=t,this.signatureCache="boolean"!=typeof(r=r||{}).signatureCache||r.signatureCache,this.operation=r.operation,this.signatureVersion=r.signatureVersion,this.constant=r.isVolcengine?{algorithm:"HMAC-SHA256",v4Identifier:"request",dateHeader:"X-Date",tokenHeader:"x-security-token",contentSha256Header:"X-Content-Sha256",kDatePrefix:""}:{algorithm:"AWS4-HMAC-SHA256",v4Identifier:"aws4_request",dateHeader:"X-Amz-Date",tokenHeader:"x-amz-security-token",contentSha256Header:"X-Amz-Content-Sha256",kDatePrefix:"AWS4"},this.bodySha256=r.bodySha256,this.shouldSerializeBody="boolean"!=typeof r.shouldSerializeBody||r.shouldSerializeBody}return function awsv4_createClass(e,t,r){t&&awsv4_defineProperties(e.prototype,t),r&&awsv4_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(AWSSignersV4,[{key:"addAuthorization",value:function addAuthorization(e,t){t=this.iso8601(t).replace(/[:\-]|\.\d{3}/g,"");this.addHeaders(e,t),this.request.headers.Authorization=this.authorization(e,t)}},{key:"addHeaders",value:function addHeaders(e,t){this.request.headers[this.constant.dateHeader]=t,e.sessionToken&&(this.request.headers[this.constant.tokenHeader]=e.sessionToken),this.request.body&&("string"!=typeof(t=this.request.body)&&this.shouldSerializeBody&&(t=t instanceof URLSearchParams?t.toString():JSON.stringify(t)),this.request.headers[this.constant.contentSha256Header]=this.bodySha256||k.sha256(t).toString())}},{key:"authorization",value:function authorization(e,t){var r=[],o=this.credentialString(t);return r.push("".concat(this.constant.algorithm," Credential=").concat(e.accessKeyId,"/").concat(o)),r.push("SignedHeaders=".concat(this.signedHeaders())),r.push("Signature=".concat(this.signature(e,t))),r.join(", ")}},{key:"signature",value:function signature(e,t){e=this.getSigningKey(e,t.substr(0,8),this.request.region,this.serviceName,this.signatureCache);return k.hmac(e,this.stringToSign(t),"hex")}},{key:"stringToSign",value:function stringToSign(e){var t=[];return t.push(this.constant.algorithm),t.push(e),t.push(this.credentialString(e)),t.push(this.hexEncodedHash(this.canonicalString())),t.join("\n")}},{key:"canonicalString",value:function canonicalString(){var e=[],t=this.request.pathname||"/";return e.push(this.request.method.toUpperCase()),e.push(t),e.push(ze(this.request.params)||""),e.push("".concat(this.canonicalHeaders(),"\n")),e.push(this.signedHeaders()),e.push(this.hexEncodedBodyHash()),e.join("\n")}},{key:"canonicalHeaders",value:function canonicalHeaders(){var r=this,t=[],o=(Object.keys(this.request.headers).forEach(function(e){t.push([e,r.request.headers[e]])}),t.sort(function(e,t){return e[0].toLowerCase()<t[0].toLowerCase()?-1:1}),[]);return t.forEach(function(e){var t=e[0].toLowerCase();if(r.isSignableHeader(t)){e=e[1];if(null==e||"function"!=typeof e.toString)throw new Error("Header ".concat(t," contains invalid value"));o.push("".concat(t,":").concat(r.canonicalHeaderValues(e.toString())))}}),o.join("\n")}},{key:"canonicalHeaderValues",value:function canonicalHeaderValues(e){return e.replace(/\s+/g," ").replace(/^\s+|\s+$/g,"")}},{key:"signedHeaders",value:function signedHeaders(){var t=this,r=[];return Object.keys(this.request.headers).forEach(function(e){e=e.toLowerCase(),t.isSignableHeader(e)&&r.push(e)}),r.sort().join(";")}},{key:"credentialString",value:function credentialString(e){return this.createScope(e.substr(0,8),this.request.region,this.serviceName)}},{key:"hexEncodedHash",value:function hexEncodedHash(e){return k.sha256(e)}},{key:"hexEncodedBodyHash",value:function hexEncodedBodyHash(){return this.request.headers[this.constant.contentSha256Header]||(this.request.body?this.hexEncodedHash(ze(this.request.body)):this.hexEncodedHash(""))}},{key:"isSignableHeader",value:function isSignableHeader(e){return 0===e.toLowerCase().indexOf("x-amz-")||je.indexOf(e)<0}},{key:"iso8601",value:function iso8601(e){return(e=void 0===e?new Date:e).toISOString().replace(/\.\d{3}Z$/,"Z")}},{key:"getSigningKey",value:function getSigningKey(e,t,r,o){e=k.hmac("".concat(this.constant.kDatePrefix).concat(e.secretAccessKey),t),t=k.hmac(e,r),e=k.hmac(t,o);return k.hmac(e,this.constant.v4Identifier)}},{key:"createScope",value:function createScope(e,t,r){return[e.substr(0,8),t,r,this.constant.v4Identifier].join("/")}}]),AWSSignersV4}(),Re=1000001,Be=1000002,Ne=1001e3,Ge=1002e3,Le=1003e3,Fe=1003003,Ke=1004e3,qe=1005e3,He="The file is not an instance of Blob ",Ve="The format of stsToken is incorrect.",We="An error occurred reading the file";function ApplyUpload_typeof(e){return(ApplyUpload_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ownKeys(t,e){var r,o=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,r)),o}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach(function(e){!function _defineProperty(e,t,r){(t=ApplyUpload_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function ApplyUpload_extends(){return(ApplyUpload_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,o=arguments[t];for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}function ApplyUpload_defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,ApplyUpload_toPropertyKey(o.key),o)}}function ApplyUpload_toPropertyKey(e){e=function ApplyUpload_toPrimitive(e,t){if("object"!==ApplyUpload_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==ApplyUpload_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===ApplyUpload_typeof(e)?e:String(e)}function ApplyUpload_setPrototypeOf(e,t){return(ApplyUpload_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function ApplyUpload_createSuper(r){var o=function ApplyUpload_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function _createSuperInternal(){var e,t=ApplyUpload_getPrototypeOf(r);return function ApplyUpload_possibleConstructorReturn(e,t){{if(t&&("object"===ApplyUpload_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return function ApplyUpload_assertThisInitialized(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(this,o?(e=ApplyUpload_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function ApplyUpload_getPrototypeOf(e){return(ApplyUpload_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Je=function(){!function ApplyUpload_inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ApplyUpload_setPrototypeOf(e,t)}(ApplyUpload,s.a);var o=ApplyUpload_createSuper(ApplyUpload);function ApplyUpload(e,t){var r;return function ApplyUpload_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,ApplyUpload),(r=o.call(this)).options=e,r.config=t,r.uploaderCtx=e.context,r.currFileCtx=e.context.tasks[e.key],r.isImageBatchUpload=!!r.options.isImageBatchUpload,r.serviceName=e.serviceName||v,r}return function ApplyUpload_createClass(e,t,r){t&&ApplyUpload_defineProperties(e.prototype,t),r&&ApplyUpload_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(ApplyUpload,[{key:"start",value:function start(e,t,r){this.failProcess=r,this.successProcess=t,this._st=Date.now();r=this.uploaderCtx._getCache(this.currFileCtx.crc32Key),t=r?JSON.parse(r):{};t.oid&&t.uploadID&&t.tosDomain?this.resumeFromCache(t):this.startPreUpload()}},{key:"startPreUpload",value:function startPreUpload(){var d=this,e=Oe[this.config.region],t=new S,r=(t.on("complete",function(t){if(!t.response)return d.fail({error:"request fail: ".concat(t.statusText||t.errText||"UNKNOWN"),xhr:t});try{var e,r,o,n,i,s,a,c,u,l,p,f=JSON.parse(t.response);return f.ResponseMetadata.Error?d.fail({xhr:t,errorCode:f.ResponseMetadata.Error.CodeN,error:f.ResponseMetadata.Error.Code,message:f.ResponseMetadata.Error.Message}):(e=f.Result,n=(o=d.serviceName===v?null==(r=e.Data)?void 0:r.UploadAddress:e.UploadAddress).StoreInfos,i=o.UploadHosts,s=o.SessionKey,c=void 0===(a=o.UploadHeader)?[]:a,u=[],l=[],d.isImageBatchUpload&&1<n.length?n.forEach(function(e){u.push(e.Auth),l.push(e.StoreUri)}):(u=n[0].Auth,l=n[0].StoreUri),p=ApplyUpload_extends(d.currFileCtx,{signature:u,type:"success",extra:{message:"prepare upload success"},stage:"preUpload",oid:w.resolveUri(l),tosDomain:"".concat(d.config.schema,"://").concat(i[0]),xhr:t,UploadHeader:c,SessionKey:s,stageStartTime:d._st,stageEndTime:Date.now(),duration:Date.now()-d._st,totalDuration:Date.now()-d._st+d.currFileCtx.totalDuration}),d.successProcess(p))}catch(e){return d.fail({error:"catch error: ".concat(e.toString()),xhr:t})}}),t.on("error",function(e){var t={error:"request fail: ".concat(e.statusText||e.errText||"UNKNOWN"),xhr:e};e.response&&(e=JSON.parse(e.response)).ResponseMetadata&&e.ResponseMetadata.Error&&(t.errorCode=e.ResponseMetadata.Error.CodeN,t.error=e.ResponseMetadata.Error.Code,t.message=e.ResponseMetadata.Error.Message),d.fail(t)}),""),o={},n=(this.serviceName===v?(n=this.config.videoConfig.spaceName,r=xe,o={Action:"ApplyUploadInfo",Version:"2023-01-01",SpaceName:n,FileSize:this.currFileCtx.fileSize,FileType:this.options.type},this.options.fileName&&(o.FileName=this.options.fileName),this.options.storageClass&&(o.StorageClass=this.options.storageClass),this.config.enOID&&(o.EnOID=1)):(r=xe,o={Action:"ApplyImageUpload",Version:"2018-08-01",ServiceId:this.options.serviceId||this.config.imageConfig.serviceId},this.currFileCtx.fileSize&&1<this.currFileCtx.fileSize.length&&(o.UploadNum=this.currFileCtx.fileSize.length),this.options.storeKey&&(n=this.options.storeKey,"[object Array]"===Object.prototype.toString.call(n)?o.StoreKeys=n:"[object String]"===Object.prototype.toString.call(n)&&(o.StoreKeys=[n]))),this.config.useFileExtension&&this.currFileCtx.fileName&&(this.options.type===we||this.options.type===be)&&(n=this.currFileCtx.fileName,n=w.getFileSuffix(n))&&(o.FileExtension=n),this.options.fileExtension&&(o.FileExtension=this.options.fileExtension),this.config.accountId&&(o["X-Account-Id"]=this.config.accountId),o.s=Math.random().toString(36).substr(2),this.currFileCtx.proxyStsToken||this.config.stsToken),i=w.toQueryString(o),s=n.AccessKeyID,a=n.AccessKeyId,c=n.SecretAccessKey,n=n.SessionToken,r={method:"GET",url:"".concat(r,"?").concat(i),timeout:3e4,region:e,params:o};new Me(r,this.serviceName,{isVolcengine:!0}).addAuthorization({accessKeyId:a||s,secretAccessKey:c,sessionToken:n},new Date),t.send(r)}},{key:"resumeFromCache",value:function resumeFromCache(i){var s=this,a=this.options.key,e=new S,t=(e.on("complete",function(e){try{var t=JSON.parse(e.response);if(!(0===t.success&&0<t.payload.partList.length))return s.startPreUpload();var r=s.confirmCache(t.payload.partList),o=!!i.hasMerge?5:r.isAllFinished?4:3,n=ApplyUpload_extends(s.currFileCtx,i,{key:a,xhr:e,extra:{message:"prepare upload from disk cache success"},stage:"preUpload",type:"success",percent:0,cacheTask:o,proxyStsToken:s.options.stsToken,currentTask:1,status:1,isBreak:1,crc32Array:r.crc32Array,stageStartTime:s._st,stageEndTime:Date.now(),duration:Date.now()-s._st,totalDuration:Date.now()-s._st+s.currFileCtx.totalDuration});s.successProcess&&s.successProcess(n)}catch(e){return s.startPreUpload()}}),e.on("error",function(e){return 400<=e.status?s.startPreUpload():s.fail({error:"request error",xhr:e})}),this.config.userId),r=ApplyUpload_extends(w.arrayToObject(i.UploadHeader),{"x-storage-mode":"gateway"});e.send({method:"GET",url:w.urlTemplate(this.config.getUploadListUrl,{tosDomain:i.tosDomain,oid:i.oid,uploadId:i.uploadID}),headers:_objectSpread({authorization:i.signature,"x-storage-u":t},r),timeout:3e4})}},{key:"confirmCache",value:function confirmCache(e){var t=this.currFileCtx.crc32Array,r={},o=(e.forEach(function(e){var t=parseInt(e.partNumber)-1;isNaN(t)||void 0!==r[t]||(r[t]={tag:!0,crc32:e.crc32})}),!0),e=t.map(function(e,t){return r[t]&&r[t].tag&&r[t].crc32?(e.crc32=r[t].crc32,e.finished=!0,e.loaded=e.end-e.start):o=!1,e});return{isAllFinished:o,crc32Array:e}}},{key:"fail",value:function fail(e){var t=e.xhr,r=e.errorCode||Ne,o="prepare upload error: UNKNOWN",o=(t&&(o=0===t.status?"prepare upload error: NETERROR":e.message||"prepare upload error: ".concat(t.status)),ApplyUpload_extends(this.currFileCtx,{extra:{message:o,error:e.error,errorCode:r},type:"error",stage:"preUpload",xhr:t,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currFileCtx.totalDuration}));this.uploaderCtx._removeTaskCache(this.options.key),this.failProcess(o)}}]),ApplyUpload}();function InitUploadID_typeof(e){return(InitUploadID_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function InitUploadID_ownKeys(t,e){var r,o=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,r)),o}function InitUploadID_objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?InitUploadID_ownKeys(Object(r),!0).forEach(function(e){!function InitUploadID_defineProperty(e,t,r){(t=InitUploadID_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):InitUploadID_ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function InitUploadID_extends(){return(InitUploadID_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,o=arguments[t];for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}function InitUploadID_defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,InitUploadID_toPropertyKey(o.key),o)}}function InitUploadID_toPropertyKey(e){e=function InitUploadID_toPrimitive(e,t){if("object"!==InitUploadID_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==InitUploadID_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===InitUploadID_typeof(e)?e:String(e)}function InitUploadID_setPrototypeOf(e,t){return(InitUploadID_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function InitUploadID_createSuper(r){var o=function InitUploadID_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function _createSuperInternal(){var e,t=InitUploadID_getPrototypeOf(r);return function InitUploadID_possibleConstructorReturn(e,t){{if(t&&("object"===InitUploadID_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return function InitUploadID_assertThisInitialized(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(this,o?(e=InitUploadID_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function InitUploadID_getPrototypeOf(e){return(InitUploadID_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Qe=function(){!function InitUploadID_inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&InitUploadID_setPrototypeOf(e,t)}(InitUploadID,s.a);var o=InitUploadID_createSuper(InitUploadID);function InitUploadID(e,t){var r;return function InitUploadID_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,InitUploadID),(r=o.call(this)).options=e,r.config=t,r.transport=new S,r.uploaderCtx=e.context,r.currFileCtx=e.context.tasks[e.key],r.eventInit(),r}return function InitUploadID_createClass(e,t,r){t&&InitUploadID_defineProperties(e.prototype,t),r&&InitUploadID_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(InitUploadID,[{key:"initUpload",value:function initUpload(){var e=this.options.context,t=this.options.key,r={oid:e.tasks[t].oid,tosDomain:e.tasks[t].tosDomain},r=w.urlTemplate(this.config.initUploadFileUrl,r),o=this.config.userId,n=InitUploadID_extends(w.arrayToObject(this.currFileCtx.UploadHeader),{"x-storage-mode":"gateway"});this.transport.send({method:"post",url:r,headers:InitUploadID_objectSpread({authorization:e.tasks[t].signature,"x-storage-u":o},n),timeout:3e4})}},{key:"start",value:function start(e,t,r){this.successProcess=t,this.failProcess=r,this._st=Date.now(),this.initUpload()}},{key:"eventInit",value:function eventInit(){var n=this,i=this.options.context,s=this.options.key;this.transport.on("complete",function(t){try{var e,r=JSON.parse(t.response),o=r.payload.uploadID;0===r.success&&o?(e=InitUploadID_extends(i.tasks[s],{uploadID:o,percent:0,type:"success",extra:{message:"init upload id success"},stage:"initUploadID",xhr:t,stageStartTime:n._st,stageEndTime:Date.now(),duration:Date.now()-n._st,totalDuration:Date.now()-n._st+n.currFileCtx.totalDuration}),n.successProcess(e)):n.fail({error:"fail! res.success: ".concat(r.success,", uploadId:").concat(o),xhr:t})}catch(e){n.fail({error:"catch error: ".concat(JSON.stringify(e)),xhr:t})}}),this.transport.on("error",function(e){n.fail({error:"request fail: ".concat(e.statusText||e.errText||"UNKNOWN"),xhr:e})})}},{key:"fail",value:function fail(e){var t=this.options.context,r=this.options.key,t=InitUploadID_extends(t.tasks[r],{extra:{message:"init upload id error, ".concat(e.error),errorCode:Ge},type:"error",stage:"initUploadID",xhr:e.xhr,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currFileCtx.totalDuration});this.uploaderCtx._removeTaskCache(this.options.key),this.failProcess(t)}}]),InitUploadID}();function Uploader_typeof(e){return(Uploader_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Uploader_ownKeys(t,e){var r,o=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,r)),o}function Uploader_objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Uploader_ownKeys(Object(r),!0).forEach(function(e){!function Uploader_defineProperty(e,t,r){(t=Uploader_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Uploader_ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Uploader_defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,Uploader_toPropertyKey(o.key),o)}}function Uploader_toPropertyKey(e){e=function Uploader_toPrimitive(e,t){if("object"!==Uploader_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==Uploader_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===Uploader_typeof(e)?e:String(e)}function Uploader_setPrototypeOf(e,t){return(Uploader_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function Uploader_createSuper(r){var o=function Uploader_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function _createSuperInternal(){var e,t=Uploader_getPrototypeOf(r);return function Uploader_possibleConstructorReturn(e,t){{if(t&&("object"===Uploader_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return function Uploader_assertThisInitialized(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(this,o?(e=Uploader_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function Uploader_getPrototypeOf(e){return(Uploader_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var $e=function(){!function Uploader_inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Uploader_setPrototypeOf(e,t)}(Uploader,s.a);var u=Uploader_createSuper(Uploader);function Uploader(e){var t,r=e.sliceItem,o=e.crc32,n=e.url,i=e.signature,s=e.uploadHeader,a=e.userId,c=e.retryTime,c=void 0===c?0:c,e=e.method,e=void 0===e?"put":e;return function Uploader_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,Uploader),(t=u.call(this)).fileSlice=r,t.crc32=o,t.uploadUrl=n,t.uploadHeader=s,t.signature=i,t.userId=a,t.retryTime=c,t.method=e,t.retryCount=0,t.ready=!1,t.cancel=!1,t.transport=new S,t.eventInit(),t}return function Uploader_createClass(e,t,r){t&&Uploader_defineProperties(e.prototype,t),r&&Uploader_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(Uploader,[{key:"upload",value:function upload(){this.isParamsValid()&&(this._st=Date.now(),this.transport.send({method:this.method,url:this.uploadUrl,headers:Uploader_objectSpread({authorization:this.signature,"content-crc32":this.crc32,"x-storage-u":this.userId},this.uploadHeader),file:this.fileSlice,binary:1,timeout:18e5}))}},{key:"isParamsValid",value:function isParamsValid(){return this.fileSlice&&(this.fileSlice.size||this.fileSlice.byteLength)?this.crc32?!!this.uploadUrl||(this.emit("error",{message:"slice upload failed: NOURL",crc32:this.crc32,size:this.fileSlice.size||this.fileSlice.byteLength}),!1):(this.emit("error",{message:"slice upload failed: NOCRC32",crc32:this.crc32,size:this.fileSlice.size||this.fileSlice.byteLength}),!1):(this.emit("error",{message:"slice upload failed: NOCONTENT",crc32:this.crc32}),!1)}},{key:"eventInit",value:function eventInit(){var t=this;this.transport.on("complete",function(e){t.success(e)}),this.transport.on("error",function(e){t.fail(e)}),this.transport.on("progress",function(e){t.process(e)})}},{key:"success",value:function success(e){this.ready=!0;var t=Date.now()-this._st,r=this.fileSlice.size||this.fileSlice.byteLength;this.emit("complete",{crc32:this.crc32,size:r,speed:r/t,xhr:e,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st})}},{key:"fail",value:function fail(e){var t,r=this;this.cancel||(e&&401===e.status?this.emit("error",{message:"slice upload failed: UNAUTHORIZED",crc32:this.crc32,size:this.fileSlice.size||this.fileSlice.byteLength,xhr:e,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st}):this.retryCount<this.retryTime?(setTimeout(function(){r.upload()},1e3),this.retryCount++):(t="slice upload failed: UNKNOWN",e&&(t=e.status?"slice upload failed: ".concat(e.status):"slice upload failed: NETERROR"),this.emit("error",{message:t,crc32:this.crc32,size:this.fileSlice.size||this.fileSlice.byteLength,xhr:e,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st})))}},{key:"process",value:function process(e){this.cancel||this.emit("progress",{crc32:this.crc32,loaded:e.loaded||0,total:e.total||0})}},{key:"abort",value:function abort(){this.transport&&(this.cancel=!0,this.transport.abort())}},{key:"destroy",value:function destroy(){this.transport=null}}]),Uploader}(),fe=n(4),Xe=n.n(fe);function Upload_typeof(e){return(Upload_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Upload_extends(){return(Upload_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,o=arguments[t];for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}function Upload_defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,function Upload_toPropertyKey(e){e=function Upload_toPrimitive(e,t){if("object"!==Upload_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==Upload_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===Upload_typeof(e)?e:String(e)}(o.key),o)}}function Upload_setPrototypeOf(e,t){return(Upload_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function Upload_createSuper(r){var o=function Upload_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function _createSuperInternal(){var e,t=Upload_getPrototypeOf(r);return function Upload_possibleConstructorReturn(e,t){{if(t&&("object"===Upload_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return function Upload_assertThisInitialized(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(this,o?(e=Upload_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function Upload_getPrototypeOf(e){return(Upload_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ze=function(){!function Upload_inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Upload_setPrototypeOf(e,t)}(Upload,s.a);var o=Upload_createSuper(Upload);function Upload(e){var t,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return function Upload_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,Upload),(t=o.call(this)).file=e.file,t.context=e.context,t.key=e.key,t.config=r,t.finishArr=[],t.errorLength=0,t.finishSize=0,t.retryUploadTime=Number(r.retryUploadTime)||5,t.retryProcess=r.retryProcess,t.retryProcessTime=Number(r.retryProcessTime)||5,t.maxProcessPause=Number(r.maxProcessPause)||20,t.uploadSliceCount=Number(r.uploadSliceCount)||5,t.realtimeSpeedInterval=Number(r.realtimeSpeedInterval)||5,t.processRetry=0,t.lastFinishSize=-1,t.lastProcessPercent=-1,t.lastIntervalSize=-1,t.lastCalculateSpeedTime=-1,t.lastCalculateSpeedSize=0,t.uploadHandlers={},t}return function Upload_createClass(e,t,r){t&&Upload_defineProperties(e.prototype,t),r&&Upload_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(Upload,[{key:"start",value:function start(e,t,r){this.failProcess=r,this.successProcess=t,this.errorLength=0,this.currentCtx=this.context.tasks[this.key],this.crc32Array=this.context.tasks[this.key].crc32Array,this.uploadSliceCount=this.uploadSliceCount>this.crc32Array.length?this.crc32Array.length:this.uploadSliceCount,this.lastIndex=0,this.uploading=[],this._uploadSize=this.crc32Array.reduce(function(e,t){return e+(t.finished?0:t.end-t.start)},0),this._st=Date.now(),this._lastSaveTime=Date.now(),this.lastCalculateSpeedTime=this._st,this.initWorker(),this.threadUpload()}},{key:"initWorker",value:function initWorker(){var n,i=this;this.worker||(n=this.crc32Array,this.worker=new Xe.a,this.worker.onmessage=function(e){var t=e.data[0],r=e.data[2],o=n[r];o.crc32=e.data[1],i.upload(o,t,r)})}},{key:"read",value:function read(e,t){var r=this,o=this.file,n=o.slice||o.webkitSlice||o.mozSlice,i=new FileReader;i.onload=function(e){r.worker.postMessage([e.target.result,t],[e.target.result])},i.onerror=function(){r.stop(),r.fail({extra:{message:We,errorCode:Fe}})},i.readAsArrayBuffer(n.call(o,e.start,e.end))}},{key:"threadUpload",value:function threadUpload(){if(this.uploading.length<this.uploadSliceCount){var e=this.lastIndex,t=this.crc32Array[e];if(t){if(t.finished){if(-1===this.finishArr.indexOf(t.start)&&(this.finishArr.push(t.start),this.finishArr.length>=this.crc32Array.length))return this.stop(),void this.success()}else t.loaded=0,this.uploading.push(e),this.read(t,e);this.lastIndex++,this.threadUpload()}}}},{key:"stop",value:function stop(){var t=this;Object.keys(this.uploadHandlers).forEach(function(e){t.uploadHandlers[e].abort()}),this.worker&&this.worker.terminate(),this.worker=null,this.clearMonitor()}},{key:"clearMonitor",value:function clearMonitor(){this.progressMonitorInterval&&clearInterval(this.progressMonitorInterval)}},{key:"upload",value:function upload(t,e,r){var o=this,n=t.crc32,i={number:r+1,uploadId:this.currentCtx.uploadID,oid:this.currentCtx.oid,tosDomain:this.currentCtx.tosDomain},i=w.urlTemplate(this.config.uploadChunkedUrl,i),s=this.config.userId,a=Upload_extends(w.arrayToObject(this.currentCtx.UploadHeader),{"x-storage-mode":"gateway"}),e=new $e({sliceItem:e,crc32:n,url:i,signature:this.currentCtx.signature,uploadHeader:a,userId:s,retryTime:this.retryUploadTime});e.on("complete",function(e){o.currentCtx.status===m&&(e.start=t.start,e.index=r,o.fileSliceSuccess(e))}),e.on("error",function(e){1===o.currentCtx.status&&(e.start=t.start,e.index=r,o.fail(e))}),e.on("progress",function(e){1===o.currentCtx.status&&(e.start=t.start,e.index=r,o.process(e))}),e.upload(),this.uploadHandlers[r]=e}},{key:"success",value:function success(e){this.finishArr=[];var t=Date.now()-this._st,t=this._uploadSize/t,t=Upload_extends(this.currentCtx,{type:"success",stage:"process",percent:100,extra:{message:"upload all success"},speed:t,xhr:e,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._lastSaveTime+this.currentCtx.totalDuration,isAllFinish:!0});this.worker&&this.worker.terminate(),this.successProcess(t)}},{key:"fail",value:function fail(e){var t=this.currentCtx.totalDuration,r=Date.now()-this._st,o=e.crc32?{message:e.message,data:e.crc32,size:e.size}:e.extra,o=(o.errorCode=o.errorCode||Le,Upload_extends(this.currentCtx,{extra:o,type:"error",stage:"process",req:{},res:{},totalDuration:r+t}));e.xhr&&(r=e.xhr,o.req={url:e.xhr.currentUrl},o.res={status:r.status,body:r.responseText,header:r.getAllResponseHeaders()},delete e.xhr),void 0!==e.statusCode&&Upload_extends(this.currentCtx,{statusCode:e.statusCode}),this.errorLength||(t=e.index,this.context.logger.send(Upload_extends({},o,{slice_index:t})),this.stop(),this.context._broadcast("error",o),this.currentCtx.isBreak?this.context._cancel(this.key):this.context._pause(this.key),this.errorLength++)}},{key:"fileSliceSuccess",value:function fileSliceSuccess(e){var t,r=e.index,o=Date.now(),n=(-1===this.finishArr.indexOf(e.start)&&this.finishArr.push(e.start),this.crc32Array[r].finished=!0,this.crc32Array[r].speed=e.speed,{message:"slice upload success"});e.xhr&&(t=e.xhr,n.currentUrl=t.currentUrl||"",Upload_extends(this.currentCtx,{req:{url:t.currentUrl,param:t.params},res:{status:t.status,body:t.responseText,header:t.getAllResponseHeaders()}}),delete e.xhr),this.context.logger.send(Upload_extends(this.currentCtx,{stage:"process",type:"success",slice_index:r,extra:n,totalDuration:o-this._lastSaveTime+this.currentCtx.totalDuration})),this._lastSaveTime=o,this.finishArr.length>=this.crc32Array.length?(this.stop(),this.success(e.xhr)):(this.uploading.splice(this.uploading.indexOf(r),1),this.uploadHandlers[r]&&delete this.uploadHandlers[r],this.threadUpload())}},{key:"getFinishSize",value:function getFinishSize(e,t){var r=t.crc32,o=0;return e.forEach(function(e){e.crc32===r?(e.loaded=t.loaded,o+=t.loaded):(e.loaded||(e.loaded=0),o+=e.loaded)}),o}},{key:"process",value:function process(e){var t=this.currentCtx.realtimeSpeed||0,r=this.currentCtx.fileSize,o=(this.finishSize=this.getFinishSize(this.crc32Array,e),this.finishSize>this.lastFinishSize&&((e=new Date).getTime()-this.lastCalculateSpeedTime>1e3*this.realtimeSpeedInterval&&(n=e.getTime()-this.lastCalculateSpeedTime,o=this.finishSize-this.lastCalculateSpeedSize,t=Math.floor(o/n),this.lastCalculateSpeedTime=e.getTime(),this.lastCalculateSpeedSize=this.finishSize),this.lastFinishSize=this.finishSize),Math.floor(this.finishSize/r*100*100)/100||0),n=Upload_extends(this.currentCtx,{stage:"process",percent:o,realtimeSpeed:t});o>this.lastProcessPercent&&100!==o&&(this.lastProcessPercent=o,this.context._broadcast("progress",n))}}]),Upload}();function FileMerge_typeof(e){return(FileMerge_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function FileMerge_ownKeys(t,e){var r,o=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,r)),o}function FileMerge_objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?FileMerge_ownKeys(Object(r),!0).forEach(function(e){!function FileMerge_defineProperty(e,t,r){(t=FileMerge_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):FileMerge_ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function FileMerge_extends(){return(FileMerge_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,o=arguments[t];for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}function FileMerge_defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,FileMerge_toPropertyKey(o.key),o)}}function FileMerge_toPropertyKey(e){e=function FileMerge_toPrimitive(e,t){if("object"!==FileMerge_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==FileMerge_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===FileMerge_typeof(e)?e:String(e)}function FileMerge_setPrototypeOf(e,t){return(FileMerge_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function FileMerge_createSuper(r){var o=function FileMerge_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function _createSuperInternal(){var e,t=FileMerge_getPrototypeOf(r);return function FileMerge_possibleConstructorReturn(e,t){{if(t&&("object"===FileMerge_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return function FileMerge_assertThisInitialized(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(this,o?(e=FileMerge_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function FileMerge_getPrototypeOf(e){return(FileMerge_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ye=function(){!function FileMerge_inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&FileMerge_setPrototypeOf(e,t)}(FileMerge,s.a);var o=FileMerge_createSuper(FileMerge);function FileMerge(e,t){var r;return function FileMerge_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,FileMerge),(r=o.call(this)).options=e,r.config=t,r.transport=new S,r.eventInit(),r.errorCount=0,r.uploaderCtx=e.context,r.currFileCtx=e.context.tasks[e.key],r}return function FileMerge_createClass(e,t,r){t&&FileMerge_defineProperties(e.prototype,t),r&&FileMerge_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(FileMerge,[{key:"mergeFile",value:function mergeFile(){for(var e={oid:this.currFileCtx.oid,uploadId:this.currFileCtx.uploadID,tosDomain:this.currFileCtx.tosDomain},t=this.currFileCtx.crc32Array,r="",o=0;o<t.length;o++)r=(r?"".concat(r,","):"").concat(o+1,":").concat(t[o].crc32);var e=w.urlTemplate(this.config.uploadMergeUrl,e),n=this.config.userId,i=FileMerge_extends(w.arrayToObject(this.currFileCtx.UploadHeader),{"x-storage-mode":"gateway"});this.transport.send({method:"post",url:e,headers:FileMerge_objectSpread({authorization:this.currFileCtx.signature,"x-storage-u":n},i),custom:r})}},{key:"start",value:function start(e,t,r){this.successProcess=t,this.failProcess=r,this._st=Date.now(),this.mergeFile()}},{key:"eventInit",value:function eventInit(){var r=this,o=this.options.stage;this.transport.on("complete",function(t){try{var e=JSON.parse(t.response);0===e.success&&e.payload.key?(FileMerge_extends(r.currFileCtx,{stage:o,type:"success",hasMerge:!0,extra:{message:"merge file success"},xhr:t,stageStartTime:r._st,stageEndTime:Date.now(),duration:Date.now()-r._st,totalDuration:Date.now()-r._st+r.currFileCtx.totalDuration}),r.successProcess(r.currFileCtx)):r.fail({error:"fail! result.success:".concat(e.success),xhr:t})}catch(e){r.fail({error:"response parse error: ".concat(JSON.stringify(e)),xhr:t})}}),this.transport.on("error",function(e){r.fail({error:"request fail: ".concat(e.statusText||e.errText),xhr:e})})}},{key:"getProcessIndex",value:function getProcessIndex(e){var r=0;return e.forEach(function(e,t){"process"===e.stage&&(r=t)}),r}},{key:"fail",value:function fail(e){e=FileMerge_extends(this.currFileCtx,{extra:{message:"merge file error, ".concat(e.error),errorCode:Ke},type:"error",stage:this.options.stage,xhr:e.xhr,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currFileCtx.totalDuration});this.failProcess(e)}}]),FileMerge}();function DirectUpload_typeof(e){return(DirectUpload_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function DirectUpload_extends(){return(DirectUpload_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,o=arguments[t];for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}function DirectUpload_defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,function DirectUpload_toPropertyKey(e){e=function DirectUpload_toPrimitive(e,t){if("object"!==DirectUpload_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==DirectUpload_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===DirectUpload_typeof(e)?e:String(e)}(o.key),o)}}function DirectUpload_setPrototypeOf(e,t){return(DirectUpload_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function DirectUpload_createSuper(r){var o=function DirectUpload_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function _createSuperInternal(){var e,t=DirectUpload_getPrototypeOf(r);return function DirectUpload_possibleConstructorReturn(e,t){{if(t&&("object"===DirectUpload_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return function DirectUpload_assertThisInitialized(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(this,o?(e=DirectUpload_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function DirectUpload_getPrototypeOf(e){return(DirectUpload_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var et=function(){!function DirectUpload_inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&DirectUpload_setPrototypeOf(e,t)}(DirectUpload,s.a);var o=DirectUpload_createSuper(DirectUpload);function DirectUpload(e){var t,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return function DirectUpload_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,DirectUpload),(t=o.call(this)).options=e,t.file=e.file,t.context=e.context,t.key=e.key,t.config=r,t.finishArr=[],t.errorLength=0,t.finishSize=0,t.retryUploadTime=Number(r.retryUploadTime)||5,t.processRetry=0,t.lastFinishSize=-1,t.lastProcessPercent=-1,t.lastIntervalSize=-1,t}return function DirectUpload_createClass(e,t,r){t&&DirectUpload_defineProperties(e.prototype,t),r&&DirectUpload_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(DirectUpload,[{key:"start",value:function start(e,t,r){this.failProcess=r,this.successProcess=t,this.currentCtx=this.context.tasks[this.key],this.crc32Array=this.context.tasks[this.key].crc32Array,this._uploadSize=this.file.size,this.uploadHandlers={},this._st=Date.now(),this.upload()}},{key:"upload",value:function upload(){for(var t=this,r=this.crc32Array.length,o=0,n=0,e=0;e<r;e++){var i=this.crc32Array[e],s=i.buffer,i=i.crc32,a=this.currentCtx.oid,c=this.currentCtx.signature,a={oid:"[object Array]"===Object.prototype.toString.call(a)?a[e]:a,tosDomain:this.currentCtx.tosDomain},a=w.urlTemplate(this.config.directUploadFileUrl,a),u=this.config.userId,l=w.arrayToObject(this.currentCtx.UploadHeader),s=new $e({sliceItem:s,crc32:i,url:a,signature:"[object Array]"===Object.prototype.toString.call(c)?c[e]:c,uploadHeader:l,userId:u,retryTime:this.retryUploadTime,method:"put"});s.on("complete",function(e){n+ ++o===r&&t.success(e.xhr)}),s.on("error",function(e){++n===r&&t.fail(e.xhr)}),s.on("progress",function(e){t.process(e)}),(this.uploadHandlers["".concat(i,"_").concat(Math.round(1e3*Math.random()))]=s).upload()}}},{key:"success",value:function success(e){this.finishArr=[];var t=Date.now()-this._st,t=this._uploadSize/t,t=DirectUpload_extends(this.currentCtx,{type:"success",stage:"process",percent:100,extra:{message:"direct upload success"},speed:t,xhr:e,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currentCtx.totalDuration});this.successProcess(t)}},{key:"fail",value:function fail(e){e=DirectUpload_extends(this.currentCtx,{extra:{message:"direct upload error",errorCode:Le},type:"error",stage:"process",xhr:e,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currentCtx.totalDuration});this.failProcess(e)}},{key:"process",value:function process(e){var t=this.currentCtx.fileSize,e=(this.finishSize=e.loaded,this.finishSize>this.lastFinishSize&&(this.lastFinishSize=this.finishSize),Math.floor(this.finishSize/t*100*100)/100||0),t=DirectUpload_extends(this.currentCtx,{stage:"process",percent:e});e>this.lastProcessPercent&&100!==e&&(this.lastProcessPercent=e,this.context._broadcast("progress",t))}},{key:"stop",value:function stop(){Object.values(this.uploadHandlers).forEach(function(e){e.abort()})}}]),DirectUpload}();function CommitUpload_typeof(e){return(CommitUpload_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function CommitUpload_extends(){return(CommitUpload_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,o=arguments[t];for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}function CommitUpload_ownKeys(t,e){var r,o=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,r)),o}function CommitUpload_objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?CommitUpload_ownKeys(Object(r),!0).forEach(function(e){!function CommitUpload_defineProperty(e,t,r){(t=CommitUpload_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):CommitUpload_ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function CommitUpload_defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,CommitUpload_toPropertyKey(o.key),o)}}function CommitUpload_toPropertyKey(e){e=function CommitUpload_toPrimitive(e,t){if("object"!==CommitUpload_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==CommitUpload_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===CommitUpload_typeof(e)?e:String(e)}function CommitUpload_setPrototypeOf(e,t){return(CommitUpload_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function CommitUpload_createSuper(r){var o=function CommitUpload_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function _createSuperInternal(){var e,t=CommitUpload_getPrototypeOf(r);return function CommitUpload_possibleConstructorReturn(e,t){{if(t&&("object"===CommitUpload_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return function CommitUpload_assertThisInitialized(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(this,o?(e=CommitUpload_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function CommitUpload_getPrototypeOf(e){return(CommitUpload_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var tt=function(){!function CommitUpload_inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&CommitUpload_setPrototypeOf(e,t)}(CommitUpload,s.a);var o=CommitUpload_createSuper(CommitUpload);function CommitUpload(e,t){var r;return function CommitUpload_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,CommitUpload),(r=o.call(this)).options=e,r.config=t,r.uploaderCtx=e.context,r.currFileCtx=e.context.tasks[e.key],r.isImageBatchUpload=!!r.options.isImageBatchUpload,r.serviceName=e.serviceName||v,r.transport=new S,r.eventInit(),r}return function CommitUpload_createClass(e,t,r){t&&CommitUpload_defineProperties(e.prototype,t),r&&CommitUpload_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(CommitUpload,[{key:"commitUpload",value:function commitUpload(){var t,e=this.options.key,e=this.options.context.tasks[e],r=Oe[this.config.region],o="",n={},i=(this.serviceName===v?(i=this.config.videoConfig.spaceName,o=xe,n={Action:"CommitUploadInfo",Version:"2023-01-01"},t={SpaceName:i,SessionKey:e.SessionKey},(i=this.options.processAction)&&Array.isArray(i)&&0<i.length&&(t.Functions=this.options.processAction),this.options.callbackArgs&&(t.callbackArgs=this.options.callbackArgs)):(n={Action:"CommitImageUpload",Version:"2018-08-01",SessionKey:e.SessionKey},this.options.serviceId||this.config.imageConfig&&this.config.imageConfig.serviceId?n.ServiceId=this.options.serviceId||this.config.imageConfig.serviceId:n.SpaceName=this.config.videoConfig&&this.config.videoConfig.spaceName),this.config.accountId&&(n["X-Account-Id"]=this.config.accountId),w.toQueryString(n)),e=this.currFileCtx.proxyStsToken||this.config.stsToken,s=e.AccessKeyID,a=e.AccessKeyId,c=e.SecretAccessKey,e=e.SessionToken,o={method:"POST",url:"".concat(o,"?").concat(i),timeout:3e4,region:r,params:n,headers:{}};this.serviceName===v?(i=Object.keys(t).map(function(e){return"[object Array]"===Object.prototype.toString.call(t[e])||"[object Object]"===Object.prototype.toString.call(t[e])?"".concat(e,"=").concat(encodeURIComponent(JSON.stringify(t[e]))):"SessionKey"===e?"".concat(e,"=").concat(encodeURIComponent(t[e])):"".concat(e,"=").concat(t[e])}).join("&"),o.headers["Content-Type"]="application/x-www-form-urlencoded",o.body=i,o.custom=o.body):(o.custom="none",o.headers["Content-Type"]="application/json"),new Me(o,this.serviceName,{isVolcengine:!0}).addAuthorization({accessKeyId:a||s,secretAccessKey:c,sessionToken:e},new Date),this.transport.send(o)}},{key:"start",value:function start(e,t,r){this.successProcess=t,this.failProcess=r,this._st=Date.now();try{this.commitUpload()}catch(e){this.fail({error:"catch error: ".concat(e.toString())})}}},{key:"eventInit",value:function eventInit(){var a=this;this.transport.on("complete",function(t){try{var e,r,o,n,i,s=JSON.parse(t.response);s.ResponseMetadata.Error?a.fail({xhr:t,errorCode:s.ResponseMetadata.Error.CodeN,error:s.ResponseMetadata.Error.Code,message:s.ResponseMetadata.Error.Message}):(e=s.Result,r={},a.options.type===be&&a.config.imageConfig&&a.config.imageConfig.serviceId?a.isImageBatchUpload?(o=e.Results,n=e.PluginResult||[],o.forEach(function(e,t){o[t]=CommitUpload_objectSpread(CommitUpload_objectSpread({},o[t]),n[t])}),r=o):CommitUpload_extends(r=e.Results[0],e.PluginResult&&e.PluginResult[0]):r=e.Data,i=CommitUpload_extends(a.currFileCtx,{stage:"complete",type:"success",percent:100,extra:{message:"upload successful"},uploadResult:r,xhr:t,stageStartTime:a._st,stageEndTime:Date.now(),duration:Date.now()-a._st,totalDuration:Date.now()-a._st+a.currFileCtx.totalDuration}),a.successProcess&&a.successProcess(i))}catch(e){a.fail({error:"catch error: ".concat(e.toString()),xhr:t})}}),this.transport.on("error",function(e){var t={error:"request fail: ".concat(e.statusText||e.errText||"UNKNOWN"),xhr:e};if(e.response)try{var r=JSON.parse(e.response);r.ResponseMetadata&&r.ResponseMetadata.Error&&(t.errorCode=r.ResponseMetadata.Error.CodeN,t.error=r.ResponseMetadata.Error.Code,t.message=r.ResponseMetadata.Error.Message)}catch(e){}a.fail(t)})}},{key:"fail",value:function fail(e){var t=this.options.context,r=this.options.key,o=e.xhr,n=e.errorCode||qe,i="commit upload error: UNKNOWN",t=(o&&(i=0===o.status?"commit upload error: NETERROR":e.message||"commit upload error: ".concat(o.status)),CommitUpload_extends(t.tasks[r],{extra:{message:i,error:e.error,errorCode:n},type:"error",stage:"complete",xhr:o,stageStartTime:this._st,stageEndTime:Date.now(),duration:Date.now()-this._st,totalDuration:Date.now()-this._st+this.currFileCtx.totalDuration}));this.failProcess(t)}}]),CommitUpload}();function Queue_typeof(e){return(Queue_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Queue_extends(){return(Queue_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,o=arguments[t];for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}function Queue_defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,function Queue_toPropertyKey(e){e=function Queue_toPrimitive(e,t){if("object"!==Queue_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==Queue_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===Queue_typeof(e)?e:String(e)}(o.key),o)}}function Queue_setPrototypeOf(e,t){return(Queue_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function Queue_createSuper(r){var o=function Queue_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function _createSuperInternal(){var e,t=Queue_getPrototypeOf(r);return function Queue_possibleConstructorReturn(e,t){{if(t&&("object"===Queue_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return function Queue_assertThisInitialized(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(this,o?(e=Queue_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function Queue_getPrototypeOf(e){return(Queue_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var rt=function(){!function Queue_inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Queue_setPrototypeOf(e,t)}(Queue,s.a);var i=Queue_createSuper(Queue);function Queue(e){var t,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},o=2<arguments.length?arguments[2]:void 0,n=3<arguments.length?arguments[3]:void 0;return function Queue_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,Queue),(t=i.call(this,e)).tasks=e,t.config=r,t.key=n,t.uploaderCtx=o,t.current=0,t.length=t.tasks.length,t.taskError={},t.uploadList=[],t.retryTaskTime=r.retryTaskTime||3,t}return function Queue_createClass(e,t,r){t&&Queue_defineProperties(e.prototype,t),r&&Queue_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(Queue,[{key:"start",value:function start(){var e=this.tasks.shift();e&&(this.current=e.index,this.execTask(e))}},{key:"execTask",value:function execTask(r){var o=this,n=r.key,i=this.uploaderCtx,e=i.tasks[n].cacheTask,s=i.taskList[n].length;e&&0<r.index&&r.index<e?this.start():(i.tasks[n].currentTask=r.index,1===i.tasks[n].status&&r&&r.func.call(r.context,r.arg,function(e){var t=i.taskList[n][r.index+1];t&&0!==r.index?i._saveTask(n,{currentTask:t.index,stage:t.stage}):r.index===s-1&&i._removeTaskCache(n),o.success(e),0<o.tasks.length?o.start():i._queueSuccess(n)},function(e){e.xhr&&400<=e.xhr.status?o.fail(e):o.taskError[n]?o.taskError[n]<o.retryTaskTime?(o.taskError[n]++,o.execTask(r)):(e.key=n,o.fail(e)):(o.taskError[n]=1,o.execTask(r))}))}},{key:"addTask",value:function addTask(e){this.tasks.push(e)}},{key:"success",value:function success(e){var t;e.xhr&&(t=e.xhr,e.req={url:t.currentUrl,param:t.params},e.res={status:t.status,header:t.getAllResponseHeaders(),body:t.responseText},delete e.xhr),Queue_extends(e,{type:"success"});try{this.uploaderCtx._broadcast(e.stage,e)}catch(e){}this.uploaderCtx.logger.send(e)}},{key:"fail",value:function fail(e){var t,r=this.uploaderCtx;e.xhr&&(t=e.xhr,e.req={url:t.currentUrl,param:t.params},e.res={status:t.status,header:t.getAllResponseHeaders(),body:t.responseText},e.extra&&(e.extra.req=e.req,e.extra.res=e.res),delete e.xhr),Queue_extends(e,{type:"error"});try{r._broadcast("error",e)}catch(e){}r.logger.send(e),1!==e.currentTask&&(r.tasks[e.key].isBreak?r._cancel(e.key):r._pause(e.key))}},{key:"cancel",value:function cancel(e){var t=this.key,r=this.uploaderCtx.tasks[t].currentTask,r=this.uploaderCtx.tasks[t].isDirect?this.uploaderCtx.taskList[t][r-1]:this.uploaderCtx.taskList[t][r];e?r&&3===r.index&&(e=r.context,Object.values(e.uploadHandlers).forEach(function(e){e.abort()})):(this.tasks=[],r&&3===r.index&&r.context.stop(),this.uploaderCtx._removeTaskCache(t))}},{key:"restart",value:function restart(){this.uploadList.forEach(function(e){e.cancel=!1}),this.start()}}]),Queue}();function MainClass_typeof(e){return(MainClass_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function MainClass_extends(){return(MainClass_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,o=arguments[t];for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}function MainClass_defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,function MainClass_toPropertyKey(e){e=function MainClass_toPrimitive(e,t){if("object"!==MainClass_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==MainClass_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===MainClass_typeof(e)?e:String(e)}(o.key),o)}}function MainClass_setPrototypeOf(e,t){return(MainClass_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function MainClass_createSuper(r){var o=function MainClass_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function _createSuperInternal(){var e,t=MainClass_getPrototypeOf(r);return function MainClass_possibleConstructorReturn(e,t){{if(t&&("object"===MainClass_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return MainClass_assertThisInitialized(e)}(this,o?(e=MainClass_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function MainClass_assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function MainClass_getPrototypeOf(e){return(MainClass_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var ot=function(){!function MainClass_inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&MainClass_setPrototypeOf(e,t)}(MainClass,s.a);var r=MainClass_createSuper(MainClass);function MainClass(e){var t;return function MainClass_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,MainClass),(t=r.call(this,e)).config=MainClass_extends({},O),t._mergeOptions(t.config,e),t.tasks={},t.taskList={},t.cache={},t.storage=w.storage(MainClass_assertThisInitialized(t),t.config.useLocalStorage),t.logger=t.config.noLog?{send:function send(){}}:new Ce(t.config,MainClass_assertThisInitialized(t)),t}return function MainClass_createClass(e,t,r){t&&MainClass_defineProperties(e.prototype,t),r&&MainClass_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(MainClass,[{key:"_mergeOptions",value:function _mergeOptions(t,r){r&&"object"===MainClass_typeof(r)&&(MainClass_extends(t,r),t.log.userId=r.userId||t.userId,t.log.appId=r.appId||t.appId,Object.keys(r).forEach(function(e){"vodDomain"===e&&(t.replace[e]=r[e])}))}},{key:"_setCache",value:function _setCache(e,t){this.storage.setItem(e,t)}},{key:"_getCache",value:function _getCache(e){return this.storage.getItem(e)}},{key:"_removeCache",value:function _removeCache(e){e?this.storage.removeItem(e):this.storage.clear()}},{key:"_addTask",value:function _addTask(e,t){var r=this.tasks,o=this.taskList;r[e]&&r[e].task?o[e].push(t):(o[e]=[],o[e].push(t),r[e]=r[e]||{},r[e].task=new rt([],this.config,this,e)),r[e].task.addTask(t)}},{key:"_broadcast",value:function _broadcast(e,t){var r=this.tasks[t.key].status;if(r===m||0===r)try{this.emit(e,t)}catch(e){r=!("[object Error]"!==Object.prototype.toString.call(e));if(!r||"Error"===e.name)throw e}}},{key:"_addCrc32ProcessTask",value:function _addCrc32ProcessTask(e,t,r){var o=r.isDirect,r=r.isImageBatchUpload,e=new Ie({file:e.file,context:this,key:t,isDirect:o,isImageBatchUpload:r},this.config),o={context:e,func:e.start,arg:{},key:t,index:0,stage:"crc32"};this._addTask(t,o)}},{key:"_addPreUploadTask",value:function _addPreUploadTask(e,t,r){var o=r.isImageBatchUpload,r=r.serviceName,o={file:e.file,stsToken:e.stsToken,context:this,type:e.type||ve,preUploadUriParams:e.preUploadUriParams||{},storeKey:e.storeKey,key:t,isImageBatchUpload:o,fileName:e.fileName||null,fileExtension:e.fileExtension||null,storageClass:e.storageClass||null,serviceName:r},e=new Je(o,this.config),r={context:e,func:e.start,arg:{},key:t,index:1,stage:"preUpload"};this._addTask(t,r)}},{key:"_addDirectUploadTask",value:function _addDirectUploadTask(e,t,r){r=r.isImageBatchUpload,e=new et({file:e.file,context:this,key:t,isImageBatchUpload:r},this.config),r={context:e,func:e.start,arg:{},key:t,index:3,stage:"process"};this._addTask(t,r)}},{key:"_addInitUploadIDTask",value:function _addInitUploadIDTask(e,t){e=new Qe({file:e.file,context:this,key:t},this.config),e={context:e,func:e.start,arg:{},key:t,index:2,stage:"initUploadID"};this._addTask(t,e)}},{key:"_addUploadProcessTask",value:function _addUploadProcessTask(e,t){e=new Ze({file:e.file,context:this,key:t},this.config),e={context:e,func:e.start,arg:{},key:t,index:3,stage:"process"};this._addTask(t,e)}},{key:"_mergeFileTask",value:function _mergeFileTask(e,t){e=new Ye({file:e.file,context:this,stage:"fileMerge",key:t},this.config),e={context:e,func:e.start,arg:{},key:t,index:4,stage:"fileMerge"};this._addTask(t,e)}},{key:"_getMetaInfoTask",value:function _getMetaInfoTask(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},o=r.isImageBatchUpload,r=r.serviceName,o={file:e.file,context:this,data:e.data,type:e.type||ve,callbackArgs:e.callbackArgs,key:t,isImageBatchUpload:void 0!==o&&o,serviceName:r,processAction:e.processAction},r=new tt(o,this.config),e={context:r,func:r.start,arg:{},key:t,index:5,stage:"complete"};this._addTask(t,e)}},{key:"_addAllUploadProcess",value:function _addAllUploadProcess(e,t,r){var o=e.type===be&&"[object Array]"===Object.prototype.toString.call(e.file),n=(this.tasks[t]=this.tasks[t]||{},this.tasks[t].fileType=e.type||ve,this.tasks[t].fileSize=e.file&&e.file.size,this.tasks[t].proxyStsToken=e.stsToken,e.file.size<10485760||o);this._addCrc32ProcessTask(e,t,{isDirect:n,isImageBatchUpload:o}),this._addPreUploadTask(e,t,{isImageBatchUpload:o,serviceName:r}),n?this._addDirectUploadTask(e,t,{isImageBatchUpload:o}):(this._addInitUploadIDTask(e,t),this._addUploadProcessTask(e,t),this._mergeFileTask(e,t)),this._getMetaInfoTask(e,t,{isImageBatchUpload:o,serviceName:r})}},{key:"_run",value:function _run(e){var t=this.tasks,r=navigator.userAgent.toLowerCase().match(/msie ([\d.]+)/);r&&r[1]&&Number(r[1])<=9?(this._broadcast("error",MainClass_extends(t[e],{key:e,status:0,stage:"browserError",extra:{message:"cannot support the browser below ie10"},type:"error"})),this.logger.send(t[e]),this._cancel(e)):t[e]?t[e].status===Ee?this._restart(e):(r=new Date,t[e].startTime=r.getTime(),t[e].task&&t[e].status!==m&&t[e].task.tasks.length&&(t[e].status=m,this.logger.send(MainClass_extends({},t[e],{extra:{message:"start upload"},type:"start",key:e})),t[e].task.start())):console.warn("".concat(e," is not exit in object tasks, stop running..."))}},{key:"_restart",value:function _restart(r){var o,n,i=this,e=this.tasks;e[r]?(o=e[r].task,n=e[r].currentTask||0,this.taskList[r].forEach(function(e,t){e.index===n&&(o.tasks=i.taskList[r].slice(t))}),o&&e[r].status!==m&&o.tasks.length&&(e[r].status=m,o.restart())):console.warn("".concat(r," is not exit in object tasks"))}},{key:"_cancel",value:function _cancel(e){var t=this.tasks;t[e]?(t[e].status=ke,t[e].task.cancel(!1),this.taskList[e]=[]):console.warn("".concat(e," is not exit in object tasks"))}},{key:"_pause",value:function _pause(e){var t=this.tasks;t[e]?(t[e].status=Ee,t[e].task.cancel(!0),this._saveTask(e)):console.warn("".concat(e," is not exit in object tasks"))}},{key:"_removeTaskCache",value:function _removeTaskCache(e){var t=this.tasks;t[e]?(t=t[e].crc32Key)&&this._removeCache(t):console.warn("".concat(e," is not exit in object tasks"))}},{key:"_saveTask",value:function _saveTask(e,t){e=MainClass_extends({},this.tasks[e],t||{}),t=e.crc32Key;if(t){var r={SessionKey:e.SessionKey,UploadHeader:e.UploadHeader,fileName:e.fileName,oid:e.oid,uploadID:e.uploadID,signature:e.signature,tosDomain:e.tosDomain,hasMerge:e.hasMerge};Object.keys(r).forEach(function(e){r[e]||delete r[e]});try{this._setCache(t,JSON.stringify(r))}catch(e){return[!1,e.message]}return[!0,""]}}},{key:"_queueSuccess",value:function _queueSuccess(e){var t,r=this.tasks;r[e]?(t=new Date,r[e].endTime=t.getTime(),r[e].time=r[e].endTime-r[e].startTime,r[e].status=0,this.taskList[e]=[]):console.warn("".concat(e," is not exit in object tasks"))}},{key:"_removeFile",value:function _removeFile(e){delete this.tasks[e]}},{key:"_batchAction",value:function _batchAction(t){var e=this.tasks;Object.keys(e).forEach(function(e){t&&t(e)})}},{key:"_refreshStsToken",value:function _refreshStsToken(o){var n=this,i=this.tasks;Object.keys(i).forEach(function(e){var e=i[e],t=MainClass_extends({},e,{proxyStsToken:o}),r=(e.proxyStsToken=o,t.crc32Key);r&&(delete t.task,delete t.xhr,delete t.crc32Array,e.proxyStsToken=o,n._setCache(r,JSON.stringify(t)))})}},{key:"_setOption",value:function _setOption(e){this._mergeOptions(this.config,e)}},{key:"_setServiceId",value:function _setServiceId(e){!this.config.imageConfig&&e?this.config.imageConfig={serviceId:e}:this.config.imageConfig.serviceId=e}},{key:"_getServiceId",value:function _getServiceId(){var e;return null==(e=this.config.imageConfig)?void 0:e.serviceId}},{key:"_getOption",value:function _getOption(e){var t=MainClass_extends({},this.config);return Object.keys(t).forEach(function(e){(-1<e.indexOf("Url")||"replace"===e||"log"===e)&&delete t[e]}),e?t[e]:t}},{key:"_userCancel",value:function _userCancel(e){var t=this,r=this.tasks;e?(this._cancel(e),this.logger.send(MainClass_extends({},r[e],{type:"cancel"}))):Object.keys(r).forEach(function(e){t._cancel(e),t.logger.send(MainClass_extends({},r[e],{type:"cancel"}))})}},{key:"_userPause",value:function _userPause(e){var t=this,r=this.tasks;e?(this._pause(e),this.logger.send(MainClass_extends({},r[e],{type:"pause"}))):Object.keys(r).forEach(function(e){t._pause(e),t.logger.send(MainClass_extends({},r[e],{type:"pause"}))})}}]),MainClass}(),nt={checkFile:function checkFile(){},checkStsToken:function checkStsToken(e){return!e||e.SessionToken&&e.SecretAccessKey&&(e.AccessKeyId||e.AccessKeyID)}};function entry_typeof(e){return(entry_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function entry_defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,function entry_toPropertyKey(e){e=function entry_toPrimitive(e,t){if("object"!==entry_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==entry_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"===entry_typeof(e)?e:String(e)}(o.key),o)}}function entry_setPrototypeOf(e,t){return(entry_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function entry_createSuper(r){var o=function entry_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function _createSuperInternal(){var e,t=entry_getPrototypeOf(r);return function entry_possibleConstructorReturn(e,t){{if(t&&("object"===entry_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return function entry_assertThisInitialized(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(this,o?(e=entry_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function entry_getPrototypeOf(e){return(entry_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var it=function(){!function entry_inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&entry_setPrototypeOf(e,t)}(TTUploader,ot);var e=entry_createSuper(TTUploader);function TTUploader(){return function entry_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,TTUploader),e.apply(this,arguments)}return function entry_createClass(e,t,r){t&&entry_defineProperties(e.prototype,t),r&&entry_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(TTUploader,[{key:"start",value:function start(e){this.abort=!1,e?this._run(e):this._batchAction(this._run.bind(this))}},{key:"addFile",value:function addFile(e){var t;return e&&nt.checkStsToken(e.stsToken)?e.file&&e.file instanceof Blob?(t=w.getUnique("file"),this._addAllUploadProcess(e,t,v),t):(this.emit("error",{extra:{message:He,errorCode:Re}}),null):(this.emit("error",{extra:{message:Ve,errorCode:Be}}),null)}},{key:"removeFile",value:function removeFile(e){e&&this._removeFile(e)}},{key:"cancel",value:function cancel(e){e?this._userCancel(e):this._batchAction(this._userCancel.bind(this))}},{key:"pause",value:function pause(e){this._userPause(e)}},{key:"restart",value:function restart(e){e?this._restart(e):this._batchAction(this._restart.bind(this))}},{key:"refreshAuth",value:function refreshAuth(e){this._refreshAuth(e)}},{key:"setOption",value:function setOption(e){this._setOption(e)}},{key:"getOption",value:function getOption(e){return this._getOption(e)}}]),TTUploader}()}]).default});
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@byteplus/uploader",
3
+ "version": "0.0.1",
4
+ "description": "byteplus vod uploader",
5
+ "main": "dist/index.js",
6
+ "typings": "./types/index.d.ts",
7
+ "scripts": {
8
+ "build-umd": "webpack --config webpack.config.js --progress --colors --display-modules -p",
9
+ "build": "rm -rf dist && npm run build-umd",
10
+ "demo": "NODE_ENV=development webpack --config webpack.config.js --watch --devtool cheap-module-eval-source-map",
11
+ "prepublish": "npm run build",
12
+ "beta": "npm publish --tag beta"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "types"
17
+ ],
18
+ "publishConfig": {
19
+ "registry": "https://registry.npmjs.org"
20
+ },
21
+ "license": "BSD-3-Clause",
22
+ "devDependencies": {
23
+ "@babel/core": "^7.6.4",
24
+ "@babel/plugin-proposal-class-properties": "^7.5.5",
25
+ "@babel/plugin-transform-object-assign": "^7.2.0",
26
+ "@babel/preset-env": "^7.6.3",
27
+ "babel-eslint": "^10.0.3",
28
+ "babel-loader": "^8.0.6",
29
+ "eslint": "^6.8.0",
30
+ "uglifyjs-webpack-plugin": "^2.2.0",
31
+ "webpack": "^4.41.2",
32
+ "webpack-cli": "^3.3.9",
33
+ "worker-loader": "^2.0.0"
34
+ },
35
+ "dependencies": {
36
+ "crypto-js": "^4.1.1",
37
+ "events": "^1.1.1"
38
+ },
39
+ "unpkg": true
40
+ }
@@ -0,0 +1,70 @@
1
+ export interface STSToken {
2
+ AccessKeyId: string
3
+ SecretAccessKey: string
4
+ SessionToken: string
5
+ ExpiredTime: string
6
+ CurrentTime: string
7
+ }
8
+
9
+ export interface Action {
10
+ name: 'GetMeta' | 'StartWorkflow' | 'Snapshot' | 'AddOptionInfo'
11
+ input?: any
12
+ }
13
+
14
+ export interface VideoConfig {
15
+ spaceName: string
16
+ processAction?: Action[]
17
+ }
18
+
19
+ export interface ImageConfig {
20
+ serviceId: string
21
+ }
22
+
23
+ export interface ObjectConfig {
24
+ spaceName: string
25
+ processAction?: Action[]
26
+ }
27
+
28
+ export interface Options {
29
+ userId: string
30
+ appId: number
31
+ videoConfig?: VideoConfig
32
+ imageConfig?: ImageConfig
33
+
34
+ useFileExtension?: boolean
35
+ noLog?: boolean
36
+ }
37
+
38
+ export interface UpdateOptions {
39
+ userId?: string
40
+ appId?: number
41
+ videoConfig?: VideoConfig
42
+ imageConfig?: ImageConfig
43
+
44
+ useFileExtension?: boolean
45
+ useLocalStorage?: boolean
46
+ }
47
+
48
+ export interface FileOption {
49
+ file: Blob
50
+ stsToken: STSToken
51
+ storeKey?: string | string[]
52
+ type?: 'video' | 'image' | 'object' | 'media'
53
+ callbackArgs?: string
54
+ fileName?: string
55
+ fileExtension?: string
56
+ storageClass?: 1 | 2
57
+ processAction?: Action[]
58
+ }
59
+
60
+ export default class BytePlusUploader {
61
+ constructor(options: Options)
62
+ addFile(fileOption: FileOption): string
63
+ start(key?: string): void
64
+ pause(key?: string): void
65
+ cancel(key?: string): void
66
+ on(eventName: 'complete' | 'error' | 'progress', callback: (info: object) => void): void
67
+ once(eventName: 'complete' | 'error' | 'progress', callback: (info: object) => void): void
68
+ removeListener(eventName: 'complete' | 'error' | 'progress', callback: (info: object) => void): void
69
+ removeAllListeners(eventName: 'complete' | 'error' | 'progress'): void
70
+ }