ulearning-obs
Version:
obs
1 lines • 67.9 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Obs=e():t.Obs=e()}(window,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=5)}([function(t,e,n){"use strict";e.decode=e.parse=n(4),e.encode=e.stringify=n(3)},function(t,e,n){t.exports=function(t){"use strict";var e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function n(t,e){var n=t[0],r=t[1],o=t[2],i=t[3];n+=(r&o|~r&i)+e[0]-680876936|0,i+=((n=(n<<7|n>>>25)+r|0)&r|~n&o)+e[1]-389564586|0,o+=((i=(i<<12|i>>>20)+n|0)&n|~i&r)+e[2]+606105819|0,r+=((o=(o<<17|o>>>15)+i|0)&i|~o&n)+e[3]-1044525330|0,n+=((r=(r<<22|r>>>10)+o|0)&o|~r&i)+e[4]-176418897|0,i+=((n=(n<<7|n>>>25)+r|0)&r|~n&o)+e[5]+1200080426|0,o+=((i=(i<<12|i>>>20)+n|0)&n|~i&r)+e[6]-1473231341|0,r+=((o=(o<<17|o>>>15)+i|0)&i|~o&n)+e[7]-45705983|0,n+=((r=(r<<22|r>>>10)+o|0)&o|~r&i)+e[8]+1770035416|0,i+=((n=(n<<7|n>>>25)+r|0)&r|~n&o)+e[9]-1958414417|0,o+=((i=(i<<12|i>>>20)+n|0)&n|~i&r)+e[10]-42063|0,r+=((o=(o<<17|o>>>15)+i|0)&i|~o&n)+e[11]-1990404162|0,n+=((r=(r<<22|r>>>10)+o|0)&o|~r&i)+e[12]+1804603682|0,i+=((n=(n<<7|n>>>25)+r|0)&r|~n&o)+e[13]-40341101|0,o+=((i=(i<<12|i>>>20)+n|0)&n|~i&r)+e[14]-1502002290|0,r+=((o=(o<<17|o>>>15)+i|0)&i|~o&n)+e[15]+1236535329|0,n+=((r=(r<<22|r>>>10)+o|0)&i|o&~i)+e[1]-165796510|0,i+=((n=(n<<5|n>>>27)+r|0)&o|r&~o)+e[6]-1069501632|0,o+=((i=(i<<9|i>>>23)+n|0)&r|n&~r)+e[11]+643717713|0,r+=((o=(o<<14|o>>>18)+i|0)&n|i&~n)+e[0]-373897302|0,n+=((r=(r<<20|r>>>12)+o|0)&i|o&~i)+e[5]-701558691|0,i+=((n=(n<<5|n>>>27)+r|0)&o|r&~o)+e[10]+38016083|0,o+=((i=(i<<9|i>>>23)+n|0)&r|n&~r)+e[15]-660478335|0,r+=((o=(o<<14|o>>>18)+i|0)&n|i&~n)+e[4]-405537848|0,n+=((r=(r<<20|r>>>12)+o|0)&i|o&~i)+e[9]+568446438|0,i+=((n=(n<<5|n>>>27)+r|0)&o|r&~o)+e[14]-1019803690|0,o+=((i=(i<<9|i>>>23)+n|0)&r|n&~r)+e[3]-187363961|0,r+=((o=(o<<14|o>>>18)+i|0)&n|i&~n)+e[8]+1163531501|0,n+=((r=(r<<20|r>>>12)+o|0)&i|o&~i)+e[13]-1444681467|0,i+=((n=(n<<5|n>>>27)+r|0)&o|r&~o)+e[2]-51403784|0,o+=((i=(i<<9|i>>>23)+n|0)&r|n&~r)+e[7]+1735328473|0,r+=((o=(o<<14|o>>>18)+i|0)&n|i&~n)+e[12]-1926607734|0,n+=((r=(r<<20|r>>>12)+o|0)^o^i)+e[5]-378558|0,i+=((n=(n<<4|n>>>28)+r|0)^r^o)+e[8]-2022574463|0,o+=((i=(i<<11|i>>>21)+n|0)^n^r)+e[11]+1839030562|0,r+=((o=(o<<16|o>>>16)+i|0)^i^n)+e[14]-35309556|0,n+=((r=(r<<23|r>>>9)+o|0)^o^i)+e[1]-1530992060|0,i+=((n=(n<<4|n>>>28)+r|0)^r^o)+e[4]+1272893353|0,o+=((i=(i<<11|i>>>21)+n|0)^n^r)+e[7]-155497632|0,r+=((o=(o<<16|o>>>16)+i|0)^i^n)+e[10]-1094730640|0,n+=((r=(r<<23|r>>>9)+o|0)^o^i)+e[13]+681279174|0,i+=((n=(n<<4|n>>>28)+r|0)^r^o)+e[0]-358537222|0,o+=((i=(i<<11|i>>>21)+n|0)^n^r)+e[3]-722521979|0,r+=((o=(o<<16|o>>>16)+i|0)^i^n)+e[6]+76029189|0,n+=((r=(r<<23|r>>>9)+o|0)^o^i)+e[9]-640364487|0,i+=((n=(n<<4|n>>>28)+r|0)^r^o)+e[12]-421815835|0,o+=((i=(i<<11|i>>>21)+n|0)^n^r)+e[15]+530742520|0,r+=((o=(o<<16|o>>>16)+i|0)^i^n)+e[2]-995338651|0,n+=(o^((r=(r<<23|r>>>9)+o|0)|~i))+e[0]-198630844|0,i+=(r^((n=(n<<6|n>>>26)+r|0)|~o))+e[7]+1126891415|0,o+=(n^((i=(i<<10|i>>>22)+n|0)|~r))+e[14]-1416354905|0,r+=(i^((o=(o<<15|o>>>17)+i|0)|~n))+e[5]-57434055|0,n+=(o^((r=(r<<21|r>>>11)+o|0)|~i))+e[12]+1700485571|0,i+=(r^((n=(n<<6|n>>>26)+r|0)|~o))+e[3]-1894986606|0,o+=(n^((i=(i<<10|i>>>22)+n|0)|~r))+e[10]-1051523|0,r+=(i^((o=(o<<15|o>>>17)+i|0)|~n))+e[1]-2054922799|0,n+=(o^((r=(r<<21|r>>>11)+o|0)|~i))+e[8]+1873313359|0,i+=(r^((n=(n<<6|n>>>26)+r|0)|~o))+e[15]-30611744|0,o+=(n^((i=(i<<10|i>>>22)+n|0)|~r))+e[6]-1560198380|0,r+=(i^((o=(o<<15|o>>>17)+i|0)|~n))+e[13]+1309151649|0,n+=(o^((r=(r<<21|r>>>11)+o|0)|~i))+e[4]-145523070|0,i+=(r^((n=(n<<6|n>>>26)+r|0)|~o))+e[11]-1120210379|0,o+=(n^((i=(i<<10|i>>>22)+n|0)|~r))+e[2]+718787259|0,r=((r+=(i^((o=(o<<15|o>>>17)+i|0)|~n))+e[9]-343485551|0)<<21|r>>>11)+o|0,t[0]=n+t[0]|0,t[1]=r+t[1]|0,t[2]=o+t[2]|0,t[3]=i+t[3]|0}function r(t){var e,n=[];for(e=0;e<64;e+=4)n[e>>2]=t.charCodeAt(e)+(t.charCodeAt(e+1)<<8)+(t.charCodeAt(e+2)<<16)+(t.charCodeAt(e+3)<<24);return n}function o(t){var e,n=[];for(e=0;e<64;e+=4)n[e>>2]=t[e]+(t[e+1]<<8)+(t[e+2]<<16)+(t[e+3]<<24);return n}function i(t){var e,o,i,s,a,u,c=t.length,l=[1732584193,-271733879,-1732584194,271733878];for(e=64;e<=c;e+=64)n(l,r(t.substring(e-64,e)));for(t=t.substring(e-64),o=t.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e=0;e<o;e+=1)i[e>>2]|=t.charCodeAt(e)<<(e%4<<3);if(i[e>>2]|=128<<(e%4<<3),e>55)for(n(l,i),e=0;e<16;e+=1)i[e]=0;return s=(s=8*c).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(s[2],16),u=parseInt(s[1],16)||0,i[14]=a,i[15]=u,n(l,i),l}function s(t){var n,r="";for(n=0;n<4;n+=1)r+=e[t>>8*n+4&15]+e[t>>8*n&15];return r}function a(t){var e;for(e=0;e<t.length;e+=1)t[e]=s(t[e]);return t.join("")}function u(t){return/[\u0080-\uFFFF]/.test(t)&&(t=unescape(encodeURIComponent(t))),t}function c(t){var e,n=[],r=t.length;for(e=0;e<r-1;e+=2)n.push(parseInt(t.substr(e,2),16));return String.fromCharCode.apply(String,n)}function l(){this.reset()}return a(i("hello")),"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function e(t,e){return(t=0|t||0)<0?Math.max(t+e,0):Math.min(t,e)}ArrayBuffer.prototype.slice=function(n,r){var o,i,s,a,u=this.byteLength,c=e(n,u),l=u;return r!==t&&(l=e(r,u)),c>l?new ArrayBuffer(0):(o=l-c,i=new ArrayBuffer(o),s=new Uint8Array(i),a=new Uint8Array(this,c,o),s.set(a),i)}}(),l.prototype.append=function(t){return this.appendBinary(u(t)),this},l.prototype.appendBinary=function(t){this._buff+=t,this._length+=t.length;var e,o=this._buff.length;for(e=64;e<=o;e+=64)n(this._hash,r(this._buff.substring(e-64,e)));return this._buff=this._buff.substring(e-64),this},l.prototype.end=function(t){var e,n,r=this._buff,o=r.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e<o;e+=1)i[e>>2]|=r.charCodeAt(e)<<(e%4<<3);return this._finish(i,o),n=a(this._hash),t&&(n=c(n)),this.reset(),n},l.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},l.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},l.prototype.setState=function(t){return this._buff=t.buff,this._length=t.length,this._hash=t.hash,this},l.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},l.prototype._finish=function(t,e){var r,o,i,s=e;if(t[s>>2]|=128<<(s%4<<3),s>55)for(n(this._hash,t),s=0;s<16;s+=1)t[s]=0;r=(r=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(r[2],16),i=parseInt(r[1],16)||0,t[14]=o,t[15]=i,n(this._hash,t)},l.hash=function(t,e){return l.hashBinary(u(t),e)},l.hashBinary=function(t,e){var n=a(i(t));return e?c(n):n},l.ArrayBuffer=function(){this.reset()},l.ArrayBuffer.prototype.append=function(t){var e,r=function(t,e,n){var r=new Uint8Array(t.byteLength+e.byteLength);return r.set(new Uint8Array(t)),r.set(new Uint8Array(e),t.byteLength),n?r:r.buffer}(this._buff.buffer,t,!0),i=r.length;for(this._length+=t.byteLength,e=64;e<=i;e+=64)n(this._hash,o(r.subarray(e-64,e)));return this._buff=e-64<i?new Uint8Array(r.buffer.slice(e-64)):new Uint8Array(0),this},l.ArrayBuffer.prototype.end=function(t){var e,n,r=this._buff,o=r.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e<o;e+=1)i[e>>2]|=r[e]<<(e%4<<3);return this._finish(i,o),n=a(this._hash),t&&(n=c(n)),this.reset(),n},l.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},l.ArrayBuffer.prototype.getState=function(){var t=l.prototype.getState.call(this);return t.buff=function(t){return String.fromCharCode.apply(null,new Uint8Array(t))}(t.buff),t},l.ArrayBuffer.prototype.setState=function(t){return t.buff=function(t,e){var n,r=t.length,o=new ArrayBuffer(r),i=new Uint8Array(o);for(n=0;n<r;n+=1)i[n]=t.charCodeAt(n);return e?i:o}(t.buff,!0),l.prototype.setState.call(this,t)},l.ArrayBuffer.prototype.destroy=l.prototype.destroy,l.ArrayBuffer.prototype._finish=l.prototype._finish,l.ArrayBuffer.hash=function(t,e){var r=a(function(t){var e,r,i,s,a,u,c=t.length,l=[1732584193,-271733879,-1732584194,271733878];for(e=64;e<=c;e+=64)n(l,o(t.subarray(e-64,e)));for(t=e-64<c?t.subarray(e-64):new Uint8Array(0),r=t.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e=0;e<r;e+=1)i[e>>2]|=t[e]<<(e%4<<3);if(i[e>>2]|=128<<(e%4<<3),e>55)for(n(l,i),e=0;e<16;e+=1)i[e]=0;return s=(s=8*c).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(s[2],16),u=parseInt(s[1],16)||0,i[14]=a,i[15]=u,n(l,i),l}(new Uint8Array(t)));return e?c(r):r},l}()},function(t,e,n){"use strict";n.r(e);var r,o=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(t){t.InvalidFile="InvalidFile",t.InvalidToken="InvalidToken",t.InvalidMetadata="InvalidMetadata",t.InvalidChunkSize="InvalidChunkSize",t.InvalidCustomVars="InvalidCustomVars",t.NotAvailableUploadHost="NotAvailableUploadHost",t.ReadCacheFailed="ReadCacheFailed",t.InvalidCacheData="InvalidCacheData",t.WriteCacheFailed="WriteCacheFailed",t.RemoveCacheFailed="RemoveCacheFailed",t.GetCanvasContextFailed="GetCanvasContextFailed",t.UnsupportedFileType="UnsupportedFileType",t.FileReaderReadFailed="FileReaderReadFailed",t.NotAvailableXMLHttpRequest="NotAvailableXMLHttpRequest",t.InvalidProgressEventTarget="InvalidProgressEventTarget",t.RequestError="RequestError"}(r||(r={}));var i=function(){return function(t,e){this.name=t,this.message=e,this.stack=(new Error).stack}}(),s=function(t){function e(e,n,o,i){var s=t.call(this,r.RequestError,o)||this;return s.code=e,s.reqId=n,s.isRequestError=!0,s.data=i,s}return o(e,t),e}(i),a=function(t){function e(e,n){return void 0===n&&(n=""),t.call(this,0,n,e)||this}return o(e,t),e}(s),u=function(){function t(t,e){this.runTask=t,this.limit=e,this.queue=[],this.processing=[]}return t.prototype.enqueue=function(t){var e=this;return new Promise(function(n,r){e.queue.push({task:t,resolve:n,reject:r}),e.check()})},t.prototype.run=function(t){var e=this;this.queue=this.queue.filter(function(e){return e!==t}),this.processing.push(t),this.runTask(t.task).then(function(){e.processing=e.processing.filter(function(e){return e!==t}),t.resolve(),e.check()},function(e){return t.reject(e)})},t.prototype.check=function(){var t=this,e=this.processing.length,n=this.limit-e;this.queue.slice(0,n).forEach(function(e){t.run(e)})},t}(),c=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),l=function(){return(l=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},h=function(t){function e(e,n,r){var o=t.call(this)||this;return o.isStopped=!1,o.destination=e&&"object"==typeof e?e:l(l(l({},e&&{next:e}),n&&{error:n}),r&&{complete:r}),o}return c(e,t),e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},e.prototype.next=function(t){!this.isStopped&&this.destination.next&&this.destination.next(t)},e.prototype.error=function(t){!this.isStopped&&this.destination.error&&(this.isStopped=!0,this.destination.error(t))},e.prototype.complete=function(t){!this.isStopped&&this.destination.complete&&(this.isStopped=!0,this.destination.complete(t))},e}(function(){function t(){this.closed=!1}return t.prototype.unsubscribe=function(){this.closed||(this.closed=!0,this._unsubscribe&&this._unsubscribe())},t.prototype.add=function(t){this._unsubscribe=t},t}()),f=function(){function t(t){this._subscribe=t}return t.prototype.subscribe=function(t,e,n){var r=new h(t,e,n);return r.add(this._subscribe(r)),r},t}();function p(t){var e,n,r,o,i,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,u=0,c="",l=[];if(!t)return t;t=function(t){if(null===t||void 0===t)return"";var e,n,r,o=t+"",i="";e=n=0,r=o.length;for(var s=0;s<r;s++){var a=o.charCodeAt(s),u=null;if(a<128)n++;else if(a>127&&a<2048)u=String.fromCharCode(a>>6|192,63&a|128);else if((63488&a^55296)>0)u=String.fromCharCode(a>>12|224,a>>6&63|128,63&a|128);else{if((64512&a^55296)>0)throw new RangeError("Unmatched trail surrogate at "+s);var c=o.charCodeAt(++s);if((64512&c^56320)>0)throw new RangeError("Unmatched lead surrogate at "+(s-1));a=((1023&a)<<10)+(1023&c)+65536,u=String.fromCharCode(a>>18|240,a>>12&63|128,a>>6&63|128,63&a|128)}null!==u&&(n>e&&(i+=o.slice(e,n)),i+=u,e=n=s+1)}return n>e&&(i+=o.slice(e,r)),i}(t+"");do{e=(i=t.charCodeAt(a++)<<16|t.charCodeAt(a++)<<8|t.charCodeAt(a++))>>18&63,n=i>>12&63,r=i>>6&63,o=63&i,l[u++]=s.charAt(e)+s.charAt(n)+s.charAt(r)+s.charAt(o)}while(a<t.length);switch(c=l.join(""),t.length%3){case 1:c=c.slice(0,-2)+"==";break;case 2:c=c.slice(0,-1)+"="}return c}function d(t){var e,n,r,o,i,s,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u=0,c=0,l=[];if(!t)return t;t+="";do{e=(s=a.indexOf(t.charAt(u++))<<18|a.indexOf(t.charAt(u++))<<12|(o=a.indexOf(t.charAt(u++)))<<6|(i=a.indexOf(t.charAt(u++))))>>16&255,n=s>>8&255,r=255&s,l[c++]=64===o?String.fromCharCode(e):64===i?String.fromCharCode(e,n):String.fromCharCode(e,n,r)}while(u<t.length);return function(t){var e=[],n=0,r=0,o=0;for(t+="";n<t.length;){o=0,(r=255&t.charCodeAt(n))<=191?(r&=127,o=1):r<=223?(r&=31,o=2):r<=239?(r&=15,o=3):(r&=7,o=4);for(var i=1;i<o;++i)r=r<<6|63&t.charCodeAt(i+n);4===o?(r-=65536,e.push(String.fromCharCode(55296|r>>10&1023)),e.push(String.fromCharCode(56320|1023&r))):e.push(String.fromCharCode(r)),n+=o}return e.join("")}(l.join(""))}function g(t){return(t=p(t)).replace(/\//g,"_").replace(/\+/g,"-")}function y(t){return d(t=t.replace(/_/g,"/").replace(/-/g,"+"))}var m,v=n(1),b=n.n(v),w=function(){return(w=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},k=function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){t.done?o(t.value):function(t){return t instanceof n?t:new n(function(e){e(t)})}(t.value).then(s,a)}u((r=r.apply(t,e||[])).next())})},x=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},C=Math.pow(1024,2);function I(t,e){try{localStorage.removeItem(t)}catch(n){e.warn(new i(r.RemoveCacheFailed,"removeLocalFileInfo failed. key: "+t))}}function O(t){return{Authorization:"UpToken "+t}}function S(t){var e=O(t);return w({"content-type":"application/octet-stream"},e)}function U(t){var e=O(t);return w({"content-type":"application/json"},e)}function P(){if(window.XMLHttpRequest)return new XMLHttpRequest;if(window.ActiveXObject)return new window.ActiveXObject("Microsoft.XMLHTTP");throw new i(r.NotAvailableXMLHttpRequest,"the current environment does not support.")}function R(t){return k(this,void 0,void 0,function(){var e,n;return x(this,function(o){switch(o.label){case 0:return[4,function(t){return new Promise(function(e,n){var o=new FileReader;o.onload=function(t){if(t.target){var o=t.target.result;e(o)}else n(new i(r.InvalidProgressEventTarget,"progress event target is undefined"))},o.onerror=function(){n(new i(r.FileReaderReadFailed,"fileReader read failed"))},o.readAsArrayBuffer(t)})}(t)];case 1:return e=o.sent(),(n=new b.a.ArrayBuffer).append(e),[2,n.end()]}})})}function z(t,e){return new Promise(function(n,r){var o=P();if(o.open(e.method,t),e.onCreate&&e.onCreate(o),e.headers){var i=e.headers;Object.keys(i).forEach(function(t){o.setRequestHeader(t,i[t])})}o.upload.addEventListener("progress",function(t){t.lengthComputable&&e.onProgress&&e.onProgress({loaded:t.loaded,total:t.total})}),o.onreadystatechange=function(){var t=o.responseText;if(4===o.readyState){var e=o.getResponseHeader("x-reqId")||"";if(0!==o.status)if(200===o.status)try{n({data:JSON.parse(t),reqId:e})}catch(t){r(t)}else{var i="xhr request failed, code: "+o.status;t&&(i+=" response: "+t);var u=void 0;try{u=JSON.parse(t)}catch(t){}r(new s(o.status,e,i,u))}else r(new a("network error.",e))}},o.send(e.body)})}function A(t){if(!t)throw new i(r.InvalidToken,"invalid token.");var e=t.split(":");if(1===e.length)throw new i(r.InvalidToken,"invalid token segments.");var n=e.length>3?e[1]:e[0];if(!n)throw new i(r.InvalidToken,"missing assess key field.");var o=null;try{o=JSON.parse(y(e[e.length-1]))}catch(t){throw new i(r.InvalidToken,"token parse failed.")}if(null==o)throw new i(r.InvalidToken,"putPolicy is null.");if(null==o.scope)throw new i(r.InvalidToken,"scope field is null.");var s=o.scope.split(":")[0];if(!s)throw new i(r.InvalidToken,"resolve bucketName failed.");return{assessKey:n,bucketName:s,scope:o.scope}}var T={z0:"z0",z1:"z1",z2:"z2",na0:"na0",as0:"as0",cnEast2:"cn-east-2"},_=((m={})[T.z0]={srcUphost:["up.qiniup.com"],cdnUphost:["upload.qiniup.com"]},m[T.z1]={srcUphost:["up-z1.qiniup.com"],cdnUphost:["upload-z1.qiniup.com"]},m[T.z2]={srcUphost:["up-z2.qiniup.com"],cdnUphost:["upload-z2.qiniup.com"]},m[T.na0]={srcUphost:["up-na0.qiniup.com"],cdnUphost:["upload-na0.qiniup.com"]},m[T.as0]={srcUphost:["up-as0.qiniup.com"],cdnUphost:["upload-as0.qiniup.com"]},m[T.cnEast2]={srcUphost:["up-cn-east-2.qiniup.com"],cdnUphost:["upload-cn-east-2.qiniup.com"]},m),E=n(0),H=function(){return(H=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},M=function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){t.done?o(t.value):function(t){return t instanceof n?t:new n(function(e){e(t)})}(t.value).then(s,a)}u((r=r.apply(t,e||[])).next())})},j=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};function q(t,e,n){return M(this,void 0,void 0,function(){var r;return j(this,function(o){return r=Object(E.stringify)({ak:t,bucket:e}),[2,z(n+"://api.qiniu.com/v2/query?"+r,{method:"GET"})]})})}function L(t,e,n){var r=n.url,o=n.id;return r+"/buckets/"+t+"/objects/"+(null!=e?g(e):"~")+"/uploads/"+o}function F(t,e,n){return z(L(A(t).bucketName,e,n),{method:"DELETE",headers:O(t)})}function N(t,e){return M(this,void 0,void 0,function(){var n,r,o,i,s;return j(this,function(a){switch(a.label){case 0:return n=kt(t),r=n.upprotocol,n.uphost.length>0?[2,r+"://"+n.uphost[0]]:[4,q((o=A(e)).assessKey,o.bucketName,r)];case 1:return i=a.sent(),s=i.data.up.acc.main,[2,r+"://"+s[0]]}})})}var D=function(){return(D=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},B=function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){t.done?o(t.value):function(t){return t instanceof n?t:new n(function(e){e(t)})}(t.value).then(s,a)}u((r=r.apply(t,e||[])).next())})},K=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},G=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},V=4,X=[0,502,503,504,599],J=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(G(arguments[e]));return t}(X,[612]),$=Math.pow(1024,3),W=function(){function t(t,e,n,r){this.hostPool=n,this.logger=r,this.aborted=!1,this.retryCount=0,this.xhrList=[],this.config=t.config,r.info("config inited.",this.config),this.putExtra=D({fname:""},t.putExtra),r.info("putExtra inited.",this.putExtra),this.key=t.key,this.file=t.file,this.token=t.token,this.onData=e.onData,this.onError=e.onError,this.onComplete=e.onComplete;try{var o=A(this.token);this.bucketName=o.bucketName,this.assessKey=o.assessKey}catch(t){r.error("get putPolicy from token failed.",t),this.onError(t)}}return t.prototype.checkAndUpdateUploadHost=function(){return B(this,void 0,void 0,function(){var t;return K(this,function(e){switch(e.label){case 0:return this.logger.info("get available upload host."),[4,this.hostPool.getUp(this.assessKey,this.bucketName,this.config.upprotocol)];case 1:if(null==(t=e.sent()))throw new i(r.NotAvailableUploadHost,"no available upload host.");return null!=this.uploadHost&&this.uploadHost.host!==t.host?this.logger.warn("host switches from "+this.uploadHost.host+" to "+t.host+"."):this.logger.info("use host "+t.host+"."),this.uploadHost=t,[2]}})})},t.prototype.checkAndUnfreezeHost=function(){this.logger.info("check unfreeze host."),null!=this.uploadHost&&this.uploadHost.isFrozen()&&(this.logger.warn(this.uploadHost.host+" will be unfrozen."),this.uploadHost.unfreeze())},t.prototype.checkAndFreezeHost=function(t){this.logger.info("check freeze host."),t instanceof s&&null!=this.uploadHost&&X.includes(t.code)&&(this.logger.warn(this.uploadHost.host+" will be temporarily frozen."),this.uploadHost.freeze())},t.prototype.handleError=function(t){this.logger.error(t.message),this.onError(t)},t.prototype.putFile=function(){return B(this,void 0,void 0,function(){var t,e,n,o,a;return K(this,function(u){switch(u.label){case 0:if(this.aborted=!1,this.putExtra.fname||(this.logger.info("use file.name as fname."),this.putExtra.fname=this.file.name),this.file.size>1e4*$)return this.handleError(new i(r.InvalidFile,"file size exceed maximum value 10000G")),[2];if(this.putExtra.customVars&&!function(t){return Object.keys(t).every(function(t){return 0===t.indexOf("x:")})}(this.putExtra.customVars))return this.handleError(new i(r.InvalidCustomVars,"customVars key should start width x:")),[2];if(this.putExtra.metadata&&!function(t){return Object.keys(t).every(function(t){return 0===t.indexOf("x-qn-meta-")})}(this.putExtra.metadata))return this.handleError(new i(r.InvalidMetadata,"metadata key should start with x-qn-meta-")),[2];u.label=1;case 1:return u.trys.push([1,4,,5]),this.uploadAt=(new Date).getTime(),[4,this.checkAndUpdateUploadHost()];case 2:return u.sent(),[4,this.run()];case 3:return t=u.sent(),this.onComplete(t.data),this.checkAndUnfreezeHost(),this.sendLog(t.reqId,200),[2];case 4:return e=u.sent(),this.logger.error(e),this.clear(),e instanceof s&&(n=this.aborted?"":e.reqId,o=this.aborted?-2:e.code,this.sendLog(n,o),this.checkAndFreezeHost(e),a=++this.retryCount<=this.config.retryCount,!this.aborted&&J.includes(e.code)&&a)?(this.logger.warn("error auto retry: "+this.retryCount+"/"+this.config.retryCount+"."),this.putFile(),[2]):(this.onError(e),[3,5]);case 5:return[2]}})})},t.prototype.clear=function(){this.logger.info("start cleaning all xhr."),this.xhrList.forEach(function(t){t.onreadystatechange=null,t.abort()}),this.logger.info("cleanup completed."),this.xhrList=[]},t.prototype.stop=function(){this.logger.info("stop."),this.clear(),this.aborted=!0},t.prototype.addXhr=function(t){this.xhrList.push(t)},t.prototype.sendLog=function(t,e){var n,r;this.logger.report({code:e,reqId:t,remoteIp:"",upType:"jssdk-h5",size:this.file.size,time:Math.floor(this.uploadAt/1e3),port:function(t){if(t&&t.match){var e=t.match(/(^https?)/);if(!e)return"";var n=e[1];return(e=t.match(/^https?:\/\/([^:^/]*):(\d*)/))?e[2]:"http"===n?"80":"443"}return""}(null===(n=this.uploadHost)||void 0===n?void 0:n.getUrl()),host:function(t){if(t&&t.match){var e=t.match(/^https?:\/\/([^:^/]*)/);return e?e[1]:""}return""}(null===(r=this.uploadHost)||void 0===r?void 0:r.getUrl()),bytesSent:this.progress?this.progress.total.loaded:0,duration:Math.floor(((new Date).getTime()-this.uploadAt)/1e3)})},t.prototype.getProgressInfoItem=function(t,e,n){return D({size:e,loaded:t,percent:t/e*100},null==n?{}:{fromCache:n})},t}(),Q=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Z=function(){return(Z=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},Y=function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){t.done?o(t.value):function(t){return t instanceof n?t:new n(function(e){e(t)})}(t.value).then(s,a)}u((r=r.apply(t,e||[])).next())})},tt=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};var et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Q(e,t),e.prototype.run=function(){return Y(this,void 0,void 0,function(){var t,e,n,o,a,c=this;return tt(this,function(l){switch(l.label){case 0:if(this.logger.info("start run Resume."),!this.config.chunkSize||!function(t){return/^[1-9]\d*$/.test(String(t))}(this.config.chunkSize))throw new i(r.InvalidChunkSize,"chunkSize must be a positive integer");if(this.config.chunkSize>1024)throw new i(r.InvalidChunkSize,"chunkSize maximum value is 1024");return[4,this.initBeforeUploadChunks()];case 1:l.sent(),t=new u(function(t){return c.uploadChunk(t)},this.config.concurrentRequestLimit),e=null,n=this.getLocalKey(),o=this.chunks.map(function(e,n){return t.enqueue({chunk:e,index:n})}),l.label=2;case 2:return l.trys.push([2,5,,6]),[4,Promise.all(o)];case 3:return l.sent(),[4,this.mkFileReq()];case 4:return e=l.sent(),[3,6];case 5:throw(a=l.sent())instanceof s&&(612===a.code||400===a.code)&&I(n,this.logger),a;case 6:return I(n,this.logger),[2,e]}})})},e.prototype.uploadChunk=function(t){return Y(this,void 0,void 0,function(){var e,n,r,o,i,s,a,u,c,l=this;return tt(this,function(h){switch(h.label){case 0:return e=t.index,n=t.chunk,r=this.cachedUploadedList[e],this.logger.info("upload part "+e+", cache:",r),o=this.config.checkByMD5,i=function(){l.usedCacheList[e]=!0,l.updateChunkProgress(n.size,e),l.uploadedList[e]=r,l.updateLocalCache()},r&&!o?(i(),[2]):[4,R(n)];case 1:return s=h.sent(),this.logger.info("computed part md5.",s),r&&s===r.md5?(i(),[2]):(this.usedCacheList[e]=!1,u={body:n,onProgress:a=function(t){l.updateChunkProgress(t.loaded,e)},onCreate:function(t){return l.addXhr(t)}},this.logger.info("part "+e+" start uploading."),[4,function(t,e,n,r,o){return z(L(A(t).bucketName,e,r)+"/"+n,H(H({},o),{method:"PUT",headers:S(t)}))}(this.token,this.key,t.index+1,this.getUploadInfo(),u)]);case 2:return c=h.sent(),this.logger.info("part "+e+" upload completed."),a({loaded:n.size,total:n.size}),this.uploadedList[e]={etag:c.data.etag,md5:c.data.md5,size:n.size},this.updateLocalCache(),[2]}})})},e.prototype.mkFileReq=function(){return Y(this,void 0,void 0,function(){var t,e,n=this;return tt(this,function(r){switch(r.label){case 0:return t=Z(Z(Z({parts:this.uploadedList.map(function(t,e){return{etag:t.etag,partNumber:e+1}}),fname:this.putExtra.fname},this.putExtra.mimeType&&{mimeType:this.putExtra.mimeType}),this.putExtra.customVars&&{customVars:this.putExtra.customVars}),this.putExtra.metadata&&{metadata:this.putExtra.metadata}),this.logger.info("parts upload completed, make file.",t),[4,function(t,e,n,r){return z(L(A(t).bucketName,e,n),H(H({},r),{method:"POST",headers:U(t)}))}(this.token,this.key,this.getUploadInfo(),{onCreate:function(t){return n.addXhr(t)},body:JSON.stringify(t)})];case 1:return e=r.sent(),this.logger.info("finish Resume Progress."),this.updateMkFileProgress(1),[2,e]}})})},e.prototype.initBeforeUploadChunks=function(){return Y(this,void 0,void 0,function(){var t,e,n;return tt(this,function(o){switch(o.label){case 0:return this.uploadedList=[],this.usedCacheList=[],(t=function(t,e){var n=null;try{n=localStorage.getItem(t)}catch(n){e.warn(new i(r.ReadCacheFailed,"getLocalFileInfo failed. key: "+t))}if(null==n)return null;var o=null;try{o=JSON.parse(n)}catch(n){I(t,e),e.warn(new i(r.InvalidCacheData,"getLocalFileInfo failed to parse. key: "+t))}return o}(this.getLocalKey(),this.logger))?[3,2]:(this.logger.info("init upload parts from api."),[4,function(t,e,n,r){return z(r+"/buckets/"+e+"/objects/"+(null!=n?g(n):"~")+"/uploads",{method:"POST",headers:O(t)})}(this.token,this.bucketName,this.key,this.uploadHost.getUrl())]);case 1:return e=o.sent(),this.logger.info("initd upload parts of id: "+e.data.uploadId+"."),this.uploadId=e.data.uploadId,this.cachedUploadedList=[],[3,3];case 2:n=["resume upload parts from local cache,","total "+t.data.length+" part,","id is "+t.id+"."],this.logger.info(n.join(" ")),this.cachedUploadedList=t.data,this.uploadId=t.id,o.label=3;case 3:return this.chunks=function(t,e){var n=e*C;if(n>t.size)n=t.size;else for(;t.size>1e4*n;)n*=2;for(var r=[],o=Math.ceil(t.size/n),i=0;i<o;i++){var s=t.slice(n*i,i===o-1?t.size:n*(i+1));r.push(s)}return r}(this.file,this.config.chunkSize),this.loaded={mkFileProgress:0,chunks:this.chunks.map(function(t){return 0})},this.notifyResumeProgress(),[2]}})})},e.prototype.getUploadInfo=function(){return{id:this.uploadId,url:this.uploadHost.getUrl()}},e.prototype.getLocalKey=function(){return function(t,e,n){return"qiniu_js_sdk_upload_file_name_"+t+(null==e?"_":"_key_"+e+"_")+"size_"+n}(this.file.name,this.key,this.file.size)},e.prototype.updateLocalCache=function(){!function(t,e,n){try{localStorage.setItem(t,JSON.stringify(e))}catch(e){n.warn(new i(r.WriteCacheFailed,"setLocalFileInfo failed: "+t))}}(this.getLocalKey(),{id:this.uploadId,data:this.uploadedList},this.logger)},e.prototype.updateChunkProgress=function(t,e){this.loaded.chunks[e]=t,this.notifyResumeProgress()},e.prototype.updateMkFileProgress=function(t){this.loaded.mkFileProgress=t,this.notifyResumeProgress()},e.prototype.notifyResumeProgress=function(){var t=this;this.progress={total:this.getProgressInfoItem(function(t){return t.reduce(function(t,e){return t+e},0)}(this.loaded.chunks)+this.loaded.mkFileProgress,this.file.size+1),chunks:this.chunks.map(function(e,n){var r=t.usedCacheList[n];return t.getProgressInfoItem(t.loaded.chunks[n],e.size,r)}),uploadInfo:{id:this.uploadId,url:this.uploadHost.getUrl()}},this.onData(this.progress)},e}(W),nt=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),rt=function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){t.done?o(t.value):function(t){return t instanceof n?t:new n(function(e){e(t)})}(t.value).then(s,a)}u((r=r.apply(t,e||[])).next())})},ot=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},it=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return nt(e,t),e.prototype.run=function(){return rt(this,void 0,void 0,function(){var t,e,n,r=this;return ot(this,function(o){switch(o.label){case 0:return this.logger.info("start run Direct."),(t=new FormData).append("file",this.file),t.append("token",this.token),null!=this.key&&t.append("key",this.key),t.append("fname",this.putExtra.fname),this.putExtra.customVars&&(this.logger.info("init customVars."),e=this.putExtra.customVars,Object.keys(e).forEach(function(n){return t.append(n,e[n].toString())}),this.logger.info("customVars inited.")),this.logger.info("formData inited."),[4,function(t,e,n){return z(t,H({method:"POST",body:e},n))}(this.uploadHost.getUrl(),t,{onProgress:function(t){r.updateDirectProgress(t.loaded,t.total)},onCreate:function(t){return r.addXhr(t)}})];case 1:return n=o.sent(),this.logger.info("Direct progress finish."),this.finishDirectProgress(),[2,n]}})})},e.prototype.updateDirectProgress=function(t,e){this.progress={total:this.getProgressInfoItem(t,e+1)},this.onData(this.progress)},e.prototype.finishDirectProgress=function(){if(!this.progress)return this.logger.warn("progress is null."),this.progress={total:this.getProgressInfoItem(this.file.size,this.file.size)},void this.onData(this.progress);var t=this.progress.total;this.progress={total:this.getProgressInfoItem(t.loaded+1,t.size)},this.onData(this.progress)},e}(W);var st=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},at=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(st(arguments[e]));return t},ut=function(){function t(e,n,r,o){void 0===n&&(n=!0),void 0===r&&(r="OFF"),void 0===o&&(o="UPLOAD"),this.token=e,this.disableReport=n,this.level=r,this.prefix=o,this.id=++t.id}return t.prototype.getPrintPrefix=function(t){return"Qiniu-JS-SDK ["+t+"]["+this.prefix+"#"+this.id+"]:"},t.prototype.report=function(t,e){if(!this.disableReport)try{!function t(e,n,r){void 0===r&&(r=3);var o=P();o.open("POST","https://uplog.qbox.me/log/3"),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),o.setRequestHeader("Authorization",O(e).Authorization),o.onreadystatechange=function(){4===o.readyState&&200!==o.status&&r>0&&t(e,n,r-1)};var i=[n.code||"",n.reqId||"",n.host||"",n.remoteIp||"",n.port||"",n.duration||"",n.time||"",n.bytesSent||"",n.upType||"",n.size||""].join(",");o.send(i)}(this.token,t,e)}catch(t){this.warn(t)}},t.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];["INFO"].includes(this.level)&&console.log.apply(console,at([this.getPrintPrefix("INFO")],t))},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];["INFO","WARN"].includes(this.level)&&console.warn.apply(console,at([this.getPrintPrefix("WARN")],t))},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];["INFO","WARN","ERROR"].includes(this.level)&&console.error.apply(console,at([this.getPrintPrefix("ERROR")],t))},t.id=0,t}(),ct=function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){t.done?o(t.value):function(t){return t instanceof n?t:new n(function(e){e(t)})}(t.value).then(s,a)}u((r=r.apply(t,e||[])).next())})},lt=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},ht=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},ft=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(ht(arguments[e]));return t},pt=new Map,dt=function(){function t(t,e){this.host=t,this.protocol=e}return t.prototype.isFrozen=function(){var t=(new Date).getTime(),e=pt.get(this.host);return null!=e&&e>=t},t.prototype.freeze=function(t){void 0===t&&(t=20);var e=(new Date).getTime()+1e3*t;pt.set(this.host,e)},t.prototype.unfreeze=function(){pt.delete(this.host)},t.prototype.getUrl=function(){return this.protocol+"://"+this.host},t.prototype.getUnfreezeTime=function(){return pt.get(this.host)},t}(),gt=function(){function t(t){void 0===t&&(t=[]),this.initHosts=t,this.cachedHostsMap=new Map}return t.prototype.register=function(t,e,n,r){this.cachedHostsMap.set(t+"@"+e,n.map(function(t){return new dt(t,r)}))},t.prototype.refresh=function(t,e,n){var r,o,i,s;return ct(this,void 0,void 0,function(){var a,u;return lt(this,function(c){switch(c.label){case 0:return(this.cachedHostsMap.get(t+"@"+e)||[]).length>0?[2]:this.initHosts.length>0?(this.register(t,e,this.initHosts,n),[2]):[4,q(t,e,n)];case 1:return null!=(null===(a=c.sent())||void 0===a?void 0:a.data)&&(u=ft((null===(o=null===(r=a.data.up)||void 0===r?void 0:r.acc)||void 0===o?void 0:o.main)||[],(null===(s=null===(i=a.data.up)||void 0===i?void 0:i.acc)||void 0===s?void 0:s.backup)||[]),this.register(t,e,u,n)),[2]}})})},t.prototype.getUp=function(t,e,n){return ct(this,void 0,void 0,function(){var r,o;return lt(this,function(i){switch(i.label){case 0:return[4,this.refresh(t,e,n)];case 1:return i.sent(),0===(r=this.cachedHostsMap.get(t+"@"+e)||[]).length?[2,null]:(o=r.filter(function(t){return!t.isFrozen()})).length>0?[2,o[0]]:[2,r.slice().sort(function(t,e){return(t.getUnfreezeTime()||0)-(e.getUnfreezeTime()||0)})[0]]}})})},t}();function yt(t,e,n,r,o){var i=new ut(n,null===o||void 0===o?void 0:o.disableStatisticsReport,null===o||void 0===o?void 0:o.debugLogLevel,t.name),s={file:t,key:e,token:n,putExtra:r,config:kt(o,i)},a=new gt(s.config.uphost);return new f(function(t){var e=function(t,e,n,r){return t.config&&t.config.forceDirect?(r.info("ues forceDirect mode."),new it(t,e,n,r)):t.file.size>4*C?(r.info("file size over 4M, use Resume."),new et(t,e,n,r)):(r.info("file size less or equal than 4M, use Direct."),new it(t,e,n,r))}(s,{onData:function(e){return t.next(e)},onError:function(e){return t.error(e)},onComplete:function(e){return t.complete(e)}},a,i);return e.putFile(),e.stop.bind(e)})}var mt=function(){return(mt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},vt=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n},bt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},wt=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(bt(arguments[e]));return t};function kt(t,e){var n=mt({},t),r=n.upprotocol,o=n.uphost,i=vt(n,["upprotocol","uphost"]),s=mt({uphost:[],retryCount:3,checkByMD5:!1,forceDirect:!1,useCdnDomain:!0,concurrentRequestLimit:3,chunkSize:V,upprotocol:"https",debugLogLevel:"OFF",disableStatisticsReport:!1},i);r&&(s.upprotocol=r.replace(/:$/,""));var a=[];if(e&&null!=(null===t||void 0===t?void 0:t.uphost)&&null!=(null===t||void 0===t?void 0:t.region)&&e.warn("do not use both the uphost and region config."),o)Array.isArray(o)?a.push.apply(a,wt(o)):a.push(o);else if(null===s||void 0===s?void 0:s.region){var u=_[null===s||void 0===s?void 0:s.region];s.useCdnDomain?a.push.apply(a,wt(u.cdnUphost)):a.push.apply(a,wt(u.srcUphost))}return mt(mt({},s),{uphost:a.filter(Boolean)})}var xt=function(){return(xt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},Ct=function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){t.done?o(t.value):function(t){return t instanceof n?t:new n(function(e){e(t)})}(t.value).then(s,a)}u((r=r.apply(t,e||[])).next())})},It=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},Ot={PNG:"image/png",JPEG:"image/jpeg",WEBP:"image/webp",BMP:"image/bmp"},St=Math.log(2),Ut=Object.keys(Ot).map(function(t){return Ot[t]}),Pt=Ot.JPEG;var Rt=function(){function t(t,e){this.file=t,this.config=e,this.config=xt({quality:.92,noCompressIfLarger:!1},this.config)}return t.prototype.process=function(){return Ct(this,void 0,void 0,function(){var t,e,n,o,s,a;return It(this,function(u){switch(u.label){case 0:if(this.outputType=this.file.type,t={},!function(t){return Ut.includes(t)}(this.file.type))throw new i(r.UnsupportedFileType,"unsupported file type: "+this.file.type);return[4,this.getOriginImage()];case 1:return e=u.sent(),[4,this.getCanvas(e)];case 2:return n=u.sent(),o=1,this.config.maxWidth&&(o=Math.min(1,this.config.maxWidth/n.width)),this.config.maxHeight&&(o=Math.min(1,o,this.config.maxHeight/n.height)),t.width=n.width,t.height=n.height,[4,this.doScale(n,o)];case 3:return s=u.sent(),(a=this.toBlob(s)).size>this.file.size&&this.config.noCompressIfLarger?[2,{dist:this.file,width:t.width,height:t.height}]:[2,{dist:a,width:s.width,height:s.height}]}})})},t.prototype.clear=function(t,e,n){this.outputType===Pt?(t.fillStyle="#fff",t.fillRect(0,0,e,n)):t.clearRect(0,0,e,n)},t.prototype.getOriginImage=function(){var t=this;return new Promise(function(e,n){var r=function(t){return(window.URL||window.webkitURL||window.mozURL).createObjectURL(t)}(t.file),o=new Image;o.onload=function(){e(o)},o.onerror=function(){n("image load error")},o.src=r})},t.prototype.getCanvas=function(t){var e=this;return new Promise(function(n,o){var s=document.createElement("canvas"),a=s.getContext("2d");if(a){var u=t.width,c=t.height;s.height=c,s.width=u,e.clear(a,u,c),a.drawImage(t,0,0),n(s)}else o(new i(r.GetCanvasContextFailed,"context is null"))})},t.prototype.doScale=function(t,e){return Ct(this,void 0,void 0,function(){var n,o,s,a,u,c,l,h,f,p,d,g,y,m,v,b;return It(this,function(w){if(1===e)return[2,t];if(n=t.getContext("2d"),o=Math.min(4,Math.ceil(1/e/St)),s=Math.pow(e,1/o),a=document.createElement("canvas"),u=a.getContext("2d"),c=t.width,l=t.height,h=c,f=l,a.width=c,a.height=l,!u||!n)throw new i(r.GetCanvasContextFailed,"mctx or sctx can't be null");for(g=0;g<o;g++)y=c*s|0,m=l*s|0,g===o-1&&(y=h*e,m=f*e),g%2==0?(p=t,d=u):(p=