uploader-qiniu-d4c6a936.a413bed1.js 50 KB

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