uploader-qiniu-dcdce4b8.CSJKBIZb.js 49 KB

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