=t+n||t?new java.lang.String(e,t,n)+"":e}function u(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}r.prototype.parseFromString=function(e,t){var n=this.options,r=new l,a=n.domBuilder||new i,s=n.errorHandler,c=n.locator,u=n.xmlns||{},d={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return c&&a.setDocumentLocator(c),r.errorHandler=o(s,a,c),r.domBuilder=n.domBuilder||a,/\/x?html?$/.test(t)&&(d.nbsp="\xa0",d.copy="\xa9",u[""]="http://www.w3.org/1999/xhtml"),u.xml=u.xml||"http://www.w3.org/XML/1998/namespace",e?r.parse(e,u,d):r.errorHandler.error("invalid doc source"),a.doc},i.prototype={startDocument:function(){this.doc=(new d).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,n,r){var o=this.doc,i=o.createElementNS(e,n||t),s=r.length;u(this,i),this.currentElement=i,this.locator&&a(this.locator,i);for(var c=0;c65535){e-=65536;var t=55296+(e>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}function p(e){var t=e.slice(1,-1);return t in n?n[t]:"#"===t.charAt(0)?h(parseInt(t.substr(1).replace("x","0x"))):(u.error("entity not found:"+e),e)}function g(t){if(t>b){var n=e.substring(b,t).replace(/?\w+;/g,p);k&&m(b),r.characters(n,0,t-b),b=t}}function m(t,n){for(;t>=C&&(n=v.exec(e));)y=n.index,C=y+n[0].length,k.lineNumber++;k.columnNumber=t-y+1}for(var y=0,C=0,v=/.*(?:\r\n?|\n)|.*$/g,k=r.locator,S=[{currentNSMap:t}],R={},b=0;;){try{var A=e.indexOf("<",b);if(A<0){if(!e.substr(b).match(/^\s*$/)){var T=r.doc,B=T.createTextNode(e.substr(b));T.appendChild(B),r.currentElement=B}return}switch(A>b&&g(A),e.charAt(A+1)){case"/":var E=e.indexOf(">",A+3),x=e.substring(A+2,E),w=S.pop();E<0?(x=e.substring(A+2).replace(/[\s<].*/,""),u.error("end tag name: "+x+" is not complete:"+w.tagName),E=A+1+x.length):x.match(/\s)&&(x=x.replace(/[\s<].*/,""),u.error("end tag name: "+x+" maybe not complete"),E=A+1+x.length);var _=w.localNSMap,I=w.tagName==x;if(I||w.tagName&&w.tagName.toLowerCase()==x.toLowerCase()){if(r.endElement(w.uri,w.localName,x),_)for(var D in _)r.endPrefixMapping(D);I||u.fatalError("end tag name: "+x+" is not match the current start tagName:"+w.tagName)}else S.push(w);E++;break;case"?":k&&m(A),E=d(e,A,r);break;case"!":k&&m(A),E=l(e,A,r,u);break;default:k&&m(A);var O=new f,N=S[S.length-1].currentNSMap,E=i(e,A,O,N,p,u),P=O.length;if(!O.closed&&c(e,E,O.tagName,R)&&(O.closed=!0,n.nbsp||u.warning("unclosed xml attribute")),k&&P){for(var M=o(k,{}),U=0;Ub?b=E:g(Math.max(A,b)+1)}}function o(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function i(e,t,n,r,o,i){for(var a,s,c=++t,u=C;;){var l=e.charAt(c);switch(l){case"=":if(u===v)a=e.slice(t,c),u=S;else{if(u!==k)throw new Error("attribute equal must after attrName");u=S}break;case"'":case'"':if(u===S||u===v){if(u===v&&(i.warning('attribute value must after "="'),a=e.slice(t,c)),t=c+1,!((c=e.indexOf(l,t))>0))throw new Error("attribute value no end '"+l+"' match");s=e.slice(t,c).replace(/?\w+;/g,o),n.add(a,s,t-1),u=b}else{if(u!=R)throw new Error('attribute value must after "="');s=e.slice(t,c).replace(/?\w+;/g,o),n.add(a,s,t),i.warning('attribute "'+a+'" missed start quot('+l+")!!"),t=c+1,u=b}break;case"/":switch(u){case C:n.setTagName(e.slice(t,c));case b:case A:case T:u=T,n.closed=!0;case R:case v:case k:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return i.error("unexpected end of input"),u==C&&n.setTagName(e.slice(t,c)),c;case">":switch(u){case C:n.setTagName(e.slice(t,c));case b:case A:case T:break;case R:case v:s=e.slice(t,c),"/"===s.slice(-1)&&(n.closed=!0,s=s.slice(0,-1));case k:u===k&&(s=a),u==R?(i.warning('attribute "'+s+'" missed quot(")!!'),n.add(a,s.replace(/?\w+;/g,o),t)):("http://www.w3.org/1999/xhtml"===r[""]&&s.match(/^(?:disabled|checked|selected)$/i)||i.warning('attribute "'+s+'" missed value!! "'+s+'" instead!!'),n.add(s,s,t));break;case S:throw new Error("attribute value missed!!")}return c;case"\x80":l=" ";default:if(l<=" ")switch(u){case C:n.setTagName(e.slice(t,c)),u=A;break;case v:a=e.slice(t,c),u=k;break;case R:var s=e.slice(t,c).replace(/?\w+;/g,o);i.warning('attribute "'+s+'" missed quot(")!!'),n.add(a,s,t);case b:u=A}else switch(u){case k:n.tagName;"http://www.w3.org/1999/xhtml"===r[""]&&a.match(/^(?:disabled|checked|selected)$/i)||i.warning('attribute "'+a+'" missed value!! "'+a+'" instead2!!'),n.add(a,a,t),t=c,u=v;break;case b:i.warning('attribute space is required"'+a+'"!!');case A:u=v,t=c;break;case S:u=R,t=c;break;case T:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function a(e,t,n){for(var r=e.tagName,o=null,i=e.length;i--;){var a=e[i],s=a.qName,c=a.value,l=s.indexOf(":");if(l>0)var d=a.prefix=s.slice(0,l),f=s.slice(l+1),h="xmlns"===d&&f;else f=s,d=null,h="xmlns"===s&&"";a.localName=f,!1!==h&&(null==o&&(o={},u(n,n={})),n[h]=o[h]=c,a.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(h,c))}for(var i=e.length;i--;){a=e[i];var d=a.prefix;d&&("xml"===d&&(a.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==d&&(a.uri=n[d||""]))}var l=r.indexOf(":");l>0?(d=e.prefix=r.slice(0,l),f=e.localName=r.slice(l+1)):(d=null,f=e.localName=r);var p=e.uri=n[d||""];if(t.startElement(p,f,r,e),!e.closed)return e.currentNSMap=n,e.localNSMap=o,!0;if(t.endElement(p,f,r),o)for(d in o)t.endPrefixMapping(d)}function s(e,t,n,r,o){if(/^(?:script|textarea)$/i.test(n)){var i=e.indexOf(""+n+">",t),a=e.substring(t+1,i);if(/[&<]/.test(a))return/^script$/i.test(n)?(o.characters(a,0,a.length),i):(a=a.replace(/?\w+;/g,r),o.characters(a,0,a.length),i)}return t+1}function c(e,t,n,r){var o=r[n];return null==o&&(o=e.lastIndexOf(""+n+">"),ot?(n.comment(e,t+4,o-t-4),o+3):(r.error("Unclosed comment"),-1)}return-1;default:if("CDATA["==e.substr(t+3,6)){var o=e.indexOf("]]>",t+9);return n.startCDATA(),n.characters(e,t+9,o-t-9),n.endCDATA(),o+3}var i=p(e,t),a=i.length;if(a>1&&/!doctype/i.test(i[0][0])){var s=i[1][0],c=a>3&&/^public$/i.test(i[2][0])&&i[3][0],u=a>4&&i[4][0],l=i[a-1];return n.startDTD(s,c&&c.replace(/^(['"])(.*?)\1$/,"$2"),u&&u.replace(/^(['"])(.*?)\1$/,"$2")),n.endDTD(),l.index+l[0].length}}return-1}function d(e,t,n){var r=e.indexOf("?>",t);if(r){var o=e.substring(t,r).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);if(o){o[0].length;return n.processingInstruction(o[1],o[2]),r+2}return-1}return-1}function f(e){}function h(e,t){return e.__proto__=t,e}function p(e,t){var n,r=[],o=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;for(o.lastIndex=t,o.exec(e);n=o.exec(e);)if(r.push(n),n[1])return r}var g=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,m=new RegExp("[\\-\\.0-9"+g.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),y=new RegExp("^"+g.source+m.source+"*(?::"+g.source+m.source+"*)?$"),C=0,v=1,k=2,S=3,R=4,b=5,A=6,T=7;n.prototype={parse:function(e,t,n){var o=this.domBuilder;o.startDocument(),u(t,t={}),r(e,t,n,o,this.errorHandler),o.endDocument()}},f.prototype={setTagName:function(e){if(!y.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},add:function(e,t,n){if(!y.test(e))throw new Error("invalid attribute:"+e);this[this.length++]={qName:e,value:t,offset:n}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},h({},h.prototype)instanceof h||(h=function(e,t){function n(){}n.prototype=t,n=new n;for(t in e)n[t]=e[t];return n}),t.XMLReader=n},function(e,t){function n(e){return(""+e).replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""").replace(o,"")}var r=new RegExp("^([^a-zA-Z_\xc0-\xd6\xd8-\xf6\xf8-\xff\u0370-\u037d\u037f-\u1fff\u200c-\u200d\u2070-\u218f\u2c00-\u2fff\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd])|^((x|X)(m|M)(l|L))|([^a-zA-Z_\xc0-\xd6\xd8-\xf6\xf8-\xff\u0370-\u037d\u037f-\u1fff\u200c-\u200d\u2070-\u218f\u2c00-\u2fff\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd-.0-9\xb7\u0300-\u036f\u203f\u2040])","g"),o=/[^\x09\x0A\x0D\x20-\xFF\x85\xA0-\uD7FF\uE000-\uFDCF\uFDE0-\uFFFD]/gm,i=function(e){var t=[];if(e instanceof Object)for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t},a=function(e,t){var o=function(e,n,o,i,a){var s=void 0!==t.indent?t.indent:"\t",c=t.prettyPrint?"\n"+new Array(i).join(s):"";t.removeIllegalNameCharacters&&(e=e.replace(r,"_"));var u=[c,"<",e,o||""];return n&&n.length>0?(u.push(">"),u.push(n),a&&u.push(c),u.push(""),u.push(e),u.push(">")):u.push("/>"),u.join("")};return function e(r,a,s){var c=typeof r;switch((Array.isArray?Array.isArray(r):r instanceof Array)?c="array":r instanceof Date&&(c="date"),c){case"array":var u=[];return r.map(function(t){u.push(e(t,1,s+1))}),t.prettyPrint&&u.push("\n"),u.join("");case"date":return r.toJSON?r.toJSON():r+"";case"object":var l=[];for(var d in r)if(r.hasOwnProperty(d))if(r[d]instanceof Array)for(var f=0;f0&&l.push("\n"),l.join("");case"function":return r();default:return t.escape?n(r):""+r}}(e,0,0)},s=function(e){var t=['"),t.join("")};e.exports=function(e,t){if(t||(t={xmlHeader:{standalone:!0},prettyPrint:!0,indent:" ",escape:!0}),"string"==typeof e)try{e=JSON.parse(e.toString())}catch(e){return!1}var n="",r="";return t&&("object"==typeof t?(t.xmlHeader&&(n=s(!!t.xmlHeader.standalone)),void 0!==t.docType&&(r="")):n=s()),t=t||{},[n,t.prettyPrint&&r?"\n":"",r,a(e,t)].join("").replace(/\n{2,}/g,"\n").replace(/\s+$/g,"")}},function(e,t,n){var r=n(3),o=n(0),i={},a=function(e,t){i[t]=e[t],e[t]=function(e,n){e.SkipTask?i[t].call(this,e,n):this._addTask(t,e,n)}},s=function(e){var t=[],n={},a=0,s=0,c=function(e){var t={id:e.id,Bucket:e.Bucket,Region:e.Region,Key:e.Key,FilePath:e.FilePath,state:e.state,loaded:e.loaded,size:e.size,speed:e.speed,percent:e.percent,hashPercent:e.hashPercent,error:e.error};return e.FilePath&&(t.FilePath=e.FilePath),e._custom&&(t._custom=e._custom),t},u=function(){var n,r=function(){n=0,e.emit("task-list-update",{list:o.map(t,c)}),e.emit("list-update",{list:o.map(t,c)})};return function(){n||(n=setTimeout(r))}}(),l=function(){if(!(t.length<=e.options.UploadQueueSize)){for(var r=0;re.options.UploadQueueSize;){var o="waiting"===t[r].state||"checking"===t[r].state||"uploading"===t[r].state;t[r]&&o?r++:(n[t[r].id]&&delete n[t[r].id],t.splice(r,1),s--)}u()}},d=function(){if(!(a>=e.options.FileParallelLimit)){for(;t[s]&&"waiting"!==t[s].state;)s++;if(!(s>=t.length)){var n=t[s];s++,a++,n.state="checking",n.params.onTaskStart&&n.params.onTaskStart(c(n)),!n.params.UploadData&&(n.params.UploadData={});var r=o.formatParams(n.api,n.params);i[n.api].call(e,r,function(t,r){e._isRunningTask(n.id)&&("checking"!==n.state&&"uploading"!==n.state||(n.state=t?"error":"success",t&&(n.error=t),a--,u(),d(),n.callback&&n.callback(t,r),"success"===n.state&&(n.params&&(delete n.params.UploadData,delete n.params.Body,delete n.params),delete n.callback)),l())}),u(),setTimeout(d)}}},f=function(t,o){var i=n[t];if(i){var s=i&&"waiting"===i.state,c=i&&("checking"===i.state||"uploading"===i.state);if("canceled"===o&&"canceled"!==i.state||"paused"===o&&s||"paused"===o&&c){if("paused"===o&&i.params.Body&&"function"==typeof i.params.Body.pipe)return void console.error("stream not support pause");i.state=o,e.emit("inner-kill-task",{TaskId:t,toState:o});try{var f=i&&i.params&&i.params.UploadData.UploadId}catch(e){}"canceled"===o&&f&&r.removeUsing(f),u(),c&&(a--,d()),"canceled"===o&&(i.params&&(delete i.params.UploadData,delete i.params.Body,delete i.params),delete i.callback)}l()}};e._addTasks=function(t){o.each(t,function(t){e._addTask(t.api,t.params,t.callback,!0)}),u()};var h=!0;e._addTask=function(r,i,a,s){i=o.formatParams(r,i);var c=o.uuid();i.TaskId=c,i.onTaskReady&&i.onTaskReady(c),i.TaskReady&&(i.TaskReady(c),h&&console.warn('warning: Param "TaskReady" has been deprecated. Please use "onTaskReady" instead.'),h=!1);var f={params:i,callback:a,api:r,index:t.length,id:c,Bucket:i.Bucket,Region:i.Region,Key:i.Key,FilePath:i.FilePath||"",state:"waiting",loaded:0,size:0,speed:0,percent:0,hashPercent:0,error:null,_custom:i._custom},p=i.onHashProgress;i.onHashProgress=function(t){e._isRunningTask(f.id)&&(f.hashPercent=t.percent,p&&p(t),u())};var g=i.onProgress;return i.onProgress=function(t){e._isRunningTask(f.id)&&("checking"===f.state&&(f.state="uploading"),f.loaded=t.loaded,f.speed=t.speed,f.percent=t.percent,g&&g(t),u())},o.getFileSize(r,i,function(e,r){if(e)return a(o.error(e));n[c]=f,t.push(f),f.size=r,!s&&u(),d(),l()}),c},e._isRunningTask=function(e){var t=n[e];return!(!t||"checking"!==t.state&&"uploading"!==t.state)},e.getTaskList=function(){return o.map(t,c)},e.cancelTask=function(e){f(e,"canceled")},e.pauseTask=function(e){f(e,"paused")},e.restartTask=function(e){var t=n[e];!t||"paused"!==t.state&&"error"!==t.state||(t.state="waiting",u(),s=Math.min(s,t.index),d())},e.isUploadRunning=function(){return a||s/gi,"<$1Rule>"),r=r.replace(/<(\/?)Tags>/gi,"<$1Tag>");var o=e.Headers;o["Content-Type"]="application/xml",o["Content-MD5"]=_e.binaryBase64(_e.md5(r)),Be.call(this,{Action:"name/cos:PutBucketReplication",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:r,action:"replication",headers:o},function(e,n){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:n.statusCode,headers:n.headers})})}function B(e,t){Be.call(this,{Action:"name/cos:GetBucketReplication",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"replication"},function(e,n){if(e)if(404!==e.statusCode||!e.error||"Not Found"!==e.error&&"ReplicationConfigurationnotFoundError"!==e.error.Code)t(e);else{var r={ReplicationConfiguration:{Rules:[]},statusCode:e.statusCode};e.headers&&(r.headers=e.headers),t(null,r)}else!n.ReplicationConfiguration&&(n.ReplicationConfiguration={}),n.ReplicationConfiguration.Rule&&(n.ReplicationConfiguration.Rules=_e.makeArray(n.ReplicationConfiguration.Rule),delete n.ReplicationConfiguration.Rule),t(e,n)})}function E(e,t){Be.call(this,{Action:"name/cos:DeleteBucketReplication",method:"DELETE",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"replication"},function(e,n){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:n.statusCode,headers:n.headers})})}function x(e,t){if(!e.WebsiteConfiguration)return void t(_e.error(new Error("missing param WebsiteConfiguration")));var n=_e.clone(e.WebsiteConfiguration||{}),r=n.RoutingRules||n.RoutingRule||[];r=_e.isArray(r)?r:[r],delete n.RoutingRule,delete n.RoutingRules,r.length&&(n.RoutingRules={RoutingRule:r});var o=_e.json2xml({WebsiteConfiguration:n}),i=e.Headers;i["Content-Type"]="application/xml",i["Content-MD5"]=_e.binaryBase64(_e.md5(o)),Be.call(this,{Action:"name/cos:PutBucketWebsite",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:o,action:"website",headers:i},function(e,n){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:n.statusCode,headers:n.headers})})}function w(e,t){Be.call(this,{Action:"name/cos:GetBucketWebsite",method:"GET",Bucket:e.Bucket,Region:e.Region,Key:e.Key,headers:e.Headers,action:"website"},function(e,n){if(e)if(404===e.statusCode&&"NoSuchWebsiteConfiguration"===e.error.Code){var r={WebsiteConfiguration:{},statusCode:e.statusCode};e.headers&&(r.headers=e.headers),t(null,r)}else t(e);else{var o=n.WebsiteConfiguration||{};if(o.RoutingRules){var i=_e.clone(o.RoutingRules.RoutingRule||[]);i=_e.makeArray(i),o.RoutingRules=i}t(null,{WebsiteConfiguration:o,statusCode:n.statusCode,headers:n.headers})}})}function _(e,t){Be.call(this,{Action:"name/cos:DeleteBucketWebsite",method:"DELETE",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"website"},function(e,n){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:n.statusCode,headers:n.headers})})}function I(e,t){if(!e.RefererConfiguration)return void t(_e.error(new Error("missing param RefererConfiguration")));var n=_e.clone(e.RefererConfiguration||{}),r=n.DomainList||{},o=r.Domains||r.Domain||[];o=_e.isArray(o)?o:[o],o.length&&(n.DomainList={Domain:o});var i=_e.json2xml({RefererConfiguration:n}),a=e.Headers;a["Content-Type"]="application/xml",a["Content-MD5"]=_e.binaryBase64(_e.md5(i)),Be.call(this,{Action:"name/cos:PutBucketReferer",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:i,action:"referer",headers:a},function(e,n){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:n.statusCode,headers:n.headers})})}function D(e,t){Be.call(this,{Action:"name/cos:GetBucketReferer",method:"GET",Bucket:e.Bucket,Region:e.Region,Key:e.Key,headers:e.Headers,action:"referer"},function(e,n){if(e)if(404===e.statusCode&&"NoSuchRefererConfiguration"===e.error.Code){var r={WebsiteConfiguration:{},statusCode:e.statusCode};e.headers&&(r.headers=e.headers),t(null,r)}else t(e);else{var o=n.RefererConfiguration||{};if(o.DomainList){var i=_e.clone(o.DomainList.Domain||[]);i=_e.makeArray(i),o.DomainList={Domains:i}}t(null,{RefererConfiguration:o,statusCode:n.statusCode,headers:n.headers})}})}function O(e,t){var n=e.DomainConfiguration||{},r=n.DomainRule||e.DomainRule||[];r=_e.clone(r);var o=_e.json2xml({DomainConfiguration:{DomainRule:r}}),i=e.Headers;i["Content-Type"]="application/xml",i["Content-MD5"]=_e.binaryBase64(_e.md5(o)),Be.call(this,{Action:"name/cos:PutBucketDomain",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:o,action:"domain",headers:i},function(e,n){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:n.statusCode,headers:n.headers})})}function N(e,t){Be.call(this,{Action:"name/cos:GetBucketDomain",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"domain"},function(e,n){if(e)return t(e);var r=[];try{r=n.DomainConfiguration.DomainRule||[]}catch(e){}r=_e.clone(_e.isArray(r)?r:[r]),t(null,{DomainRule:r,statusCode:n.statusCode,headers:n.headers})})}function P(e,t){Be.call(this,{Action:"name/cos:DeleteBucketDomain",method:"DELETE",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"domain"},function(e,n){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:n.statusCode,headers:n.headers})})}function M(e,t){var n=e.OriginConfiguration||{},r=n.OriginRule||e.OriginRule||[];r=_e.clone(r);var o=_e.json2xml({OriginConfiguration:{OriginRule:r}}),i=e.Headers;i["Content-Type"]="application/xml",i["Content-MD5"]=_e.binaryBase64(_e.md5(o)),Be.call(this,{Action:"name/cos:PutBucketOrigin",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:o,action:"origin",headers:i},function(e,n){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:n.statusCode,headers:n.headers})})}function U(e,t){Be.call(this,{Action:"name/cos:GetBucketOrigin",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"origin"},function(e,n){if(e)return t(e);var r=[];try{r=n.OriginConfiguration.OriginRule||[]}catch(e){}r=_e.clone(_e.isArray(r)?r:[r]),t(null,{OriginRule:r,statusCode:n.statusCode,headers:n.headers})})}function H(e,t){Be.call(this,{Action:"name/cos:DeleteBucketOrigin",method:"DELETE",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"origin"},function(e,n){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:n.statusCode,headers:n.headers})})}function L(e,t){var n=_e.json2xml({BucketLoggingStatus:e.BucketLoggingStatus||""}),r=e.Headers;r["Content-Type"]="application/xml",r["Content-MD5"]=_e.binaryBase64(_e.md5(n)),Be.call(this,{Action:"name/cos:PutBucketLogging",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:n,action:"logging",headers:r},function(e,n){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:n.statusCode,headers:n.headers})})}function F(e,t){Be.call(this,{Action:"name/cos:GetBucketLogging",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"logging"},function(e,n){if(e)return t(e);t(null,{BucketLoggingStatus:n.BucketLoggingStatus,statusCode:n.statusCode,headers:n.headers})})}function K(e,t){var n=_e.clone(e.InventoryConfiguration);if(n.OptionalFields){var r=n.OptionalFields||[];n.OptionalFields={Field:r}}if(n.Destination&&n.Destination.COSBucketDestination&&n.Destination.COSBucketDestination.Encryption){var o=n.Destination.COSBucketDestination.Encryption;Object.keys(o).indexOf("SSECOS")>-1&&(o["SSE-COS"]=o.SSECOS,delete o.SSECOS)}var i=_e.json2xml({InventoryConfiguration:n}),a=e.Headers;a["Content-Type"]="application/xml",a["Content-MD5"]=_e.binaryBase64(_e.md5(i)),Be.call(this,{Action:"name/cos:PutBucketInventory",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:i,action:"inventory",qs:{id:e.Id},headers:a},function(e,n){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:n.statusCode,headers:n.headers})})}function j(e,t){Be.call(this,{Action:"name/cos:GetBucketInventory",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"inventory",qs:{id:e.Id}},function(e,n){if(e)return t(e);var r=n.InventoryConfiguration;if(r&&r.OptionalFields&&r.OptionalFields.Field){var o=r.OptionalFields.Field;_e.isArray(o)||(o=[o]),r.OptionalFields=o}if(r.Destination&&r.Destination.COSBucketDestination&&r.Destination.COSBucketDestination.Encryption){var i=r.Destination.COSBucketDestination.Encryption;Object.keys(i).indexOf("SSE-COS")>-1&&(i.SSECOS=i["SSE-COS"],delete i["SSE-COS"])}t(null,{InventoryConfiguration:r,statusCode:n.statusCode,headers:n.headers})})}function z(e,t){Be.call(this,{Action:"name/cos:ListBucketInventory",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"inventory",qs:{"continuation-token":e.ContinuationToken}},function(e,n){if(e)return t(e);var r=n.ListInventoryConfigurationResult,o=r.InventoryConfiguration||[];o=_e.isArray(o)?o:[o],delete r.InventoryConfiguration,_e.each(o,function(e){if(e&&e.OptionalFields&&e.OptionalFields.Field){var t=e.OptionalFields.Field;_e.isArray(t)||(t=[t]),e.OptionalFields=t}if(e.Destination&&e.Destination.COSBucketDestination&&e.Destination.COSBucketDestination.Encryption){var n=e.Destination.COSBucketDestination.Encryption;Object.keys(n).indexOf("SSE-COS")>-1&&(n.SSECOS=n["SSE-COS"],delete n["SSE-COS"])}}),r.InventoryConfigurations=o,_e.extend(r,{statusCode:n.statusCode,headers:n.headers}),t(null,r)})}function q(e,t){Be.call(this,{Action:"name/cos:DeleteBucketInventory",method:"DELETE",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"inventory",qs:{id:e.Id}},function(e,n){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:n.statusCode,headers:n.headers})})}function G(e,t){if(!e.AccelerateConfiguration)return void t(_e.error(new Error("missing param AccelerateConfiguration")));var n={AccelerateConfiguration:e.AccelerateConfiguration||{}},r=_e.json2xml(n),o={};o["Content-Type"]="application/xml",o["Content-MD5"]=_e.binaryBase64(_e.md5(r)),Be.call(this,{Action:"name/cos:PutBucketAccelerate",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:r,action:"accelerate",headers:o},function(e,n){if(e)return t(e);t(null,{statusCode:n.statusCode,headers:n.headers})})}function V(e,t){Be.call(this,{Action:"name/cos:GetBucketAccelerate",method:"GET",Bucket:e.Bucket,Region:e.Region,action:"accelerate"},function(e,n){e||!n.AccelerateConfiguration&&(n.AccelerateConfiguration={}),t(e,n)})}function X(e,t){var n=e.ServerSideEncryptionConfiguration||{},r=n.Rule||n.Rules||[],o=_e.json2xml({ServerSideEncryptionConfiguration:{Rule:r}}),i=e.Headers;i["Content-Type"]="application/xml",i["Content-MD5"]=_e.binaryBase64(_e.md5(o)),Be.call(this,{Action:"name/cos:PutBucketEncryption",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:o,action:"encryption",headers:i},function(e,n){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:n.statusCode,headers:n.headers})})}function W(e,t){Be.call(this,{Action:"name/cos:GetBucketEncryption",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"encryption"},function(e,n){if(e)if(404===e.statusCode&&"NoSuchEncryptionConfiguration"===e.code){var r={EncryptionConfiguration:{Rules:[]},statusCode:e.statusCode};e.headers&&(r.headers=e.headers),t(null,r)}else t(e);else{var o=_e.makeArray(n.EncryptionConfiguration&&n.EncryptionConfiguration.Rule||[]);n.EncryptionConfiguration={Rules:o},t(e,n)}})}function Q(e,t){Be.call(this,{Action:"name/cos:DeleteBucketReplication",method:"DELETE",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"encryption"},function(e,n){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:n.statusCode,headers:n.headers})})}function $(e,t){Be.call(this,{Action:"name/cos:HeadObject",method:"HEAD",Bucket:e.Bucket,Region:e.Region,Key:e.Key,VersionId:e.VersionId,headers:e.Headers},function(n,r){if(n){var o=n.statusCode;return e.Headers["If-Modified-Since"]&&o&&304===o?t(null,{NotModified:!0,statusCode:o}):t(n)}r.ETag=_e.attr(r.headers,"etag",""),t(null,r)})}function J(e,t){var n={};n.prefix=e.Prefix||"",n.delimiter=e.Delimiter,n["key-marker"]=e.KeyMarker,n["version-id-marker"]=e.VersionIdMarker,n["max-keys"]=e.MaxKeys,n["encoding-type"]=e.EncodingType,Be.call(this,{Action:"name/cos:GetBucketObjectVersions",ResourceKey:n.prefix,method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,qs:n,action:"versions"},function(e,n){if(e)return t(e);var r=n.ListVersionsResult||{},o=r.DeleteMarker||[];o=_e.isArray(o)?o:[o];var i=r.Version||[];i=_e.isArray(i)?i:[i];var a=_e.clone(r);delete a.DeleteMarker,delete a.Version,_e.extend(a,{DeleteMarkers:o,Versions:i,statusCode:n.statusCode,headers:n.headers}),t(null,a)})}function Y(e,t){var n=e.Query||{},r=e.QueryString||"",o=_e.throttleOnProgress.call(this,0,e.onProgress);n["response-content-type"]=e.ResponseContentType,n["response-content-language"]=e.ResponseContentLanguage,n["response-expires"]=e.ResponseExpires,n["response-cache-control"]=e.ResponseCacheControl,n["response-content-disposition"]=e.ResponseContentDisposition,n["response-content-encoding"]=e.ResponseContentEncoding,Be.call(this,{Action:"name/cos:GetObject",method:"GET",Bucket:e.Bucket,Region:e.Region,Key:e.Key,VersionId:e.VersionId,DataType:e.DataType,headers:e.Headers,qs:n,qsStr:r,rawBody:!0,onDownloadProgress:o},function(n,r){if(o(null,!0),n){var i=n.statusCode;return e.Headers["If-Modified-Since"]&&i&&304===i?t(null,{NotModified:!0}):t(n)}t(null,{Body:r.body,ETag:_e.attr(r.headers,"etag",""),statusCode:r.statusCode,headers:r.headers})})}function Z(e,t){var n=this,r=e.ContentLength,o=_e.throttleOnProgress.call(n,r,e.onProgress),i=e.Headers;i["Cache-Control"]||i["cache-control"]||(i["Cache-Control"]=""),i["Content-Type"]||i["content-type"]||(i["Content-Type"]=e.Body&&e.Body.type||"");var a=e.UploadAddMetaMd5||n.options.UploadAddMetaMd5||n.options.UploadCheckContentMd5;_e.getBodyMd5(a,e.Body,function(a){a&&(n.options.UploadCheckContentMd5&&(i["Content-MD5"]=_e.binaryBase64(a)),(e.UploadAddMetaMd5||n.options.UploadAddMetaMd5)&&(i["x-cos-meta-md5"]=a)),void 0!==e.ContentLength&&(i["Content-Length"]=e.ContentLength),o(null,!0),Be.call(n,{Action:"name/cos:PutObject",TaskId:e.TaskId,method:"PUT",Bucket:e.Bucket,Region:e.Region,Key:e.Key,headers:e.Headers,qs:e.Query,body:e.Body,onProgress:o},function(i,a){if(i)return o(null,!0),t(i);o({loaded:r,total:r},!0);var s=be({ForcePathStyle:n.options.ForcePathStyle,protocol:n.options.Protocol,domain:n.options.Domain,bucket:e.Bucket,region:n.options.UseAccelerate?"accelerate":e.Region,object:e.Key});s=s.substr(s.indexOf("://")+3),a.Location=s,a.ETag=_e.attr(a.headers,"etag",""),t(null,a)})},e.onHashProgress)}function ee(e,t){Be.call(this,{Action:"name/cos:DeleteObject",method:"DELETE",Bucket:e.Bucket,Region:e.Region,Key:e.Key,headers:e.Headers,VersionId:e.VersionId},function(e,n){if(e){var r=e.statusCode;return r&&404===r?t(null,{BucketNotFound:!0,statusCode:r}):t(e)}t(null,{statusCode:n.statusCode,headers:n.headers})})}function te(e,t){Be.call(this,{Action:"name/cos:GetObjectACL",method:"GET",Bucket:e.Bucket,Region:e.Region,Key:e.Key,headers:e.Headers,action:"acl"},function(e,n){if(e)return t(e);var r=n.AccessControlPolicy||{},o=r.Owner||{},i=r.AccessControlList&&r.AccessControlList.Grant||[];i=_e.isArray(i)?i:[i];var a=Se(r);delete a.GrantWrite,n.headers&&n.headers["x-cos-acl"]&&(a.ACL=n.headers["x-cos-acl"]),a=_e.extend(a,{Owner:o,Grants:i,statusCode:n.statusCode,headers:n.headers}),t(null,a)})}function ne(e,t){var n=e.Headers,r="";if(e.AccessControlPolicy){var o=_e.clone(e.AccessControlPolicy||{}),i=o.Grants||o.Grant;i=_e.isArray(i)?i:[i],delete o.Grant,delete o.Grants,o.AccessControlList={Grant:i},r=_e.json2xml({AccessControlPolicy:o}),n["Content-Type"]="application/xml",n["Content-MD5"]=_e.binaryBase64(_e.md5(r))}_e.each(n,function(e,t){0===t.indexOf("x-cos-grant-")&&(n[t]=Re(n[t]))}),Be.call(this,{Action:"name/cos:PutObjectACL",method:"PUT",Bucket:e.Bucket,Region:e.Region,Key:e.Key,action:"acl",headers:n,body:r},function(e,n){if(e)return t(e);t(null,{statusCode:n.statusCode,headers:n.headers})})}function re(e,t){var n=e.Headers;n.Origin=e.Origin,n["Access-Control-Request-Method"]=e.AccessControlRequestMethod,n["Access-Control-Request-Headers"]=e.AccessControlRequestHeaders,Be.call(this,{Action:"name/cos:OptionsObject",method:"OPTIONS",Bucket:e.Bucket,Region:e.Region,Key:e.Key,headers:n},function(e,n){if(e)return e.statusCode&&403===e.statusCode?t(null,{OptionsForbidden:!0,statusCode:e.statusCode}):t(e);var r=n.headers||{};t(null,{AccessControlAllowOrigin:r["access-control-allow-origin"],AccessControlAllowMethods:r["access-control-allow-methods"],AccessControlAllowHeaders:r["access-control-allow-headers"],AccessControlExposeHeaders:r["access-control-expose-headers"],AccessControlMaxAge:r["access-control-max-age"],statusCode:n.statusCode,headers:n.headers})})}function oe(e,t){var n=this,r=e.Headers;r["Cache-Control"]||r["cache-control"]||(r["Cache-Control"]="");var o=e.CopySource||"",i=o.match(/^([^.]+-\d+)\.cos(v6)?\.([^.]+)\.[^\/]+\/(.+)$/);if(!i)return void t(_e.error(new Error("CopySource format error")));var a=i[1],s=i[3],c=decodeURIComponent(i[4]);Be.call(this,{Scope:[{action:"name/cos:GetObject",bucket:a,region:s,prefix:c},{action:"name/cos:PutObject",bucket:e.Bucket,region:e.Region,prefix:e.Key}],method:"PUT",Bucket:e.Bucket,Region:e.Region,Key:e.Key,VersionId:e.VersionId,headers:e.Headers},function(r,o){if(r)return t(r);var i=_e.clone(o.CopyObjectResult||{}),a=be({ForcePathStyle:n.options.ForcePathStyle,protocol:n.options.Protocol,domain:n.options.Domain,bucket:e.Bucket,region:e.Region,object:e.Key,isLocation:!0});_e.extend(i,{Location:a,statusCode:o.statusCode,headers:o.headers}),t(null,i)})}function ie(e,t){var n=e.CopySource||"",r=n.match(/^([^.]+-\d+)\.cos(v6)?\.([^.]+)\.[^\/]+\/(.+)$/);if(!r)return void t(_e.error(new Error("CopySource format error")));var o=r[1],i=r[3],a=decodeURIComponent(r[4]);Be.call(this,{Scope:[{action:"name/cos:GetObject",bucket:o,region:i,prefix:a},{action:"name/cos:PutObject",bucket:e.Bucket,region:e.Region,prefix:e.Key}],method:"PUT",Bucket:e.Bucket,Region:e.Region,Key:e.Key,VersionId:e.VersionId,qs:{partNumber:e.PartNumber,uploadId:e.UploadId},headers:e.Headers},function(e,n){if(e)return t(e);var r=_e.clone(n.CopyPartResult||{});_e.extend(r,{statusCode:n.statusCode,headers:n.headers}),t(null,r)})}function ae(e,t){var n=e.Objects||[],r=e.Quiet;n=_e.isArray(n)?n:[n];var o=_e.json2xml({Delete:{Object:n,Quiet:r||!1}}),i=e.Headers;i["Content-Type"]="application/xml",i["Content-MD5"]=_e.binaryBase64(_e.md5(o));var a=_e.map(n,function(t){return{action:"name/cos:DeleteObject",bucket:e.Bucket,region:e.Region,prefix:t.Key}});Be.call(this,{Scope:a,method:"POST",Bucket:e.Bucket,Region:e.Region,body:o,action:"delete",headers:i},function(e,n){if(e)return t(e);var r=n.DeleteResult||{},o=r.Deleted||[],i=r.Error||[];o=_e.isArray(o)?o:[o],i=_e.isArray(i)?i:[i];var a=_e.clone(r);_e.extend(a,{Error:i,Deleted:o,statusCode:n.statusCode,headers:n.headers}),t(null,a)})}function se(e,t){var n=e.Headers;if(!e.RestoreRequest)return void t(_e.error(new Error("missing param RestoreRequest")));var r=e.RestoreRequest||{},o=_e.json2xml({RestoreRequest:r});n["Content-Type"]="application/xml",n["Content-MD5"]=_e.binaryBase64(_e.md5(o)),Be.call(this,{Action:"name/cos:RestoreObject",method:"POST",Bucket:e.Bucket,Region:e.Region,Key:e.Key,VersionId:e.VersionId,body:o,action:"restore",headers:n},t)}function ce(e,t){var n=e.Tagging||{},r=n.TagSet||n.Tags||e.Tags||[];r=_e.clone(_e.isArray(r)?r:[r]);var o=_e.json2xml({Tagging:{TagSet:{Tag:r}}}),i=e.Headers;i["Content-Type"]="application/xml",i["Content-MD5"]=_e.binaryBase64(_e.md5(o)),Be.call(this,{Action:"name/cos:PutObjectTagging",method:"PUT",Bucket:e.Bucket,Key:e.Key,Region:e.Region,body:o,action:"tagging",headers:i,VersionId:e.VersionId},function(e,n){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:n.statusCode,headers:n.headers})})}function ue(e,t){Be.call(this,{Action:"name/cos:GetObjectTagging",method:"GET",Key:e.Key,Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"tagging",VersionId:e.VersionId},function(e,n){if(e)if(404!==e.statusCode||!e.error||"Not Found"!==e.error&&"NoSuchTagSet"!==e.error.Code)t(e);else{var r={Tags:[],statusCode:e.statusCode};e.headers&&(r.headers=e.headers),t(null,r)}else{var o=[];try{o=n.Tagging.TagSet.Tag||[]}catch(e){}o=_e.clone(_e.isArray(o)?o:[o]),t(null,{Tags:o,statusCode:n.statusCode,headers:n.headers})}})}function le(e,t){Be.call(this,{Action:"name/cos:DeleteObjectTagging",method:"DELETE",Bucket:e.Bucket,Region:e.Region,Key:e.Key,headers:e.Headers,action:"tagging",VersionId:e.VersionId},function(e,n){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:n.statusCode,headers:n.headers})})}function de(e,t){if(!e.SelectType)return t(_e.error(new Error("missing param SelectType")));var n=e.SelectRequest||{},r=_e.json2xml({SelectRequest:n}),o=e.Headers;o["Content-Type"]="application/xml",o["Content-MD5"]=_e.binaryBase64(_e.md5(r)),Be.call(this,{Action:"name/cos:GetObject",method:"POST",Bucket:e.Bucket,Region:e.Region,Key:e.Key,headers:e.Headers,action:"select",qs:{"select-type":e.SelectType},VersionId:e.VersionId,body:r,DataType:"arraybuffer",rawBody:!0},function(e,n){if(e&&204===e.statusCode)return t(null,{statusCode:e.statusCode});if(e)return t(e);var r=_e.parseSelectPayload(n.body);t(null,{statusCode:n.statusCode,headers:n.headers,Body:r.body,Payload:r.payload})})}function fe(e,t){var n=this,r=e.Headers;r["Cache-Control"]||r["cache-control"]||(r["Cache-Control"]=""),r["Content-Type"]||r["content-type"]||(r["Content-Type"]=e.Body&&e.Body.type||""),_e.getBodyMd5(e.Body&&(e.UploadAddMetaMd5||n.options.UploadAddMetaMd5),e.Body,function(r){r&&(e.Headers["x-cos-meta-md5"]=r),Be.call(n,{Action:"name/cos:InitiateMultipartUpload",method:"POST",Bucket:e.Bucket,Region:e.Region,Key:e.Key,action:"uploads",headers:e.Headers,qs:e.Query},function(e,n){return e?t(e):(n=_e.clone(n||{}))&&n.InitiateMultipartUploadResult?t(null,_e.extend(n.InitiateMultipartUploadResult,{statusCode:n.statusCode,headers:n.headers})):void t(null,n)})},e.onHashProgress)}function he(e,t){var n=this;_e.getFileSize("multipartUpload",e,function(){_e.getBodyMd5(n.options.UploadCheckContentMd5,e.Body,function(r){r&&(e.Headers["Content-MD5"]=_e.binaryBase64(r)),Be.call(n,{Action:"name/cos:UploadPart",TaskId:e.TaskId,method:"PUT",Bucket:e.Bucket,Region:e.Region,Key:e.Key,qs:{partNumber:e.PartNumber,uploadId:e.UploadId},headers:e.Headers,onProgress:e.onProgress,body:e.Body||null},function(e,n){if(e)return t(e);t(null,{ETag:_e.attr(n.headers,"etag",""),statusCode:n.statusCode,headers:n.headers})})})})}function pe(e,t){for(var n=this,r=e.UploadId,o=e.Parts,i=0,a=o.length;i-1?n.Authorization:"sign="+encodeURIComponent(n.Authorization)),n.SecurityToken&&(i+="&x-cos-security-token="+n.SecurityToken),n.ClientIP&&(i+="&clientIP="+n.ClientIP),n.ClientUA&&(i+="&clientUA="+n.ClientUA),n.Token&&(i+="&token="+n.Token),o&&(i+="&"+o),setTimeout(function(){t(null,{Url:i})})}});return a?(i+="?"+a.Authorization+(a.SecurityToken?"&x-cos-security-token="+a.SecurityToken:""),o&&(i+="&"+o)):o&&(i+="?"+o),i}function Se(e){var t={GrantFullControl:[],GrantWrite:[],GrantRead:[],GrantReadAcp:[],GrantWriteAcp:[],ACL:""},n={FULL_CONTROL:"GrantFullControl",WRITE:"GrantWrite",READ:"GrantRead",READ_ACP:"GrantReadAcp",WRITE_ACP:"GrantWriteAcp"},r=e&&e.AccessControlList||{},o=r.Grant;o&&(o=_e.isArray(o)?o:[o]);var i={READ:0,WRITE:0,FULL_CONTROL:0};return o&&o.length&&_e.each(o,function(r){"qcs::cam::anyone:anyone"===r.Grantee.ID||"http://cam.qcloud.com/groups/global/AllUsers"===r.Grantee.URI?i[r.Permission]=1:r.Grantee.ID!==e.Owner.ID&&t[n[r.Permission]].push('id="'+r.Grantee.ID+'"')}),i.FULL_CONTROL||i.WRITE&&i.READ?t.ACL="public-read-write":i.READ?t.ACL="public-read":t.ACL="private",_e.each(n,function(e){t[e]=Re(t[e].join(","))}),t}function Re(e){var t,n,r=e.split(","),o={};for(t=0;t-1?"{Region}.myqcloud.com":"cos.{Region}.myqcloud.com",e.ForcePathStyle||(o="{Bucket}."+o)),o=o.replace(/\{\{AppId\}\}/gi,r).replace(/\{\{Bucket\}\}/gi,n).replace(/\{\{Region\}\}/gi,i).replace(/\{\{.*?\}\}/gi,""),o=o.replace(/\{AppId\}/gi,r).replace(/\{BucketName\}/gi,n).replace(/\{Bucket\}/gi,t).replace(/\{Region\}/gi,i).replace(/\{.*?\}/gi,""),/^[a-zA-Z]+:\/\//.test(o)||(o=s+"//"+o),"/"===o.slice(-1)&&(o=o.slice(0,-1));var c=o;return e.ForcePathStyle&&(c+="/"+t),c+="/",a&&(c+=_e.camSafeUrlEncode(a).replace(/%2F/g,"/")),e.isLocation&&(c=c.replace(/^https?:\/\//,"")),c}function Ae(e,t){var n=_e.clone(e.Headers);_e.each(n,function(e,t){(""===e||["content-type","cache-control","expires"].indexOf(t.toLowerCase())>-1)&&delete n[t]});var r=!1,o=function(e,n){r||(r=!0,n&&n.XCosSecurityToken&&!n.SecurityToken&&(n=_e.clone(n),n.SecurityToken=n.XCosSecurityToken,delete n.XCosSecurityToken),t&&t(e,n))},i=this,a=e.Bucket||"",s=e.Region||"",c=e.Key||"";i.options.ForcePathStyle&&a&&(c=a+"/"+c);var u="/"+c,l={},d=e.Scope;if(!d){var f=e.Action||"",h=e.ResourceKey||e.Key||"";d=e.Scope||[{action:f,bucket:a,region:s,prefix:h}]}var p=_e.md5(JSON.stringify(d));i._StsCache=i._StsCache||[],function(){var e,t;for(e=i._StsCache.length-1;e>=0;e--){t=i._StsCache[e];var n=Math.round(_e.getSkewTime(i.options.SystemClockOffset)/1e3)+30;if(t.StartTime&&n=t.ExpiredTime)i._StsCache.splice(e,1);else if(!t.ScopeLimit||t.ScopeLimit&&t.ScopeKey===p){l=t;break}}}();var g=function(){var t=l.StartTime&&l.ExpiredTime?l.StartTime+";"+l.ExpiredTime:"",r=_e.getAuth({SecretId:l.TmpSecretId,SecretKey:l.TmpSecretKey,Method:e.Method,Pathname:u,Query:e.Query,Headers:n,Expires:e.Expires,UseRawKey:i.options.UseRawKey,SystemClockOffset:i.options.SystemClockOffset,KeyTime:t}),a={Authorization:r,SecurityToken:l.SecurityToken||l.XCosSecurityToken||"",Token:l.Token||"",ClientIP:l.ClientIP||"",ClientUA:l.ClientUA||""};o(null,a)},m=function(e){if(e.Authorization){var t=!1,n=e.Authorization;if(n)if(n.indexOf(" ")>-1)t=!1;else if(n.indexOf("q-sign-algorithm=")>-1&&n.indexOf("q-ak=")>-1&&n.indexOf("q-sign-time=")>-1&&n.indexOf("q-key-time=")>-1&&n.indexOf("q-url-param-list=")>-1)t=!0;else try{n=atob(n),n.indexOf("a=")>-1&&n.indexOf("k=")>-1&&n.indexOf("t=")>-1&&n.indexOf("r=")>-1&&n.indexOf("b=")>-1&&(t=!0)}catch(e){}if(!t)return _e.error(new Error("getAuthorization callback params format error"))}else{if(!e.TmpSecretId)return _e.error(new Error('getAuthorization callback params missing "TmpSecretId"'));if(!e.TmpSecretKey)return _e.error(new Error('getAuthorization callback params missing "TmpSecretKey"'));if(!e.SecurityToken&&!e.XCosSecurityToken)return _e.error(new Error('getAuthorization callback params missing "SecurityToken"'));if(!e.ExpiredTime)return _e.error(new Error('getAuthorization callback params missing "ExpiredTime"'));if(e.ExpiredTime&&10!==e.ExpiredTime.toString().length)return _e.error(new Error('getAuthorization callback params "ExpiredTime" should be 10 digits'));if(e.StartTime&&10!==e.StartTime.toString().length)return _e.error(new Error('getAuthorization callback params "StartTime" should be 10 StartTime'))}return!1};if(l.ExpiredTime&&l.ExpiredTime-_e.getSkewTime(i.options.SystemClockOffset)/1e3>60)g();else if(i.options.getAuthorization)i.options.getAuthorization.call(i,{Bucket:a,Region:s,Method:e.Method,Key:c,Pathname:u,Query:e.Query,Headers:n,Scope:d,SystemClockOffset:i.options.SystemClockOffset},function(e){"string"==typeof e&&(e={Authorization:e});var t=m(e);if(t)return o(t);e.Authorization?o(null,e):(l=e||{},l.Scope=d,l.ScopeKey=p,i._StsCache.push(l),g())});else{if(!i.options.getSTS)return function(){var t=_e.getAuth({SecretId:e.SecretId||i.options.SecretId,SecretKey:e.SecretKey||i.options.SecretKey,Method:e.Method,Pathname:u,Query:e.Query,Headers:n,Expires:e.Expires,UseRawKey:i.options.UseRawKey,SystemClockOffset:i.options.SystemClockOffset}),r={Authorization:t,SecurityToken:i.options.SecurityToken||i.options.XCosSecurityToken};return o(null,r),r}();i.options.getSTS.call(i,{Bucket:a,Region:s},function(e){l=e||{},l.Scope=d,l.ScopeKey=p,l.TmpSecretId||(l.TmpSecretId=l.SecretId),l.TmpSecretKey||(l.TmpSecretKey=l.SecretKey);var t=m(l);if(t)return o(t);i._StsCache.push(l),g()})}return""}function Te(e){var t=!1,n=!1,r=e.headers&&(e.headers.date||e.headers.Date)||e.error&&e.error.ServerTime;try{var o=e.error.Code,i=e.error.Message;("RequestTimeTooSkewed"===o||"AccessDenied"===o&&"Request has expired"===i)&&(n=!0)}catch(e){}if(e)if(n&&r){var a=Date.parse(r);this.options.CorrectClockSkew&&Math.abs(_e.getSkewTime(this.options.SystemClockOffset)-a)>=3e4&&(console.error("error: Local time is too skewed."),this.options.SystemClockOffset=a-Date.now(),t=!0)}else 5===Math.floor(e.statusCode/100)&&(t=!0);return t}function Be(e,t){var n=this;!e.headers&&(e.headers={}),!e.qs&&(e.qs={}),e.VersionId&&(e.qs.versionId=e.VersionId),e.qs=_e.clearKey(e.qs),e.headers&&(e.headers=_e.clearKey(e.headers)),e.qs&&(e.qs=_e.clearKey(e.qs));var r=_e.clone(e.qs);e.action&&(r[e.action]="");var o=function(i){var a=n.options.SystemClockOffset;Ae.call(n,{Bucket:e.Bucket||"",Region:e.Region||"",Method:e.method,Key:e.Key,Query:r,Headers:e.headers,Action:e.Action,ResourceKey:e.ResourceKey,Scope:e.Scope},function(r,s){if(r)return void t(r);e.AuthData=s,Ee.call(n,e,function(r,s){r&&i<2&&(a!==n.options.SystemClockOffset||Te.call(n,r))?(e.headers&&(delete e.headers.Authorization,delete e.headers.token,delete e.headers.clientIP,delete e.headers.clientUA,delete e.headers["x-cos-security-token"]),o(i+1)):t(r,s)})})};o(1)}function Ee(e,t){var n=this,r=e.TaskId;if(!r||n._isRunningTask(r)){var o=e.Bucket,i=e.Region,a=e.Key,s=e.method||"GET",c=e.url,u=e.body,l=e.rawBody;n.options.UseAccelerate&&(i="accelerate"),c=c||be({ForcePathStyle:n.options.ForcePathStyle,protocol:n.options.Protocol,domain:n.options.Domain,bucket:o,region:i,object:a}),e.action&&(c=c+"?"+e.action),e.qsStr&&(c=c.indexOf("?")>-1?c+"&"+e.qsStr:c+"?"+e.qsStr);var d={method:s,url:c,headers:e.headers,qs:e.qs,body:u};if(d.headers.Authorization=e.AuthData.Authorization,e.AuthData.Token&&(d.headers.token=e.AuthData.Token),e.AuthData.ClientIP&&(d.headers.clientIP=e.AuthData.ClientIP),e.AuthData.ClientUA&&(d.headers.clientUA=e.AuthData.ClientUA),e.AuthData.SecurityToken&&(d.headers["x-cos-security-token"]=e.AuthData.SecurityToken),d.headers&&(d.headers=_e.clearKey(d.headers)),d=_e.clearKey(d),e.onProgress&&"function"==typeof e.onProgress){var f=u&&(u.size||u.length)||0;d.onProgress=function(t){if(!r||n._isRunningTask(r)){var o=t?t.loaded:0;e.onProgress({loaded:o,total:f})}}}e.onDownloadProgress&&(d.onDownloadProgress=e.onDownloadProgress),e.DataType&&(d.dataType=e.DataType),this.options.Timeout&&(d.timeout=this.options.Timeout),n.options.ForcePathStyle&&(d.pathStyle=n.options.ForcePathStyle),n.emit("before-send",d);var h=(n.options.Request||we)(d,function(e){if("abort"!==e.error){n.emit("after-receive",e);var o,i={statusCode:e.statusCode,statusMessage:e.statusMessage,headers:e.headers},a=e.error,s=e.body,c=function(e,a){if(r&&n.off("inner-kill-task",p),!o){o=!0;var s={};i&&i.statusCode&&(s.statusCode=i.statusCode),i&&i.headers&&(s.headers=i.headers),e?(e=_e.extend(e||{},s),t(e,null)):(a=_e.extend(a||{},s),t(null,a)),h=null}};if(a)return c(_e.error(a));var u=i.statusCode,d=2===Math.floor(u/100);if(l&&d)return c(null,{body:s});var f;try{f=s&&s.indexOf("<")>-1&&s.indexOf(">")>-1&&_e.xml2json(s)||{}}catch(e){f={}}var g=f&&f.Error;d?c(null,f):g?c(_e.error(new Error(g.Message),{code:g.Code,error:g})):u?c(_e.error(new Error(i.statusMessage),{code:""+u})):u&&c(_e.error(new Error("statusCode error")))}}),p=function(e){e.TaskId===r&&(h&&h.abort&&h.abort(),n.off("inner-kill-task",p))};r&&n.on("inner-kill-task",p)}}function xe(e,t,n){_e.each(["Cors","Acl"],function(r){if(e.slice(-r.length)===r){var o=e.slice(0,-r.length)+r.toUpperCase(),i=_e.apiWrapper(e,t),a=!1;n[o]=function(){!a&&console.warn("warning: cos."+o+" has been deprecated. Please Use cos."+e+" instead."),a=!0,i.apply(this,arguments)}}})}var we=n(17),_e=n(0),Ie={getService:r,putBucket:o,headBucket:i,getBucket:a,deleteBucket:s,putBucketAcl:c,getBucketAcl:u,putBucketCors:l,getBucketCors:d,deleteBucketCors:f,getBucketLocation:h,getBucketPolicy:g,putBucketPolicy:p,deleteBucketPolicy:m,putBucketTagging:y,getBucketTagging:C,deleteBucketTagging:v,putBucketLifecycle:k,getBucketLifecycle:S,deleteBucketLifecycle:R,putBucketVersioning:b,getBucketVersioning:A,putBucketReplication:T,getBucketReplication:B,deleteBucketReplication:E,putBucketWebsite:x,getBucketWebsite:w,deleteBucketWebsite:_,putBucketReferer:I,getBucketReferer:D,putBucketDomain:O,getBucketDomain:N,deleteBucketDomain:P,putBucketOrigin:M,getBucketOrigin:U,deleteBucketOrigin:H,putBucketLogging:L,getBucketLogging:F,putBucketInventory:K,getBucketInventory:j,listBucketInventory:z,deleteBucketInventory:q,putBucketAccelerate:G,getBucketAccelerate:V,putBucketEncryption:X,getBucketEncryption:W,deleteBucketEncryption:Q,getObject:Y,headObject:$,listObjectVersions:J,putObject:Z,deleteObject:ee,getObjectAcl:te,putObjectAcl:ne,optionsObject:re,putObjectCopy:oe,deleteMultipleObject:ae,restoreObject:se,putObjectTagging:ce,getObjectTagging:ue,deleteObjectTagging:le,selectObjectContent:de,uploadPartCopy:ie,multipartInit:fe,multipartUpload:he,multipartComplete:pe,multipartList:ge,multipartListPart:me,multipartAbort:ye,request:Ce,getObjectUrl:ke,getAuth:ve};e.exports.init=function(e,t){t.transferToTaskMethod(Ie,"putObject"),_e.each(Ie,function(t,n){e.prototype[n]=_e.apiWrapper(n,t),xe(n,t,e.prototype)})}},function(e,t){var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},r=function(e,t,r,o){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map(function(o){var i=encodeURIComponent(n(o))+r;return Array.isArray(e[o])?e[o].map(function(e){return i+encodeURIComponent(n(e))}).join(t):i+encodeURIComponent(n(e[o]))}).filter(Boolean).join(t):o?encodeURIComponent(n(o))+r+encodeURIComponent(n(e)):""},o=function(e,t,n){var r={};return t.getAllResponseHeaders().trim().split("\n").forEach(function(e){if(e){var t=e.indexOf(":"),n=e.substr(0,t).trim().toLowerCase(),o=e.substr(t+1).trim();r[n]=o}}),{error:e,statusCode:t.status,statusMessage:t.statusText,headers:r,body:n}},i=function(e,t){return t||"text"!==t?e.response:e.responseText},a=function(e,t){var n=(e.method||"GET").toUpperCase(),a=e.url;if(e.qs){var s=r(e.qs);s&&(a+=(-1===a.indexOf("?")?"?":"&")+s)}var c=new XMLHttpRequest;c.open(n,a,!0),c.responseType=e.dataType||"text";var u=e.headers;if(u)for(var l in u)u.hasOwnProperty(l)&&"content-length"!==l.toLowerCase()&&"user-agent"!==l.toLowerCase()&&"origin"!==l.toLowerCase()&&"host"!==l.toLowerCase()&&c.setRequestHeader(l,u[l]);return e.onProgress&&c.upload&&(c.upload.onprogress=e.onProgress),e.onDownloadProgress&&(c.onprogress=e.onDownloadProgress),c.onload=function(){t(o(null,c,i(c,e.dataType)))},c.onerror=function(n){var r=i(c,e.dataType);if(r)t(o(null,c,r));else{var a=c.statusText;a||0!==c.status||(a=new Error("CORS blocked or network error")),t(o(a,c,r))}},c.send(e.body||""),c};e.exports=a},function(e,t,n){function r(e,t){var n,r,i=this,a=new y,c=e.TaskId,l=e.Bucket,d=e.Region,f=e.Key,h=e.Body,p=e.ChunkSize||e.SliceSize||i.options.ChunkSize,m=e.AsyncLimit,v=e.StorageClass,k=e.ServerSideEncryption,S=e.onHashProgress;a.on("error",function(e){if(i._isRunningTask(c))return t(e)}),a.on("upload_complete",function(e){t(null,e)}),a.on("upload_slice_complete",function(t){var o={};C.each(e.Headers,function(e,t){var n=t.toLowerCase();0!==n.indexOf("x-cos-meta-")&&"pic-operations"!==n||(o[t]=e)}),u.call(i,{Bucket:l,Region:d,Key:f,UploadId:t.UploadId,SliceList:t.SliceList,Headers:o},function(e,o){if(i._isRunningTask(c)){if(g.removeUsing(t.UploadId),e)return r(null,!0),a.emit("error",e);g.removeUploadId.call(i,t.UploadId),r({loaded:n,total:n},!0),a.emit("upload_complete",o)}})}),a.on("get_upload_data_finish",function(t){var o=g.getFileId(h,e.ChunkSize,l,f);o&&g.saveUploadId.call(i,o,t.UploadId,i.options.UploadIdCacheLimit),g.setUsing(t.UploadId),r(null,!0),s.call(i,{TaskId:c,Bucket:l,Region:d,Key:f,Body:h,FileSize:n,SliceSize:p,AsyncLimit:m,ServerSideEncryption:k,UploadData:t,onProgress:r},function(e,t){if(i._isRunningTask(c))return e?(r(null,!0),a.emit("error",e)):void a.emit("upload_slice_complete",t)})}),a.on("get_file_size_finish",function(){if(r=C.throttleOnProgress.call(i,n,e.onProgress),e.UploadData.UploadId)a.emit("get_upload_data_finish",e.UploadData);else{var t=C.extend({TaskId:c,Bucket:l,Region:d,Key:f,Headers:e.Headers,StorageClass:v,Body:h,FileSize:n,SliceSize:p,onHashProgress:S},e);o.call(i,t,function(t,n){if(i._isRunningTask(c)){if(t)return a.emit("error",t);e.UploadData.UploadId=n.UploadId,e.UploadData.PartList=n.PartList,a.emit("get_upload_data_finish",e.UploadData)}})}}),n=e.ContentLength,delete e.ContentLength,!e.Headers&&(e.Headers={}),C.each(e.Headers,function(t,n){"content-length"===n.toLowerCase()&&delete e.Headers[n]}),function(){for(var t=[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,5120],r=1048576,o=0;oh)return t(null,!1);if(n>1){if(Math.max(e[0].Size,e[1].Size)!==f)return t(null,!1)}var r=function(o){if(o=c.length)return void b.emit("has_and_check_upload_id",t);var i=c[e];return C.isInArray(t,i)?g.using[i]?void l(e+1):void a.call(u,{Bucket:r,Region:o,Key:s,UploadId:i},function(t,r){u._isRunningTask(n)&&(t?(g.removeUploadId.call(u,i),l(e+1)):b.emit("upload_id_available",{UploadId:i,PartList:r.PartList}))}):(g.removeUploadId.call(u,i),void l(e+1))};l(0)}),b.on("get_remote_upload_id_list",function(){i.call(u,{Bucket:r,Region:o,Key:s},function(t,o){if(u._isRunningTask(n)){if(t)return b.emit("error",t);var i=C.filter(o.UploadList,function(e){return e.Key===s&&(!c||e.StorageClass.toUpperCase()===c.toUpperCase())}).reverse().map(function(e){return e.UploadId||e.UploadID});if(i.length)b.emit("seek_local_avail_upload_id",i);else{var a,l=g.getFileId(e.Body,e.ChunkSize,r,s);l&&(a=g.getUploadIdList.call(u,l))&&C.each(a,function(e){g.removeUploadId.call(u,e)}),b.emit("no_available_upload_id")}}})}),b.emit("get_remote_upload_id_list")}function i(e,t){var n=this,r=[],o={Bucket:e.Bucket,Region:e.Region,Prefix:e.Key},i=function(){n.multipartList(o,function(e,n){if(e)return t(e);r.push.apply(r,n.Upload||[]),"true"===n.IsTruncated?(o.KeyMarker=n.NextKeyMarker,o.UploadIdMarker=n.NextUploadIdMarker,i()):t(null,{UploadList:r})})};i()}function a(e,t){var n=this,r=[],o={Bucket:e.Bucket,Region:e.Region,Key:e.Key,UploadId:e.UploadId},i=function(){n.multipartListPart(o,function(e,n){if(e)return t(e);r.push.apply(r,n.Part||[]),"true"===n.IsTruncated?(o.PartNumberMarker=n.NextPartNumberMarker,i()):t(null,{PartList:r})})};i()}function s(e,t){var n=this,r=e.TaskId,o=e.Bucket,i=e.Region,a=e.Key,s=e.UploadData,u=e.FileSize,l=e.SliceSize,d=Math.min(e.AsyncLimit||n.options.ChunkParallelLimit||1,256),f=e.Body,h=Math.ceil(u/l),p=0,g=e.ServerSideEncryption,y=C.filter(s.PartList,function(e){return e.Uploaded&&(p+=e.PartNumber>=h?u%l||l:l),!e.Uploaded}),v=e.onProgress;m.eachLimit(y,d,function(e,t){if(n._isRunningTask(r)){var d=e.PartNumber,h=Math.min(u,e.PartNumber*l)-(e.PartNumber-1)*l,m=0;c.call(n,{TaskId:r,Bucket:o,Region:i,Key:a,SliceSize:l,FileSize:u,PartNumber:d,ServerSideEncryption:g,Body:f,UploadData:s,onProgress:function(e){p+=e.loaded-m,m=e.loaded,v({loaded:p,total:u})}},function(o,i){n._isRunningTask(r)&&(o||i.ETag||(o='get ETag error, please add "ETag" to CORS ExposeHeader setting.'),o?p-=m:(p+=h-m,e.ETag=i.ETag),v({loaded:p,total:u}),t(o||null,i))})}},function(e){if(n._isRunningTask(r))return e?t(e):void t(null,{UploadId:s.UploadId,SliceList:s.PartList})})}function c(e,t){var n=this,r=e.TaskId,o=e.Bucket,i=e.Region,a=e.Key,s=e.FileSize,c=e.Body,u=1*e.PartNumber,l=e.SliceSize,d=e.ServerSideEncryption,f=e.UploadData,h=n.options.ChunkRetryTimes+1,p=l*(u-1),g=l,y=p+l;y>s&&(y=s,g=y-p);var v=f.PartList[u-1];m.retry(h,function(t){n._isRunningTask(r)&&C.fileSlice(c,p,y,!0,function(s){n.multipartUpload({TaskId:r,Bucket:o,Region:i,Key:a,ContentLength:g,PartNumber:u,UploadId:f.UploadId,ServerSideEncryption:d,Body:s,onProgress:e.onProgress},function(e,o){if(n._isRunningTask(r))return e?t(e):(v.Uploaded=!0,t(null,o))})})},function(e,o){if(n._isRunningTask(r))return t(e,o)})}function u(e,t){var n=e.Bucket,r=e.Region,o=e.Key,i=e.UploadId,a=e.SliceList,s=this,c=this.options.ChunkRetryTimes+1,u=e.Headers,l=a.map(function(e){return{PartNumber:e.PartNumber,ETag:e.ETag}});m.retry(c,function(e){s.multipartComplete({Bucket:n,Region:r,Key:o,UploadId:i,Parts:l,Headers:u},e)},function(e,n){t(e,n)})}function l(e,t){var n=e.Bucket,r=e.Region,o=e.Key,a=e.UploadId,s=e.Level||"task",c=e.AsyncLimit,u=this,l=new y;if(l.on("error",function(e){return t(e)}),l.on("get_abort_array",function(i){d.call(u,{Bucket:n,Region:r,Key:o,Headers:e.Headers,AsyncLimit:c,AbortArray:i},t)}),"bucket"===s)i.call(u,{Bucket:n,Region:r},function(e,n){if(e)return t(e);l.emit("get_abort_array",n.UploadList||[])});else if("file"===s){if(!o)return t(C.error(new Error("abort_upload_task_no_key")));i.call(u,{Bucket:n,Region:r,Key:o},function(e,n){if(e)return t(e);l.emit("get_abort_array",n.UploadList||[])})}else{if("task"!==s)return t(C.error(new Error("abort_unknown_level")));if(!a)return t(C.error(new Error("abort_upload_task_no_id")));if(!o)return t(C.error(new Error("abort_upload_task_no_key")));l.emit("get_abort_array",[{Key:o,UploadId:a}])}}function d(e,t){var n=e.Bucket,r=e.Region,o=e.Key,i=e.AbortArray,a=e.AsyncLimit||1,s=this,c=0,u=new Array(i.length);m.eachLimit(i,a,function(t,i){var a=c;if(o&&o!==t.Key)return u[a]={error:{KeyNotMatch:!0}},void i(null);var l=t.UploadId||t.UploadID;s.multipartAbort({Bucket:n,Region:r,Key:t.Key,Headers:e.Headers,UploadId:l},function(e){var o={Bucket:n,Region:r,Key:t.Key,UploadId:l};u[a]={error:e,task:o},i(null)}),c++},function(e){if(e)return t(e);for(var n=[],r=[],o=0,i=u.length;or?"sliceUploadFile":"putObject";d.push({api:v,params:e,callback:y})}()}),n._addTasks(d)}function h(e,t){var n=new y,r=this,o=e.Bucket,i=e.Region,a=e.Key,s=e.CopySource,c=s.match(/^([^.]+-\d+)\.cos(v6)?\.([^.]+)\.[^\/]+\/(.+)$/);if(!c)return void t(C.error(new Error("CopySource format error")));var u=c[1],l=c[3],d=decodeURIComponent(c[4]),f=void 0===e.CopySliceSize?r.options.CopySliceSize:e.CopySliceSize;f=Math.max(0,f);var h,g,v=e.CopyChunkSize||this.options.CopyChunkSize,k=this.options.CopyChunkParallelLimit,S=0;n.on("copy_slice_complete",function(n){var s={};C.each(e.Headers,function(e,t){0===t.toLowerCase().indexOf("x-cos-meta-")&&(s[t]=e)});var c=C.map(n.PartList,function(e){return{PartNumber:e.PartNumber,ETag:e.ETag}});r.multipartComplete({Bucket:o,Region:i,Key:a,UploadId:n.UploadId,Parts:c},function(e,n){if(e)return g(null,!0),t(e);g({loaded:h,total:h},!0),t(null,n)})}),n.on("get_copy_data_finish",function(e){m.eachLimit(e.PartList,k,function(t,n){var c=t.PartNumber,u=t.CopySourceRange,l=t.end-t.start;p.call(r,{Bucket:o,Region:i,Key:a,CopySource:s,UploadId:e.UploadId,PartNumber:c,CopySourceRange:u},function(e,r){if(e)return n(e);S+=l,g({loaded:S,total:h}),t.ETag=r.ETag,n(e||null,r)})},function(r){if(r)return g(null,!0),t(r);n.emit("copy_slice_complete",e)})}),n.on("get_file_size_finish",function(s){!function(){for(var t=[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,5120],n=1048576,o=0;o"x-cos-meta-".length&&(s[t]=e)}),n.emit("get_file_size_finish",s)}})}function p(e,t){var n=e.TaskId,r=e.Bucket,o=e.Region,i=e.Key,a=e.CopySource,s=e.UploadId,c=1*e.PartNumber,u=e.CopySourceRange,l=this.options.ChunkRetryTimes+1,d=this;m.retry(l,function(e){d.uploadPartCopy({TaskId:n,Bucket:r,Region:o,Key:i,CopySource:a,UploadId:s,PartNumber:c,CopySourceRange:u},function(t,n){e(t||null,n)})},function(e,n){return t(e,n)})}var g=n(3),m=n(19),y=n(2).EventProxy,C=n(0),v={sliceUploadFile:r,abortUploadTask:l,uploadFiles:f,sliceCopyFile:h};e.exports.init=function(e,t){t.transferToTaskMethod(v,"sliceUploadFile"),C.each(v,function(t,n){e.prototype[n]=C.apiWrapper(n,t)})}},function(e,t){var n=function(e,t,n,r){if(r=r||function(){},!e.length||t<=0)return r();var o=0,i=0,a=0;!function s(){if(o>=e.length)return r();for(;a=e.length?r():s())})}()},r=function(e,t,n){var r=function(o){t(function(t,i){t&&o