H5-contact/node_modules/@dcloudio/uni-cloud/dist/uni-cloud-x.cjs.js

2 lines
116 KiB
JavaScript
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.

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function t(e,t,n){return e(n={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&n.path)}},n.exports),n.exports}var n=t((function(e,t){var n;e.exports=(n=n||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),s={},r=s.lib={},i=r.Base={extend:function(e){var t=n(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)}},o=r.WordArray=i.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){var t=this.words,n=e.words,s=this.sigBytes,r=e.sigBytes;if(this.clamp(),s%4)for(var i=0;i<r;i++){var o=n[i>>>2]>>>24-i%4*8&255;t[s+i>>>2]|=o<<24-(s+i)%4*8}else for(i=0;i<r;i+=4)t[s+i>>>2]=n[i>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,s=[],r=function(t){t=t;var n=987654321,s=4294967295;return function(){var r=((n=36969*(65535&n)+(n>>16)&s)<<16)+(t=18e3*(65535&t)+(t>>16)&s)&s;return r/=4294967296,(r+=.5)*(e.random()>.5?1:-1)}},i=0;i<t;i+=4){var a=r(4294967296*(n||e.random()));n=987654071*a(),s.push(4294967296*a()|0)}return new o.init(s,t)}}),a=s.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],r=0;r<n;r++){var i=t[r>>>2]>>>24-r%4*8&255;s.push((i>>>4).toString(16)),s.push((15&i).toString(16))}return s.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s<t;s+=2)n[s>>>3]|=parseInt(e.substr(s,2),16)<<24-s%8*4;return new o.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],r=0;r<n;r++){var i=t[r>>>2]>>>24-r%4*8&255;s.push(String.fromCharCode(i))}return s.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s<t;s++)n[s>>>2]|=(255&e.charCodeAt(s))<<24-s%4*8;return new o.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},d=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,s=n.words,r=n.sigBytes,i=this.blockSize,a=r/(4*i),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*i,u=e.min(4*c,r);if(c){for(var l=0;l<c;l+=i)this._doProcessBlock(s,l);var d=s.splice(0,c);n.sigBytes-=u}return new o.init(d,u)},clone:function(){var e=i.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});r.Hasher=d.extend({cfg:i.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}});var h=s.algo={};return s}(Math),n)})),s=n,r=(t((function(e,t){var n;e.exports=(n=s,function(e){var t=n,s=t.lib,r=s.WordArray,i=s.Hasher,o=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=o.MD5=i.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var s=t+n,r=e[s];e[s]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}var i=this._hash.words,o=e[t+0],c=e[t+1],p=e[t+2],f=e[t+3],g=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],w=e[t+8],v=e[t+9],I=e[t+10],S=e[t+11],k=e[t+12],C=e[t+13],A=e[t+14],T=e[t+15],b=i[0],x=i[1],P=i[2],O=i[3];b=u(b,x,P,O,o,7,a[0]),O=u(O,b,x,P,c,12,a[1]),P=u(P,O,b,x,p,17,a[2]),x=u(x,P,O,b,f,22,a[3]),b=u(b,x,P,O,g,7,a[4]),O=u(O,b,x,P,m,12,a[5]),P=u(P,O,b,x,y,17,a[6]),x=u(x,P,O,b,_,22,a[7]),b=u(b,x,P,O,w,7,a[8]),O=u(O,b,x,P,v,12,a[9]),P=u(P,O,b,x,I,17,a[10]),x=u(x,P,O,b,S,22,a[11]),b=u(b,x,P,O,k,7,a[12]),O=u(O,b,x,P,C,12,a[13]),P=u(P,O,b,x,A,17,a[14]),b=l(b,x=u(x,P,O,b,T,22,a[15]),P,O,c,5,a[16]),O=l(O,b,x,P,y,9,a[17]),P=l(P,O,b,x,S,14,a[18]),x=l(x,P,O,b,o,20,a[19]),b=l(b,x,P,O,m,5,a[20]),O=l(O,b,x,P,I,9,a[21]),P=l(P,O,b,x,T,14,a[22]),x=l(x,P,O,b,g,20,a[23]),b=l(b,x,P,O,v,5,a[24]),O=l(O,b,x,P,A,9,a[25]),P=l(P,O,b,x,f,14,a[26]),x=l(x,P,O,b,w,20,a[27]),b=l(b,x,P,O,C,5,a[28]),O=l(O,b,x,P,p,9,a[29]),P=l(P,O,b,x,_,14,a[30]),b=d(b,x=l(x,P,O,b,k,20,a[31]),P,O,m,4,a[32]),O=d(O,b,x,P,w,11,a[33]),P=d(P,O,b,x,S,16,a[34]),x=d(x,P,O,b,A,23,a[35]),b=d(b,x,P,O,c,4,a[36]),O=d(O,b,x,P,g,11,a[37]),P=d(P,O,b,x,_,16,a[38]),x=d(x,P,O,b,I,23,a[39]),b=d(b,x,P,O,C,4,a[40]),O=d(O,b,x,P,o,11,a[41]),P=d(P,O,b,x,f,16,a[42]),x=d(x,P,O,b,y,23,a[43]),b=d(b,x,P,O,v,4,a[44]),O=d(O,b,x,P,k,11,a[45]),P=d(P,O,b,x,T,16,a[46]),b=h(b,x=d(x,P,O,b,p,23,a[47]),P,O,o,6,a[48]),O=h(O,b,x,P,_,10,a[49]),P=h(P,O,b,x,A,15,a[50]),x=h(x,P,O,b,m,21,a[51]),b=h(b,x,P,O,k,6,a[52]),O=h(O,b,x,P,f,10,a[53]),P=h(P,O,b,x,I,15,a[54]),x=h(x,P,O,b,c,21,a[55]),b=h(b,x,P,O,w,6,a[56]),O=h(O,b,x,P,T,10,a[57]),P=h(P,O,b,x,y,15,a[58]),x=h(x,P,O,b,C,21,a[59]),b=h(b,x,P,O,g,6,a[60]),O=h(O,b,x,P,S,10,a[61]),P=h(P,O,b,x,p,15,a[62]),x=h(x,P,O,b,v,21,a[63]),i[0]=i[0]+b|0,i[1]=i[1]+x|0,i[2]=i[2]+P|0,i[3]=i[3]+O|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,r=8*t.sigBytes;n[r>>>5]|=128<<24-r%32;var i=e.floor(s/4294967296),o=s;n[15+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(r+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,s,r,i,o){var a=e+(t&n|~t&s)+r+o;return(a<<i|a>>>32-i)+t}function l(e,t,n,s,r,i,o){var a=e+(t&s|n&~s)+r+o;return(a<<i|a>>>32-i)+t}function d(e,t,n,s,r,i,o){var a=e+(t^n^s)+r+o;return(a<<i|a>>>32-i)+t}function h(e,t,n,s,r,i,o){var a=e+(n^(t|~s))+r+o;return(a<<i|a>>>32-i)+t}t.MD5=i._createHelper(c),t.HmacMD5=i._createHmacHelper(c)}(Math),n.MD5)})),t((function(e,t){var n;e.exports=(n=s,void function(){var e=n,t=e.lib.Base,s=e.enc.Utf8;e.algo.HMAC=t.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=s.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),a=i.words,c=o.words,u=0;u<n;u++)a[u]^=1549556828,c[u]^=909522486;i.sigBytes=o.sigBytes=r,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,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})}())})),t((function(e,t){e.exports=s.HmacMD5}))),i=t((function(e,t){e.exports=s.enc.Utf8})),o=t((function(e,t){var n;e.exports=(n=s,function(){var e=n,t=e.lib.WordArray;function s(e,n,s){for(var r=[],i=0,o=0;o<n;o++)if(o%4){var a=s[e.charCodeAt(o-1)]<<o%4*2,c=s[e.charCodeAt(o)]>>>6-o%4*2;r[i>>>2]|=(a|c)<<24-i%4*8,i++}return t.create(r,i)}e.enc.Base64={stringify:function(e){var t=e.words,n=e.sigBytes,s=this._map;e.clamp();for(var r=[],i=0;i<n;i+=3)for(var o=(t[i>>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;a<4&&i+.75*a<n;a++)r.push(s.charAt(o>>>6*(3-a)&63));var c=s.charAt(64);if(c)for(;r.length%4;)r.push(c);return r.join("")},parse:function(e){var t=e.length,n=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var i=0;i<n.length;i++)r[n.charCodeAt(i)]=i}var o=n.charAt(64);if(o){var a=e.indexOf(o);-1!==a&&(t=a)}return s(e,t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),n.enc.Base64)})),a=o;const c="FUNCTION",u="OBJECT",l="CLIENT_DB",d="pending",h="fulfilled",p="rejected";function f(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function g(e){return"object"===f(e)}function m(e){return"function"==typeof e}function y(e){return function(){try{return e.apply(e,arguments)}catch(e){console.error(e)}}}const _="REJECTED",w="NOT_PENDING";class v{constructor({createPromise:e,retryRule:t=_}={}){this.createPromise=e,this.status=null,this.promise=null,this.retryRule=t}get needRetry(){if(!this.status)return!0;switch(this.retryRule){case _:return this.status===p;case w:return this.status!==d}}exec(){return this.needRetry?(this.status=d,this.promise=this.createPromise().then((e=>(this.status=h,Promise.resolve(e))),(e=>(this.status=p,Promise.reject(e)))),this.promise):this.promise}}function I(e){return e&&"string"==typeof e?JSON.parse(e):e}const S="development"===process.env.NODE_ENV,k=process.env.UNI_PLATFORM,C=I(process.env.UNI_SECURE_NETWORK_CONFIG),A="h5"===k?"web":"app-plus"===k||"app-harmony"===k?"app":k,T=I(process.env.UNICLOUD_DEBUG),b=I(process.env.UNI_CLOUD_PROVIDER)||[],x=process.env.RUN_BY_HBUILDERX;let P="";try{P=process.env.UNI_APP_ID||""}catch(e){}let O,E={};if("app"===A&&(E=uni._globalUniCloudObj?uni._globalUniCloudObj:uni._globalUniCloudObj={}),"mp-weixin"===A){const e=R();E=e._globalUniCloudObj?e._globalUniCloudObj:e._globalUniCloudObj={}}function L(e,t={}){var n,s;return n=E,s=e,Object.prototype.hasOwnProperty.call(n,s)||(E[e]=t),E[e]}function R(){return O||(O=function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;function e(){return this}return void 0!==e()?e():new Function("return this")()}(),O)}const U=["invoke","success","fail","complete"],N=L("_globalUniCloudInterceptor");function D(e,t){N[e]||(N[e]={}),g(t)&&Object.keys(t).forEach((n=>{U.indexOf(n)>-1&&function(e,t,n){let s=N[e][t];s||(s=N[e][t]=[]),-1===s.indexOf(n)&&m(n)&&s.push(n)}(e,n,t[n])}))}function M(e,t){N[e]||(N[e]={}),g(t)?Object.keys(t).forEach((n=>{U.indexOf(n)>-1&&function(e,t,n){const s=N[e][t];if(!s)return;const r=s.indexOf(n);r>-1&&s.splice(r,1)}(e,n,t[n])})):delete N[e]}function F(e,t){return e&&0!==e.length?e.reduce(((e,n)=>e.then((()=>n(t)))),Promise.resolve()):Promise.resolve()}function q(e,t){return N[e]&&N[e][t]||[]}function K(e){D("callObject",e)}const j=L("_globalUniCloudListener"),B="response",$="needLogin",H="refreshToken",W="failover",J="clientdb",z="cloudfunction",V="cloudobject";function G(e){return j[e]||(j[e]=[]),j[e]}function Q(e,t){const n=G(e);n.includes(t)||n.push(t)}function Y(e,t){const n=G(e),s=n.indexOf(t);-1!==s&&n.splice(s,1)}function X(e,t){const n=G(e);for(let e=0;e<n.length;e++){(0,n[e])(t)}}let Z,ee=!1;function te(){return Z||(Z=new Promise((e=>{ee&&e(),function t(){if("function"==typeof getCurrentPages){const t=getCurrentPages();t&&t[0]&&(ee=!0,e())}ee||setTimeout((()=>{t()}),30)}()})),Z)}function ne(e){const t={};for(const n in e){const s=e[n];m(s)&&(t[n]=y(s))}return t}class se extends Error{constructor(e){const t=e.message||e.errMsg||"unknown system error";super(t),this.errMsg=t,this.code=this.errCode=e.code||e.errCode||"SYSTEM_ERROR",this.errSubject=this.subject=e.subject||e.errSubject,this.cause=e.cause,this.requestId=e.requestId}toJson(e=0){if(!(e>=10))return e++,{errCode:this.errCode,errMsg:this.errMsg,errSubject:this.errSubject,cause:this.cause&&this.cause.toJson?this.cause.toJson(e):this.cause}}}var re={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(),connectSocket:e=>uni.connectSocket(e)};function ie(e){return e&&ie(e.__v_raw)||e}function oe(){return{token:re.getStorageSync("uni_id_token")||re.getStorageSync("uniIdToken"),tokenExpired:re.getStorageSync("uni_id_token_expired")}}function ae({token:e,tokenExpired:t}={}){e&&re.setStorageSync("uni_id_token",e),t&&re.setStorageSync("uni_id_token_expired",t)}let ce,ue;function le(){return ce||(ce="mp-weixin"===A&&wx.canIUse("getAppBaseInfo")&&wx.canIUse("getDeviceInfo")?{...uni.getAppBaseInfo(),...uni.getDeviceInfo()}:uni.getSystemInfoSync()),ce}function de(){let e,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 he={};function pe(){const e=uni.getLocale&&uni.getLocale()||"en";if(ue)return{...he,...ue,locale:e,LOCALE:e};const t=le(),{deviceId:n,osName:s,uniPlatform:r,appId:i}=t,o=["appId","appLanguage","appName","appVersion","appVersionCode","appWgtVersion","browserName","browserVersion","deviceBrand","deviceId","deviceModel","deviceType","osName","osVersion","romName","romVersion","ua","hostName","hostVersion","uniPlatform","uniRuntimeVersion","uniRuntimeVersionCode","uniCompilerVersion","uniCompilerVersionCode"];for(const e in t)Object.hasOwnProperty.call(t,e)&&-1===o.indexOf(e)&&delete t[e];return ue={PLATFORM:r,OS:s,APPID:i,DEVICEID:n,...de(),...t},{...he,...ue,locale:e,LOCALE:e}}var fe={sign:function(e,t){let n="";return Object.keys(e).sort().forEach((function(t){e[t]&&(n=n+"&"+t+"="+e[t])})),n=n.slice(1),r(n,t).toString()},wrappedRequest:function(e,t){return new Promise(((n,s)=>{t(Object.assign(e,{complete(e){e||(e={}),S&&"web"===A&&e.errMsg&&0===e.errMsg.indexOf("request:fail")&&console.warn("发布H5需要在uniCloud后台操作绑定安全域名否则会因为跨域问题而无法访问。教程参考https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5");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){const n=e.data&&e.data.error&&e.data.error.code||"SYS_ERR",r=e.data&&e.data.error&&e.data.error.message||e.errMsg||"request:fail";return s(new se({code:n,message:r,requestId:t}))}const r=e.data;if(r.error)return s(new se({code:r.error.code,message:r.error.message,requestId:t}));r.result=r.data,r.requestId=t,delete r.data,n(r)}}))}))},toBase64:function(e){return a.stringify(i.parse(e))}};var ge=class{constructor(e){["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(`${t} required`)})),this.config=Object.assign({},{endpoint:0===e.spaceId.indexOf("mp-")?"https://api.next.bspapp.com":"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=re,this._getAccessTokenPromiseHub=new v({createPromise:()=>this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>{if(!e.result||!e.result.accessToken)throw new se({code:"AUTH_FAILED",message:"获取accessToken失败"});this.setAccessToken(e.result.accessToken)})),retryRule:w})}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return fe.wrappedRequest(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,n)=>{!t||"GATEWAY_INVALID_TOKEN"!==t.code&&"InvalidParameter.InvalidToken"!==t.code?n(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"]=fe.sign(t.data,this.config.clientSecret),t}setupRequest(e,t){const n=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"]=fe.sign(n,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:s}}getAccessToken(){return this._getAccessTokenPromiseHub.exec()}async authorize(){await 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),timeout:e.timeout})}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:n,filePath:s,fileType:r,onUploadProgress:i}){return new Promise(((o,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:r,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?o(e):a(new se({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new se({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof i&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{i({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))}async uploadFile({filePath:e,cloudPath:t,fileType:n="image",cloudPathAsRealPath:s=!1,onUploadProgress:r,config:i}){if("string"!==f(t))throw new se({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new se({code:"INVALID_PARAM",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new se({code:"INVALID_PARAM",message:"cloudPath不合法"});const o=i&&i.envType||this.config.envType;if(s&&("/"!==t[0]&&(t="/"+t),t.indexOf("\\")>-1))throw new se({code:"INVALID_PARAM",message:"使用cloudPath作为路径时cloudPath不可包含“\\”"});const a=(await this.getOSSUploadOptionsFromPath({env:o,filename:s?t.split("/").pop():t,fileId:s?t:void 0})).result,c="https://"+a.cdnDomain+"/"+a.ossPath,{securityToken:u,accessKeyId:l,signature:d,host:h,ossPath:p,id:g,policy:m,ossCallbackUrl:y}=a,_={"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:l,Signature:d,host:h,id:g,key:p,policy:m,success_action_status:200};if(u&&(_["x-oss-security-token"]=u),y){const e=JSON.stringify({callbackUrl:y,callbackBody:JSON.stringify({fileId:g,spaceId:this.config.spaceId}),callbackBodyType:"application/json"});_.callback=fe.toBase64(e)}const w={url:"https://"+a.host,formData:_,fileName:"file",name:"file",filePath:e,fileType:n};if(await this.uploadFileToOSS(Object.assign({},w,{onUploadProgress:r})),y)return{success:!0,filePath:e,fileID:c};if((await this.reportOSSUpload({id:g})).success)return{success:!0,filePath:e,fileID:c};throw new se({code:"UPLOAD_FAILED",message:"文件上传失败"})}getTempFileURL({fileList:e}={}){return new Promise(((t,n)=>{Array.isArray(e)&&0!==e.length||n(new se({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),this.getFileInfo({fileList:e}).then((n=>{t({fileList:e.map(((e,t)=>{const s=n.fileList[t];return{fileID:e,tempFileURL:s&&s.url||e}}))})}))}))}async getFileInfo({fileList:e}={}){if(!Array.isArray(e)||0===e.length)throw new se({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"});const t={method:"serverless.file.resource.info",params:JSON.stringify({id:e.map((e=>e.split("?")[0])).join(",")})};return{fileList:(await this.request(this.setupRequest(t))).result}}};var me={init(e){const t=new ge(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}};const ye="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var _e;!function(e){e.local="local",e.none="none",e.session="session"}(_e||(_e={}));var we=function(){},ve=t((function(e,t){var n;e.exports=(n=s,function(e){var t=n,s=t.lib,r=s.WordArray,i=s.Hasher,o=t.algo,a=[],c=[];!function(){function t(t){for(var n=e.sqrt(t),s=2;s<=n;s++)if(!(t%s))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var s=2,r=0;r<64;)t(s)&&(r<8&&(a[r]=n(e.pow(s,.5))),c[r]=n(e.pow(s,1/3)),r++),s++}();var u=[],l=o.SHA256=i.extend({_doReset:function(){this._hash=new r.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,s=n[0],r=n[1],i=n[2],o=n[3],a=n[4],l=n[5],d=n[6],h=n[7],p=0;p<64;p++){if(p<16)u[p]=0|e[t+p];else{var f=u[p-15],g=(f<<25|f>>>7)^(f<<14|f>>>18)^f>>>3,m=u[p-2],y=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;u[p]=g+u[p-7]+y+u[p-16]}var _=s&r^s&i^r&i,w=(s<<30|s>>>2)^(s<<19|s>>>13)^(s<<10|s>>>22),v=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&d)+c[p]+u[p];h=d,d=l,l=a,a=o+v|0,o=i,i=r,r=s,s=v+(w+_)|0}n[0]=n[0]+s|0,n[1]=n[1]+r|0,n[2]=n[2]+i|0,n[3]=n[3]+o|0,n[4]=n[4]+a|0,n[5]=n[5]+l|0,n[6]=n[6]+d|0,n[7]=n[7]+h|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,r=8*t.sigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=e.floor(s/4294967296),n[15+(r+64>>>9<<4)]=s,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(l),t.HmacSHA256=i._createHmacHelper(l)}(Math),n.SHA256)})),Ie=ve,Se=t((function(e,t){e.exports=s.HmacSHA256}));const ke=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new se({message:'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,n)=>{e=(e,s)=>e?n(e):t(s)}));return e.promise=t,e};function Ce(e){return void 0===e}function Ae(e){return"[object Null]"===Object.prototype.toString.call(e)}function Te(e=""){return e.replace(/([\s\S]+)\s+(请前往云开发AI小助手查看问题.*)/,"$1")}function be(e=32){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=t.length;let s="";for(let r=0;r<e;r++)s+=t.charAt(Math.floor(Math.random()*n));return s}var xe;function Pe(e){const t=(n=e,"[object Array]"===Object.prototype.toString.call(n)?e:[e]);var n;for(const e of t){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"}(xe||(xe={}));const Oe={adapter:null,runtime:void 0},Ee=["anonymousUuidKey"];class Le extends we{constructor(){super(),Oe.adapter.root.tcbObject||(Oe.adapter.root.tcbObject={})}setItem(e,t){Oe.adapter.root.tcbObject[e]=t}getItem(e){return Oe.adapter.root.tcbObject[e]}removeItem(e){delete Oe.adapter.root.tcbObject[e]}clear(){delete Oe.adapter.root.tcbObject}}function Re(e,t){switch(e){case"local":return t.localStorage||new Le;case"none":return new Le;default:return t.sessionStorage||new Le}}class Ue{constructor(e){if(!this._storage){this._persistence=Oe.adapter.primaryStorage||e.persistence,this._storage=Re(this._persistence,Oe.adapter);const t=`access_token_${e.env}`,n=`access_token_expire_${e.env}`,s=`refresh_token_${e.env}`,r=`anonymous_uuid_${e.env}`,i=`login_type_${e.env}`,o="device_id",a=`token_type_${e.env}`,c=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s,anonymousUuidKey:r,loginTypeKey:i,userInfoKey:c,deviceIdKey:o,tokenTypeKey:a}}}updatePersistence(e){if(e===this._persistence)return;const t="local"===this._persistence;this._persistence=e;const n=Re(e,Oe.adapter);for(const e in this.keys){const s=this.keys[e];if(t&&Ee.includes(e))continue;const r=this._storage.getItem(s);Ce(r)||Ae(r)||(n.setItem(s,r),this._storage.removeItem(s))}this._storage=n}setStore(e,t,n){if(!this._storage)return;const s={version:n||"localCachev1",content:t},r=JSON.stringify(s);try{this._storage.setItem(e,r)}catch(e){throw e}}getStore(e,t){try{if(!this._storage)return}catch(e){return""}t=t||"localCachev1";const n=this._storage.getItem(e);if(!n)return"";if(n.indexOf(t)>=0){return JSON.parse(n).content}return""}removeStore(e){this._storage.removeItem(e)}}const Ne={},De={};function Me(e){return Ne[e]}class Fe{constructor(e,t){this.data=t||null,this.name=e}}class qe extends Fe{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const Ke=new class{constructor(){this._listeners={}}on(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this._listeners),this}off(e,t){return function(e,t,n){if(n&&n[e]){const s=n[e].indexOf(t);-1!==s&&n[e].splice(s,1)}}(e,t,this._listeners),this}fire(e,t){if(e instanceof qe)return console.error(e.error),this;const n="string"==typeof e?new Fe(e,t||{}):e;const s=n.name;if(this._listens(s)){n.target=this;const e=this._listeners[s]?[...this._listeners[s]]:[];for(const t of e)t.call(this,n)}return this}_listens(e){return this._listeners[e]&&this._listeners[e].length>0}};function je(e,t){Ke.on(e,t)}function Be(e,t={}){Ke.fire(e,t)}function $e(e,t){Ke.off(e,t)}const He="loginStateChanged",We="loginStateExpire",Je="loginTypeChanged",ze="anonymousConverted",Ve="refreshAccessToken";var Ge;!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"}(Ge||(Ge={}));class Qe{constructor(){this._fnPromiseMap=new Map}async run(e,t){let n=this._fnPromiseMap.get(e);return n||(n=new Promise((async(n,s)=>{try{await this._runIdlePromise();const s=t();n(await s)}catch(e){s(e)}finally{this._fnPromiseMap.delete(e)}})),this._fnPromiseMap.set(e,n)),n}_runIdlePromise(){return Promise.resolve()}}class Ye{constructor(e){this._singlePromise=new Qe,this._cache=Me(e.env),this._baseURL=`https://${e.env}.ap-shanghai.tcb-api.tencentcloudapi.com`,this._reqClass=new Oe.adapter.reqClass({timeout:e.timeout,timeoutMsg:`请求在${e.timeout/1e3}s内未完成已中断`,restrictedMethods:["post"]})}_getDeviceId(){if(this._deviceID)return this._deviceID;const{deviceIdKey:e}=this._cache.keys;let t=this._cache.getStore(e);return"string"==typeof t&&t.length>=16&&t.length<=48||(t=be(),this._cache.setStore(e,t)),this._deviceID=t,t}async _request(e,t,n={}){const s={"x-request-id":be(),"x-device-id":this._getDeviceId()};if(n.withAccessToken){const{tokenTypeKey:e}=this._cache.keys,t=await this.getAccessToken(),n=this._cache.getStore(e);s.authorization=`${n} ${t}`}return this._reqClass["get"===n.method?"get":"post"]({url:`${this._baseURL}${e}`,data:t,headers:s})}async _fetchAccessToken(){const{loginTypeKey:e,accessTokenKey:t,accessTokenExpireKey:n,tokenTypeKey:s}=this._cache.keys,r=this._cache.getStore(e);if(r&&r!==Ge.ANONYMOUS)throw new se({code:"INVALID_OPERATION",message:"非匿名登录不支持刷新 access token"});const i=await this._singlePromise.run("fetchAccessToken",(async()=>(await this._request("/auth/v1/signin/anonymously",{},{method:"post"})).data)),{access_token:o,expires_in:a,token_type:c}=i;return this._cache.setStore(s,c),this._cache.setStore(t,o),this._cache.setStore(n,Date.now()+1e3*a),o}isAccessTokenExpired(e,t){let n=!0;return e&&t&&(n=t<Date.now()),n}async getAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t}=this._cache.keys,n=this._cache.getStore(e),s=this._cache.getStore(t);return this.isAccessTokenExpired(n,s)?this._fetchAccessToken():n}async refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,loginTypeKey:n}=this._cache.keys;return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.setStore(n,Ge.ANONYMOUS),this.getAccessToken()}async getUserInfo(){return this._singlePromise.run("getUserInfo",(async()=>(await this._request("/auth/v1/user/me",{},{withAccessToken:!0,method:"get"})).data))}}const Xe=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],Ze={"X-SDK-Version":"1.3.5"};function et(e,t,n){const s=e[t];e[t]=function(t){const r={},i={};n.forEach((n=>{const{data:s,headers:o}=n.call(e,t);Object.assign(r,s),Object.assign(i,o)}));const o=t.data;return o&&(()=>{var e;if(e=o,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...o,...r};else for(const e in r)o.append(e,r[e])})(),t.headers={...t.headers||{},...i},s.call(e,t)}}function tt(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...Ze,"x-seqid":e}}}class nt{constructor(e={}){var t;this.config=e,this._reqClass=new Oe.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成已中断`,restrictedMethods:["post"]}),this._cache=Me(this.config.env),this._localCache=(t=this.config.env,De[t]),this.oauth=new Ye(this.config),et(this._reqClass,"post",[tt]),et(this._reqClass,"upload",[tt]),et(this._reqClass,"download",[tt])}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(e){t=e}if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return e}async _refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n,loginTypeKey:s,anonymousUuidKey:r}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);let i=this._cache.getStore(n);if(!i)throw new se({message:"未登录CloudBase"});const o={refresh_token:i},a=await this.request("auth.fetchAccessTokenWithRefreshToken",o);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)===Ge.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){const e=this._cache.getStore(r),t=this._cache.getStore(n),s=await this.send("auth.signInAnonymously",{anonymous_uuid:e,refresh_token:t});return this.setRefreshToken(s.refresh_token),this._refreshAccessToken()}Be(We),this._cache.removeStore(n)}throw new se({code:a.data.code,message:`刷新access token失败${a.data.code}`})}if(a.data.access_token)return Be(Ve),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())}async getAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n}=this._cache.keys;if(!this._cache.getStore(n))throw new se({message:"refresh token不存在登录状态异常"});let s=this._cache.getStore(e),r=this._cache.getStore(t),i=!0;return this._shouldRefreshAccessTokenHook&&!await this._shouldRefreshAccessTokenHook(s,r)&&(i=!1),(!s||!r||r<Date.now())&&i?this.refreshAccessToken():{accessToken:s,accessTokenExpire:r}}async request(e,t,n){const s=`x-tcb-trace_${this.config.env}`;let r="application/x-www-form-urlencoded";const i={action:e,env:this.config.env,dataVersion:"2019-08-16",...t};let o;if(-1===Xe.indexOf(e)&&(this._cache.keys,i.access_token=await this.oauth.getAccessToken()),"storage.uploadFile"===e){o=new FormData;for(let e in o)o.hasOwnProperty(e)&&void 0!==o[e]&&o.append(e,i[e]);r="multipart/form-data"}else{r="application/json",o={};for(let e in i)void 0!==i[e]&&(o[e]=i[e])}let a={headers:{"content-type":r}};n&&n.timeout&&(a.timeout=n.timeout),n&&n.onUploadProgress&&(a.onUploadProgress=n.onUploadProgress);const c=this._localCache.getStore(s);c&&(a.headers["X-TCB-Trace"]=c);const{parse:u,inQuery:l,search:d}=t;let h={env:this.config.env};u&&(h.parse=!0),l&&(h={...l,...h});let p=function(e,t,n={}){const s=/\?/.test(t);let r="";for(let e in n)""===r?!s&&(t+="?"):r+="&",r+=`${e}=${encodeURIComponent(n[e])}`;return/^http(s)?\:\/\//.test(t+=r)?t:`${e}${t}`}(ye,"//tcb-api.tencentcloudapi.com/web",h);d&&(p+=d);const f=await this.post({url:p,data:o,...a}),g=f.header&&f.header["x-tcb-trace"];if(g&&this._localCache.setStore(s,g),200!==Number(f.status)&&200!==Number(f.statusCode)||!f.data)throw new se({code:"NETWORK_ERROR",message:"network request error"});return f}async send(e,t={},n={}){const s=await this.request(e,t,{...n,onUploadProgress:t.onUploadProgress});if(("ACCESS_TOKEN_DISABLED"===s.data.code||"ACCESS_TOKEN_EXPIRED"===s.data.code)&&-1===Xe.indexOf(e)){await this.oauth.refreshAccessToken();const s=await this.request(e,t,{...n,onUploadProgress:t.onUploadProgress});if(s.data.code)throw new se({code:s.data.code,message:Te(s.data.message)});return s.data}if(s.data.code)throw new se({code:s.data.code,message:Te(s.data.message)});return s.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)}}const st={};function rt(e){return st[e]}class it{constructor(e){this.config=e,this._cache=Me(e.env),this._request=rt(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)}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 ot{constructor(e){if(!e)throw new se({code:"PARAM_ERROR",message:"envId is not defined"});this._envId=e,this._cache=Me(this._envId),this._request=rt(this._envId),this.setUserInfo()}linkWithTicket(e){if("string"!=typeof e)throw new se({code:"PARAM_ERROR",message:"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 se({code:"PARAM_ERROR",message:"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:n}=e;return n.forEach((e=>{e.wxOpenId&&e.wxPublicId&&(t=!0)})),{users:n,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:n,avatarUrl:s,province:r,country:i,city:o}=e,{data:a}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:s,province:r,country:i,city:o});this.setLocalUserInfo(a)}async refresh(){const e=await this._request.oauth.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 at{constructor(e){if(!e)throw new se({code:"PARAM_ERROR",message:"envId is not defined"});this._cache=Me(e);const{refreshTokenKey:t,accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys,r=this._cache.getStore(t),i=this._cache.getStore(n),o=this._cache.getStore(s);this.credential={refreshToken:r,accessToken:i,accessTokenExpire:o},this.user=new ot(e)}get isAnonymousAuth(){return this.loginType===Ge.ANONYMOUS}get isCustomAuth(){return this.loginType===Ge.CUSTOM}get isWeixinAuth(){return this.loginType===Ge.WECHAT||this.loginType===Ge.WECHAT_OPEN||this.loginType===Ge.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class ct extends it{async signIn(){this._cache.updatePersistence("local"),await this._request.oauth.getAccessToken(),Be(He),Be(Je,{env:this.config.env,loginType:Ge.ANONYMOUS,persistence:"local"});const e=new at(this.config.env);return await e.user.refresh(),e}async linkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:n}=this._cache.keys,s=this._cache.getStore(t),r=this._cache.getStore(n),i=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:s,refresh_token:r,ticket:e});if(i.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(i.refresh_token),await this._request.refreshAccessToken(),Be(ze,{env:this.config.env}),Be(Je,{loginType:Ge.CUSTOM,persistence:"local"}),{credential:{refreshToken:i.refresh_token}};throw new se({message:"匿名转化失败"})}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(n,Ge.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class ut extends it{async signIn(e){if("string"!=typeof e)throw new se({code:"PARAM_ERROR",message:"ticket must be a string"});const{refreshTokenKey:t}=this._cache.keys,n=await this._request.send("auth.signInWithTicket",{ticket:e,refresh_token:this._cache.getStore(t)||""});if(n.refresh_token)return this.setRefreshToken(n.refresh_token),await this._request.refreshAccessToken(),Be(He),Be(Je,{env:this.config.env,loginType:Ge.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new at(this.config.env);throw new se({message:"自定义登录失败"})}}class lt extends it{async signIn(e,t){if("string"!=typeof e)throw new se({code:"PARAM_ERROR",message:"email must be a string"});const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:r,access_token:i,access_token_expire:o}=s;if(r)return this.setRefreshToken(r),i&&o?this.setAccessToken(i,o):await this._request.refreshAccessToken(),await this.refreshUserInfo(),Be(He),Be(Je,{env:this.config.env,loginType:Ge.EMAIL,persistence:this.config.persistence}),new at(this.config.env);throw s.code?new se({code:s.code,message:`邮箱登录失败: ${s.message}`}):new se({message:"邮箱登录失败"})}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 dt extends it{async signIn(e,t){if("string"!=typeof e)throw new se({code:"PARAM_ERROR",message:"username must be a string"});"string"!=typeof t&&(t="",console.warn("password is empty"));const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:Ge.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:r,access_token_expire:i,access_token:o}=s;if(r)return this.setRefreshToken(r),o&&i?this.setAccessToken(o,i):await this._request.refreshAccessToken(),await this.refreshUserInfo(),Be(He),Be(Je,{env:this.config.env,loginType:Ge.USERNAME,persistence:this.config.persistence}),new at(this.config.env);throw s.code?new se({code:s.code,message:`用户名密码登录失败: ${s.message}`}):new se({message:"用户名密码登录失败"})}}class ht{constructor(e){this.config=e,this._cache=Me(e.env),this._request=rt(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),je(Je,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 ct(this.config)}customAuthProvider(){return new ut(this.config)}emailAuthProvider(){return new lt(this.config)}usernameAuthProvider(){return new dt(this.config)}async signInAnonymously(){return new ct(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new lt(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new dt(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){this._anonymousAuthProvider||(this._anonymousAuthProvider=new ct(this.config)),je(ze,this._onAnonymousConverted);return await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===Ge.ANONYMOUS)throw new se({message:"匿名用户不支持登出操作"});const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:n}=this._cache.keys,s=this._cache.getStore(e);if(!s)return;const r=await this._request.send("auth.logout",{refresh_token:s});return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(n),Be(He),Be(Je,{env:this.config.env,loginType:Ge.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){je(He,(()=>{const t=this.hasLoginState();e.call(this,t)}));const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){je(We,e.bind(this))}onAccessTokenRefreshed(e){je(Ve,e.bind(this))}onAnonymousConverted(e){je(ze,e.bind(this))}onLoginTypeChanged(e){je(Je,(()=>{const t=this.hasLoginState();e.call(this,t)}))}async getAccessToken(){return{accessToken:(await this._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{accessTokenKey:e,accessTokenExpireKey:t}=this._cache.keys,n=this._cache.getStore(e),s=this._cache.getStore(t);return this._request.oauth.isAccessTokenExpired(n,s)?null:new at(this.config.env)}async isUsernameRegistered(e){if("string"!=typeof e)throw new se({code:"PARAM_ERROR",message:"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 ut(this.config).signIn(e)}shouldRefreshAccessToken(e){this._request._shouldRefreshAccessTokenHook=e.bind(this)}getUserInfo(){return this._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))}}const pt=function(e,t){t=t||ke();const n=rt(this.config.env),{cloudPath:s,filePath:r,onUploadProgress:i,fileType:o="image"}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{const{data:{url:a,authorization:c,token:u,fileId:l,cosFileId:d},requestId:h}=e,p={key:s,signature:c,"x-cos-meta-fileid":d,success_action_status:"201","x-cos-security-token":u};n.upload({url:a,data:p,file:r,name:s,fileType:o,onUploadProgress:i}).then((e=>{201===e.statusCode?t(null,{fileID:l,requestId:h}):t(new se({code:"STORAGE_REQUEST_FAIL",message:`STORAGE_REQUEST_FAIL: ${e.data}`}))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},ft=function(e,t){t=t||ke();const n=rt(this.config.env),{cloudPath:s}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},gt=function({fileList:e},t){if(t=t||ke(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(let t of e)if(!t||"string"!=typeof t)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};const n={fileid_list:e};return rt(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},mt=function({fileList:e},t){t=t||ke(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});let n=[];for(let s of e)"object"==typeof s?(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"==typeof s?n.push({fileid:s}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});const s={file_list:n};return rt(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},yt=async function({fileID:e},t){const n=(await mt.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==n.code)return t?t(n):new Promise((e=>{e(n)}));const s=rt(this.config.env);let r=n.download_url;if(r=encodeURI(r),!t)return s.download({url:r});t(await s.download({url:r}))},_t=function({name:e,data:t,query:n,parse:s,search:r,timeout:i},o){const a=o||ke();let c;try{c=t?JSON.stringify(t):""}catch(e){return Promise.reject(e)}if(!e)return Promise.reject(new se({code:"PARAM_ERROR",message:"函数名不能为空"}));const u={inQuery:n,parse:s,search:r,function_name:e,request_data:c};return rt(this.config.env).send("functions.invokeFunction",u,{timeout:i}).then((e=>{if(e.code)a(null,e);else{let t=e.data.response_data;if(s)a(null,{result:t,requestId:e.requestId});else try{t=JSON.parse(e.data.response_data),a(null,{result:t,requestId:e.requestId})}catch(e){a(new se({message:"response data must be json"}))}}return a.promise})).catch((e=>{a(e)})),a.promise},wt={timeout:15e3,persistence:"session"},vt={};class It{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(Oe.adapter||(this.requestClient=new Oe.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成已中断`})),this.config={...wt,...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 It(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||Oe.adapter.primaryStorage||wt.persistence;var n;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;Ne[t]=new Ue(e),De[t]=new Ue({...e,persistence:"local"})}(this.config),n=this.config,st[n.env]=new nt(n),this.authObj=new ht(this.config),this.authObj}on(e,t){return je.apply(this,[e,t])}off(e,t){return $e.apply(this,[e,t])}callFunction(e,t){return _t.apply(this,[e,t])}deleteFile(e,t){return gt.apply(this,[e,t])}getTempFileURL(e,t){return mt.apply(this,[e,t])}downloadFile(e,t){return yt.apply(this,[e,t])}uploadFile(e,t){return pt.apply(this,[e,t])}getUploadMetadata(e,t){return ft.apply(this,[e,t])}registerExtension(e){vt[e.name]=e}async invokeExtension(e,t){const n=vt[e];if(!n)throw new se({message:`扩展${e} 必须先注册`});return await n.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:n}=Pe(e)||{};t&&(Oe.adapter=t),n&&(Oe.runtime=n)}}var St=new It;function kt(e,t,n){void 0===n&&(n={});var s=/\?/.test(t),r="";for(var i in n)""===r?!s&&(t+="?"):r+="&",r+=i+"="+encodeURIComponent(n[i]);return/^http(s)?:\/\//.test(t+=r)?t:""+e+t}class Ct{get(e){const{url:t,data:n,headers:s,timeout:r}=e;return new Promise(((e,i)=>{re.request({url:kt("https:",t),data:n,method:"GET",header:s,timeout:r,success(t){e(t)},fail(e){i(e)}})}))}post(e){const{url:t,data:n,headers:s,timeout:r}=e;return new Promise(((e,i)=>{re.request({url:kt("https:",t),data:n,method:"POST",header:s,timeout:r,success(t){e(t)},fail(e){i(e)}})}))}upload(e){return new Promise(((t,n)=>{const{url:s,file:r,data:i,headers:o,fileType:a}=e,c=re.uploadFile({url:kt("https:",s),name:"file",formData:Object.assign({},i),filePath:r,fileType:a,header:o,success(e){const n={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&i.success_action_status&&(n.statusCode=parseInt(i.success_action_status,10)),t(n)},fail(e){n(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 At={setItem(e,t){re.setStorageSync(e,t)},getItem:e=>re.getStorageSync(e),removeItem(e){re.removeStorageSync(e)},clear(){re.clearStorageSync()}};var Tt={genAdapter:function(){return{root:{},reqClass:Ct,localStorage:At,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};St.useAdapters(Tt);const bt=St,xt=bt.init;bt.init=function(e){e.env=e.spaceId;const t=xt.call(this,e);t.config.provider="tencent",t.config.spaceId=e.spaceId;const n=t.auth;return t.auth=function(e){const t=n.call(this,e);return["linkAndRetrieveDataWithTicket","signInAnonymously","signOut","getAccessToken","getLoginState","signInWithTicket","getUserInfo"].forEach((e=>{var n;t[e]=(n=t[e],function(e){e=e||{};const{success:t,fail:s,complete:r}=ne(e);if(!(t||s||r))return n.call(this,e);n.call(this,e).then((e=>{t&&t(e),r&&r(e)}),(e=>{s&&s(e),r&&r(e)}))}).bind(t)})),t},t.customAuth=t.auth,t};var Pt=bt;async function Ot(e,t){const n=`http://${e}:${t}/system/ping`;try{const e=await(s={url:n,timeout:500},new Promise(((e,t)=>{re.request({...s,success(t){e(t)},fail(e){t(e)}})})));return!(!e.data||0!==e.data.code)}catch(e){return!1}var s}async function Et(e,t){let n;for(let s=0;s<e.length;s++){const r=e[s];if(await Ot(r,t)){n=r;break}}return{address:n,port:t}}const Lt={"serverless.file.resource.generateProximalSign":"storage/generate-proximal-sign","serverless.file.resource.report":"storage/report","serverless.file.resource.delete":"storage/delete","serverless.file.resource.getTempFileURL":"storage/get-temp-file-url","system/check-storage":"system/check-storage"};var Rt=class{constructor(e){if(["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(`${t} required`)})),!e.endpoint)throw new Error("集群空间未配置ApiEndpoint配置后需要重新关联服务空间后生效");this.config=Object.assign({},e),this.config.provider="dcloud",this.config.requestUrl=this.config.endpoint+"/client",this.config.envType=this.config.envType||"public",this.adapter=re}async request(e,t=!0){const n=S&&t;return Promise.resolve().then((()=>n?this.requestLocal(e):fe.wrappedRequest(this.setupRequest(e),this.adapter.request)))}async requestLocal(e){const t=await this.setupLocalRequest({method:"system/check-storage",platform:A,provider:this.config.provider,spaceId:this.config.spaceId});return new Promise((e=>{this.adapter.request(Object.assign({},t,{success:t=>{e(t)},fail:()=>{e({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:t,message:n})=>0!==t?(console.error(t,n),fe.wrappedRequest(this.setupRequest(e),this.adapter.request)):new Promise(((t,n)=>{this.setupLocalRequest(e).then((e=>{this.adapter.request(Object.assign(e,{complete(e){if(e||(e={}),!e.statusCode||e.statusCode>=400){const t=e.data&&e.data.code||"SYS_ERR",s=e.data&&e.data.message||"request:fail";return n(new se({code:t,message:s}))}const s=e.data;if(s.error)return n(new se({code:s.error.code,message:s.error.message}));t({success:!0,result:s})}}))}))}))))}setupRequest(e){const t=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),n={"Content-Type":"application/json"};n["x-serverless-sign"]=fe.sign(t,this.config.clientSecret);const s=pe();n["x-client-info"]=encodeURIComponent(JSON.stringify(s));const{token:r}=oe();return n["x-client-token"]=r,{url:this.config.requestUrl,method:"POST",data:t,dataType:"json",header:JSON.parse(JSON.stringify(n))}}async setupLocalRequest(e){const t=pe(),{token:n}=oe(),s=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now(),clientInfo:t,token:n}),{address:r,servePort:i}=this.__dev__&&this.__dev__.debugInfo||{},{address:o}=await Et(r,i);return{url:`http://${o}:${i}/${Lt[e.method]}`,method:"POST",data:s,dataType:"json",header:JSON.parse(JSON.stringify({"Content-Type":"application/json"}))}}callFunction(e){const t={method:"serverless.function.runtime.invoke",params:JSON.stringify({functionTarget:e.name,functionArgs:e.data||{}})};return this.request(t,!1)}getUploadFileOptions(e){const t={method:"serverless.file.resource.generateProximalSign",params:JSON.stringify(e)};return this.request(t)}reportUploadFile(e){const t={method:"serverless.file.resource.report",params:JSON.stringify(e)};return this.request(t)}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s}){if(!t)throw new se({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});let r;return this.getUploadFileOptions({cloudPath:t}).then((t=>{const{url:i,formData:o,name:a}=t.result;return r=t.result.fileUrl,new Promise(((t,r)=>{const c=this.adapter.uploadFile({url:i,formData:o,name:a,filePath:e,fileType:n,success(e){e&&e.statusCode<400?t(e):r(new se({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){r(new se({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof s&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{s({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))})).then((()=>this.reportUploadFile({cloudPath:t}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:r}):s(new se({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({fileList:e})};return this.request(t).then((e=>{if(e.success)return e.result;throw new se({code:"DELETE_FILE_FAILED",message:"删除文件失败"})}))}getTempFileURL({fileList:e,maxAge:t}={}){if(!Array.isArray(e)||0===e.length)throw new se({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"});const n={method:"serverless.file.resource.getTempFileURL",params:JSON.stringify({fileList:e,maxAge:t})};return this.request(n).then((e=>{if(e.success)return{fileList:e.result.fileList.map((e=>({fileID:e.fileID,tempFileURL:e.tempFileURL})))};throw new se({code:"GET_TEMP_FILE_URL_FAILED",message:"获取临时文件链接失败"})}))}};var Ut={init(e){const t=new Rt(e),n={signInAnonymously:function(){return Promise.resolve()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}},Nt=t((function(e,t){e.exports=s.enc.Hex}));function Dt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}function Mt(e){return`${e}.api-hz.cloudbasefunction.cn`}function Ft(e="",t={}){const{data:n,functionName:s,method:r,headers:i,signHeaderKeys:o=[],endpoint:a,config:c}=t,u=String(Date.now()),l=Dt(),d=Object.assign({},i,{"x-from-app-id":c.spaceAppId,"x-from-env-id":c.spaceId,"x-to-env-id":c.spaceId,"x-from-instance-id":u,"x-from-function-name":s,"x-client-timestamp":u,"x-alipay-source":"client","x-request-id":l,"x-alipay-callid":l,"x-trace-id":l}),h=["x-from-app-id","x-from-env-id","x-to-env-id","x-from-instance-id","x-from-function-name","x-client-timestamp"].concat(o),[p="",f=""]=e.split("?")||[],g=function(e){const t=e.signedHeaders.join(";"),n=e.signedHeaders.map((t=>`${t.toLowerCase()}:${e.headers[t]}\n`)).join(""),s=Ie(e.body).toString(Nt),r=`${e.method.toUpperCase()}\n${e.path}\n${e.query}\n${n}\n${t}\n${s}\n`,i=Ie(r).toString(Nt),o=`HMAC-SHA256\n${e.timestamp}\n${i}\n`,a=Se(o,e.secretKey).toString(Nt);return`HMAC-SHA256 Credential=${e.secretId}, SignedHeaders=${t}, Signature=${a}`}({path:p,query:f,method:r,headers:d,timestamp:u,body:JSON.stringify(n),secretId:c.accessKey,secretKey:c.secretKey,signedHeaders:h.sort()});return{url:`${a||c.endpoint}${e}`,headers:Object.assign({},d,{Authorization:g})}}function qt({url:e,data:t,method:n="POST",headers:s={},timeout:r}){return new Promise(((i,o)=>{re.request({url:e,method:n,data:"object"==typeof t?JSON.stringify(t):t,header:s,dataType:"json",timeout:r,complete:(e={})=>{const t=s["x-trace-id"]||"";if(!e.statusCode||e.statusCode>=400){const{message:n,errMsg:s,trace_id:r}=e.data||{};return o(new se({code:"SYS_ERR",message:n||s||"request:fail",requestId:r||t}))}i({status:e.statusCode,data:e.data,headers:e.header,requestId:t})}})}))}function Kt(e,t){const{path:n,data:s,method:r="GET"}=e,{url:i,headers:o}=Ft(n,{functionName:"",data:s,method:r,headers:{"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":String(Date.now()+6e4)},signHeaderKeys:["x-data-api-type","x-expire-timestamp"],config:t,endpoint:`https://${Mt(t.spaceId)}`});return qt({url:i,data:s,method:r,headers:o}).then((e=>{const t=e.data||{};if(!t.success)throw new se({code:e.errCode,message:e.errMsg,requestId:e.requestId});return t.data||{}})).catch((e=>{throw new se({code:e.errCode,message:e.errMsg,requestId:e.requestId})}))}function jt(e=""){const t=e.trim().replace(/^cloud:\/\//,""),n=t.indexOf("/");if(n<=0)throw new se({code:"INVALID_PARAM",message:"fileID不合法"});const s=t.substring(0,n),r=t.substring(n+1);return s!==this.config.spaceId&&console.warn("file ".concat(e," does not belong to env ").concat(this.config.spaceId)),r}function Bt(e=""){return"cloud://".concat(this.config.spaceId,"/").concat(e.replace(/^\/+/,""))}class $t{constructor(e){this.config=e}signedURL(e,t={}){const n=`/ws/function/${e}`,s=this.config.wsEndpoint.replace(/^ws(s)?:\/\//,""),r=Object.assign({},t,{accessKeyId:this.config.accessKey,signatureNonce:Dt(),timestamp:""+Date.now()}),i=[n,["accessKeyId","authorization","signatureNonce","timestamp"].sort().map((function(e){return r[e]?"".concat(e,"=").concat(r[e]):null})).filter(Boolean).join("&"),`host:${s}`].join("\n"),o=["HMAC-SHA256",Ie(i).toString(Nt)].join("\n"),a=Se(o,this.config.secretKey).toString(Nt),c=Object.keys(r).map((e=>`${e}=${encodeURIComponent(r[e])}`)).join("&");return`${this.config.wsEndpoint}${n}?${c}&signature=${a}`}}class Ht{constructor(e){this.config=e}signedURL(e,t={}){const n=`/ws/sse/function/${e}`,s=this.config.endpoint.replace(/^http(s)?:\/\//,""),r=Object.assign({},t,{accessKeyId:this.config.accessKey,signatureNonce:Dt(),timestamp:""+Date.now()}),i=["accessKeyId","authorization","signatureNonce","timestamp"].sort().map((function(e){return r[e]?"".concat(e,"=").concat(r[e]):null})).filter(Boolean).join("&"),o=[n.replace("/ws",""),i,`host:${s}`].join("\n"),a=["HMAC-SHA256",Ie(o).toString(Nt)].join("\n"),c=Se(a,this.config.secretKey).toString(Nt),u=Object.keys(r).map((e=>`${e}=${encodeURIComponent(r[e])}`)).join("&");return`${this.config.endpoint}${n}?${u}&signature=${c}`}}var Wt=class{constructor(e){if(["spaceId","spaceAppId","accessKey","secretKey"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(`${t} required`)})),e.endpoint){if("string"!=typeof e.endpoint)throw new Error("endpoint must be string");if(!/^https:\/\//.test(e.endpoint))throw new Error("endpoint must start with https://");e.endpoint=e.endpoint.replace(/\/$/,"")}this.config=Object.assign({},e,{endpoint:e.endpoint||`https://${Mt(e.spaceId)}`,wsEndpoint:e.wsEndpoint||`wss://${Mt(e.spaceId)}`}),this._websocket=new $t(this.config),this._sse=new Ht(this.config)}callFunction(e){return function(e,t){const{name:n,data:s,async:r=!1,timeout:i}=e,o="POST",a={"x-to-function-name":n};r&&(a["x-function-invoke-type"]="async");const{url:c,headers:u}=Ft("/functions/invokeFunction",{functionName:n,data:s,method:o,headers:a,signHeaderKeys:["x-to-function-name"],config:t});return qt({url:c,data:s,method:o,headers:u,timeout:i}).then((e=>{let t=0;if(r){const n=e.data||{};t="200"===n.errCode?0:n.errCode,e.data=n.data||{},e.errMsg=n.errMsg}if(0!==t)throw new se({code:t,message:e.errMsg,requestId:e.requestId});return{errCode:t,success:0===t,requestId:e.requestId,result:e.data}})).catch((e=>{throw new se({code:e.errCode,message:e.errMsg,requestId:e.requestId})}))}(e,this.config)}uploadFileToOSS({url:e,filePath:t,fileType:n,formData:s,onUploadProgress:r}){return new Promise(((i,o)=>{const a=re.uploadFile({url:e,filePath:t,fileType:n,formData:s,name:"file",success(e){e&&e.statusCode<400?i(e):o(new se({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){o(new se({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof r&&a&&"function"==typeof a.onProgressUpdate&&a.onProgressUpdate((e=>{r({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}async uploadFile({filePath:e,cloudPath:t="",fileType:n="image",onUploadProgress:s}){if("string"!==f(t))throw new se({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new se({code:"INVALID_PARAM",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new se({code:"INVALID_PARAM",message:"cloudPath不合法"});const r=await Kt({path:"/".concat(t.replace(/^\//,""),"?post_url")},this.config),{file_id:i,upload_url:o,form_data:a}=r,c=a&&a.reduce(((e,t)=>(e[t.key]=t.value,e)),{});return this.uploadFileToOSS({url:o,filePath:e,fileType:n,formData:c,onUploadProgress:s}).then((()=>({fileID:i})))}async getTempFileURL({fileList:e}){return new Promise(((t,n)=>{(!e||e.length<0)&&t({code:"INVALID_PARAM",message:"fileList不能为空数组"}),e.length>50&&t({code:"INVALID_PARAM",message:"fileList数组长度不能超过50"});const s=[];for(const n of e){let e;"string"!==f(n)&&t({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"});try{e=jt.call(this,n)}catch(t){console.warn(t.errCode,t.errMsg),e=n}s.push({file_id:e,expire:600})}Kt({path:"/?download_url",data:{file_list:s},method:"POST"},this.config).then((e=>{const{file_list:n=[]}=e;t({fileList:n.map((e=>({fileID:Bt.call(this,e.file_id),tempFileURL:e.download_url})))})})).catch((e=>n(e)))}))}async connectWebSocket(e){const{name:t,query:n}=e;return re.connectSocket({url:this._websocket.signedURL(t,n),complete:()=>{}})}requestSSE(e){const{name:t,data:n}=e;return re.request({method:"POST",url:this._sse.signedURL(t),data:n,header:{"content-type":"application/json"},dataType:"json"})}};var Jt={init:e=>{e.provider="alipay";const t=new Wt(e);return t.auth=function(){return{signInAnonymously:function(){return Promise.resolve()},getLoginState:function(){return Promise.resolve(!0)}}},t}};function zt({data:e}){let t;t=pe();const n=JSON.parse(JSON.stringify(e||{}));if(Object.assign(n,{clientInfo:t}),!n.uniIdToken){const{token:e}=oe();e&&(n.uniIdToken=e)}return n}const Vt={enable:!1,interval:0,space:{}};let Gt=null,Qt=0,Yt=!1;function Xt(){return Array.isArray(b)&&b.length?b[0]:{}}function Zt(e){return`${e}_${Xt().spaceId||"default"}`}function en(){if(Gt)return Gt;try{const e=re.getStorageSync(Zt("UNICLOUD_FAILOVER_CONFIG"));if(g(e))return Gt=e,e}catch(e){}return null}function tn(e){Qt=e;try{re.setStorageSync(Zt("UNICLOUD_FAILOVER_LAST_REQUEST"),e)}catch(e){}}function nn(e){if(null===e||e<0)return!1;if(0===e)return!0;const t=function(){if(Qt)return Qt;try{const e=re.getStorageSync(Zt("UNICLOUD_FAILOVER_LAST_REQUEST"));if(e&&"number"==typeof e)return Qt=e,e}catch(e){}return 0}();if(!t)return!0;return Date.now()-t>=e}async function sn(){const e=Xt(),{failoverEndpoint:t}=e;if(!t)return null;if(Yt)return en();Yt=!0;try{const e=`${t}/.unicloud/failover-cfg.json`,n=await re.request({url:e,method:"GET",dataType:"json",timeout:5e3});if(tn(Date.now()),200!==n.statusCode||!g(n.data))return null;const s={...Vt,...n.data},{enable:r=!1,interval:i=0,space:o={}}=s,a=en(),c=a&&a.enable,u=function(e,t){if(!e)return t.enable;if(e.enable!==t.enable)return!0;if(e.interval!==t.interval)return!0;if(t._lastModifiedAt&&e._lastModifiedAt!==t._lastModifiedAt)return!0;if(JSON.stringify(e.space)!==JSON.stringify(t.space))return!0;return!1}(a,s);return function(e){try{Gt=e,e&&e.enable?re.setStorageSync(Zt("UNICLOUD_FAILOVER_CONFIG"),e):(re.removeStorageSync(Zt("UNICLOUD_FAILOVER_CONFIG")),re.removeStorageSync(Zt("UNICLOUD_FAILOVER_LAST_REQUEST")))}catch(e){}}({enable:r,interval:i,space:o,_lastModifiedAt:n.data._lastModifiedAt||Date.now()}),u&&X(W,{isEnabled:r,hasStatusChanged:c!==r,failoverSpace:o}),s}catch(e){return en()}finally{Yt=!1}}async function rn(e={}){await this.__dev__.initLocalNetwork();const{localAddress:t,localPort:n}=this.__dev__,s=Xt(),r={aliyun:"aliyun",tencent:"tcb",alipay:"alipay",dcloud:"dcloud"}[s.provider],i=s.spaceId,o=`http://${t}:${n}/system/check-function`,a=`http://${t}:${n}/cloudfunctions/${e.name}`;return new Promise(((t,n)=>{re.request({method:"POST",url:o,data:{name:e.name,platform:A,provider:r,spaceId:i},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:t,message:n})=>{if(0!==t){switch(t){case"MODULE_ENCRYPTED":console.error(`此云函数(${e.name})依赖加密公共模块不可本地调试,自动切换为云端已部署的云函数`);break;case"FUNCTION_ENCRYPTED":console.error(`此云函数(${e.name})已加密不可本地调试,自动切换为云端已部署的云函数`);break;case"ACTION_ENCRYPTED":console.error(n||"需要访问加密的uni-clientDB-action自动切换为云端环境");break;case"NETWORK_ERROR":console.error(n||"连接本地调试服务失败,请检查客户端是否和主机在同一局域网下");break;case"SWITCH_TO_CLOUD":break;default:{const e=`检测本地调试服务出现错误:${n},请检查网络环境或重启客户端再试`;throw console.error(e),new Error(e)}}return this._callCloudFunction(e)}return new Promise(((t,n)=>{const s=zt.call(this,{data:e.data});re.request({method:"POST",url:a,data:{provider:r,platform:A,param:s},timeout:e.timeout,success:({statusCode:e,data:s}={})=>!e||e>=400?n(new se({code:s.code||"SYS_ERR",message:s.message||"request:fail"})):t({result:s}),fail(e){n(new se({code:e.code||e.errCode||"SYS_ERR",message:e.message||e.errMsg||"request:fail"}))}})}))}))}const on=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var an=/[\\^$.*+?()[\]{}|]/g,cn=RegExp(an.source);function un(e,t,n){return e.replace(new RegExp((s=t)&&cn.test(s)?s.replace(an,"\\$&"):s,"g"),n);var s}const ln="none",dn="request",hn="response",pn="both",fn={code:2e4,message:"System error"},gn={code:20101,message:"Invalid client"},mn={code:20102,message:"Get encrypt key failed"},yn={10001:"Secure network is not supported on current playground or unimpsdk",10003:"Config missing in current app. If the problem pesist, please contact DCloud.",10009:"Encrypt payload failed",10010:"Decrypt response failed"};function _n(e){return new se({subject:e.errSubject||"uni-secure-network",code:e.errCode||e.code||fn.code,message:e.errMsg||e.message||fn.message})}function wn(e){const{errSubject:t,subject:n,errCode:s,errMsg:r,code:i,message:o,cause:a}=e||{};return new se({subject:t||n||"uni-secure-network",code:s||i||fn.code,message:r||o,cause:a})}class vn{constructor({secretType:e,uniCloudIns:t}={}){this.clientType="",this.secretType=e||ln,this.uniCloudIns=t;const{provider:n,spaceId:s}=this.uniCloudIns.config;var r;this.provider=n,this.spaceId=s,this.scopedGlobalCache=(r=this.uniCloudIns,L("_globalUniCloudSecureNetworkCache__{spaceId}".replace("{spaceId}",r.config.spaceId)))}getSystemInfo(){return this._systemInfo||(this._systemInfo=le()),this._systemInfo}get appId(){return this.getSystemInfo().appId}get deviceId(){return this.getSystemInfo().deviceId}async encryptData(e){return this.secretType===ln?e:this.platformEncryptData(e)}async decryptResult(e){if(this.secretType===ln)return e;const{errCode:t,errMsg:n,content:s}=e||{};if(t||!s){if(t)throw _n({errCode:t,errMsg:n});if(!s)throw _n();return e}return this.secretType===dn?s:this.platformDecryptResult(e)}wrapVerifyClientCallFunction(e){const t=this;return async function({name:n,data:s={}}={}){await t.prepare(),(s=JSON.parse(JSON.stringify(s)))._uniCloudOptions=await t.platformGetSignOption();let r=await e({name:n,data:s});return t.isClientKeyNotFound(r)&&(await t.prepare({forceUpdate:!0}),s._uniCloudOptions=await t.platformGetSignOption(),r=await e({name:n,data:s})),r}}wrapEncryptDataCallFunction(e){const t=this;return async function({name:n,data:s={}}={}){await t.prepare();const r=await t.encryptData(s);let i=await e({name:n,data:r});if(t.isClientKeyNotFound(i)){await t.prepare({forceUpdate:!0});const r=await t.encryptData(s);i=await e({name:n,data:r})}return i.result=await t.decryptResult(i.result),i}}}t((function(e,t){var n,r,i,o,a,c,u,l;e.exports=(r=(n=l=s).lib,i=r.WordArray,o=r.Hasher,a=n.algo,c=[],u=a.SHA1=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,s=n[0],r=n[1],i=n[2],o=n[3],a=n[4],u=0;u<80;u++){if(u<16)c[u]=0|e[t+u];else{var l=c[u-3]^c[u-8]^c[u-14]^c[u-16];c[u]=l<<1|l>>>31}var d=(s<<5|s>>>27)+a+c[u];d+=u<20?1518500249+(r&i|~r&o):u<40?1859775393+(r^i^o):u<60?(r&i|r&o|i&o)-1894007588:(r^i^o)-899497514,a=o,o=i,i=r<<30|r>>>2,r=s,s=d}n[0]=n[0]+s|0,n[1]=n[1]+r|0,n[2]=n[2]+i|0,n[3]=n[3]+o|0,n[4]=n[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,s=8*e.sigBytes;return t[s>>>5]|=128<<24-s%32,t[14+(s+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(s+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),n.SHA1=o._createHelper(u),n.HmacSHA1=o._createHmacHelper(u),l.SHA1)})),t((function(e,t){var n;e.exports=(n=s,function(){var e=n,t=e.lib,s=t.Base,r=t.WordArray,i=e.algo,o=i.MD5,a=i.EvpKDF=s.extend({cfg:s.extend({keySize:4,hasher:o,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=this.cfg,s=n.hasher.create(),i=r.create(),o=i.words,a=n.keySize,c=n.iterations;o.length<a;){u&&s.update(u);var u=s.update(e).finalize(t);s.reset();for(var l=1;l<c;l++)u=s.finalize(u),s.reset();i.concat(u)}return i.sigBytes=4*a,i}});e.EvpKDF=function(e,t,n){return a.create(n).compute(e,t)}}(),n.EvpKDF)})),t((function(e,t){var n;e.exports=void((n=s).lib.Cipher||function(e){var t=n,s=t.lib,r=s.Base,i=s.WordArray,o=s.BufferedBlockAlgorithm,a=t.enc;a.Utf8;var c=a.Base64,u=t.algo.EvpKDF,l=s.Cipher=o.extend({cfg:r.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,n){this.cfg=this.cfg.extend(n),this._xformMode=e,this._key=t,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?w:y}return function(t){return{encrypt:function(n,s,r){return e(s).encrypt(t,n,s,r)},decrypt:function(n,s,r){return e(s).decrypt(t,n,s,r)}}}}()});s.StreamCipher=l.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var d=t.mode={},h=s.BlockCipherMode=r.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),p=d.CBC=function(){var t=h.extend();function n(t,n,s){var r=this._iv;if(r){var i=r;this._iv=e}else i=this._prevBlock;for(var o=0;o<s;o++)t[n+o]^=i[o]}return t.Encryptor=t.extend({processBlock:function(e,t){var s=this._cipher,r=s.blockSize;n.call(this,e,t,r),s.encryptBlock(e,t),this._prevBlock=e.slice(t,t+r)}}),t.Decryptor=t.extend({processBlock:function(e,t){var s=this._cipher,r=s.blockSize,i=e.slice(t,t+r);s.decryptBlock(e,t),n.call(this,e,t,r),this._prevBlock=i}}),t}(),f=(t.pad={}).Pkcs7={pad:function(e,t){for(var n=4*t,s=n-e.sigBytes%n,r=s<<24|s<<16|s<<8|s,o=[],a=0;a<s;a+=4)o.push(r);var c=i.create(o,s);e.concat(c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};s.BlockCipher=l.extend({cfg:l.cfg.extend({mode:p,padding:f}),reset:function(){l.reset.call(this);var e=this.cfg,t=e.iv,n=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var s=n.createEncryptor;else s=n.createDecryptor,this._minBufferSize=1;this._mode&&this._mode.__creator==s?this._mode.init(this,t&&t.words):(this._mode=s.call(n,this,t&&t.words),this._mode.__creator=s)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4});var g=s.CipherParams=r.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),m=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,n=e.salt;if(n)var s=i.create([1398893684,1701076831]).concat(n).concat(t);else s=t;return s.toString(c)},parse:function(e){var t=c.parse(e),n=t.words;if(1398893684==n[0]&&1701076831==n[1]){var s=i.create(n.slice(2,4));n.splice(0,4),t.sigBytes-=16}return g.create({ciphertext:t,salt:s})}},y=s.SerializableCipher=r.extend({cfg:r.extend({format:m}),encrypt:function(e,t,n,s){s=this.cfg.extend(s);var r=e.createEncryptor(n,s),i=r.finalize(t),o=r.cfg;return g.create({ciphertext:i,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:s.format})},decrypt:function(e,t,n,s){return s=this.cfg.extend(s),t=this._parse(t,s.format),e.createDecryptor(n,s).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),_=(t.kdf={}).OpenSSL={execute:function(e,t,n,s){s||(s=i.random(8));var r=u.create({keySize:t+n}).compute(e,s),o=i.create(r.words.slice(t),4*n);return r.sigBytes=4*t,g.create({key:r,iv:o,salt:s})}},w=s.PasswordBasedCipher=y.extend({cfg:y.cfg.extend({kdf:_}),encrypt:function(e,t,n,s){var r=(s=this.cfg.extend(s)).kdf.execute(n,e.keySize,e.ivSize);s.iv=r.iv;var i=y.encrypt.call(this,e,t,r.key,s);return i.mixIn(r),i},decrypt:function(e,t,n,s){s=this.cfg.extend(s),t=this._parse(t,s.format);var r=s.kdf.execute(n,e.keySize,e.ivSize,t.salt);return s.iv=r.iv,y.decrypt.call(this,e,t,r.key,s)}})}())}));var In=t((function(e,t){var n;e.exports=(n=s,function(){var e=n,t=e.lib.BlockCipher,s=e.algo,r=[],i=[],o=[],a=[],c=[],u=[],l=[],d=[],h=[],p=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var n=0,s=0;for(t=0;t<256;t++){var f=s^s<<1^s<<2^s<<3^s<<4;f=f>>>8^255&f^99,r[n]=f,i[f]=n;var g=e[n],m=e[g],y=e[m],_=257*e[f]^16843008*f;o[n]=_<<24|_>>>8,a[n]=_<<16|_>>>16,c[n]=_<<8|_>>>24,u[n]=_,_=16843009*y^65537*m^257*g^16843008*n,l[f]=_<<24|_>>>8,d[f]=_<<16|_>>>16,h[f]=_<<8|_>>>24,p[f]=_,n?(n=g^e[e[e[y^g]]],s^=e[e[s]]):n=s=1}}();var f=[0,1,2,4,8,16,32,64,128,27,54],g=s.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,n=e.sigBytes/4,s=4*((this._nRounds=n+6)+1),i=this._keySchedule=[],o=0;o<s;o++)if(o<n)i[o]=t[o];else{var a=i[o-1];o%n?n>6&&o%n==4&&(a=r[a>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=f[o/n|0]<<24),i[o]=i[o-n]^a}for(var c=this._invKeySchedule=[],u=0;u<s;u++)o=s-u,a=u%4?i[o]:i[o-4],c[u]=u<4||o<=4?a:l[r[a>>>24]]^d[r[a>>>16&255]]^h[r[a>>>8&255]]^p[r[255&a]]}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,a,c,u,r)},decryptBlock:function(e,t){var n=e[t+1];e[t+1]=e[t+3],e[t+3]=n,this._doCryptBlock(e,t,this._invKeySchedule,l,d,h,p,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,s,r,i,o,a){for(var c=this._nRounds,u=e[t]^n[0],l=e[t+1]^n[1],d=e[t+2]^n[2],h=e[t+3]^n[3],p=4,f=1;f<c;f++){var g=s[u>>>24]^r[l>>>16&255]^i[d>>>8&255]^o[255&h]^n[p++],m=s[l>>>24]^r[d>>>16&255]^i[h>>>8&255]^o[255&u]^n[p++],y=s[d>>>24]^r[h>>>16&255]^i[u>>>8&255]^o[255&l]^n[p++],_=s[h>>>24]^r[u>>>16&255]^i[l>>>8&255]^o[255&d]^n[p++];u=g,l=m,d=y,h=_}g=(a[u>>>24]<<24|a[l>>>16&255]<<16|a[d>>>8&255]<<8|a[255&h])^n[p++],m=(a[l>>>24]<<24|a[d>>>16&255]<<16|a[h>>>8&255]<<8|a[255&u])^n[p++],y=(a[d>>>24]<<24|a[h>>>16&255]<<16|a[u>>>8&255]<<8|a[255&l])^n[p++],_=(a[h>>>24]<<24|a[u>>>16&255]<<16|a[l>>>8&255]<<8|a[255&d])^n[p++],e[t]=g,e[t+1]=m,e[t+2]=y,e[t+3]=_},keySize:8});e.AES=t._createHelper(g)}(),n.AES)})),Sn=In,kn=t((function(e,t){var n;e.exports=((n=s).pad.NoPadding={pad:function(){},unpad:function(){}},n.pad.NoPadding)}));function Cn(e,t){const n=a.parse(e);if(-1===[16,24,32].indexOf(n.sigBytes))throw new Error("invalid key size (must be 16, 24 or 32 bytes)");const s=i.parse(t);if(16!==s.sigBytes)throw new Error("invalid initialation vector size (must be 16 bytes)");return{key:n,ivBuffer:s}}function An(e,t){return e.words[t>>>2]>>>24-t%4*8&255}function Tn(e,t,n){const{key:s,ivBuffer:r}=Cn(t,n);return Sn.encrypt(i.parse(e),s,{iv:r}).ciphertext.toString(a)}function bn(e,t,n){const s=a.parse(e);if(s.sigBytes%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");const{key:r,ivBuffer:o}=Cn(t,n);return function(e){if(e.sigBytes<16)throw new Error("PKCS#7 invalid length");const t=An(e,e.sigBytes-1);if(t>16)throw new Error("PKCS#7 padding byte out of range");const n=e.sigBytes-t;for(let s=0;s<t;s++)if(An(e,n+s)!==t)throw new Error("PKCS#7 invalid padding byte");return e.sigBytes=n,e.clamp(),e}(Sn.decrypt({ciphertext:s},r,{iv:o,padding:kn})).toString(i)}let xn,Pn,On=null;class En extends vn{constructor(e){super(e),this.clientType="mp-weixin",this.userEncryptKey=null}isLogin(){return!!this.scopedGlobalCache.mpWeixinCode||!!this.scopedGlobalCache.mpWeixinOpenid}async prepare(){if(!this.isLogin()){if(!this.scopedGlobalCache.initPromise)throw new Error("`uniCloud.initSecureNetworkByWeixin` has not yet been called");if(await this.scopedGlobalCache.initPromise,!this.isLogin())throw new Error("uniCloud.initSecureNetworkByWeixin` has not yet been called or successfully excuted")}}async getUserEncryptKey(){if(this.userEncryptKey)return this.userEncryptKey;if(On&&On.expireTime){const e=Date.now();if(On.expireTime-e>0)return this.userEncryptKey=On,this.userEncryptKey}return new Promise(((e,t)=>{uni.getUserCryptoManager().getLatestUserKey({success:t=>{On=t,this.userEncryptKey=t,e(this.userEncryptKey)},fail:e=>{t(wn({...mn,cause:e}))}})}))}getWxAppId(){return wx.getAccountInfoSync().miniProgram.appId}async platformGetSignOption(){const{encryptKey:e,iv:t,version:n}=await this.getUserEncryptKey();return{verifyClientSign:Tn(JSON.stringify({data:JSON.stringify({}),appId:this.appId,deviceId:this.deviceId,wxAppId:this.getWxAppId(),simulator:"devtools"===le().platform,timestamp:Date.now()}),e,t),encryptKeyId:n,mpWeixinCode:this.scopedGlobalCache.mpWeixinCode,mpWeixinOpenid:this.scopedGlobalCache.mpWeixinOpenid}}async platformEncryptData(e){const{encryptKey:t,iv:n,version:s}=await this.getUserEncryptKey(),r={secretType:this.secretType,encryptKeyId:s,mpWeixinCode:this.scopedGlobalCache.mpWeixinCode,mpWeixinOpenid:this.scopedGlobalCache.mpWeixinOpenid};return this.secretType===hn?{content:e,_uniCloudOptions:r}:{content:Tn(JSON.stringify({data:JSON.stringify(e),appId:this.appId,deviceId:this.deviceId,wxAppId:this.getWxAppId(),simulator:"devtools"===le().platform,timestamp:Date.now()}),t,n),_uniCloudOptions:r}}async platformDecryptResult(e){const{content:t}=e,{encryptKey:n,iv:s}=await this.getUserEncryptKey();return JSON.parse(bn(t,n,s))}isClientKeyNotFound(){return!1}}function Ln(e){const t=["hasClientKey","encryptGetClientKeyPayload","setClientKey","encrypt","decrypt"],n={};for(let s=0;s<t.length;s++){const r=t[s];n[r]=function(...t){return new Promise(((n,s)=>{"function"==typeof e[r]?e[r]({...t[0],success(e){n(e)},fail(e){s(wn({errCode:e.errCode,errMsg:yn[e.errCode]||e.errMsg||e.message}))}}):s(wn({message:"请检查manifest.json内是否开启安全网络模块另外注意标准基座不支持安全网络模块"}))}))}}return n}class Rn extends vn{constructor(e){super(e),this.clientType="app",this.appUtils={...Ln(uni.__getSecureNetworkManager())},this.systemInfo=xn||(xn=le())}async hasClientKey(){return this._hasClientKey=await this.appUtils.hasClientKey({provider:this.provider,spaceId:this.spaceId}),this._hasClientKey}async getAppClientKey(){const{data:e,key:t}=await this.appUtils.encryptGetClientKeyPayload({data:{}}),n=(await this.uniCloudIns.callFunction({name:"DCloud-clientDB",data:{redirectTo:"encryption",action:"getAppClientKey",data:e,key:t}})).result||{};if(0!==n.errCode)throw _n(n);const{clientKey:s,key:r}=n;await this.appUtils.setClientKey({provider:this.provider,spaceId:this.spaceId,clientKey:s,key:r})}async ensureClientKey({forceUpdate:e=!1}={}){if(!0!==await this.hasClientKey()||e)return e&&this.scopedGlobalCache.initPromise&&this.scopedGlobalCache.initStatus===d||!e&&this.scopedGlobalCache.initPromise&&this.scopedGlobalCache.initStatus!==p||(this.scopedGlobalCache.initPromise=this.getAppClientKey(),this.scopedGlobalCache.initPromise.then((e=>{this.scopedGlobalCache.initStatus=h})).catch((e=>{throw this.scopedGlobalCache.initStatus=p,e})),this.scopedGlobalCache.initStatus=d),this.scopedGlobalCache.initPromise}async prepare({forceUpdate:e=!1}={}){await this.ensureClientKey({forceUpdate:e})}async platformGetSignOption(){const{data:e,key:t}=await this.appUtils.encrypt({provider:this.provider,spaceId:this.spaceId,data:JSON.stringify({})});return{verifyClientSign:e,encryptKeyId:t}}async platformEncryptData(e){const{data:t,key:n}=await this.appUtils.encrypt({provider:this.provider,spaceId:this.spaceId,data:JSON.stringify(e)}),s={secretType:this.secretType,encryptKeyId:n};return this.secretType===hn?{content:e,_uniCloudOptions:s}:{content:t,_uniCloudOptions:s}}async platformDecryptResult(e){const{content:t,_uniCloudOptions:n={}}=e,s=n.encryptKeyId,r=await this.appUtils.decrypt({provider:this.provider,spaceId:this.spaceId,data:t,key:s});return JSON.parse(r.data)}isClientKeyNotFound(e={}){const t=e.result||{};return 70009===t.errCode&&"uni-secure-network"===t.errSubject}}function Un({secretType:e}={}){return e===dn||e===hn||e===pn}function Nn({name:e,data:t={}}={}){return"app"===A&&"DCloud-clientDB"===e&&"encryption"===t.redirectTo&&"getAppClientKey"===t.action}function Dn({provider:e,spaceId:t,functionName:n}={}){const{appId:s,uniPlatform:r,osName:i}=le();let o=r;"app"===r&&(o=i);const a=function({provider:e,spaceId:t}={}){const n=C;if(!n)return{};e=function(e){return"tencent"===e?"tcb":e}(e);const s=n.find((n=>n.provider===e&&n.spaceId===t));return s&&s.config}({provider:e,spaceId:t});if(!a||!a.accessControl||!a.accessControl.enable)return!1;const c=a.accessControl.function||{},u=Object.keys(c);if(0===u.length)return!0;const l=function(e,t){let n,s,r;for(let i=0;i<e.length;i++){const o=e[i];o!==t?"*"!==o?o.split(",").map((e=>e.trim())).indexOf(t)>-1&&(s=o):r=o:n=o}return n||s||r}(u,n);if(!l)return!1;if((c[l]||[]).find(((e={})=>e.appId===s&&(e.platform||"").toLowerCase()===o.toLowerCase())))return!0;throw console.error(`此应用[appId: ${s}, platform: ${o}]不在云端配置的允许访问的应用列表内参考https://uniapp.dcloud.net.cn/uniCloud/secure-network.html#verify-client`),wn(gn)}function Mn({functionName:e,result:t,logPvd:n}){if(S&&this.__dev__.debugLog&&t&&t.requestId){const s=JSON.stringify({spaceId:this.config.spaceId,functionName:e,requestId:t.requestId});console.log(`[${n}-request]${s}[/${n}-request]`)}}function Fn(e){const t=e.callFunction,n=function(n){const s=n.name;n.data=zt.call(e,{data:n.data});const r={aliyun:"aliyun",tencent:"tcb",tcb:"tcb",alipay:"alipay",dcloud:"dcloud"}[this.config.provider],i=Un(n),o=Nn(n),a=i||o;return t.call(this,n).then((e=>(e.errCode=0,!a&&Mn.call(this,{functionName:s,result:e,logPvd:r}),Promise.resolve(e))),(e=>(!a&&Mn.call(this,{functionName:s,result:e,logPvd:r}),e&&e.message&&(e.message=function({message:e="",extraInfo:t={},formatter:n=[]}={}){for(let s=0;s<n.length;s++){const{rule:r,content:i,mode:o}=n[s],a=e.match(r);if(!a)continue;let c=i;for(let e=1;e<a.length;e++)c=un(c,`{$${e}}`,a[e]);for(const e in t)c=un(c,`{${e}}`,t[e]);return"replace"===o?c:e+c}return e}({message:`[${n.name}]: ${e.message}`,formatter:on,extraInfo:{functionName:s}})),Promise.reject(e))))};e.callFunction=function(t){const{provider:s,spaceId:r}=e.config,i=t.name;let o,a;if(t.data=t.data||{},S&&e.__dev__.debugInfo&&!e.__dev__.debugInfo.forceRemote&&b&&e._isDefault?(e._callCloudFunction||(e._callCloudFunction=n,e._callLocalFunction=rn),o=rn):o=n,o=o.bind(e),Nn(t))a=n.call(e,t);else if(function({name:e,data:t={}}){return"mp-weixin"===A&&"uni-id-co"===e&&"secureNetworkHandshakeByWeixin"===t.method}(t))a=o.call(e,t);else if(Un(t)){a=new Pn({secretType:t.secretType,uniCloudIns:e}).wrapEncryptDataCallFunction(n.bind(e))(t)}else if(Dn({provider:s,spaceId:r,functionName:i})){a=new Pn({secretType:t.secretType,uniCloudIns:e}).wrapVerifyClientCallFunction(n.bind(e))(t)}else a=o(t);return Object.defineProperty(a,"result",{get:()=>(console.warn("当前返回结果为Promise类型不可直接访问其result属性详情请参考https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),a.then((e=>(e.result=UTS.JSON.parse(JSON.stringify(e.result)),e)))}}Pn="mp-weixin"!==A&&"app"!==A?class{constructor(){throw wn({message:`Platform ${A} is not supported by secure network`})}}:"mp-weixin"===A?En:Rn;const qn=Symbol("CLIENT_DB_INTERNAL");function Kn(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=qn,e.inspect=null,e.__v_raw=void 0,new Proxy(e,{get(e,n,s){if("_uniClient"===n)return null;if("symbol"==typeof n)return e[n];if(n in e||"string"!=typeof n){const t=e[n];return"function"==typeof t?t.bind(e):t}return t.get(e,n,s)}})}function jn(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]||[];const s=e[t].indexOf(n);-1!==s&&e[t].splice(s,1)}}}const Bn=["db.Geo","db.command","command.aggregate"];function $n(e,t){return Bn.indexOf(`${e}.${t}`)>-1}function Hn(e){switch(f(e=ie(e))){case"array":return e.map((e=>Hn(e)));case"object":return e._internalType===qn||Object.keys(e).forEach((t=>{e[t]=Hn(e[t])})),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:return e}}function Wn(e){return e&&e.content&&e.content.$method}class Jn{constructor(e,t,n){this.content=e,this.prevStage=t||null,this.udb=null,this._database=n}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:Hn(e.$param)})))}}toString(){return JSON.stringify(this.toJSON())}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 isAggregate(){let e=this;for(;e;){const t=Wn(e),n=Wn(e.prevStage);if("aggregate"===t&&"collection"===n||"pipeline"===t)return!0;e=e.prevStage}return!1}get isCommand(){let e=this;for(;e;){if("command"===Wn(e))return!0;e=e.prevStage}return!1}get isAggregateCommand(){let e=this;for(;e;){const t=Wn(e),n=Wn(e.prevStage);if("aggregate"===t&&"command"===n)return!0;e=e.prevStage}return!1}getNextStageFn(e){const t=this;return function(){return zn({$method:e,$param:Hn(Array.from(arguments))},t,t._database)}}get count(){return this.isAggregate?this.getNextStageFn("count"):function(){return this._send("count",Array.from(arguments))}}get remove(){return this.isCommand?this.getNextStageFn("remove"):function(){return this._send("remove",Array.from(arguments))}}get(){return this._send("get",Array.from(arguments))}get add(){return this.isCommand?this.getNextStageFn("add"):function(){return this._send("add",Array.from(arguments))}}update(){return this._send("update",Array.from(arguments))}end(){return this._send("end",Array.from(arguments))}get set(){return this.isCommand?this.getNextStageFn("set"):function(){throw new Error("JQL禁止使用set方法")}}_send(e,t){const n=this.getAction(),s=this.getCommand();if(s.$db.push({$method:e,$param:Hn(t)}),S){const e=s.$db.find((e=>"collection"===e.$method)),t=e&&e.$param;t&&1===t.length&&"string"==typeof e.$param[0]&&e.$param[0].indexOf(",")>-1&&console.warn("检测到使用JQL语法联表查询时未使用getTemp先过滤主表数据在主表数据量大的情况下可能会查询缓慢。\n- 如何优化请参考此文档https://uniapp.dcloud.net.cn/uniCloud/jql?id=lookup-with-temp \n- 如果主表数据量很小请忽略此信息,项目发行时不会出现此提示。")}return this._database._callCloudFunction({action:n,command:s})}}function zn(e,t,n){return Kn(new Jn(e,t,n),{get(e,t){let s="db";return e&&e.content&&(s=e.content.$method),$n(s,t)?zn({$method:t},e,n):function(){return zn({$method:t,$param:Hn(Array.from(arguments))},e,n)}}})}function Vn({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}]}}toString(){return JSON.stringify(this.toJSON())}}}function Gn(e,t={}){return Kn(new e(t),{get:(e,t)=>$n("db",t)?zn({$method:t},null,e):function(){return zn({$method:t,$param:Hn(Array.from(arguments))},null,e)}})}class Qn extends class{constructor({uniClient:e={},isJQL:t=!1}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e._isDefault&&(this._dbCallBacks=L("_globalUniCloudDatabaseCallback")),t||(this.auth=jn(this._authCallBacks)),this._isJQL=t,Object.assign(this,jn(this._dbCallBacks)),this.env=Kn({},{get:(e,t)=>({$env:t})}),this.Geo=Kn({},{get:(e,t)=>Vn({path:["Geo"],method:t})}),this.serverDate=Vn({path:[],method:"serverDate"}),this.RegExp=Vn({path:[],method:"RegExp"})}getCloudEnv(e){if("string"!=typeof e||!e.trim())throw new Error("getCloudEnv参数错误");return{$env:e.replace("$cloudEnv_","")}}_callback(e,t){const n=this._dbCallBacks;n[e]&&n[e].forEach((e=>{e(...t)}))}_callbackAuth(e,t){const n=this._authCallBacks;n[e]&&n[e].forEach((e=>{e(...t)}))}multiSend(){const e=Array.from(arguments),t=e.map((e=>{const t=e.getAction(),n=e.getCommand();if("getTemp"!==n.$db[n.$db.length-1].$method)throw new Error("multiSend只支持子命令内使用getTemp");return{action:t,command:n}}));return this._callCloudFunction({multiCommand:t,queryList:e})}startTransaction(){throw new Error("JQL 事务仅支持在云端使用")}commit(){throw new Error("JQL 事务仅支持在云端使用")}rollback(){throw new Error("JQL 事务仅支持在云端使用")}}{_parseResult(e){return this._isJQL?e.result:e}_callCloudFunction({action:e,command:t,multiCommand:n,queryList:s}){function r(e,t){if(n&&s)for(let n=0;n<s.length;n++){const r=s[n];r.udb&&"function"==typeof r.udb.setResult&&(t?r.udb.setResult(t):r.udb.setResult(e.result.dataList[n]))}}const i=this,o=this._isJQL?"databaseForJQL":"database";function a(e){return i._callback("error",[e]),F(q(o,"fail"),e).then((()=>F(q(o,"complete"),e))).then((()=>(r(null,e),X(B,{type:J,content:e}),Promise.reject(e))))}const c=F(q(o,"invoke")),u=this._uniClient;return c.then((()=>u.callFunction({name:"DCloud-clientDB",type:l,data:{action:e,command:t,multiCommand:n}}))).then((e=>{const{code:t,message:n,token:s,tokenExpired:c,systemInfo:u=[]}=e.result;if(u)for(let e=0;e<u.length;e++){const{level:t,message:n,detail:s}=u[e],r=console["app"===A&&"warn"===t?"error":t]||console.log;let i="[System Info]"+n;s&&(i=`${i}\n详细信息:${s}`),r(i)}if(t){return a(new se({code:t,message:n,requestId:e.requestId}))}e.result.errCode=e.result.errCode||e.result.code,e.result.errMsg=e.result.errMsg||e.result.message,s&&c&&(ae({token:s,tokenExpired:c}),this._callbackAuth("refreshToken",[{token:s,tokenExpired:c}]),this._callback("refreshToken",[{token:s,tokenExpired:c}]),X(H,{token:s,tokenExpired:c}));const l=[{prop:"affectedDocs",tips:"affectedDocs不再推荐使用请使用inserted/deleted/updated/data.length替代"},{prop:"code",tips:"code不再推荐使用请使用errCode替代"},{prop:"message",tips:"message不再推荐使用请使用errMsg替代"}];for(let t=0;t<l.length;t++){const{prop:n,tips:s}=l[t];if(n in e.result){const t=e.result[n];Object.defineProperty(e.result,n,{get:()=>(console.warn(s),t)})}}return function(e){return F(q(o,"success"),e).then((()=>F(q(o,"complete"),e))).then((()=>{r(e,null);const t=i._parseResult(e);return X(B,{type:J,content:t}),Promise.resolve(t)}))}(e)}),(e=>{/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化请在web控制台保存一次schema以开启clientDB");return a(new se({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId}))}))}}var Yn={};const Xn="token无效跳转登录页面",Zn="token过期跳转登录页面",es={TOKEN_INVALID_TOKEN_EXPIRED:Zn,TOKEN_INVALID_INVALID_CLIENTID:Xn,TOKEN_INVALID:Xn,TOKEN_INVALID_WRONG_TOKEN:Xn,TOKEN_INVALID_ANONYMOUS_USER:Xn},ts={"uni-id-token-expired":Zn,"uni-id-check-token-failed":Xn,"uni-id-token-not-exist":Xn,"uni-id-check-device-feature-failed":Xn},ns={...es,...ts,default:"用户未登录或登录状态过期,自动跳转登录页面"};function ss(e,t){let n="";return n=e?`${e}/${t}`:t,n.replace(/^\//,"")}function rs(e=[],t=""){const n=[],s=[];return e.forEach((e=>{!0===e.needLogin?n.push(ss(t,e.path)):!1===e.needLogin&&s.push(ss(t,e.path))})),{needLoginPage:n,notNeedLoginPage:s}}function is(e){return e.split("?")[0].replace(/^\//,"")}function os(){return function(e){let t=e&&e.route;return t?("/"!==t.charAt(0)&&(t="/"+t),t):""}(function(){const e=getCurrentPages();return e[e.length-1]}())}function as(){return is(os())}function cs(e="",t={}){if(!e)return!1;if(!(t&&t.list&&t.list.length))return!1;const n=t.list,s=is(e);return n.some((e=>e.pagePath===s))}const us=!!Yn.uniIdRouter;const{loginPage:ls,routerNeedLogin:ds,resToLogin:hs,needLoginPage:ps,notNeedLoginPage:fs,loginPageInTabBar:gs}=function({pages:e=[],subPackages:t=[],uniIdRouter:n={},tabBar:s={}}=Yn){const{loginPage:r,needLogin:i=[],resToLogin:o=!0}=n,{needLoginPage:a,notNeedLoginPage:c}=rs(e),{needLoginPage:u,notNeedLoginPage:l}=function(e=[]){const t=[],n=[];return e.forEach((e=>{const{root:s,pages:r=[]}=e,{needLoginPage:i,notNeedLoginPage:o}=rs(r,s);t.push(...i),n.push(...o)})),{needLoginPage:t,notNeedLoginPage:n}}(t);return{loginPage:r,routerNeedLogin:i,resToLogin:o,needLoginPage:[...a,...u],notNeedLoginPage:[...c,...l],loginPageInTabBar:cs(r,s)}}();if(ps.indexOf(ls)>-1)throw new Error(`Login page [${ls}] should not be "needLogin", please check your pages.json`);function ms(e){const t=as();if("/"===e.charAt(0))return e;const[n,s]=e.split("?"),r=n.replace(/^\//,"").split("/"),i=t.split("/");i.pop();for(let e=0;e<r.length;e++){const t=r[e];".."===t?i.pop():"."!==t&&i.push(t)}return""===i[0]&&i.shift(),"/"+i.join("/")+(s?"?"+s:"")}function ys(e,t){return new RegExp(t).test(e)}function _s({redirect:e}){const t=is(e),n=is(ls);return as()!==n&&t!==n}function ws({api:e,redirect:t}={}){if(!t||!_s({redirect:t}))return;const n=function(e,t){return"/"!==e.charAt(0)&&(e="/"+e),t?e.indexOf("?")>-1?e+`&uniIdRedirectUrl=${encodeURIComponent(t)}`:e+`?uniIdRedirectUrl=${encodeURIComponent(t)}`:e}(ls,t);gs?"navigateTo"!==e&&"redirectTo"!==e||(e="switchTab"):"switchTab"===e&&(e="navigateTo");const s={navigateTo:uni.navigateTo,redirectTo:uni.redirectTo,switchTab:uni.switchTab,reLaunch:uni.reLaunch};setTimeout((()=>{s[e]({url:n})}),0)}function vs({url:e}={}){const t={abortLoginPageJump:!1,autoToLoginPage:!1},n=function(){const{token:e,tokenExpired:t}=oe();let n;if(e){if(t<Date.now()){const e="uni-id-token-expired";n={errCode:e,errMsg:ns[e]}}}else{const e="uni-id-check-token-failed";n={errCode:e,errMsg:ns[e]}}return n}();if(function(e){const t=is(ms(e));return!(fs.indexOf(t)>-1)&&(ps.indexOf(t)>-1||ds.some((n=>ys(t,n)||ys(e,n))))}(e)&&n){n.uniIdRedirectUrl=e;if(G($).length>0)return setTimeout((()=>{X($,n)}),0),t.abortLoginPageJump=!0,t;t.autoToLoginPage=!0}return t}function Is(){const e=os(),{abortLoginPageJump:t,autoToLoginPage:n}=vs({url:e});t||n&&ws({api:"redirectTo",redirect:e})}function Ss(){Is();const e=["navigateTo","redirectTo","reLaunch","switchTab"];for(let t=0;t<e.length;t++){const n=e[t];uni.addInterceptor(n,{invoke(e){const{abortLoginPageJump:t,autoToLoginPage:s}=vs({url:e.url});return t?e:s?(ws({api:n,redirect:ms(e.url)}),!1):e}}),"web"===A&&window.addEventListener("popstate",(()=>{(0===getCurrentPages().length?(ee=!1,Z=null,te()):Promise.resolve()).then((()=>{Is()}))}))}}function ks(){this.onResponse((e=>{const{type:t,content:n}=e;let s=!1;switch(t){case"cloudobject":s=function(e){if("object"!=typeof e)return!1;const{errCode:t}=e||{};return t in ns}(n);break;case"clientdb":s=function(e){if("object"!=typeof e)return!1;const{errCode:t}=e||{};return t in es}(n)}s&&function(e={}){const t=G($);te().then((()=>{const n=os();if(n&&_s({redirect:n}))return t.length>0?X($,Object.assign({uniIdRedirectUrl:n},e)):void(ls&&ws({api:"navigateTo",redirect:n}))}))}(n)}))}function Cs(e){e.onNeedLogin=function(e){Q($,e)},e.offNeedLogin=function(e){Y($,e)},us&&(L("_globalUniCloudStatus").needLoginInit||(L("_globalUniCloudStatus").needLoginInit=!0,te().then((()=>{Ss.call(e)})),hs&&ks.call(e)))}function As(e){e.onFailover=function(e){Q(W,e)},e.offFailover=function(e){Y(W,e)},e.refreshFailoverConfig=function(){return e.config,tn(0),sn()},e.clearFailoverConfig=function(){!function(){Gt=null,Qt=0;try{re.removeStorageSync(Zt("UNICLOUD_FAILOVER_CONFIG")),re.removeStorageSync(Zt("UNICLOUD_FAILOVER_LAST_REQUEST"))}catch(e){}}()}}function Ts(e){!function(e){e.onResponse=function(e){Q(B,e)},e.offResponse=function(e){Y(B,e)}}(e),Cs(e),function(e){e.onRefreshToken=function(e){Q(H,e)},e.offRefreshToken=function(e){Y(H,e)}}(e),As(e)}const bs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",xs=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function Ps(e){return decodeURIComponent(function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!xs.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 n,s,r="",i=0;i<e.length;)t=bs.indexOf(e.charAt(i++))<<18|bs.indexOf(e.charAt(i++))<<12|(n=bs.indexOf(e.charAt(i++)))<<6|(s=bs.indexOf(e.charAt(i++))),r+=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);return r}(e).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))}function Os(){const e=oe().token||"",t=e.split(".");if(!e||3!==t.length)return{uid:null,role:[],permission:[],tokenExpired:0};let n;try{n=JSON.parse(Ps(t[1]))}catch(e){throw new Error("获取当前用户信息出错,详细错误信息为:"+e.message)}return n.tokenExpired=1e3*n.exp,delete n.exp,delete n.iat,n}var Es=t((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const n="chooseAndUploadFile:ok",s="chooseAndUploadFile:fail";function r(e,t){return e.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}function i(e,t,{onChooseFile:s,onUploadProgress:r}){return t.then((e=>{if(s){const t=s(e);if(void 0!==t)return Promise.resolve(t).then((t=>void 0===t?e:t))}return e})).then((t=>!1===t?{errMsg:n,tempFilePaths:[],tempFiles:[]}:function(e,t,s=5,r){(t=Object.assign({},t)).errMsg=n;const i=t.tempFiles,o=i.length;let a=0;return new Promise((n=>{for(;a<s;)c();function c(){const s=a++;if(s>=o)return void(!i.find((e=>!e.url&&!e.errMsg))&&n(t));const u=i[s];e.uploadFile({provider:u.provider,filePath:u.path,cloudPath:u.cloudPath,fileType:u.fileType,cloudPathAsRealPath:u.cloudPathAsRealPath,onUploadProgress(e){e.index=s,e.tempFile=u,e.tempFilePath=u.path,r&&r(e)}}).then((e=>{u.url=e.fileID,s<o&&c()})).catch((e=>{u.errMsg=e.errMsg||e.message,s<o&&c()}))}}))}(e,t,5,r)))}t.initChooseAndUploadFile=function(e){return function(t={type:"all"}){return"image"===t.type?i(e,function(e){const{count:t,sizeType:n,sourceType:i=["album","camera"],extension:o}=e;return new Promise(((e,a)=>{uni.chooseImage({count:t,sizeType:n,sourceType:i,extension:o,success(t){e(r(t,"image"))},fail(e){a({errMsg:e.errMsg.replace("chooseImage:fail",s)})}})}))}(t),t):"video"===t.type?i(e,function(e){const{camera:t,compressed:n,maxDuration:i,sourceType:o=["album","camera"],extension:a}=e;return new Promise(((e,c)=>{uni.chooseVideo({camera:t,compressed:n,maxDuration:i,sourceType:o,extension:a,success(t){const{tempFilePath:n,duration:s,size:i,height:o,width:a}=t;e(r({errMsg:"chooseVideo:ok",tempFilePaths:[n],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:n,size:i,type:t.tempFile&&t.tempFile.type||"",width:a,height:o,duration:s,fileType:"video",cloudPath:""}]},"video"))},fail(e){c({errMsg:e.errMsg.replace("chooseVideo:fail",s)})}})}))}(t),t):i(e,function(e){const{count:t,extension:n}=e;return new Promise(((e,i)=>{let o=uni.chooseFile;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(o=wx.chooseMessageFile),"function"!=typeof o)return i({errMsg:s+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});o({type:"all",count:t,extension:n,success(t){e(r(t))},fail(e){i({errMsg:e.errMsg.replace("chooseFile:fail",s)})}})}))}(t),t)}}})),Ls=e(Es);const Rs="manual";function Us(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:{},mixinDatacomError:null}),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(this.loadtime===Rs)return;let n=!1;const s=[];for(let r=2;r<e.length;r++)e[r]!==t[r]&&(s.push(e[r]),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.mixinDatacomError=null,this.mixinDatacomGet().then((n=>{this.mixinDatacomLoading=!1;const{data:s,count:r}=n.result;this.getcount&&(this.mixinDatacomPage.count=r),this.mixinDatacomHasMore=s.length<this.pageSize;const i=e?s.length?s[0]:void 0:s;this.mixinDatacomResData=i,t&&t(i)})).catch((e=>{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,this.mixinDatacomError=e,n&&n(e)})))},mixinDatacomGet(t={}){let n;t=t||{},n="undefined"!=typeof __uniX&&__uniX?e.databaseForJQL(this.spaceInfo):e.database(this.spaceInfo);const s=t.action||this.action;s&&(n=n.action(s));const r=t.collection||this.collection;n=Array.isArray(r)?n.collection(...r):n.collection(r);const i=t.where||this.where;i&&Object.keys(i).length&&(n=n.where(i));const o=t.field||this.field;o&&(n=n.field(o));const a=t.foreignKey||this.foreignKey;a&&(n=n.foreignKey(a));const c=t.groupby||this.groupby;c&&(n=n.groupBy(c));const u=t.groupField||this.groupField;u&&(n=n.groupField(u));!0===(void 0!==t.distinct?t.distinct:this.distinct)&&(n=n.distinct());const l=t.orderby||this.orderby;l&&(n=n.orderBy(l));const d=void 0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,h=void 0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,p=void 0!==t.getcount?t.getcount:this.getcount,f=void 0!==t.gettree?t.gettree:this.gettree,g=void 0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:p},y={limitLevel:void 0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void 0!==t.startwith?t.startwith:this.startwith};return f&&(m.getTree=y),g&&(m.getTreePath=y),n=n.skip(h*(d-1)).limit(h).get(m),n}}}}function Ns(e){return function(t,n={}){n=function(e,t={}){return e.customUI=t.customUI||e.customUI,e.parseSystemError=t.parseSystemError||e.parseSystemError,Object.assign(e.loadingOptions,t.loadingOptions),Object.assign(e.errorOptions,t.errorOptions),"object"==typeof t.secretMethods&&(e.secretMethods=t.secretMethods),e}({customUI:!1,loadingOptions:{title:"加载中...",mask:!0},errorOptions:{type:"modal",retry:!1}},n);const{customUI:s,loadingOptions:r,errorOptions:i,parseSystemError:o}=n,a=!s;return new Proxy({},{get(s,c){switch(c){case"toString":return"[object UniCloudObject]";case"toJSON":return{}}return function({fn:e,interceptorName:t,getCallbackArgs:n}={}){return async function(...s){const r=n?n({params:s}):{};let i,o;try{return await F(q(t,"invoke"),{...r}),i=await e(...s),await F(q(t,"success"),{...r,result:i}),i}catch(e){throw o=e,await F(q(t,"fail"),{...r,error:o}),o}finally{await F(q(t,"complete"),o?{...r,error:o}:{...r,result:i})}}}({fn:async function s(...l){let d;a&&uni.showLoading({title:r.title,mask:r.mask});const h={name:t,type:u,data:{method:c,params:l}};"object"==typeof n.secretMethods&&function(e,t){const n=t.data.method,s=e.secretMethods||{},r=s[n]||s["*"];r&&(t.secretType=r)}(n,h);let p=!1;try{d=await e.callFunction(h)}catch(e){p=!0,d={result:new se(e)}}const{errSubject:f,errCode:g,errMsg:m,newToken:y}=d.result||{};if(a&&uni.hideLoading(),y&&y.token&&y.tokenExpired&&(ae(y),X(H,{...y})),g){let e=m;if(p&&o){e=(await o({objectName:t,methodName:c,params:l,errSubject:f,errCode:g,errMsg:m})).errMsg||m}if(a)if("toast"===i.type)uni.showToast({title:e,icon:"none"});else{if("modal"!==i.type)throw new Error(`Invalid errorOptions.type: ${i.type}`);{const{confirm:t}=await async function({title:e,content:t,showCancel:n,cancelText:s,confirmText:r}={}){return new Promise(((i,o)=>{uni.showModal({title:e,content:t,showCancel:n,cancelText:s,confirmText:r,success(e){i(e)},fail(){i({confirm:!1,cancel:!0})}})}))}({title:"提示",content:e,showCancel:i.retry,cancelText:"取消",confirmText:i.retry?"重试":"确定"});if(i.retry&&t)return s(...l)}}const n=new se({subject:f,code:g,message:m,requestId:d.requestId});throw n.detail=d.result,X(B,{type:V,content:n}),n}return X(B,{type:V,content:d.result}),d.result},interceptorName:"callObject",getCallbackArgs:function({params:e}={}){return{objectName:t,methodName:c,params:e}}})}})}}function Ds(e){return L("_globalUniCloudSecureNetworkCache__{spaceId}".replace("{spaceId}",e.config.spaceId))}async function Ms({openid:e,callLoginByWeixin:t=!1}={}){const n=Ds(this);if("mp-weixin"!==A)throw new Error(`[SecureNetwork] API \`initSecureNetworkByWeixin\` is not supported on platform \`${A}\``);if(e&&t)throw new Error("[SecureNetwork] openid and callLoginByWeixin cannot be passed at the same time");if(e)return n.mpWeixinOpenid=e,{};const s=await new Promise(((e,t)=>{uni.login({success(t){e(t.code)},fail(e){t(new Error(e.errMsg))}})})),r=this.importObject("uni-id-co",{customUI:!0});return await r.secureNetworkHandshakeByWeixin({code:s,callLoginByWeixin:t}),n.mpWeixinCode=s,{code:s}}async function Fs(e){const t=Ds(this);return t.initPromise||(t.initPromise=Ms.call(this,e).then((e=>e)).catch((e=>{throw delete t.initPromise,e}))),t.initPromise}function qs(e){return function({openid:t,callLoginByWeixin:n=!1}={}){return Fs.call(e,{openid:t,callLoginByWeixin:n})}}function Ks(e){!function(e){he=e}(e)}function js(e){const t="mp-weixin"===A&&wx.canIUse("getAppBaseInfo"),n={getAppBaseInfo:t?uni.getAppBaseInfo:uni.getSystemInfo,getPushClientId:uni.getPushClientId};return function(s){return new Promise(((r,i)=>{t&&"getAppBaseInfo"===e?r(n[e]()):n[e]({...s,success(e){r(e)},fail(e){i(e)}})}))}}class Bs extends class{constructor(){this._callback={}}addListener(e,t){this._callback[e]||(this._callback[e]=[]),this._callback[e].push(t)}on(e,t){return this.addListener(e,t)}removeListener(e,t){if(!t)throw new Error('The "listener" argument must be of type function. Received undefined');const n=this._callback[e];if(!n)return;const s=function(e,t){for(let n=e.length-1;n>=0;n--)if(e[n]===t)return n;return-1}(n,t);n.splice(s,1)}off(e,t){return this.removeListener(e,t)}removeAllListener(e){delete this._callback[e]}emit(e,...t){const n=this._callback[e];if(n)for(let e=0;e<n.length;e++)n[e](...t)}}{constructor(){super(),this._uniPushMessageCallback=this._receivePushMessage.bind(this),this._currentMessageId=-1,this._payloadQueue=[]}init(){return Promise.all([js("getAppBaseInfo")(),js("getPushClientId")()]).then((([{appId:e}={},{cid:t}={}]=[])=>{if(!e)throw new Error("Invalid appId, please check the manifest.json file");if(!t)throw new Error("Invalid push client id");this._appId=e,this._pushClientId=t,this._seqId=Date.now()+"-"+Math.floor(9e5*Math.random()+1e5),this.emit("open"),this._initMessageListener()}),(e=>{throw this.emit("error",e),this.close(),e}))}async open(){return this.init()}_isUniCloudSSE(e){if("receive"!==e.type)return!1;const t=e&&e.data&&e.data.payload;return!(!t||"UNI_CLOUD_SSE"!==t.channel||t.seqId!==this._seqId)}_receivePushMessage(e){if(!this._isUniCloudSSE(e))return;const t=e&&e.data&&e.data.payload,{action:n,messageId:s,message:r}=t;this._payloadQueue.push({action:n,messageId:s,message:r}),this._consumMessage()}_consumMessage(){for(;;){const e=this._payloadQueue.find((e=>e.messageId===this._currentMessageId+1));if(!e)break;this._currentMessageId++,this._parseMessagePayload(e)}}_parseMessagePayload(e){const{action:t,messageId:n,message:s}=e;"end"===t?this._end({messageId:n,message:s}):"message"===t&&this._appendMessage({messageId:n,message:s})}_appendMessage({messageId:e,message:t}={}){this.emit("message",t)}_end({messageId:e,message:t}={}){this.emit("end",t),this.close()}_initMessageListener(){uni.onPushMessage(this._uniPushMessageCallback)}_destroy(){uni.offPushMessage(this._uniPushMessageCallback)}toJSON(){return{appId:this._appId,pushClientId:this._pushClientId,seqId:this._seqId}}close(){this._destroy(),this.emit("close")}}async function $s(e){if(!S)return Promise.resolve();if("app"===A){const{osName:e,osVersion:t}=le();"ios"===e&&function(e){if(!e||"string"!=typeof e)return 0;const t=e.match(/^(\d+)./);return t&&t[1]?parseInt(t[1]):0}(t)>=14&&console.warn("iOS 14及以上版本连接uniCloud本地调试服务需要允许客户端查找并连接到本地网络上的设备仅开发期间需要发行后不需要")}const t=e.__dev__;if(!t.debugInfo)return;const{address:n,servePort:s}=t.debugInfo,{address:r}=await Et(n,s);if(r)return t.localAddress=r,void(t.localPort=s);const i=console["app"===A?"error":"warn"];let o="";if("remote"===t.debugInfo.initialLaunchType?(t.debugInfo.forceRemote=!0,o="当前客户端和HBuilderX不在同一局域网下或其他网络原因无法连接HBuilderXuniCloud本地调试服务不对当前客户端生效。\n- 如果不使用uniCloud本地调试服务请直接忽略此信息。\n- 如需使用uniCloud本地调试服务请将客户端与主机连接到同一局域网下并重新运行到客户端。"):o="无法连接uniCloud本地调试服务请检查当前客户端是否与主机在同一局域网下。\n- 如需使用uniCloud本地调试服务请将客户端与主机连接到同一局域网下并重新运行到客户端。",o+="\n- 如果在HBuilderX开启的状态下切换过网络环境请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs\n- 检查是否错误的使用拦截器修改uni.request方法的参数","web"===A&&(o+="\n- 部分浏览器开启节流模式之后访问本地地址受限,请检查是否启用了节流模式"),0===A.indexOf("mp-")&&(o+="\n- 小程序中如何使用uniCloud请参考https://uniapp.dcloud.net.cn/uniCloud/publish.html#useinmp"),!t.debugInfo.forceRemote)throw new Error(o);i(o)}function Hs(e){e._initPromiseHub||(e._initPromiseHub=new v({createPromise:function(){let t=Promise.resolve();var n;n=1,t=new Promise((e=>{setTimeout((()=>{e()}),n)}));const s=e.auth();return t.then((()=>s.getLoginState())).then((e=>e?Promise.resolve():s.signInAnonymously()))}}))}const Ws={tcb:Pt,tencent:Pt,aliyun:me,private:Ut,dcloud:Ut,alipay:Jt};if(exports.uniCloud=new class{init(e){let t={};const n=Ws[e.provider];if(!n)throw new Error("未提供正确的provider参数");t=n.init(e),S&&function(e){if(!S)return;const t={};e.__dev__=t,t.debugLog=S&&("web"===A&&navigator.userAgent.indexOf("HBuilderX")>0||"app"===A||"mp-harmony"===A);const n=T;n&&!n.code&&(t.debugInfo=n);const s=new v({createPromise:function(){return $s(e)}});t.initLocalNetwork=function(){return s.exec()}}(t),Hs(t),Fn(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 n=Gn(Qn,{uniClient:e});return this._database=n,n},e.databaseForJQL=function(t){if(t&&Object.keys(t).length>0)return e.init(t).databaseForJQL();if(this._databaseForJQL)return this._databaseForJQL;const n=Gn(Qn,{uniClient:e,isJQL:!0});return this._databaseForJQL=n,n}}(t),function(e){e.getCurrentUserInfo=Os,e.chooseAndUploadFile=Ls.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return Us(e)}}),e.SSEChannel=Bs,e.initSecureNetworkByWeixin=qs(e),e.setCustomClientInfo=Ks,e.importObject=Ns(e)}(t);return["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach((e=>{if(!t[e])return;const n=t[e];t[e]=function(){return n.apply(t,Array.from(arguments))},t[e]=function(e,t){return function(n){let s=!1;if("callFunction"===t){const e=n&&n.type||c;s=e!==c}const r="callFunction"===t&&!s,i=this._initPromiseHub.exec();n=n||{};const{success:o,fail:a,complete:u}=ne(n),l=i.then((()=>s?Promise.resolve():F(q(t,"invoke"),n))).then((()=>e.call(this,n))).then((e=>s?Promise.resolve(e):F(q(t,"success"),e).then((()=>F(q(t,"complete"),e))).then((()=>(r&&X(B,{type:z,content:e}),Promise.resolve(e))))),(e=>s?Promise.reject(e):F(q(t,"fail"),e).then((()=>F(q(t,"complete"),e))).then((()=>(X(B,{type:z,content:e}),Promise.reject(e))))));if(!(o||a||u))return l;l.then((e=>{o&&o(e),u&&u(e),r&&X(B,{type:z,content:e})}),(e=>{a&&a(e),u&&u(e),r&&X(B,{type:z,content:e})}))}}(t[e],e).bind(t)})),t.init=this.init,t}},(()=>{const e=Array.isArray(b)?b.length:0,t=function(){const e=Xt(),t=en();return t&&t.enable&&g(t.space)?t.space:e}();if(1===e)exports.uniCloud=exports.uniCloud.init(t),exports.uniCloud._isDefault=!0;else{const t=["database","getCurrentUserInfo","importObject"];let n;n=e>0?"应用有多个服务空间请通过uniCloud.init方法指定要使用的服务空间":x?"应用未关联服务空间请在uniCloud目录右键关联服务空间":"uni-app cli项目内使用uniCloud需要使用HBuilderX的运行菜单运行项目且需要在uniCloud目录关联服务空间",[...["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile"],...t].forEach((e=>{exports.uniCloud[e]=function(){if(console.error(n),-1===t.indexOf(e))return Promise.reject(new se({code:"SYS_ERR",message:n}));console.error(n)}}))}if(Object.assign(exports.uniCloud,{get mixinDatacom(){return Us(exports.uniCloud)}}),Ts(exports.uniCloud),exports.uniCloud.addInterceptor=D,exports.uniCloud.removeInterceptor=M,exports.uniCloud.interceptObject=K,S&&"web"===A&&(window.uniCloud=exports.uniCloud),"app"===A&&(uni.__uniCloud=exports.uniCloud),"app"===A||"web"===A){const e=R();e.uniCloud=exports.uniCloud,e.UniCloudError=se}if("mp-weixin"===A){const e=R();e.uniCloud=e.uniCloud||exports.uniCloud,e.UniCloudError=e.UniCloudError||se}!function(){const{failoverEndpoint:e}=Xt();if(!e)return;sn().catch((e=>{console.error("请求故障切换配置失败:",e)}));const t={fail(){const e=en();nn(e&&e.interval||0)&&sn().catch((e=>{console.error("请求故障切换配置失败:",e)}))}};D("callFunction",t),D("database",t),D("uploadFile",t)}()})(),exports.UniCloudError=se,"mp-weixin"===A){const e=R();exports.uniCloud=e.uniCloud,exports.UniCloudError=e.UniCloudError}var Js=exports.uniCloud;exports.default=Js;