cos-js-sdk-v5.min.js 148 KB

1
  1. !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.COS=t():e.COS=t()}(this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=9)}([function(e,t){function r(t){return e.exports=r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";(function(t){var n=r(0);function o(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){c=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw a}}}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var a=r(12),s=r(14),c=r(15),u=c.XMLParser,l=c.XMLBuilder,d=new u({ignoreDeclaration:!0,ignoreAttributes:!0,parseTagValue:!1}),p=new l,h=r(25),f=r(5);function g(e){return encodeURIComponent(e).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")}function m(e,t){var r=[];for(var n in e)e.hasOwnProperty(n)&&r.push(t?g(n).toLowerCase():n);return r.sort((function(e,t){return(e=e.toLowerCase())===(t=t.toLowerCase())?0:e>t?1:-1}))}var y,k=["cache-control","content-disposition","content-encoding","content-length","content-md5","expect","expires","host","if-match","if-modified-since","if-none-match","if-unmodified-since","origin","range","transfer-encoding","pic-operations"],C=function(e,t,r){var n=t/8,o=e.slice(r,r+n);return new Uint8Array(o).reverse(),new{8:Uint8Array,16:Uint16Array,32:Uint32Array}[t](o)[0]},v=function(e,t,r,n){var o=e.slice(t,r),i="";return new Uint8Array(o).forEach((function(e){i+=String.fromCharCode(e)})),n&&(i=decodeURIComponent(escape(i))),i},b=function(){},S=function(e){var t={};for(var r in e)e.hasOwnProperty(r)&&void 0!==e[r]&&null!==e[r]&&(t[r]=e[r]);return t},x=function(e,t){var r,n=new FileReader;FileReader.prototype.readAsBinaryString?(r=FileReader.prototype.readAsBinaryString,n.onload=function(){t(this.result)}):FileReader.prototype.readAsArrayBuffer&&(r=function(e){var r="",n=new FileReader;n.onload=function(e){for(var o=new Uint8Array(n.result),i=o.byteLength,a=0;a<i;a++)r+=String.fromCharCode(o[a]);t(r)},n.readAsArrayBuffer(e)}),r.call(n,e)},T=(y=function(e,t){e=e.split("."),t=t.split(".");for(var r=0;r<t.length;r++)if(e[r]!==t[r])return parseInt(e[r])>parseInt(t[r])?1:-1;return 0},function(e){if(!e)return!1;var t=(e.match(/Chrome\/([.\d]+)/)||[])[1],r=(e.match(/QBCore\/([.\d]+)/)||[])[1],n=(e.match(/QQBrowser\/([.\d]+)/)||[])[1];return t&&y(t,"53.0.2785.116")<0&&r&&y(r,"3.53.991.400")<0&&n&&y(n,"9.0.2524.400")<=0||!1}("undefined"!=typeof navigator&&navigator.userAgent)),R=1048576;function B(e){return w(e,(function(e){return"object"===n(e)&&null!==e?B(e):e}))}function A(e,t){return E(t,(function(r,n){e[n]=t[n]})),e}function P(e){return e instanceof Array}function E(e,t){for(var r in e)e.hasOwnProperty(r)&&t(e[r],r)}function w(e,t){var r=P(e)?[]:{};for(var n in e)e.hasOwnProperty(n)&&(r[n]=t(e[n],n));return r}var O=function(e,t){var r=t.Bucket,n=t.Region,o=t.Key,i=this.options.Domain,a=!i||"string"==typeof i&&i.indexOf("{Bucket}")>-1,s=!i||"string"==typeof i&&i.indexOf("{Region}")>-1;if(e.indexOf("Bucket")>-1||"deleteMultipleObject"===e||"multipartList"===e||"listObjectVersions"===e){if(a&&!r)return"Bucket";if(s&&!n)return"Region"}else if(e.indexOf("Object")>-1||e.indexOf("multipart")>-1||"sliceUploadFile"===e||"abortUploadTask"===e||"uploadFile"===e){if(a&&!r)return"Bucket";if(s&&!n)return"Region";if(!o)return"Key"}return!1},I=function(e,t){if(t=A({},t),"getAuth"!==e&&"getV4Auth"!==e&&"getObjectUrl"!==e){var r=t.Headers||{};if(t&&"object"===n(t)){!function(){for(var e in t)t.hasOwnProperty(e)&&e.indexOf("x-cos-")>-1&&(r[e]=t[e])}();D.each({"x-cos-mfa":"MFA","Content-MD5":"ContentMD5","Content-Length":"ContentLength","Content-Type":"ContentType",Expect:"Expect",Expires:"Expires","Cache-Control":"CacheControl","Content-Disposition":"ContentDisposition","Content-Encoding":"ContentEncoding",Range:"Range","If-Modified-Since":"IfModifiedSince","If-Unmodified-Since":"IfUnmodifiedSince","If-Match":"IfMatch","If-None-Match":"IfNoneMatch","x-cos-copy-source":"CopySource","x-cos-copy-source-Range":"CopySourceRange","x-cos-metadata-directive":"MetadataDirective","x-cos-copy-source-If-Modified-Since":"CopySourceIfModifiedSince","x-cos-copy-source-If-Unmodified-Since":"CopySourceIfUnmodifiedSince","x-cos-copy-source-If-Match":"CopySourceIfMatch","x-cos-copy-source-If-None-Match":"CopySourceIfNoneMatch","x-cos-acl":"ACL","x-cos-grant-read":"GrantRead","x-cos-grant-write":"GrantWrite","x-cos-grant-full-control":"GrantFullControl","x-cos-grant-read-acp":"GrantReadAcp","x-cos-grant-write-acp":"GrantWriteAcp","x-cos-storage-class":"StorageClass","x-cos-traffic-limit":"TrafficLimit","x-cos-mime-limit":"MimeLimit","x-cos-server-side-encryption-customer-algorithm":"SSECustomerAlgorithm","x-cos-server-side-encryption-customer-key":"SSECustomerKey","x-cos-server-side-encryption-customer-key-MD5":"SSECustomerKeyMD5","x-cos-server-side-encryption":"ServerSideEncryption","x-cos-server-side-encryption-cos-kms-key-id":"SSEKMSKeyId","x-cos-server-side-encryption-context":"SSEContext","Pic-Operations":"PicOperations","x-cos-callback":"Callback","x-cos-callback-var":"CallbackVar","x-cos-return-body":"ReturnBody"},(function(e,n){void 0!==t[e]&&(r[n]=t[e])})),t.Headers=S(r)}}return t},U=function(e){return Date.now()+(e||0)},N="object"===("undefined"==typeof navigator?"undefined":n(navigator))&&!!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),_="object"===("undefined"==typeof navigator?"undefined":n(navigator))&&/\sQQ/i.test(navigator.userAgent),D={noop:b,formatParams:I,apiWrapper:function(e,t){return function(r,n){var o,i=this;if("function"==typeof r&&(n=r,r={}),r=I(e,r),i.options.EnableReporter)if("sliceUploadFile"===r.calledBySdk||"sliceCopyFile"===r.calledBySdk)o=r.tracker&&r.tracker.generateSubTracker({apiName:e});else if(["uploadFile","uploadFiles"].includes(e))o=null;else{var a=0;r.Body&&(a="string"==typeof r.Body?r.Body.length:r.Body.size||r.Body.byteLength||0);var s=i.options.UseAccelerate||"string"==typeof i.options.Domain&&i.options.Domain.includes("accelerate.");o=new f({Beacon:i.options.BeaconReporter,clsReporter:i.options.ClsReporter,bucket:r.Bucket,region:r.Region,apiName:e,realApi:e,accelerate:s,fileKey:r.Key,fileSize:a,deepTracker:i.options.DeepTracker,customId:i.options.CustomId,delay:i.options.TrackerDelay})}r.tracker=o;var c=function(e){return e&&e.headers&&(e.headers["x-cos-request-id"]&&(e.RequestId=e.headers["x-cos-request-id"]),e.headers["x-ci-request-id"]&&(e.RequestId=e.headers["x-ci-request-id"]),e.headers["x-cos-version-id"]&&(e.VersionId=e.headers["x-cos-version-id"]),e.headers["x-cos-delete-marker"]&&(e.DeleteMarker=e.headers["x-cos-delete-marker"])),e},u=function(e,t){o&&o.report(e,t),n&&n(c(e),c(t))},l=function(){if("getService"!==e&&"abortUploadTask"!==e){var t=O.call(i,e,r);if(t)return"missing param "+t;if(r.Region){if(i.options.CompatibilityMode){if(!/^([a-z\d-.]+)$/.test(r.Region))return"Region format error."}else{if(r.Region.indexOf("cos.")>-1)return'param Region should not be start with "cos."';if(!/^([a-z\d-]+)$/.test(r.Region))return"Region format error."}!i.options.CompatibilityMode&&-1===r.Region.indexOf("-")&&"yfb"!==r.Region&&"default"!==r.Region&&r.Region}if(r.Bucket){if(!/^([a-z\d-]+)-(\d+)$/.test(r.Bucket))if(r.AppId)r.Bucket=r.Bucket+"-"+r.AppId;else{if(!i.options.AppId)return'Bucket should format as "test-1250000000".';r.Bucket=r.Bucket+"-"+i.options.AppId}r.AppId&&delete r.AppId}!i.options.UseRawKey&&r.Key&&"/"===r.Key.substr(0,1)&&(r.Key=r.Key.substr(1))}}(),d=["getAuth","getObjectUrl"].includes(e);if("function"==typeof Promise&&!d&&!n)return new Promise((function(e,o){if(n=function(t,r){t?o(t):e(r)},l)return u(D.error(new Error(l)));t.call(i,r,u)}));if(l)return u(D.error(new Error(l)));var p=t.call(i,r,u);return d?p:void 0}},xml2json:function(e){return d.parse(e)},json2xml:function(e){return p.build(e)},md5:a,clearKey:S,fileSlice:function(e,t,r,n,o){var i;if(e.slice?i=e.slice(t,r):e.mozSlice?i=e.mozSlice(t,r):e.webkitSlice&&(i=e.webkitSlice(t,r)),n&&T){var a=new FileReader;a.onload=function(e){i=null,o(new Blob([a.result]))},a.readAsArrayBuffer(i)}else o(i)},getBodyMd5:function(e,t,r,n){r=r||b,e?"string"==typeof t?r(D.md5(t,!0)):Blob&&t instanceof Blob?D.getFileMd5(t,(function(e,t){r(t)}),n):r():r()},getFileMd5:function(e,t,r){var n=e.size,o=0,i=a.getCtx();!function a(s){if(s>=n){var c=i.digest("hex");t(null,c)}else{var u=Math.min(n,s+R);D.fileSlice(e,s,u,!1,(function(e){x(e,(function(t){e=null,i=i.update(t,!0),o+=t.length,t=null,r&&r({loaded:o,total:n,percent:Math.round(o/n*1e4)/1e4}),a(s+R)}))}))}}(0)},b64:function(e){var t,r,n,o="";for(t=0,r=e.length/2;t<r;t++)n=parseInt(e[2*t]+e[2*t+1],16),o+=String.fromCharCode(n);return btoa(o)},extend:A,isArray:P,isInArray:function(e,t){for(var r=!1,n=0;n<e.length;n++)if(t===e[n]){r=!0;break}return r},makeArray:function(e){return P(e)?e:[e]},each:E,map:w,filter:function(e,t){var r=P(e),n=r?[]:{};for(var o in e)e.hasOwnProperty(o)&&t(e[o],o)&&(r?n.push(e[o]):n[o]=e[o]);return n},clone:B,attr:function(e,t,r){return e&&t in e?e[t]:r},uuid:function(){var e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()},camSafeUrlEncode:g,throttleOnProgress:function(e,t){var r,n,o=this,i=0,a=0,s=Date.now();function c(){if(n=0,t&&"function"==typeof t){r=Date.now();var o,c=Math.max(0,Math.round((a-i)/((r-s)/1e3)*100)/100)||0;o=0===a&&0===e?1:Math.floor(a/e*100)/100||0,s=r,i=a;try{t({loaded:a,total:e,speed:c,percent:o})}catch(e){}}}return function(t,r){if(t&&(a=t.loaded,e=t.total),r)clearTimeout(n),c();else{if(n)return;n=setTimeout(c,o.options.ProgressInterval)}}},getFileSize:function(e,t,r){var n;"string"==typeof t.Body?t.Body=new Blob([t.Body],{type:"text/plain"}):t.Body instanceof ArrayBuffer&&(t.Body=new Blob([t.Body])),t.Body&&(t.Body instanceof Blob||"[object File]"===t.Body.toString()||"[object Blob]"===t.Body.toString())?(n=t.Body.size,t.ContentLength=n,r(null,n)):r(D.error(new Error("params body format error, Only allow File|Blob|String.")))},getSkewTime:U,error:function(e,t){var r=e;return e.message=e.message||null,"string"==typeof t?(e.error=t,e.message=t):"object"===n(t)&&null!==t&&(A(e,t),(t.code||t.name)&&(e.code=t.code||t.name),t.message&&(e.message=t.message),t.stack&&(e.stack=t.stack)),"function"==typeof Object.defineProperty&&(Object.defineProperty(e,"name",{writable:!0,enumerable:!1}),Object.defineProperty(e,"message",{enumerable:!0})),e.name=t&&t.name||e.name||e.code||"Error",e.code||(e.code=e.name),e.error||(e.error=B(r)),e},obj2str:function(e,t){var r,n,o,i=[],a=m(e);for(r=0;r<a.length;r++)o=void 0===e[n=a[r]]||null===e[n]?"":""+e[n],n=t?g(n).toLowerCase():g(n),o=g(o)||"",i.push(n+"="+o);return i.join("&")},getAuth:function(e){var t,r=(e=e||{}).SecretId,n=e.SecretKey,o=e.KeyTime,i=(e.method||e.Method||"get").toLowerCase(),a=B(e.Query||e.params||{}),c=function(e){var t={};for(var r in e){var n=r.toLowerCase();(n.indexOf("x-cos-")>-1||k.indexOf(n)>-1)&&(t[r]=e[r])}return t}(B(e.Headers||e.headers||{})),u=e.Key||"";e.UseRawKey?t=e.Pathname||e.pathname||"/"+u:0!==(t=e.Pathname||e.pathname||u).indexOf("/")&&(t="/"+t);var l=!1!==e.ForceSignHost;if(!c.Host&&!c.host&&e.Bucket&&e.Region&&l&&(c.Host=e.Bucket+".cos."+e.Region+".myqcloud.com"),!r)throw new Error("missing param SecretId");if(!n)throw new Error("missing param SecretKey");var d=Math.round(U(e.SystemClockOffset)/1e3)-1,p=d,h=e.Expires||e.expires;p+=void 0===h?900:1*h||0;var f=r,g=o||d+";"+p,y=o||d+";"+p,C=m(c,!0).join(";").toLowerCase(),v=m(a,!0).join(";").toLowerCase(),b=s.HmacSHA1(y,n).toString(),S=[i,t,D.obj2str(a,!0),D.obj2str(c,!0),""].join("\n"),x=["sha1",g,s.SHA1(S).toString(),""].join("\n");return["q-sign-algorithm=sha1","q-ak="+f,"q-sign-time="+g,"q-key-time="+y,"q-header-list="+C,"q-url-param-list="+v,"q-signature="+s.HmacSHA1(x,b).toString()].join("&")},parseSelectPayload:function(e){for(var t={},r=v(e),n={records:[]};e.byteLength;){var o,i=C(e,32,0),a=C(e,32,4),s=i-a-16,c=0;for(e=e.slice(12);c<a;){var u=C(e,8,c),l=v(e,c+1,c+1+u),d=C(e,16,c+u+2),p=v(e,c+u+4,c+u+4+d);t[l]=p,c+=u+4+d}if("Records"===t[":event-type"])o=v(e,c,c+s,!0),n.records.push(o);else if("Stats"===t[":event-type"])o=v(e,c,c+s,!0),n.stats=D.xml2json(o).Stats;else if("error"===t[":event-type"]){var h=t[":error-code"],f=t[":error-message"],g=new Error(f);g.message=f,g.name=g.code=h,n.error=g}else["Progress","Continuation","End"].includes(t[":event-type"]);e=e.slice(c+s+4)}return{payload:n.records.join(""),body:r}},getSourceParams:function(e){var t=this.options.CopySourceParser;if(t)return t(e);var r=e.match(/^([^.]+-\d+)\.cos(v6|-cdc|-cdz|-internal)?\.([^.]+)\.((myqcloud\.com)|(tencentcos\.cn))\/(.+)$/);return r?{Bucket:r[1],Region:r[3],Key:r[7]}:null},isBrowser:!0,isNode:function(){return"object"!==("undefined"==typeof window?"undefined":n(window))&&"object"===(void 0===t?"undefined":n(t))&&!("object"===("undefined"==typeof globalThis?"undefined":n(globalThis))&&("DedicatedWorkerGlobalScope"===globalThis.constructor.name||globalThis.FileReaderSync))},isCIHost:function(e){return/^https?:\/\/([^/]+\.)?ci\.[^/]+/.test(e)},isIOS_QQ:N&&_,encodeBase64:function(e,t){var r=h.encode(e);return t&&(r=r.replaceAll("+","-").replaceAll("/","_").replaceAll("=","")),r},decodeBase64:function(e){return e?h.decode(e):""},simplifyPath:function(e){var t,r=[],n=o(e.split("/"));try{for(n.s();!(t=n.n()).done;){var i=t.value;".."===i?r.length&&r.pop():i.length&&"."!==i&&r.push(i)}}catch(e){n.e(e)}finally{n.f()}return"/"+r.join("/")},readAsBinaryString:x,parseResBody:function(e){var t;if(e&&"string"==typeof e){var r=e.trim(),n=0===r.indexOf("<"),o=0===r.indexOf("{");if(n)t=D.xml2json(e)||{};else if(o)try{var i=e.replace(/\n/g," "),a=JSON.parse(i);t="[object Object]"===Object.prototype.toString.call(a)?a:e}catch(r){t=e}else t=e}else t=e||{};return t}};e.exports=D}).call(this,r(11))},function(e,t,r){"use strict";const n=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",o="["+n+"]["+(n+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040")+"]*",i=new RegExp("^"+o+"$");t.isExist=function(e){return void 0!==e},t.isEmptyObject=function(e){return 0===Object.keys(e).length},t.merge=function(e,t,r){if(t){const n=Object.keys(t),o=n.length;for(let i=0;i<o;i++)e[n[i]]="strict"===r?[t[n[i]]]:t[n[i]]}},t.getValue=function(e){return t.isExist(e)?e:""},t.isName=function(e){const t=i.exec(e);return!(null==t)},t.getAllMatches=function(e,t){const r=[];let n=t.exec(e);for(;n;){const o=[];o.startIndex=t.lastIndex-n[0].length;const i=n.length;for(let e=0;e<i;e++)o.push(n[e]);r.push(o),n=t.exec(e)}return r},t.nameRegexp=o},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,r){"use strict";const n=r(2),o={allowBooleanAttributes:!1,unpairedTags:[]};function i(e){return" "===e||"\t"===e||"\n"===e||"\r"===e}function a(e,t){const r=t;for(;t<e.length;t++)if("?"!=e[t]&&" "!=e[t]);else{const n=e.substr(r,t-r);if(t>5&&"xml"===n)return f("InvalidXml","XML declaration allowed only at the start of the document.",m(e,t));if("?"==e[t]&&">"==e[t+1]){t++;break}}return t}function s(e,t){if(e.length>t+5&&"-"===e[t+1]&&"-"===e[t+2]){for(t+=3;t<e.length;t++)if("-"===e[t]&&"-"===e[t+1]&&">"===e[t+2]){t+=2;break}}else if(e.length>t+8&&"D"===e[t+1]&&"O"===e[t+2]&&"C"===e[t+3]&&"T"===e[t+4]&&"Y"===e[t+5]&&"P"===e[t+6]&&"E"===e[t+7]){let r=1;for(t+=8;t<e.length;t++)if("<"===e[t])r++;else if(">"===e[t]&&(r--,0===r))break}else if(e.length>t+9&&"["===e[t+1]&&"C"===e[t+2]&&"D"===e[t+3]&&"A"===e[t+4]&&"T"===e[t+5]&&"A"===e[t+6]&&"["===e[t+7])for(t+=8;t<e.length;t++)if("]"===e[t]&&"]"===e[t+1]&&">"===e[t+2]){t+=2;break}return t}t.validate=function(e,t){t=Object.assign({},o,t);const r=[];let c=!1,u=!1;"\ufeff"===e[0]&&(e=e.substr(1));for(let o=0;o<e.length;o++)if("<"===e[o]&&"?"===e[o+1]){if(o+=2,o=a(e,o),o.err)return o}else{if("<"!==e[o]){if(i(e[o]))continue;return f("InvalidChar","char '"+e[o]+"' is not expected.",m(e,o))}{let g=o;if(o++,"!"===e[o]){o=s(e,o);continue}{let y=!1;"/"===e[o]&&(y=!0,o++);let k="";for(;o<e.length&&">"!==e[o]&&" "!==e[o]&&"\t"!==e[o]&&"\n"!==e[o]&&"\r"!==e[o];o++)k+=e[o];if(k=k.trim(),"/"===k[k.length-1]&&(k=k.substring(0,k.length-1),o--),d=k,!n.isName(d)){let t;return t=0===k.trim().length?"Invalid space after '<'.":"Tag '"+k+"' is an invalid name.",f("InvalidTag",t,m(e,o))}const C=l(e,o);if(!1===C)return f("InvalidAttr","Attributes for '"+k+"' have open quote.",m(e,o));let v=C.value;if(o=C.index,"/"===v[v.length-1]){const r=o-v.length;v=v.substring(0,v.length-1);const n=p(v,t);if(!0!==n)return f(n.err.code,n.err.msg,m(e,r+n.err.line));c=!0}else if(y){if(!C.tagClosed)return f("InvalidTag","Closing tag '"+k+"' doesn't have proper closing.",m(e,o));if(v.trim().length>0)return f("InvalidTag","Closing tag '"+k+"' can't have attributes or invalid starting.",m(e,g));if(0===r.length)return f("InvalidTag","Closing tag '"+k+"' has not been opened.",m(e,g));{const t=r.pop();if(k!==t.tagName){let r=m(e,t.tagStartPos);return f("InvalidTag","Expected closing tag '"+t.tagName+"' (opened in line "+r.line+", col "+r.col+") instead of closing tag '"+k+"'.",m(e,g))}0==r.length&&(u=!0)}}else{const n=p(v,t);if(!0!==n)return f(n.err.code,n.err.msg,m(e,o-v.length+n.err.line));if(!0===u)return f("InvalidXml","Multiple possible root nodes found.",m(e,o));-1!==t.unpairedTags.indexOf(k)||r.push({tagName:k,tagStartPos:g}),c=!0}for(o++;o<e.length;o++)if("<"===e[o]){if("!"===e[o+1]){o++,o=s(e,o);continue}if("?"!==e[o+1])break;if(o=a(e,++o),o.err)return o}else if("&"===e[o]){const t=h(e,o);if(-1==t)return f("InvalidChar","char '&' is not expected.",m(e,o));o=t}else if(!0===u&&!i(e[o]))return f("InvalidXml","Extra text at the end",m(e,o));"<"===e[o]&&o--}}}var d;return c?1==r.length?f("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",m(e,r[0].tagStartPos)):!(r.length>0)||f("InvalidXml","Invalid '"+JSON.stringify(r.map((e=>e.tagName)),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):f("InvalidXml","Start tag expected.",1)};const c='"',u="'";function l(e,t){let r="",n="",o=!1;for(;t<e.length;t++){if(e[t]===c||e[t]===u)""===n?n=e[t]:n!==e[t]||(n="");else if(">"===e[t]&&""===n){o=!0;break}r+=e[t]}return""===n&&{value:r,index:t,tagClosed:o}}const d=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function p(e,t){const r=n.getAllMatches(e,d),o={};for(let e=0;e<r.length;e++){if(0===r[e][1].length)return f("InvalidAttr","Attribute '"+r[e][2]+"' has no space in starting.",y(r[e]));if(void 0!==r[e][3]&&void 0===r[e][4])return f("InvalidAttr","Attribute '"+r[e][2]+"' is without value.",y(r[e]));if(void 0===r[e][3]&&!t.allowBooleanAttributes)return f("InvalidAttr","boolean attribute '"+r[e][2]+"' is not allowed.",y(r[e]));const n=r[e][2];if(!g(n))return f("InvalidAttr","Attribute '"+n+"' is an invalid name.",y(r[e]));if(o.hasOwnProperty(n))return f("InvalidAttr","Attribute '"+n+"' is repeated.",y(r[e]));o[n]=1}return!0}function h(e,t){if(";"===e[++t])return-1;if("#"===e[t])return function(e,t){let r=/\d/;for("x"===e[t]&&(t++,r=/[\da-fA-F]/);t<e.length;t++){if(";"===e[t])return t;if(!e[t].match(r))break}return-1}(e,++t);let r=0;for(;t<e.length;t++,r++)if(!(e[t].match(/\w/)&&r<20)){if(";"===e[t])break;return-1}return t}function f(e,t,r){return{err:{code:e,msg:t,line:r.line||r,col:r.col}}}function g(e){return n.isName(e)}function m(e,t){const r=e.substring(0,t).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function y(e){return e.startIndex+e[1].length}},function(e,t,r){var n=r(26),o=r(27),i=r(0),a=r(6),s=null,c=function(e){return!e||e<0?0:(e/1e3).toFixed(3)},u=function(){var e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()},l=function(){if("object"===("undefined"==typeof navigator?"undefined":i(navigator))){var e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;return(null==e?void 0:e.type)||(null==e?void 0:e.effectiveType)||"unknown"}return"unknown"},d=function(){return"object"===("undefined"==typeof location?"undefined":i(location))?location.protocol.replace(/:/,""):"unknown protocol"},p=function(){if("object"!==("undefined"==typeof navigator?"undefined":i(navigator)))return"unknown os";var e=navigator.userAgent.toLowerCase(),t=/macintosh|mac os x/i.test(navigator.userAgent);return e.indexOf("win32")>=0||e.indexOf("wow32")>=0?"win32":e.indexOf("win64")>=0||e.indexOf("wow64")>=0?"win64":t?"mac":"unknown os"},h=function(){return!("object"!==("undefined"==typeof navigator?"undefined":i(navigator))||!navigator.userAgent.match(/(Android|Adr|Linux)/i))},f=function(){return!("object"!==("undefined"==typeof navigator?"undefined":i(navigator))||!navigator.userAgent.match(/(iPhone|iPod|iPad|iOS)/i))},g=function(){return"object"!==("undefined"==typeof navigator?"undefined":i(navigator))?"unknown device":navigator.userAgent},m=function(){return!("object"!==("undefined"==typeof navigator?"undefined":i(navigator))||!navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))}(),y=h()?"android":f?"ios":"other_mobile",k=p(),C=m?y:k,v=g(),b=d();function S(e){return e.replace(/([A-Z])/g,"_$1").toLowerCase()}var x=function(){"use strict";function e(t){n(this,e);var r=t.parent,o=t.traceId,i=t.bucket,c=t.region,l=t.apiName,d=t.realApi,p=t.httpMethod,h=t.fileKey,f=t.fileSize,g=t.accelerate,m=t.customId,y=t.delay,k=t.deepTracker,S=t.Beacon,x=t.clsReporter,T=i&&i.substr(i.lastIndexOf("-")+1)||"";this.parent=r,this.deepTracker=k,this.delay=y,x&&!this.clsReporter&&(this.clsReporter=x),this.params={sdkVersionName:"cos-js-sdk-v5",sdkVersionCode:a.version,osName:C,networkType:"",requestName:l||"",requestResult:"",realApi:d,bucket:i,region:c,accelerate:g,httpMethod:p,url:"",host:"",httpDomain:"",requestPath:h||"",userAgent:v,networkProtocol:b,errorType:"",errorCode:"",errorName:"",errorMessage:"",errorRequestId:"",errorHttpCode:0,errorServiceName:"",errorNode:"",httpTookTime:0,httpSize:f||0,httpMd5:0,httpSign:0,httpFullTime:0,httpSpeed:0,md5StartTime:0,md5EndTime:0,signStartTime:0,signEndTime:0,httpStartTime:0,httpEndTime:0,startTime:(new Date).getTime(),endTime:0,traceId:o||u(),appid:T,partNumber:0,httpRetryTimes:0,customId:m||"",partTime:0},S&&(this.beacon=function(e,t){if(!s){if("function"!=typeof e)throw new Error("Beacon not found");s=new e({appkey:"0WEB05PY6MHRGK0U",versionCode:a.version,channelID:"js_sdk",openid:"openid",unionid:"unid",strictMode:!1,delay:t,sessionDuration:6e4})}return s}(S,y))}return o(e,[{key:"formatResult",value:function(e,t){var r,n,o,i,a,s,u=(new Date).getTime(),d=l(),p=e?(null==e?void 0:e.code)||(null==e||null===(r=e.error)||void 0===r?void 0:r.code)||(null==e||null===(n=e.error)||void 0===n?void 0:n.Code):"",h=e?(null==e?void 0:e.message)||(null==e||null===(o=e.error)||void 0===o?void 0:o.message)||(null==e||null===(i=e.error)||void 0===i?void 0:i.Message):"",f=h,g=e?(null==e?void 0:e.resource)||(null==e||null===(a=e.error)||void 0===a?void 0:a.resource)||(null==e||null===(s=e.error)||void 0===s?void 0:s.Resource):"",m=e?null==e?void 0:e.statusCode:t.statusCode,y=e?(null==e?void 0:e.headers)&&(null==e?void 0:e.headers["x-cos-request-id"]):(null==t?void 0:t.headers)&&(null==t?void 0:t.headers["x-cos-request-id"]),k=e?y?"Server":"Client":"";"getObject"===this.params.requestName&&(this.params.httpSize=t?t.headers&&t.headers["content-length"]:0);var C="sliceUploadFile"===this.params.realApi,v="sliceCopyFile"===this.params.realApi;if(C||v){var b=this.params.httpSize/1024/this.params.partTime;Object.assign(this.params,{httpSpeed:b<0?0:b.toFixed(3)})}else{var S=u-this.params.startTime,x=this.params.httpEndTime-this.params.httpStartTime,T=this.params.httpSize/1024/(x/1e3),R=this.params.md5EndTime-this.params.md5StartTime,B=this.params.signEndTime-this.params.signStartTime;this.parent&&(this.parent.addParamValue("httpTookTime",c(x)),this.parent.addParamValue("httpFullTime",c(S)),this.parent.addParamValue("httpMd5",c(R)),this.parent.addParamValue("httpSign",c(B)),["multipartUpload","uploadPartCopy","putObjectCopy"].includes(this.params.requestName)&&this.parent.addParamValue("partTime",c(x))),Object.assign(this.params,{httpFullTime:c(S),httpMd5:c(R),httpSign:c(B),httpTookTime:c(x),httpSpeed:T<0?0:T.toFixed(3)})}if(Object.assign(this.params,{networkType:d,requestResult:e?"Failure":"Success",errorType:k,errorCode:p,errorHttpCode:m,errorName:f,errorMessage:h,errorServiceName:g,errorRequestId:y}),!e||p&&h||(this.params.fullError=e?JSON.stringify(e):""),this.params.url){try{var A=/^http(s)?:\/\/(.*?)\//.exec(this.params.url);this.params.host=A[2]}catch(e){this.params.host=this.params.url}this.params.httpDomain=this.params.host}}},{key:"report",value:function(e,t){if(this.beacon||this.clsReporter){this.formatResult(e,t);var r=function(e){var t,r={},n=["sdkVersionName","sdkVersionCode","osName","networkType","requestName","requestResult","bucket","region","appid","accelerate","url","host","requestPath","userAgent","networkProtocol","httpMethod","httpSize","httpSpeed","httpTookTime","httpMd5","httpSign","httpFullTime","httpDomain","partNumber","httpRetryTimes","customId","traceId","realApi"],o=[].concat(n,["errorNode","errorCode","errorName","errorMessage","errorRequestId","errorHttpCode","errorServiceName","errorType","fullError"]),i="Success"===e.requestResult?n:o;for(var a in e)i.includes(a)&&(r[S(a)]=e[a]);return r.request_name=e.realApi?(t=e.realApi,["putObject","sliceUploadFile","uploadFile","uploadFiles"].includes(t)?"UploadTask":"getObject"===t?"DownloadTask":["putObjectCopy","sliceCopyFile"].includes(t)?"CopyTask":t):e.requestName,r}(this.params);this.beacon&&this.sendEventsToBeacon(r),this.clsReporter&&this.sendEventsToCLS(r)}}},{key:"setParams",value:function(e){Object.assign(this.params,e)}},{key:"addParamValue",value:function(e,t){this.params[e]=(+this.params[e]+ +t).toFixed(3)}},{key:"sendEventsToBeacon",value:function(e){if(!("sliceUploadFile"===this.params.requestName||"sliceUploadFile"===this.params.realApi)||this.deepTracker){var t="qcloud_track_cos_sdk";0===this.delay?this.beacon&&this.beacon.onDirectUserAction(t,e):this.beacon&&this.beacon.onUserAction(t,e)}}},{key:"sendEventsToCLS",value:function(e){var t=!(0!==this.delay);this.clsReporter.log(e,t)}},{key:"generateSubTracker",value:function(t){return Object.assign(t,{parent:this,deepTracker:this.deepTracker,traceId:this.params.traceId,bucket:this.params.bucket,region:this.params.region,accelerate:this.params.accelerate,fileKey:this.params.requestPath,customId:this.params.customId,delay:this.delay,clsReporter:this.clsReporter}),new e(t)}}]),e}();e.exports=x},function(e){e.exports=JSON.parse('{"name":"cos-js-sdk-v5","version":"1.8.6","description":"JavaScript SDK for [腾讯云对象存储](https://cloud.tencent.com/product/cos)","main":"dist/cos-js-sdk-v5.js","types":"index.d.ts","scripts":{"prettier":"prettier --write src demo/demo.js demo/CIDemos/*.js test/test.js server/sts.js lib/request.js index.d.ts","server":"node server/sts.js","dev":"cross-env NODE_ENV=development webpack -w --mode=development","build":"cross-env NODE_ENV=production webpack --mode=production","cos-auth.min.js":"uglifyjs ./demo/common/cos-auth.js -o ./demo/common/cos-auth.min.js -c -m","test":"jest --runInBand --coverage"},"repository":{"type":"git","url":"git+https://github.com/tencentyun/cos-js-sdk-v5.git"},"keywords":[],"author":"carsonxu","license":"ISC","bugs":{"url":"https://github.com/tencentyun/cos-js-sdk-v5/issues"},"homepage":"https://github.com/tencentyun/cos-js-sdk-v5#readme","dependencies":{"fast-xml-parser":"^4.4.0"},"devDependencies":{"@babel/core":"7.17.9","@babel/plugin-transform-runtime":"7.18.10","@babel/preset-env":"7.16.11","babel-loader":"8.2.5","body-parser":"^1.18.3","cross-env":"^5.2.0","express":"^4.16.4","jest":"^29.3.1","jest-environment-jsdom":"^29.3.1","prettier":"^3.0.1","qcloud-cos-sts":"^3.0.2","request":"^2.87.0","terser-webpack-plugin":"4.2.3","uglifyjs":"^2.4.11","webpack":"4.46.0","webpack-cli":"4.10.0"}}')},function(e,t){var r=function(e){var t={},r=function(e){return!t[e]&&(t[e]=[]),t[e]};e.on=function(e,t){r(e).push(t)},e.off=function(e,t){for(var n=r(e),o=n.length-1;o>=0;o--)t===n[o]&&n.splice(o,1)},e.emit=function(e,t){for(var n=r(e).map((function(e){return e})),o=0;o<n.length;o++)n[o](t)}};e.exports.init=r,e.exports.EventProxy=function(){r(this)}},function(e,t,r){var n,o,i=r(1),a="cos_sdk_upload_cache",s=function(){try{var e=JSON.parse(localStorage.getItem(a))}catch(e){}e||(e=[]),n=e},c=function(){try{n.length?localStorage.setItem(a,JSON.stringify(n)):localStorage.removeItem(a)}catch(e){}},u=function(){if(!n){s.call(this);for(var e=!1,t=Math.round(Date.now()/1e3),r=n.length-1;r>=0;r--){var o=n[r][2];(!o||o+2592e3<t)&&(n.splice(r,1),e=!0)}e&&c()}},l=function(){o||(o=setTimeout((function(){c(),o=null}),400))},d={using:{},setUsing:function(e){d.using[e]=!0},removeUsing:function(e){delete d.using[e]},getFileId:function(e,t,r,n){return e.name&&e.size&&e.lastModifiedDate&&t?i.md5([e.name,e.size,e.lastModifiedDate,t,r,n].join("::")):null},getCopyFileId:function(e,t,r,n,o){var a=t["content-length"],s=t.etag||"",c=t["last-modified"];return e&&r?i.md5([e,a,s,c,r,n,o].join("::")):null},getUploadIdList:function(e){if(!e)return null;u.call(this);for(var t=[],r=0;r<n.length;r++)n[r][0]===e&&t.push(n[r][1]);return t.length?t:null},saveUploadId:function(e,t,r){if(u.call(this),e){for(var o=n.length-1;o>=0;o--){var i=n[o];i[0]===e&&i[1]===t&&n.splice(o,1)}n.unshift([e,t,Math.round(Date.now()/1e3)]),n.length>r&&n.splice(r),l()}},removeUploadId:function(e){u.call(this),delete d.using[e];for(var t=n.length-1;t>=0;t--)n[t][1]===e&&n.splice(t,1);l()}};e.exports=d},function(e,t,r){var n=r(10);e.exports=n},function(e,t,r){"use strict";var n=r(1),o=r(7),i=r(30),a=r(31),s=r(33),c=r(6),u={AppId:"",SecretId:"",SecretKey:"",SecurityToken:"",StartTime:0,ExpiredTime:0,ChunkRetryTimes:2,FileParallelLimit:3,ChunkParallelLimit:3,ChunkSize:1048576,SliceSize:1048576,CopyChunkParallelLimit:20,CopyChunkSize:10485760,CopySliceSize:10485760,MaxPartNumber:1e4,ProgressInterval:1e3,Domain:"",ServiceDomain:"",Protocol:"",CompatibilityMode:!1,ForcePathStyle:!1,UseRawKey:!1,Timeout:0,CorrectClockSkew:!0,SystemClockOffset:0,UploadCheckContentMd5:!1,UploadQueueSize:1e4,UploadAddMetaMd5:!1,UploadIdCacheLimit:50,UseAccelerate:!1,ForceSignHost:!0,AutoSwitchHost:!0,CopySourceParser:null,ObjectKeySimplifyCheck:!0,DeepTracker:!1,TrackerDelay:5e3,CustomId:"",BeaconReporter:null,ClsReporter:null},l=function(e){if(this.options=n.extend(n.clone(u),e||{}),this.options.FileParallelLimit=Math.max(1,this.options.FileParallelLimit),this.options.ChunkParallelLimit=Math.max(1,this.options.ChunkParallelLimit),this.options.ChunkRetryTimes=Math.max(0,this.options.ChunkRetryTimes),this.options.ChunkSize=Math.max(1048576,this.options.ChunkSize),this.options.CopyChunkParallelLimit=Math.max(1,this.options.CopyChunkParallelLimit),this.options.CopyChunkSize=Math.max(1048576,this.options.CopyChunkSize),this.options.CopySliceSize=Math.max(0,this.options.CopySliceSize),this.options.MaxPartNumber=Math.max(1024,Math.min(1e4,this.options.MaxPartNumber)),this.options.Timeout=Math.max(0,this.options.Timeout),this.options.EnableReporter=this.options.BeaconReporter||this.options.ClsReporter,this.options.AppId,this.options.SecretId&&this.options.SecretId.indexOf(" "),this.options.SecretKey&&this.options.SecretKey.indexOf(" "),n.isNode(),this.options.ForcePathStyle)throw new Error("ForcePathStyle is not supported");o.init(this),i.init(this)};a.init(l,i),s.init(l,i),l.util={md5:n.md5,xml2json:n.xml2json,json2xml:n.json2xml,encodeBase64:n.encodeBase64},l.getAuthorization=n.getAuth,l.version=c.version,e.exports=l},function(e,t){var r,n,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(r===setTimeout)return setTimeout(e,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(e){r=i}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var c,u=[],l=!1,d=-1;function p(){l&&c&&(l=!1,c.length?u=c.concat(u):d=-1,u.length&&h())}function h(){if(!l){var e=s(p);l=!0;for(var t=u.length;t;){for(c=u,u=[];++d<t;)c&&c[d].run();d=-1,t=u.length}c=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{return n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function g(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new f(e,t)),1!==u.length||l||s(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=g,o.addListener=g,o.once=g,o.off=g,o.removeListener=g,o.removeAllListeners=g,o.emit=g,o.prependListener=g,o.prependOnceListener=g,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,r){(function(e){var t,n=r(0);!function(){"use strict";var o="object"===("undefined"==typeof window?"undefined":n(window)),i=o?window:{};i.JS_MD5_NO_WINDOW&&(o=!1),!o&&"object"===("undefined"==typeof self?"undefined":n(self))&&(i=self);var a,s=!i.JS_MD5_NO_COMMON_JS&&"object"===n(e)&&e.exports,c=r(13),u=!i.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,l="0123456789abcdef".split(""),d=[128,32768,8388608,-2147483648],p=[0,8,16,24],h=["hex","array","digest","buffer","arrayBuffer","base64"],f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),g=[];if(u){var m=new ArrayBuffer(68);a=new Uint8Array(m),g=new Uint32Array(m)}!i.JS_MD5_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!u||!i.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"===n(e)&&e.buffer&&e.buffer.constructor===ArrayBuffer});var y=function(e){return function(t,r){return new k(!0).update(t,r)[e]()}};function k(e){if(e)g[0]=g[16]=g[1]=g[2]=g[3]=g[4]=g[5]=g[6]=g[7]=g[8]=g[9]=g[10]=g[11]=g[12]=g[13]=g[14]=g[15]=0,this.blocks=g,this.buffer8=a;else if(u){var t=new ArrayBuffer(68);this.buffer8=new Uint8Array(t),this.blocks=new Uint32Array(t)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}k.prototype.update=function(e,t){if(!this.finalized){for(var r,n,o=0,i=e.length,a=this.blocks,s=this.buffer8;o<i;){if(this.hashed&&(this.hashed=!1,a[0]=a[16],a[16]=a[1]=a[2]=a[3]=a[4]=a[5]=a[6]=a[7]=a[8]=a[9]=a[10]=a[11]=a[12]=a[13]=a[14]=a[15]=0),u)for(n=this.start;o<i&&n<64;++o)r=e.charCodeAt(o),t||r<128?s[n++]=r:r<2048?(s[n++]=192|r>>6,s[n++]=128|63&r):r<55296||r>=57344?(s[n++]=224|r>>12,s[n++]=128|r>>6&63,s[n++]=128|63&r):(r=65536+((1023&r)<<10|1023&e.charCodeAt(++o)),s[n++]=240|r>>18,s[n++]=128|r>>12&63,s[n++]=128|r>>6&63,s[n++]=128|63&r);else for(n=this.start;o<i&&n<64;++o)r=e.charCodeAt(o),t||r<128?a[n>>2]|=r<<p[3&n++]:r<2048?(a[n>>2]|=(192|r>>6)<<p[3&n++],a[n>>2]|=(128|63&r)<<p[3&n++]):r<55296||r>=57344?(a[n>>2]|=(224|r>>12)<<p[3&n++],a[n>>2]|=(128|r>>6&63)<<p[3&n++],a[n>>2]|=(128|63&r)<<p[3&n++]):(r=65536+((1023&r)<<10|1023&e.charCodeAt(++o)),a[n>>2]|=(240|r>>18)<<p[3&n++],a[n>>2]|=(128|r>>12&63)<<p[3&n++],a[n>>2]|=(128|r>>6&63)<<p[3&n++],a[n>>2]|=(128|63&r)<<p[3&n++]);this.lastByteIndex=n,this.bytes+=n-this.start,n>=64?(this.start=n-64,this.hash(),this.hashed=!0):this.start=n}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},k.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[t>>2]|=d[3&t],t>=56&&(this.hashed||this.hash(),e[0]=e[16],e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.bytes<<3,e[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},k.prototype.hash=function(){var e,t,r,n,o,i,a=this.blocks;this.first?t=((t=((e=((e=a[0]-680876937)<<7|e>>>25)-271733879|0)^(r=((r=(-271733879^(n=((n=(-1732584194^2004318071&e)+a[1]-117830708)<<12|n>>>20)+e|0)&(-271733879^e))+a[2]-1126478375)<<17|r>>>15)+n|0)&(n^e))+a[3]-1316259209)<<22|t>>>10)+r|0:(e=this.h0,t=this.h1,r=this.h2,t=((t+=((e=((e+=((n=this.h3)^t&(r^n))+a[0]-680876936)<<7|e>>>25)+t|0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+a[1]-389564586)<<12|n>>>20)+e|0)&(e^t))+a[2]+606105819)<<17|r>>>15)+n|0)&(n^e))+a[3]-1044525330)<<22|t>>>10)+r|0),t=((t+=((e=((e+=(n^t&(r^n))+a[4]-176418897)<<7|e>>>25)+t|0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+a[5]+1200080426)<<12|n>>>20)+e|0)&(e^t))+a[6]-1473231341)<<17|r>>>15)+n|0)&(n^e))+a[7]-45705983)<<22|t>>>10)+r|0,t=((t+=((e=((e+=(n^t&(r^n))+a[8]+1770035416)<<7|e>>>25)+t|0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+a[9]-1958414417)<<12|n>>>20)+e|0)&(e^t))+a[10]-42063)<<17|r>>>15)+n|0)&(n^e))+a[11]-1990404162)<<22|t>>>10)+r|0,t=((t+=((e=((e+=(n^t&(r^n))+a[12]+1804603682)<<7|e>>>25)+t|0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+a[13]-40341101)<<12|n>>>20)+e|0)&(e^t))+a[14]-1502002290)<<17|r>>>15)+n|0)&(n^e))+a[15]+1236535329)<<22|t>>>10)+r|0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+a[1]-165796510)<<5|e>>>27)+t|0)^t))+a[6]-1069501632)<<9|n>>>23)+e|0)^e&((r=((r+=(e^t&(n^e))+a[11]+643717713)<<14|r>>>18)+n|0)^n))+a[0]-373897302)<<20|t>>>12)+r|0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+a[5]-701558691)<<5|e>>>27)+t|0)^t))+a[10]+38016083)<<9|n>>>23)+e|0)^e&((r=((r+=(e^t&(n^e))+a[15]-660478335)<<14|r>>>18)+n|0)^n))+a[4]-405537848)<<20|t>>>12)+r|0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+a[9]+568446438)<<5|e>>>27)+t|0)^t))+a[14]-1019803690)<<9|n>>>23)+e|0)^e&((r=((r+=(e^t&(n^e))+a[3]-187363961)<<14|r>>>18)+n|0)^n))+a[8]+1163531501)<<20|t>>>12)+r|0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+a[13]-1444681467)<<5|e>>>27)+t|0)^t))+a[2]-51403784)<<9|n>>>23)+e|0)^e&((r=((r+=(e^t&(n^e))+a[7]+1735328473)<<14|r>>>18)+n|0)^n))+a[12]-1926607734)<<20|t>>>12)+r|0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+a[5]-378558)<<4|e>>>28)+t|0))+a[8]-2022574463)<<11|n>>>21)+e|0)^e)^(r=((r+=(i^t)+a[11]+1839030562)<<16|r>>>16)+n|0))+a[14]-35309556)<<23|t>>>9)+r|0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+a[1]-1530992060)<<4|e>>>28)+t|0))+a[4]+1272893353)<<11|n>>>21)+e|0)^e)^(r=((r+=(i^t)+a[7]-155497632)<<16|r>>>16)+n|0))+a[10]-1094730640)<<23|t>>>9)+r|0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+a[13]+681279174)<<4|e>>>28)+t|0))+a[0]-358537222)<<11|n>>>21)+e|0)^e)^(r=((r+=(i^t)+a[3]-722521979)<<16|r>>>16)+n|0))+a[6]+76029189)<<23|t>>>9)+r|0,t=((t+=((i=(n=((n+=((o=t^r)^(e=((e+=(o^n)+a[9]-640364487)<<4|e>>>28)+t|0))+a[12]-421815835)<<11|n>>>21)+e|0)^e)^(r=((r+=(i^t)+a[15]+530742520)<<16|r>>>16)+n|0))+a[2]-995338651)<<23|t>>>9)+r|0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+a[0]-198630844)<<6|e>>>26)+t|0)|~r))+a[7]+1126891415)<<10|n>>>22)+e|0)^((r=((r+=(e^(n|~t))+a[14]-1416354905)<<15|r>>>17)+n|0)|~e))+a[5]-57434055)<<21|t>>>11)+r|0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+a[12]+1700485571)<<6|e>>>26)+t|0)|~r))+a[3]-1894986606)<<10|n>>>22)+e|0)^((r=((r+=(e^(n|~t))+a[10]-1051523)<<15|r>>>17)+n|0)|~e))+a[1]-2054922799)<<21|t>>>11)+r|0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+a[8]+1873313359)<<6|e>>>26)+t|0)|~r))+a[15]-30611744)<<10|n>>>22)+e|0)^((r=((r+=(e^(n|~t))+a[6]-1560198380)<<15|r>>>17)+n|0)|~e))+a[13]+1309151649)<<21|t>>>11)+r|0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+a[4]-145523070)<<6|e>>>26)+t|0)|~r))+a[11]-1120210379)<<10|n>>>22)+e|0)^((r=((r+=(e^(n|~t))+a[2]+718787259)<<15|r>>>17)+n|0)|~e))+a[9]-343485551)<<21|t>>>11)+r|0,this.first?(this.h0=e+1732584193|0,this.h1=t-271733879|0,this.h2=r-1732584194|0,this.h3=n+271733878|0,this.first=!1):(this.h0=this.h0+e|0,this.h1=this.h1+t|0,this.h2=this.h2+r|0,this.h3=this.h3+n|0)},k.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3;return l[e>>4&15]+l[15&e]+l[e>>12&15]+l[e>>8&15]+l[e>>20&15]+l[e>>16&15]+l[e>>28&15]+l[e>>24&15]+l[t>>4&15]+l[15&t]+l[t>>12&15]+l[t>>8&15]+l[t>>20&15]+l[t>>16&15]+l[t>>28&15]+l[t>>24&15]+l[r>>4&15]+l[15&r]+l[r>>12&15]+l[r>>8&15]+l[r>>20&15]+l[r>>16&15]+l[r>>28&15]+l[r>>24&15]+l[n>>4&15]+l[15&n]+l[n>>12&15]+l[n>>8&15]+l[n>>20&15]+l[n>>16&15]+l[n>>28&15]+l[n>>24&15]},k.prototype.toString=k.prototype.hex,k.prototype.digest=function(e){if("hex"===e)return this.hex();this.finalize();var t=this.h0,r=this.h1,n=this.h2,o=this.h3;return[255&t,t>>8&255,t>>16&255,t>>24&255,255&r,r>>8&255,r>>16&255,r>>24&255,255&n,n>>8&255,n>>16&255,n>>24&255,255&o,o>>8&255,o>>16&255,o>>24&255]},k.prototype.array=k.prototype.digest,k.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(16),t=new Uint32Array(e);return t[0]=this.h0,t[1]=this.h1,t[2]=this.h2,t[3]=this.h3,e},k.prototype.buffer=k.prototype.arrayBuffer,k.prototype.base64=function(){for(var e,t,r,n="",o=this.array(),i=0;i<15;)e=o[i++],t=o[i++],r=o[i++],n+=f[e>>>2]+f[63&(e<<4|t>>>4)]+f[63&(t<<2|r>>>6)]+f[63&r];return e=o[i],n+=f[e>>>2]+f[e<<4&63]+"=="};var C=function(){var e=y("hex");e.getCtx=e.create=function(){return new k},e.update=function(t){return e.create().update(t)};for(var t=0;t<h.length;++t){var r=h[t];e[r]=y(r)}return e}();s?e.exports=C:(i.md5=C,c&&(void 0===(t=function(){return C}.call(C,r,C,e))||(e.exports=t)))}()}).call(this,r(3)(e))},function(e,t){(function(t){e.exports=t}).call(this,{})},function(e,t,r){(function(e){var t,n,o,i,a,s,c,u=r(0),l=l||function(e,t){var r={},n=r.lib={},o=function(){},i=n.Base={extend:function(e){o.prototype=this;var t=new o;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},a=n.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes;if(e=e.sigBytes,this.clamp(),n%4)for(var o=0;o<e;o++)t[n+o>>>2]|=(r[o>>>2]>>>24-o%4*8&255)<<24-(n+o)%4*8;else if(65535<r.length)for(o=0;o<e;o+=4)t[n+o>>>2]=r[o>>>2];else t.push.apply(t,r);return this.sigBytes+=e,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r=[],n=0;n<t;n+=4)r.push(4294967296*e.random()|0);return new a.init(r,t)}}),s=r.enc={},c=s.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],n=0;n<e;n++){var o=t[n>>>2]>>>24-n%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new a.init(r,t/2)}},u=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],n=0;n<e;n++)r.push(String.fromCharCode(t[n>>>2]>>>24-n%4*8&255));return r.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new a.init(r,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},d=n.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,n=r.words,o=r.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var c=0;c<t;c+=i)this._doProcessBlock(n,c);c=n.splice(0,t),r.sigBytes-=o}return new a.init(c,o)},clone:function(){var e=i.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});n.Hasher=d.extend({cfg:i.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new p.HMAC.init(e,r).finalize(t)}}});var p=r.algo={};return r}(Math);n=(a=(t=l).lib).WordArray,o=a.Hasher,i=[],a=t.algo.SHA1=o.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],o=r[1],a=r[2],s=r[3],c=r[4],u=0;80>u;u++){if(16>u)i[u]=0|e[t+u];else{var l=i[u-3]^i[u-8]^i[u-14]^i[u-16];i[u]=l<<1|l>>>31}l=(n<<5|n>>>27)+c+i[u],l=20>u?l+(1518500249+(o&a|~o&s)):40>u?l+(1859775393+(o^a^s)):60>u?l+((o&a|o&s|a&s)-1894007588):l+((o^a^s)-899497514),c=s,s=a,a=o<<30|o>>>2,o=n,n=l}r[0]=r[0]+n|0,r[1]=r[1]+o|0,r[2]=r[2]+a|0,r[3]=r[3]+s|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),t.SHA1=o._createHelper(a),t.HmacSHA1=o._createHmacHelper(a),function(){var e=l,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,r){e=this._hasher=new e.init,"string"==typeof r&&(r=t.parse(r));var n=e.blockSize,o=4*n;r.sigBytes>o&&(r=e.finalize(r)),r.clamp();for(var i=this._oKey=r.clone(),a=this._iKey=r.clone(),s=i.words,c=a.words,u=0;u<n;u++)s[u]^=1549556828,c[u]^=909522486;i.sigBytes=a.sigBytes=o,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher;return e=t.finalize(e),t.reset(),t.finalize(this._oKey.clone().concat(e))}})}(),c=(s=l).lib.WordArray,s.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var o=[],i=0;i<r;i+=3)for(var a=(t[i>>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;s<4&&i+.75*s<r;s++)o.push(n.charAt(a>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;o.length%4;)o.push(c);return o.join("")},parse:function(e){var t=e.length,r=this._map,n=r.charAt(64);if(n){var o=e.indexOf(n);-1!=o&&(t=o)}for(var i=[],a=0,s=0;s<t;s++)if(s%4){var u=r.indexOf(e.charAt(s-1))<<s%4*2,l=r.indexOf(e.charAt(s))>>>6-s%4*2;i[a>>>2]|=(u|l)<<24-a%4*8,a++}return c.create(i,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},"object"===u(e)?e.exports=l:window.CryptoJS=l}).call(this,r(3)(e))},function(e,t,r){"use strict";const n=r(4),o=r(16),i=r(23);e.exports={XMLParser:o,XMLValidator:n,XMLBuilder:i}},function(e,t,r){const{buildOptions:n}=r(17),o=r(18),{prettify:i}=r(22),a=r(4);e.exports=class{constructor(e){this.externalEntities={},this.options=n(e)}parse(e,t){if("string"==typeof e);else{if(!e.toString)throw new Error("XML data is accepted in String or Bytes[] form.");e=e.toString()}if(t){!0===t&&(t={});const r=a.validate(e,t);if(!0!==r)throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`)}const r=new o(this.options);r.addExternalEntities(this.externalEntities);const n=r.parseXml(e);return this.options.preserveOrder||void 0===n?n:i(n,this.options)}addEntity(e,t){if(-1!==t.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==e.indexOf("&")||-1!==e.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if("&"===t)throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=t}}},function(e,t){const r={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,r){return e}};t.buildOptions=function(e){return Object.assign({},r,e)},t.defaultOptions=r},function(e,t,r){"use strict";const n=r(2),o=r(19),i=r(20),a=r(21);function s(e){const t=Object.keys(e);for(let r=0;r<t.length;r++){const n=t[r];this.lastEntities[n]={regex:new RegExp("&"+n+";","g"),val:e[n]}}}function c(e,t,r,n,o,i,a){if(void 0!==e&&(this.options.trimValues&&!n&&(e=e.trim()),e.length>0)){a||(e=this.replaceEntitiesValue(e));const n=this.options.tagValueProcessor(t,e,r,o,i);if(null==n)return e;if(typeof n!=typeof e||n!==e)return n;if(this.options.trimValues)return v(e,this.options.parseTagValue,this.options.numberParseOptions);return e.trim()===e?v(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function u(e){if(this.options.removeNSPrefix){const t=e.split(":"),r="/"===e.charAt(0)?"/":"";if("xmlns"===t[0])return"";2===t.length&&(e=r+t[1])}return e}const l=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function d(e,t,r){if(!this.options.ignoreAttributes&&"string"==typeof e){const r=n.getAllMatches(e,l),o=r.length,i={};for(let e=0;e<o;e++){const n=this.resolveNameSpace(r[e][1]);let o=r[e][4],a=this.options.attributeNamePrefix+n;if(n.length)if(this.options.transformAttributeName&&(a=this.options.transformAttributeName(a)),"__proto__"===a&&(a="#__proto__"),void 0!==o){this.options.trimValues&&(o=o.trim()),o=this.replaceEntitiesValue(o);const e=this.options.attributeValueProcessor(n,o,t);i[a]=null==e?o:typeof e!=typeof o||e!==o?e:v(o,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(i[a]=!0)}if(!Object.keys(i).length)return;if(this.options.attributesGroupName){const e={};return e[this.options.attributesGroupName]=i,e}return i}}const p=function(e){e=e.replace(/\r\n?/g,"\n");const t=new o("!xml");let r=t,n="",a="";for(let s=0;s<e.length;s++){if("<"===e[s])if("/"===e[s+1]){const t=y(e,">",s,"Closing Tag is not closed.");let o=e.substring(s+2,t).trim();if(this.options.removeNSPrefix){const e=o.indexOf(":");-1!==e&&(o=o.substr(e+1))}this.options.transformTagName&&(o=this.options.transformTagName(o)),r&&(n=this.saveTextToParentTag(n,r,a));const i=a.substring(a.lastIndexOf(".")+1);if(o&&-1!==this.options.unpairedTags.indexOf(o))throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);let c=0;i&&-1!==this.options.unpairedTags.indexOf(i)?(c=a.lastIndexOf(".",a.lastIndexOf(".")-1),this.tagsNodeStack.pop()):c=a.lastIndexOf("."),a=a.substring(0,c),r=this.tagsNodeStack.pop(),n="",s=t}else if("?"===e[s+1]){let t=k(e,s,!1,"?>");if(!t)throw new Error("Pi Tag is not closed.");if(n=this.saveTextToParentTag(n,r,a),this.options.ignoreDeclaration&&"?xml"===t.tagName||this.options.ignorePiTags);else{const e=new o(t.tagName);e.add(this.options.textNodeName,""),t.tagName!==t.tagExp&&t.attrExpPresent&&(e[":@"]=this.buildAttributesMap(t.tagExp,a,t.tagName)),this.addChild(r,e,a)}s=t.closeIndex+1}else if("!--"===e.substr(s+1,3)){const t=y(e,"--\x3e",s+4,"Comment is not closed.");if(this.options.commentPropName){const o=e.substring(s+4,t-2);n=this.saveTextToParentTag(n,r,a),r.add(this.options.commentPropName,[{[this.options.textNodeName]:o}])}s=t}else if("!D"===e.substr(s+1,2)){const t=i(e,s);this.docTypeEntities=t.entities,s=t.i}else if("!["===e.substr(s+1,2)){const t=y(e,"]]>",s,"CDATA is not closed.")-2,o=e.substring(s+9,t);n=this.saveTextToParentTag(n,r,a);let i=this.parseTextData(o,r.tagname,a,!0,!1,!0,!0);null==i&&(i=""),this.options.cdataPropName?r.add(this.options.cdataPropName,[{[this.options.textNodeName]:o}]):r.add(this.options.textNodeName,i),s=t+2}else{let i=k(e,s,this.options.removeNSPrefix),c=i.tagName;const u=i.rawTagName;let l=i.tagExp,d=i.attrExpPresent,p=i.closeIndex;this.options.transformTagName&&(c=this.options.transformTagName(c)),r&&n&&"!xml"!==r.tagname&&(n=this.saveTextToParentTag(n,r,a,!1));const h=r;if(h&&-1!==this.options.unpairedTags.indexOf(h.tagname)&&(r=this.tagsNodeStack.pop(),a=a.substring(0,a.lastIndexOf("."))),c!==t.tagname&&(a+=a?"."+c:c),this.isItStopNode(this.options.stopNodes,a,c)){let t="";if(l.length>0&&l.lastIndexOf("/")===l.length-1)"/"===c[c.length-1]?(c=c.substr(0,c.length-1),a=a.substr(0,a.length-1),l=c):l=l.substr(0,l.length-1),s=i.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(c))s=i.closeIndex;else{const r=this.readStopNodeData(e,u,p+1);if(!r)throw new Error(`Unexpected end of ${u}`);s=r.i,t=r.tagContent}const n=new o(c);c!==l&&d&&(n[":@"]=this.buildAttributesMap(l,a,c)),t&&(t=this.parseTextData(t,c,a,!0,d,!0,!0)),a=a.substr(0,a.lastIndexOf(".")),n.add(this.options.textNodeName,t),this.addChild(r,n,a)}else{if(l.length>0&&l.lastIndexOf("/")===l.length-1){"/"===c[c.length-1]?(c=c.substr(0,c.length-1),a=a.substr(0,a.length-1),l=c):l=l.substr(0,l.length-1),this.options.transformTagName&&(c=this.options.transformTagName(c));const e=new o(c);c!==l&&d&&(e[":@"]=this.buildAttributesMap(l,a,c)),this.addChild(r,e,a),a=a.substr(0,a.lastIndexOf("."))}else{const e=new o(c);this.tagsNodeStack.push(r),c!==l&&d&&(e[":@"]=this.buildAttributesMap(l,a,c)),this.addChild(r,e,a),r=e}n="",s=p}}else n+=e[s]}return t.child};function h(e,t,r){const n=this.options.updateTag(t.tagname,r,t[":@"]);!1===n||("string"==typeof n?(t.tagname=n,e.addChild(t)):e.addChild(t))}const f=function(e){if(this.options.processEntities){for(let t in this.docTypeEntities){const r=this.docTypeEntities[t];e=e.replace(r.regx,r.val)}for(let t in this.lastEntities){const r=this.lastEntities[t];e=e.replace(r.regex,r.val)}if(this.options.htmlEntities)for(let t in this.htmlEntities){const r=this.htmlEntities[t];e=e.replace(r.regex,r.val)}e=e.replace(this.ampEntity.regex,this.ampEntity.val)}return e};function g(e,t,r,n){return e&&(void 0===n&&(n=0===Object.keys(t.child).length),void 0!==(e=this.parseTextData(e,t.tagname,r,!1,!!t[":@"]&&0!==Object.keys(t[":@"]).length,n))&&""!==e&&t.add(this.options.textNodeName,e),e=""),e}function m(e,t,r){const n="*."+r;for(const r in e){const o=e[r];if(n===o||t===o)return!0}return!1}function y(e,t,r,n){const o=e.indexOf(t,r);if(-1===o)throw new Error(n);return o+t.length-1}function k(e,t,r,n=">"){const o=function(e,t,r=">"){let n,o="";for(let i=t;i<e.length;i++){let t=e[i];if(n)t===n&&(n="");else if('"'===t||"'"===t)n=t;else if(t===r[0]){if(!r[1])return{data:o,index:i};if(e[i+1]===r[1])return{data:o,index:i}}else"\t"===t&&(t=" ");o+=t}}(e,t+1,n);if(!o)return;let i=o.data;const a=o.index,s=i.search(/\s/);let c=i,u=!0;-1!==s&&(c=i.substring(0,s),i=i.substring(s+1).trimStart());const l=c;if(r){const e=c.indexOf(":");-1!==e&&(c=c.substr(e+1),u=c!==o.data.substr(e+1))}return{tagName:c,tagExp:i,closeIndex:a,attrExpPresent:u,rawTagName:l}}function C(e,t,r){const n=r;let o=1;for(;r<e.length;r++)if("<"===e[r])if("/"===e[r+1]){const i=y(e,">",r,`${t} is not closed`);if(e.substring(r+2,i).trim()===t&&(o--,0===o))return{tagContent:e.substring(n,r),i:i};r=i}else if("?"===e[r+1]){r=y(e,"?>",r+1,"StopNode is not closed.")}else if("!--"===e.substr(r+1,3)){r=y(e,"--\x3e",r+3,"StopNode is not closed.")}else if("!["===e.substr(r+1,2)){r=y(e,"]]>",r,"StopNode is not closed.")-2}else{const n=k(e,r,">");if(n){(n&&n.tagName)===t&&"/"!==n.tagExp[n.tagExp.length-1]&&o++,r=n.closeIndex}}}function v(e,t,r){if(t&&"string"==typeof e){const t=e.trim();return"true"===t||"false"!==t&&a(e,r)}return n.isExist(e)?e:""}e.exports=class{constructor(e){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(e,t)=>String.fromCharCode(Number.parseInt(t,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(e,t)=>String.fromCharCode(Number.parseInt(t,16))}},this.addExternalEntities=s,this.parseXml=p,this.parseTextData=c,this.resolveNameSpace=u,this.buildAttributesMap=d,this.isItStopNode=m,this.replaceEntitiesValue=f,this.readStopNodeData=C,this.saveTextToParentTag=g,this.addChild=h}}},function(e,t,r){"use strict";e.exports=class{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,t){"__proto__"===e&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e){"__proto__"===e.tagname&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child})}}},function(e,t,r){const n=r(2);function o(e,t){let r="";for(;t<e.length&&"'"!==e[t]&&'"'!==e[t];t++)r+=e[t];if(r=r.trim(),-1!==r.indexOf(" "))throw new Error("External entites are not supported");const n=e[t++];let o="";for(;t<e.length&&e[t]!==n;t++)o+=e[t];return[r,o,t]}function i(e,t){return"!"===e[t+1]&&"-"===e[t+2]&&"-"===e[t+3]}function a(e,t){return"!"===e[t+1]&&"E"===e[t+2]&&"N"===e[t+3]&&"T"===e[t+4]&&"I"===e[t+5]&&"T"===e[t+6]&&"Y"===e[t+7]}function s(e,t){return"!"===e[t+1]&&"E"===e[t+2]&&"L"===e[t+3]&&"E"===e[t+4]&&"M"===e[t+5]&&"E"===e[t+6]&&"N"===e[t+7]&&"T"===e[t+8]}function c(e,t){return"!"===e[t+1]&&"A"===e[t+2]&&"T"===e[t+3]&&"T"===e[t+4]&&"L"===e[t+5]&&"I"===e[t+6]&&"S"===e[t+7]&&"T"===e[t+8]}function u(e,t){return"!"===e[t+1]&&"N"===e[t+2]&&"O"===e[t+3]&&"T"===e[t+4]&&"A"===e[t+5]&&"T"===e[t+6]&&"I"===e[t+7]&&"O"===e[t+8]&&"N"===e[t+9]}function l(e){if(n.isName(e))return e;throw new Error(`Invalid entity name ${e}`)}e.exports=function(e,t){const r={};if("O"!==e[t+3]||"C"!==e[t+4]||"T"!==e[t+5]||"Y"!==e[t+6]||"P"!==e[t+7]||"E"!==e[t+8])throw new Error("Invalid Tag instead of DOCTYPE");{t+=9;let n=1,d=!1,p=!1,h="";for(;t<e.length;t++)if("<"!==e[t]||p)if(">"===e[t]){if(p?"-"===e[t-1]&&"-"===e[t-2]&&(p=!1,n--):n--,0===n)break}else"["===e[t]?d=!0:h+=e[t];else{if(d&&a(e,t))t+=7,[entityName,val,t]=o(e,t+1),-1===val.indexOf("&")&&(r[l(entityName)]={regx:RegExp(`&${entityName};`,"g"),val:val});else if(d&&s(e,t))t+=8;else if(d&&c(e,t))t+=8;else if(d&&u(e,t))t+=9;else{if(!i)throw new Error("Invalid DOCTYPE");p=!0}n++,h=""}if(0!==n)throw new Error("Unclosed DOCTYPE")}return{entities:r,i:t}}},function(e,t){const r=/^[-+]?0x[a-fA-F0-9]+$/,n=/^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt),!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const o={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};e.exports=function(e,t={}){if(t=Object.assign({},o,t),!e||"string"!=typeof e)return e;let i=e.trim();if(void 0!==t.skipLike&&t.skipLike.test(i))return e;if(t.hex&&r.test(i))return Number.parseInt(i,16);{const r=n.exec(i);if(r){const n=r[1],o=r[2];let a=function(e){if(e&&-1!==e.indexOf("."))return"."===(e=e.replace(/0+$/,""))?e="0":"."===e[0]?e="0"+e:"."===e[e.length-1]&&(e=e.substr(0,e.length-1)),e;return e}(r[3]);const s=r[4]||r[6];if(!t.leadingZeros&&o.length>0&&n&&"."!==i[2])return e;if(!t.leadingZeros&&o.length>0&&!n&&"."!==i[1])return e;{const r=Number(i),c=""+r;return-1!==c.search(/[eE]/)||s?t.eNotation?r:e:-1!==i.indexOf(".")?"0"===c&&""===a||c===a||n&&c==="-"+a?r:e:o?a===c||n+a===c?r:e:i===c||i===n+c?r:e}}return e}}},function(e,t,r){"use strict";function n(e,t,r){let s;const c={};for(let u=0;u<e.length;u++){const l=e[u],d=o(l);let p="";if(p=void 0===r?d:r+"."+d,d===t.textNodeName)void 0===s?s=l[d]:s+=""+l[d];else{if(void 0===d)continue;if(l[d]){let e=n(l[d],t,p);const r=a(e,t);l[":@"]?i(e,l[":@"],p,t):1!==Object.keys(e).length||void 0===e[t.textNodeName]||t.alwaysCreateTextNode?0===Object.keys(e).length&&(t.alwaysCreateTextNode?e[t.textNodeName]="":e=""):e=e[t.textNodeName],void 0!==c[d]&&c.hasOwnProperty(d)?(Array.isArray(c[d])||(c[d]=[c[d]]),c[d].push(e)):t.isArray(d,p,r)?c[d]=[e]:c[d]=e}}}return"string"==typeof s?s.length>0&&(c[t.textNodeName]=s):void 0!==s&&(c[t.textNodeName]=s),c}function o(e){const t=Object.keys(e);for(let e=0;e<t.length;e++){const r=t[e];if(":@"!==r)return r}}function i(e,t,r,n){if(t){const o=Object.keys(t),i=o.length;for(let a=0;a<i;a++){const i=o[a];n.isArray(i,r+"."+i,!0,!0)?e[i]=[t[i]]:e[i]=t[i]}}}function a(e,t){const{textNodeName:r}=t,n=Object.keys(e).length;return 0===n||!(1!==n||!e[r]&&"boolean"!=typeof e[r]&&0!==e[r])}t.prettify=function(e,t){return n(e,t)}},function(e,t,r){"use strict";const n=r(24),o={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function i(e){this.options=Object.assign({},o,e),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=c),this.processTextOrObjNode=a,this.options.format?(this.indentate=s,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function a(e,t,r){const n=this.j2x(e,r+1);return void 0!==e[this.options.textNodeName]&&1===Object.keys(e).length?this.buildTextValNode(e[this.options.textNodeName],t,n.attrStr,r):this.buildObjectNode(n.val,t,n.attrStr,r)}function s(e){return this.options.indentBy.repeat(e)}function c(e){return!(!e.startsWith(this.options.attributeNamePrefix)||e===this.options.textNodeName)&&e.substr(this.attrPrefixLen)}i.prototype.build=function(e){return this.options.preserveOrder?n(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0).val)},i.prototype.j2x=function(e,t){let r="",n="";for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o))if(void 0===e[o])this.isAttribute(o)&&(n+="");else if(null===e[o])this.isAttribute(o)?n+="":"?"===o[0]?n+=this.indentate(t)+"<"+o+"?"+this.tagEndChar:n+=this.indentate(t)+"<"+o+"/"+this.tagEndChar;else if(e[o]instanceof Date)n+=this.buildTextValNode(e[o],o,"",t);else if("object"!=typeof e[o]){const i=this.isAttribute(o);if(i)r+=this.buildAttrPairStr(i,""+e[o]);else if(o===this.options.textNodeName){let t=this.options.tagValueProcessor(o,""+e[o]);n+=this.replaceEntitiesValue(t)}else n+=this.buildTextValNode(e[o],o,"",t)}else if(Array.isArray(e[o])){const r=e[o].length;let i="";for(let a=0;a<r;a++){const r=e[o][a];void 0===r||(null===r?"?"===o[0]?n+=this.indentate(t)+"<"+o+"?"+this.tagEndChar:n+=this.indentate(t)+"<"+o+"/"+this.tagEndChar:"object"==typeof r?this.options.oneListGroup?i+=this.j2x(r,t+1).val:i+=this.processTextOrObjNode(r,o,t):i+=this.buildTextValNode(r,o,"",t))}this.options.oneListGroup&&(i=this.buildObjectNode(i,o,"",t)),n+=i}else if(this.options.attributesGroupName&&o===this.options.attributesGroupName){const t=Object.keys(e[o]),n=t.length;for(let i=0;i<n;i++)r+=this.buildAttrPairStr(t[i],""+e[o][t[i]])}else n+=this.processTextOrObjNode(e[o],o,t);return{attrStr:r,val:n}},i.prototype.buildAttrPairStr=function(e,t){return t=this.options.attributeValueProcessor(e,""+t),t=this.replaceEntitiesValue(t),this.options.suppressBooleanAttributes&&"true"===t?" "+e:" "+e+'="'+t+'"'},i.prototype.buildObjectNode=function(e,t,r,n){if(""===e)return"?"===t[0]?this.indentate(n)+"<"+t+r+"?"+this.tagEndChar:this.indentate(n)+"<"+t+r+this.closeTag(t)+this.tagEndChar;{let o="</"+t+this.tagEndChar,i="";return"?"===t[0]&&(i="?",o=""),!r&&""!==r||-1!==e.indexOf("<")?!1!==this.options.commentPropName&&t===this.options.commentPropName&&0===i.length?this.indentate(n)+`\x3c!--${e}--\x3e`+this.newLine:this.indentate(n)+"<"+t+r+i+this.tagEndChar+e+this.indentate(n)+o:this.indentate(n)+"<"+t+r+i+">"+e+o}},i.prototype.closeTag=function(e){let t="";return-1!==this.options.unpairedTags.indexOf(e)?this.options.suppressUnpairedNode||(t="/"):t=this.options.suppressEmptyNode?"/":`></${e}`,t},i.prototype.buildTextValNode=function(e,t,r,n){if(!1!==this.options.cdataPropName&&t===this.options.cdataPropName)return this.indentate(n)+`<![CDATA[${e}]]>`+this.newLine;if(!1!==this.options.commentPropName&&t===this.options.commentPropName)return this.indentate(n)+`\x3c!--${e}--\x3e`+this.newLine;if("?"===t[0])return this.indentate(n)+"<"+t+r+"?"+this.tagEndChar;{let o=this.options.tagValueProcessor(t,e);return o=this.replaceEntitiesValue(o),""===o?this.indentate(n)+"<"+t+r+this.closeTag(t)+this.tagEndChar:this.indentate(n)+"<"+t+r+">"+o+"</"+t+this.tagEndChar}},i.prototype.replaceEntitiesValue=function(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){const r=this.options.entities[t];e=e.replace(r.regex,r.val)}return e},e.exports=i},function(e,t){function r(e,t,s,c){let u="",l=!1;for(let d=0;d<e.length;d++){const p=e[d],h=n(p);if(void 0===h)continue;let f="";if(f=0===s.length?h:`${s}.${h}`,h===t.textNodeName){let e=p[h];i(f,t)||(e=t.tagValueProcessor(h,e),e=a(e,t)),l&&(u+=c),u+=e,l=!1;continue}if(h===t.cdataPropName){l&&(u+=c),u+=`<![CDATA[${p[h][0][t.textNodeName]}]]>`,l=!1;continue}if(h===t.commentPropName){u+=c+`\x3c!--${p[h][0][t.textNodeName]}--\x3e`,l=!0;continue}if("?"===h[0]){const e=o(p[":@"],t),r="?xml"===h?"":c;let n=p[h][0][t.textNodeName];n=0!==n.length?" "+n:"",u+=r+`<${h}${n}${e}?>`,l=!0;continue}let g=c;""!==g&&(g+=t.indentBy);const m=c+`<${h}${o(p[":@"],t)}`,y=r(p[h],t,f,g);-1!==t.unpairedTags.indexOf(h)?t.suppressUnpairedNode?u+=m+">":u+=m+"/>":y&&0!==y.length||!t.suppressEmptyNode?y&&y.endsWith(">")?u+=m+`>${y}${c}</${h}>`:(u+=m+">",y&&""!==c&&(y.includes("/>")||y.includes("</"))?u+=c+t.indentBy+y+c:u+=y,u+=`</${h}>`):u+=m+"/>",l=!0}return u}function n(e){const t=Object.keys(e);for(let r=0;r<t.length;r++){const n=t[r];if(e.hasOwnProperty(n)&&":@"!==n)return n}}function o(e,t){let r="";if(e&&!t.ignoreAttributes)for(let n in e){if(!e.hasOwnProperty(n))continue;let o=t.attributeValueProcessor(n,e[n]);o=a(o,t),!0===o&&t.suppressBooleanAttributes?r+=` ${n.substr(t.attributeNamePrefix.length)}`:r+=` ${n.substr(t.attributeNamePrefix.length)}="${o}"`}return r}function i(e,t){let r=(e=e.substr(0,e.length-t.textNodeName.length-1)).substr(e.lastIndexOf(".")+1);for(let n in t.stopNodes)if(t.stopNodes[n]===e||t.stopNodes[n]==="*."+r)return!0;return!1}function a(e,t){if(e&&e.length>0&&t.processEntities)for(let r=0;r<t.entities.length;r++){const n=t.entities[r];e=e.replace(n.regex,n.val)}return e}e.exports=function(e,t){let n="";return t.format&&t.indentBy.length>0&&(n="\n"),r(e,t,"",n)}},function(e,t){var r=function(e){var t=(e=e||{}).Base64,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=function(e){for(var t={},r=0,n=e.length;r<n;r++)t[e.charAt(r)]=r;return t}(r),o=String.fromCharCode,i=function(e){if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?o(192|t>>>6)+o(128|63&t):o(224|t>>>12&15)+o(128|t>>>6&63)+o(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return o(240|t>>>18&7)+o(128|t>>>12&63)+o(128|t>>>6&63)+o(128|63&t)},a=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,s=function(e){return e.replace(a,i)},c=function(e){var t=[0,2,1][e.length%3],n=e.charCodeAt(0)<<16|(e.length>1?e.charCodeAt(1):0)<<8|(e.length>2?e.charCodeAt(2):0);return[r.charAt(n>>>18),r.charAt(n>>>12&63),t>=2?"=":r.charAt(n>>>6&63),t>=1?"=":r.charAt(63&n)].join("")},u=e.btoa?function(t){return e.btoa(t)}:function(e){return e.replace(/[\s\S]{1,3}/g,c)},l=function(e){return u(s(e))},d=function(e,t){return t?l(String(e)).replace(/[+\/]/g,(function(e){return"+"==e?"-":"_"})).replace(/=/g,""):l(String(e))},p=new RegExp(["[À-ß][€-¿]","[à-ï][€-¿]{2}","[ð-÷][€-¿]{3}"].join("|"),"g"),h=function(e){switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return o(55296+(t>>>10))+o(56320+(1023&t));case 3:return o((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return o((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},f=function(e){return e.replace(p,h)},g=function(e){var t=e.length,r=t%4,i=(t>0?n[e.charAt(0)]<<18:0)|(t>1?n[e.charAt(1)]<<12:0)|(t>2?n[e.charAt(2)]<<6:0)|(t>3?n[e.charAt(3)]:0),a=[o(i>>>16),o(i>>>8&255),o(255&i)];return a.length-=[0,0,2,1][r],a.join("")},m=e.atob?function(t){return e.atob(t)}:function(e){return e.replace(/[\s\S]{1,4}/g,g)},y=function(e){return f(m(e))},k=function(e){return y(String(e).replace(/[-_]/g,(function(e){return"-"==e?"+":"/"})).replace(/[^A-Za-z0-9\+\/]/g,""))};return{VERSION:"2.1.9",atob:m,btoa:u,fromBase64:k,toBase64:d,utob:s,encode:d,encodeURI:function(e){return d(e,!0)},btou:f,decode:k,noConflict:function(){var r=e.Base64;return e.Base64=t,r}}}();e.exports=r},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(28);function o(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,n(o.key),o)}}e.exports=function(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(0).default,o=r(29);e.exports=function(e){var t=o(e,"string");return"symbol"===n(t)?t:String(t)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(0).default;e.exports=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(8),o=r(1),i={};e.exports.transferToTaskMethod=function(e,t){i[t]=e[t],e[t]=function(e,r){e.SkipTask?i[t].call(this,e,r):this._addTask(t,e,r)}},e.exports.init=function(e){var t,r,a=[],s={},c=0,u=0,l=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},d=(r=function(){t=0,e.emit("task-list-update",{list:o.map(a,l)}),e.emit("list-update",{list:o.map(a,l)})},function(){t||(t=setTimeout(r))}),p=function(){if(!(a.length<=e.options.UploadQueueSize)){for(var t=0;t<u&&t<a.length&&a.length>e.options.UploadQueueSize;){var r="waiting"===a[t].state||"checking"===a[t].state||"uploading"===a[t].state;a[t]&&r?t++:(s[a[t].id]&&delete s[a[t].id],a.splice(t,1),u--)}d()}},h=function t(){if(!(c>=e.options.FileParallelLimit)){for(;a[u]&&"waiting"!==a[u].state;)u++;if(!(u>=a.length)){var r=a[u];u++,c++,r.state="checking",r.params.onTaskStart&&r.params.onTaskStart(l(r)),!r.params.UploadData&&(r.params.UploadData={});var n=o.formatParams(r.api,r.params);i[r.api].call(e,n,(function(n,o){e._isRunningTask(r.id)&&("checking"!==r.state&&"uploading"!==r.state||(r.state=n?"error":"success",n&&(r.error=n),c--,d(),t(),r.callback&&r.callback(n,o),"success"===r.state&&(r.params&&(delete r.params.UploadData,delete r.params.Body,delete r.params),delete r.callback)),p())})),d(),setTimeout(t)}}},f=function(t,r){var o=s[t];if(o){var i=o&&"waiting"===o.state,a=o&&("checking"===o.state||"uploading"===o.state);if("canceled"===r&&"canceled"!==o.state||"paused"===r&&i||"paused"===r&&a){o.state=r,e.emit("inner-kill-task",{TaskId:t,toState:r});try{var u=o&&o.params&&o.params.UploadData.UploadId}catch(e){}"canceled"===r&&u&&n.removeUsing(u),d(),a&&(c--,h()),"canceled"===r&&(o.params&&(delete o.params.UploadData,delete o.params.Body,delete o.params),delete o.callback)}p()}};e._addTasks=function(t){o.each(t,(function(t){e._addTask(t.api,t.params,t.callback,!0)})),d()};e._addTask=function(t,r,n,i){r=o.formatParams(t,r);var c=o.uuid();r.TaskId=c,r.onTaskReady&&r.onTaskReady(c),r.TaskReady&&(r.TaskReady(c),!1);var u={params:r,callback:n,api:t,index:a.length,id:c,Bucket:r.Bucket,Region:r.Region,Key:r.Key,FilePath:r.FilePath||"",state:"waiting",loaded:0,size:0,speed:0,percent:0,hashPercent:0,error:null,_custom:r._custom},l=r.onHashProgress;r.onHashProgress=function(t){e._isRunningTask(u.id)&&(u.hashPercent=t.percent,l&&l(t),d())};var f=r.onProgress;return r.onProgress=function(t){e._isRunningTask(u.id)&&("checking"===u.state&&(u.state="uploading"),u.loaded=t.loaded,u.speed=t.speed,u.percent=t.percent,f&&f(t),d())},o.getFileSize(t,r,(function(e,t){if(e)return n(o.error(e));s[c]=u,a.push(u),u.size=t,!i&&d(),h(),p()})),c},e._isRunningTask=function(e){var t=s[e];return!(!t||"checking"!==t.state&&"uploading"!==t.state)},e.getTaskList=function(){return o.map(a,l)},e.cancelTask=function(e){f(e,"canceled")},e.pauseTask=function(e){f(e,"paused")},e.restartTask=function(e){var t=s[e];!t||"paused"!==t.state&&"error"!==t.state||(t.state="waiting",d(),u=Math.min(u,t.index),h())},e.isUploadRunning=function(){return c||u<a.length}}},function(e,t,r){var n=r(0),o=r(32),i=r(1);function a(e,t,r){var n=i.clone(t.InventoryConfiguration);if(n.OptionalFields){var o=n.OptionalFields||[];n.OptionalFields={Field:o}}if(n.Destination&&n.Destination.COSBucketDestination&&n.Destination.COSBucketDestination.Encryption){var a=n.Destination.COSBucketDestination.Encryption;Object.keys(a).indexOf("SSECOS")>-1&&(a["SSE-COS"]=a.SSECOS,delete a.SSECOS)}var s=i.json2xml({InventoryConfiguration:n}),c=t.Headers;c["Content-Type"]="application/xml",c["Content-MD5"]=i.b64(i.md5(s));var u="PUT"===e?"name/cos:PutBucketInventory":"name/cos:PostBucketInventory";f.call(this,{Action:u,method:e,Bucket:t.Bucket,Region:t.Region,body:s,action:"inventory",qs:{id:t.Id},headers:c,tracker:t.tracker},(function(e,t){return e&&204===e.statusCode?r(null,{statusCode:e.statusCode}):e?r(e):void r(null,{statusCode:t.statusCode,headers:t.headers})}))}function s(e){var t={GrantFullControl:[],GrantWrite:[],GrantRead:[],GrantReadAcp:[],GrantWriteAcp:[],ACL:""},r={FULL_CONTROL:"GrantFullControl",WRITE:"GrantWrite",READ:"GrantRead",READ_ACP:"GrantReadAcp",WRITE_ACP:"GrantWriteAcp"},n=(e&&e.AccessControlList||{}).Grant;n&&(n=i.isArray(n)?n:[n]);var o={READ:0,WRITE:0,FULL_CONTROL:0};return n&&n.length&&i.each(n,(function(n){var i=n.Grantee.URI&&n.Grantee.URI.endsWith("/groups/global/AllUsers");"qcs::cam::anyone:anyone"===n.Grantee.ID||i?o[n.Permission]=1:n.Grantee.ID!==e.Owner.ID&&t[r[n.Permission]].push('id="'+n.Grantee.ID+'"')})),o.FULL_CONTROL||o.WRITE&&o.READ?t.ACL="public-read-write":o.READ?t.ACL="public-read":t.ACL="private",i.each(r,(function(e){t[e]=c(t[e].join(","))})),t}function c(e){var t,r,n=e.split(","),o={};for(t=0;t<n.length;)o[r=n[t].trim()]?n.splice(t,1):(o[r]=!0,n[t]=r,t++);return n.join(",")}function u(e){var t=e.region||"",r=e.bucket||"",o=r.substr(0,r.lastIndexOf("-")),a=r.substr(r.lastIndexOf("-")+1),s=e.domain,c=e.object;"function"==typeof s&&(s=s({Bucket:r,Region:t})),["http","https"].includes(e.protocol)&&(e.protocol=e.protocol+":");var u=e.protocol||(i.isBrowser&&"object"===("undefined"==typeof location?"undefined":n(location))&&"http:"===location.protocol?"http:":"https:");s||(s=["cn-south","cn-south-2","cn-north","cn-east","cn-southwest","sg"].indexOf(t)>-1?"{Region}.myqcloud.com":"cos.{Region}.myqcloud.com",e.ForcePathStyle||(s="{Bucket}."+s)),s=(s=s.replace(/\{\{AppId\}\}/gi,a).replace(/\{\{Bucket\}\}/gi,o).replace(/\{\{Region\}\}/gi,t).replace(/\{\{.*?\}\}/gi,"")).replace(/\{AppId\}/gi,a).replace(/\{BucketName\}/gi,o).replace(/\{Bucket\}/gi,r).replace(/\{Region\}/gi,t).replace(/\{.*?\}/gi,""),/^[a-zA-Z]+:\/\//.test(s)||(s=u+"//"+s),"/"===s.slice(-1)&&(s=s.slice(0,-1));var l=s;return e.ForcePathStyle&&(l+="/"+r),l+="/",c&&(l+=i.camSafeUrlEncode(c).replace(/%2F/g,"/")),e.isLocation&&(l=l.replace(/^https?:\/\//,"")),l}var l=function(e){if(!e.Bucket||!e.Region)return"";var t=void 0===e.UseAccelerate?this.options.UseAccelerate:e.UseAccelerate;return(e.Url||u({ForcePathStyle:this.options.ForcePathStyle,protocol:this.options.Protocol,domain:this.options.Domain,bucket:e.Bucket,region:t?"accelerate":e.Region})).replace(/^https?:\/\/([^/]+)(\/.*)?$/,"$1")};function d(e,t){var r=i.clone(e.Headers),n="";i.each(r,(function(e,t){(""===e||["content-type","cache-control","expires"].indexOf(t.toLowerCase())>-1)&&delete r[t],"host"===t.toLowerCase()&&(n=e)}));var o=!1!==e.ForceSignHost;!n&&e.SignHost&&o&&(r.Host=e.SignHost);var a=!1,s=function(e,r){a||(a=!0,r&&r.XCosSecurityToken&&!r.SecurityToken&&((r=i.clone(r)).SecurityToken=r.XCosSecurityToken,delete r.XCosSecurityToken),t&&t(e,r))},c=this,u=e.Bucket||"",l=e.Region||"",d=e.Key||"";c.options.ForcePathStyle&&u&&(d=u+"/"+d);var p="/"+d,h={},f=e.Scope;if(!f){var g=e.Action||"",m=e.ResourceKey||e.Key||"";f=e.Scope||[{action:g,bucket:u,region:l,prefix:m}]}var y=i.md5(JSON.stringify(f));c._StsCache=c._StsCache||[],function(){var e,t;for(e=c._StsCache.length-1;e>=0;e--){t=c._StsCache[e];var r=Math.round(i.getSkewTime(c.options.SystemClockOffset)/1e3)+30;if(t.StartTime&&r<t.StartTime||r>=t.ExpiredTime)c._StsCache.splice(e,1);else if(!t.ScopeLimit||t.ScopeLimit&&t.ScopeKey===y){h=t;break}}}();var k=function(){var t="";h.StartTime&&e.Expires?t=h.StartTime+";"+(h.StartTime+1*e.Expires):h.StartTime&&h.ExpiredTime&&(t=h.StartTime+";"+h.ExpiredTime);var n={Authorization:i.getAuth({SecretId:h.TmpSecretId,SecretKey:h.TmpSecretKey,Method:e.Method,Pathname:p,Query:e.Query,Headers:r,Expires:e.Expires,UseRawKey:c.options.UseRawKey,SystemClockOffset:c.options.SystemClockOffset,KeyTime:t,ForceSignHost:o}),SecurityToken:h.SecurityToken||h.XCosSecurityToken||"",Token:h.Token||"",ClientIP:h.ClientIP||"",ClientUA:h.ClientUA||"",SignFrom:"client"};s(null,n)},C=function(e){if(e.Authorization){var t=!1,r=e.Authorization;if(r)if(r.indexOf(" ")>-1)t=!1;else if(r.indexOf("q-sign-algorithm=")>-1&&r.indexOf("q-ak=")>-1&&r.indexOf("q-sign-time=")>-1&&r.indexOf("q-key-time=")>-1&&r.indexOf("q-url-param-list=")>-1)t=!0;else try{(r=atob(r)).indexOf("a=")>-1&&r.indexOf("k=")>-1&&r.indexOf("t=")>-1&&r.indexOf("r=")>-1&&r.indexOf("b=")>-1&&(t=!0)}catch(e){}if(!t)return i.error(new Error("getAuthorization callback params format error"))}else{if(!e.TmpSecretId)return i.error(new Error('getAuthorization callback params missing "TmpSecretId"'));if(!e.TmpSecretKey)return i.error(new Error('getAuthorization callback params missing "TmpSecretKey"'));if(!e.SecurityToken&&!e.XCosSecurityToken)return i.error(new Error('getAuthorization callback params missing "SecurityToken"'));if(!e.ExpiredTime)return i.error(new Error('getAuthorization callback params missing "ExpiredTime"'));if(e.ExpiredTime&&10!==e.ExpiredTime.toString().length)return i.error(new Error('getAuthorization callback params "ExpiredTime" should be 10 digits'));if(e.StartTime&&10!==e.StartTime.toString().length)return i.error(new Error('getAuthorization callback params "StartTime" should be 10 StartTime'))}return!1};if(h.ExpiredTime&&h.ExpiredTime-i.getSkewTime(c.options.SystemClockOffset)/1e3>60)k();else if(c.options.getAuthorization)c.options.getAuthorization.call(c,{Bucket:u,Region:l,Method:e.Method,Key:d,Pathname:p,Query:e.Query,Headers:r,Scope:f,SystemClockOffset:c.options.SystemClockOffset,ForceSignHost:o},(function(e){"string"==typeof e&&(e={Authorization:e});var t=C(e);if(t)return s(t);e.Authorization?s(null,e):((h=e||{}).Scope=f,h.ScopeKey=y,c._StsCache.push(h),k())}));else{if(!c.options.getSTS)return function(){var t="";if(c.options.StartTime&&e.Expires){if(10!==c.options.StartTime.toString().length)return s(i.error(new Error('params "StartTime" should be 10 digits')));t=c.options.StartTime+";"+(c.options.StartTime+1*e.Expires)}else if(c.options.StartTime&&c.options.ExpiredTime){if(10!==c.options.StartTime.toString().length)return s(i.error(new Error('params "StartTime" should be 10 digits')));if(10!==c.options.ExpiredTime.toString().length)return s(i.error(new Error('params "ExpiredTime" should be 10 digits')));t=c.options.StartTime+";"+1*c.options.ExpiredTime}var n={Authorization:i.getAuth({SecretId:e.SecretId||c.options.SecretId,SecretKey:e.SecretKey||c.options.SecretKey,Method:e.Method,Pathname:p,Query:e.Query,Headers:r,Expires:e.Expires,KeyTime:t,UseRawKey:c.options.UseRawKey,SystemClockOffset:c.options.SystemClockOffset,ForceSignHost:o}),SecurityToken:c.options.SecurityToken||c.options.XCosSecurityToken,SignFrom:"client"};return s(null,n),n}();c.options.getSTS.call(c,{Bucket:u,Region:l},(function(e){(h=e||{}).Scope=f,h.ScopeKey=y,h.TmpSecretId||(h.TmpSecretId=h.SecretId),h.TmpSecretKey||(h.TmpSecretKey=h.SecretKey);var t=C(h);if(t)return s(t);c._StsCache.push(h),k()}))}return""}function p(e){var t=!1,r=!1,n=!1,o=e.headers&&(e.headers.date||e.headers.Date)||e.error&&e.error.ServerTime;try{var a=e.error.Code,s=e.error.Message;("RequestTimeTooSkewed"===a||"AccessDenied"===a&&"Request has expired"===s)&&(r=!0)}catch(e){}if(e)if(r&&o){var c=Date.parse(o);this.options.CorrectClockSkew&&Math.abs(i.getSkewTime(this.options.SystemClockOffset)-c)>=3e4&&(this.options.SystemClockOffset=c-Date.now(),t=!0)}else 5===Math.floor(e.statusCode/100)?t=!0:"CORS blocked or network error"===e.message&&(n=!0,t=this.options.AutoSwitchHost);return{canRetry:t,networkError:n}}function h(e){var t=e.requestUrl,r=e.clientCalcSign,n=e.networkError;if(!this.options.AutoSwitchHost)return!1;if(!t)return!1;if(!r)return!1;if(!n)return!1;return/^https?:\/\/[^\/]*\.cos\.[^\/]*\.myqcloud\.com(\/.*)?$/.test(t)&&!/^https?:\/\/[^\/]*\.cos\.accelerate\.myqcloud\.com(\/.*)?$/.test(t)}function f(e,t){var r=this;!e.headers&&(e.headers={}),!e.qs&&(e.qs={}),e.VersionId&&(e.qs.versionId=e.VersionId),e.qs=i.clearKey(e.qs),e.headers&&(e.headers=i.clearKey(e.headers)),e.qs&&(e.qs=i.clearKey(e.qs));var n=i.clone(e.qs);e.action&&(n[e.action]="");var o=e.url||e.Url,a=e.SignHost||l.call(this,{Bucket:e.Bucket,Region:e.Region,Url:o}),s=e.tracker;!function o(i){var c=r.options.SystemClockOffset;s&&s.setParams({signStartTime:(new Date).getTime(),httpRetryTimes:i-1}),e.SwitchHost&&(a=a.replace(/myqcloud.com/,"tencentcos.cn")),d.call(r,{Bucket:e.Bucket||"",Region:e.Region||"",Method:e.method,Key:e.Key,Query:n,Headers:e.headers,SignHost:a,Action:e.Action,ResourceKey:e.ResourceKey,Scope:e.Scope,ForceSignHost:r.options.ForceSignHost,SwitchHost:e.SwitchHost},(function(n,a){n?t(n):(s&&s.setParams({signEndTime:(new Date).getTime(),httpStartTime:(new Date).getTime()}),e.AuthData=a,g.call(r,e,(function(n,u){s&&s.setParams({httpEndTime:(new Date).getTime()});var l=!1,d=!1;if(n){var f=p.call(r,n);l=f.canRetry||c!==r.options.SystemClockOffset,d=f.networkError}if(n&&i<2&&l){e.headers&&(delete e.headers.Authorization,delete e.headers.token,delete e.headers.clientIP,delete e.headers.clientUA,e.headers["x-cos-security-token"]&&delete e.headers["x-cos-security-token"],e.headers["x-ci-security-token"]&&delete e.headers["x-ci-security-token"]);var g=h.call(r,{requestUrl:(null==n?void 0:n.url)||"",clientCalcSign:"client"===a.SignFrom,networkError:d});e.SwitchHost=g,e.retry=!0,o(i+1)}else t(n,u)})))}))}(1)}function g(e,t){var r=this,n=e.TaskId;if(!n||r._isRunningTask(n)){var a=e.Bucket,s=e.Region,c=e.Key,l=e.method||"GET",d=e.Url||e.url,p=e.body,h=e.rawBody;r.options.UseAccelerate&&(s="accelerate"),d=d||u({ForcePathStyle:r.options.ForcePathStyle,protocol:r.options.Protocol,domain:r.options.Domain,bucket:a,region:s,object:c}),e.SwitchHost&&(d=d.replace(/myqcloud.com/,"tencentcos.cn"));var f=c?d:"";e.action&&(d=d+"?"+(i.isIOS_QQ?"".concat(e.action,"="):e.action)),e.qsStr&&(d=d.indexOf("?")>-1?d+"&"+e.qsStr:d+"?"+e.qsStr);var g={method:l,url:d,headers:e.headers,qs:e.qs,body:p},m="x-cos-security-token";if(i.isCIHost(d)&&(m="x-ci-security-token"),g.headers.Authorization=e.AuthData.Authorization,e.AuthData.Token&&(g.headers.token=e.AuthData.Token),e.AuthData.ClientIP&&(g.headers.clientIP=e.AuthData.ClientIP),e.AuthData.ClientUA&&(g.headers.clientUA=e.AuthData.ClientUA),e.AuthData.SecurityToken&&(g.headers[m]=e.AuthData.SecurityToken),g.headers&&(g.headers=i.clearKey(g.headers)),e.retry&&(g.headers["x-cos-sdk-retry"]=!0),g=i.clearKey(g),e.onProgress&&"function"==typeof e.onProgress){var y=p&&(p.size||p.length)||0;g.onProgress=function(t){if(!n||r._isRunningTask(n)){var o=t?t.loaded:0;e.onProgress({loaded:o,total:y})}}}e.onDownloadProgress&&(g.onDownloadProgress=e.onDownloadProgress),e.DataType&&(g.dataType=e.DataType),this.options.Timeout&&(g.timeout=this.options.Timeout),r.options.ForcePathStyle&&(g.pathStyle=r.options.ForcePathStyle),r.emit("before-send",g);var k,C=g.url.includes("accelerate."),v=g.qs?Object.keys(g.qs).map((function(e){return"".concat(e,"=").concat(g.qs[e])})).join("&"):"",b=v?g.url+"?"+v:g.url;if(e.tracker)e.tracker.setParams({url:b,httpMethod:g.method,accelerate:C,httpSize:(null===(k=g.body)||void 0===k?void 0:k.size)||0}),e.tracker.parent&&!e.tracker.parent.params.url&&e.tracker.parent.setParams({url:f,accelerate:C});var S=(r.options.Request||o)(g,(function(o){if(!o||"abort"!==o.error){var a={options:g,error:o&&o.error,statusCode:o&&o.statusCode||0,statusMessage:o&&o.statusMessage||"",headers:o&&o.headers||{},body:o&&o.body};r.emit("after-receive",a);var s,c=a.error,u=a.body,l={statusCode:a.statusCode,statusMessage:a.statusMessage,headers:a.headers},d=function(o,a){if(n&&r.off("inner-kill-task",x),!s){s=!0;var c={};if(l&&l.statusCode&&(c.statusCode=l.statusCode),l&&l.headers&&(c.headers=l.headers),o)g.url&&(c.url=g.url),g.method&&(c.method=g.method),o=i.extend(o||{},c),t(o,null);else{if("name/cos:PutObject"===e.Action){var u={};for(var d in e.headers){u[d.toLowerCase()]=e.headers[d]}u["x-cos-callback"]?a.Error?(a.CallbackError=i.clone(a.Error),delete a.Error):a.CallbackBody=i.clone(a):u["x-cos-return-body"]&&(a.Error?(a.ReturnError=i.clone(a.Error),delete a.Error):a.ReturnBody=i.clone(a))}a=i.extend(a||{},c),t(null,a)}S=null}};if(c)return d(i.error(c));var p=l.statusCode,f=2===Math.floor(p/100);if(h){if(f)return d(null,{body:u});if(u instanceof Blob)return void i.readAsBinaryString(u,(function(e){var t=i.parseResBody(e),r=t.Error||t;return d(i.error(new Error(r.Message||"response body error"),{code:r.Code,error:r}))}))}var m=i.parseResBody(u),y=m.Error||m;f?d(null,m):y?d(i.error(new Error(y.Message),{code:y.Code,error:y})):p?d(i.error(new Error(l.statusMessage),{code:""+p})):p&&d(i.error(new Error("statusCode error")))}})),x=function e(t){t.TaskId===n&&(S&&S.abort&&S.abort(),r.off("inner-kill-task",e))};n&&r.on("inner-kill-task",x)}}var m={getService:function(e,t){var r=this.options.Protocol||(i.isBrowser&&"object"===("undefined"==typeof location?"undefined":n(location))&&"http:"===location.protocol?"http:":"https:"),o=this.options.ServiceDomain,a=e.AppId||this.options.appId,s=e.Region;o?(o=o.replace(/\{\{AppId\}\}/gi,a||"").replace(/\{\{Region\}\}/gi,s||"").replace(/\{\{.*?\}\}/gi,""),/^[a-zA-Z]+:\/\//.test(o)||(o=r+"//"+o),"/"===o.slice(-1)&&(o=o.slice(0,-1))):o=s?r+"//cos."+s+".myqcloud.com":r+"//service.cos.myqcloud.com";var c="",u=s?"cos."+s+".myqcloud.com":"service.cos.myqcloud.com";u===o.replace(/^https?:\/\/([^/]+)(\/.*)?$/,"$1")&&(c=u),f.call(this,{Action:"name/cos:GetService",url:o,method:"GET",headers:e.Headers,SignHost:c,tracker:e.tracker},(function(e,r){if(e)return t(e);var n=r&&r.ListAllMyBucketsResult&&r.ListAllMyBucketsResult.Buckets&&r.ListAllMyBucketsResult.Buckets.Bucket||[];n=i.isArray(n)?n:[n];var o=r&&r.ListAllMyBucketsResult&&r.ListAllMyBucketsResult.Owner||{};t(null,{Buckets:n,Owner:o,statusCode:r.statusCode,headers:r.headers})}))},putBucket:function(e,t){var r=this,n="";if(e.BucketAZConfig){var o={BucketAZConfig:e.BucketAZConfig};n=i.json2xml({CreateBucketConfiguration:o})}f.call(this,{Action:"name/cos:PutBucket",method:"PUT",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,body:n,tracker:e.tracker},(function(n,o){if(n)return t(n);var i=u({protocol:r.options.Protocol,domain:r.options.Domain,bucket:e.Bucket,region:e.Region,isLocation:!0});t(null,{Location:i,statusCode:o.statusCode,headers:o.headers})}))},headBucket:function(e,t){f.call(this,{Action:"name/cos:HeadBucket",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,method:"HEAD",tracker:e.tracker},t)},getBucket:function(e,t){var r={};r.prefix=e.Prefix||"",r.delimiter=e.Delimiter,r.marker=e.Marker,r["max-keys"]=e.MaxKeys,r["encoding-type"]=e.EncodingType,f.call(this,{Action:"name/cos:GetBucket",ResourceKey:r.prefix,method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,qs:r,tracker:e.tracker},(function(e,r){if(e)return t(e);var n=r.ListBucketResult||{},o=n.Contents||[],a=n.CommonPrefixes||[];o=i.isArray(o)?o:[o],a=i.isArray(a)?a:[a];var s=i.clone(n);i.extend(s,{Contents:o,CommonPrefixes:a,statusCode:r.statusCode,headers:r.headers}),t(null,s)}))},deleteBucket:function(e,t){f.call(this,{Action:"name/cos:DeleteBucket",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,method:"DELETE",tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},putBucketAcl:function(e,t){var r=e.Headers,n="";if(e.AccessControlPolicy){var o=i.clone(e.AccessControlPolicy||{}),a=o.Grants||o.Grant;a=i.isArray(a)?a:[a],delete o.Grant,delete o.Grants,o.AccessControlList={Grant:a},n=i.json2xml({AccessControlPolicy:o}),r["Content-Type"]="application/xml",r["Content-MD5"]=i.b64(i.md5(n))}i.each(r,(function(e,t){0===t.indexOf("x-cos-grant-")&&(r[t]=c(r[t]))})),f.call(this,{Action:"name/cos:PutBucketACL",method:"PUT",Bucket:e.Bucket,Region:e.Region,headers:r,action:"acl",body:n,tracker:e.tracker},(function(e,r){if(e)return t(e);t(null,{statusCode:r.statusCode,headers:r.headers})}))},getBucketAcl:function(e,t){f.call(this,{Action:"name/cos:GetBucketACL",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"acl",tracker:e.tracker},(function(e,r){if(e)return t(e);var n=r.AccessControlPolicy||{},o=n.Owner||{},a=n.AccessControlList.Grant||[];a=i.isArray(a)?a:[a];var c=s(n);r.headers&&r.headers["x-cos-acl"]&&(c.ACL=r.headers["x-cos-acl"]),c=i.extend(c,{Owner:o,Grants:a,statusCode:r.statusCode,headers:r.headers}),t(null,c)}))},putBucketCors:function(e,t){var r=(e.CORSConfiguration||{}).CORSRules||e.CORSRules||[];r=i.clone(i.isArray(r)?r:[r]),i.each(r,(function(e){i.each(["AllowedOrigin","AllowedHeader","AllowedMethod","ExposeHeader"],(function(t){var r=t+"s",n=e[r]||e[t]||[];delete e[r],e[t]=i.isArray(n)?n:[n]}))}));var n={CORSRule:r};e.ResponseVary&&(n.ResponseVary=e.ResponseVary);var o=i.json2xml({CORSConfiguration:n}),a=e.Headers;a["Content-Type"]="application/xml",a["Content-MD5"]=i.b64(i.md5(o)),f.call(this,{Action:"name/cos:PutBucketCORS",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:o,action:"cors",headers:a,tracker:e.tracker},(function(e,r){if(e)return t(e);t(null,{statusCode:r.statusCode,headers:r.headers})}))},getBucketCors:function(e,t){f.call(this,{Action:"name/cos:GetBucketCORS",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"cors",tracker:e.tracker},(function(e,r){if(e)if(404===e.statusCode&&e.error&&"NoSuchCORSConfiguration"===e.error.Code){var n={CORSRules:[],statusCode:e.statusCode};e.headers&&(n.headers=e.headers),t(null,n)}else t(e);else{var o=r.CORSConfiguration||{},a=o.CORSRules||o.CORSRule||[];a=i.clone(i.isArray(a)?a:[a]);var s=o.ResponseVary;i.each(a,(function(e){i.each(["AllowedOrigin","AllowedHeader","AllowedMethod","ExposeHeader"],(function(t){var r=t+"s",n=e[r]||e[t]||[];delete e[t],e[r]=i.isArray(n)?n:[n]}))})),t(null,{CORSRules:a,ResponseVary:s,statusCode:r.statusCode,headers:r.headers})}}))},deleteBucketCors:function(e,t){f.call(this,{Action:"name/cos:DeleteBucketCORS",method:"DELETE",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"cors",tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode||e.statusCode,headers:r.headers})}))},getBucketLocation:function(e,t){f.call(this,{Action:"name/cos:GetBucketLocation",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"location",tracker:e.tracker},t)},getBucketPolicy:function(e,t){f.call(this,{Action:"name/cos:GetBucketPolicy",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"policy",rawBody:!0,tracker:e.tracker},(function(e,r){if(e)return e.statusCode&&403===e.statusCode?t(i.error(e,{ErrorStatus:"Access Denied"})):e.statusCode&&405===e.statusCode?t(i.error(e,{ErrorStatus:"Method Not Allowed"})):e.statusCode&&404===e.statusCode?t(i.error(e,{ErrorStatus:"Policy Not Found"})):t(e);var n={};try{n=JSON.parse(r.body)}catch(e){}t(null,{Policy:n,statusCode:r.statusCode,headers:r.headers})}))},putBucketPolicy:function(e,t){var r=e.Policy;try{"string"==typeof r&&(r=JSON.parse(r))}catch(e){}if(!r||"string"==typeof r)return t(i.error(new Error("Policy format error")));var n=JSON.stringify(r);r.version||(r.version="2.0");var o=e.Headers;o["Content-Type"]="application/json",o["Content-MD5"]=i.b64(i.md5(n)),f.call(this,{Action:"name/cos:PutBucketPolicy",method:"PUT",Bucket:e.Bucket,Region:e.Region,action:"policy",body:n,headers:o,tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},deleteBucketPolicy:function(e,t){f.call(this,{Action:"name/cos:DeleteBucketPolicy",method:"DELETE",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"policy",tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode||e.statusCode,headers:r.headers})}))},putBucketTagging:function(e,t){var r=e.Tagging||{},n=r.TagSet||r.Tags||e.Tags||[];n=i.clone(i.isArray(n)?n:[n]);var o=i.json2xml({Tagging:{TagSet:{Tag:n}}}),a=e.Headers;a["Content-Type"]="application/xml",a["Content-MD5"]=i.b64(i.md5(o)),f.call(this,{Action:"name/cos:PutBucketTagging",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:o,action:"tagging",headers:a,tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},getBucketTagging:function(e,t){f.call(this,{Action:"name/cos:GetBucketTagging",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"tagging",tracker:e.tracker},(function(e,r){if(e)if(404!==e.statusCode||!e.error||"Not Found"!==e.error&&"NoSuchTagSet"!==e.error.Code)t(e);else{var n={Tags:[],statusCode:e.statusCode};e.headers&&(n.headers=e.headers),t(null,n)}else{var o=[];try{o=r.Tagging.TagSet.Tag||[]}catch(e){}o=i.clone(i.isArray(o)?o:[o]),t(null,{Tags:o,statusCode:r.statusCode,headers:r.headers})}}))},deleteBucketTagging:function(e,t){f.call(this,{Action:"name/cos:DeleteBucketTagging",method:"DELETE",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"tagging",tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},putBucketLifecycle:function(e,t){var r=(e.LifecycleConfiguration||{}).Rules||e.Rules||[];r=i.clone(r);var n=i.json2xml({LifecycleConfiguration:{Rule:r}}),o=e.Headers;o["Content-Type"]="application/xml",o["Content-MD5"]=i.b64(i.md5(n)),f.call(this,{Action:"name/cos:PutBucketLifecycle",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:n,action:"lifecycle",headers:o,tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},getBucketLifecycle:function(e,t){f.call(this,{Action:"name/cos:GetBucketLifecycle",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"lifecycle",tracker:e.tracker},(function(e,r){if(e)if(404===e.statusCode&&e.error&&"NoSuchLifecycleConfiguration"===e.error.Code){var n={Rules:[],statusCode:e.statusCode};e.headers&&(n.headers=e.headers),t(null,n)}else t(e);else{var o=[];try{o=r.LifecycleConfiguration.Rule||[]}catch(e){}o=i.clone(i.isArray(o)?o:[o]),t(null,{Rules:o,statusCode:r.statusCode,headers:r.headers})}}))},deleteBucketLifecycle:function(e,t){f.call(this,{Action:"name/cos:DeleteBucketLifecycle",method:"DELETE",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"lifecycle",tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},putBucketVersioning:function(e,t){if(e.VersioningConfiguration){var r=e.VersioningConfiguration||{},n=i.json2xml({VersioningConfiguration:r}),o=e.Headers;o["Content-Type"]="application/xml",o["Content-MD5"]=i.b64(i.md5(n)),f.call(this,{Action:"name/cos:PutBucketVersioning",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:n,action:"versioning",headers:o,tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))}else t(i.error(new Error("missing param VersioningConfiguration")))},getBucketVersioning:function(e,t){f.call(this,{Action:"name/cos:GetBucketVersioning",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"versioning",tracker:e.tracker},(function(e,r){e||!r.VersioningConfiguration&&(r.VersioningConfiguration={}),t(e,r)}))},putBucketReplication:function(e,t){var r=i.clone(e.ReplicationConfiguration),n=i.json2xml({ReplicationConfiguration:r});n=(n=n.replace(/<(\/?)Rules>/gi,"<$1Rule>")).replace(/<(\/?)Tags>/gi,"<$1Tag>");var o=e.Headers;o["Content-Type"]="application/xml",o["Content-MD5"]=i.b64(i.md5(n)),f.call(this,{Action:"name/cos:PutBucketReplication",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:n,action:"replication",headers:o,tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},getBucketReplication:function(e,t){f.call(this,{Action:"name/cos:GetBucketReplication",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"replication",tracker:e.tracker},(function(e,r){if(e)if(404!==e.statusCode||!e.error||"Not Found"!==e.error&&"ReplicationConfigurationnotFoundError"!==e.error.Code)t(e);else{var n={ReplicationConfiguration:{Rules:[]},statusCode:e.statusCode};e.headers&&(n.headers=e.headers),t(null,n)}else!r.ReplicationConfiguration&&(r.ReplicationConfiguration={}),r.ReplicationConfiguration.Rule&&(r.ReplicationConfiguration.Rules=i.makeArray(r.ReplicationConfiguration.Rule),delete r.ReplicationConfiguration.Rule),t(e,r)}))},deleteBucketReplication:function(e,t){f.call(this,{Action:"name/cos:DeleteBucketReplication",method:"DELETE",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"replication",tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},putBucketWebsite:function(e,t){if(e.WebsiteConfiguration){var r=i.clone(e.WebsiteConfiguration||{}),n=r.RoutingRules||r.RoutingRule||[];n=i.isArray(n)?n:[n],delete r.RoutingRule,delete r.RoutingRules,n.length&&(r.RoutingRules={RoutingRule:n});var o=i.json2xml({WebsiteConfiguration:r}),a=e.Headers;a["Content-Type"]="application/xml",a["Content-MD5"]=i.b64(i.md5(o)),f.call(this,{Action:"name/cos:PutBucketWebsite",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:o,action:"website",headers:a,tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))}else t(i.error(new Error("missing param WebsiteConfiguration")))},getBucketWebsite:function(e,t){f.call(this,{Action:"name/cos:GetBucketWebsite",method:"GET",Bucket:e.Bucket,Region:e.Region,Key:e.Key,headers:e.Headers,action:"website",tracker:e.tracker},(function(e,r){if(e)if(404===e.statusCode&&"NoSuchWebsiteConfiguration"===e.error.Code){var n={WebsiteConfiguration:{},statusCode:e.statusCode};e.headers&&(n.headers=e.headers),t(null,n)}else t(e);else{var o=r.WebsiteConfiguration||{};if(o.RoutingRules){var a=i.clone(o.RoutingRules.RoutingRule||[]);a=i.makeArray(a),o.RoutingRules=a}t(null,{WebsiteConfiguration:o,statusCode:r.statusCode,headers:r.headers})}}))},deleteBucketWebsite:function(e,t){f.call(this,{Action:"name/cos:DeleteBucketWebsite",method:"DELETE",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"website",tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},putBucketReferer:function(e,t){if(e.RefererConfiguration){var r=i.clone(e.RefererConfiguration||{}),n=r.DomainList||{},o=n.Domains||n.Domain||[];(o=i.isArray(o)?o:[o]).length&&(r.DomainList={Domain:o});var a=i.json2xml({RefererConfiguration:r}),s=e.Headers;s["Content-Type"]="application/xml",s["Content-MD5"]=i.b64(i.md5(a)),f.call(this,{Action:"name/cos:PutBucketReferer",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:a,action:"referer",headers:s,tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))}else t(i.error(new Error("missing param RefererConfiguration")))},getBucketReferer:function(e,t){f.call(this,{Action:"name/cos:GetBucketReferer",method:"GET",Bucket:e.Bucket,Region:e.Region,Key:e.Key,headers:e.Headers,action:"referer",tracker:e.tracker},(function(e,r){if(e)if(404===e.statusCode&&"NoSuchRefererConfiguration"===e.error.Code){var n={WebsiteConfiguration:{},statusCode:e.statusCode};e.headers&&(n.headers=e.headers),t(null,n)}else t(e);else{var o=r.RefererConfiguration||{};if(o.DomainList){var a=i.makeArray(o.DomainList.Domain||[]);o.DomainList={Domains:a}}t(null,{RefererConfiguration:o,statusCode:r.statusCode,headers:r.headers})}}))},putBucketDomain:function(e,t){var r=(e.DomainConfiguration||{}).DomainRule||e.DomainRule||[];r=i.clone(r);var n=i.json2xml({DomainConfiguration:{DomainRule:r}}),o=e.Headers;o["Content-Type"]="application/xml",o["Content-MD5"]=i.b64(i.md5(n)),f.call(this,{Action:"name/cos:PutBucketDomain",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:n,action:"domain",headers:o,tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},getBucketDomain:function(e,t){f.call(this,{Action:"name/cos:GetBucketDomain",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"domain",tracker:e.tracker},(function(e,r){if(e)return t(e);var n=[];try{n=r.DomainConfiguration.DomainRule||[]}catch(e){}n=i.clone(i.isArray(n)?n:[n]),t(null,{DomainRule:n,statusCode:r.statusCode,headers:r.headers})}))},deleteBucketDomain:function(e,t){f.call(this,{Action:"name/cos:DeleteBucketDomain",method:"DELETE",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"domain",tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},putBucketOrigin:function(e,t){var r=(e.OriginConfiguration||{}).OriginRule||e.OriginRule||[];r=i.clone(r);var n=i.json2xml({OriginConfiguration:{OriginRule:r}}),o=e.Headers;o["Content-Type"]="application/xml",o["Content-MD5"]=i.b64(i.md5(n)),f.call(this,{Action:"name/cos:PutBucketOrigin",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:n,action:"origin",headers:o,tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},getBucketOrigin:function(e,t){f.call(this,{Action:"name/cos:GetBucketOrigin",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"origin",tracker:e.tracker},(function(e,r){if(e)return t(e);var n=[];try{n=r.OriginConfiguration.OriginRule||[]}catch(e){}n=i.clone(i.isArray(n)?n:[n]),t(null,{OriginRule:n,statusCode:r.statusCode,headers:r.headers})}))},deleteBucketOrigin:function(e,t){f.call(this,{Action:"name/cos:DeleteBucketOrigin",method:"DELETE",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"origin",tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},putBucketLogging:function(e,t){var r=i.json2xml({BucketLoggingStatus:e.BucketLoggingStatus||""}),n=e.Headers;n["Content-Type"]="application/xml",n["Content-MD5"]=i.b64(i.md5(r)),f.call(this,{Action:"name/cos:PutBucketLogging",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:r,action:"logging",headers:n,tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},getBucketLogging:function(e,t){f.call(this,{Action:"name/cos:GetBucketLogging",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"logging",tracker:e.tracker},(function(e,r){if(e)return t(e);t(null,{BucketLoggingStatus:r.BucketLoggingStatus,statusCode:r.statusCode,headers:r.headers})}))},putBucketInventory:function(e,t){return a.call(this,"PUT",e,t)},postBucketInventory:function(e,t){return a.call(this,"POST",e,t)},getBucketInventory:function(e,t){f.call(this,{Action:"name/cos:GetBucketInventory",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"inventory",qs:{id:e.Id},tracker:e.tracker},(function(e,r){if(e)return t(e);var n=r.InventoryConfiguration;if(n&&n.OptionalFields&&n.OptionalFields.Field){var o=n.OptionalFields.Field;i.isArray(o)||(o=[o]),n.OptionalFields=o}if(n.Destination&&n.Destination.COSBucketDestination&&n.Destination.COSBucketDestination.Encryption){var a=n.Destination.COSBucketDestination.Encryption;Object.keys(a).indexOf("SSE-COS")>-1&&(a.SSECOS=a["SSE-COS"],delete a["SSE-COS"])}t(null,{InventoryConfiguration:n,statusCode:r.statusCode,headers:r.headers})}))},listBucketInventory:function(e,t){f.call(this,{Action:"name/cos:ListBucketInventory",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"inventory",qs:{"continuation-token":e.ContinuationToken},tracker:e.tracker},(function(e,r){if(e)return t(e);var n=r.ListInventoryConfigurationResult,o=n.InventoryConfiguration||[];o=i.isArray(o)?o:[o],delete n.InventoryConfiguration,i.each(o,(function(e){if(e&&e.OptionalFields&&e.OptionalFields.Field){var t=e.OptionalFields.Field;i.isArray(t)||(t=[t]),e.OptionalFields=t}if(e.Destination&&e.Destination.COSBucketDestination&&e.Destination.COSBucketDestination.Encryption){var r=e.Destination.COSBucketDestination.Encryption;Object.keys(r).indexOf("SSE-COS")>-1&&(r.SSECOS=r["SSE-COS"],delete r["SSE-COS"])}})),n.InventoryConfigurations=o,i.extend(n,{statusCode:r.statusCode,headers:r.headers}),t(null,n)}))},deleteBucketInventory:function(e,t){f.call(this,{Action:"name/cos:DeleteBucketInventory",method:"DELETE",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"inventory",qs:{id:e.Id},tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},putBucketAccelerate:function(e,t){if(e.AccelerateConfiguration){var r={AccelerateConfiguration:e.AccelerateConfiguration||{}},n=i.json2xml(r),o={"Content-Type":"application/xml"};o["Content-MD5"]=i.b64(i.md5(n)),f.call(this,{Action:"name/cos:PutBucketAccelerate",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:n,action:"accelerate",headers:o,tracker:e.tracker},(function(e,r){if(e)return t(e);t(null,{statusCode:r.statusCode,headers:r.headers})}))}else t(i.error(new Error("missing param AccelerateConfiguration")))},getBucketAccelerate:function(e,t){f.call(this,{Action:"name/cos:GetBucketAccelerate",method:"GET",Bucket:e.Bucket,Region:e.Region,action:"accelerate",tracker:e.tracker},(function(e,r){e||!r.AccelerateConfiguration&&(r.AccelerateConfiguration={}),t(e,r)}))},putBucketEncryption:function(e,t){var r=e.ServerSideEncryptionConfiguration||{},n=r.Rule||r.Rules||[],o=i.json2xml({ServerSideEncryptionConfiguration:{Rule:n}}),a=e.Headers;a["Content-Type"]="application/xml",a["Content-MD5"]=i.b64(i.md5(o)),f.call(this,{Action:"name/cos:PutBucketEncryption",method:"PUT",Bucket:e.Bucket,Region:e.Region,body:o,action:"encryption",headers:a,tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},getBucketEncryption:function(e,t){f.call(this,{Action:"name/cos:GetBucketEncryption",method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"encryption",tracker:e.tracker},(function(e,r){if(e)if(404===e.statusCode&&"NoSuchEncryptionConfiguration"===e.code){var n={EncryptionConfiguration:{Rules:[]},statusCode:e.statusCode};e.headers&&(n.headers=e.headers),t(null,n)}else t(e);else{var o=i.makeArray(r.EncryptionConfiguration&&r.EncryptionConfiguration.Rule||[]);r.EncryptionConfiguration={Rules:o},t(e,r)}}))},deleteBucketEncryption:function(e,t){f.call(this,{Action:"name/cos:DeleteBucketReplication",method:"DELETE",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,action:"encryption",tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},getObject:function(e,t){if(this.options.ObjectKeySimplifyCheck&&"/"===i.simplifyPath(e.Key))return void t(i.error(new Error("The Getobject Key is illegal")));var r=e.Query||{},n=e.QueryString||"",o=i.throttleOnProgress.call(this,0,e.onProgress),a=e.tracker;a&&a.setParams({signStartTime:(new Date).getTime()}),r["response-content-type"]=e.ResponseContentType,r["response-content-language"]=e.ResponseContentLanguage,r["response-expires"]=e.ResponseExpires,r["response-cache-control"]=e.ResponseCacheControl,r["response-content-disposition"]=e.ResponseContentDisposition,r["response-content-encoding"]=e.ResponseContentEncoding,f.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:r,qsStr:n,rawBody:!0,onDownloadProgress:o,tracker:a},(function(r,n){if(o(null,!0),r){var a=r.statusCode;return e.Headers["If-Modified-Since"]&&a&&304===a?t(null,{NotModified:!0}):t(r)}t(null,{Body:n.body,ETag:i.attr(n.headers,"etag",""),statusCode:n.statusCode,headers:n.headers})}))},headObject:function(e,t){f.call(this,{Action:"name/cos:HeadObject",method:"HEAD",Bucket:e.Bucket,Region:e.Region,Key:e.Key,VersionId:e.VersionId,headers:e.Headers,tracker:e.tracker},(function(r,n){if(r){var o=r.statusCode;return e.Headers["If-Modified-Since"]&&o&&304===o?t(null,{NotModified:!0,statusCode:o}):t(r)}n.ETag=i.attr(n.headers,"etag",""),t(null,n)}))},listObjectVersions:function(e,t){var r={};r.prefix=e.Prefix||"",r.delimiter=e.Delimiter,r["key-marker"]=e.KeyMarker,r["version-id-marker"]=e.VersionIdMarker,r["max-keys"]=e.MaxKeys,r["encoding-type"]=e.EncodingType,f.call(this,{Action:"name/cos:GetBucketObjectVersions",ResourceKey:r.prefix,method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,qs:r,action:"versions",tracker:e.tracker},(function(e,r){if(e)return t(e);var n=r.ListVersionsResult||{},o=n.DeleteMarker||[];o=i.isArray(o)?o:[o];var a=n.Version||[];a=i.isArray(a)?a:[a];var s=i.clone(n);delete s.DeleteMarker,delete s.Version,i.extend(s,{DeleteMarkers:o,Versions:a,statusCode:r.statusCode,headers:r.headers}),t(null,s)}))},putObject:function(e,t){var r=this,n=e.ContentLength,o=i.throttleOnProgress.call(r,n,e.onProgress),a=e.Headers;a["Cache-Control"]||a["cache-control"]||(a["Cache-Control"]=""),a["Content-Type"]||a["content-type"]||(a["Content-Type"]=e.Body&&e.Body.type||"");var s=e.UploadAddMetaMd5||r.options.UploadAddMetaMd5||r.options.UploadCheckContentMd5,c=e.tracker;s&&c&&c.setParams({md5StartTime:(new Date).getTime()}),i.getBodyMd5(s,e.Body,(function(s){s&&(c&&c.setParams({md5EndTime:(new Date).getTime()}),r.options.UploadCheckContentMd5&&(a["Content-MD5"]=i.b64(s)),(e.UploadAddMetaMd5||r.options.UploadAddMetaMd5)&&(a["x-cos-meta-md5"]=s)),void 0!==e.ContentLength&&(a["Content-Length"]=e.ContentLength),o(null,!0),f.call(r,{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,tracker:c},(function(a,s){if(a)return o(null,!0),t(a);o({loaded:n,total:n},!0);var c=u({ForcePathStyle:r.options.ForcePathStyle,protocol:r.options.Protocol,domain:r.options.Domain,bucket:e.Bucket,region:r.options.UseAccelerate?"accelerate":e.Region,object:e.Key});c=c.substr(c.indexOf("://")+3),s.Location=c,s.ETag=i.attr(s.headers,"etag",""),t(null,s)}))}),e.onHashProgress)},deleteObject:function(e,t){f.call(this,{Action:"name/cos:DeleteObject",method:"DELETE",Bucket:e.Bucket,Region:e.Region,Key:e.Key,headers:e.Headers,VersionId:e.VersionId,action:e.Recursive?"recursive":"",tracker:e.tracker},(function(e,r){if(e){var n=e.statusCode;return n&&404===n?t(null,{BucketNotFound:!0,statusCode:n}):t(e)}t(null,{statusCode:r.statusCode,headers:r.headers})}))},getObjectAcl:function(e,t){var r={};e.VersionId&&(r.versionId=e.VersionId),f.call(this,{Action:"name/cos:GetObjectACL",method:"GET",Bucket:e.Bucket,Region:e.Region,Key:e.Key,headers:e.Headers,qs:r,action:"acl",tracker:e.tracker},(function(e,r){if(e)return t(e);var n=r.AccessControlPolicy||{},o=n.Owner||{},a=n.AccessControlList&&n.AccessControlList.Grant||[];a=i.isArray(a)?a:[a];var c=s(n);delete c.GrantWrite,r.headers&&r.headers["x-cos-acl"]&&(c.ACL=r.headers["x-cos-acl"]),c=i.extend(c,{Owner:o,Grants:a,statusCode:r.statusCode,headers:r.headers}),t(null,c)}))},putObjectAcl:function(e,t){var r=e.Headers,n="";if(e.AccessControlPolicy){var o=i.clone(e.AccessControlPolicy||{}),a=o.Grants||o.Grant;a=i.isArray(a)?a:[a],delete o.Grant,delete o.Grants,o.AccessControlList={Grant:a},n=i.json2xml({AccessControlPolicy:o}),r["Content-Type"]="application/xml",r["Content-MD5"]=i.b64(i.md5(n))}i.each(r,(function(e,t){0===t.indexOf("x-cos-grant-")&&(r[t]=c(r[t]))})),f.call(this,{Action:"name/cos:PutObjectACL",method:"PUT",Bucket:e.Bucket,Region:e.Region,Key:e.Key,action:"acl",headers:r,body:n,tracker:e.tracker},(function(e,r){if(e)return t(e);t(null,{statusCode:r.statusCode,headers:r.headers})}))},optionsObject:function(e,t){var r=e.Headers;r.Origin=e.Origin,r["Access-Control-Request-Method"]=e.AccessControlRequestMethod,r["Access-Control-Request-Headers"]=e.AccessControlRequestHeaders,f.call(this,{Action:"name/cos:OptionsObject",method:"OPTIONS",Bucket:e.Bucket,Region:e.Region,Key:e.Key,headers:r,tracker:e.tracker},(function(e,r){if(e)return e.statusCode&&403===e.statusCode?t(null,{OptionsForbidden:!0,statusCode:e.statusCode}):t(e);var n=r.headers||{};t(null,{AccessControlAllowOrigin:n["access-control-allow-origin"],AccessControlAllowMethods:n["access-control-allow-methods"],AccessControlAllowHeaders:n["access-control-allow-headers"],AccessControlExposeHeaders:n["access-control-expose-headers"],AccessControlMaxAge:n["access-control-max-age"],statusCode:r.statusCode,headers:r.headers})}))},putObjectCopy:function(e,t){var r=this,n=e.Headers;n["Cache-Control"]||n["cache-control"]||(n["Cache-Control"]="");var o=e.CopySource||"",a=i.getSourceParams.call(this,o);if(a){var s=a.Bucket,c=a.Region,l=decodeURIComponent(a.Key);f.call(this,{Scope:[{action:"name/cos:GetObject",bucket:s,region:c,prefix:l},{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,tracker:e.tracker},(function(n,o){if(n)return t(n);var a=i.clone(o.CopyObjectResult||{}),s=u({ForcePathStyle:r.options.ForcePathStyle,protocol:r.options.Protocol,domain:r.options.Domain,bucket:e.Bucket,region:e.Region,object:e.Key,isLocation:!0});i.extend(a,{Location:s,statusCode:o.statusCode,headers:o.headers}),t(null,a)}))}else t(i.error(new Error("CopySource format error")))},deleteMultipleObject:function(e,t){var r=e.Objects||[],n=e.Quiet;r=i.isArray(r)?r:[r];var o=i.json2xml({Delete:{Object:r,Quiet:n||!1}}),a=e.Headers;a["Content-Type"]="application/xml",a["Content-MD5"]=i.b64(i.md5(o));var s=i.map(r,(function(t){return{action:"name/cos:DeleteObject",bucket:e.Bucket,region:e.Region,prefix:t.Key}}));f.call(this,{Scope:s,method:"POST",Bucket:e.Bucket,Region:e.Region,body:o,action:"delete",headers:a,tracker:e.tracker},(function(e,r){if(e)return t(e);var n=r.DeleteResult||{},o=n.Deleted||[],a=n.Error||[];o=i.isArray(o)?o:[o],a=i.isArray(a)?a:[a];var s=i.clone(n);i.extend(s,{Error:a,Deleted:o,statusCode:r.statusCode,headers:r.headers}),t(null,s)}))},restoreObject:function(e,t){var r=e.Headers;if(e.RestoreRequest){var n=e.RestoreRequest||{},o=i.json2xml({RestoreRequest:n});r["Content-Type"]="application/xml",r["Content-MD5"]=i.b64(i.md5(o)),f.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:r,tracker:e.tracker},t)}else t(i.error(new Error("missing param RestoreRequest")))},putObjectTagging:function(e,t){var r=e.Tagging||{},n=r.TagSet||r.Tags||e.Tags||[];n=i.clone(i.isArray(n)?n:[n]);var o=i.json2xml({Tagging:{TagSet:{Tag:n}}}),a=e.Headers;a["Content-Type"]="application/xml",a["Content-MD5"]=i.b64(i.md5(o)),f.call(this,{Action:"name/cos:PutObjectTagging",method:"PUT",Bucket:e.Bucket,Key:e.Key,Region:e.Region,body:o,action:"tagging",headers:a,VersionId:e.VersionId,tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},getObjectTagging:function(e,t){f.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,tracker:e.tracker},(function(e,r){if(e)if(404!==e.statusCode||!e.error||"Not Found"!==e.error&&"NoSuchTagSet"!==e.error.Code)t(e);else{var n={Tags:[],statusCode:e.statusCode};e.headers&&(n.headers=e.headers),t(null,n)}else{var o=[];try{o=r.Tagging.TagSet.Tag||[]}catch(e){}o=i.clone(i.isArray(o)?o:[o]),t(null,{Tags:o,statusCode:r.statusCode,headers:r.headers})}}))},deleteObjectTagging:function(e,t){f.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,tracker:e.tracker},(function(e,r){return e&&204===e.statusCode?t(null,{statusCode:e.statusCode}):e?t(e):void t(null,{statusCode:r.statusCode,headers:r.headers})}))},selectObjectContent:function(e,t){if(!e.SelectType)return t(i.error(new Error("missing param SelectType")));var r=e.SelectRequest||{},n=i.json2xml({SelectRequest:r}),o=e.Headers;o["Content-Type"]="application/xml",o["Content-MD5"]=i.b64(i.md5(n)),f.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:n,DataType:"arraybuffer",rawBody:!0,tracker:e.tracker},(function(e,r){if(e&&204===e.statusCode)return t(null,{statusCode:e.statusCode});if(e)return t(e);var n=i.parseSelectPayload(r.body);t(null,{statusCode:r.statusCode,headers:r.headers,Body:n.body,Payload:n.payload})}))},appendObject:function(e,t){var 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||""),f.call(this,{Action:"name/cos:AppendObject",method:"POST",Bucket:e.Bucket,Region:e.Region,action:"append",Key:e.Key,body:e.Body,qs:{position:e.Position},headers:e.Headers,tracker:e.tracker},(function(e,r){if(e)return t(e);t(null,r)}))},uploadPartCopy:function(e,t){var r=e.CopySource||"",n=i.getSourceParams.call(this,r);if(n){var o=n.Bucket,a=n.Region,s=decodeURIComponent(n.Key);f.call(this,{Scope:[{action:"name/cos:GetObject",bucket:o,region:a,prefix:s},{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,tracker:e.tracker},(function(e,r){if(e)return t(e);var n=i.clone(r.CopyPartResult||{});i.extend(n,{statusCode:r.statusCode,headers:r.headers}),t(null,n)}))}else t(i.error(new Error("CopySource format error")))},multipartInit:function(e,t){var r=this,n=e.Headers,o=e.tracker;n["Cache-Control"]||n["cache-control"]||(n["Cache-Control"]=""),n["Content-Type"]||n["content-type"]||(n["Content-Type"]=e.Body&&e.Body.type||"");var a=e.Body&&(e.UploadAddMetaMd5||r.options.UploadAddMetaMd5);a&&o&&o.setParams({md5StartTime:(new Date).getTime()}),i.getBodyMd5(a,e.Body,(function(n){n&&(e.Headers["x-cos-meta-md5"]=n),a&&o&&o.setParams({md5EndTime:(new Date).getTime()}),f.call(r,{Action:"name/cos:InitiateMultipartUpload",method:"POST",Bucket:e.Bucket,Region:e.Region,Key:e.Key,action:"uploads",headers:e.Headers,qs:e.Query,tracker:o},(function(e,r){return e?(o&&o.parent&&o.parent.setParams({errorNode:"multipartInit"}),t(e)):(r=i.clone(r||{}))&&r.InitiateMultipartUploadResult?t(null,i.extend(r.InitiateMultipartUploadResult,{statusCode:r.statusCode,headers:r.headers})):void t(null,r)}))}),e.onHashProgress)},multipartUpload:function(e,t){var r=this;i.getFileSize("multipartUpload",e,(function(){var n=e.tracker,o=r.options.UploadCheckContentMd5;o&&n&&n.setParams({md5StartTime:(new Date).getTime()}),i.getBodyMd5(o,e.Body,(function(a){a&&(e.Headers["Content-MD5"]=i.b64(a)),o&&n&&n.setParams({md5EndTime:(new Date).getTime()}),n&&n.setParams({partNumber:e.PartNumber}),f.call(r,{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,tracker:n},(function(e,r){if(e)return n&&n.parent&&n.parent.setParams({errorNode:"multipartUpload"}),t(e);t(null,{ETag:i.attr(r.headers,"etag",""),statusCode:r.statusCode,headers:r.headers})}))}))}))},multipartComplete:function(e,t){for(var r=this,n=e.UploadId,o=e.Parts,a=e.tracker,s=0,c=o.length;s<c;s++)o[s].ETag&&0===o[s].ETag.indexOf('"')||(o[s].ETag='"'+o[s].ETag+'"');var l=i.json2xml({CompleteMultipartUpload:{Part:o}});l=l.replace(/\n\s*/g,"");var d=e.Headers;d["Content-Type"]="application/xml",d["Content-MD5"]=i.b64(i.md5(l)),f.call(this,{Action:"name/cos:CompleteMultipartUpload",method:"POST",Bucket:e.Bucket,Region:e.Region,Key:e.Key,qs:{uploadId:n},body:l,headers:d,tracker:a},(function(n,o){if(n)return a&&a.parent&&a.parent.setParams({errorNode:"multipartComplete"}),t(n);var s=u({ForcePathStyle:r.options.ForcePathStyle,protocol:r.options.Protocol,domain:r.options.Domain,bucket:e.Bucket,region:e.Region,object:e.Key,isLocation:!0}),c=o.CompleteMultipartUploadResult||{};if(c.ProcessResults&&(c.UploadResult={OriginalInfo:{Key:c.Key,Location:s,ETag:c.ETag,ImageInfo:c.ImageInfo},ProcessResults:c.ProcessResults},delete c.ImageInfo,delete c.ProcessResults),c.CallbackResult){var l=c.CallbackResult;if("200"===l.Status&&l.CallbackBody)try{c.CallbackBody=JSON.parse(i.decodeBase64(l.CallbackBody))}catch(e){c.CallbackBody={}}else c.CallbackError=l.Error||{};delete c.CallbackResult}if(c.ReturnBodyResult){var d=c.ReturnBodyResult;if("200"===d.Status&&d.ReturnBody)try{c.ReturnBody=JSON.parse(i.decodeBase64(d.ReturnBody))}catch(e){c.ReturnBody={}}else c.ReturnError={Code:d.Code,Message:d.Message,Status:d.Status};delete c.ReturnBodyResult}var p=i.extend(c,{Location:s,statusCode:o.statusCode,headers:o.headers});t(null,p)}))},multipartList:function(e,t){var r={};r.delimiter=e.Delimiter,r["encoding-type"]=e.EncodingType,r.prefix=e.Prefix||"",r["max-uploads"]=e.MaxUploads,r["key-marker"]=e.KeyMarker,r["upload-id-marker"]=e.UploadIdMarker,r=i.clearKey(r);var n=e.tracker;n&&n.setParams({signStartTime:(new Date).getTime()}),f.call(this,{Action:"name/cos:ListMultipartUploads",ResourceKey:r.prefix,method:"GET",Bucket:e.Bucket,Region:e.Region,headers:e.Headers,qs:r,action:"uploads",tracker:n},(function(e,r){if(e)return n&&n.parent&&n.parent.setParams({errorNode:"multipartList"}),t(e);if(r&&r.ListMultipartUploadsResult){var o=r.ListMultipartUploadsResult.Upload||[];o=i.isArray(o)?o:[o],r.ListMultipartUploadsResult.Upload=o}var a=i.clone(r.ListMultipartUploadsResult||{});i.extend(a,{statusCode:r.statusCode,headers:r.headers}),t(null,a)}))},multipartListPart:function(e,t){var r={},n=e.tracker;r.uploadId=e.UploadId,r["encoding-type"]=e.EncodingType,r["max-parts"]=e.MaxParts,r["part-number-marker"]=e.PartNumberMarker,f.call(this,{Action:"name/cos:ListParts",method:"GET",Bucket:e.Bucket,Region:e.Region,Key:e.Key,headers:e.Headers,qs:r,tracker:n},(function(e,r){if(e)return n&&n.parent&&n.parent.setParams({errorNode:"multipartListPart"}),t(e);var o=r.ListPartsResult||{},a=o.Part||[];a=i.isArray(a)?a:[a],o.Part=a;var s=i.clone(o);i.extend(s,{statusCode:r.statusCode,headers:r.headers}),t(null,s)}))},multipartAbort:function(e,t){var r={};r.uploadId=e.UploadId,f.call(this,{Action:"name/cos:AbortMultipartUpload",method:"DELETE",Bucket:e.Bucket,Region:e.Region,Key:e.Key,headers:e.Headers,qs:r,tracker:e.tracker},(function(e,r){if(e)return t(e);t(null,{statusCode:r.statusCode,headers:r.headers})}))},request:function(e,t){f.call(this,{method:e.Method,Bucket:e.Bucket,Region:e.Region,Key:e.Key,action:e.Action,headers:e.Headers,qs:e.Query,body:e.Body,Url:e.Url,rawBody:e.RawBody,DataType:e.DataType,tracker:e.tracker},(function(e,r){if(e)return t(e);r&&r.body&&(r.Body=r.body,delete r.body),t(e,r)}))},getObjectUrl:function(e,t){var r=this,n=void 0===e.UseAccelerate?r.options.UseAccelerate:e.UseAccelerate,o=u({ForcePathStyle:r.options.ForcePathStyle,protocol:e.Protocol||r.options.Protocol,domain:e.Domain||r.options.Domain,bucket:e.Bucket,region:n?"accelerate":e.Region,object:e.Key}),a="";e.Query&&(a+=i.obj2str(e.Query)),e.QueryString&&(a+=(a?"&":"")+e.QueryString);var s=o;if(void 0!==e.Sign&&!e.Sign)return a&&(s+="?"+a),t(null,{Url:s}),s;var c=l.call(this,{Bucket:e.Bucket,Region:e.Region,UseAccelerate:e.UseAccelerate,Url:o}),p=d.call(this,{Action:"PUT"===(e.Method||"").toUpperCase()?"name/cos:PutObject":"name/cos:GetObject",Bucket:e.Bucket||"",Region:e.Region||"",Method:e.Method||"get",Key:e.Key,Expires:e.Expires,Headers:e.Headers,Query:e.Query,SignHost:c,ForceSignHost:!1!==e.ForceSignHost&&r.options.ForceSignHost},(function(e,r){if(t)if(e)t(e);else{var n=o;n+="?"+(r.Authorization.indexOf("q-signature")>-1?function(e){var t=e.match(/q-url-param-list.*?(?=&)/g)[0],r="q-url-param-list="+encodeURIComponent(t.replace(/q-url-param-list=/,"")).toLowerCase(),n=new RegExp(t,"g");return e.replace(n,r)}(r.Authorization):"sign="+encodeURIComponent(r.Authorization)),r.SecurityToken&&(n+="&x-cos-security-token="+r.SecurityToken),r.ClientIP&&(n+="&clientIP="+r.ClientIP),r.ClientUA&&(n+="&clientUA="+r.ClientUA),r.Token&&(n+="&token="+r.Token),a&&(n+="&"+a),setTimeout((function(){t(null,{Url:n})}))}}));return p?(s+="?"+p.Authorization+(p.SecurityToken?"&x-cos-security-token="+p.SecurityToken:""),a&&(s+="&"+a)):a&&(s+="?"+a),s},getAuth:function(e){return i.getAuth({SecretId:e.SecretId||this.options.SecretId||"",SecretKey:e.SecretKey||this.options.SecretKey||"",Bucket:e.Bucket,Region:e.Region,Method:e.Method,Key:e.Key,Query:e.Query,Headers:e.Headers,Expires:e.Expires,UseRawKey:this.options.UseRawKey,SystemClockOffset:this.options.SystemClockOffset})}};e.exports.init=function(e,t){t.transferToTaskMethod(m,"putObject"),i.each(m,(function(t,r){e.prototype[r]=i.apiWrapper(r,t),function(e,t,r){i.each(["Cors","Acl"],(function(n){if(e.slice(-n.length)===n){var o=e.slice(0,-n.length)+n.toUpperCase(),a=i.apiWrapper(e,t);r[o]=function(){a.apply(this,arguments)}}}))}(r,t,e.prototype)}))}},function(e,t,r){var n=r(0),o=function(e){switch(n(e)){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},i=function(e,t,r){var n={},o=t.getAllResponseHeaders();return o&&o.length>0&&o.trim().split("\n").forEach((function(e){if(e){var t=e.indexOf(":"),r=e.substr(0,t).trim().toLowerCase(),o=e.substr(t+1).trim();n[r]=o}})),{error:e,statusCode:t.status,statusMessage:t.statusText,headers:n,body:r}},a=function(e,t){return t||"text"!==t?e.response:e.responseText};e.exports=function(e,t){var r,s,c,u,l=(e.method||"GET").toUpperCase(),d=e.url;if(e.qs){var p=(r=e.qs,s=s||"&",c=c||"=",null===r&&(r=void 0),"object"===n(r)?Object.keys(r).map((function(e){var t=encodeURIComponent(o(e))+c;return Array.isArray(r[e])?r[e].map((function(e){return t+encodeURIComponent(o(e))})).join(s):t+encodeURIComponent(o(r[e]))})).filter(Boolean).join(s):u?encodeURIComponent(o(u))+c+encodeURIComponent(o(r)):"");p&&(d+=(-1===d.indexOf("?")?"?":"&")+p)}var h=new XMLHttpRequest;if(h.open(l,d,!0),h.responseType=e.dataType||"text",e.xhrFields)for(var f in e.xhrFields)h[f]=e.xhrFields[f];var g=e.headers;if(g)for(var m in g)g.hasOwnProperty(m)&&"content-length"!==m.toLowerCase()&&"user-agent"!==m.toLowerCase()&&"origin"!==m.toLowerCase()&&"host"!==m.toLowerCase()&&h.setRequestHeader(m,g[m]);return e.onProgress&&h.upload&&(h.upload.onprogress=e.onProgress),e.onDownloadProgress&&(h.onprogress=e.onDownloadProgress),e.timeout&&(h.timeout=e.timeout),h.ontimeout=function(e){var r=new Error("timeout");t(i(r,h))},h.onload=function(){t(i(null,h,a(h,e.dataType)))},h.onerror=function(r){var n=a(h,e.dataType);if(n)t(i(null,h,n));else{var o=h.statusText;o||0!==h.status||(o=new Error("CORS blocked or network error")),t(i(o,h,n))}},h.send(e.body||""),h}},function(e,t,r){var n=r(0),o=r(8),i=r(34),a=r(7).EventProxy,s=r(1),c=r(5);function u(e,t){var r=e.TaskId,n=e.Bucket,c=e.Region,u=e.Key,p=e.StorageClass,h=this,f={},g=e.FileSize,m=e.SliceSize,y=Math.ceil(g/m),k=0,C=s.throttleOnProgress.call(h,g,e.onHashProgress),v=function(t,r){var n=t.length;if(0===n)return r(null,!0);if(n>y)return r(null,!1);if(n>1&&Math.max(t[0].Size,t[1].Size)!==m)return r(null,!1);!function o(i){if(i<n){var a=t[i];!function(t,r){var n=m*(t-1),o=Math.min(n+m,g),i=o-n;f[t]?r(null,{PartNumber:t,ETag:f[t],Size:i}):s.fileSlice(e.Body,n,o,!1,(function(e){s.getFileMd5(e,(function(e,n){if(e)return r(s.error(e));var o='"'+n+'"';f[t]=o,1,C({loaded:k+=i,total:g}),r(null,{PartNumber:t,ETag:o,Size:i})}))}))}(a.PartNumber,(function(e,t){t&&t.ETag===a.ETag&&t.Size===a.Size?o(i+1):r(null,!1)}))}else r(null,!0)}(0)},b=new a;b.on("error",(function(e){if(h._isRunningTask(r))return t(e)})),b.on("upload_id_available",(function(e){var r={},n=[];s.each(e.PartList,(function(e){r[e.PartNumber]=e}));for(var o=1;o<=y;o++){var i=r[o];i?(i.PartNumber=o,i.Uploaded=!0):i={PartNumber:o,ETag:null,Uploaded:!1},n.push(i)}e.PartList=n,t(null,e)})),b.on("no_available_upload_id",(function(){if(h._isRunningTask(r)){var o=s.extend({Bucket:n,Region:c,Key:u,Query:s.clone(e.Query),StorageClass:p,Body:e.Body,calledBySdk:"sliceUploadFile",tracker:e.tracker},e),i=s.clone(e.Headers);delete i["x-cos-mime-limit"],o.Headers=i,h.multipartInit(o,(function(e,n){if(h._isRunningTask(r)){if(e)return b.emit("error",e);var o=n.UploadId;if(!o)return t(s.error(new Error("no such upload id")));b.emit("upload_id_available",{UploadId:o,PartList:[]})}}))}})),b.on("has_and_check_upload_id",(function(t){t=t.reverse(),i.eachLimit(t,1,(function(t,i){h._isRunningTask(r)&&(o.using[t]?i():d.call(h,{Bucket:n,Region:c,Key:u,UploadId:t,tracker:e.tracker},(function(e,n){if(h._isRunningTask(r)){if(e)return o.removeUsing(t),b.emit("error",e);var a=n.PartList;a.forEach((function(e){e.PartNumber*=1,e.Size*=1,e.ETag=e.ETag||""})),v(a,(function(e,n){if(h._isRunningTask(r))return e?b.emit("error",e):void(n?i({UploadId:t,PartList:a}):i())}))}})))}),(function(e){h._isRunningTask(r)&&(C(null,!0),e&&e.UploadId?b.emit("upload_id_available",e):b.emit("no_available_upload_id"))}))})),b.on("seek_local_avail_upload_id",(function(t){var i=o.getFileId(e.Body,e.ChunkSize,n,u),a=o.getUploadIdList.call(h,i);if(i&&a){!function i(l){if(l>=a.length)b.emit("has_and_check_upload_id",t);else{var p=a[l];if(!s.isInArray(t,p))return o.removeUploadId.call(h,p),void i(l+1);o.using[p]?i(l+1):d.call(h,{Bucket:n,Region:c,Key:u,UploadId:p,tracker:e.tracker},(function(e,t){h._isRunningTask(r)&&(e?(o.removeUploadId.call(h,p),i(l+1)):b.emit("upload_id_available",{UploadId:p,PartList:t.PartList}))}))}}(0)}else b.emit("has_and_check_upload_id",t)})),b.on("get_remote_upload_id_list",(function(){l.call(h,{Bucket:n,Region:c,Key:u,tracker:e.tracker},(function(t,i){if(h._isRunningTask(r)){if(t)return b.emit("error",t);var a=s.filter(i.UploadList,(function(e){return e.Key===u&&(!p||e.StorageClass.toUpperCase()===p.toUpperCase())})).reverse().map((function(e){return e.UploadId||e.UploadID}));if(a.length)b.emit("seek_local_avail_upload_id",a);else{var c,l=o.getFileId(e.Body,e.ChunkSize,n,u);l&&(c=o.getUploadIdList.call(h,l))&&s.each(c,(function(e){o.removeUploadId.call(h,e)})),b.emit("no_available_upload_id")}}}))})),b.emit("get_remote_upload_id_list")}function l(e,t){var r=this,n=[],o={Bucket:e.Bucket,Region:e.Region,Prefix:e.Key,calledBySdk:e.calledBySdk||"sliceUploadFile",tracker:e.tracker};!function e(){r.multipartList(o,(function(r,i){if(r)return t(r);n.push.apply(n,i.Upload||[]),"true"===i.IsTruncated?(o.KeyMarker=i.NextKeyMarker,o.UploadIdMarker=i.NextUploadIdMarker,e()):t(null,{UploadList:n})}))}()}function d(e,t){var r=this,n=[],o={Bucket:e.Bucket,Region:e.Region,Key:e.Key,UploadId:e.UploadId,calledBySdk:"sliceUploadFile",tracker:e.tracker};!function e(){r.multipartListPart(o,(function(r,i){if(r)return t(r);n.push.apply(n,i.Part||[]),"true"===i.IsTruncated?(o.PartNumberMarker=i.NextPartNumberMarker,e()):t(null,{PartList:n})}))}()}function p(e,t){var r=this,n=e.TaskId,o=e.Bucket,a=e.Region,c=e.Key,u=e.UploadData,l=e.FileSize,d=e.SliceSize,p=Math.min(e.AsyncLimit||r.options.ChunkParallelLimit||1,256),f=e.Body,g=Math.ceil(l/d),m=0,y=e.ServerSideEncryption,k=e.Headers,C=s.filter(u.PartList,(function(e){return e.Uploaded&&(m+=e.PartNumber>=g&&l%d||d),!e.Uploaded})),v=e.onProgress;i.eachLimit(C,p,(function(t,i){if(r._isRunningTask(n)){var s=t.PartNumber,p=Math.min(l,t.PartNumber*d)-(t.PartNumber-1)*d,g=0;h.call(r,{TaskId:n,Bucket:o,Region:a,Key:c,SliceSize:d,FileSize:l,PartNumber:s,ServerSideEncryption:y,Body:f,UploadData:u,Headers:k,onProgress:function(e){m+=e.loaded-g,g=e.loaded,v({loaded:m,total:l})},tracker:e.tracker},(function(e,o){r._isRunningTask(n)&&(e||o.ETag||(e='get ETag error, please add "ETag" to CORS ExposeHeader setting.( 获取ETag失败,请在CORS ExposeHeader设置中添加ETag,请参考文档:https://cloud.tencent.com/document/product/436/13318 )'),e?m-=g:(m+=p-g,t.ETag=o.ETag),v({loaded:m,total:l}),i(e||null,o))}))}}),(function(e){if(r._isRunningTask(n))return e?t(e):void t(null,{UploadId:u.UploadId,SliceList:u.PartList})}))}function h(e,t){var r=this,n=e.TaskId,o=e.Bucket,a=e.Region,c=e.Key,u=e.FileSize,l=e.Body,d=1*e.PartNumber,p=e.SliceSize,h=e.ServerSideEncryption,f=e.UploadData,g=e.Headers||{},m=r.options.ChunkRetryTimes+1,y=p*(d-1),k=p,C=y+p;C>u&&(k=(C=u)-y);var v=["x-cos-traffic-limit","x-cos-mime-limit"],b={};s.each(g,(function(e,t){v.indexOf(t)>-1&&(b[t]=e)}));var S=f.PartList[d-1];i.retry(m,(function(t){r._isRunningTask(n)&&s.fileSlice(l,y,C,!0,(function(i){r.multipartUpload({TaskId:n,Bucket:o,Region:a,Key:c,ContentLength:k,PartNumber:d,UploadId:f.UploadId,ServerSideEncryption:h,Body:i,Headers:b,onProgress:e.onProgress,calledBySdk:"sliceUploadFile",tracker:e.tracker},(function(e,o){if(r._isRunningTask(n))return e?t(e):(S.Uploaded=!0,t(null,o))}))}))}),(function(e,o){if(r._isRunningTask(n))return t(e,o)}))}function f(e,t){var r=e.Bucket,n=e.Region,o=e.Key,a=e.UploadId,s=e.SliceList,c=this,u=this.options.ChunkRetryTimes+1,l=e.Headers,d=s.map((function(e){return{PartNumber:e.PartNumber,ETag:e.ETag}}));i.retry(u,(function(t){c.multipartComplete({Bucket:r,Region:n,Key:o,UploadId:a,Parts:d,Headers:l,calledBySdk:"sliceUploadFile",tracker:e.tracker},t)}),(function(e,r){t(e,r)}))}function g(e,t){var r=e.Bucket,n=e.Region,o=e.Key,a=e.AbortArray,s=e.AsyncLimit||1,c=this,u=0,l=new Array(a.length);i.eachLimit(a,s,(function(t,i){var a=u;if(o&&o!==t.Key)return l[a]={error:{KeyNotMatch:!0}},void i(null);var s=t.UploadId||t.UploadID;c.multipartAbort({Bucket:r,Region:n,Key:t.Key,Headers:e.Headers,UploadId:s},(function(e){var o={Bucket:r,Region:n,Key:t.Key,UploadId:s};l[a]={error:e,task:o},i(null)})),u++}),(function(e){if(e)return t(e);for(var r=[],n=[],o=0,i=l.length;o<i;o++){var a=l[o];a.task&&(a.error?n.push(a.task):r.push(a.task))}return t(null,{successList:r,errorList:n})}))}function m(e,t){var r=e.TaskId,n=e.Bucket,o=e.Region,a=e.Key,s=e.CopySource,c=e.UploadId,u=1*e.PartNumber,l=e.CopySourceRange,d=this.options.ChunkRetryTimes+1,p=this;i.retry(d,(function(t){p.uploadPartCopy({TaskId:r,Bucket:n,Region:o,Key:a,CopySource:s,UploadId:c,PartNumber:u,CopySourceRange:l,tracker:e.tracker,calledBySdk:e.calledBySdk},(function(e,r){t(e||null,r)}))}),(function(e,r){return t(e,r)}))}var y={sliceUploadFile:function(e,t){var r,n,i=this,c=new a,l=e.TaskId,d=e.Bucket,h=e.Region,g=e.Key,m=e.Body,y=e.ChunkSize||e.SliceSize||i.options.ChunkSize,k=e.AsyncLimit,C=e.StorageClass,v=e.ServerSideEncryption,b=e.onHashProgress,S=e.tracker;S&&S.setParams({chunkSize:y}),c.on("error",(function(r){if(i._isRunningTask(l))return e.UploadData.UploadId&&o.removeUsing(e.UploadData.UploadId),r.UploadId=e.UploadData.UploadId||"",t(r)})),c.on("upload_complete",(function(r){var n=s.extend({UploadId:e.UploadData.UploadId||""},r);t(null,n)})),c.on("upload_slice_complete",(function(t){var a={};s.each(e.Headers,(function(e,t){var r=t.toLowerCase();(0===r.indexOf("x-cos-meta-")||["pic-operations","x-cos-callback","x-cos-callback-var","x-cos-return-body"].includes(r))&&(a[t]=e)})),f.call(i,{Bucket:d,Region:h,Key:g,UploadId:t.UploadId,SliceList:t.SliceList,Headers:a,tracker:S},(function(e,a){if(i._isRunningTask(l)){if(o.removeUsing(t.UploadId),e)return n(null,!0),c.emit("error",e);o.removeUploadId.call(i,t.UploadId),n({loaded:r,total:r},!0),c.emit("upload_complete",a)}}))})),c.on("get_upload_data_finish",(function(t){var a=o.getFileId(m,e.ChunkSize,d,g);a&&o.saveUploadId.call(i,a,t.UploadId,i.options.UploadIdCacheLimit),o.setUsing(t.UploadId),n(null,!0),p.call(i,{TaskId:l,Bucket:d,Region:h,Key:g,Body:m,FileSize:r,SliceSize:y,AsyncLimit:k,ServerSideEncryption:v,UploadData:t,Headers:e.Headers,onProgress:n,tracker:S},(function(e,t){if(i._isRunningTask(l))return e?(n(null,!0),c.emit("error",e)):void c.emit("upload_slice_complete",t)}))})),c.on("get_file_size_finish",(function(){if(n=s.throttleOnProgress.call(i,r,e.onProgress),e.UploadData.UploadId)c.emit("get_upload_data_finish",e.UploadData);else{var t=s.extend({TaskId:l,Bucket:d,Region:h,Key:g,Headers:e.Headers,StorageClass:C,Body:m,FileSize:r,SliceSize:y,onHashProgress:b,tracker:S},e);u.call(i,t,(function(t,r){if(i._isRunningTask(l)){if(t)return c.emit("error",t);e.UploadData.UploadId=r.UploadId,e.UploadData.PartList=r.PartList,c.emit("get_upload_data_finish",e.UploadData)}}))}})),r=e.ContentLength,delete e.ContentLength,!e.Headers&&(e.Headers={}),s.each(e.Headers,(function(t,r){"content-length"===r.toLowerCase()&&delete e.Headers[r]})),function(){for(var t=[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,5120],n=1048576,o=0;o<t.length&&!(r/(n=1024*t[o]*1024)<=i.options.MaxPartNumber);o++);e.ChunkSize=e.SliceSize=y=Math.max(y,n)}(),0===r?(e.Body="",e.ContentLength=0,e.SkipTask=!0,i.putObject(e,t)):c.emit("get_file_size_finish")},abortUploadTask:function(e,t){var r=e.Bucket,n=e.Region,o=e.Key,i=e.UploadId,c=e.Level||"task",u=e.AsyncLimit,d=this,p=new a;if(p.on("error",(function(e){return t(e)})),p.on("get_abort_array",(function(i){g.call(d,{Bucket:r,Region:n,Key:o,Headers:e.Headers,AsyncLimit:u,AbortArray:i},t)})),"bucket"===c)l.call(d,{Bucket:r,Region:n,calledBySdk:"abortUploadTask"},(function(e,r){if(e)return t(e);p.emit("get_abort_array",r.UploadList||[])}));else if("file"===c){if(!o)return t(s.error(new Error("abort_upload_task_no_key")));l.call(d,{Bucket:r,Region:n,Key:o,calledBySdk:"abortUploadTask"},(function(e,r){if(e)return t(e);p.emit("get_abort_array",r.UploadList||[])}))}else{if("task"!==c)return t(s.error(new Error("abort_unknown_level")));if(!i)return t(s.error(new Error("abort_upload_task_no_id")));if(!o)return t(s.error(new Error("abort_upload_task_no_key")));p.emit("get_abort_array",[{Key:o,UploadId:i}])}},uploadFile:function(e,t){var r=this,o=void 0===e.SliceSize?r.options.SliceSize:e.SliceSize,i=[],a=e.Body,u=a.size||a.length||0,l={TaskId:""};if(r.options.EnableReporter){var d=r.options.UseAccelerate||"string"==typeof r.options.Domain&&r.options.Domain.includes("accelerate."),p=u>o?"sliceUploadFile":"putObject";e.tracker=new c({Beacon:r.options.BeaconReporter,clsReporter:r.options.ClsReporter,bucket:e.Bucket,region:e.Region,apiName:"uploadFile",realApi:p,fileKey:e.Key,fileSize:u,accelerate:d,deepTracker:r.options.DeepTracker,customId:r.options.CustomId,delay:r.options.TrackerDelay})}s.each(e,(function(e,t){"object"!==n(e)&&"function"!=typeof e&&(l[t]=e)}));var h=e.onTaskReady;e.onTaskReady=function(e){l.TaskId=e,h&&h(e)};var f=u>o?"sliceUploadFile":"putObject",g=e.onFileFinish;i.push({api:f,params:e,callback:function(r,n){e.tracker&&e.tracker.report(r,n),g&&g(r,n,l),t&&t(r,n)}}),r._addTasks(i)},uploadFiles:function(e,t){var r=this,o=void 0===e.SliceSize?r.options.SliceSize:e.SliceSize,i=0,a=0,u=s.throttleOnProgress.call(r,a,e.onProgress),l=e.files.length,d=e.onFileFinish,p=Array(l),h=function(e,r,n){u(null,!0),d&&d(e,r,n),p[n.Index]={options:n,error:e,data:r},--l<=0&&t&&t(null,{files:p})},f=[];s.each(e.files,(function(e,t){!function(){var l=e.Body,d=l.size||l.length||0,p={Index:t,TaskId:""};if(!r.options.UseRawKey&&e.Key&&"/"===e.Key.substr(0,1)&&(e.Key=e.Key.substr(1)),i+=d,r.options.EnableReporter){var g=r.options.UseAccelerate||"string"==typeof r.options.Domain&&r.options.Domain.includes("accelerate."),m=d>o?"sliceUploadFile":"putObject";e.tracker=new c({Beacon:r.options.BeaconReporter,clsReporter:r.options.ClsReporter,bucket:e.Bucket,region:e.Region,apiName:"uploadFiles",realApi:m,fileKey:e.Key,fileSize:d,accelerate:g,deepTracker:r.options.DeepTracker,customId:r.options.CustomId,delay:r.options.TrackerDelay})}s.each(e,(function(e,t){"object"!==n(e)&&"function"!=typeof e&&(p[t]=e)}));var y=e.onTaskReady;e.onTaskReady=function(e){p.TaskId=e,y&&y(e)};var k=0,C=e.onProgress;e.onProgress=function(e){a=a-k+e.loaded,k=e.loaded,C&&C(e),u({loaded:a,total:i})};var v=d>o?"sliceUploadFile":"putObject",b=e.onFileFinish;f.push({api:v,params:e,callback:function(t,r){e.tracker&&e.tracker.report(t,r),b&&b(t,r),h&&h(t,r,p)}})}()})),r._addTasks(f)},sliceCopyFile:function(e,t){var r=new a,n=this,c=e.Bucket,u=e.Region,l=e.Key,p=e.CopySource,h=s.getSourceParams.call(this,p);if(h){var f=h.Bucket,g=h.Region,y=decodeURIComponent(h.Key),k=void 0===e.CopySliceSize?n.options.CopySliceSize:e.CopySliceSize;k=Math.max(0,k);var C,v,b=e.CopyChunkSize||this.options.CopyChunkSize,S=this.options.CopyChunkParallelLimit,x=this.options.ChunkRetryTimes+1,T=0,R=0,B={},A={},P={};r.on("copy_slice_complete",(function(r){var a={};s.each(e.Headers,(function(e,t){0===t.toLowerCase().indexOf("x-cos-meta-")&&(a[t]=e)}));var d=s.map(r.PartList,(function(e){return{PartNumber:e.PartNumber,ETag:e.ETag}}));i.retry(x,(function(t){n.multipartComplete({Bucket:c,Region:u,Key:l,UploadId:r.UploadId,Parts:d,tracker:e.tracker,calledBySdk:"sliceCopyFile"},t)}),(function(e,n){if(o.removeUsing(r.UploadId),e)return v(null,!0),t(e);o.removeUploadId(r.UploadId),v({loaded:C,total:C},!0),t(null,n)}))})),r.on("get_copy_data_finish",(function(a){var d=o.getCopyFileId(p,B,b,c,l);d&&o.saveUploadId(d,a.UploadId,n.options.UploadIdCacheLimit),o.setUsing(a.UploadId);var h=s.filter(a.PartList,(function(e){return e.Uploaded&&(R+=e.PartNumber>=T&&C%b||b),!e.Uploaded}));i.eachLimit(h,S,(function(t,r){var o=t.PartNumber,s=t.CopySourceRange,d=t.end-t.start;i.retry(x,(function(t){m.call(n,{Bucket:c,Region:u,Key:l,CopySource:p,UploadId:a.UploadId,PartNumber:o,CopySourceRange:s,tracker:e.tracker,calledBySdk:"sliceCopyFile"},t)}),(function(e,n){if(e)return r(e);v({loaded:R+=d,total:C}),t.ETag=n.ETag,r(e||null,n)}))}),(function(e){if(e)return o.removeUsing(a.UploadId),v(null,!0),t(e);r.emit("copy_slice_complete",a)}))})),r.on("get_chunk_size_finish",(function(){var i=function(){n.multipartInit({Bucket:c,Region:u,Key:l,Headers:P,tracker:e.tracker,calledBySdk:"sliceCopyFile"},(function(n,o){if(n)return t(n);e.UploadId=o.UploadId,r.emit("get_copy_data_finish",{UploadId:e.UploadId,PartList:e.PartList})}))},a=o.getCopyFileId(p,B,b,c,l),h=o.getUploadIdList(a);if(!a||!h)return i();!function t(a){if(a>=h.length)return i();var p=h[a];if(o.using[p])return t(a+1);d.call(n,{Bucket:c,Region:u,Key:l,UploadId:p,tracker:e.tracker,calledBySdk:"sliceCopyFile"},(function(n,i){if(n)o.removeUploadId(p),t(a+1);else{if(o.using[p])return t(a+1);var c={},u=0;s.each(i.PartList,(function(e){var t=parseInt(e.Size),r=u+t-1;c[e.PartNumber+"|"+u+"|"+r]=e.ETag,u+=t})),s.each(e.PartList,(function(e){var t=c[e.PartNumber+"|"+e.start+"|"+e.end];t&&(e.ETag=t,e.Uploaded=!0)})),r.emit("get_copy_data_finish",{UploadId:p,PartList:e.PartList})}}))}(0)})),r.on("get_file_size_finish",(function(){if(function(){for(var t=[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,5120],r=1048576,o=0;o<t.length&&!(C/(r=1024*t[o]*1024)<=n.options.MaxPartNumber);o++);e.ChunkSize=b=Math.max(b,r),T=Math.ceil(C/b);for(var i=[],a=1;a<=T;a++){var s=(a-1)*b,c=a*b<C?a*b-1:C-1,u={PartNumber:a,start:s,end:c,CopySourceRange:"bytes="+s+"-"+c};i.push(u)}e.PartList=i}(),(P="Replaced"===e.Headers["x-cos-metadata-directive"]?e.Headers:A)["x-cos-storage-class"]=e.Headers["x-cos-storage-class"]||A["x-cos-storage-class"],P=s.clearKey(P),"ARCHIVE"===A["x-cos-storage-class"]||"DEEP_ARCHIVE"===A["x-cos-storage-class"]){var o=A["x-cos-restore"];if(!o||'ongoing-request="true"'===o)return void t(s.error(new Error("Unrestored archive object is not allowed to be copied")))}delete P["x-cos-copy-source"],delete P["x-cos-metadata-directive"],delete P["x-cos-copy-source-If-Modified-Since"],delete P["x-cos-copy-source-If-Unmodified-Since"],delete P["x-cos-copy-source-If-Match"],delete P["x-cos-copy-source-If-None-Match"],r.emit("get_chunk_size_finish")})),n.headObject({Bucket:f,Region:g,Key:y,tracker:e.tracker,calledBySdk:"sliceCopyFile"},(function(o,i){if(o)o.statusCode&&404===o.statusCode?t(s.error(o,{ErrorStatus:y+" Not Exist"})):t(o);else if(void 0!==(C=e.FileSize=i.headers["content-length"])&&C)if(e.tracker&&e.tracker.setParams({httpSize:C}),v=s.throttleOnProgress.call(n,C,e.onProgress),C<=k)e.Headers["x-cos-metadata-directive"]||(e.Headers["x-cos-metadata-directive"]="Copy"),n.putObjectCopy(Object.assign(e,{calledBySdk:"sliceCopyFile"}),(function(e,r){if(e)return v(null,!0),t(e);v({loaded:C,total:C},!0),t(e,r)}));else{var a=i.headers;B=a,A={"Cache-Control":a["cache-control"],"Content-Disposition":a["content-disposition"],"Content-Encoding":a["content-encoding"],"Content-Type":a["content-type"],Expires:a.expires,"x-cos-storage-class":a["x-cos-storage-class"]},s.each(a,(function(e,t){var r="x-cos-meta-";0===t.indexOf(r)&&t.length>11&&(A[t]=e)})),r.emit("get_file_size_finish")}else t(s.error(new Error('get Content-Length error, please add "Content-Length" to CORS ExposeHeader setting.( 获取Content-Length失败,请在CORS ExposeHeader设置中添加Content-Length,请参考文档:https://cloud.tencent.com/document/product/436/13318 )')))}))}else t(s.error(new Error("CopySource format error")))}};e.exports.init=function(e,t){t.transferToTaskMethod(y,"sliceUploadFile"),s.each(y,(function(t,r){e.prototype[r]=s.apiWrapper(r,t)}))}},function(e,t){var r={eachLimit:function(e,t,r,n){if(n=n||function(){},!e.length||t<=0)return n();var o=0,i=0,a=0;!function s(){if(o>=e.length)return n();for(;a<t&&i<e.length;)a+=1,r(e[(i+=1)-1],(function(t){t?(n(t),n=function(){}):(a-=1,(o+=1)>=e.length?n():s())}))}()},retry:function(e,t,r){e<1?r():function n(o){t((function(t,i){t&&o<e?n(o+1):r(t,i)}))}(1)}};e.exports=r}])}));