@cloudbase/js-sdk
Version:
cloudbase javascript sdk
1 lines • 93.1 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_storage",[],e):"object"==typeof exports?exports.cloudbase_storage=e():t.cloudbase_storage=e()}("undefined"!=typeof window?window:this,()=>(()=>{var t={829:(t,e,r)=>{"use strict";var n;r.r(e),r.d(e,{AbstractSDKRequest:()=>o,AbstractStorage:()=>i,StorageType:()=>n,formatUrl:()=>a}),function(t){t.local="local",t.none="none",t.session="session"}(n||(n={}));var o=function(){},i=function(){};function a(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";for(var i in r)""===o?!n&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},891:function(t,e,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)},o=this&&this.__decorate||function(t,e,r,n){var o,i=arguments.length,a=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},i=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},a=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(a,s)}c((n=n.apply(t,e||[])).next())})},s=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseStorage=e.COMPONENT_NAME=e.EUploadMethod=void 0;var c,u=r(877),l=r(90),d=r(388);!function(t){t.put="put",t.post="post"}(c=e.EUploadMethod||(e.EUploadMethod={}));var f=u.constants.getSdkName,h=u.constants.ERRORS,p=u.constants.COMMUNITY_SITE_URL,v=u.utils.isArray,y=u.utils.isString,g=u.utils.isPalinObject,m=u.utils.execCallback,b=u.helpers.catchErrorsDecorator;e.COMPONENT_NAME="storage";var w=function(t,e,r){return a(void 0,void 0,void 0,function(){var o,i,a;return s(this,function(s){switch(s.label){case 0:return[4,t.gateWay({path:"storages",name:"get-objects-upload-info",data:[n({objectId:e.path},e.signedHeader?{signedHeader:e.signedHeader}:{})]},r)];case 1:return o=s.sent(),i=(null===(a=o.data)||void 0===a?void 0:a[0])||{},[2,n(n({},o),{data:n(n({},i.code?n({},i):{}),{authorization:i.authorization,token:i.token,url:i.uploadUrl,fileId:i.cloudObjectId,cosFileId:i.cloudObjectMeta,download_url:i.downloadUrl})})]}})})},O=function(t,e,r){return a(void 0,void 0,void 0,function(){var o,i;return s(this,function(a){switch(a.label){case 0:return[4,t.gateWay({path:"storages",name:"get-objects-download-info",data:e.convertedFileList.map(function(t){return{cloudObjectId:t.fileid}})},r)];case 1:return o=a.sent(),[2,n(n({},o),{data:{download_list:null===(i=o.data)||void 0===i?void 0:i.map(function(t){return{code:t.code||"SUCCESS",message:t.message,fileid:t.cloudObjectId,download_url:t.downloadUrl,fileID:t.cloudObjectId,tempFileURL:t.downloadUrl}})}})]}})})},_=function(t,e,r){return a(void 0,void 0,void 0,function(){var o,i;return s(this,function(a){switch(a.label){case 0:return[4,t.gateWay({path:"storages",name:"delete-objects",data:e.fileList.map(function(t){return{cloudObjectId:t}})},r)];case 1:return o=a.sent(),[2,n(n({},o),{data:{delete_list:null===(i=o.data)||void 0===i?void 0:i.map(function(t){return{code:t.code||"SUCCESS",fileID:t.cloudObjectId,message:t.message}})}})]}})})},S=function(t,e,r){return a(void 0,void 0,void 0,function(){var o,i;return s(this,function(a){switch(a.label){case 0:return[4,t.gateWay({path:"storages",name:"copy-objects",data:e.convertedFileList.map(function(t){return{srcPath:t.src_path,dstPath:t.dst_path,overwrite:t.overwrite,removeOriginal:t.remove_original}})},r)];case 1:return o=a.sent(),[2,n(n({},o),{data:{copy_list:null===(i=o.data)||void 0===i?void 0:i.map(function(t){return{code:t.code||"SUCCESS",fileID:t.cloudObjectId,message:t.message}})}})]}})})},E={txt:"text/plain",json:"application/json",html:"text/html",htm:"text/html",css:"text/css",js:"application/javascript",csv:"text/csv",xml:"application/xml",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",pdf:"application/pdf",zip:"application/zip",gz:"application/gzip",mp4:"video/mp4",webm:"video/webm",mp3:"audio/mpeg",wav:"audio/wav"};function P(t,e){if("undefined"!=typeof Blob&&t instanceof Blob&&t.type)return t.type;var r=/\.([a-zA-Z0-9]+)$/.exec(e||""),n=r?r[1].toLowerCase():"";return E[n]||"application/octet-stream"}function I(t,e){var r=e.toLowerCase();return Object.keys(t).some(function(t){return t.toLowerCase()===r})}function j(t){return Object.keys(t).reduce(function(e,r){var o;return n(n({},e),((o={})[r]=[t[r]],o))},{})}e.CloudbaseStorage=function(){function t(t){this.context=t}var r,u,E,N,C,x,T,A,R,U,k,L,F,M,D,B;return Object.defineProperty(t.prototype,"config",{get:function(){var t;return null===(t=this.context)||void 0===t?void 0:t.config},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){var t;return null===(t=this.context)||void 0===t?void 0:t.request},enumerable:!1,configurable:!0}),t.prototype.isGateWay=function(){return"GATEWAY"===(this.config.endPointMode||"CLOUD_API")},t.prototype.uploadFile=function(t,r){return a(this,void 0,Promise,function(){var o,i,a,u,d,p,v,g,b,w,O,_,S,E,N,C,x,T,A,R,U,k,L,F,M,D,B,q,G,W,V;return s(this,function(s){switch(s.label){case 0:if(o=t.cloudPath,i=t.filePath,a=t.onUploadProgress,G=t.method,u=void 0===G?"put":G,W=t.headers,d=void 0===W?{}:W,p=t.fileContent,!y(o)||!i&&!p)throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".uploadFile] invalid params")}));return v={put:c.put,post:c.post}[u.toLocaleLowerCase()]||c.put,g=this.isGateWay(),b=n({},d),w=Object.keys(d).reduce(function(t,e){return"content-length"!==e.toLowerCase()&&(t[e]=d[e]),t},{}),v===c.put&&g&&(I(b,"content-length")||(O=function(t,e){var r=null!=t?t:e;if(null!==r){if("undefined"!=typeof Blob&&r instanceof Blob)return r.size;if("undefined"!=typeof ArrayBuffer){if(r instanceof ArrayBuffer)return r.byteLength;if("function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(r))return r.byteLength}if("string"==typeof r){if("undefined"!=typeof Blob)return new Blob([r]).size;var n=(0,l.getStringByteLength)(r);return"number"==typeof n?n:r.length}return"object"==typeof r&&"number"==typeof r.size?r.size:void 0}}(i,p),"number"==typeof O&&(b["content-length"]=String(O))),I(b,"content-type")||(b["content-type"]=P(i,o)),I(w,"content-type")||(w["content-type"]=P(i,o))),[4,this.getUploadMetadata({cloudPath:o,method:v,headers:v!==c.put||g?void 0:w,signedHeader:v===c.put&&g?j(b):void 0,customReqOpts:t.customReqOpts})];case 1:return _=s.sent(),S=_.data,E=_.requestId,(null==(N=S)?void 0:N.code)||!(null==N?void 0:N.url)?(C=(null==N?void 0:N.code)||h.OPERATION_FAIL,x=(null==N?void 0:N.message)||"get upload info failed",[2,m(r,new Error("[".concat(f(),"][").concat(C,"][").concat(e.COMPONENT_NAME,"]:").concat(x)))]):(T=S.url,A=S.authorization,R=S.token,U=S.fileId,k=S.cosFileId,L=S.download_url,M=n(n({},F={url:T,file:i,name:o,onUploadProgress:a,fileContent:p,fileId:U,requestId:E}),{method:c.put,headers:n(n({},w),{authorization:A,"x-cos-meta-fileid":k,"x-cos-security-token":R})}),D=n(n({},F),{method:c.post,data:{key:o,signature:A,"x-cos-meta-fileid":k,success_action_status:"201","x-cos-security-token":R}}),(V={})[c.put]={params:M,isSuccess:function(t){return t>=200&&t<300}},V[c.post]={params:D,isSuccess:function(t){return 201===t}},B=V,[4,this.request.upload(B[v].params)]);case 2:return q=s.sent(),B[v].isSuccess(q.statusCode)?[2,m(r,null,{fileID:U,download_url:L,requestId:E})]:[2,m(r,new Error("[".concat(f(),"][").concat(h.OPERATION_FAIL,"][").concat(e.COMPONENT_NAME,"]:").concat(q.data)))]}})})},t.prototype.getUploadMetadata=function(t,r){return a(this,void 0,Promise,function(){var n,o,i,a,u,l,d,f,p,v;return s(this,function(s){switch(s.label){case 0:if(n=t.cloudPath,o=t.method,i=t.headers,a=t.signedHeader,!y(n))throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".getUploadMetadata] invalid cloudPath")}));u=this.request,l="storage.getUploadMetadata",s.label=1;case 1:return s.trys.push([1,6,,7]),d=void 0,f={path:n},p=this.isGateWay(),o&&(f.method=o),o===c.put&&(p&&a?f.signedHeader=a:!p&&i&&(f.headers=i)),p?[4,w(u,f,t.customReqOpts)]:[3,3];case 2:return d=s.sent(),[3,5];case 3:return[4,u.send(l,f,t.customReqOpts)];case 4:d=s.sent(),s.label=5;case 5:return[2,m(r,null,d)];case 6:return v=s.sent(),[2,m(r,v)];case 7:return[2]}})})},t.prototype.deleteFile=function(t,r){return a(this,void 0,Promise,function(){var n,o,i,a,c,u,l,d;return s(this,function(s){switch(s.label){case 0:if(!(n=t.fileList)||!v(n)||0===n.length)throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".deleteFile] fileList must not be empty")}));for(o=0,i=n;o<i.length;o++)if(!(a=i[o])||!y(a))throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".deleteFile] fileID must be string")}));return c="storage.batchDeleteFile",u=this.request,l={},this.isGateWay()?[4,_(u,{fileList:n},t.customReqOpts)]:[3,2];case 1:return l=s.sent(),[3,4];case 2:return[4,u.send(c,{fileid_list:n},t.customReqOpts)];case 3:l=s.sent(),s.label=4;case 4:return l.code?[2,m(r,null,l)]:(d={fileList:l.data.delete_list,requestId:l.requestId},[2,m(r,null,d)])}})})},t.prototype.getTempFileURL=function(t,r){return a(this,void 0,Promise,function(){var n,o,i,a,c,u,l,d;return s(this,function(s){switch(s.label){case 0:if(!(n=t.fileList)||!v(n)||0===n.length)throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".getTempFileURL] fileList must not be empty")}));for(o=[],i=0,a=n;i<a.length;i++)if(c=a[i],g(c)){if(!Object.prototype.hasOwnProperty.call(c,"fileID"))throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".getTempFileURL] file info must include fileID")}));o.push({fileid:c.fileID,max_age:c.maxAge||7200})}else{if(!y(c))throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".getTempFileURL] invalid fileList")}));o.push({fileid:c})}return u="storage.batchGetDownloadUrl",l=this.request,d={},this.isGateWay()?[4,O(l,{convertedFileList:o},t.customReqOpts)]:[3,2];case 1:return d=s.sent(),[3,4];case 2:return[4,l.send(u,{file_list:o},t.customReqOpts)];case 3:d=s.sent(),s.label=4;case 4:return d.code?[2,m(r,null,d)]:[2,m(r,null,{fileList:d.data.download_list,requestId:d.requestId})]}})})},t.prototype.downloadFile=function(t,r){return a(this,void 0,Promise,function(){var n,o,i,a,c,u;return s(this,function(s){switch(s.label){case 0:if(n=t.fileID,!y(n))throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".getTempFileURL] fileID must be string")}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:n,maxAge:600}],customReqOpts:t.customReqOpts})];case 1:return o=s.sent(),"SUCCESS"!==(i=o.fileList[0]).code?[2,m(r,i)]:(a=this.request,c=encodeURI(i.download_url),[4,a.download({url:c,tempFilePath:t.tempFilePath})]);case 2:return u=s.sent(),[2,m(r,null,u)]}})})},t.prototype.copyFile=function(t,r){return a(this,void 0,Promise,function(){var n,o,i,a,c,u,l,d,f;return s(this,function(s){switch(s.label){case 0:if(!(n=t.fileList)||!v(n)||0===n.length)throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".copyFile] fileList must not be empty")}));for(o=[],i=0,a=n;i<a.length;i++){if(c=a[i],u=c.srcPath,l=c.dstPath,!u||!l||"string"!=typeof u||"string"!=typeof l)throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".copyFile] srcPath and dstPath may not be empty")}));if(u===l)throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".copyFile] srcPath and dstPath can not be the same")}));o.push({src_path:u,dst_path:l,overwrite:c.overwrite,remove_original:c.removeOriginal})}return d=this.request,f={},this.isGateWay()?[4,S(d,{convertedFileList:o},t.customReqOpts)]:[3,2];case 1:return f=s.sent(),[3,4];case 2:return[4,d.send("storage.batchCopyFile",{file_list:o},t.customReqOpts)];case 3:f=s.sent(),s.label=4;case 4:return f.code?[2,m(r,null,f)]:[2,m(r,null,{fileList:f.data.copy_list,requestId:f.requestId})]}})})},t.prototype.getFileInfo=function(t){var e;return a(this,void 0,Promise,function(){var r,n=this;return s(this,function(o){switch(o.label){case 0:return[4,this.getTempFileURL(t)];case 1:return(null==(r=o.sent())?void 0:r.fileList)&&(null===(e=null==r?void 0:r.fileList)||void 0===e?void 0:e.length)>0?[4,Promise.all(r.fileList.map(function(t){return a(n,void 0,void 0,function(){var e,r,n,o,i,a,c;return s(this,function(s){switch(s.label){case 0:if("SUCCESS"!==t.code)return[2,{code:t.code,fileID:t.fileID,tempFileURL:t.tempFileURL,message:t.message}];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.request.fetch({url:t.tempFileURL,method:"HEAD"})];case 2:return e=s.sent(),r=e.header,"undefined"!=typeof Headers&&r instanceof Headers&&(n={},r.forEach(function(t,e){n[e]=t}),r=n),o=parseInt(r["content-length"])||0,i=r["content-type"]||"",[400,404].includes(Number(e.statusCode))?[2,{code:"FILE_NOT_FOUND",fileID:t.fileID,tempFileURL:t.tempFileURL,message:"file not found"}]:[2,{code:t.code,fileID:t.fileID,tempFileURL:t.tempFileURL,cloudId:t.fileID,fileName:t.fileID.split("/").pop(),contentType:i,mime:i.split(";")[0].trim(),size:o,etag:r.etag||"",lastModified:r["last-modified"]||"",cacheControl:r["cache-control"]||""}];case 3:return a=s.sent(),c="object"==typeof a&&null!==a&&"message"in a?String(a.message):void 0,[2,{code:"FETCH_FILE_INFO_ERROR",fileID:t.fileID,tempFileURL:t.tempFileURL,message:c}];case 4:return[2]}})})}))]:[3,3];case 2:return[2,{fileList:o.sent(),requestId:r.requestId}];case 3:return[2,{fileList:[],requestId:r.requestId}]}})})},o([b({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",[Object,"function"==typeof(r="undefined"!=typeof Function&&Function)?r:Object]),i("design:returntype","function"==typeof(u="undefined"!=typeof Promise&&Promise)?u:Object)],t.prototype,"uploadFile",null),o([b({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",[Object,"function"==typeof(E="undefined"!=typeof Function&&Function)?E:Object]),i("design:returntype","function"==typeof(N="undefined"!=typeof Promise&&Promise)?N:Object)],t.prototype,"getUploadMetadata",null),o([b({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(C=void 0!==d.ICloudbaseDeleteFileParams&&d.ICloudbaseDeleteFileParams)?C:Object,"function"==typeof(x="undefined"!=typeof Function&&Function)?x:Object]),i("design:returntype","function"==typeof(T="undefined"!=typeof Promise&&Promise)?T:Object)],t.prototype,"deleteFile",null),o([b({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(A=void 0!==d.ICloudbaseGetTempFileURLParams&&d.ICloudbaseGetTempFileURLParams)?A:Object,"function"==typeof(R="undefined"!=typeof Function&&Function)?R:Object]),i("design:returntype","function"==typeof(U="undefined"!=typeof Promise&&Promise)?U:Object)],t.prototype,"getTempFileURL",null),o([b({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(k=void 0!==d.ICloudbaseDownloadFileParams&&d.ICloudbaseDownloadFileParams)?k:Object,"function"==typeof(L="undefined"!=typeof Function&&Function)?L:Object]),i("design:returntype","function"==typeof(F="undefined"!=typeof Promise&&Promise)?F:Object)],t.prototype,"downloadFile",null),o([b({customInfo:{className:"Cloudbase",methodName:"copyFile"},title:"批量复制文件",messages:["请确认以下各项:"," 1 - 调用 copyFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(M=void 0!==d.ICloudbaseCopyFileParams&&d.ICloudbaseCopyFileParams)?M:Object,"function"==typeof(D="undefined"!=typeof Function&&Function)?D:Object]),i("design:returntype","function"==typeof(B="undefined"!=typeof Promise&&Promise)?B:Object)],t.prototype,"copyFile",null),t}()},656:function(t,e,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(a,s)}c((n=n.apply(t,e||[])).next())})},i=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.DownloadBuilder=e.StreamDownloadBuilder=void 0;var a=r(957),s=r(90);function c(t){return(0,a.isStorageError)(t)?t:new a.StorageError((null==t?void 0:t.message)||String(t))}function u(t){var e={};return void 0!==(null==t?void 0:t.download)&&(e.download=!0===t.download?"":t.download),void 0!==(null==t?void 0:t.cacheNonce)&&(e.cacheNonce=String(t.cacheNonce)),{headers:{},query:e}}var l=function(){function t(t){this.ctx=t}return t.prototype.then=function(t,e){return this.execute().then(t,e)},t.prototype.execute=function(){var t,e;return o(this,void 0,Promise,function(){var r,o,l,d,f;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),r=u(this.ctx.options),o=r.headers,l=r.query,[4,this.ctx.http.download({path:"/object/".concat(this.ctx.bucketId,"/").concat((0,s.encodeObjectName)(this.ctx.cleanName)),headers:n(n({},this.ctx.headers),o),query:l,signal:null===(t=this.ctx.parameters)||void 0===t?void 0:t.signal,cache:null===(e=this.ctx.parameters)||void 0===e?void 0:e.cache})];case 1:if(!(d=i.sent().response).body)throw new a.StorageApiError("Response body is empty",d.status,"STORAGE_PG_EMPTY_BODY");return[2,{data:d.body,error:null}];case 2:if(f=i.sent(),this.ctx.shouldThrowOnError)throw f;return[2,{data:null,error:c(f)}];case 3:return[2]}})})},t}();e.StreamDownloadBuilder=l;var d=function(){function t(t){this.ctx=t}return t.prototype.asStream=function(){return new l(this.ctx)},t.prototype.then=function(t,e){return this.execute().then(t,e)},t.prototype.execute=function(){var t,e;return o(this,void 0,Promise,function(){var r,o,a,l,d,f;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),r=u(this.ctx.options),o=r.headers,a=r.query,[4,this.ctx.http.download({path:"/object/".concat(this.ctx.bucketId,"/").concat((0,s.encodeObjectName)(this.ctx.cleanName)),headers:n(n({},this.ctx.headers),o),query:a,signal:null===(t=this.ctx.parameters)||void 0===t?void 0:t.signal,cache:null===(e=this.ctx.parameters)||void 0===e?void 0:e.cache})];case 1:return l=i.sent().response,f={},[4,l.blob()];case 2:return[2,(f.data=i.sent(),f.error=null,f)];case 3:if(d=i.sent(),this.ctx.shouldThrowOnError)throw d;return[2,{data:null,error:c(d)}];case 4:return[2]}})})},t}();e.DownloadBuilder=d},90:(t,e)=>{"use strict";function r(){return globalThis.Buffer}Object.defineProperty(e,"__esModule",{value:!0}),e.encodeObjectName=e.toBase64=e.getStringByteLength=void 0,e.getStringByteLength=function(t){var e;return null===(e=r())||void 0===e?void 0:e.byteLength(t)},e.toBase64=function(t){var e=r();return e?e.from(t).toString("base64"):btoa(t)},e.encodeObjectName=function(t){return t.split("/").map(function(t){return encodeURIComponent(t)}).join("/")}},98:function(t,e,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(a,s)}c((n=n.apply(t,e||[])).next())})},i=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.Http=e.handleOperation=void 0;var a=r(957),s="/v1/storages";e.handleOperation=function(t,e){return o(this,void 0,Promise,function(){var r;return i(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,t()];case 1:return[2,{data:n.sent(),error:null}];case 2:if(r=n.sent(),e)throw r;return(0,a.isStorageError)(r)?[2,{data:null,error:r}]:[2,{data:null,error:new a.StorageError((null==r?void 0:r.message)||String(r))}];case 3:return[2]}})})};var c=function(){function t(t){this.ctx=t}return Object.defineProperty(t.prototype,"request",{get:function(){return this.ctx.request},enumerable:!1,configurable:!0}),t.prototype.gatewayOrigin=function(){return this.request.getBaseEndPoint("GATEWAY")},t.prototype.buildUrl=function(t,e){var r="".concat(this.gatewayOrigin()).concat(s).concat(t),n=function(t){if(!t)return"";var e=[];return Object.keys(t).forEach(function(r){var n=t[r];null!=n&&e.push("".concat(encodeURIComponent(r),"=").concat(encodeURIComponent(String(n))))}),e.join("&")}(e);return n&&(r+=(r.includes("?")?"&":"?")+n),r},t.prototype.toFullUrl=function(t){return t?/^https?:\/\//.test(t)||t.startsWith("//")?t:"".concat(this.gatewayOrigin()).concat(s).concat(t.startsWith("/")?"":"/").concat(t):t},t.prototype.send=function(t){return o(this,void 0,Promise,function(){var e,r,o,a,s,c;return i(this,function(i){switch(i.label){case 0:return e=this.buildUrl(t.path,t.query),r=t.method.toUpperCase(),o=["GET","HEAD"].includes(r),a=n({},t.headers||{}),o||(void 0!==t.rawBody?s=t.rawBody:void 0!==t.json&&(a["Content-Type"]=a["Content-Type"]||"application/json",s=JSON.stringify(t.json))),[4,this.request.fetch(n(n(n(n({url:e,method:r,headers:a},void 0!==s?{body:s}:{}),{withCredentials:!1!==t.withCredentials,shouldThrowOnError:!1}),t.signal?{signal:t.signal}:{}),t.cache?{cache:t.cache}:{}))];case 1:return c=i.sent(),[2,this.unwrap(c,e)]}})})},t.prototype.download=function(t){var e,r;return o(this,void 0,Promise,function(){var o,s,c,u;return i(this,function(i){switch(i.label){case 0:return o=this.buildUrl(t.path,t.query),[4,this.request.fetch(n(n({url:o,method:"GET",headers:n({},t.headers||{}),stream:!0,withCredentials:!1!==t.withCredentials,shouldThrowOnError:!1},t.signal?{signal:t.signal}:{}),t.cache?{cache:t.cache}:{}))];case 1:if(s=i.sent(),null===(e=t.signal)||void 0===e?void 0:e.aborted)throw new a.StorageApiError("The download was aborted",0,"STORAGE_PG_ABORTED");if(304===(c=Number(null!==(r=null==s?void 0:s.statusCode)&&void 0!==r?r:200)))throw new a.StorageApiError("Not Modified",c,"STORAGE_PG_NOT_MODIFIED");if(c>=400)throw new a.StorageApiError("Download failed with status ".concat(c),c,"STORAGE_PG_REQUEST_FAIL");if(!(u=null==s?void 0:s.response))throw new a.StorageApiError("Underlying adapter did not expose the raw Response",c,"STORAGE_PG_NO_RESPONSE");return[2,{response:u,status:c,header:null==s?void 0:s.header}]}})})},t.prototype.unwrap=function(t,e){var r,n;return o(this,void 0,Promise,function(){var o,s,c,u;return i(this,function(i){switch(i.label){case 0:o=Number(null!==(n=null!==(r=null==t?void 0:t.statusCode)&&void 0!==r?r:null==t?void 0:t.status)&&void 0!==n?n:200),s=null==t?void 0:t.data,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,s];case 2:return s=i.sent(),[3,4];case 3:return i.sent(),s=void 0,[3,4];case 4:if(o>=200&&o<300)return[2,s];throw c=(null==s?void 0:s.code)||(null==s?void 0:s.error)||"STORAGE_PG_REQUEST_FAIL",u=(null==s?void 0:s.message)||"Storage request failed with status ".concat(o,": ").concat(e),new a.StorageApiError(u,o,c)}})})},t}();e.Http=c},456:function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0}),e.registerStorage=e.StorageClient=e.StorageFileApi=e.ClassicStorageFileApi=e.CloudbaseStorage=e.COMPONENT_NAME=void 0;var i=r(502),a=r(14),s=r(504),c=r(891),u=r(77),l=r(891);Object.defineProperty(e,"COMPONENT_NAME",{enumerable:!0,get:function(){return l.COMPONENT_NAME}}),Object.defineProperty(e,"CloudbaseStorage",{enumerable:!0,get:function(){return l.CloudbaseStorage}});var d=r(77);Object.defineProperty(e,"ClassicStorageFileApi",{enumerable:!0,get:function(){return d.ClassicStorageFileApi}});var f=r(502);Object.defineProperty(e,"StorageFileApi",{enumerable:!0,get:function(){return f.StorageFileApi}});var h=new c.CloudbaseStorage,p={name:c.COMPONENT_NAME,entity:{uploadFile:h.uploadFile,deleteFile:h.deleteFile,getTempFileURL:h.getTempFileURL,downloadFile:h.downloadFile,getUploadMetadata:h.getUploadMetadata,copyFile:h.copyFile,getFileInfo:h.getFileInfo,isGateWay:h.isGateWay}},v=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.from=function(t){return t?((0,s.assertValidBucketId)(t,"from"),new i.StorageFileApi(this.http,t,this.shouldThrowOnError)):new u.ClassicStorageFileApi(this.http.ctx,this.shouldThrowOnError)},e}(a.StorageBucketApi);e.StorageClient=v;var y={name:"".concat(c.COMPONENT_NAME,"/supabase"),IIFE:!0,entity:function(){var t=new WeakMap;Object.defineProperty(this.prototype,"storage",{get:function(){if(t.has(this))return t.get(this);var e=this,r=new Proxy({},{get:function(t,r){return"config"===r?e.config:"request"===r?e.request:void 0}}),n=new v(r);return t.set(this,n),n},configurable:!0,enumerable:!0})}};try{cloudbase.registerComponent(p),cloudbase.registerComponent(y)}catch(t){}function g(t){try{t.registerComponent(p),t.registerComponent(y)}catch(t){console.warn(t)}}e.registerStorage=g;try{window.registerStorage=g}catch(t){}},14:function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(a,s)}c((n=n.apply(t,e||[])).next())})},o=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.StorageBucketApi=void 0;var i=r(98),a=r(504),s=function(){function t(t,e){void 0===e&&(e=!1),this.http=new i.Http(t),this.shouldThrowOnError=e}return t.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},t.prototype.listBuckets=function(t){return n(this,void 0,Promise,function(){var e=this;return o(this,function(r){return[2,(0,i.handleOperation)(function(){var r={};return void 0!==(null==t?void 0:t.limit)&&(r.limit=t.limit),void 0!==(null==t?void 0:t.offset)&&(r.offset=t.offset),(null==t?void 0:t.sortColumn)&&(r.sortColumn=t.sortColumn),(null==t?void 0:t.sortOrder)&&(r.sortOrder=t.sortOrder),(null==t?void 0:t.search)&&(r.search=t.search),e.http.send({method:"GET",path:"/bucket/",query:r})},this.shouldThrowOnError)]})})},t.prototype.getBucket=function(t){return n(this,void 0,Promise,function(){var e=this;return o(this,function(r){return[2,(0,i.handleOperation)(function(){return(0,a.assertValidBucketId)(t,"getBucket"),e.http.send({method:"GET",path:"/bucket/".concat(t)})},this.shouldThrowOnError)]})})},t.prototype.createBucket=function(t,e){return n(this,void 0,Promise,function(){var r=this;return o(this,function(n){return[2,(0,i.handleOperation)(function(){var n;return(0,a.assertValidBucketId)(t,"createBucket"),r.http.send({method:"POST",path:"/bucket/",json:{id:t,name:t,public:null!==(n=null==e?void 0:e.public)&&void 0!==n&&n,type:null==e?void 0:e.type,file_size_limit:null==e?void 0:e.fileSizeLimit,allowed_mime_types:null==e?void 0:e.allowedMimeTypes}})},this.shouldThrowOnError)]})})},t.prototype.updateBucket=function(t,e){return n(this,void 0,Promise,function(){var r=this;return o(this,function(n){return[2,(0,i.handleOperation)(function(){return(0,a.assertValidBucketId)(t,"updateBucket"),r.http.send({method:"PUT",path:"/bucket/".concat(t),json:{public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes}})},this.shouldThrowOnError)]})})},t.prototype.deleteBucket=function(t){return n(this,void 0,Promise,function(){var e=this;return o(this,function(r){return[2,(0,i.handleOperation)(function(){return(0,a.assertValidBucketId)(t,"deleteBucket"),e.http.send({method:"DELETE",path:"/bucket/".concat(t)})},this.shouldThrowOnError)]})})},t}();e.StorageBucketApi=s},77:function(t,e,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(a,s)}c((n=n.apply(t,e||[])).next())})},i=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.ClassicStorageFileApi=void 0;var a=r(877),s=r(957),c=r(891),u=r(90),l=a.constants.ERRORS,d=function(){function t(t,e){void 0===e&&(e=!1),this.shouldThrowOnError=!1,this.bucketId="",this.context=t,this.shouldThrowOnError=e,this.storage=new c.CloudbaseStorage(t)}return Object.defineProperty(t.prototype,"config",{get:function(){var t;return null===(t=this.context)||void 0===t?void 0:t.config},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){var t;return null===(t=this.context)||void 0===t?void 0:t.request},enumerable:!1,configurable:!0}),t.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},t.prototype.upload=function(t,e,r){return o(this,void 0,Promise,function(){var o,a,u,d,f,h,p,v,y;return i(this,function(i){switch(i.label){case 0:o=n({upsert:!0},r),a=o.cacheControl,u=o.contentType,d=o.metadata,i.label=1;case 1:return i.trys.push([1,3,,4]),f=this.getCloudPath(t),h={cloudPath:f,filePath:e},(a||u||d)&&(p={},a&&(p["cache-control"]=a),u&&(p["content-type"]=u),d&&(p["x-cos-metadata-metadata"]=this.toBase64(JSON.stringify(d))),h.headers=p),[4,this.storage.uploadFile(h)];case 2:if(!(v=i.sent()).fileID)throw new Error(JSON.stringify({code:l.OPERATION_FAIL,msg:"[".concat(c.COMPONENT_NAME,".update] no fileID returned")}));return[2,{data:{id:v.fileID,path:t,fullPath:t},error:null}];case 3:if(y=i.sent(),this.shouldThrowOnError)throw y;if((0,s.isStorageError)(y))return[2,{data:null,error:y}];throw y;case 4:return[2]}})})},t.prototype.uploadToSignedUrl=function(t,e,r,n){return o(this,void 0,Promise,function(){return i(this,function(e){return[2,this.upload(t,r,n)]})})},t.prototype.createSignedUploadUrl=function(t){return o(this,void 0,Promise,function(){var e,r,n;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),e=this.getCloudPath(t),[4,this.storage.getUploadMetadata({cloudPath:e})];case 1:return[2,{data:{signedUrl:(r=o.sent().data).url,token:r.token,path:t,authorization:r.authorization,id:r.fileId,cosFileId:r.cosFileId,downloadUrl:r.download_url},error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;return[2,{data:null,error:n instanceof s.StorageError?n:new s.StorageError(n.message)}];case 3:return[2]}})})},t.prototype.update=function(t,e,r){return o(this,void 0,Promise,function(){return i(this,function(o){return[2,this.upload(t,e,n(n({},r),{upsert:!0}))]})})},t.prototype.move=function(t,e){return o(this,void 0,Promise,function(){var r,n;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.storage.copyFile({fileList:[{srcPath:this.getCloudPath(t),dstPath:this.getCloudPath(e),overwrite:!0,removeOriginal:!0}]})];case 1:if((r=o.sent()).fileList[0].code&&"SUCCESS"!==r.fileList[0].code)throw new s.StorageError(r.fileList[0].message||"Move failed");return[2,{data:{message:"File moved from ".concat(t," to ").concat(e)},error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;if((0,s.isStorageError)(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}})})},t.prototype.copy=function(t,e){return o(this,void 0,Promise,function(){var r,n;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.storage.copyFile({fileList:[{srcPath:this.getCloudPath(t),dstPath:this.getCloudPath(e),overwrite:!0,removeOriginal:!1}]})];case 1:if((r=o.sent()).fileList[0].code&&"SUCCESS"!==r.fileList[0].code)throw new s.StorageError(r.fileList[0].message||"Copy failed");return[2,{data:{path:this.getCloudPath(e)},error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;if((0,s.isStorageError)(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}})})},t.prototype.createSignedUrl=function(t,e,r){return o(this,void 0,Promise,function(){var n,o,a,c,u,l,d;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=this.normalizeCloudId(t),[4,this.storage.getTempFileURL({fileList:[{fileID:n,maxAge:e}]})];case 1:if("SUCCESS"!==(o=i.sent()).fileList[0].code)throw new s.StorageError("Failed to create signed URL: [".concat(o.fileList[0].code,"] ").concat(o.fileList[0].fileID));return a=o.fileList[0].download_url,c=[],void 0!==(null==r?void 0:r.download)&&("string"==typeof r.download?c.push("download=".concat(encodeURIComponent(r.download))):!0===r.download&&c.push("download=true")),(null==r?void 0:r.transform)&&(u=this.transformOptsToQueryString(r.transform))&&c.push(u),c.length>0&&(l=a.includes("?")?"&":"?",a="".concat(a).concat(l).concat(c.join("&"))),[2,{data:{signedUrl:a},error:null}];case 2:if(d=i.sent(),this.shouldThrowOnError)throw d;if((0,s.isStorageError)(d))return[2,{data:null,error:d}];throw d;case 3:return[2]}})})},t.prototype.createSignedUrls=function(t,e){return o(this,void 0,Promise,function(){var r,n,o=this;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),r=t.map(function(t){return{fileID:o.normalizeCloudId(t),maxAge:e}}),[4,this.storage.getTempFileURL({fileList:r})];case 1:return[2,{data:i.sent().fileList.map(function(e,r){return{path:t[r],signedUrl:e.tempFileURL||"",error:"SUCCESS"===e.code?null:e.message}}),error:null}];case 2:if(n=i.sent(),this.shouldThrowOnError)throw n;if((0,s.isStorageError)(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}})})},t.prototype.download=function(t,e){return o(this,void 0,Promise,function(){var r,n,a=this;return i(this,function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),n={},[4,o(a,void 0,void 0,function(){var r,n,o,a;return i(this,function(i){switch(i.label){case 0:return[4,this.createSignedUrl(t,600,{transform:e})];case 1:if((r=i.sent()).error)throw r.error;return n=encodeURI(null===(a=r.data)||void 0===a?void 0:a.signedUrl),[4,this.request.reqClass.get({url:n,headers:{},responseType:"blob"})];case 2:if(!(o=i.sent().data))throw new s.StorageError("Download failed: no file content");return[2,new Blob([o])]}})})];case 1:return[2,(n.data=c.sent(),n.error=null,n)];case 2:if(r=c.sent(),this.shouldThrowOnError)throw r;if((0,s.isStorageError)(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}})})},t.prototype.info=function(t){return o(this,void 0,Promise,function(){var e,r,n,o,a,c,u,l;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),e=t.startsWith("cloud://"),r=e?this.extractPathFromFileId(t):t,n=e?this.extractBucketFromFileId(t):this.bucketId,[4,this.storage.getFileInfo({fileList:[this.normalizeCloudId(t)]})];case 1:if(o=i.sent(),"SUCCESS"!==(a=o.fileList[0]).code)throw new s.StorageError(a.message);return c=(new Date).toISOString(),u=(a.lastModified?new Date(a.lastModified):new Date).toISOString(),[2,{data:{id:a.fileID,version:"1",name:r,bucketId:n,updatedAt:u,createdAt:u,lastAccessedAt:c,size:a.size,cacheControl:a.cacheControl,contentType:a.contentType,etag:a.etag,lastModified:u,metadata:{}},error:null}];case 2:if(l=i.sent(),this.shouldThrowOnError)throw l;return[2,{data:null,error:l instanceof s.StorageError?l:new s.StorageError(l.message)}];case 3:return[2]}})})},t.prototype.exists=function(t){return o(this,void 0,Promise,function(){var e,r,n;return i(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.storage.getFileInfo({fileList:[this.normalizeCloudId(t)]})];case 1:if(e=o.sent(),"FILE_NOT_FOUND"===(r=e.fileList[0]).code)return[2,{data:!1,error:null}];if("SUCCESS"!==r.code)throw new s.StorageError(r.message);return[2,{data:!0,error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;if((0,s.isStorageError)(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}})})},t.prototype.getPublicUrl=function(t,e){return o(this,void 0,Promise,function(){var r;return i(this,function(n){switch(n.label){case 0:return[4,this.createSignedUrl(t,600,e)];case 1:return(r=n.sent()).data?[2,{data:{publicUrl:r.data.signedUrl}}]:[2,{data:null,error:r.error}]}})})},t.prototype.remove=function(t){return o(this,void 0,Promise,function(){var e,r,n,o,a,c,u,l,d,f,h=this;return i(this,function(i){switch(i.label){case 0:for(i.trys.push([0,3,,4]),e=10,r=[],n=0;n<t.length;n+=e)r.push(t.slice(n,n+e));return[4,Promise.all(r.map(function(t){return Promise.all(t.map(function(t){return h.info(t)}))}))];case 1:return o=i.sent(),a=new Map,o.forEach(function(r,n){r.forEach(function(r,o){r.data&&a.set(t[n*e+o],r.data)})}),c=t.map(function(t){return h.normalizeCloudId(t)}),[4,this.storage.deleteFile({fileList:c})];case 2:if(u=i.sent(),(l=u.fileList.filter(function(t){return"SUCCESS"!==t.code})).length>0)throw new s.StorageError("Delete failed for ".concat(l.length," file(s)"));return d=(new Date).toISOString(),[2,{data:t.map(function(t){var e=a.get(t);return{name:null==e?void 0:e.name,id:null==e?void 0:e.id,bucket_id:null==e?void 0:e.bucketId,owner:void 0,updated_at:(null==e?void 0:e.updatedAt)||d,created_at:null==e?void 0:e.createdAt,last_accessed_at:(null==e?void 0:e.lastAccessedAt)||d,metadata:(null==e?void 0:e.metadata)||{},buckets:{id:null==e?void 0:e.bucketId,name:null==e?void 0:e.bucketId,owner:void 0,public:!1,created_at:"",updated_at:d}}}),error:null}];case 3:if(f=i.sent(),this.shouldThrowOnError)throw f;if((0,s.isStorageError)(f))return[2,{data:null,error:f}];throw f;case 4:return[2]}})})},t.prototype.list=function(){return o(this,void 0,void 0,function(){return i(this,function(t){throw new s.StorageError("Not implemented")})})},t.prototype.getCloudPath=function(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")},t.prototype.normalizeCloudId=function(t){var e;if(/^cloud:\/\//.test(t))return t;var r=this.getCloudPath(t);if(!this.bucketId)throw new s.StorageError("bucketId is not set");var n=(null===(e=this.config)||void 0===e?void 0:e.env)||"";return n?"cloud://".concat(n,".").concat(this.bucketId,"/").concat(r):void 0},t.prototype.toBase64=function(t){return(0,u.toBase64)(t)},t.prototype.transformOptsToQueryString=function(t){var e=["imageMogr2"];if(t.width||t.height){var r=t.width||"",n=t.height||"";"fill"===t.resize?e.push("thumbnail/".concat(r,"x").concat(n,"!")):"contain"===t.resize?e.push("thumbnail/".concat(r,"x").concat(n)):e.push("thumbnail/".concat(r,"x").concat(n,"^"))}if(t.format&&"origin"!==t.format&&e.push("format/".concat(t.format)),void 0!==t.quality){var o=Math.max(1,Math.min(100,t.quality));e.push("quality/".concat(o))}return e.join("/")},t.prototype.extractPathFromFileId=function(t){var e=t.replace(/^cloud:\/\//,"").split("/");return e.length<2?t:e.slice(1).join("/")},t.prototype.extractBucketFromFileId=function(t){var e=t.replace(/^cloud:\/\//,"").split("/");if(e.length<1)return"";var r=e[0],n=r.indexOf(".");return-1===n?r:r.substring(n+1)},t}();e.ClassicStorageFileApi=d},502:function(t,e,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function s(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(a,s)}c((n=n.apply(t,e||[])).next())})},i=this&&this.__generator||function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.StorageFileApi=void 0;var a=r(957),s=r(90),c=r(98),u=r(656),l="3600",d=function(){function t(t,e,r){void 0===r&&(r=!1),this.headers={},this.http=t,this.bucketId=e,this.shouldThrowOnError=r}return t.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},t.prototype.setHeader=function(t,e){var r;if("string"!=typeof t||""===t.trim())throw new a.StorageError("setHeader requires a non-empty header name");if(/[\r\n]/.test(t)||"string"==typeof e&&/[\r\n]/.test(e))throw new a.StorageError("setHeader does not allow CR/LF characters in header name or value");return this.headers=n(n({},this.headers),((r={})[t]=String(e),r)),this},t.prototype.upload=function(t,e,r){return o(this,void 0,Promise,function(){return i(this,function(n){return[2,this.uploadOrUpdate("POST",t,e,r)]})})},t.prototype.update=function(t,e,r){return o(this,void 0,Promise,function(){return i(this,function(n){return[2,this.uploadOrUpdate("PUT",t,e,r)]})})},t.prototype.download=function(t,e,r){return new u.DownloadBuilder({http:this.http,bucketId:this.bucketId,cleanName:this.cleanPath(t),options:e,parameters:r,headers:this.headers,shouldThrowOnError:this.shouldThrowOnError})}