ctms/ctms-appgm/assets/uni-cloud.es.3c5d81c2.js
2025-04-10 23:19:13 +08:00

2 lines
60 KiB
JavaScript
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var e=Object.defineProperty,t=Object.defineProperties,s=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,i=(t,s,n)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n,a=(e,t)=>{for(var s in t||(t={}))r.call(t,s)&&i(e,s,t[s]);if(n)for(var s of n(t))o.call(t,s)&&i(e,s,t[s]);return e},c=(e,n)=>t(e,s(n));import{P as u,T as h,V as l,W as d,a0 as f,a1 as p,q as g,a2 as m,m as y,U as _,p as w,k,a3 as v,a4 as S,a5 as T,a6 as A}from"./index.ed795884.js";function P(e,t,s){return e(s={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&s.path)}},s.exports),s.exports}var I=P((function(e,t){var s;e.exports=(s=s||function(e,t){var s=Object.create||function(){function e(){}return function(t){var s;return e.prototype=t,s=new e,e.prototype=null,s}}(),n={},r=n.lib={},o=r.Base={extend:function(e){var t=s(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.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)}},i=r.WordArray=o.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,s=e.words,n=this.sigBytes,r=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<r;o++){var i=s[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=i<<24-(n+o)%4*8}else for(o=0;o<r;o+=4)t[n+o>>>2]=s[o>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,s=this.sigBytes;t[s>>>2]&=4294967295<<32-s%4*8,t.length=e.ceil(s/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var s,n=[],r=function(t){t=t;var s=987654321,n=4294967295;return function(){var r=((s=36969*(65535&s)+(s>>16)&n)<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n;return r/=4294967296,(r+=.5)*(e.random()>.5?1:-1)}},o=0;o<t;o+=4){var a=r(4294967296*(s||e.random()));s=987654071*a(),n.push(4294967296*a()|0)}return new i.init(n,t)}}),a=n.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,s=e.sigBytes,n=[],r=0;r<s;r++){var o=t[r>>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,s=[],n=0;n<t;n+=2)s[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new i.init(s,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,s=e.sigBytes,n=[],r=0;r<s;r++){var o=t[r>>>2]>>>24-r%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,s=[],n=0;n<t;n++)s[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new i.init(s,t)}},h=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},l=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new i.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var s=this._data,n=s.words,r=s.sigBytes,o=this.blockSize,a=r/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,u=e.min(4*c,r);if(c){for(var h=0;h<c;h+=o)this._doProcessBlock(n,h);var l=n.splice(0,c);s.sigBytes-=u}return new i.init(l,u)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});r.Hasher=l.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){l.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,s){return new e.init(s).finalize(t)}},_createHmacHelper:function(e){return function(t,s){return new d.HMAC.init(e,s).finalize(t)}}});var d=n.algo={};return n}(Math),s)})),b=(P((function(e,t){var s;e.exports=(s=I,function(e){var t=s,n=t.lib,r=n.WordArray,o=n.Hasher,i=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=i.MD5=o.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var s=0;s<16;s++){var n=t+s,r=e[n];e[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}var o=this._hash.words,i=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],g=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],w=e[t+8],k=e[t+9],v=e[t+10],S=e[t+11],T=e[t+12],A=e[t+13],P=e[t+14],I=e[t+15],b=o[0],O=o[1],E=o[2],U=o[3];b=u(b,O,E,U,i,7,a[0]),U=u(U,b,O,E,c,12,a[1]),E=u(E,U,b,O,f,17,a[2]),O=u(O,E,U,b,p,22,a[3]),b=u(b,O,E,U,g,7,a[4]),U=u(U,b,O,E,m,12,a[5]),E=u(E,U,b,O,y,17,a[6]),O=u(O,E,U,b,_,22,a[7]),b=u(b,O,E,U,w,7,a[8]),U=u(U,b,O,E,k,12,a[9]),E=u(E,U,b,O,v,17,a[10]),O=u(O,E,U,b,S,22,a[11]),b=u(b,O,E,U,T,7,a[12]),U=u(U,b,O,E,A,12,a[13]),E=u(E,U,b,O,P,17,a[14]),b=h(b,O=u(O,E,U,b,I,22,a[15]),E,U,c,5,a[16]),U=h(U,b,O,E,y,9,a[17]),E=h(E,U,b,O,S,14,a[18]),O=h(O,E,U,b,i,20,a[19]),b=h(b,O,E,U,m,5,a[20]),U=h(U,b,O,E,v,9,a[21]),E=h(E,U,b,O,I,14,a[22]),O=h(O,E,U,b,g,20,a[23]),b=h(b,O,E,U,k,5,a[24]),U=h(U,b,O,E,P,9,a[25]),E=h(E,U,b,O,p,14,a[26]),O=h(O,E,U,b,w,20,a[27]),b=h(b,O,E,U,A,5,a[28]),U=h(U,b,O,E,f,9,a[29]),E=h(E,U,b,O,_,14,a[30]),b=l(b,O=h(O,E,U,b,T,20,a[31]),E,U,m,4,a[32]),U=l(U,b,O,E,w,11,a[33]),E=l(E,U,b,O,S,16,a[34]),O=l(O,E,U,b,P,23,a[35]),b=l(b,O,E,U,c,4,a[36]),U=l(U,b,O,E,g,11,a[37]),E=l(E,U,b,O,_,16,a[38]),O=l(O,E,U,b,v,23,a[39]),b=l(b,O,E,U,A,4,a[40]),U=l(U,b,O,E,i,11,a[41]),E=l(E,U,b,O,p,16,a[42]),O=l(O,E,U,b,y,23,a[43]),b=l(b,O,E,U,k,4,a[44]),U=l(U,b,O,E,T,11,a[45]),E=l(E,U,b,O,I,16,a[46]),b=d(b,O=l(O,E,U,b,f,23,a[47]),E,U,i,6,a[48]),U=d(U,b,O,E,_,10,a[49]),E=d(E,U,b,O,P,15,a[50]),O=d(O,E,U,b,m,21,a[51]),b=d(b,O,E,U,T,6,a[52]),U=d(U,b,O,E,p,10,a[53]),E=d(E,U,b,O,v,15,a[54]),O=d(O,E,U,b,c,21,a[55]),b=d(b,O,E,U,w,6,a[56]),U=d(U,b,O,E,I,10,a[57]),E=d(E,U,b,O,y,15,a[58]),O=d(O,E,U,b,A,21,a[59]),b=d(b,O,E,U,g,6,a[60]),U=d(U,b,O,E,S,10,a[61]),E=d(E,U,b,O,f,15,a[62]),O=d(O,E,U,b,k,21,a[63]),o[0]=o[0]+b|0,o[1]=o[1]+O|0,o[2]=o[2]+E|0,o[3]=o[3]+U|0},_doFinalize:function(){var t=this._data,s=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;s[r>>>5]|=128<<24-r%32;var o=e.floor(n/4294967296),i=n;s[15+(r+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),s[14+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(s.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var h=c[u];c[u]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,s,n,r,o,i){var a=e+(t&s|~t&n)+r+i;return(a<<o|a>>>32-o)+t}function h(e,t,s,n,r,o,i){var a=e+(t&n|s&~n)+r+i;return(a<<o|a>>>32-o)+t}function l(e,t,s,n,r,o,i){var a=e+(t^s^n)+r+i;return(a<<o|a>>>32-o)+t}function d(e,t,s,n,r,o,i){var a=e+(s^(t|~n))+r+i;return(a<<o|a>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),s.MD5)})),P((function(e,t){var s,n,r;e.exports=(n=(s=I).lib.Base,r=s.enc.Utf8,void(s.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=r.parse(t));var s=e.blockSize,n=4*s;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,c=i.words,u=0;u<s;u++)a[u]^=1549556828,c[u]^=909522486;o.sigBytes=i.sigBytes=n,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,s=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(s))}})))})),P((function(e,t){e.exports=I.HmacMD5})));const O="FUNCTION";function E(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function U(e){return"object"===E(e)}function x(e){return e&&"string"==typeof e?JSON.parse(e):e}x({}.UNICLOUD_DEBUG);const C=x('[{"provider":"tencent","spaceName":"ctms","spaceId":"tcb-jag8g5hv5b112a-0di7f9a328884"}]');let D="";try{D="__UNI__79A6010"}catch(te){}let q={};function F(e,t={}){var s,n;return s=q,n=e,Object.prototype.hasOwnProperty.call(s,n)||(q[e]=t),q[e]}const L=["invoke","success","fail","complete"],R=F("_globalUniCloudInterceptor");function N(e,t){R[e]||(R[e]={}),U(t)&&Object.keys(t).forEach((s=>{L.indexOf(s)>-1&&function(e,t,s){let n=R[e][t];n||(n=R[e][t]=[]),-1===n.indexOf(s)&&"function"==typeof s&&n.push(s)}(e,s,t[s])}))}function j(e,t){R[e]||(R[e]={}),U(t)?Object.keys(t).forEach((s=>{L.indexOf(s)>-1&&function(e,t,s){const n=R[e][t];if(!n)return;const r=n.indexOf(s);r>-1&&n.splice(r,1)}(e,s,t[s])})):delete R[e]}function M(e,t){return e&&0!==e.length?e.reduce(((e,s)=>e.then((()=>s(t)))),Promise.resolve()):Promise.resolve()}function $(e,t){return R[e]&&R[e][t]||[]}function K(e,t){return t?function(s){let n,r=!1;if("callFunction"===t){const e=s&&s.type||O;r=e!==O}n=this.isReady?Promise.resolve():this.initUniCloud,s=s||{};const o=n.then((()=>r?Promise.resolve():M($(t,"invoke"),s))).then((()=>e.call(this,s))).then((e=>r?Promise.resolve(e):M($(t,"success"),e).then((()=>M($(t,"complete"),e))).then((()=>Promise.resolve(e)))),(e=>r?Promise.reject(e):M($(t,"fail"),e).then((()=>M($(t,"complete"),e))).then((()=>Promise.reject(e)))));if(!(s.success||s.fail||s.complete))return o;o.then((e=>{s.success&&s.success(e),s.complete&&s.complete(e)}),(e=>{s.fail&&s.fail(e),s.complete&&s.complete(e)}))}:function(t){if(!((t=t||{}).success||t.fail||t.complete))return e.call(this,t);e.call(this,t).then((e=>{t.success&&t.success(e),t.complete&&t.complete(e)}),(e=>{t.fail&&t.fail(e),t.complete&&t.complete(e)}))}}class B extends Error{constructor(e){super(e.message),this.errMsg=e.message||"",this.errCode=this.code=e.code,this.requestId=e.requestId,Object.defineProperties(this,{message:{get(){return this.errMsg},set(e){this.errMsg=e}}})}}let W;function z(){const e=T&&T()||"en";if(W)return c(a({},W),{LOCALE:e});const{deviceId:t,platform:s}=A();return W={PLATFORM:"h5",OS:s,APPID:D,DEVICEID:t,CLIENT_SDK_VERSION:"1.0.25"},c(a({},W),{LOCALE:e})}var H=function(e,t){let s="";return Object.keys(e).sort().forEach((function(t){e[t]&&(s=s+"&"+t+"="+e[t])})),s=s.slice(1),b(s,t).toString()},J=function(e,t){return new Promise(((s,n)=>{t(Object.assign(e,{complete(e){e||(e={});const t=e.data&&e.data.header&&e.data.header["x-serverless-request-id"]||e.header&&e.header["request-id"];if(!e.statusCode||e.statusCode>=400)return n(new B({code:"SYS_ERR",message:e.errMsg||"request:fail",requestId:t}));const r=e.data;if(r.error)return n(new B({code:r.error.code,message:r.error.message,requestId:t}));r.result=r.data,r.requestId=t,delete r.data,s(r)}}))}))},V={request:e=>y(e),uploadFile:e=>_(e),setStorageSync:(e,t)=>w(e,t),getStorageSync:e=>k(e),removeStorageSync:e=>v(e),clearStorageSync:()=>S()},Y={"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"};const{t:G}=u({"zh-Hans":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},"zh-Hant":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},en:Y,fr:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},es:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},ja:Y},"zh-Hans");var X=class{constructor(e){["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(G("uniCloud.init.paramRequired",{param:t}))})),this.config=Object.assign({},{endpoint:"https://api.bspapp.com"},e),this.config.provider="aliyun",this.config.requestUrl=this.config.endpoint+"/client",this.config.envType=this.config.envType||"public",this.config.accessTokenKey="access_token_"+this.config.spaceId,this.adapter=V,this._getAccessTokenPromise=null,this._getAccessTokenPromiseStatus=null}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return J(e,this.adapter.request)}requestAuth(e){return this.requestWrapped(e)}request(e,t){return Promise.resolve().then((()=>this.hasAccessToken?t?this.requestWrapped(e):this.requestWrapped(e).catch((t=>new Promise(((e,s)=>{!t||"GATEWAY_INVALID_TOKEN"!==t.code&&"InvalidParameter.InvalidToken"!==t.code?s(t):e()})).then((()=>this.getAccessToken())).then((()=>{const t=this.rebuildRequest(e);return this.request(t,!0)})))):this.getAccessToken().then((()=>{const t=this.rebuildRequest(e);return this.request(t,!0)}))))}rebuildRequest(e){const t=Object.assign({},e);return t.data.token=this.accessToken,t.header["x-basement-token"]=this.accessToken,t.header["x-serverless-sign"]=H(t.data,this.config.clientSecret),t}setupRequest(e,t){const s=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),n={"Content-Type":"application/json"};return"auth"!==t&&(s.token=this.accessToken,n["x-basement-token"]=this.accessToken),n["x-serverless-sign"]=H(s,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:s,dataType:"json",header:n}}getAccessToken(){return"pending"===this._getAccessTokenPromiseStatus||(this._getAccessTokenPromiseStatus="pending",this._getAccessTokenPromise=this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>new Promise(((t,s)=>{e.result&&e.result.accessToken?(this.setAccessToken(e.result.accessToken),this._getAccessTokenPromiseStatus="fulfilled",t(this.accessToken)):(this._getAccessTokenPromiseStatus="rejected",s(new B({code:"AUTH_FAILED",message:"获取accessToken失败"})))}))),(e=>(this._getAccessTokenPromiseStatus="rejected",Promise.reject(e))))),this._getAccessTokenPromise}authorize(){this.getAccessToken()}callFunction(e){const t={method:"serverless.function.runtime.invoke",params:JSON.stringify({functionTarget:e.name,functionArgs:e.data||{}})};return this.request(this.setupRequest(t))}getOSSUploadOptionsFromPath(e){const t={method:"serverless.file.resource.generateProximalSign",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFileToOSS({url:e,formData:t,name:s,filePath:n,fileType:r,onUploadProgress:o}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:s,filePath:n,fileType:r,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?i(e):a(new B({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new B({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof o&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{o({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}reportOSSUpload(e){const t={method:"serverless.file.resource.report",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFile({filePath:e,cloudPath:t,fileType:s="image",onUploadProgress:n,config:r}){if("string"!==E(t))throw new B({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new B({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new B({code:"INVALID_PARAM",message:"cloudPath不合法"});const o=r&&r.envType||this.config.envType;let i,a;return this.getOSSUploadOptionsFromPath({env:o,filename:t}).then((t=>{const r=t.result;i=r.id,a="https://"+r.cdnDomain+"/"+r.ossPath;const o={url:"https://"+r.host,formData:{"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:r.accessKeyId,Signature:r.signature,host:r.host,id:i,key:r.ossPath,policy:r.policy,success_action_status:200},fileName:"file",name:"file",filePath:e,fileType:s};return this.uploadFileToOSS(Object.assign({},o,{onUploadProgress:n}))})).then((()=>this.reportOSSUpload({id:i}))).then((t=>new Promise(((s,n)=>{t.success?s({success:!0,filePath:e,fileID:a}):n(new B({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({id:e[0]})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){return new Promise(((t,s)=>{Array.isArray(e)&&0!==e.length||s(new B({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),t({fileList:e.map((e=>({fileID:e,tempFileURL:e})))})}))}},Q={init(e){const t=new X(e),s={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return s},t.customAuth=t.auth,t}};const Z="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var ee,te;(te=ee||(ee={})).local="local",te.none="none",te.session="session";var se=function(){};const ne=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}const t=new Promise(((t,s)=>{e=(e,n)=>e?s(e):t(n)}));return e.promise=t,e};function re(e){return void 0===e}function oe(e){return"[object Null]"===Object.prototype.toString.call(e)}var ie;!function(e){e.WEB="web",e.WX_MP="wx_mp"}(ie||(ie={}));const ae={adapter:null,runtime:void 0},ce=["anonymousUuidKey"];class ue extends se{constructor(){super(),ae.adapter.root.tcbObject||(ae.adapter.root.tcbObject={})}setItem(e,t){ae.adapter.root.tcbObject[e]=t}getItem(e){return ae.adapter.root.tcbObject[e]}removeItem(e){delete ae.adapter.root.tcbObject[e]}clear(){delete ae.adapter.root.tcbObject}}function he(e,t){switch(e){case"local":return t.localStorage||new ue;case"none":return new ue;default:return t.sessionStorage||new ue}}class le{constructor(e){if(!this._storage){this._persistence=ae.adapter.primaryStorage||e.persistence,this._storage=he(this._persistence,ae.adapter);const t=`access_token_${e.env}`,s=`access_token_expire_${e.env}`,n=`refresh_token_${e.env}`,r=`anonymous_uuid_${e.env}`,o=`login_type_${e.env}`,i=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:s,refreshTokenKey:n,anonymousUuidKey:r,loginTypeKey:o,userInfoKey:i}}}updatePersistence(e){if(e===this._persistence)return;const t="local"===this._persistence;this._persistence=e;const s=he(e,ae.adapter);for(const n in this.keys){const e=this.keys[n];if(t&&ce.includes(n))continue;const r=this._storage.getItem(e);re(r)||oe(r)||(s.setItem(e,r),this._storage.removeItem(e))}this._storage=s}setStore(e,t,s){if(!this._storage)return;const n={version:s||"localCachev1",content:t},r=JSON.stringify(n);try{this._storage.setItem(e,r)}catch(o){throw o}}getStore(e,t){try{if(!this._storage)return}catch(n){return""}t=t||"localCachev1";const s=this._storage.getItem(e);return s&&s.indexOf(t)>=0?JSON.parse(s).content:""}removeStore(e){this._storage.removeItem(e)}}const de={},fe={};function pe(e){return de[e]}class ge{constructor(e,t){this.data=t||null,this.name=e}}class me extends ge{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const ye=new class{constructor(){this._listeners={}}on(e,t){return s=e,n=t,(r=this._listeners)[s]=r[s]||[],r[s].push(n),this;var s,n,r}off(e,t){return function(e,t,s){if(s&&s[e]){const n=s[e].indexOf(t);-1!==n&&s[e].splice(n,1)}}(e,t,this._listeners),this}fire(e,t){if(e instanceof me)return console.error(e.error),this;const s="string"==typeof e?new ge(e,t||{}):e,n=s.name;if(this._listens(n)){s.target=this;const e=this._listeners[n]?[...this._listeners[n]]:[];for(const t of e)t.call(this,s)}return this}_listens(e){return this._listeners[e]&&this._listeners[e].length>0}};function _e(e,t){ye.on(e,t)}function we(e,t={}){ye.fire(e,t)}function ke(e,t){ye.off(e,t)}const ve="loginStateChanged",Se="loginStateExpire",Te="loginTypeChanged",Ae="anonymousConverted",Pe="refreshAccessToken";var Ie;!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.WECHAT_PUBLIC="WECHAT-PUBLIC",e.WECHAT_OPEN="WECHAT-OPEN",e.CUSTOM="CUSTOM",e.EMAIL="EMAIL",e.USERNAME="USERNAME",e.NULL="NULL"}(Ie||(Ie={}));const be=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],Oe={"X-SDK-Version":"1.3.5"};function Ee(e,t,s){const n=e[t];e[t]=function(t){const r={},o={};s.forEach((s=>{const{data:n,headers:i}=s.call(e,t);Object.assign(r,n),Object.assign(o,i)}));const i=t.data;return i&&(()=>{var e;if(e=i,"[object FormData]"!==Object.prototype.toString.call(e))t.data=a(a({},i),r);else for(const t in r)i.append(t,r[t])})(),t.headers=a(a({},t.headers||{}),o),n.call(e,t)}}function Ue(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:c(a({},Oe),{"x-seqid":e})}}class xe{constructor(e={}){var t;this.config=e,this._reqClass=new ae.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成已中断`,restrictedMethods:["post"]}),this._cache=pe(this.config.env),this._localCache=(t=this.config.env,fe[t]),Ee(this._reqClass,"post",[Ue]),Ee(this._reqClass,"upload",[Ue]),Ee(this._reqClass,"download",[Ue])}async post(e){return await this._reqClass.post(e)}async upload(e){return await this._reqClass.upload(e)}async download(e){return await this._reqClass.download(e)}async refreshAccessToken(){let e,t;this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken());try{e=await this._refreshAccessTokenPromise}catch(s){t=s}if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return e}async _refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:s,loginTypeKey:n,anonymousUuidKey:r}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);let o=this._cache.getStore(s);if(!o)throw new Error("未登录CloudBase");const i={refresh_token:o},a=await this.request("auth.fetchAccessTokenWithRefreshToken",i);if(a.data.code){const{code:e}=a.data;if("SIGN_PARAM_INVALID"===e||"REFRESH_TOKEN_EXPIRED"===e||"INVALID_REFRESH_TOKEN"===e){if(this._cache.getStore(n)===Ie.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){const e=this._cache.getStore(r),t=this._cache.getStore(s),n=await this.send("auth.signInAnonymously",{anonymous_uuid:e,refresh_token:t});return this.setRefreshToken(n.refresh_token),this._refreshAccessToken()}we(Se),this._cache.removeStore(s)}throw new Error(`刷新access token失败${a.data.code}`)}if(a.data.access_token)return we(Pe),this._cache.setStore(e,a.data.access_token),this._cache.setStore(t,a.data.access_token_expire+Date.now()),{accessToken:a.data.access_token,accessTokenExpire:a.data.access_token_expire};a.data.refresh_token&&(this._cache.removeStore(s),this._cache.setStore(s,a.data.refresh_token),this._refreshAccessToken())}async getAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:s}=this._cache.keys;if(!this._cache.getStore(s))throw new Error("refresh token不存在登录状态异常");let n=this._cache.getStore(e),r=this._cache.getStore(t),o=!0;return this._shouldRefreshAccessTokenHook&&!(await this._shouldRefreshAccessTokenHook(n,r))&&(o=!1),(!n||!r||r<Date.now())&&o?this.refreshAccessToken():{accessToken:n,accessTokenExpire:r}}async request(e,t,s){const n=`x-tcb-trace_${this.config.env}`;let r="application/x-www-form-urlencoded";const o=a({action:e,env:this.config.env,dataVersion:"2019-08-16"},t);if(-1===be.indexOf(e)){const{refreshTokenKey:e}=this._cache.keys;this._cache.getStore(e)&&(o.access_token=(await this.getAccessToken()).accessToken)}let i;if("storage.uploadFile"===e){i=new FormData;for(let e in i)i.hasOwnProperty(e)&&void 0!==i[e]&&i.append(e,o[e]);r="multipart/form-data"}else{r="application/json",i={};for(let e in o)void 0!==o[e]&&(i[e]=o[e])}let c={headers:{"content-type":r}};s&&s.onUploadProgress&&(c.onUploadProgress=s.onUploadProgress);const u=this._localCache.getStore(n);u&&(c.headers["X-TCB-Trace"]=u);const{parse:h,inQuery:l,search:d}=t;let f={env:this.config.env};h&&(f.parse=!0),l&&(f=a(a({},l),f));let p=function(e,t,s={}){const n=/\?/.test(t);let r="";for(let o in s)""===r?!n&&(t+="?"):r+="&",r+=`${o}=${encodeURIComponent(s[o])}`;return/^http(s)?\:\/\//.test(t+=r)?t:`${e}${t}`}(Z,"//tcb-api.tencentcloudapi.com/web",f);d&&(p+=d);const g=await this.post(a({url:p,data:i},c)),m=g.header&&g.header["x-tcb-trace"];if(m&&this._localCache.setStore(n,m),200!==Number(g.status)&&200!==Number(g.statusCode)||!g.data)throw new Error("network request error");return g}async send(e,t={}){const s=await this.request(e,t,{onUploadProgress:t.onUploadProgress});if("ACCESS_TOKEN_EXPIRED"===s.data.code&&-1===be.indexOf(e)){await this.refreshAccessToken();const s=await this.request(e,t,{onUploadProgress:t.onUploadProgress});if(s.data.code)throw new Error(`[${s.data.code}] ${s.data.message}`);return s.data}if(s.data.code)throw new Error(`[${s.data.code}] ${s.data.message}`);return s.data}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:s,refreshTokenKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(s),this._cache.setStore(n,e)}}const Ce={};function De(e){return Ce[e]}class qe{constructor(e){this.config=e,this._cache=pe(e.env),this._request=De(e.env)}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:s,refreshTokenKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(s),this._cache.setStore(n,e)}setAccessToken(e,t){const{accessTokenKey:s,accessTokenExpireKey:n}=this._cache.keys;this._cache.setStore(s,e),this._cache.setStore(n,t)}async refreshUserInfo(){const{data:e}=await this._request.send("auth.getUserInfo",{});return this.setLocalUserInfo(e),e}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e)}}class Fe{constructor(e){if(!e)throw new Error("envId is not defined");this._envId=e,this._cache=pe(this._envId),this._request=De(this._envId),this.setUserInfo()}linkWithTicket(e){if("string"!=typeof e)throw new Error("ticket must be string");return this._request.send("auth.linkWithTicket",{ticket:e})}linkWithRedirect(e){e.signInWithRedirect()}updatePassword(e,t){return this._request.send("auth.updatePassword",{oldPassword:t,newPassword:e})}updateEmail(e){return this._request.send("auth.updateEmail",{newEmail:e})}updateUsername(e){if("string"!=typeof e)throw new Error("username must be a string");return this._request.send("auth.updateUsername",{username:e})}async getLinkedUidList(){const{data:e}=await this._request.send("auth.getLinkedUidList",{});let t=!1;const{users:s}=e;return s.forEach((e=>{e.wxOpenId&&e.wxPublicId&&(t=!0)})),{users:s,hasPrimaryUid:t}}setPrimaryUid(e){return this._request.send("auth.setPrimaryUid",{uid:e})}unlink(e){return this._request.send("auth.unlink",{platform:e})}async update(e){const{nickName:t,gender:s,avatarUrl:n,province:r,country:o,city:i}=e,{data:a}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:s,avatarUrl:n,province:r,country:o,city:i});this.setLocalUserInfo(a)}async refresh(){const{data:e}=await this._request.send("auth.getUserInfo",{});return this.setLocalUserInfo(e),e}setUserInfo(){const{userInfoKey:e}=this._cache.keys,t=this._cache.getStore(e);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl"].forEach((e=>{this[e]=t[e]})),this.location={country:t.country,province:t.province,city:t.city}}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e),this.setUserInfo()}}class Le{constructor(e){if(!e)throw new Error("envId is not defined");this._cache=pe(e);const{refreshTokenKey:t,accessTokenKey:s,accessTokenExpireKey:n}=this._cache.keys,r=this._cache.getStore(t),o=this._cache.getStore(s),i=this._cache.getStore(n);this.credential={refreshToken:r,accessToken:o,accessTokenExpire:i},this.user=new Fe(e)}get isAnonymousAuth(){return this.loginType===Ie.ANONYMOUS}get isCustomAuth(){return this.loginType===Ie.CUSTOM}get isWeixinAuth(){return this.loginType===Ie.WECHAT||this.loginType===Ie.WECHAT_OPEN||this.loginType===Ie.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class Re extends qe{async signIn(){this._cache.updatePersistence("local");const{anonymousUuidKey:e,refreshTokenKey:t}=this._cache.keys,s=this._cache.getStore(e)||void 0,n=this._cache.getStore(t)||void 0,r=await this._request.send("auth.signInAnonymously",{anonymous_uuid:s,refresh_token:n});if(r.uuid&&r.refresh_token){this._setAnonymousUUID(r.uuid),this.setRefreshToken(r.refresh_token),await this._request.refreshAccessToken(),we(ve),we(Te,{env:this.config.env,loginType:Ie.ANONYMOUS,persistence:"local"});const e=new Le(this.config.env);return await e.user.refresh(),e}throw new Error("匿名登录失败")}async linkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:s}=this._cache.keys,n=this._cache.getStore(t),r=this._cache.getStore(s),o=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:n,refresh_token:r,ticket:e});if(o.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(o.refresh_token),await this._request.refreshAccessToken(),we(Ae,{env:this.config.env}),we(Te,{loginType:Ie.CUSTOM,persistence:"local"}),{credential:{refreshToken:o.refresh_token}};throw new Error("匿名转化失败")}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:s}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(s,Ie.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class Ne extends qe{async signIn(e){if("string"!=typeof e)throw new Error("ticket must be a string");const{refreshTokenKey:t}=this._cache.keys,s=await this._request.send("auth.signInWithTicket",{ticket:e,refresh_token:this._cache.getStore(t)||""});if(s.refresh_token)return this.setRefreshToken(s.refresh_token),await this._request.refreshAccessToken(),we(ve),we(Te,{env:this.config.env,loginType:Ie.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new Le(this.config.env);throw new Error("自定义登录失败")}}class je extends qe{async signIn(e,t){if("string"!=typeof e)throw new Error("email must be a string");const{refreshTokenKey:s}=this._cache.keys,n=await this._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(s)||""}),{refresh_token:r,access_token:o,access_token_expire:i}=n;if(r)return this.setRefreshToken(r),o&&i?this.setAccessToken(o,i):await this._request.refreshAccessToken(),await this.refreshUserInfo(),we(ve),we(Te,{env:this.config.env,loginType:Ie.EMAIL,persistence:this.config.persistence}),new Le(this.config.env);throw n.code?new Error(`邮箱登录失败: [${n.code}] ${n.message}`):new Error("邮箱登录失败")}async activate(e){return this._request.send("auth.activateEndUserMail",{token:e})}async resetPasswordWithToken(e,t){return this._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})}}class Me extends qe{async signIn(e,t){if("string"!=typeof e)throw new Error("username must be a string");"string"!=typeof t&&(t="",console.warn("password is empty"));const{refreshTokenKey:s}=this._cache.keys,n=await this._request.send("auth.signIn",{loginType:Ie.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(s)||""}),{refresh_token:r,access_token_expire:o,access_token:i}=n;if(r)return this.setRefreshToken(r),i&&o?this.setAccessToken(i,o):await this._request.refreshAccessToken(),await this.refreshUserInfo(),we(ve),we(Te,{env:this.config.env,loginType:Ie.USERNAME,persistence:this.config.persistence}),new Le(this.config.env);throw n.code?new Error(`用户名密码登录失败: [${n.code}] ${n.message}`):new Error("用户名密码登录失败")}}class $e{constructor(e){this.config=e,this._cache=pe(e.env),this._request=De(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),_e(Te,this._onLoginTypeChanged)}get currentUser(){const e=this.hasLoginState();return e&&e.user||null}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}anonymousAuthProvider(){return new Re(this.config)}customAuthProvider(){return new Ne(this.config)}emailAuthProvider(){return new je(this.config)}usernameAuthProvider(){return new Me(this.config)}async signInAnonymously(){return new Re(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new je(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new Me(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){return this._anonymousAuthProvider||(this._anonymousAuthProvider=new Re(this.config)),_e(Ae,this._onAnonymousConverted),await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===Ie.ANONYMOUS)throw new Error("匿名用户不支持登出操作");const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:s}=this._cache.keys,n=this._cache.getStore(e);if(!n)return;const r=await this._request.send("auth.logout",{refresh_token:n});return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(s),we(ve),we(Te,{env:this.config.env,loginType:Ie.NULL,persistence:this.config.persistence}),r}async signUpWithEmailAndPassword(e,t){return this._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})}async sendPasswordResetEmail(e){return this._request.send("auth.sendPasswordResetEmail",{email:e})}onLoginStateChanged(e){_e(ve,(()=>{const t=this.hasLoginState();e.call(this,t)}));const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){_e(Se,e.bind(this))}onAccessTokenRefreshed(e){_e(Pe,e.bind(this))}onAnonymousConverted(e){_e(Ae,e.bind(this))}onLoginTypeChanged(e){_e(Te,(()=>{const t=this.hasLoginState();e.call(this,t)}))}async getAccessToken(){return{accessToken:(await this._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{refreshTokenKey:e}=this._cache.keys;return this._cache.getStore(e)?new Le(this.config.env):null}async isUsernameRegistered(e){if("string"!=typeof e)throw new Error("username must be a string");const{data:t}=await this._request.send("auth.isUsernameRegistered",{username:e});return t&&t.isRegistered}getLoginState(){return Promise.resolve(this.hasLoginState())}async signInWithTicket(e){return new Ne(this.config).signIn(e)}shouldRefreshAccessToken(e){this._request._shouldRefreshAccessTokenHook=e.bind(this)}getUserInfo(){return this._request.send("auth.getUserInfo",{}).then((e=>e.code?e:c(a({},e.data),{requestId:e.seqId})))}getAuthHeader(){const{refreshTokenKey:e,accessTokenKey:t}=this._cache.keys,s=this._cache.getStore(e);return{"x-cloudbase-credentials":this._cache.getStore(t)+"/@@/"+s}}_onAnonymousConverted(e){const{env:t}=e.data;t===this.config.env&&this._cache.updatePersistence(this.config.persistence)}_onLoginTypeChanged(e){const{loginType:t,persistence:s,env:n}=e.data;n===this.config.env&&(this._cache.updatePersistence(s),this._cache.setStore(this._cache.keys.loginTypeKey,t))}}const Ke=function(e,t){t=t||ne();const s=De(this.config.env),{cloudPath:n,filePath:r,onUploadProgress:o,fileType:i="image"}=e;return s.send("storage.getUploadMetadata",{path:n}).then((e=>{const{data:{url:a,authorization:c,token:u,fileId:h,cosFileId:l},requestId:d}=e,f={key:n,signature:c,"x-cos-meta-fileid":l,success_action_status:"201","x-cos-security-token":u};s.upload({url:a,data:f,file:r,name:n,fileType:i,onUploadProgress:o}).then((e=>{201===e.statusCode?t(null,{fileID:h,requestId:d}):t(new Error(`STORAGE_REQUEST_FAIL: ${e.data}`))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},Be=function(e,t){t=t||ne();const s=De(this.config.env),{cloudPath:n}=e;return s.send("storage.getUploadMetadata",{path:n}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},We=function({fileList:e},t){if(t=t||ne(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(let n of e)if(!n||"string"!=typeof n)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};const s={fileid_list:e};return De(this.config.env).send("storage.batchDeleteFile",s).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.delete_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},ze=function({fileList:e},t){t=t||ne(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});let s=[];for(let r of e)"object"==typeof r?(r.hasOwnProperty("fileID")&&r.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),s.push({fileid:r.fileID,max_age:r.maxAge})):"string"==typeof r?s.push({fileid:r}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});const n={file_list:s};return De(this.config.env).send("storage.batchGetDownloadUrl",n).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.download_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},He=async function({fileID:e},t){const s=(await ze.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==s.code)return t?t(s):new Promise((e=>{e(s)}));const n=De(this.config.env);let r=s.download_url;if(r=encodeURI(r),!t)return n.download({url:r});t(await n.download({url:r}))},Je=function({name:e,data:t,query:s,parse:n,search:r},o){const i=o||ne();let a;try{a=t?JSON.stringify(t):""}catch(u){return Promise.reject(u)}if(!e)return Promise.reject(new Error("函数名不能为空"));const c={inQuery:s,parse:n,search:r,function_name:e,request_data:a};return De(this.config.env).send("functions.invokeFunction",c).then((e=>{if(e.code)i(null,e);else{let s=e.data.response_data;if(n)i(null,{result:s,requestId:e.requestId});else try{s=JSON.parse(e.data.response_data),i(null,{result:s,requestId:e.requestId})}catch(t){i(new Error("response data must be json"))}}return i.promise})).catch((e=>{i(e)})),i.promise},Ve={timeout:15e3,persistence:"session"},Ye={};class Ge{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(ae.adapter||(this.requestClient=new ae.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成已中断`})),this.config=a(a({},Ve),e),!0){case this.config.timeout>6e5:console.warn("timeout大于可配置上限[10分钟],已重置为上限数值"),this.config.timeout=6e5;break;case this.config.timeout<100:console.warn("timeout小于可配置下限[100ms],已重置为下限数值"),this.config.timeout=100}return new Ge(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||ae.adapter.primaryStorage||Ve.persistence;var s;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;de[t]=new le(e),fe[t]=new le(c(a({},e),{persistence:"local"}))}(this.config),s=this.config,Ce[s.env]=new xe(s),this.authObj=new $e(this.config),this.authObj}on(e,t){return _e.apply(this,[e,t])}off(e,t){return ke.apply(this,[e,t])}callFunction(e,t){return Je.apply(this,[e,t])}deleteFile(e,t){return We.apply(this,[e,t])}getTempFileURL(e,t){return ze.apply(this,[e,t])}downloadFile(e,t){return He.apply(this,[e,t])}uploadFile(e,t){return Ke.apply(this,[e,t])}getUploadMetadata(e,t){return Be.apply(this,[e,t])}registerExtension(e){Ye[e.name]=e}async invokeExtension(e,t){const s=Ye[e];if(!s)throw Error(`扩展${e} 必须先注册`);return await s.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:s}=function(e){const t=(s=e,"[object Array]"===Object.prototype.toString.call(s)?e:[e]);var s;for(const n of t){const{isMatch:e,genAdapter:t,runtime:s}=n;if(e())return{adapter:t(),runtime:s}}}(e)||{};t&&(ae.adapter=t),s&&(ae.runtime=s)}}var Xe=new Ge;function Qe(e,t,s){void 0===s&&(s={});var n=/\?/.test(t),r="";for(var o in s)""===r?!n&&(t+="?"):r+="&",r+=o+"="+encodeURIComponent(s[o]);return/^http(s)?:\/\//.test(t+=r)?t:""+e+t}class Ze{post(e){const{url:t,data:s,headers:n}=e;return new Promise(((e,r)=>{V.request({url:Qe("https:",t),data:s,method:"POST",header:n,success(t){e(t)},fail(e){r(e)}})}))}upload(e){return new Promise(((t,s)=>{const{url:n,file:r,data:o,headers:i,fileType:a}=e,c=V.uploadFile({url:Qe("https:",n),name:"file",formData:Object.assign({},o),filePath:r,fileType:a,header:i,success(e){const s={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&o.success_action_status&&(s.statusCode=parseInt(o.success_action_status,10)),t(s)},fail(e){s(new Error(e.errMsg||"uploadFile:fail"))}});"function"==typeof e.onUploadProgress&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((t=>{e.onUploadProgress({loaded:t.totalBytesSent,total:t.totalBytesExpectedToSend})}))}))}}const et={setItem(e,t){V.setStorageSync(e,t)},getItem:e=>V.getStorageSync(e),removeItem(e){V.removeStorageSync(e)},clear(){V.clearStorageSync()}};var tt={genAdapter:function(){return{root:{},reqClass:Ze,localStorage:et,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};Xe.useAdapters(tt);const st=Xe,nt=st.init;st.init=function(e){e.env=e.spaceId;const t=nt.call(this,e);t.config.provider="tencent",t.config.spaceId=e.spaceId;const s=t.auth;return t.auth=function(e){const t=s.call(this,e);return["linkAndRetrieveDataWithTicket","signInAnonymously","signOut","getAccessToken","getLoginState","signInWithTicket","getUserInfo"].forEach((e=>{t[e]=K(t[e]).bind(t)})),t},t.customAuth=t.auth,t};var rt=st;function ot(e){return e&&ot(e.__v_raw)||e}function it(){return{token:V.getStorageSync("uni_id_token")||V.getStorageSync("uniIdToken"),tokenExpired:V.getStorageSync("uni_id_token_expired")}}var at=class extends X{getAccessToken(){return new Promise(((e,t)=>{const s="Anonymous_Access_token";this.setAccessToken(s),e(s)}))}setupRequest(e,t){const s=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),n={"Content-Type":"application/json"};"auth"!==t&&(s.token=this.accessToken,n["x-basement-token"]=this.accessToken),n["x-serverless-sign"]=H(s,this.config.clientSecret);const r=z();n["x-client-info"]=JSON.stringify(r);const{token:o}=it();return n["x-client-token"]=o,{url:this.config.requestUrl,method:"POST",data:s,dataType:"json",header:JSON.parse(JSON.stringify(n))}}uploadFileToOSS({url:e,formData:t,name:s,filePath:n,fileType:r,onUploadProgress:o}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:s,filePath:n,fileType:r,success(e){e&&e.statusCode<400?i(e):a(new B({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new B({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof o&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{o({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}uploadFile({filePath:e,cloudPath:t,fileType:s="image",onUploadProgress:n}){if(!t)throw new B({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});let r;return this.getOSSUploadOptionsFromPath({cloudPath:t}).then((t=>{const{url:o,formData:i,name:a}=t.result;r=t.result.fileUrl;const c={url:o,formData:i,name:a,filePath:e,fileType:s};return this.uploadFileToOSS(Object.assign({},c,{onUploadProgress:n}))})).then((()=>this.reportOSSUpload({cloudPath:t}))).then((t=>new Promise(((s,n)=>{t.success?s({success:!0,filePath:e,fileID:r}):n(new B({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){const t={method:"serverless.file.resource.getTempFileURL",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}},ct={init(e){const t=new at(e),s={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return s},t.customAuth=t.auth,t}};function ut({data:e}){let t;t=z();const s=JSON.parse(JSON.stringify(e||{}));if(Object.assign(s,{clientInfo:t}),!s.uniIdToken){const{token:e}=it();e&&(s.uniIdToken=e)}return s}const ht=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var lt=/[\\^$.*+?()[\]{}|]/g,dt=RegExp(lt.source);function ft(e,t,s){return e.replace(new RegExp((n=t)&&dt.test(n)?n.replace(lt,"\\$&"):n,"g"),s);var n}function pt({functionName:e,result:t,logPvd:s}){if(this.config.useDebugFunction&&t&&t.requestId){const n=JSON.stringify({spaceId:this.config.spaceId,functionName:e,requestId:t.requestId});console.log(`[${s}-request]${n}[/${s}-request]`)}}function gt(e){const t=e.callFunction,s=function(s){const n=s.name;s.data=ut.call(e,{data:s.data});const r={aliyun:"aliyun",tencent:"tcb"}[this.config.provider];return t.call(this,s).then((e=>(pt.call(this,{functionName:n,result:e,logPvd:r}),Promise.resolve(e))),(e=>(pt.call(this,{functionName:n,result:e,logPvd:r}),e&&e.message&&(e.message=function({message:e="",extraInfo:t={},formatter:s=[]}={}){for(let n=0;n<s.length;n++){const{rule:r,content:o,mode:i}=s[n],a=e.match(r);if(!a)continue;let c=o;for(let e=1;e<a.length;e++)c=ft(c,`{$${e}}`,a[e]);for(const e in t)c=ft(c,`{${e}}`,t[e]);return"replace"===i?c:e+c}return e}({message:`[${s.name}]: ${e.message}`,formatter:ht,extraInfo:{functionName:n}})),Promise.reject(e))))};e.callFunction=function(e){let t;return t=s.call(this,e),Object.defineProperty(t,"result",{get:()=>(console.warn("当前返回结果为Promise类型不可直接访问其result属性详情请参考https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),t}}const mt=Symbol("CLIENT_DB_INTERNAL");function yt(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=mt,e.__v_raw=void 0,new Proxy(e,{get(e,s,n){if("_uniClient"===s)return null;if(s in e||"string"!=typeof s){const t=e[s];return"function"==typeof t?t.bind(e):t}return t.get(e,s,n)}})}function _t(e){return{on:(t,s)=>{e[t]=e[t]||[],e[t].indexOf(s)>-1||e[t].push(s)},off:(t,s)=>{e[t]=e[t]||[];const n=e[t].indexOf(s);-1!==n&&e[t].splice(n,1)}}}const wt=["db.Geo","db.command","command.aggregate"];function kt(e,t){return wt.indexOf(`${e}.${t}`)>-1}function vt(e){switch(E(e=ot(e))){case"array":return e.map((e=>vt(e)));case"object":return e._internalType===mt||Object.keys(e).forEach((t=>{e[t]=vt(e[t])})),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:return e}}class St{constructor(e,t,s){this.content=e,this.prevStage=t||null,this.udb=null,this._database=s}toJSON(){let e=this;const t=[e.content];for(;e.prevStage;)e=e.prevStage,t.push(e.content);return{$db:t.reverse().map((e=>({$method:e.$method,$param:vt(e.$param)})))}}getAction(){const e=this.toJSON().$db.find((e=>"action"===e.$method));return e&&e.$param&&e.$param[0]}getCommand(){return{$db:this.toJSON().$db.filter((e=>"action"!==e.$method))}}get useAggregate(){let e=this,t=!1;for(;e.prevStage;){e=e.prevStage;const s=e.content.$method;if("aggregate"===s||"pipeline"===s){t=!0;break}}return t}get count(){if(!this.useAggregate)return function(){return this._send("count",Array.from(arguments))};const e=this;return function(){return Tt({$method:"count",$param:vt(Array.from(arguments))},e,this._database)}}get(){return this._send("get",Array.from(arguments))}add(){return this._send("add",Array.from(arguments))}remove(){return this._send("remove",Array.from(arguments))}update(){return this._send("update",Array.from(arguments))}end(){return this._send("end",Array.from(arguments))}set(){throw new Error("clientDB禁止使用set方法")}_send(e,t){const s=this.getAction(),n=this.getCommand();return n.$db.push({$method:e,$param:vt(t)}),this._database._callCloudFunction({action:s,command:n})}}function Tt(e,t,s){return yt(new St(e,t,s),{get(e,t){let n="db";return e&&e.content&&(n=e.content.$method),kt(n,t)?Tt({$method:t},e,s):function(){return Tt({$method:t,$param:vt(Array.from(arguments))},e,s)}}})}function At({path:e,method:t}){return class{constructor(){this.param=Array.from(arguments)}toJSON(){return{$newDb:[...e.map((e=>({$method:e}))),{$method:t,$param:this.param}]}}}}class Pt extends class{constructor({uniClient:e={}}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e.isDefault&&(this._dbCallBacks=F("_globalUniCloudDatabaseCallback")),this.auth=_t(this._authCallBacks),Object.assign(this,_t(this._dbCallBacks)),this.env=yt({},{get:(e,t)=>({$env:t})}),this.Geo=yt({},{get:(e,t)=>At({path:["Geo"],method:t})}),this.serverDate=At({path:[],method:"serverDate"}),this.RegExp=At({path:[],method:"RegExp"})}getCloudEnv(e){if("string"!=typeof e||!e.trim())throw new Error("getCloudEnv参数错误");return{$env:e.replace("$cloudEnv_","")}}_callback(e,t){const s=this._dbCallBacks;s[e]&&s[e].forEach((e=>{e(...t)}))}_callbackAuth(e,t){const s=this._authCallBacks;s[e]&&s[e].forEach((e=>{e(...t)}))}multiSend(){const e=Array.from(arguments),t=e.map((e=>{const t=e.getAction(),s=e.getCommand();if("getTemp"!==s.$db[s.$db.length-1].$method)throw new Error("multiSend只支持子命令内使用getTemp");return{action:t,command:s}}));return this._callCloudFunction({multiCommand:t,queryList:e})}}{_callCloudFunction({action:e,command:t,multiCommand:s,queryList:n}){function r(e,t){if(s&&n)for(let s=0;s<n.length;s++){const r=n[s];r.udb&&"function"==typeof r.udb.setResult&&(t?r.udb.setResult(t):r.udb.setResult(e.result.dataList[s]))}}const o=M($("database","invoke")),i=this._uniClient;return o.then((()=>i.callFunction({name:"DCloud-clientDB",type:"CLIENT_DB",data:{action:e,command:t,multiCommand:s}}))).then((e=>{const{code:t,message:s,token:n,tokenExpired:o,systemInfo:i=[]}=e.result;if(i)for(let r=0;r<i.length;r++){const{level:e,message:t,detail:s}=i[r],n=console[e]||console.log;let o="[System Info]"+t;s&&(o=`${o}\n详细信息:${s}`),n(o)}if(t){const n=new B({message:s,code:t,requestId:e.requestId});return this._callback("error",[n]),Promise.reject(n)}n&&o&&(function({token:e,tokenExpired:t}={}){e&&V.setStorageSync("uni_id_token",e),t&&V.setStorageSync("uni_id_token_expired",t)}({token:n,tokenExpired:o}),this._callbackAuth("refreshToken",[{token:n,tokenExpired:o}]),this._callback("refreshToken",[{token:n,tokenExpired:o}]));const a=e.result.affectedDocs;return"number"==typeof a&&Object.defineProperty(e.result,"affectedDocs",{get:()=>(console.warn("affectedDocs不再推荐使用请使用inserted/deleted/updated/data.length替代"),a)}),M($("database","success"),e).then((()=>M($("database","complete"),e))).then((()=>(r(e,null),Promise.resolve(e))))}),(e=>{const t=new B({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId});return this._callback("error",[t]),/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化请在web控制台保存一次schema以开启clientDB"),M($("database","fail"),e).then((()=>M($("database","complete"),e))).then((()=>(r(null,e),Promise.reject(e))))}))}}let It;const bt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Ot=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function Et(){const e=it().token||"",t=e.split(".");if(!e||3!==t.length)return{uid:null,role:[],permission:[],tokenExpired:0};let s;try{s=JSON.parse((n=t[1],decodeURIComponent(It(n).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))))}catch(r){throw new Error("获取当前用户信息出错,详细错误信息为:"+r.message)}var n;return s.tokenExpired=1e3*s.exp,delete s.exp,delete s.iat,s}It="function"!=typeof atob?function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!Ot.test(e))throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var s,n,r="",o=0;o<e.length;)t=bt.indexOf(e.charAt(o++))<<18|bt.indexOf(e.charAt(o++))<<12|(s=bt.indexOf(e.charAt(o++)))<<6|(n=bt.indexOf(e.charAt(o++))),r+=64===s?String.fromCharCode(t>>16&255):64===n?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return r}:atob;var Ut=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(P((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const s="chooseAndUploadFile:ok",n="chooseAndUploadFile:fail";function r(e,t){return e.tempFiles.forEach(((e,s)=>{e.name||(e.name=e.path.substring(e.path.lastIndexOf("/")+1)),t&&(e.fileType=t),e.cloudPath=Date.now()+"_"+s+e.name.substring(e.name.lastIndexOf("."))})),e.tempFilePaths||(e.tempFilePaths=e.tempFiles.map((e=>e.path))),e}function o(e,t,{onChooseFile:n,onUploadProgress:r}){return t.then((e=>{if(n){const t=n(e);if(void 0!==t)return Promise.resolve(t).then((t=>void 0===t?e:t))}return e})).then((t=>!1===t?{errMsg:s,tempFilePaths:[],tempFiles:[]}:function(e,t,n=5,r){(t=Object.assign({},t)).errMsg=s;const o=t.tempFiles,i=o.length;let a=0;return new Promise((s=>{for(;a<n;)c();function c(){const n=a++;if(n>=i)return void(!o.find((e=>!e.url&&!e.errMsg))&&s(t));const u=o[n];e.uploadFile({filePath:u.path,cloudPath:u.cloudPath,fileType:u.fileType,onUploadProgress(e){e.index=n,e.tempFile=u,e.tempFilePath=u.path,r&&r(e)}}).then((e=>{u.url=e.fileID,n<i&&c()})).catch((e=>{u.errMsg=e.errMsg||e.message,n<i&&c()}))}}))}(e,t,5,r)))}t.initChooseAndUploadFile=function(e){return function(t={type:"all"}){return"image"===t.type?o(e,function(e){const{count:t,sizeType:s,sourceType:o=["album","camera"],extension:i}=e;return new Promise(((e,a)=>{h({count:t,sizeType:s,sourceType:o,extension:i,success(t){e(r(t,"image"))},fail(e){a({errMsg:e.errMsg.replace("chooseImage:fail",n)})}})}))}(t),t):"video"===t.type?o(e,function(e){const{camera:t,compressed:s,maxDuration:o,sourceType:i=["album","camera"],extension:a}=e;return new Promise(((e,c)=>{l({camera:t,compressed:s,maxDuration:o,sourceType:i,extension:a,success(t){const{tempFilePath:s,duration:n,size:o,height:i,width:a}=t;e(r({errMsg:"chooseVideo:ok",tempFilePaths:[s],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:s,size:o,type:t.tempFile&&t.tempFile.type||"",width:a,height:i,duration:n,fileType:"video",cloudPath:""}]},"video"))},fail(e){c({errMsg:e.errMsg.replace("chooseVideo:fail",n)})}})}))}(t),t):o(e,function(e){const{count:t,extension:s}=e;return new Promise(((e,o)=>{let i=d;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(i=wx.chooseMessageFile),"function"!=typeof i)return o({errMsg:n+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});i({type:"all",count:t,extension:s,success(t){e(r(t))},fail(e){o({errMsg:e.errMsg.replace("chooseFile:fail",n)})}})}))}(t),t)}}})));function xt(e){return{props:{localdata:{type:Array,default:()=>[]},options:{type:[Object,Array],default:()=>({})},spaceInfo:{type:Object,default:()=>({})},collection:{type:[String,Array],default:""},action:{type:String,default:""},field:{type:String,default:""},orderby:{type:String,default:""},where:{type:[String,Object],default:""},pageData:{type:String,default:"add"},pageCurrent:{type:Number,default:1},pageSize:{type:Number,default:20},getcount:{type:[Boolean,String],default:!1},gettree:{type:[Boolean,String],default:!1},gettreepath:{type:[Boolean,String],default:!1},startwith:{type:String,default:""},limitlevel:{type:Number,default:10},groupby:{type:String,default:""},groupField:{type:String,default:""},distinct:{type:[Boolean,String],default:!1},foreignKey:{type:String,default:""},loadtime:{type:String,default:"auto"},manual:{type:Boolean,default:!1}},data:()=>({mixinDatacomLoading:!1,mixinDatacomHasMore:!1,mixinDatacomResData:[],mixinDatacomErrorMessage:"",mixinDatacomPage:{}}),created(){this.mixinDatacomPage={current:this.pageCurrent,size:this.pageSize,count:0},this.$watch((()=>{var e=[];return["pageCurrent","pageSize","localdata","collection","action","field","orderby","where","getont","getcount","gettree","groupby","groupField","distinct"].forEach((t=>{e.push(this[t])})),e}),((e,t)=>{if("manual"===this.loadtime)return;let s=!1;const n=[];for(let r=2;r<e.length;r++)e[r]!==t[r]&&(n.push(e[r]),s=!0);e[0]!==t[0]&&(this.mixinDatacomPage.current=this.pageCurrent),this.mixinDatacomPage.size=this.pageSize,this.onMixinDatacomPropsChange(s,n)}))},methods:{onMixinDatacomPropsChange(e,t){},mixinDatacomEasyGet({getone:e=!1,success:t,fail:s}={}){this.mixinDatacomLoading||(this.mixinDatacomLoading=!0,this.mixinDatacomErrorMessage="",this.mixinDatacomGet().then((s=>{this.mixinDatacomLoading=!1;const{data:n,count:r}=s.result;this.getcount&&(this.mixinDatacomPage.count=r),this.mixinDatacomHasMore=n.length<this.pageSize;const o=e?n.length?n[0]:void 0:n;this.mixinDatacomResData=o,t&&t(o)})).catch((e=>{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,s&&s(e)})))},mixinDatacomGet(t={}){let s=e.database(this.spaceInfo);const n=t.action||this.action;n&&(s=s.action(n));const r=t.collection||this.collection;s=Array.isArray(r)?s.collection(...r):s.collection(r);const o=t.where||this.where;o&&Object.keys(o).length&&(s=s.where(o));const i=t.field||this.field;i&&(s=s.field(i));const a=t.foreignKey||this.foreignKey;a&&(s=s.foreignKey(a));const c=t.groupby||this.groupby;c&&(s=s.groupBy(c));const u=t.groupField||this.groupField;u&&(s=s.groupField(u)),!0===(void 0!==t.distinct?t.distinct:this.distinct)&&(s=s.distinct());const h=t.orderby||this.orderby;h&&(s=s.orderBy(h));const l=void 0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,d=void 0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,f=void 0!==t.getcount?t.getcount:this.getcount,p=void 0!==t.gettree?t.gettree:this.gettree,g=void 0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:f},y={limitLevel:void 0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void 0!==t.startwith?t.startwith:this.startwith};return p&&(m.getTree=y),g&&(m.getTreePath=y),s=s.skip(d*(l-1)).limit(d).get(m),s}}}}function Ct(e){if(e.initUniCloudStatus&&"rejected"!==e.initUniCloudStatus)return;let t=Promise.resolve();t=new Promise(((e,t)=>{setTimeout((()=>{e()}),1)})),e.isReady=!1,e.isDefault=!1;const s=e.auth();e.initUniCloudStatus="pending",e.initUniCloud=t.then((()=>s.getLoginState())).then((e=>e?Promise.resolve():s.signInAnonymously())).then((()=>Promise.resolve())).then((({address:e,port:t}={})=>Promise.resolve())).then((()=>{e.isReady=!0,e.initUniCloudStatus="fulfilled"})).catch((t=>{console.error(t),e.initUniCloudStatus="rejected"}))}let Dt=new class{init(e){let t={};const s=!1!==e.debugFunction&&false;switch(e.provider){case"tencent":t=rt.init(Object.assign(e,{useDebugFunction:s}));break;case"aliyun":t=Q.init(Object.assign(e,{useDebugFunction:s}));break;case"private":t=ct.init(Object.assign(e,{useDebugFunction:s}));break;default:throw new Error("未提供正确的provider参数")}var n;return Ct(t),t.reInit=function(){Ct(this)},gt(t),function(e){const t=e.uploadFile;e.uploadFile=function(e){return t.call(this,e)}}(t),function(e){e.database=function(t){if(t&&Object.keys(t).length>0)return e.init(t).database();if(this._database)return this._database;const s=function(e,t={}){return yt(new Pt(t),{get:(e,t)=>kt("db",t)?Tt({$method:t},null,e):function(){return Tt({$method:t,$param:vt(Array.from(arguments))},null,e)}})}(0,{uniClient:e});return this._database=s,s}}(t),(n=t).getCurrentUserInfo=Et,n.chooseAndUploadFile=Ut.initChooseAndUploadFile(n),Object.assign(n,{get mixinDatacom(){return xt(n)}}),n.importObject=function(e){return function(t,s={}){s=function(e,t={}){return e.customUI=t.customUI||e.customUI,Object.assign(e.loadingOptions,t.loadingOptions),Object.assign(e.errorOptions,t.errorOptions),e}({customUI:!1,loadingOptions:{text:"加载中...",mask:!0},errorOptions:{type:"modal",retry:!1}},s);const{customUI:r,loadingOptions:o,errorOptions:i}=s,a=!r;return new Proxy({},{get:(s,r)=>async function s(...c){let u;a&&f({title:o.title,mask:o.mask});try{u=await e.callFunction({name:t,type:"OBJECT",data:{method:r,params:c}})}catch(n){u={result:n}}const{errCode:h,errMsg:l}=u.result||{};if(a&&p(),h){if(a)if("toast"===i.type)g({title:l,icon:"none"});else{if("modal"!==i.type)throw new Error(`Invalid errorOptions.type: ${i.type}`);{const{confirm:e}=await async function({title:e,content:t,showCancel:s,cancelText:n,confirmText:r}={}){return new Promise(((o,i)=>{m({title:e,content:t,showCancel:s,cancelText:n,confirmText:r,success(e){o(e)},fail(){o({confirm:!1,cancel:!0})}})}))}({title:"提示",content:l,showCancel:i.retry,cancelText:"取消",confirmText:i.retry?"重试":"确定"});if(i.retry&&e)return s(...c)}}const e=new B({code:h,message:l,requestId:u.requestId});throw e.detail=u.result,e}return u.result}})}}(n),["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach((e=>{if(!t[e])return;const s=t[e];t[e]=function(){return t.reInit(),s.apply(t,Array.from(arguments))},t[e]=K(t[e],e).bind(t)})),t.init=this.init,t}};(()=>{{const e=C;let t={};if(1===e.length)t=e[0],Dt=Dt.init(t),Dt.isDefault=!0;else{const t=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","database","getCurrentUSerInfo","importObject"];let s;s=e&&e.length>0?"应用有多个服务空间请通过uniCloud.init方法指定要使用的服务空间":"应用未关联服务空间请在uniCloud目录右键关联服务空间",t.forEach((e=>{Dt[e]=function(){return console.error(s),Promise.reject(new B({code:"SYS_ERR",message:s}))}}))}Object.assign(Dt,{get mixinDatacom(){return xt(Dt)}}),Dt.addInterceptor=N,Dt.removeInterceptor=j}})();var qt=Dt;export{qt as S};