import{d as t,k as e,X as r,p as n,r as o,o as i,j as a,at as s,w as u,e as l,t as c,b as h,c as f,s as p,a as d,f as g,bZ as y,O as b,b_ as v,$ as m,_ as w}from"./index-9b91a2d9.js";import{h as _}from"./http-46f56a71.js";/* empty css *//* empty css */var k,T,x,C=globalThis&&globalThis.__extends||(k=function(t,e){return(k=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}k(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});(x=T||(T={})).InvalidFile="InvalidFile",x.InvalidToken="InvalidToken",x.InvalidMetadata="InvalidMetadata",x.InvalidChunkSize="InvalidChunkSize",x.InvalidCustomVars="InvalidCustomVars",x.NotAvailableUploadHost="NotAvailableUploadHost",x.ReadCacheFailed="ReadCacheFailed",x.InvalidCacheData="InvalidCacheData",x.WriteCacheFailed="WriteCacheFailed",x.RemoveCacheFailed="RemoveCacheFailed",x.GetCanvasContextFailed="GetCanvasContextFailed",x.UnsupportedFileType="UnsupportedFileType",x.FileReaderReadFailed="FileReaderReadFailed",x.NotAvailableXMLHttpRequest="NotAvailableXMLHttpRequest",x.InvalidProgressEventTarget="InvalidProgressEventTarget",x.RequestError="RequestError";var A=function(t,e){this.name=t,this.message=e,this.stack=(new Error).stack},S=function(t){function e(e,r,n,o){var i=t.call(this,T.RequestError,n)||this;return i.code=e,i.reqId=r,i.isRequestError=!0,i.data=o,i}return C(e,t),e}(A),I=function(t){function e(e,r){return void 0===r&&(r=""),t.call(this,0,r,e)||this}return C(e,t),e}(S),O=function(){function t(t,e){this.runTask=t,this.limit=e,this.aborted=!1,this.queue=[],this.processing=[]}return t.prototype.enqueue=function(t){var e=this;return new Promise((function(r,n){e.queue.push({task:t,resolve:r,reject:n}),e.check()}))},t.prototype.run=function(t){var e=this;this.queue=this.queue.filter((function(e){return e!==t})),this.processing.push(t),this.runTask(t.task).then((function(){e.processing=e.processing.filter((function(e){return e!==t})),t.resolve(),e.check()}),(function(e){return t.reject(e)}))},t.prototype.check=function(){var t=this;if(!this.aborted){var e=this.processing.length,r=this.limit-e;this.queue.slice(0,r).forEach((function(e){t.run(e)}))}},t.prototype.abort=function(){this.queue=[],this.aborted=!0},t}(),P=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),U=globalThis&&globalThis.__assign||function(){return U=Object.assign||function(t){for(var e,r=1,n=arguments.length;r127&&s<2048)u=String.fromCharCode(s>>6|192,63&s|128);else if((63488&s^55296)>0)u=String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128);else{if((64512&s^55296)>0)throw new RangeError("Unmatched trail surrogate at "+a);var l=o.charCodeAt(++a);if((64512&l^56320)>0)throw new RangeError("Unmatched lead surrogate at "+(a-1));s=((1023&s)<<10)+(1023&l)+65536,u=String.fromCharCode(s>>18|240,s>>12&63|128,s>>6&63|128,63&s|128)}null!==u&&(r>e&&(i+=o.slice(e,r)),i+=u,e=r=a+1)}return r>e&&(i+=o.slice(e,n)),i}(t+"");do{e=(i=t.charCodeAt(s++)<<16|t.charCodeAt(s++)<<8|t.charCodeAt(s++))>>18&63,r=i>>12&63,n=i>>6&63,o=63&i,c[u++]=a.charAt(e)+a.charAt(r)+a.charAt(n)+a.charAt(o)}while(s>16&255,r=a>>8&255,n=255&a,c[l++]=64===o?String.fromCharCode(e):64===i?String.fromCharCode(e,r):String.fromCharCode(e,r,n)}while(u>10&1023)),e.push(String.fromCharCode(56320|1023&n))):e.push(String.fromCharCode(n)),r+=o}return e.join("")}(c.join(""))}function L(t){return(t=z(t)).replace(/\//g,"_").replace(/\+/g,"-")}!function(t){function e(e,r,n){var o=t.call(this)||this;return o.isStopped=!1,o.destination=e&&"object"==typeof e?e:U(U(U({},e&&{next:e}),r&&{error:r}),n&&{complete:n}),o}P(e,t),e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},e.prototype.next=function(t){!this.isStopped&&this.destination.next&&this.destination.next(t)},e.prototype.error=function(t){!this.isStopped&&this.destination.error&&(this.isStopped=!0,this.destination.error(t))},e.prototype.complete=function(t){!this.isStopped&&this.destination.complete&&(this.isStopped=!0,this.destination.complete(t))}}(function(){function t(){this.closed=!1}return t.prototype.unsubscribe=function(){this.closed||(this.closed=!0,this._unsubscribe&&this._unsubscribe())},t.prototype.add=function(t){this._unsubscribe=t},t}());var E={};({get exports(){return E},set exports(t){E=t}}).exports=function(t){var e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function r(t,e){var r=t[0],n=t[1],o=t[2],i=t[3];n=((n+=((o=((o+=((i=((i+=((r=((r+=(n&o|~n&i)+e[0]-680876936|0)<<7|r>>>25)+n|0)&n|~r&o)+e[1]-389564586|0)<<12|i>>>20)+r|0)&r|~i&n)+e[2]+606105819|0)<<17|o>>>15)+i|0)&i|~o&r)+e[3]-1044525330|0)<<22|n>>>10)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n&o|~n&i)+e[4]-176418897|0)<<7|r>>>25)+n|0)&n|~r&o)+e[5]+1200080426|0)<<12|i>>>20)+r|0)&r|~i&n)+e[6]-1473231341|0)<<17|o>>>15)+i|0)&i|~o&r)+e[7]-45705983|0)<<22|n>>>10)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n&o|~n&i)+e[8]+1770035416|0)<<7|r>>>25)+n|0)&n|~r&o)+e[9]-1958414417|0)<<12|i>>>20)+r|0)&r|~i&n)+e[10]-42063|0)<<17|o>>>15)+i|0)&i|~o&r)+e[11]-1990404162|0)<<22|n>>>10)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n&o|~n&i)+e[12]+1804603682|0)<<7|r>>>25)+n|0)&n|~r&o)+e[13]-40341101|0)<<12|i>>>20)+r|0)&r|~i&n)+e[14]-1502002290|0)<<17|o>>>15)+i|0)&i|~o&r)+e[15]+1236535329|0)<<22|n>>>10)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n&i|o&~i)+e[1]-165796510|0)<<5|r>>>27)+n|0)&o|n&~o)+e[6]-1069501632|0)<<9|i>>>23)+r|0)&n|r&~n)+e[11]+643717713|0)<<14|o>>>18)+i|0)&r|i&~r)+e[0]-373897302|0)<<20|n>>>12)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n&i|o&~i)+e[5]-701558691|0)<<5|r>>>27)+n|0)&o|n&~o)+e[10]+38016083|0)<<9|i>>>23)+r|0)&n|r&~n)+e[15]-660478335|0)<<14|o>>>18)+i|0)&r|i&~r)+e[4]-405537848|0)<<20|n>>>12)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n&i|o&~i)+e[9]+568446438|0)<<5|r>>>27)+n|0)&o|n&~o)+e[14]-1019803690|0)<<9|i>>>23)+r|0)&n|r&~n)+e[3]-187363961|0)<<14|o>>>18)+i|0)&r|i&~r)+e[8]+1163531501|0)<<20|n>>>12)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n&i|o&~i)+e[13]-1444681467|0)<<5|r>>>27)+n|0)&o|n&~o)+e[2]-51403784|0)<<9|i>>>23)+r|0)&n|r&~n)+e[7]+1735328473|0)<<14|o>>>18)+i|0)&r|i&~r)+e[12]-1926607734|0)<<20|n>>>12)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n^o^i)+e[5]-378558|0)<<4|r>>>28)+n|0)^n^o)+e[8]-2022574463|0)<<11|i>>>21)+r|0)^r^n)+e[11]+1839030562|0)<<16|o>>>16)+i|0)^i^r)+e[14]-35309556|0)<<23|n>>>9)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n^o^i)+e[1]-1530992060|0)<<4|r>>>28)+n|0)^n^o)+e[4]+1272893353|0)<<11|i>>>21)+r|0)^r^n)+e[7]-155497632|0)<<16|o>>>16)+i|0)^i^r)+e[10]-1094730640|0)<<23|n>>>9)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n^o^i)+e[13]+681279174|0)<<4|r>>>28)+n|0)^n^o)+e[0]-358537222|0)<<11|i>>>21)+r|0)^r^n)+e[3]-722521979|0)<<16|o>>>16)+i|0)^i^r)+e[6]+76029189|0)<<23|n>>>9)+o|0,n=((n+=((o=((o+=((i=((i+=((r=((r+=(n^o^i)+e[9]-640364487|0)<<4|r>>>28)+n|0)^n^o)+e[12]-421815835|0)<<11|i>>>21)+r|0)^r^n)+e[15]+530742520|0)<<16|o>>>16)+i|0)^i^r)+e[2]-995338651|0)<<23|n>>>9)+o|0,n=((n+=((i=((i+=(n^((r=((r+=(o^(n|~i))+e[0]-198630844|0)<<6|r>>>26)+n|0)|~o))+e[7]+1126891415|0)<<10|i>>>22)+r|0)^((o=((o+=(r^(i|~n))+e[14]-1416354905|0)<<15|o>>>17)+i|0)|~r))+e[5]-57434055|0)<<21|n>>>11)+o|0,n=((n+=((i=((i+=(n^((r=((r+=(o^(n|~i))+e[12]+1700485571|0)<<6|r>>>26)+n|0)|~o))+e[3]-1894986606|0)<<10|i>>>22)+r|0)^((o=((o+=(r^(i|~n))+e[10]-1051523|0)<<15|o>>>17)+i|0)|~r))+e[1]-2054922799|0)<<21|n>>>11)+o|0,n=((n+=((i=((i+=(n^((r=((r+=(o^(n|~i))+e[8]+1873313359|0)<<6|r>>>26)+n|0)|~o))+e[15]-30611744|0)<<10|i>>>22)+r|0)^((o=((o+=(r^(i|~n))+e[6]-1560198380|0)<<15|o>>>17)+i|0)|~r))+e[13]+1309151649|0)<<21|n>>>11)+o|0,n=((n+=((i=((i+=(n^((r=((r+=(o^(n|~i))+e[4]-145523070|0)<<6|r>>>26)+n|0)|~o))+e[11]-1120210379|0)<<10|i>>>22)+r|0)^((o=((o+=(r^(i|~n))+e[2]+718787259|0)<<15|o>>>17)+i|0)|~r))+e[9]-343485551|0)<<21|n>>>11)+o|0,t[0]=r+t[0]|0,t[1]=n+t[1]|0,t[2]=o+t[2]|0,t[3]=i+t[3]|0}function n(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t.charCodeAt(e)+(t.charCodeAt(e+1)<<8)+(t.charCodeAt(e+2)<<16)+(t.charCodeAt(e+3)<<24);return r}function o(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t[e]+(t[e+1]<<8)+(t[e+2]<<16)+(t[e+3]<<24);return r}function i(t){var e,o,i,a,s,u,l=t.length,c=[1732584193,-271733879,-1732584194,271733878];for(e=64;e<=l;e+=64)r(c,n(t.substring(e-64,e)));for(o=(t=t.substring(e-64)).length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e=0;e>2]|=t.charCodeAt(e)<<(e%4<<3);if(i[e>>2]|=128<<(e%4<<3),e>55)for(r(c,i),e=0;e<16;e+=1)i[e]=0;return a=(a=8*l).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(a[2],16),u=parseInt(a[1],16)||0,i[14]=s,i[15]=u,r(c,i),c}function a(t){var e,n,i,a,s,u,l=t.length,c=[1732584193,-271733879,-1732584194,271733878];for(e=64;e<=l;e+=64)r(c,o(t.subarray(e-64,e)));for(n=(t=e-64>2]|=t[e]<<(e%4<<3);if(i[e>>2]|=128<<(e%4<<3),e>55)for(r(c,i),e=0;e<16;e+=1)i[e]=0;return a=(a=8*l).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(a[2],16),u=parseInt(a[1],16)||0,i[14]=s,i[15]=u,r(c,i),c}function s(t){var r,n="";for(r=0;r<4;r+=1)n+=e[t>>8*r+4&15]+e[t>>8*r&15];return n}function u(t){var e;for(e=0;ec?new ArrayBuffer(0):(o=c-l,i=new ArrayBuffer(o),a=new Uint8Array(i),s=new Uint8Array(this,l,o),a.set(s),i)}}(),d.prototype.append=function(t){return this.appendBinary(l(t)),this},d.prototype.appendBinary=function(t){this._buff+=t,this._length+=t.length;var e,o=this._buff.length;for(e=64;e<=o;e+=64)r(this._hash,n(this._buff.substring(e-64,e)));return this._buff=this._buff.substring(e-64),this},d.prototype.end=function(t){var e,r,n=this._buff,o=n.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e>2]|=n.charCodeAt(e)<<(e%4<<3);return this._finish(i,o),r=u(this._hash),t&&(r=p(r)),this.reset(),r},d.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},d.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},d.prototype.setState=function(t){return this._buff=t.buff,this._length=t.length,this._hash=t.hash,this},d.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},d.prototype._finish=function(t,e){var n,o,i,a=e;if(t[a>>2]|=128<<(a%4<<3),a>55)for(r(this._hash,t),a=0;a<16;a+=1)t[a]=0;n=(n=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(n[2],16),i=parseInt(n[1],16)||0,t[14]=o,t[15]=i,r(this._hash,t)},d.hash=function(t,e){return d.hashBinary(l(t),e)},d.hashBinary=function(t,e){var r=u(i(t));return e?p(r):r},d.ArrayBuffer=function(){this.reset()},d.ArrayBuffer.prototype.append=function(t){var e,n=f(this._buff.buffer,t,!0),i=n.length;for(this._length+=t.byteLength,e=64;e<=i;e+=64)r(this._hash,o(n.subarray(e-64,e)));return this._buff=e-64>2]|=n[e]<<(e%4<<3);return this._finish(i,o),r=u(this._hash),t&&(r=p(r)),this.reset(),r},d.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},d.ArrayBuffer.prototype.getState=function(){var t=d.prototype.getState.call(this);return t.buff=h(t.buff),t},d.ArrayBuffer.prototype.setState=function(t){return t.buff=c(t.buff,!0),d.prototype.setState.call(this,t)},d.ArrayBuffer.prototype.destroy=d.prototype.destroy,d.ArrayBuffer.prototype._finish=d.prototype._finish,d.ArrayBuffer.hash=function(t,e){var r=u(a(new Uint8Array(t)));return e?p(r):r},d}();const F=E;var R,q=globalThis&&globalThis.__assign||function(){return q=Object.assign||function(t){for(var e,r=1,n=arguments.length;r0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]3?e[1]:e[0];if(!r)throw new A(T.InvalidToken,"missing assess key field.");var n=null;try{n=JSON.parse(j(e[e.length-1].replace(/_/g,"/").replace(/-/g,"+")))}catch(i){throw new A(T.InvalidToken,"token parse failed.")}if(null==n)throw new A(T.InvalidToken,"putPolicy is null.");if(null==n.scope)throw new A(T.InvalidToken,"scope field is null.");var o=n.scope.split(":")[0];if(!o)throw new A(T.InvalidToken,"resolve bucketName failed.");return{assessKey:r,bucketName:o,scope:n.scope}}var Z,Q="z0",Y="z1",tt="z2",et="na0",rt="as0",nt="cn-east-2",ot=((R={})[Q]={srcUphost:["up.qiniup.com"],cdnUphost:["upload.qiniup.com"]},R[Y]={srcUphost:["up-z1.qiniup.com"],cdnUphost:["upload-z1.qiniup.com"]},R[tt]={srcUphost:["up-z2.qiniup.com"],cdnUphost:["upload-z2.qiniup.com"]},R[et]={srcUphost:["up-na0.qiniup.com"],cdnUphost:["upload-na0.qiniup.com"]},R[rt]={srcUphost:["up-as0.qiniup.com"],cdnUphost:["upload-as0.qiniup.com"]},R[nt]={srcUphost:["up-cn-east-2.qiniup.com"],cdnUphost:["upload-cn-east-2.qiniup.com"]},R),it=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};Z=function(t,e,r,n){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map((function(n){var o=encodeURIComponent(it(n))+r;return Array.isArray(t[n])?t[n].map((function(t){return o+encodeURIComponent(it(t))})).join(e):o+encodeURIComponent(it(t[n]))})).filter(Boolean).join(e):n?encodeURIComponent(it(n))+r+encodeURIComponent(it(t)):""};var at=globalThis&&globalThis.__assign||function(){return at=Object.assign||function(t){for(var e,r=1,n=arguments.length;r0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0?[2,n+"://"+r.uphost[0]]:[4,lt((o=W(e)).assessKey,o.bucketName,n)];case 1:return i=s.sent(),a=i.data.up.acc.main,[2,n+"://"+a[0]]}}))}))}var pt=globalThis&&globalThis.__assign||function(){return pt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0)&&!(n=i.next()).done;)a.push(n.value)}catch(s){o={error:s}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},bt=globalThis&&globalThis.__spread||function(){for(var t=[],e=0;e1e4*_t)return this.handleError(new A(T.InvalidFile,"file size exceed maximum value 10000G")),[2];if(this.putExtra.customVars&&(o=this.putExtra.customVars,!Object.keys(o).every((function(t){return 0===t.indexOf("x:")}))))return this.handleError(new A(T.InvalidCustomVars,"customVars key should start width x:")),[2];if(this.putExtra.metadata&&!function(t){return Object.keys(t).every((function(t){return 0===t.indexOf("x-qn-meta-")}))}(this.putExtra.metadata))return this.handleError(new A(T.InvalidMetadata,"metadata key should start with x-qn-meta-")),[2];n.label=1;case 1:return n.trys.push([1,4,,5]),this.uploadAt=(new Date).getTime(),[4,this.checkAndUpdateUploadHost()];case 2:return n.sent(),[4,this.run()];case 3:return t=n.sent(),this.onComplete(t.data),this.checkAndUnfreezeHost(),this.sendLog(t.reqId,200),[2];case 4:return e=n.sent(),this.aborted?(this.logger.warn("upload is aborted."),this.sendLog("",-2),[2]):(this.clear(),this.logger.error(e),e instanceof S&&(this.sendLog(e.reqId,e.code),this.checkAndFreezeHost(e),r=++this.retryCount<=this.config.retryCount,wt.includes(e.code)&&r)?(this.logger.warn("error auto retry: "+this.retryCount+"/"+this.config.retryCount+"."),this.putFile(),[2]):(this.onError(e),[3,5]));case 5:return[2]}var o}))}))},t.prototype.clear=function(){this.xhrList.forEach((function(t){t.onreadystatechange=null,t.abort()})),this.xhrList=[],this.logger.info("cleanup uploading xhr.")},t.prototype.stop=function(){this.logger.info("aborted."),this.clear(),this.aborted=!0},t.prototype.addXhr=function(t){this.xhrList.push(t)},t.prototype.sendLog=function(t,e){var r,n;this.logger.report({code:e,reqId:t,remoteIp:"",upType:"jssdk-h5",size:this.file.size,time:Math.floor(this.uploadAt/1e3),port:K(null===(r=this.uploadHost)||void 0===r?void 0:r.getUrl()),host:J(null===(n=this.uploadHost)||void 0===n?void 0:n.getUrl()),bytesSent:this.progress?this.progress.total.loaded:0,duration:Math.floor(((new Date).getTime()-this.uploadAt)/1e3)})},t.prototype.getProgressInfoItem=function(t,e,r){return pt({size:e,loaded:t,percent:t/e*100},null==r?{}:{fromCache:r})},t}(),Tt=globalThis&&globalThis.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),xt=globalThis&&globalThis.__assign||function(){return xt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]1024)throw new A(T.InvalidChunkSize,"chunkSize maximum value is 1024");return[4,this.initBeforeUploadChunks()];case 1:a.sent(),t=new O((function(e){return Ct(i,void 0,void 0,(function(){return At(this,(function(r){switch(r.label){case 0:if(this.aborted)throw t.abort(),new Error("pool is aborted");return[4,this.uploadChunk(e)];case 1:return r.sent(),[2]}}))}))}),this.config.concurrentRequestLimit),e=null,r=this.getLocalKey(),n=this.chunks.map((function(e,r){return t.enqueue({chunk:e,index:r})})),a.label=2;case 2:return a.trys.push([2,5,,6]),[4,Promise.all(n)];case 3:return a.sent(),[4,this.mkFileReq()];case 4:return e=a.sent(),[3,6];case 5:throw(o=a.sent())instanceof S&&(612===o.code||400===o.code)&&M(r,this.logger),o;case 6:return M(r,this.logger),[2,e]}var s}))}))},e.prototype.uploadChunk=function(t){return Ct(this,void 0,void 0,(function(){var e,r,n,o,i,a,s,u,l,c=this;return At(this,(function(h){switch(h.label){case 0:return e=t.index,r=t.chunk,n=this.cachedUploadedList[e],this.logger.info("upload part "+e+", cache:",n),o=this.config.checkByMD5,i=function(){c.usedCacheList[e]=!0,c.updateChunkProgress(r.size,e),c.uploadedList[e]=n,c.updateLocalCache()},n&&!o?(i(),[2]):[4,G(r)];case 1:return a=h.sent(),this.logger.info("computed part md5.",a),n&&a===n.md5?(i(),[2]):(this.usedCacheList[e]=!1,s=function(t){c.updateChunkProgress(t.loaded,e)},u={body:r,md5:this.config.checkByServer?a:void 0,onProgress:s,onCreate:function(t){return c.addXhr(t)}},this.logger.info("part "+e+" start uploading."),[4,ht(this.token,this.key,t.index+1,this.getUploadInfo(),u)]);case 2:return l=h.sent(),this.logger.info("part "+e+" upload completed."),s({loaded:r.size,total:r.size}),this.uploadedList[e]={etag:l.data.etag,md5:l.data.md5,size:r.size},this.updateLocalCache(),[2]}}))}))},e.prototype.mkFileReq=function(){return Ct(this,void 0,void 0,(function(){var t,e,r=this;return At(this,(function(n){switch(n.label){case 0:return t=xt(xt(xt({parts:this.uploadedList.map((function(t,e){return{etag:t.etag,partNumber:e+1}})),fname:this.putExtra.fname},this.putExtra.mimeType&&{mimeType:this.putExtra.mimeType}),this.putExtra.customVars&&{customVars:this.putExtra.customVars}),this.putExtra.metadata&&{metadata:this.putExtra.metadata}),this.logger.info("parts upload completed, make file.",t),[4,(o=this.token,i=this.key,a=this.getUploadInfo(),s={onCreate:function(t){return r.addXhr(t)},body:JSON.stringify(t)},$(ct(W(o).bucketName,i,a),at(at({},s),{method:"POST",headers:V(o)})))];case 1:return e=n.sent(),this.logger.info("finish Resume Progress."),this.updateMkFileProgress(1),[2,e]}var o,i,a,s}))}))},e.prototype.initBeforeUploadChunks=function(){return Ct(this,void 0,void 0,(function(){var t,e,r;return At(this,(function(n){switch(n.label){case 0:return this.uploadedList=[],this.usedCacheList=[],(t=function(t,e){var r=null;try{r=localStorage.getItem(t)}catch(n){e.warn(new A(T.ReadCacheFailed,"getLocalFileInfo failed. key: "+t))}if(null==r)return null;var o=null;try{o=JSON.parse(r)}catch(i){M(t,e),e.warn(new A(T.InvalidCacheData,"getLocalFileInfo failed to parse. key: "+t))}return o}(this.getLocalKey(),this.logger))?[3,2]:(this.logger.info("init upload parts from api."),[4,(o=this.token,i=this.bucketName,a=this.key,s=this.uploadHost.getUrl(),$(s+"/buckets/"+i+"/objects/"+(null!=a?L(a):"~")+"/uploads",{method:"POST",headers:N(o)}))]);case 1:return e=n.sent(),this.logger.info("initd upload parts of id: "+e.data.uploadId+"."),this.uploadId=e.data.uploadId,this.cachedUploadedList=[],[3,3];case 2:r=["resume upload parts from local cache,","total "+t.data.length+" part,","id is "+t.id+"."],this.logger.info(r.join(" ")),this.cachedUploadedList=t.data,this.uploadId=t.id,n.label=3;case 3:return this.chunks=function(t,e){var r=e*D;if(r>t.size)r=t.size;else for(;t.size>1e4*r;)r*=2;for(var n=[],o=Math.ceil(t.size/r),i=0;i0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]>>1^3988292384:r>>>=1;t[e]=r}return t},t.prototype.append=function(t){for(var e=this.crc,r=0;r>>8^this.table[255&(e^t[r])];this.crc=e},t.prototype.compute=function(){return(-1^this.crc)>>>0},t.prototype.readAsUint8Array=function(t){return St(this,void 0,void 0,(function(){var e;return It(this,(function(r){switch(r.label){case 0:return"function"!=typeof t.arrayBuffer?[3,2]:(e=Uint8Array.bind,[4,t.arrayBuffer()]);case 1:return[2,new(e.apply(Uint8Array,[void 0,r.sent()]))];case 2:return[2,new Promise((function(e,r){var n=new FileReader;n.onload=function(){null!=n.result&&"string"!=typeof n.result?e(new Uint8Array(n.result)):r()},n.readAsArrayBuffer(t)}))]}}))}))},t.prototype.file=function(t){return St(this,void 0,void 0,(function(){var e,r,n,o,i,a;return It(this,(function(s){switch(s.label){case 0:return t.size<=D?(e=this.append,[4,this.readAsUint8Array(t)]):[3,2];case 1:return e.apply(this,[s.sent()]),[2,this.compute()];case 2:r=Math.ceil(t.size/D),n=0,s.label=3;case 3:return n0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0)&&!(n=i.next()).done;)a.push(n.value)}catch(s){o={error:s}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},Ft=globalThis&&globalThis.__spread||function(){for(var t=[],e=0;e{try{const e=await _.get("/qiniu/upload/token",t);C.value=await e.data,C.value&&(A.value={Authorization:`${C.value}`}),ft({checkByServer:!0,checkByMD5:!0,forceDirect:!1,useCdnDomain:!0,disableStatisticsReport:!1,retryCount:6,region:Q,debugLogLevel:"INFO"},C.value).then((t=>{T.value=t}))}catch(e){console.error(e),b.error("获取上传凭证失败")}var t},j=t=>{const e=t.name.split(".")[0];if(t.name,!/^\d+$/.test(e)&&k.isCheckName)return b.error("文件命名错误,请以数字命名,例:1.mp4; 11.mp4; 333.mp4"),!1;const r=t.type;const n=k.acceptTypeDesc.split("/").map((t=>(t=>{let e="";switch(t){case".mp4":e="mp4";break;case".avi":e="avi";break;case".wmv":e="wmv"}return e})(t))).filter((t=>r.indexOf(t)>-1)),o=k.acceptTypeDesc.replace("/",", ");if(n.length<1)return b.error(`仅支持格式为${o}的图片`),!1;if(t.size/1024/1024>k.maxFileSize&&k.isLimitSize)return b.error(`文件大小不能超过${k.maxFileSize}MB!`),!1;I.value=!0;const i=`${Date.now()}_${t.name}`;if(x.value={key:`${i}`,token:C.value,"x:video_id":O.value.id},!R(t,!1))return R(t);P.value=v.service({text:"正在上传视频",background:"rgba(0,0,0,.2)"})},L=t=>{S.value=Math.floor(t.loaded/t.total*100)},E=(t,e)=>{t&&"success"===t.status&&w("fileRemove",t)},F=(t,e,r)=>{w("success",t),k.public_video_url,U.value.push(t),k.fileList.push({name:t.fname,url:k.public_video_url,...t}),b.success("上传成功"),r.length==U.value.length&&(P.value.close(),I.value=!1)},R=(t,e=!0)=>{const r=t.name;return q.value.includes(r)?(e&&m.alert(`上传失败,《${r}》文件名已存在,请修改后重新上传`),!1):(q.value.push(r),!0)},q=e([]);return n((()=>{z()})),(e,r)=>{const n=o("el-icon"),b=o("el-upload");return i(),a(b,{class:"w-auto",action:T.value,headers:A.value,"list-type":"text","file-list":k.fileList,data:x.value,multiple:k.isMultiple,accept:k.acceptType,"auto-upload":!0,"on-remove":E,"show-file-list":!0,"before-upload":j,"on-progress":L,"on-success":F},s({default:u((()=>[l("div",Bt,[d(n,{class:"avatar-uploader-icon"},{default:u((()=>[d(g(y))])),_:1}),l("span",null,c(k.buttonText),1)])])),_:2},[!k.isDisableUpload&&t.isShowTips?{name:"tip",fn:u((()=>[l("div",Ht,[l("span",null,"支持"+c(t.acceptTypeDesc)+";",1),h(),t.isLimitSize?(i(),f("span",Dt,"文件大小不能超过"+c(k.maxFileSize)+"M",1)):p("",!0)])])),key:"0"}:void 0]),1032,["action","headers","file-list","data","multiple","accept"])}}}),[["__scopeId","data-v-f738cd19"]]);export{Mt as _};