"use strict";vare=require("@dcloudio/uni-i18n");"undefined"!=typeofglobalThis?globalThis:"undefined"!=typeofwindow?window:"undefined"!=typeofglobal?global:"undefined"!=typeofself&&self;functiont(e){returne&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}functionn(e,t,n){returne(n={path:t,exports:{},require:function(e,t){returnfunction(){thrownewError("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&n.path)}},n.exports),n.exports}vars=n((function(e,t){varn;e.exports=(n=n||function(e,t){varn=Object.create||function(){functione(){}returnfunction(t){varn;returne.prototype=t,n=newe,e.prototype=null,n}}(),s={},o=s.lib={},r=o.Base={extend:function(e){vart=n(this);returne&&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(){vare=this.extend();returne.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(vartine)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){returnthis.init.prototype.extend(this)}},i=o.WordArray=r.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){vart=this.words,n=e.words,s=this.sigBytes,o=e.sigBytes;if(this.clamp(),s%4)for(varr=0;r<o;r++){vari=n[r>>>2]>>>24-r%4*8&255;t[s+r>>>2]|=i<<24-(s+r)%4*8}elsefor(r=0;r<o;r+=4)t[s+r>>>2]=n[r>>>2];returnthis.sigBytes+=o,this},clamp:function(){vart=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){vare=r.clone.call(this);returne.words=this.words.slice(0),e},random:function(t){for(varn,s=[],o=function(t){t=t;varn=987654321,s=4294967295;returnfunction(){varo=((n=36969*(65535&n)+(n>>16)&s)<<16)+(t=18e3*(65535&t)+(t>>16)&s)&s;returno/=4294967296,(o+=.5)*(e.random()>.5?1:-1)}},r=0;r<t;r+=4){vara=o(4294967296*(n||e.random()));n=987654071*a(),s.push(4294967296*a()|0)}returnnewi.init(s,t)}}),a=s.enc={},c=a.Hex={stringify:function(e){for(vart=e.words,n=e.sigBytes,s=[],o=0;o<n;o++){varr=t[o>>>2]>>>24-o%4*8&255;s.push((r>>>4).toString(16)),s.push((15&r).toString(16))}returns.join("")},parse:function(e){for(vart=e.length,n=[],s=0;s<t;s+=2)n[s>>>3]|=parseInt(e.substr(s,2),16)<<24-s%8*4;returnnewi.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(vart=e.words,n=e.sigBytes,s=[],o=0;o<n;o++){varr=t[o>>>2]>>>24-o%4*8&255;s.push(String.fromCharCode(r))}returns.join("")},parse:function(e){for(vart=e.length,n=[],s=0;s<t;s++)n[s>>>2]|=(255&e.charCodeAt(s))<<24-s%4*8;returnnewi.init(n,t)}},l=a.Utf8={stringify:function(e){try{returndecodeURIComponent(escape(u.stringify(e)))}catch(e){thrownewError("Malformed UTF-8 data")}},parse:function(e){returnu.parse(unescape(encodeURIComponent(e)))}},h=o.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=newi.init,this._nDataBytes=0},_append:function(e){"string"==typeofe&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){varn=this._data,s=n.words,o=n.sigBytes,r=this.blockSize,a=o/(4*r),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*r,u=e.min(4*c,o);if(c){for(varl=0;l<c;l+=r)this._doProcessBlock(s,l);varh=s.splice(0,c);n.sigBytes-=u}returnnewi.init(h,u)},clone:function(){vare=r.clone.call(this);returne._data=this._data.clone(),e},_minBufferSize:0});o.Hasher=h.extend({cfg:r.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){returnthis._append(e),this._process(),this},finalize:function(e){returne&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){returnfunction(t,n){returnnewe.init(n).finalize(t)}},_createHmacHelper:function(e){returnfunction(t,n){returnnewd.HMAC.init(e,n).finalize(t)}}});vard=s.algo={};returns}(Math),n)})),o=(n((function(e,t){varn;e.exports=(n=s,function(e){vart=n,s=t.lib,o=s.WordArray,r=s.Hasher,i=t.algo,a=[];!function(){for(vart=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();varc=i.MD5=r.extend({_doReset:function(){this._hash=newo.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(varn=0;n<16;n++){vars=t+n,o=e[s];e[s]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}varr=this._hash.words,i=e[t+0],c=e[t+1],f=e[t+2],g=e[t+3],p=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],w=e[t+8],k=e[t+9],S=e[t+10],T=e[t+11],v=e[t+12],A=e[t+13],P=e[t+14],I=e[t+15],O=r[0],b=r[1],C=r[2],E=r[3];O=u(O,b,C,E,i,7,a[0]),E=u(E,O,b,C,c,12,a[1]),C=u(C,E,O,b,f,17,a[2]),b=u(b,C,E,O,g,22,a[3]),O=u(O,b,C,E,p,7,a[4]),E=u(E,O,b,C,m,12,a[5]),C=u(C,E,O,b,y,17,a[6]),b=u(b,C,E,O,_,22,a[7]),O=u(O,b,C,E,w,7,a[8]),E=u(E,O,b,C,k,12,a[9]),C=u(C,E,O,b,S,17,a[10]),b=u(b,C,E,O,T,22,a[11]),O=u(O,b,C,E,v,7,a[12]),E=u(E,O,b,C,A,12,a[13]),C=u(C,E,O,b,P,17,a[14]),O=l(O,b=u(b,C,E,O,I,22,a[15]),C,E,c,5,a[16]),E=l(E,O,b,C,y,9,a[17]),C=l(C,E,O,b,T,14,a[18]),b=l(b,C,E,O,i,20,a[19]),O=l(O,b,C,E,m,5,a[20]),E=l(E,O,b,C,S,9,a[21]),C=l(C,E,O,b,I,14,a[22]),b=l(b,C,E,O,p,20,a[23]),O=l(O,b,C,E,k,5,a[24]),E=l(E,O,b,C,P,9,a[25]),C=l(C,E,O,b,g,14,a[26]),b=l(b,C,E,O,w,20,a[27]),O=l(O,b,C,E,A,5,a[28]),E=l(E,O,b,C,f,9,a[29]),C=l(C,E,O,b,_,14,a[30]),O=h(O,b=l(b,C,E,O,v,20,a[31]),C,E,m,4,a[32]),E=h(E,O,b,C,w,11,a[33]),C=h(C,E,O,b,T,16,a[34]),b=h(b,C,E,O,P,23,a[35]),O=h(O,b,C,E,c,4,a[36]),E=h(E,O,b,C,p,11,a[37]),C=h(C,E,O,b,_,16,a[38]),b=h(b,C,E,O,S,23,a[39]),O=h(O,b,C,E,A,4,a[40]),E=h(E,O,b,C,i,11,a[41]),C=h(C,E,O,b,g,16,a[42]),b=h(b,C,E,O,y,23,a[43]),O=h(O,b,C,E,k,4,a[44]),E=h(E,O,b,C,v,11,a[45]),C=h(C,E,O,b,I,16,a[46]),O=d(O,b=h(b,C,E,O,f,23,a[47]),C,E,i,6,a[48]),E=d(E,O,b,C,_,10,a[49]),C=d(C,E,O,b,P,15,a[50]),b=d(b,C,E,O,m,21,a[51]),O=d(O,b,C,E,v,6,a[52]),E=d(E,O,b,C,g,10,a[53]),C=d(C,E,O,b,S,15,a[54]),b=d(b,C,E,O,c,21,a[55]),O=d(O,b,C,E,w,6,a[56]),E=d(E,O,b,C,I,10,a[57]),C=d(C,E,O,b,y,15,a[58]),b=d(b,C,E,O,A,21,a[59]),O=d(O,b,C,E,p,6,a[60]),E=d(E,O,b,C,T,10,a[61]),C=d(C,E,O,b,f,15,a[62]),b=d(b,C,E,O,k,21,a[63]),r[0]=r[0]+O|0,r[1]=r[1]+b|0,r[2]=r[2]+C|0,r[3]=r[3]+E|0},_doFinalize:function(){vart=this._data,n=t.words,s=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;varr=e.floor(s/4294967296),i=s;n[15+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),n[14+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(n.length+1),this._process();for(vara=this._hash,c=a.words,u=0;u<4;u++){varl=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}returna},clone:function(){vare=r.clone.call(this);returne._hash=this._hash.clone(),e}});functionu(e,t,n,s,o,r,i){vara=e+(t&n|~t&s)+o+i;return(a<<r|a>>>32-r)+t}functionl(e,t,n,s,o,r,i){vara=e+(t&s|n&~s)+o+i;return(a<<r|a>>>32-r)+t}functionh(e,t,n,s,o,r,i){vara=e+(t^n^s)+o+i;return(a<<r|a>>>32-r)+t}functiond(e,t,n,s,o,r,i){vara=e+(n^(t|~s))+o+i;return(a<<r|a>>>32-r)+t}t.MD5=r._createHelper(c),t.HmacMD5=r._createHmacHelper(c)}(Math),n.MD5)})),n((function(e,t){varn,o,r;e.exports=(o=(n=s).lib.Base,r=n.enc.Utf8,void(n.algo.HMAC=o.extend({init:function(e,t){e=this._hasher=newe.init,"string"==typeoft&&(t=r.parse(t));varn=e.blockSize,s=4*n;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(varo=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,c=i.words,u=0;u<n;u++)a[u]^=1549556828,c[u]^=909522486;o.sigBytes=i.sigBytes=s,this.reset()},reset:function(){vare=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){returnthis._hasher.update(e),this},finalize:function(e){vart=this._hasher,n=t.finalize(e);returnt.reset(),t.finalize(this._oKey.clone().concat(n))}})))})),n((function(e,t){e.exports=s.HmacMD5})));constr="FUNCTION",i="OBJECT",a="CLIENT_DB";functionc(e){returnObject.prototype.toString.call(e).slice(8,-1).toLowerCase()}functionu(e){return"object"===c(e)}functionl(e){returne&&"string"==typeofe?JSON.parse(e):e}consth="development"===process.env.NODE_ENV,d=process.env.UNI_PLATFORM;letf;switch(d){case"h5":f="web";break;case"app-plus":f="app";break;default:f=d}constg=l(process.env.UNICLOUD_DEBUG),p=l(process.env.UNI_CLOUD_PROVIDER)||[],m=process.env.RUN_BY_HBUILDERX;lety="";try{y=process.env.UNI_APP_ID||""}catch(e){}let_={};functionw(e,t={}){varn,s;returnn=_,s=e,Object.prototype.hasOwnProperty.call(n,s)||(_[e]=t),_[e]}constk=["invoke","success","fail","complete"],S=w("_globalUniCloudInterceptor");functionT(e,t){S[e]||(S[e]={}),u(t)&&Object.keys(t).forEach((n=>{k.indexOf(n)>-1&&function(e,t,n){lets=S[e][t];s||(s=S[e][t]=[]),-1===s.indexOf(n)&&"function"==typeofn&&s.push(n)}(e,n,t[n])}))}functionv(e,t){S[e]||(S[e]={}),u(t)?Object.keys(t).forEach((n=>{k.indexOf(n)>-1&&function(e,t,n){consts=S[e][t];if(!s)return;consto=s.indexOf(n);o>-1&&s.splice(o,1)}(e,n,t[n])})):deleteS[e]}functionA(e,t){returne&&0!==e.length?e.reduce(((e,n)=>e.then((()=>n(t)))),Promise.resolve()):Promise.resolve()}functionP(e,t){returnS[e]&&S[e][t]||[]}constI=w("_globalUniCloudListener"),O="response",b="needLogin",C="refreshToken",E="clientdb",R="cloudfunction",U="cloudobject";functionx(e){returnI[e]||(I[e]=[]),I[e]}functionL(e,t){constn=x(e);n.includes(t)||n.push(t)}functionD(e,t){constn=x(e),s=n.indexOf(t);-1!==s&&n.splice(s,1)}functionN(e,t){constn=x(e);for(lete=0;e<n.length;e++){(0,n[e])(t)}}functionq(e,t){returnt?function(n){lets=!1;if("callFunction"===t){conste=n&&n.type||r;s=e!==r}consto="callFunction"===t&&!s;leti;i=this.isReady?Promise.resolve():this.initUniCloud,n=n||{};consta=i.then((()=>s?Promise.resolve():A(P(t,"invoke"),n))).then((()=>e.call(this,n))).then((e=>s?Promise.resolve(e):A(P(t,"success"),e).then((()=>A(P(t,"complete"),e))).then((()=>(o&&N(O,{type:R,content:e}),Promise.resolve(e))))),(e=>s?Promise.reject(e):A(P(t,"fail"),e).then((()=>A(P(t,"complete"),e))).then((()=>(N(O,{type:R,content:e}),Promise.reject(e))))));if(!(n.success||n.fail||n.complete))returna;a.then((e=>{n.success&&n.success(e),n.complete&&n.complete(e),o&&N(O,{type:R,content:e})}),(e=>{n.fail&&n.fail(e),n.complete&&n.complete(e),o&&N(O,{type:R,content:e})}))}:function(t){if(!((t=t||{}).success||t.fail||t.complete))returne.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)}))}}classFextendsError{constructor(e){super(e.message),this.errMsg=e.message||"",this.errCode=this.code=e.code||"SYSTEM_ERROR",this.requestId=e.requestId}}functionM(){lete,t;try{if(uni.getLaunchOptionsSync){if(uni.getLaunchOptionsSync.toString().indexOf("not yet implemented")>-1)return;const{scene:n,channel:s}=uni.getLaunchOptionsSync();e=s,t=n}}catch(e){}return{channel:e,scene:t}}let$;functionj(){conste=uni.getLocale&&uni.getLocale()||"en";if($)return{...$,locale:e,LOCALE:e};constt=uni.getSystemInfoSync(),{deviceId:n,osName:s,uniPlatform:o,appId:r}=t,i=["pixelRatio","brand","model","system","language","version","platform","host","SDKVersion","swanNativeVersion","app","AppPlatform","fontSizeSetting"];for(lete=0;e<i.length;e++){deletet[i[e]]}return$={PLATFORM:o,OS:s,APPID:r,DEVICEID:n,...M(),...t},{...$,locale:e,LOCALE:e}}varK={sign:function(e,t){letn="";returnObject.keys(e).sort().forEach((function(t){e[t]&&(n=n+"&"+t+"="+e[t])})),n=n.slice(1),o(n,t).toString()},wrappedRequest:function(e,t){returnnewPromise(((n,s)=>{t(Object.assign(e,{complete(e){e||(e={}),h&&"web"===f&&e.errMsg&&0===e.errMsg.indexOf("request:fail")&&console.warn("发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5");constt=e.data&&e.data.header&&e.data.header["x-serverless-request-id"]||e.header&&e.header["request-id"];if(!e.statusCode||e.statusCode>=400)returns(newF({code:"SYS_ERR",message:e.errMsg||"request:fail",requestId:t}));consto=e.data;if(o.error)returns(newF({code:o.error.code,message:o.error.message,requestId:t}));o.result=o.data,o.requestId=t,deleteo.data,n(o)}}))}))}};varB={request:e=>uni.request(e),uploadFile:e=>uni.uploadFile(e),setStorageSync:(e,t)=>uni.setStorageSync(e,t),getStorageSync:e=>uni.getStorageSync(e),removeStorageSync:e=>uni.removeStorageSync(e),clearStorageSync:()=>uni.clearStorageSync()},H={"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"};const{t:W}=e.initVueI18n({"zh-Hans":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},"zh-Hant":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},en:H,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:H},"zh-Hans");varz=class{constructor(e){["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))thrownewError(W("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=B,this._getAccessTokenPromise=null,this._getAccessTokenPromiseStatus=null}gethasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){returnK.wrappedRequest(e,this.adapter.request)}requestAuth(e){returnthis.requestWrapped(e)}request(e,t){returnPromise.resolve().then((()=>this.hasAccessToken?t?this.requestWrapped(e):this.requestWrapped(e).catch((t=>newPromise(((e,n)=>{!t||"GATEWAY_INVALID_TOKEN"!==t.code&&"InvalidParameter.InvalidToken"!==t.code?n(t):e()})).then((()=>this.getAccessToken())).then((()=>{constt=this.rebuildRequest(e);returnthis.request(t,!0)})))):this.getAccessToken().then((()=>{constt=this.rebuildRequest(e);returnthis.request(t,!0)}))))}rebuildRequest(e){constt=Object.assign({},e);returnt.data.token=this.accessToken,t.header["x-basement-token"]=this.accessToken,t.header["x-serverless-sign"]=K.sign(t.data,this.config.clientSecret),t}setupRequest(e,t){constn=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};return"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=K.sign(n,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:s}}getAccessToken(){if("pending"===this._getAccessTokenPromiseStatus)returnthis._getAccessTokenPromise;this._getAccessTokenPromiseStatus="pending";returnthis._getAccessTokenPromise=this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>newPromise(((t,n)=>{e.result&&e.result.accessToken?(this.setAccessToken(e.result.accessToken),this._getAccessTokenPromiseStatus="fulfilled",t(this.accessToken)):(this._getAccessTokenPromiseStatus="rejected",n(newF({code:"AUTH_FAILED",message:"获取accessToken失败"})))}))),(e=>(this._getAccessTokenPromiseStatus="rejected",Promise.reject(e)))),this._getAccessTokenPromise}authorize(){this.getAccessToken()}callFunction(e){constt={method:"serverless.function.runtime.invoke",params:JSON.stringify({functionTarget:e.name,functionArgs:e.data||{}})};returnthis.request(this.setupRequest(t))}getOSSUploadOptionsFromPath(e){constt={method:"serverless.file.resource.generateProximalSign",params:JSON.stringify(e)};returnthis.request(this.setupRequest(t))}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:o,onUploadProgress:r}){returnnewPromise(((i,a)=>{constc=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:o,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?i(e):a(newF({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(newF({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeofr&&c&&"function"==typeofc.onProgressUpdate&&c.onProgressUpdate((e=>{r({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}reportOSSUpload(e){constt={method:"serverless.file.resource.report",params:JSON.stringify(e)};returnthis.request(this.setupRequest(t))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s,config:o}){if("string"!==c(t))thrownewF({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))thrownewF({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});if(/:\/\//.test(t))thrownewF({code:"INVALID_PARAM",message:"cloudPath不合法"});constr=o&&o.envType||this.config.envType;leti,a;returnthis.getOSSUploadOptionsFromPath({env:r,filename:t}).then((t=>{consto=t.result;i=o.id,a="https://"+o.cdnDomain+"/"+o.ossPath;constr={url:"https://"+o.host,formData:{"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:o.accessKeyId,Signature:o.signature,host:o.host,id:i,key:o.ossPath,policy:o.policy,success_action_status:200},fileName:"file",name:"file",filePath:e,fileType:n};returnthis.uploadFileToOSS(Object.assign({},r,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({id:i}))).then((t=>newPromise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:a}):s(newF({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){constt={method:"serverless.file.resource.delete",params:JSON.stringify({id:e[0]})};returnthis.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){returnnewPromise(((t,n)=>{Array.isArray(e)&&0!==e.length||n(newF({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),t({fileList:e.map((e=>({fileID:e,tempFileURL:e})))})}))}};varV={init(e){constt=newz(e),n={signInAnonymously:function(){returnt.authorize()},getLoginState:function(){returnPromise.resolve(!1)}};returnt.auth=function(){returnn},t.customAuth=t.auth,t}};constJ="undefined"!=typeoflocation&&"http:"===location.protocol?"http:":"https:";varY;!function(e){e.local="local",e.none="none",e.session="session"}(Y||(Y={}));varX=function(){};constG=()=>{lete;if(!Promise){e=()=>{},e.promise={};constt=()=>{thrownewF({message:'Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.'})};returnObject.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}constt=newPromise(((t,n)=>{e=(e,s)=>e?n(e):t(s)}));returne.promise=t,e};functionQ(e){returnvoid0===e}functionZ(e){return"[object Null]"===Object.prototype.toString.call(e)}varee;functionte(e){constt=(n=e,"[object Array]"===Object.prototype.toString.call(n)?e:[e]);varn;for(consteoft){const{isMatch:t,genAdapter:n,runtime:s}=e;if(t())return{adapter:n(),runtime:s}}}!function(e){e.WEB="web",e.WX_MP="wx_mp"}(ee||(ee={}));constne={adapter:null,runtime:void0},se=["anonymousUuidKey"];classoeextendsX{constructor(){super(),ne.adapter.root.tcbObject||(ne.adapter.root.tcbObject={})}setItem(e,t){ne.adapter.root.tcbObject[e]=t}getItem(e){returnne.adapter.root.tcbObject[e]}removeItem(e){deletene.adapter.root.tcbObject[e]}clear(){deletene.adapter.root.tcbObject}}functionre(e,t){switch(e){case"local":returnt.localStorage||newoe;case"none":returnnewoe;default:returnt.sessionStorage||newoe}}classie{constructor(e){if(!this._storage){this._persistence=ne.adapter.primaryStorage||e.persistence,this._storage=re(this._persistence,ne.adapter);constt=`access_token_${e.env}`,n=`access_token_expire_${e.env}`,s=`refresh_token_${e.env}`,o=`anonymous_uuid_${e.env}`,r=`login_type_${e.env}`,i=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s,anonymousUuidKey:o,loginTypeKey:r,userInfoKey:i}}}updatePersistence(e){if(e===this._persistence)return;constt="local"===this._persistence;this._persistence=e;constn=re(e,ne.adapter);for(consteinthis.keys){consts=this.keys[e];if(t&&se.includes(e))continue;consto=this._storage.getItem(s);Q(o)||Z(o)||(n.setItem(s,o),this._storage.removeItem(s))}this._storage=n}setStore(e,t,n){if(!this._storage)return;consts={version:n||"localCachev1",content:t},o=JSON.stringify(s);try{this._storage.setItem(e,o)}catch(e){throwe}}getStore(e,t){try{if(!this._storage)return}catch(e){return""}t=t||"localCachev1";constn=this._storage.getItem(e);if(!n)return"";if(n.indexOf(t)>=0){returnJSON.parse(n).content}return""}removeStore(e){this._storage.removeItem(e)}}constae={},ce={};functionue(e){returnae[e]}classle{constructor(e,t){this.data=t||null,this.name=e}}classheextendsle{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}constde=newclass{constructor(){this._listeners={}}on(e,t){returnfunction(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this._listeners),this}off(e,t){returnfunction(e,t,n){if(n&&n[e]){consts=n[e].indexOf(t);-1!==s&&n[e].splice(s,1)}}(e,t,this._listeners),this}fire(e,t){if(einstanceofhe)returnconsole.error(e.error),this;constn="string"==typeofe?newle(e,t||{}):e;consts=n.name;if(this._listens(s)){n.target=this;conste=this._listeners[s]?[...this._listeners[s]]:[];for(consttofe)t.call(this,n)}returnthis}_listens(e){returnthis._listeners[e]&&this._listeners[e].length>0}};functionfe(e,t){de.on(e,t)}functionge(e,t={}){de.fire(e,t)}functionpe(e,t){de.off(e,t)}constme="loginStateChanged",ye="loginStateExpire",_e="loginTypeChanged",we="anonymousConverted",ke="refreshAccessToken";varSe;!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"}(Se||(Se={}));constTe=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],ve={"X-SDK-Version":"1.3.5"};functionAe(e,t,n){consts=e[t];e[t]=function(t){consto={},r={};n.forEach((n=>{const{data:s,headers:i}=n.call(e,t);Object.assign(o,s),Object.assign(r,i)}));consti=t.data;returni&&(()=>{vare;if(e=i,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...i,...o};elsefor(consteino)i.append(e,o[e])})(),t.headers={...t.headers||{},...r},s.call(e,t)}}functionPe(){conste=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...ve,"x-seqid":e}}}classIe{constructor(e={}){vart;this.config=e,this._reqClass=newne.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=ue(this.config.env),this._localCache=(t=this.config.env,ce[t]),Ae(this._reqClass,"post",[Pe]),Ae(this._reqClass,"upload",[Pe]),Ae(this._reqClass,"download",[Pe])}asyncpost(e){returnawaitthis._reqClass.post(e)}asyncupload(e){returnawaitthis._reqClass.upload(e)}asyncdownload(e){returnawaitthis._reqClass.download(e)}asyncrefreshAccessToken(){lete,t;this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken());try{e=awaitthis._refreshAccessTokenPromise}catch(e){t=e}if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throwt;returne}async_refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n,loginTypeKey:s,anonymousUuidKey:o}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);letr=this._cache.getStore(n);if(!r)thrownewF({message:"未登录CloudBase"});consti={refresh_token:r},a=awaitthis.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(s)===Se.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){conste=this._cache.getStore(o),t=this._cache.getStore(n),s=awaitthis.send("auth.signInAnonymously",{anonymous_uuid:e,refresh_token:t});returnthis.setRefreshToken(s.refresh_token),this._refreshAccessToken()}ge(ye),this._cache.removeStore(n)}thrownewF({code:a.data.code,message:`刷新access token失败:${a.data.code}`})}if(a.data.access_token)returnge(ke),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(n),this._cache.setStore(n,a.data.refresh_token),this._refreshAccessToken())}asyncgetAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n}=this._cache.keys;if(!this._cache.getStore(n))thrownewF({message:"refresh token不存在,登录状态异常"});lets=this._cache.getStore(e),o=this._cache.getStore(t),r=!0;returnthis._shouldRefreshAccessTokenHook&&!awaitthis._shouldRefreshAccessTokenHook(s,o)&&(r=!1),(!s||!o||o<Date.now())&&r?this.refreshAccessToken():{accessToken:s,accessTokenExpire:o}}asyncrequest(e,t,n){consts=`x-tcb-trace_${this.config.env}`;leto="application/x-www-form-urlencoded";constr={action:e,env:this.config.env,dataVersion:"2019-08-16",...t};if(-1===Te.indexOf(e)){const{refreshTokenKey:e}=this._cache.keys;this._cache.getStore(e)&&(r.access_token=(awaitthis.getAccessToken()).accessToken)}leti;if("storage.uploadFile"===e){i=newFormData;for(leteini)i.hasOwnProperty(e)&&void0!==i[e]&&i.append(e,r[e]);o="multipart/form-data"}else{o="application/json",i={};for(leteinr)void0!==r[e]&&(i[e]=r[e])}leta={headers:{"content-type":o}};n&&n.onUploadProgress&&(a.onUploadProgress=n.onUploadProgress);constc=this._localCache.getStore(s);c&&(a.headers["X-TCB-Trace"]=c);const{parse:u,inQuery:l,search:h}=t;letd={env:this.config.env};u&&(d.parse=!0),l&&(d={...l,...d});letf=function(e,t,n={}){consts=/\?/.test(t);leto="";for(leteinn)""===o?!s&&(t+="?"):o+="&",o+=`${e}=${encodeURIComponent(n[e])}`;return/^http(s)?\:\/\//.test(t+=o)?t:`${e}${t}`}(J,"//tcb-api.tencentcloudapi.com/web",d);h&&(f+=h);constg=awaitthis.post({url:f,data:i,...a}),p=g.header&&g.header["x-tcb-trace"];if(p&&this._localCache.setStore(s,p),200!==Number(g.status)&&200!==Number(g.statusCode)||!g.data)thrownewF({code:"NETWORK_ERROR",message:"network request error"});returng}asyncsend(e,t={}){constn=awaitthis.request(e,t,{onUploadProgress:t.onUploadProgress});if("ACCESS_TOKEN_EXPIRED"===n.data.code&&-1===Te.indexOf(e)){awaitthis.refreshAccessToken();constn=awaitthis.request(e,t,{onUploadProgress:t.onUploadProgress});if(n.data.code)thrownewF({code:n.data.code,message:n.data.message});returnn.data}if(n.data.code)thrownewF({code:n.data.code,message:n.data.message});returnn.data}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(n),this._cache.setStore(s,e)}}constOe={};functionbe(e){returnOe[e]}classCe{constructor(e){this.config=e,this._cache=ue(e.env),this._request=be(e.env)}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(n),this._cache.setStore(s,e)}setAccessToken(e,t){const{accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys;this._cache.setStore(n,e),this._cache.setStore(s,t)}asyncrefreshUserInfo(){const{data:e}=awaitthis._request.send("auth.getUserInfo",{});returnthis.setLocalUserInfo(e),e}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e)}}classEe{constructor(e){if(!e)thrownewF({code:"PARAM_ERROR",message:"envId is not defined"});this._envId=e,this._cache=ue(this._envId),this._request=be(this._envId),this.setUserInfo()}linkWithTicket(e){if("string"!=typeofe)thrownewF({code:"PARAM_ERROR",message:"ticket must be string"});returnthis._request.send("auth.linkWithTicket",{ticket:e})}linkWithRedirect(e){e.signInWithRedirect()}updatePassword(e,t){returnthis._request.send("auth.updatePassword",{oldPassword:t,newPassword:e})}updateEmail(e){returnthis._request.send("auth.updateEmail",{newEmail:e})}updateUsername(e){if("string"!=typeofe)thrownewF({code:"PARAM_ERROR",message:"username must be a string"});returnthis._request.send("auth.updateUsername",{username:e})}asyncgetLinkedUidList(){const{data:e}=awaitthis._request.send("auth.getLinkedUidList",{});lett=!1;const{users:n}=e;returnn.forEach((e=>{e.wxOpenId&&e.wxPublicId&&(t=!0)})),{users:n,hasPrimaryUid:t}}setPrimaryUid(e){returnthis._request.send("auth.setPrimaryUid",{uid:e})}unlink(e){returnthis._request.send("auth.unlink",{platform:e})}asyncupdate(e){const{nickName:t,gender:n,avatarUrl:s,province:o,country:r,city:i}=e,{data:a}=awaitthis._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:s,province:o,country:r,city:i});this.setLocalUserInfo(a)}asyncrefresh(){const{data:e}=awaitthis._request.send("auth.getUserInfo",{});returnthis.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()}}classRe{constructor(e){if(!e)thrownewF({code:"PARAM_ERROR",message:"envId is not defined"});this._cache=ue(e);const{refreshTokenKey:t,accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys,o=this._cache.getStore(t),r=this._cache.getStore(n),i=this._cache.getStore(s);this.credential={refreshToken:o,accessToken:r,accessTokenExpire:i},this.user=newEe(e)}getisAnonymousAuth(){returnthis.loginType===Se.ANONYMOUS}getisCustomAuth(){returnthis.loginType===Se.CUSTOM}getisWeixinAuth(){returnthis.loginType===Se.WECHAT||this.loginType===Se.WECHAT_OPEN||this.loginType===Se.WECHAT_PUBLIC}getloginType(){returnthis._cache.getStore(this._cache.keys.loginTypeKey)}}classUeextendsCe{asyncsignIn(){this._cache.updatePersistence("local");const{anonymousUuidKey:e,refreshTokenKey:t}=this._cache.keys,n=this._cache.getStore(e)||void0,s=this._cache.getStore(t)||void0,o=awaitthis._request.send("auth.signInAnonymously",{anonymous_uuid:n,refresh_token:s});if(o.uuid&&o.refresh_token){this._setAnonymousUUID(o.uuid),this.setRefreshToken(o.refresh_token),awaitthis._request.refreshAccessToken(),ge(me),ge(_e,{env:this.config.env,loginType:Se.ANONYMOUS,persistence:"local"});conste=newRe(this.config.env);returnawaite.user.refresh(),e}thrownewF({message:"匿名登录失败"})}asynclinkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:n}=this._cache.keys,s=this._cache.getStore(t),o=this._cache.getStore(n),r=awaitthis._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:s,refresh_token:o,ticket:e});if(r.refresh_token)returnthis._clearAnonymousUUID(),this.setRefreshToken(r.refresh_token),awaitthis._request.refreshAccessToken(),ge(we,{env:this.config.env}),ge(_e,{loginType:Se.CUSTOM,persistence:"local"}),{credential:{refreshToken:r.refresh_token}};thrownewF({message:"匿名转化失败"})}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(n,Se.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}classxeextendsCe{asyncsignIn(e){if("string"!=typeofe)thrownewF({param:"PARAM_ERROR",message:"ticket must be a string"});const{refreshTokenKey:t}=this._cache.keys,n=awaitthis._request.send("auth.signInWithTicket",{ticket:e,refresh_token:this._cache.getStore(t)||""});if(n.refresh_token)returnthis.setRefreshToken(n.refresh_token),awaitthis._request.refreshAccessToken(),ge(me),ge(_e,{env:this.config.env,loginType:Se.CUSTOM,persistence:this.config.persistence}),awaitthis.refreshUserInfo(),newRe(this.config.env);thrownewF({message:"自定义登录失败"})}}classLeextendsCe{asyncsignIn(e,t){if("string"!=typeofe)thrownewF({code:"PARAM_ERROR",message:"email must be a string"});const{refreshTokenKey:n}=this._cache.keys,s=awaitthis._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:o,access_token:r,access_token_expire:i}=s;if(o)returnthis.setRefreshToken(o),r&&i?this.setAccessToken(r,i):awaitthis._request.refreshAccessToken(),awaitthis.refreshUserInfo(),ge(me),ge(_e,{env:this.config.env,loginType:Se.EMAIL,persistence:this.config.persistence}),newRe(this.config.env);throws.code?newF({code:s.code,message:`邮箱登录失败: ${s.message}`}):newF({message:"邮箱登录失败"})}asyncactivate(e){returnthis._request.send("auth.activateEndUserMail",{token:e})}asyncresetPasswordWithToken(e,t){returnthis._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})}}classDeextendsCe{asyncsignIn(e,t){if("string"!=typeofe)thrownewF({code:"PARAM_ERROR",message:"username must be a string"});"string"!=typeoft&&(t="",console.warn("password is empty"));const{refreshTokenKey:n}=this._cache.keys,s=awaitthis._request.send("auth.signIn",{loginType:Se.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:o,access_token_expire:r,access_token:i}=s;if(o)returnthis.setRefreshToken(o),i&&r?this.setAccessToken(i,r):awaitthis._request.refreshAccessToken(),awaitthis.refreshUserInfo(),ge(me),ge(_e,{env:this.config.env,loginType:Se.USERNAME,persistence:this.config.persistence}),newRe(this.config.env);throws.code?newF({code:s.code,message:`用户名密码登录失败: ${s.message}`}):newF({message:"用户名密码登录失败"})}}classNe{constructor(e){this.config=e,this._cache=ue(e.env),this._request=be(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),fe(_e,this._onLoginTypeChanged)}getcurrentUser(){conste=this.hasLoginState();returne&&e.user||null}getloginType(){returnthis._cache.getStore(this._cache.keys.loginTypeKey)}anonymousAuthProvider(){returnnewUe(this.config)}customAuthProvider(){returnnewxe(this.config)}emailAuthProvider(){returnnewLe(this.config)}usernameAuthProvider(){returnnewDe(this.config)}asyncsignInAnonymously(){returnnewUe(this.config).signIn()}asyncsignInWithEmailAndPassword(e,t){returnnewLe(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){returnnewDe(this.config).signIn(e,t)}asynclinkAndRetrieveDataWithTicket(e){this._anonymousAuthProvider||(this._anonymousAuthProvider=newUe(this.config)),fe(we,this._onAnonymousConverted);returnawaitthis._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}asyncsignOut(){if(this.loginType===Se.ANONYMOUS)thrownewF({message:"匿名用户不支持登出操作"});const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:n}=this._cache.keys,s=this._cache.getStore(e);if(!s)return;consto=awaitthis._request.send("auth.logout",{refresh_token:s});returnthis._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(n),ge(me),ge(_e,{env:this.config.env,loginType:Se.NULL,persistence:this.config.persistence}),o}asyncsignUpWithEmailAndPassword(e,t){returnthis._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})}asyncsendPasswordResetEmail(e){returnthis._request.send("auth.sendPasswordResetEmail",{email:e})}onLoginStateChanged(e){fe(me,(()=>{constt=this.hasLoginState();e.call(this,t)}));constt=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){fe(ye,e.bind(this))}onAccessTokenRefreshed(e){fe(ke,e.bind(this))}onAnonymousConverted(e){fe(we,e.bind(this))}onLoginTypeChanged(e){fe(_e,(()=>{constt=this.hasLoginState();e.call(this,t)}))}asyncgetAccessToken(){return{accessToken:(awaitthis._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{refreshTokenKey:e}=this._cache.keys;returnthis._cache.getStore(e)?newRe(this.config.env):null}asyncisUsernameRegistered(e){if("string"!=typeofe)thrownewF({code:"PARAM_ERROR",message:"username must be a string"});const{data:t}=awaitthis._request.send("auth.isUsernameRegistered",{username:e});returnt&&t.isRegistered}getLoginState(){returnPromise.resolve(this.hasLoginState())}asyncsignInWithTicket(e){returnnewxe(this.config).signIn(e)}shouldRefreshAccessToken(e){this._request._shouldRefreshAccessTokenHook=e.bind(this)}getUserInfo(){returnthis._request.send("auth.getUserInfo",{}).then((e=>e.code?e:{...e.data,requestId:e.seqId}))}getAuthHeader(){const{refreshTokenKey:e,accessTokenKey:t}=this._cache.keys,n=this._cache.getStore(e);return{"x-cloudbase-credentials":this._cache.getStore(t)+"/@@/"+n}}_onAnonymousConverted(e){const{env:t}=e.data;t===this.config.env&&this._cache.updatePersistence(this.config.persistence)}_onLoginTypeChanged(e){const{loginType:t,persistence:n,env:s}=e.data;s===this.config.env&&(this._cache.updatePersistence(n),this._cache.setStore(this._cache.keys.loginTypeKey,t))}}constqe=function(e,t){t=t||G();constn=be(this.config.env),{cloudPath:s,filePath:o,onUploadProgress:r,fileType:i="image"}=e;returnn.send("storage.getUploadMetadata",{path:s}).then((e=>{const{data:{url:a,authorization:c,token:u,fileId:l,cosFileId:h},requestId:d}=e,f={key:s,signature:c,"x-cos-meta-fileid":h,success_action_status:"201","x-cos-security-token":u};n.upload({url:a,data:f,file:o,name:s,fileType:i,onUploadProgress:r}).then((e=>{201===e.statusCode?t(null,{fileID:l,requestId:d}):t(newF({code:"STORAGE_REQUEST_FAIL",message:`STORAGE_REQUEST_FAIL: ${e.data}`}))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},Fe=function(e,t){t=t||G();constn=be(this.config.env),{cloudPath:s}=e;returnn.send("storage.getUploadMetadata",{path:s}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},Me=function({fileList:e},t){if(t=t||G(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(lettofe)if(!t||"string"!=typeoft)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};constn={fileid_list:e};returnbe(this.config.env).send("storage.batchDeleteFile",n).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.delete_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},$e=function({fileList:e},t){t=t||G(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});letn=[];for(letsofe)"object"==typeofs?(s.hasOwnProperty("fileID")&&s.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),n.push({fileid:s.fileID,max_age:s.maxAge})):"string"==typeofs?n.push({fileid:s}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});consts={file_list:n};returnbe(this.config.env).send("storage.batchGetDownloadUrl",s).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.download_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},je=asyncfunction({fileID:e},t){constn=(await$e.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==n.code)returnt?t(n):newPromise((e=>{e(n)}));consts=be(this.config.env);leto=n.download_url;if(o=encodeURI(o),!t)returns.download({url:o});t(awaits.download({url:o}))},Ke=function({name:e,data:t,query:n,parse:s,search:o},r){consti=r||G();leta;try{a=t?JSON.stringify(t):""}catch(e){returnPromise.reject(e)}if(!e)returnPromise.reject(newF({code:"PARAM_ERROR",message:"函数名不能为空"}));constc={inQuery:n,parse:s,search:o,function_name:e,request_data:a};returnbe(this.config.env).send("functions.invokeFunction",c).then((e=>{if(e.code)i(null,e);else{lett=e.data.response_data;if(s)i(null,{result:t,requestId:e.requestId});elsetry{t=JSON.parse(e.data.response_data),i(null,{result:t,requestId:e.requestId})}catch(e){i(newF({message:"response data must be json"}))}}returni.promise})).catch((e=>{i(e)})),i.promise},Be={timeout:15e3,persistence:"session"},He={};classWe{constructor(e){this.config=e||this.config,this.authObj=void0}init(e){switch(ne.adapter||(this.requestClient=newne.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...Be,...e},!0){casethis.config.timeout>6e5:console.warn("timeout大于可配置上限[10分钟],已重置为上限数值"),this.config.timeout=6e5;break;casethis.config.timeout<100:console.warn("timeout小于可配置下限[100ms],已重置为下限数值"),this.config.timeout=100}returnnewWe(this.config)}auth({persistence:e}={}){if(this.authObj)returnthis.authObj;constt=e||ne.adapter.primaryStorage||Be.persistence;varn;returnt!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;ae[t]=newie(e),ce[t]=newie({...e,persistence:"local"})}(this.config),n=this.config,Oe[n.env]=newIe(n),this.authObj=newNe(this.config),this.authObj}on(e,t){returnfe.apply(this,[e,t])}off(e,t){returnpe.apply(this,[e,t])}callFunction(e,t){returnKe.apply(this,[e,t])}deleteFile(e,t){returnMe.apply(this,[e,t])}getTempFileURL(e,t){return$e.apply(this,[e,t])}downloadFile(e,t){returnje.apply(this,[e,t])}uploadFile(e,t){returnqe.apply(this,[e,t])}getUploadMetadata(e,t){returnFe.apply(this,[e,t])}registerExtension(e){He[e.name]=e}asyncinvokeExtension(e,t){constn=He[e];if(!n)thrownewF({message:`扩展${e} 必须先注册`});returnawaitn.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:n}=te(e)||{};t&&(ne.adapter=t),n&&(ne.runtime=n)}}varze=newWe;functionVe(e,t,n){void0===n&&(n={});vars=/\?/.test(t),o="";for(varrinn)""===o?!s&&(t+="?"):o+="&",o+=r+"="+encodeURIComponent(n[r]);return/^http(s)?:\/\//.test(t+=o)?t:""+e+t}classJe{post(e){const{url:t,data:n,headers:s}=e;returnnewPromise(((e,o)=>{B.request({url:Ve("https:",t),data:n,method:"POST",header:s,success(t){e(t)},fail(e){o(e)}})}))}upload(e){returnnewPromise(((t,n)=>{const{url:s,file:o,data:r,headers:i,fileType:a}=e,c=B.uploadFile({url:Ve("https:",s),name:"file",formData:Object.assign({},r),filePath:o,fileType:a,header:i,success(e){constn={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&r.success_action_status&&(n.statusCode=parseInt(r.success_action_status,10)),t(n)},fail(e){n(newError(e.errMsg||"uploadFile:fail"))}});"function"==typeofe.onUploadProgress&&c&&"function"==typeofc.onProgressUpdate&&c.onProgressUpdate((t=>{e.onUploadProgress({loaded:t.totalBytesSent,total:t.totalBytesExpectedToSend})}))}))}}constYe={setItem(e,t){B.setStorageSync(e,t)},getItem:e=>B.getStorageSync(e),removeItem(e){B.removeStorageSync(e)},clear(){B.clearStorageSync()}};varXe={genAdapter:function(){return{root:{},reqClass:Je,localStorage:Ye,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};ze.useAdapters(Xe);constGe=ze,Qe=Ge.init;Ge.init=function(e){e.env=e.spaceId;constt=Qe.call(this,e);t.config.provider="tencent",t.config.spaceId=e.spaceId;constn=t.auth;returnt.auth=function(e){constt=n.call(this,e);return["linkAndRetrieveDataWithTicket","signInAnonymously","signOut","getAccessToken","getLoginState","signInWithTicket","getUserInfo"].forEach((e=>{t[e]=q(t[e]).bind(t)})),t},t.customAuth=t.auth,t};varZe=Ge;functionet(e){returne&&et(e.__v_raw)||e}functiontt(){return{token:B.getStorageSync("uni_id_token")||B.getStorageSync("uniIdToken"),tokenExpired:B.getStorageSync("uni_id_token_expired")}}functionnt({token:e,tokenExpired:t}={}){e&&B.setStorageSync("uni_id_token",e),t&&B.setStorageSync("uni_id_token_expired",t)}functionst(){if(!h||"web"!==f)return;uni.getStorageSync("__LAST_DCLOUD_APPID")!==y&&(uni.setStorageSync("__LAST_DCLOUD_APPID",y),console.warn("检测到当前项目与上次运行到此端口的项目不一致,自动清理uni-id保存的token信息(仅开发调试时生效)"),B.removeStorageSync("uni_id_token"),B.removeStorageSync("uniIdToken"),B.removeStorageSync("uni_id_token_expired"))}varot=classextendsz{getAccessToken(){returnnewPromise(((e,t)=>{constn="Anonymous_Access_token";this.setAccessToken(n),e(n)}))}setupRequest(e,t){constn=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=K.sign(n,this.config.clientSecret);consto=j();s["x-client-info"]=encodeURIComponent(JSON.stringify(o));const{token:r}=tt();returns["x-client-token"]=r,{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:JSON.parse(JSON.stringify(s))}}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:o,onUploadProgress:r}){returnnewPromise(((i,a)=>{constc=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:o,success(e){e&&e.statusCode<400?i(e):a(newF({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(newF({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeofr&&c&&"function"==typeofc.onProgressUpdate&&c.onProgressUpdate((e=>{r({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s}){if(!t)thrownewF({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});leto;returnthis.getOSSUploadOptionsFromPath({cloudPath:t}).then((t=>{const{url:r,formData:i,name:a}=t.result;o=t.result.fileUrl;constc={url:r,formData:i,name:a,filePath:e,fileType:n};returnthis.uploadFileToOSS(Object.assign({},c,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({cloudPath:t}))).then((t=>newPromise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:o}):s(newF({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){constt={method:"serverless.file.resource.delete",params:JSON.stringify({fileList:e})};returnthis.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){constt={method:"serverless.file.resource.getTempFileURL",params:JSON.stringify({fileList:e})};returnthis.request(this.setupRequest(t))}};varrt={init(e){constt=newot(e),n={signInAnonymously:function(){returnt.authorize()},getLoginState:function(){returnPromise.resolve(!1)}};returnt.auth=function(){returnn},t.customAuth=t.auth,t}};functionit({data:e}){lett;t=j();constn=JSON.parse(JSON.stringify(e||{}));if(Object.assign(n,{clientInfo:t}),!n.uniIdToken){const{token:e}=tt();e&&(n.uniIdToken=e)}returnn}functionat({name:e,data:t}){const{localAddress:n,localPort:s}=this,o={aliyun:"aliyun",tencent:"tcb"}[this.config.provider],r=this.config.spaceId,i=`http://${n}:${s}/system/check-function`,a=`http://${n}:${s}/cloudfunctions/${e}`;returnnewPromise(((t,n)=>{B.request({method:"POST",url:i,data:{name:e,platform:f,provider:o,spaceId:r},timeout:3e3,success(e){t(e)},fail(){t({data:{code:"NETWORK_ERROR",message:"连接本地调试服务失败,请检查客户端是否和主机在同一局域网下,自动切换为已部署的云函数。"}})}})})).then((({data:e}={})=>{const{code:t,message:n}=e||{};return{code:0===t?0:t||"SYS_ERR",message:n||"SYS_ERR"}})).then((({code:n,message:s})=>{if(0!==n){switch(n){case"MODULE_ENCRYPTED":console.error(`此云函数(${e})依赖加密公共模块不可本地调试,自动切换为云端已部署的云函数`);break;case"FUNCTION_ENCRYPTED":console.error(`此云函数(${e})已加密不可本地调试,自动切换为云端已部署的云函数`);break;case"ACTION_ENCRYPTED":console.error(s||"需要访问加密的uni-clientDB-action,自动切换为云端环境");break;case"NETWORK_ERROR":{conste="连接本地调试服务失败,请检查客户端是否和主机在同一局域网下";throwconsole.error(e),newError(e)}case"SWITCH_TO_CLOUD":break;default:{conste=`检测本地调试服务出现错误:${s},请检查网络环境或重启客户端再试`;throwconsole.error(e),newError(e)}}returnthis._originCallFunction({name:e,data:t})}returnnewPromise(((e,n)=>{consts=it.call(this,{data:t});B.request({method:"POST",url:a,data:{provider:o,platform:f,param:s},success:({statusCode:t,data:s}={})=>!t||t>=400?n(newF({code:s.code||"SYS_ERR",message:s.message||"request:fail"})):e({result:s}),fail(e){n(newF({code:e.code||e.errCode||"SYS_ERR",message:e.message||e.errMsg||"request:fail"}))}})}))}))}constct=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];varut=/[\\^$.*+?()[\]{}|]/g,lt=RegExp(ut.source);functionht(e,t,n){returne.replace(newRegExp((s=t)&<.test(s)?s.replace(ut,"\\$&"):s,"g"),n);vars}functiondt({functionName:e,result:t,logPvd:n}){if(this.config.debugLog&&t&&t.requestId){consts=JSON.stringify({spaceId:this.config.spaceId,functionName:e,requestId:t.requestId});console.log(`[${n}-request]${s}[/${n}-request]`)}}functionft(e){constt=e.callFunction,n=function(n){consts=n.name;n.data=it.call(e,{data:n.data});consto={aliyun:"aliyun",tencent:"tcb",tcb:"tcb"}[this.config.provider];returnt.call(this,n).then((e=>(e.errCode=0,dt.call(this,{functionName:s,result:e,logPvd:o}),Promise.resolve(e))),(e=>(dt.call(this,{functionName:s,result:e,logPvd:o}),e&&e.message&&(e.message=function({message:e="",extraInfo:t={},formatter:n=[]}={}){for(lets=0;s<n.length;s++){const{rule:o,content:r,mode:i}=n[s],a=e.match(o);if(!a)continue;letc=r;for(lete=1;e<a.length;e++)c=ht(c,`{$${e}}`,a[e]);for(consteint)c=ht(c,`{${e}}`,t[e]);return"replace"===i?c:e+c}returne}({message:`[${n.name}]: ${e.message}`,formatter:ct,extraInfo:{functionName:s}})),Promise.reject(e))))};e.callFunction=function(t){lets;returnh&&e.debugInfo&&!e.debugInfo.forceRemote&&p?(e._originCallFunction||(e._originCallFunction=n),s=at.call(this,t)):s=n.call(this,t),Object.defineProperty(s,"result",{get:()=>(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),s}}constgt=Symbol("CLIENT_DB_INTERNAL");functionpt(e,t){returne.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=gt,e.__v_raw=void0,newProxy(e,{get(e,n,s){if("_uniClient"===n)returnnull;if(nine||"string"!=typeofn){constt=e[n];return"function"==typeoft?t.bind(e):t}returnt.get(e,n,s)}})}functionmt(e){return{on:(t,n)=>{e[t]=e[t]||[],e[t].indexOf(n)>-1||e[t].push(n)},off:(t,n)=>{e[t]=e[t]||[];consts=e[t].indexOf(n);-1!==s&&e[t].splice(s,1)}}}constyt=["db.Geo","db.command","command.aggregate"];function_t(e,t){returnyt.indexOf(`${e}.${t}`)>-1}functionwt(e){switch(c(e=et(e))){case"array":returne.map((e=>wt(e)));case"object":returne._internalType===gt||Object.keys(e).forEach((t=>{e[t]=wt(e[t])})),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:returne}}functionkt(e){returne&&e.content&&e.content.$method}classSt{constructor(e,t,n){this.content=e,this.prevStage=t||null,this.udb=null,this._database=n}toJSON(){lete=this;constt=[e.content];for(;e.prevStage;)e=e.prevStage,t.push(e.content);return{$db:t.reverse().map((e=>({$method:e.$method,$param:wt(e.$param)})))}}getAction(){conste=this.toJSON().$db.find((e=>"action"===e.$method));returne&&e.$param&&e.$param[0]}getCommand(){return{$db:this.toJSON().$db.filter((e=>"action"!==e.$method))}}getisAggregate(){lete=this;for(;e;){constt=kt(e),n=kt(e.prevStage);if("aggregate"===t&&"collection"===n||"pipeline"===t)return!0;e=e.prevStage}return!1}getisCommand(){lete=this;for(;e;){if("command"===kt(e))return!0;e=e.prevStage}return!1}getisAggregateCommand(){lete=this;for(;e;){constt=kt(e),n=kt(e.prevStage);if("aggregate"===t&&"command"===n)return!0;e=e.prevStage}return!1}getcount(){if(!this.isAggregate)returnfunction(){returnthis._send("count",Array.from(arguments))};conste=this;returnfunction(){returnTt({$method:"count",$param:wt(Array.from(arguments))},e,this._database)}}getremove(){if(!this.isCommand)returnfunction(){returnthis._send("remove",Array.from(arguments))};conste=this;returnfunction(){returnTt({$method:"remove",$param:wt(Array.from(arguments))},e,this._database)}}get(){returnthis._send("get",Array.from(arguments))}add(){returnthis._send("add",Array.from(arguments))}update(){returnthis._send("update",Array.from(arguments))}end(){returnthis._send("end",Array.from(arguments))}getset(){if(!this.isCommand)returnfunction(){thrownewError("JQL禁止使用set方法")};conste=this;returnfunction(){returnTt({$method:"set",$param:wt(Array.from(arguments))},e,this._database)}}_send(e,t){constn=this.getAction(),s=this.getCommand();if(s.$db.push({$method:e,$param:wt(t)}),h){conste=s.$db.find((e=>"collection"===e.$method)),t=e&&e.$param;t&&1===t.length&&"string"==typeofe.$param[0]&&e.$param[0].indexOf(",")>-1&&console.warn("检测到使用JQL语法联表查询时,未使用getTemp先过滤主表数据,在主表数据量大的情况下可能会查询缓慢。\n- 如何优化请参考此文档:https://uniapp.dcloud.net.cn/uniCloud/jql?id=lookup-with-temp \n- 如果主表数据量很小请忽略此信息,项目发行时不会出现此提示。")}returnthis._database._callCloudFunction({action:n,command:s})}}functionTt(e,t,n){returnpt(newSt(e,t,n),{get(e,t){lets="db";returne&&e.content&&(s=e.content.$method),_t(s,t)?Tt({$method:t},e,n):function(){returnTt({$method:t,$param:wt(Array.from(arguments))},e,n)}}})}functionvt({path:e,method:t}){returnclass{constructor(){this.param=Array.from(arguments)}toJSON(){return{$newDb:[...e.map((e=>({$method:e}))),{$method:t,$param:this.param}]}}}}classAtextendsclass{constructor({uniClient:e={}}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e.isDefault&&(this._dbCallBacks=w("_globalUniCloudDatabaseCallback")),this.auth=mt(this._authCallBacks),Object.assign(this,mt(this._dbCallBacks)),this.env=pt({},{get:(e,t)=>({$env:t})}),this.Geo=pt({},{get:(e,t)=>vt({path:["Geo"],method:t})}),this.serverDate=vt({path:[],method:"serverDate"}),this.RegExp=vt({path:[],method:"RegExp"})}getCloudEnv(e){if("string"!=typeofe||!e.trim())thrownewError("getCloudEnv参数错误");return{$env:e.replace("$cloudEnv_","")}}_callback(e,t){constn=this._dbCallBacks;n[e]&&n[e].forEach((e=>{e(...t)}))}_callbackAuth(e,t){constn=this._authCallBacks;n[e]&&n[e].forEach((e=>{e(...t)}))}multiSend(){conste=Array.from(arguments),t=e.map((e=>{constt=e.getAction(),n=e.getCommand();if("getTemp"!==n.$db[n.$db.length-1].$method)thrownewError("multiSend只支持子命令内使用getTemp");return{action:t,command:n}}));returnthis._callCloudFunction({multiCommand:t,queryList:e})}}{_callCloudFunction({action:e,command:t,multiCommand:n,queryList:s}){functiono(e,t){if(n&&s)for(letn=0;n<s.length;n++){consto=s[n];o.udb&&"function"==typeofo.udb.setResult&&(t?o.udb.setResult(t):o.udb.setResult(e.result.dataList[n]))}}constr=this;functioni(e){returnr._callback("error",[e]),A(P("database","fail"),e).then((()=>A(P("database","complete"),e))).then((()=>(o(null,e),N(O,{type:E,content:e}),Promise.reject(e))))}constc=A(P("database","invoke")),u=this._uniClient;returnc.then((()=>u.callFunction({name:"DCloud-clientDB",type:a,data:{action:e,command:t,multiCommand:n}}))).then((e=>{const{code:t,message:n,token:s,tokenExpired:r,systemInfo:a=[]}=e.result;if(a)for(lete=0;e<a.length;e++){const{level:t,message:n,detail:s}=a[e],o=console["app"===f&&"warn"===t?"error":t]||console.log;letr="[System Info]"+n;s&&(r=`${r}\n详细信息:${s}`),o(r)}if(t){returni(newF({code:t,message:n,requestId:e.requestId}))}e.result.errCode=e.result.code,e.result.errMsg=e.result.message,s&&r&&(nt({token:s,tokenExpired:r}),this._callbackAuth("refreshToken",[{token:s,tokenExpired:r}]),this._callback("refreshToken",[{token:s,tokenExpired:r}]),N(C,{token:s,tokenExpired:r}));constc=[{prop:"affectedDocs",tips:"affectedDocs不再推荐使用,请使用inserted/deleted/updated/data.length替代"},{prop:"code",tips:"code不再推荐使用,请使用errCode替代"},{prop:"message",tips:"message不再推荐使用,请使用errMsg替代"}];for(lett=0;t<c.length;t++){const{prop:n,tips:s}=c[t];if(nine.result){constt=e.result[n];Object.defineProperty(e.result,n,{get:()=>(console.warn(s),t)})}}returnfunction(e){returnA(P("database","success"),e).then((()=>A(P("database","complete"),e))).then((()=>(o(e,null),N(O,{type:E,content:e}),Promise.resolve(e))))}(e)}),(e=>{/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化,请在web控制台保存一次schema以开启clientDB");returni(newF({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId}))}))}}functionPt(e){e.database=function(t){if(t&&Object.keys(t).length>0)returne.init(t).database();if(this._database)returnthis._database;constn=function(e,t={}){returnpt(newe(t),{get:(e,t)=>_t("db",t)?Tt({$method:t},null,e):function(){returnTt({$method:t,$param:wt(Array.from(arguments))},null,e)}})}(At,{uniClient:e});returnthis._database=n,n}}varIt={};constOt="token无效,跳转登录页面",bt="token过期,跳转登录页面",Ct={TOKEN_INVALID_TOKEN_EXPIRED:bt,TOKEN_INVALID_INVALID_CLIENTID:Ot,TOKEN_INVALID:Ot,TOKEN_INVALID_WRONG_TOKEN:Ot,TOKEN_INVALID_ANONYMOUS_USER:Ot},Et={"uni-id-token-expired":bt,"uni-id-check-token-failed":Ot,"uni-id-token-not-exist":Ot,"uni-id-check-device-feature-failed":Ot};functionRt(e,t){letn="";returnn=e?`${e}/${t}`:t,n.replace(/^\//,"")}functionUt(e=[],t=""){constn=[],s=[];returne.forEach((e=>{!0===e.needLogin?n.push(Rt(t,e.path)):!1===e.needLogin&&s.push(Rt(t,e.path))})),{needLoginPage:n,notNeedLoginPage:s}}functionxt(e="",t={}){if(!e)return!1;if(!(t&&t.list&&t.list.length))return!1;constn=t.list,s=e.split("?")[0].replace(/^\//,"");returnn.some((e=>e.pagePath===s))}constLt=!!It.uniIdRouter;const{loginPage:Dt,routerNeedLogin:Nt,resToLogin:qt,needLoginPage:Ft,notNeedLoginPage:Mt,loginPageInTabBar:$t}=function({pages:e=[],subPackages:t=[],uniIdRouter:n={},tabBar:s={}}=It){const{loginPage:o,needLogin:r=[],resToLogin:i=!0}=n,{needLoginPage:a,notNeedLoginPage:c}=Ut(e),{needLoginPage:u,notNeedLoginPage:l}=function(e=[]){constt=[],n=[];returne.forEach((e=>{const{root:s,pages:o=[]}=e,{needLoginPage:r,notNeedLoginPage:i}=Ut(o,s);t.push(...r),n.push(...i)})),{needLoginPage:t,notNeedLoginPage:n}}(t);return{loginPage:o,routerNeedLogin:r,resToLogin:i,needLoginPage:[...a,...u],notNeedLoginPage:[...c,...l],loginPageInTabBar:xt(o,s)}}();functionjt(e){constt=function(e){constt=getCurrentPages(),n=t[t.length-1].route,s=e.charAt(0),o=e.split("?")[0];if("/"===s)returno;constr=o.replace(/^\//,"").split("/"),i=n.split("/");i.pop();for(lete=0;e<r.length;e++){constt=r[e];".."===t?i.pop():"."!==t&&i.push(t)}return""===i[0]&&i.shift(),i.join("/")}(e).replace(/^\//,"");return!(Mt.indexOf(t)>-1)&&(Ft.indexOf(t)>-1||Nt.some((t=>function(e,t){returnnewRegExp(t).test(e)}(e,t))))}functionKt(e,t){return"/"!==e.charAt(0)&&(e="/"+e),t?e.indexOf("?")>-1?e+`&uniIdRedirectUrl=${encodeURIComponent(t)}`:e+`?uniIdRedirectUrl=${encodeURIComponent(t)}`:e}functionBt(){conste=["navigateTo","redirectTo","reLaunch","switchTab"];for(lett=0;t<e.length;t++){constn=e[t];uni.addInterceptor(n,{invoke(e){const{token:t,tokenExpired:s}=tt();leto;if(t){if(s<Date.now()){conste="uni-id-token-expired";o={errCode:e,errMsg:Et[e]}}}else{conste="uni-id-check-token-failed";o={errCode:e,errMsg:Et[e]}}if(jt(e.url)&&o){o.uniIdRedirectUrl=e.url;if(x(b).length>0)returnsetTimeout((()=>{N(b,o)}),0),e.url="",!1;if(!Dt)returne;constt=Kt(Dt,o.uniIdRedirectUrl);if($t){if("navigateTo"===n||"redirectTo"===n)returnsetTimeout((()=>{uni.switchTab({url:t})})),!1}elseif("switchTab"===n)returnsetTimeout((()=>{uni.navigateTo({url:t})})),!1;e.url=t}returne}})}}functionHt(){this.onResponse((e=>{const{type:t,content:n}=e;lets=!1;switch(t){case"cloudobject":s=function(e){const{errCode:t}=e;returntinEt}(n);break;case"clientdb":s=function(e){const{errCode:t}=e;returntinCt}(n)}s&&function(e={}){constt=x(b),n=getCurrentPages(),s=n[n.length-1],o=s&&s.$page&&s.$page.fullPath;if(t.length>0)returnN(b,Object.assign({uniIdRedirectUrl:o},e));Dt&&uni.navigateTo({url:Kt(Dt,o)})}(n)}))}functionWt(e){e.onNeedLogin=function(e){L(b,e)},e.offNeedLogin=function(e){D(b,e)},Lt&&(w("uni-cloud-status").needLoginInit||(w("uni-cloud-status").needLoginInit=!0,functiont(){letn=!1;if("function"==typeofgetCurrentPages){constt=getCurrentPages();t&&t[0]&&(Bt.call(e),n=!0)}n||setTimeout((()=>{t()}),30)}(),qt&&Ht.call(e)))}functionzt(e){!function(e){e.onResponse=function(e){L(O,e)},e.offResponse=function(e){D(O,e)}}(e),Wt(e),function(e){e.onRefreshToken=function(e){L(C,e)},e.offRefreshToken=function(e){D(C,e)}}(e)}letVt;constJt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Yt=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;functionXt(){conste=tt().token||"",t=e.split(".");if(!e||3!==t.length)return{uid:null,role:[],permission:[],tokenExpired:0};letn;try{n=JSON.parse((s=t[1],decodeURIComponent(Vt(s).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))))}catch(e){thrownewError("获取当前用户信息出错,详细错误信息为:"+e.message)}vars;returnn.tokenExpired=1e3*n.exp,deleten.exp,deleten.iat,n}Vt="function"!=typeofatob?function(e){if(e=String(e).replace(/[\t\n\f\r]+/g,""),!Yt.test(e))thrownewError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");vart;e+="==".slice(2-(3&e.length));for(varn,s,o="",r=0;r<e.length;)t=Jt.indexOf(e.charAt(r++))<<18|Jt.indexOf(e.charAt(r++))<<12|(n=Jt.indexOf(e.charAt(r++)))<<6|(s=Jt.indexOf(e.charAt(r++))),o+=64===n?String.fromCharCode(t>>16&255):64===s?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);returno}:atob;varGt=n((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});constn="chooseAndUploadFile:ok",s="chooseAndUploadFile:fail";functiono(e,t){returne.tempFiles.forEach(((e,n)=>{e.name||(e.name=e.path.substring(e.path.lastIndexOf("/")+1)),t&&(e.fileType=t),e.cloudPath=Date.now()+"_"+n+e.name.substring(e.name.lastIndexOf("."))})),e.tempFilePaths||(e.tempFilePaths=e.tempFiles.map((e=>e.path))),e}functionr(e,t,{onChooseFile:s,onUploadProgress:o}){returnt.then((e=>{if(s){constt=s(e);if(void0!==t)returnPromise.resolve(t).then((t=>void0===t?e:t))}returne})).then((t=>!1===t?{errMsg:n,tempFilePaths:[],tempFiles:[]}:function(e,t,s=5,o){(t=Object.assign({},t)).errMsg=n;constr=t.tempFiles,i=r.length;leta=0;returnnewPromise((n=>{for(;a<s;)c();functionc(){consts=a++;if(s>=i)returnvoid(!r.find((e=>!e.url&&!e.errMsg))&&n(t));constu=r[s];e.uploadFile({filePath:u.path,cloudPath:u.cloudPath,fileType:u.fileType,onUploadProgress(e){e.index=s,e.tempFile=u,e.tempFilePath=u.path,o&&o(e)}}).then((e=>{u.url=e.fileID,s<i&&c()})).catch((e=>{u.errMsg=e.errMsg||e.message,s<i&&c()}))}}))}(e,t,5,o)))}t.initChooseAndUploadFile=function(e){returnfunction(t={type:"all"}){return"image"===t.type?r(e,function(e){const{count:t,sizeType:n,sourceType:r=["album","camera"],extension:i}=e;returnnewPromise(((e,a)=>{uni.chooseImage({count:t,sizeType:n,sourceType:r,extension:i,success(t){e(o(t,"image"))},fail(e){a({errMsg:e.errMsg.replace("chooseImage:fail",s)})}})}))}(t),t):"video"===t.type?r(e,function(e){const{camera:t,compressed:n,maxDuration:r,sourceType:i=["album","camera"],extension:a}=e;returnnewPromise(((e,c)=>{uni.chooseVideo({camera:t,compressed:n,maxDuration:r,sourceType:i,extension:a,success(t){const{tempFilePath:n,duration:s,size:r,height:i,width:a}=t;e(o({errMsg:"chooseVideo:ok",tempFilePaths:[n],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:n,size:r,type:t.tempFile&&t.tempFile.type||"",width:a,height:i,duration:s,fileType:"video",cloudPath:""}]},"video"))},fail(e){c({errMsg:e.errMsg.replace("chooseVideo:fail",s)})}})}))}(t),t):r(e,function(e){const{count:t,extension:n}=e;returnnewPromise(((e,r)=>{leti=uni.chooseFile;if("undefined"!=typeofwx&&"function"==typeofwx.chooseMessageFile&&(i=wx.chooseMessageFile),"function"!=typeofi)returnr({errMsg:s+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});i({type:"all",count:t,extension:n,success(t){e(o(t))},fail(e){r({errMsg:e.errMsg.replace("chooseFile:fail",s)})}})}))}(t),t)}}})),Qt=t(Gt);constZt="manual";functionen(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((()=>{vare=[];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(this.loadtime===Zt)return;letn=!1;consts=[];for(leto=2;o<e.length;o++)e[o]!==t[o]&&(s.push(e[o]),n=!0);e[0]!==t[0]&&(this.mixinDatacomPage.current=this.pageCurrent),this.mixinDatacomPage.size=this.pageSize,this.onMixinDatacomPropsChange(n,s)}))},methods:{onMixinDatacomPropsChange(e,t){},mixinDatacomEasyGet({getone:e=!1,success:t,fail:n}={}){this.mixinDatacomLoading||(this.mixinDatacomLoading=!0,this.mixinDatacomErrorMessage="",this.mixinDatacomGet().then((n=>{this.mixinDatacomLoading=!1;const{data:s,count:o}=n.result;this.getcount&&(this.mixinDatacomPage.count=o),this.mixinDatacomHasMore=s.length<this.pageSize;constr=e?s.length?s[0]:void0:s;this.mixinDatacomResData=r,t&&t(r)})).catch((e=>{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,n&&n(e)})))},mixinDatacomGet(t={}){letn=e.database(this.spaceInfo);consts=t.action||this.action;s&&(n=n.action(s));consto=t.collection||this.collection;n=Array.isArray(o)?n.collection(...o):n.collection(o);constr=t.where||this.where;r&&Object.keys(r).length&&(n=n.where(r));consti=t.field||this.field;i&&(n=n.field(i));consta=t.foreignKey||this.foreignKey;a&&(n=n.foreignKey(a));constc=t.groupby||this.groupby;c&&(n=n.groupBy(c));constu=t.groupField||this.groupField;u&&(n=n.groupField(u));!0===(void0!==t.distinct?t.distinct:this.distinct)&&(n=n.distinct());constl=t.orderby||this.orderby;l&&(n=n.orderBy(l));consth=void0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,d=void0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,f=void0!==t.getcount?t.getcount:this.getcount,g=void0!==t.gettree?t.gettree:this.gettree,p=void0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:f},y={limitLevel:void0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void0!==t.startwith?t.startwith:this.startwith};returng&&(m.getTree=y),p&&(m.getTreePath=y),n=n.skip(d*(h-1)).limit(d).get(m),n}}}}functiontn(e){returnfunction(t,n={}){n=function(e,t={}){returne.customUI=t.customUI||e.customUI,Object.assign(e.loadingOptions,t.loadingOptions),Object.assign(e.errorOptions,t.errorOptions),e}({customUI:!1,loadingOptions:{title:"加载中...",mask:!0},errorOptions:{type:"modal",retry:!1}},n);const{customUI:s,loadingOptions:o,errorOptions:r}=n,a=!s;returnnewProxy({},{get:(n,s)=>asyncfunctionn(...c){letu;a&&uni.showLoading({title:o.title,mask:o.mask});try{u=awaite.callFunction({name:t,type:i,data:{method:s,params:c}})}catch(e){u={result:e}}const{errCode:l,errMsg:h,newToken:d}=u.result||{};if(a&&uni.hideLoading(),d&&d.token&&d.tokenExpired&&(nt(d),N(C,{...d})),l){if(a)if("toast"===r.type)uni.showToast({title:h,icon:"none"});else{if("modal"!==r.type)thrownewError(`Invalid errorOptions.type: ${r.type}`);{const{confirm:e}=awaitasyncfunction({title:e,content:t,showCancel:n,cancelText:s,confirmText:o}={}){returnnewPromise(((r,i)=>{uni.showModal({title:e,content:t,showCancel:n,cancelText:s,confirmText:o,success(e){r(e)},fail(){r({confirm:!1,cancel:!0})}})}))}({title:"提示",content:h,showCancel:r.retry,cancelText:"取消",confirmText:r.retry?"重试":"确定"});if(r.retry&&e)returnn(...c)}}conste=newF({code:l,message:h,requestId:u.requestId});throwe.detail=u.result,N(O,{type:U,content:e}),e}returnN(O,{type:U,content:u.result}),u.result}})}}asyncfunctionnn(e,t){constn=`http://${e}:${t}/system/ping`;try{conste=await(s={url:n,timeout:500},newPromise(((e,t)=>{B.request({...s,success(t){e(t)},fail(e){t(e)}})})));return!(!e.data||0!==e.data.code)}catch(e){return!1}vars}functionsn(e){if(e.initUniCloudStatus&&"rejected"!==e.initUniCloudStatus)return;lett=Promise.resolve();e.isReady=!1,e.isDefault=!1;constn=e.auth();e.initUniCloudStatus="pending",e.initUniCloud=t.then((()=>n.getLoginState())).then((e=>e?Promise.resolve():n.signInAnonymously())).then((()=>{if(!h)returnPromise.resolve();if("app"===f&&"ios"===uni.getSystemInfoSync().osName){const{osName:e,osVersion:t}=uni.getSystemInfoSync();"ios"===e&&function(e){if(!e||"string"!=typeofe)return0;constt=e.match(/^(\d+)./);returnt&&t[1]?parseInt(t[1]):0}(t)>=14&&console.warn("iOS 14及以上版本连接uniCloud本地调试服务需要允许客户端查找并连接到本地网络上的设备(仅开发模式生效,发行模式会连接uniCloud云端服务)")}if(h&&e.debugInfo){const{address:t,servePort:n}=e.debugInfo;returnasyncfunction(e,t){letn;for(lets=0;s<e.length;s++){consto=e[s];if(awaitnn(o,t)){n=o;break}}return{address:n,port:t}}(t,n)}})).then((({address:t,port:n}={})=>{if(!h)returnPromise.resolve();consts=console["app"===f?"error":"warn"];if(t)e.localAddress=t,e.localPort=n;elseif(e.debugInfo){lett="";"remote"===e.debugInfo.initialLaunchType?(e.debugInfo.forceRemote=!0,t="当前客户端和HBuilderX不在同一局域网下(或其他网络原因无法连接HBuilderX),uniCloud本地调试服务不对当前客户端生效。\n- 如果不使用uniCloud本地调试服务,请直接忽略此信息。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs"):t="无法连接uniCloud本地调试服务,请检查当前客户端是否与主机在同一局域网下。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs","web"===f&&(t+="\n- 部分浏览器开启节流模式之后访问本地地址受限,请检查是否启用了节流模式"),0===f.indexOf("mp-")&&(t+="\n- 小程序中如何使用uniCloud,请参考:https://uniapp.dcloud.net.cn/uniCloud/publish.html#useinmp"),s(t)}})).then((()=>{st(),e.isReady=!0,e.initUniCloudStatus="fulfilled"})).catch((t=>{console.error(t),e.initUniCloudStatus="rejected"}))}leton=newclass{init(e){lett={};constn=h&&!1;switch(e.provider){case"tcb":case"tencent":t=Ze.init(Object.assign(e,{debugLog:n}));break;case"aliyun":t=V.init(Object.assign(e,{debugLog:n}));break;case"private":t=rt.init(Object.assign(e,{debugLog:n}));break;default:thrownewError("未提供正确的provider参数")}consts=g;h&&s&&!s.code&&(t.debugInfo=s),sn(t),t.reInit=function(){sn(this)},ft(t),function(e){constt=e.uploadFile;e.uploadFile=function(e){returnt.call(this,e)}}(t),Pt(t),function(e){e.getCurrentUserInfo=Xt,e.chooseAndUploadFile=Qt.initChooseAndUploadFile(e),Object.assign(e,{getmixinDatacom(){returnen(e)}}),e.importObject=tn(e)}(t);return["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach((e=>{if(!t[e])return;constn=t[e];t[e]=function(){returnt.reInit(),n.apply(t,Array.from(arguments))},t[e]=q(t[e],e).bind(t)})),t.init=this.init,t}};(()=>{{conste=p;lett={};if(e&&1===e.length)t=e[0],on=on.init(t),on.isDefault=!0;else{constt=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","database","getCurrentUSerInfo","importObject"];letn;n=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":m?"应用未关联服务空间,请在uniCloud目录右键关联服务空间":"uni-app cli项目内使用uniCloud需要使用HBuilderX的运行菜单运行项目,且需要在uniCloud目录关联服务空间",t.forEach((e=>{on[e]=function(){returnconsole.error(n),Promise.reject(newF({code:"SYS_ERR",message:n}))}}))}Object.assign(on,{getmixinDatacom(){returnen(on)}}),zt(on),on.addInterceptor=T,on.removeInterceptor=v}})();varrn=on;module.exports=rn;