import{a2 as e,t,ad as n,ae as s,ay as r,aQ as o,af as i,al as a,am as c,A as u,W as h,aR as l,aS as d,aE as f,aF as p,aT as g,aU as m,aa as y,$ as _,aV as w,s as k,a as v,aH as T,aW as S}from"./index-f6e54d8f.js";function A(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 P=A((function(e,t){var n;e.exports=(n=n||function(e){var t=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),n={},s=n.lib={},r=s.Base={extend:function(e){var n=t(this);return e&&n.mixIn(e),n.hasOwnProperty("init")&&this.init!==n.init||(n.init=function(){n.$super.init.apply(this,arguments)}),n.init.prototype=n,n.$super=this,n},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=s.WordArray=r.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||a).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 o=0;o>>2]>>>24-o%4*8&255;t[s+o>>>2]|=i<<24-(s+o)%4*8}else for(o=0;o>>2]=n[o>>>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=r.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,s=[],r=function(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>>2]>>>24-r%4*8&255;s.push((o>>>4).toString(16)),s.push((15&o).toString(16))}return s.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s>>3]|=parseInt(e.substr(s,2),16)<<24-s%8*4;return new o.init(n,t/2)}},c=i.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],r=0;r>>2]>>>24-r%4*8&255;s.push(String.fromCharCode(o))}return s.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s>>2]|=(255&e.charCodeAt(s))<<24-s%4*8;return new o.init(n,t)}},u=i.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},h=s.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.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 h=0;h>>24)|4278255360&(r<<24|r>>>8)}var o=this._hash.words,i=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],g=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],w=e[t+8],k=e[t+9],v=e[t+10],T=e[t+11],S=e[t+12],A=e[t+13],P=e[t+14],I=e[t+15],b=o[0],O=o[1],C=o[2],E=o[3];b=u(b,O,C,E,i,7,a[0]),E=u(E,b,O,C,c,12,a[1]),C=u(C,E,b,O,f,17,a[2]),O=u(O,C,E,b,p,22,a[3]),b=u(b,O,C,E,g,7,a[4]),E=u(E,b,O,C,m,12,a[5]),C=u(C,E,b,O,y,17,a[6]),O=u(O,C,E,b,_,22,a[7]),b=u(b,O,C,E,w,7,a[8]),E=u(E,b,O,C,k,12,a[9]),C=u(C,E,b,O,v,17,a[10]),O=u(O,C,E,b,T,22,a[11]),b=u(b,O,C,E,S,7,a[12]),E=u(E,b,O,C,A,12,a[13]),C=u(C,E,b,O,P,17,a[14]),b=h(b,O=u(O,C,E,b,I,22,a[15]),C,E,c,5,a[16]),E=h(E,b,O,C,y,9,a[17]),C=h(C,E,b,O,T,14,a[18]),O=h(O,C,E,b,i,20,a[19]),b=h(b,O,C,E,m,5,a[20]),E=h(E,b,O,C,v,9,a[21]),C=h(C,E,b,O,I,14,a[22]),O=h(O,C,E,b,g,20,a[23]),b=h(b,O,C,E,k,5,a[24]),E=h(E,b,O,C,P,9,a[25]),C=h(C,E,b,O,p,14,a[26]),O=h(O,C,E,b,w,20,a[27]),b=h(b,O,C,E,A,5,a[28]),E=h(E,b,O,C,f,9,a[29]),C=h(C,E,b,O,_,14,a[30]),b=l(b,O=h(O,C,E,b,S,20,a[31]),C,E,m,4,a[32]),E=l(E,b,O,C,w,11,a[33]),C=l(C,E,b,O,T,16,a[34]),O=l(O,C,E,b,P,23,a[35]),b=l(b,O,C,E,c,4,a[36]),E=l(E,b,O,C,g,11,a[37]),C=l(C,E,b,O,_,16,a[38]),O=l(O,C,E,b,v,23,a[39]),b=l(b,O,C,E,A,4,a[40]),E=l(E,b,O,C,i,11,a[41]),C=l(C,E,b,O,p,16,a[42]),O=l(O,C,E,b,y,23,a[43]),b=l(b,O,C,E,k,4,a[44]),E=l(E,b,O,C,S,11,a[45]),C=l(C,E,b,O,I,16,a[46]),b=d(b,O=l(O,C,E,b,f,23,a[47]),C,E,i,6,a[48]),E=d(E,b,O,C,_,10,a[49]),C=d(C,E,b,O,P,15,a[50]),O=d(O,C,E,b,m,21,a[51]),b=d(b,O,C,E,S,6,a[52]),E=d(E,b,O,C,p,10,a[53]),C=d(C,E,b,O,v,15,a[54]),O=d(O,C,E,b,c,21,a[55]),b=d(b,O,C,E,w,6,a[56]),E=d(E,b,O,C,I,10,a[57]),C=d(C,E,b,O,y,15,a[58]),O=d(O,C,E,b,A,21,a[59]),b=d(b,O,C,E,g,6,a[60]),E=d(E,b,O,C,T,10,a[61]),C=d(C,E,b,O,f,15,a[62]),O=d(O,C,E,b,k,21,a[63]),o[0]=o[0]+b|0,o[1]=o[1]+O|0,o[2]=o[2]+C|0,o[3]=o[3]+E|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 o=e.floor(s/4294967296),i=s;n[15+(r+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var h=c[u];c[u]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,s,r,o,i){var a=e+(t&n|~t&s)+r+i;return(a<>>32-o)+t}function h(e,t,n,s,r,o,i){var a=e+(t&s|n&~s)+r+i;return(a<>>32-o)+t}function l(e,t,n,s,r,o,i){var a=e+(t^n^s)+r+i;return(a<>>32-o)+t}function d(e,t,n,s,r,o,i){var a=e+(n^(t|~s))+r+i;return(a<>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),n.MD5)})),A((function(e,t){var n,s,r;e.exports=(s=(n=I).lib.Base,r=n.enc.Utf8,void(n.algo.HMAC=s.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=r.parse(t));var n=e.blockSize,s=4*n;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,c=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a>>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,s=this._reverseMap;if(!s){s=this._reverseMap=[];for(var o=0;o>>6-i%4*2;s[o>>>2]|=(a|c)<<24-o%4*8,o++}return r.create(s,o)}(e,t,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},n.enc.Base64)}));const E="FUNCTION",x="pending",L="rejected";function R(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function U(e){return"object"===R(e)}function N(e){return"function"==typeof e}function D(e){return function(){try{return e.apply(e,arguments)}catch(t){console.error(t)}}}const F="REJECTED",q="NOT_PENDING";class M{constructor({createPromise:e,retryRule:t=F}={}){this.createPromise=e,this.status=null,this.promise=null,this.retryRule=t}get needRetry(){if(!this.status)return!0;switch(this.retryRule){case F:return this.status===L;case q:return this.status!==x}}exec(){return this.needRetry?(this.status=x,this.promise=this.createPromise().then((e=>(this.status="fullfilled",Promise.resolve(e))),(e=>(this.status=L,Promise.reject(e)))),this.promise):this.promise}}function j(e){return e&&"string"==typeof e?JSON.parse(e):e}const $=j([]),K="web";j("");const B=j("[]")||[];let W="";try{W="__UNI__27C6F45"}catch(Ue){}let H={};function J(e,t={}){var n,s;return n=H,s=e,Object.prototype.hasOwnProperty.call(n,s)||(H[e]=t),H[e]}const z=["invoke","success","fail","complete"],V=J("_globalUniCloudInterceptor");function Q(e,t){V[e]||(V[e]={}),U(t)&&Object.keys(t).forEach((n=>{z.indexOf(n)>-1&&function(e,t,n){let s=V[e][t];s||(s=V[e][t]=[]),-1===s.indexOf(n)&&N(n)&&s.push(n)}(e,n,t[n])}))}function G(e,t){V[e]||(V[e]={}),U(t)?Object.keys(t).forEach((n=>{z.indexOf(n)>-1&&function(e,t,n){const s=V[e][t];if(!s)return;const r=s.indexOf(n);r>-1&&s.splice(r,1)}(e,n,t[n])})):delete V[e]}function Y(e,t){return e&&0!==e.length?e.reduce(((e,n)=>e.then((()=>n(t)))),Promise.resolve()):Promise.resolve()}function X(e,t){return V[e]&&V[e][t]||[]}function Z(e){Q("callObject",e)}const ee=J("_globalUniCloudListener"),te="response",ne="needLogin",se="refreshToken",re="clientdb",oe="cloudfunction",ie="cloudobject";function ae(e){return ee[e]||(ee[e]=[]),ee[e]}function ce(e,t){const n=ae(e);n.includes(t)||n.push(t)}function ue(e,t){const n=ae(e),s=n.indexOf(t);-1!==s&&n.splice(s,1)}function he(e,t){const n=ae(e);for(let s=0;s{de&&e(),function t(){if("function"==typeof r){const t=r();t&&t[0]&&(de=!0,e())}de||setTimeout((()=>{t()}),30)}()})),le)}function pe(e){const t={};for(const n in e){const s=e[n];N(s)&&(t[n]=D(s))}return t}class ge extends Error{constructor(e){super(e.message),this.errMsg=e.message||e.errMsg||"unknown system error",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 me={request:e=>l(e),uploadFile:e=>d(e),setStorageSync:(e,t)=>f(e,t),getStorageSync:e=>p(e),removeStorageSync:e=>g(e),clearStorageSync:()=>m()};function ye(e){return e&&ye(e.__v_raw)||e}function _e(){return{token:me.getStorageSync("uni_id_token")||me.getStorageSync("uniIdToken"),tokenExpired:me.getStorageSync("uni_id_token_expired")}}function we({token:e,tokenExpired:t}={}){e&&me.setStorageSync("uni_id_token",e),t&&me.setStorageSync("uni_id_token_expired",t)}let ke,ve;function Te(){return ke||(ke=y()),ke}function Se(){let e,t;try{if(S){if(S.toString().indexOf("not yet implemented")>-1)return;const{scene:n,channel:s}=S();e=s,t=n}}catch(n){}return{channel:e,scene:t}}function Ae(){const e=T&&T()||"en";if(ve)return{...ve,locale:e,LOCALE:e};const t=Te(),{deviceId:n,osName:s,uniPlatform:r,appId:o}=t,i=["pixelRatio","brand","model","system","language","version","platform","host","SDKVersion","swanNativeVersion","app","AppPlatform","fontSizeSetting"];for(let a=0;a{t(Object.assign(e,{complete(e){e||(e={});const t=e.data&&e.data.header&&e.data.header["x-serverless-request-id"]||e.header&&e.header["request-id"];if(!e.statusCode||e.statusCode>=400)return s(new ge({code:"SYS_ERR",message:e.errMsg||"request:fail",requestId:t}));const r=e.data;if(r.error)return s(new ge({code:r.error.code,message:r.error.message,requestId:t}));r.result=r.data,r.requestId=t,delete r.data,n(r)}}))}))},be=function(e){return C.stringify(O.parse(e))},Oe={"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"};const{t:Ce}=e({"zh-Hans":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},"zh-Hant":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},en:Oe,fr:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},es:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},ja:Oe},"zh-Hans");var Ee=class{constructor(e){["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(Ce("uniCloud.init.paramRequired",{param:t}))})),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=me,this._getAccessTokenPromiseHub=new M({createPromise:()=>this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>{if(!e.result||!e.result.accessToken)throw new ge({code:"AUTH_FAILED",message:"获取accessToken失败"});this.setAccessToken(e.result.accessToken)})),retryRule:q})}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return Ie(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"]=Pe(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"]=Pe(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))}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:o}){return new Promise(((i,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?i(e):a(new ge({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new ge({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof o&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{o({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}reportOSSUpload(e){const t={method:"serverless.file.resource.report",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}async uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s,config:r}){if("string"!==R(t))throw new ge({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new ge({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new ge({code:"INVALID_PARAM",message:"cloudPath不合法"});const o=r&&r.envType||this.config.envType,i=(await this.getOSSUploadOptionsFromPath({env:o,filename:t})).result,a="https://"+i.cdnDomain+"/"+i.ossPath,{securityToken:c,accessKeyId:u,signature:h,host:l,ossPath:d,id:f,policy:p,ossCallbackUrl:g}=i,m={"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:u,Signature:h,host:l,id:f,key:d,policy:p,success_action_status:200};if(c&&(m["x-oss-security-token"]=c),g){const e=JSON.stringify({callbackUrl:g,callbackBody:JSON.stringify({fileId:f,spaceId:this.config.spaceId}),callbackBodyType:"application/json"});m.callback=be(e)}const y={url:"https://"+i.host,formData:m,fileName:"file",name:"file",filePath:e,fileType:n};if(await this.uploadFileToOSS(Object.assign({},y,{onUploadProgress:s})),g)return{success:!0,filePath:e,fileID:a};if((await this.reportOSSUpload({id:f})).success)return{success:!0,filePath:e,fileID:a};throw new ge({code:"UPLOAD_FAILED",message:"文件上传失败"})}getTempFileURL({fileList:e}={}){return new Promise(((t,n)=>{Array.isArray(e)&&0!==e.length||n(new ge({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),t({fileList:e.map((e=>({fileID:e,tempFileURL:e})))})}))}async getFileInfo({fileList:e}={}){if(!Array.isArray(e)||0===e.length)throw new ge({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}}},xe={init(e){const t=new Ee(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 Le="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var Re,Ue;(Ue=Re||(Re={})).local="local",Ue.none="none",Ue.session="session";var Ne=function(){};const De=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new ge({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 Fe(e){return void 0===e}function qe(e){return"[object Null]"===Object.prototype.toString.call(e)}var Me;!function(e){e.WEB="web",e.WX_MP="wx_mp"}(Me||(Me={}));const je={adapter:null,runtime:void 0},$e=["anonymousUuidKey"];class Ke extends Ne{constructor(){super(),je.adapter.root.tcbObject||(je.adapter.root.tcbObject={})}setItem(e,t){je.adapter.root.tcbObject[e]=t}getItem(e){return je.adapter.root.tcbObject[e]}removeItem(e){delete je.adapter.root.tcbObject[e]}clear(){delete je.adapter.root.tcbObject}}function Be(e,t){switch(e){case"local":return t.localStorage||new Ke;case"none":return new Ke;default:return t.sessionStorage||new Ke}}class We{constructor(e){if(!this._storage){this._persistence=je.adapter.primaryStorage||e.persistence,this._storage=Be(this._persistence,je.adapter);const t=`access_token_${e.env}`,n=`access_token_expire_${e.env}`,s=`refresh_token_${e.env}`,r=`anonymous_uuid_${e.env}`,o=`login_type_${e.env}`,i=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s,anonymousUuidKey:r,loginTypeKey:o,userInfoKey:i}}}updatePersistence(e){if(e===this._persistence)return;const t="local"===this._persistence;this._persistence=e;const n=Be(e,je.adapter);for(const s in this.keys){const e=this.keys[s];if(t&&$e.includes(s))continue;const r=this._storage.getItem(e);Fe(r)||qe(r)||(n.setItem(e,r),this._storage.removeItem(e))}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(o){throw o}}getStore(e,t){try{if(!this._storage)return}catch(s){return""}t=t||"localCachev1";const n=this._storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}removeStore(e){this._storage.removeItem(e)}}const He={},Je={};function ze(e){return He[e]}class Ve{constructor(e,t){this.data=t||null,this.name=e}}class Qe extends Ve{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const Ge=new class{constructor(){this._listeners={}}on(e,t){return n=e,s=t,(r=this._listeners)[n]=r[n]||[],r[n].push(s),this;var n,s,r}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 Ve(e,t||{}):e,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 Ye(e,t){Ge.on(e,t)}function Xe(e,t={}){Ge.fire(e,t)}function Ze(e,t){Ge.off(e,t)}const et="loginStateChanged",tt="loginStateExpire",nt="loginTypeChanged",st="anonymousConverted",rt="refreshAccessToken";var ot;!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"}(ot||(ot={}));const it=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],at={"X-SDK-Version":"1.3.5"};function ct(e,t,n){const s=e[t];e[t]=function(t){const r={},o={};n.forEach((n=>{const{data:s,headers:i}=n.call(e,t);Object.assign(r,s),Object.assign(o,i)}));const i=t.data;return i&&(()=>{var e;if(e=i,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...i,...r};else for(const t in r)i.append(t,r[t])})(),t.headers={...t.headers||{},...o},s.call(e,t)}}function ut(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...at,"x-seqid":e}}}class ht{constructor(e={}){var t;this.config=e,this._reqClass=new je.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=ze(this.config.env),this._localCache=(t=this.config.env,Je[t]),ct(this._reqClass,"post",[ut]),ct(this._reqClass,"upload",[ut]),ct(this._reqClass,"download",[ut])}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(n){t=n}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 o=this._cache.getStore(n);if(!o)throw new ge({message:"未登录CloudBase"});const i={refresh_token:o},a=await this.request("auth.fetchAccessTokenWithRefreshToken",i);if(a.data.code){const{code:e}=a.data;if("SIGN_PARAM_INVALID"===e||"REFRESH_TOKEN_EXPIRED"===e||"INVALID_REFRESH_TOKEN"===e){if(this._cache.getStore(s)===ot.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()}Xe(tt),this._cache.removeStore(n)}throw new ge({code:a.data.code,message:`刷新access token失败:${a.data.code}`})}if(a.data.access_token)return Xe(rt),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 ge({message:"refresh token不存在,登录状态异常"});let s=this._cache.getStore(e),r=this._cache.getStore(t),o=!0;return this._shouldRefreshAccessTokenHook&&!(await this._shouldRefreshAccessTokenHook(s,r))&&(o=!1),(!s||!r||r{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:o,city:i}=e,{data:a}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:s,province:r,country:o,city:i});this.setLocalUserInfo(a)}async refresh(){const{data:e}=await this._request.send("auth.getUserInfo",{});return this.setLocalUserInfo(e),e}setUserInfo(){const{userInfoKey:e}=this._cache.keys,t=this._cache.getStore(e);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl"].forEach((e=>{this[e]=t[e]})),this.location={country:t.country,province:t.province,city:t.city}}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e),this.setUserInfo()}}class gt{constructor(e){if(!e)throw new ge({code:"PARAM_ERROR",message:"envId is not defined"});this._cache=ze(e);const{refreshTokenKey:t,accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys,r=this._cache.getStore(t),o=this._cache.getStore(n),i=this._cache.getStore(s);this.credential={refreshToken:r,accessToken:o,accessTokenExpire:i},this.user=new pt(e)}get isAnonymousAuth(){return this.loginType===ot.ANONYMOUS}get isCustomAuth(){return this.loginType===ot.CUSTOM}get isWeixinAuth(){return this.loginType===ot.WECHAT||this.loginType===ot.WECHAT_OPEN||this.loginType===ot.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class mt extends ft{async signIn(){this._cache.updatePersistence("local");const{anonymousUuidKey:e,refreshTokenKey:t}=this._cache.keys,n=this._cache.getStore(e)||void 0,s=this._cache.getStore(t)||void 0,r=await this._request.send("auth.signInAnonymously",{anonymous_uuid:n,refresh_token:s});if(r.uuid&&r.refresh_token){this._setAnonymousUUID(r.uuid),this.setRefreshToken(r.refresh_token),await this._request.refreshAccessToken(),Xe(et),Xe(nt,{env:this.config.env,loginType:ot.ANONYMOUS,persistence:"local"});const e=new gt(this.config.env);return await e.user.refresh(),e}throw new ge({message:"匿名登录失败"})}async linkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:n}=this._cache.keys,s=this._cache.getStore(t),r=this._cache.getStore(n),o=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:s,refresh_token:r,ticket:e});if(o.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(o.refresh_token),await this._request.refreshAccessToken(),Xe(st,{env:this.config.env}),Xe(nt,{loginType:ot.CUSTOM,persistence:"local"}),{credential:{refreshToken:o.refresh_token}};throw new ge({message:"匿名转化失败"})}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(n,ot.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class yt extends ft{async signIn(e){if("string"!=typeof e)throw new ge({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(),Xe(et),Xe(nt,{env:this.config.env,loginType:ot.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new gt(this.config.env);throw new ge({message:"自定义登录失败"})}}class _t extends ft{async signIn(e,t){if("string"!=typeof e)throw new ge({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:o,access_token_expire:i}=s;if(r)return this.setRefreshToken(r),o&&i?this.setAccessToken(o,i):await this._request.refreshAccessToken(),await this.refreshUserInfo(),Xe(et),Xe(nt,{env:this.config.env,loginType:ot.EMAIL,persistence:this.config.persistence}),new gt(this.config.env);throw s.code?new ge({code:s.code,message:`邮箱登录失败: ${s.message}`}):new ge({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 wt extends ft{async signIn(e,t){if("string"!=typeof e)throw new ge({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:ot.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:r,access_token_expire:o,access_token:i}=s;if(r)return this.setRefreshToken(r),i&&o?this.setAccessToken(i,o):await this._request.refreshAccessToken(),await this.refreshUserInfo(),Xe(et),Xe(nt,{env:this.config.env,loginType:ot.USERNAME,persistence:this.config.persistence}),new gt(this.config.env);throw s.code?new ge({code:s.code,message:`用户名密码登录失败: ${s.message}`}):new ge({message:"用户名密码登录失败"})}}class kt{constructor(e){this.config=e,this._cache=ze(e.env),this._request=dt(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),Ye(nt,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 mt(this.config)}customAuthProvider(){return new yt(this.config)}emailAuthProvider(){return new _t(this.config)}usernameAuthProvider(){return new wt(this.config)}async signInAnonymously(){return new mt(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new _t(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new wt(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){return this._anonymousAuthProvider||(this._anonymousAuthProvider=new mt(this.config)),Ye(st,this._onAnonymousConverted),await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===ot.ANONYMOUS)throw new ge({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),Xe(et),Xe(nt,{env:this.config.env,loginType:ot.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){Ye(et,(()=>{const t=this.hasLoginState();e.call(this,t)}));const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){Ye(tt,e.bind(this))}onAccessTokenRefreshed(e){Ye(rt,e.bind(this))}onAnonymousConverted(e){Ye(st,e.bind(this))}onLoginTypeChanged(e){Ye(nt,(()=>{const t=this.hasLoginState();e.call(this,t)}))}async getAccessToken(){return{accessToken:(await this._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{refreshTokenKey:e}=this._cache.keys;return this._cache.getStore(e)?new gt(this.config.env):null}async isUsernameRegistered(e){if("string"!=typeof e)throw new ge({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 yt(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 vt=function(e,t){t=t||De();const n=dt(this.config.env),{cloudPath:s,filePath:r,onUploadProgress:o,fileType:i="image"}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{const{data:{url:a,authorization:c,token:u,fileId:h,cosFileId:l},requestId:d}=e,f={key:s,signature:c,"x-cos-meta-fileid":l,success_action_status:"201","x-cos-security-token":u};n.upload({url:a,data:f,file:r,name:s,fileType:i,onUploadProgress:o}).then((e=>{201===e.statusCode?t(null,{fileID:h,requestId:d}):t(new ge({code:"STORAGE_REQUEST_FAIL",message:`STORAGE_REQUEST_FAIL: ${e.data}`}))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},Tt=function(e,t){t=t||De();const n=dt(this.config.env),{cloudPath:s}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},St=function({fileList:e},t){if(t=t||De(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(let s of e)if(!s||"string"!=typeof s)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};const n={fileid_list:e};return dt(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},At=function({fileList:e},t){t=t||De(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});let n=[];for(let r of e)"object"==typeof r?(r.hasOwnProperty("fileID")&&r.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),n.push({fileid:r.fileID,max_age:r.maxAge})):"string"==typeof r?n.push({fileid:r}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});const s={file_list:n};return dt(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},Pt=async function({fileID:e},t){const n=(await At.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==n.code)return t?t(n):new Promise((e=>{e(n)}));const s=dt(this.config.env);let r=n.download_url;if(r=encodeURI(r),!t)return s.download({url:r});t(await s.download({url:r}))},It=function({name:e,data:t,query:n,parse:s,search:r},o){const i=o||De();let a;try{a=t?JSON.stringify(t):""}catch(u){return Promise.reject(u)}if(!e)return Promise.reject(new ge({code:"PARAM_ERROR",message:"函数名不能为空"}));const c={inQuery:n,parse:s,search:r,function_name:e,request_data:a};return dt(this.config.env).send("functions.invokeFunction",c).then((e=>{if(e.code)i(null,e);else{let n=e.data.response_data;if(s)i(null,{result:n,requestId:e.requestId});else try{n=JSON.parse(e.data.response_data),i(null,{result:n,requestId:e.requestId})}catch(t){i(new ge({message:"response data must be json"}))}}return i.promise})).catch((e=>{i(e)})),i.promise},bt={timeout:15e3,persistence:"session"},Ot={};class Ct{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(je.adapter||(this.requestClient=new je.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...bt,...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 Ct(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||je.adapter.primaryStorage||bt.persistence;var n;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;He[t]=new We(e),Je[t]=new We({...e,persistence:"local"})}(this.config),n=this.config,lt[n.env]=new ht(n),this.authObj=new kt(this.config),this.authObj}on(e,t){return Ye.apply(this,[e,t])}off(e,t){return Ze.apply(this,[e,t])}callFunction(e,t){return It.apply(this,[e,t])}deleteFile(e,t){return St.apply(this,[e,t])}getTempFileURL(e,t){return At.apply(this,[e,t])}downloadFile(e,t){return Pt.apply(this,[e,t])}uploadFile(e,t){return vt.apply(this,[e,t])}getUploadMetadata(e,t){return Tt.apply(this,[e,t])}registerExtension(e){Ot[e.name]=e}async invokeExtension(e,t){const n=Ot[e];if(!n)throw new ge({message:`扩展${e} 必须先注册`});return await n.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:n}=function(e){const t=(n=e,"[object Array]"===Object.prototype.toString.call(n)?e:[e]);var n;for(const s of t){const{isMatch:e,genAdapter:t,runtime:n}=s;if(e())return{adapter:t(),runtime:n}}}(e)||{};t&&(je.adapter=t),n&&(je.runtime=n)}}var Et=new Ct;function xt(e,t,n){void 0===n&&(n={});var s=/\?/.test(t),r="";for(var o in n)""===r?!s&&(t+="?"):r+="&",r+=o+"="+encodeURIComponent(n[o]);return/^http(s)?:\/\//.test(t+=r)?t:""+e+t}class Lt{post(e){const{url:t,data:n,headers:s}=e;return new Promise(((e,r)=>{me.request({url:xt("https:",t),data:n,method:"POST",header:s,success(t){e(t)},fail(e){r(e)}})}))}upload(e){return new Promise(((t,n)=>{const{url:s,file:r,data:o,headers:i,fileType:a}=e,c=me.uploadFile({url:xt("https:",s),name:"file",formData:Object.assign({},o),filePath:r,fileType:a,header:i,success(e){const n={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&o.success_action_status&&(n.statusCode=parseInt(o.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 Rt={setItem(e,t){me.setStorageSync(e,t)},getItem:e=>me.getStorageSync(e),removeItem(e){me.removeStorageSync(e)},clear(){me.clearStorageSync()}};var Ut={genAdapter:function(){return{root:{},reqClass:Lt,localStorage:Rt,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};Et.useAdapters(Ut);const Nt=Et,Dt=Nt.init;Nt.init=function(e){e.env=e.spaceId;const t=Dt.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}=pe(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 Ft=Nt,qt=class extends Ee{getAccessToken(){return new Promise(((e,t)=>{const n="Anonymous_Access_token";this.setAccessToken(n),e(n)}))}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=Pe(n,this.config.clientSecret);const r=Ae();s["x-client-info"]=encodeURIComponent(JSON.stringify(r));const{token:o}=_e();return s["x-client-token"]=o,{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:JSON.parse(JSON.stringify(s))}}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:r,onUploadProgress:o}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:r,success(e){e&&e.statusCode<400?i(e):a(new ge({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new ge({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof o&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{o({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s}){if(!t)throw new ge({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});let r;return this.getOSSUploadOptionsFromPath({cloudPath:t}).then((t=>{const{url:o,formData:i,name:a}=t.result;r=t.result.fileUrl;const c={url:o,formData:i,name:a,filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},c,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({cloudPath:t}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:r}):s(new ge({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t)).then((e=>{if(e.success)return e.result;throw new ge({code:"DELETE_FILE_FAILED",message:"删除文件失败"})}))}getTempFileURL({fileList:e}={}){if(!Array.isArray(e)||0===e.length)throw new ge({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"});const t={method:"serverless.file.resource.getTempFileURL",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t)).then((e=>{if(e.success)return{fileList:e.result.fileList.map((e=>({fileID:e.fileID,tempFileURL:e.tempFileURL})))};throw new ge({code:"GET_TEMP_FILE_URL_FAILED",message:"获取临时文件链接失败"})}))}},Mt={init(e){const t=new qt(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}};function jt({data:e}){let t;t=Ae();const n=JSON.parse(JSON.stringify(e||{}));if(Object.assign(n,{clientInfo:t}),!n.uniIdToken){const{token:e}=_e();e&&(n.uniIdToken=e)}return n}const $t=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var Kt=/[\\^$.*+?()[\]{}|]/g,Bt=RegExp(Kt.source);function Wt(e,t,n){return e.replace(new RegExp((s=t)&&Bt.test(s)?s.replace(Kt,"\\$&"):s,"g"),n);var s}const Ht=2e4,Jt={code:20101,message:"Invalid client"};function zt(e){const{errSubject:t,subject:n,errCode:s,errMsg:r,code:o,message:i,cause:a}=e||{};return new ge({subject:t||n||"uni-secure-network",code:s||o||Ht,message:r||i,cause:a})}let Vt;function Qt({secretType:e}={}){return"request"===e||"response"===e||"both"===e}function Gt({functionName:e,result:t,logPvd:n}){}function Yt(e){const t=e.callFunction,n=function(n){const s=n.name;n.data=jt.call(e,{data:n.data});const r={aliyun:"aliyun",tencent:"tcb",tcb:"tcb"}[this.config.provider],o=Qt(n)||false;return t.call(this,n).then((e=>(e.errCode=0,!o&&Gt.call(this,{functionName:s,result:e,logPvd:r}),Promise.resolve(e))),(e=>(!o&&Gt.call(this,{functionName:s,result:e,logPvd:r}),e&&e.message&&(e.message=function({message:e="",extraInfo:t={},formatter:n=[]}={}){for(let s=0;sn.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 h=function(e,t){let n,s,r;for(let o=0;oe.trim())).indexOf(t)>-1&&(s=i):r=i:n=i}return n||s||r}(u,n);if(!h)return!1;if((c[h]||[]).find(((e={})=>e.appId===s&&(e.platform||"").toLowerCase()===i.toLowerCase())))return!0;throw console.error(`此应用[appId: ${s}, platform: ${i}]不在云端配置的允许访问的应用列表内,参考:https://uniapp.dcloud.net.cn/uniCloud/secure-network.html#verify-client`),zt(Jt)}({provider:s,spaceId:r,functionName:o})?new Vt({secretType:t.secretType,uniCloudIns:e}).wrapVerifyClientCallFunction(n.bind(e))(t):i(t),Object.defineProperty(a,"result",{get:()=>(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),a}}Vt=class{constructor(){throw zt({message:`Platform ${K} is not supported by secure network`})}};const Xt=Symbol("CLIENT_DB_INTERNAL");function Zt(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=Xt,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 en(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 tn=["db.Geo","db.command","command.aggregate"];function nn(e,t){return tn.indexOf(`${e}.${t}`)>-1}function sn(e){switch(R(e=ye(e))){case"array":return e.map((e=>sn(e)));case"object":return e._internalType===Xt||Object.keys(e).forEach((t=>{e[t]=sn(e[t])})),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:return e}}function rn(e){return e&&e.content&&e.content.$method}class on{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:sn(e.$param)})))}}getAction(){const e=this.toJSON().$db.find((e=>"action"===e.$method));return e&&e.$param&&e.$param[0]}getCommand(){return{$db:this.toJSON().$db.filter((e=>"action"!==e.$method))}}get isAggregate(){let e=this;for(;e;){const t=rn(e),n=rn(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"===rn(e))return!0;e=e.prevStage}return!1}get isAggregateCommand(){let e=this;for(;e;){const t=rn(e),n=rn(e.prevStage);if("aggregate"===t&&"command"===n)return!0;e=e.prevStage}return!1}getNextStageFn(e){const t=this;return function(){return an({$method:e,$param:sn(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();return s.$db.push({$method:e,$param:sn(t)}),this._database._callCloudFunction({action:n,command:s})}}function an(e,t,n){return Zt(new on(e,t,n),{get(e,t){let s="db";return e&&e.content&&(s=e.content.$method),nn(s,t)?an({$method:t},e,n):function(){return an({$method:t,$param:sn(Array.from(arguments))},e,n)}}})}function cn({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}]}}}}function un(e,t={}){return Zt(new e(t),{get:(e,t)=>nn("db",t)?an({$method:t},null,e):function(){return an({$method:t,$param:sn(Array.from(arguments))},null,e)}})}class hn extends class{constructor({uniClient:e={},isJQL:t=!1}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e._isDefault&&(this._dbCallBacks=J("_globalUniCloudDatabaseCallback")),t||(this.auth=en(this._authCallBacks)),this._isJQL=t,Object.assign(this,en(this._dbCallBacks)),this.env=Zt({},{get:(e,t)=>({$env:t})}),this.Geo=Zt({},{get:(e,t)=>cn({path:["Geo"],method:t})}),this.serverDate=cn({path:[],method:"serverDate"}),this.RegExp=cn({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})}}{_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;nY(X(i,"complete"),e))).then((()=>(r(null,e),he(te,{type:re,content:e}),Promise.reject(e))))}const c=Y(X(i,"invoke")),u=this._uniClient;return c.then((()=>u.callFunction({name:"DCloud-clientDB",type:"CLIENT_DB",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 r=0;r(console.warn(n),s)})}}return l=e,Y(X(i,"success"),l).then((()=>Y(X(i,"complete"),l))).then((()=>{r(l,null);const e=o._parseResult(l);return he(te,{type:re,content:e}),Promise.resolve(e)}));var l}),(e=>(/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化,请在web控制台保存一次schema以开启clientDB"),a(new ge({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId})))))}}const ln="token无效,跳转登录页面",dn="token过期,跳转登录页面",fn={TOKEN_INVALID_TOKEN_EXPIRED:dn,TOKEN_INVALID_INVALID_CLIENTID:ln,TOKEN_INVALID:ln,TOKEN_INVALID_WRONG_TOKEN:ln,TOKEN_INVALID_ANONYMOUS_USER:ln},pn={"uni-id-token-expired":dn,"uni-id-check-token-failed":ln,"uni-id-token-not-exist":ln,"uni-id-check-device-feature-failed":ln};function gn(e,t){let n="";return n=e?`${e}/${t}`:t,n.replace(/^\//,"")}function mn(e=[],t=""){const n=[],s=[];return e.forEach((e=>{!0===e.needLogin?n.push(gn(t,e.path)):!1===e.needLogin&&s.push(gn(t,e.path))})),{needLoginPage:n,notNeedLoginPage:s}}function yn(e){return e.split("?")[0].replace(/^\//,"")}function _n(){return function(e){let t=e&&e.$page&&e.$page.fullPath||"";return t?("/"!==t.charAt(0)&&(t="/"+t),t):t}(function(){const e=r();return e[e.length-1]}())}function wn(){return yn(_n())}function kn(e="",t={}){if(!e)return!1;if(!(t&&t.list&&t.list.length))return!1;const n=t.list,s=yn(e);return n.some((e=>e.pagePath===s))}const vn=!!t.uniIdRouter,{loginPage:Tn,routerNeedLogin:Sn,resToLogin:An,needLoginPage:Pn,notNeedLoginPage:In,loginPageInTabBar:bn}=function({pages:e=[],subPackages:n=[],uniIdRouter:s={},tabBar:r={}}=t){const{loginPage:o,needLogin:i=[],resToLogin:a=!0}=s,{needLoginPage:c,notNeedLoginPage:u}=mn(e),{needLoginPage:h,notNeedLoginPage:l}=function(e=[]){const t=[],n=[];return e.forEach((e=>{const{root:s,pages:r=[]}=e,{needLoginPage:o,notNeedLoginPage:i}=mn(r,s);t.push(...o),n.push(...i)})),{needLoginPage:t,notNeedLoginPage:n}}(n);return{loginPage:o,routerNeedLogin:i,resToLogin:a,needLoginPage:[...c,...h],notNeedLoginPage:[...u,...l],loginPageInTabBar:kn(o,r)}}();if(Pn.indexOf(Tn)>-1)throw new Error(`Login page [${Tn}] should not be "needLogin", please check your pages.json`);function On(e){const t=wn();if("/"===e.charAt(0))return e;const[n,s]=e.split("?"),r=n.replace(/^\//,"").split("/"),o=t.split("/");o.pop();for(let i=0;i-1?s+`&uniIdRedirectUrl=${encodeURIComponent(r)}`:s+`?uniIdRedirectUrl=${encodeURIComponent(r)}`:s);var s,r;bn?"navigateTo"!==e&&"redirectTo"!==e||(e="switchTab"):"switchTab"===e&&(e="navigateTo");const o={navigateTo:_,redirectTo:w,switchTab:k,reLaunch:v};setTimeout((()=>{o[e]({url:n})}))}function xn({url:e}={}){const t={abortLoginPageJump:!1,autoToLoginPage:!1},n=function(){const{token:e,tokenExpired:t}=_e();let n;if(e){if(t-1)&&(Pn.indexOf(t)>-1||Sn.some((t=>{return n=e,new RegExp(t).test(n);var n})))}(e)&&n){if(n.uniIdRedirectUrl=e,ae(ne).length>0)return setTimeout((()=>{he(ne,n)}),0),t.abortLoginPageJump=!0,t;t.autoToLoginPage=!0}return t}function Ln(){!function(){const e=_n(),{abortLoginPageJump:t,autoToLoginPage:n}=xn({url:e});t||n&&En({api:"redirectTo",redirect:e})}();const e=["navigateTo","redirectTo","reLaunch","switchTab"];for(let t=0;t{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 pn}(n);break;case"clientdb":s=function(e){if("object"!=typeof e)return!1;const{errCode:t}=e||{};return t in fn}(n)}s&&function(e={}){const t=ae(ne);fe().then((()=>{const n=_n();if(n&&Cn({redirect:n}))return t.length>0?he(ne,Object.assign({uniIdRedirectUrl:n},e)):void(Tn&&En({api:"navigateTo",redirect:n}))}))}(n)}))}function Un(e){var t;(t=e).onResponse=function(e){ce(te,e)},t.offResponse=function(e){ue(te,e)},function(e){e.onNeedLogin=function(e){ce(ne,e)},e.offNeedLogin=function(e){ue(ne,e)},vn&&(J("_globalUniCloudStatus").needLoginInit||(J("_globalUniCloudStatus").needLoginInit=!0,fe().then((()=>{Ln.call(e)})),An&&Rn.call(e)))}(e),function(e){e.onRefreshToken=function(e){ce(se,e)},e.offRefreshToken=function(e){ue(se,e)}}(e)}let Nn;const Dn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Fn=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function qn(){const e=_e().token||"",t=e.split(".");if(!e||3!==t.length)return{uid:null,role:[],permission:[],tokenExpired:0};let n;try{n=JSON.parse((s=t[1],decodeURIComponent(Nn(s).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))))}catch(r){throw new Error("获取当前用户信息出错,详细错误信息为:"+r.message)}var s;return n.tokenExpired=1e3*n.exp,delete n.exp,delete n.iat,n}Nn="function"!=typeof atob?function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!Fn.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="",o=0;o>16&255):64===s?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return r}:atob;var Mn=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(A((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r="chooseAndUploadFile:ok",o="chooseAndUploadFile:fail";function a(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 c(e,t,{onChooseFile:n,onUploadProgress:s}){return t.then((e=>{if(n){const t=n(e);if(void 0!==t)return Promise.resolve(t).then((t=>void 0===t?e:t))}return e})).then((t=>!1===t?{errMsg:r,tempFilePaths:[],tempFiles:[]}:function(e,t,n=5,s){(t=Object.assign({},t)).errMsg=r;const o=t.tempFiles,i=o.length;let a=0;return new Promise((r=>{for(;a=i)return void(!o.find((e=>!e.url&&!e.errMsg))&&r(t));const u=o[n];e.uploadFile({filePath:u.path,cloudPath:u.cloudPath,fileType:u.fileType,onUploadProgress(e){e.index=n,e.tempFile=u,e.tempFilePath=u.path,s&&s(e)}}).then((e=>{u.url=e.fileID,n{u.errMsg=e.errMsg||e.message,n{n({count:t,sizeType:s,sourceType:r,extension:i,success(t){e(a(t,"image"))},fail(e){c({errMsg:e.errMsg.replace("chooseImage:fail",o)})}})}))}(t),t):"video"===t.type?c(e,function(e){const{camera:t,compressed:n,maxDuration:r,sourceType:i=["album","camera"],extension:c}=e;return new Promise(((e,u)=>{s({camera:t,compressed:n,maxDuration:r,sourceType:i,extension:c,success(t){const{tempFilePath:n,duration:s,size:r,height:o,width:i}=t;e(a({errMsg:"chooseVideo:ok",tempFilePaths:[n],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:n,size:r,type:t.tempFile&&t.tempFile.type||"",width:i,height:o,duration:s,fileType:"video",cloudPath:""}]},"video"))},fail(e){u({errMsg:e.errMsg.replace("chooseVideo:fail",o)})}})}))}(t),t):c(e,function(e){const{count:t,extension:n}=e;return new Promise(((e,s)=>{let r=i;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(r=wx.chooseMessageFile),"function"!=typeof r)return s({errMsg:o+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});r({type:"all",count:t,extension:n,success(t){e(a(t))},fail(e){s({errMsg:e.errMsg.replace("chooseFile:fail",o)})}})}))}(t),t)}}})));function jn(e){return{props:{localdata:{type:Array,default:()=>[]},options:{type:[Object,Array],default:()=>({})},spaceInfo:{type:Object,default:()=>({})},collection:{type:[String,Array],default:""},action:{type:String,default:""},field:{type:String,default:""},orderby:{type:String,default:""},where:{type:[String,Object],default:""},pageData:{type:String,default:"add"},pageCurrent:{type:Number,default:1},pageSize:{type:Number,default:20},getcount:{type:[Boolean,String],default:!1},gettree:{type:[Boolean,String],default:!1},gettreepath:{type:[Boolean,String],default:!1},startwith:{type:String,default:""},limitlevel:{type:Number,default:10},groupby:{type:String,default:""},groupField:{type:String,default:""},distinct:{type:[Boolean,String],default:!1},foreignKey:{type:String,default:""},loadtime:{type:String,default:"auto"},manual:{type:Boolean,default:!1}},data:()=>({mixinDatacomLoading:!1,mixinDatacomHasMore:!1,mixinDatacomResData:[],mixinDatacomErrorMessage:"",mixinDatacomPage:{}}),created(){this.mixinDatacomPage={current:this.pageCurrent,size:this.pageSize,count:0},this.$watch((()=>{var e=[];return["pageCurrent","pageSize","localdata","collection","action","field","orderby","where","getont","getcount","gettree","groupby","groupField","distinct"].forEach((t=>{e.push(this[t])})),e}),((e,t)=>{if("manual"===this.loadtime)return;let n=!1;const s=[];for(let r=2;r{this.mixinDatacomLoading=!1;const{data:s,count:r}=n.result;this.getcount&&(this.mixinDatacomPage.count=r),this.mixinDatacomHasMore=s.length{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,n&&n(e)})))},mixinDatacomGet(t={}){let n=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 o=t.where||this.where;o&&Object.keys(o).length&&(n=n.where(o));const i=t.field||this.field;i&&(n=n.field(i));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 h=t.orderby||this.orderby;h&&(n=n.orderBy(h));const l=void 0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,d=void 0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,f=void 0!==t.getcount?t.getcount:this.getcount,p=void 0!==t.gettree?t.gettree:this.gettree,g=void 0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:f},y={limitLevel:void 0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void 0!==t.startwith?t.startwith:this.startwith};return p&&(m.getTree=y),g&&(m.getTreePath=y),n=n.skip(d*(l-1)).limit(d).get(m),n}}}}function $n(e){return J("_globalUniCloudSecureNetworkCache__{spaceId}".replace("{spaceId}",e.config.spaceId))}async function Kn({openid:e,callLoginByWeixin:t=!1}={}){throw $n(this),new Error(`[SecureNetwork] API \`initSecureNetworkByWeixin\` is not supported on platform \`${K}\``)}async function Bn(e){const t=$n(this);return t.initPromise||(t.initPromise=Kn.call(this,e)),t.initPromise}const Wn={tcb:Ft,tencent:Ft,aliyun:xe,private:Mt};let Hn=new class{init(e){let t={};const n=Wn[e.provider];if(!n)throw new Error("未提供正确的provider参数");var s;return t=n.init(e),function(e){e._initPromiseHub||(e._initPromiseHub=new M({createPromise:function(){let t=Promise.resolve();t=new Promise((e=>{setTimeout((()=>{e()}),1)}));const n=e.auth();return t.then((()=>n.getLoginState())).then((e=>e?Promise.resolve():n.signInAnonymously()))}}))}(t),Yt(t),function(e){const t=e.uploadFile;e.uploadFile=function(e){return t.call(this,e)}}(t),(s=t).database=function(e){if(e&&Object.keys(e).length>0)return s.init(e).database();if(this._database)return this._database;const t=un(hn,{uniClient:s});return this._database=t,t},s.databaseForJQL=function(e){if(e&&Object.keys(e).length>0)return s.init(e).databaseForJQL();if(this._databaseForJQL)return this._databaseForJQL;const t=un(hn,{uniClient:s,isJQL:!0});return this._databaseForJQL=t,t},function(e){e.getCurrentUserInfo=qn,e.chooseAndUploadFile=Mn.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return jn(e)}}),e.importObject=function(t){return function(n,s={}){s=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}},s);const{customUI:r,loadingOptions:o,errorOptions:i,parseSystemError:l}=s,d=!r;return new Proxy({},{get:(r,f)=>function({fn:e,interceptorName:t,getCallbackArgs:n}={}){return async function(...s){const r=n?n({params:s}):{};let o,i;try{return await Y(X(t,"invoke"),{...r}),o=await e(...s),await Y(X(t,"success"),{...r,result:o}),o}catch(a){throw i=a,await Y(X(t,"fail"),{...r,error:i}),i}finally{await Y(X(t,"complete"),i?{...r,error:i}:{...r,result:o})}}}({fn:async function r(...p){let g;d&&a({title:o.title,mask:o.mask});const m={name:n,type:"OBJECT",data:{method:f,params:p}};"object"==typeof s.secretMethods&&function(e,t){const n=t.data.method,s=e.secretMethods||{},r=s[n]||s["*"];r&&(t.secretType=r)}(s,m);let y=!1;try{g=await t.callFunction(m)}catch(e){y=!0,g={result:new ge(e)}}const{errSubject:_,errCode:w,errMsg:k,newToken:v}=g.result||{};if(d&&c(),v&&v.token&&v.tokenExpired&&(we(v),he(se,{...v})),w){let e=k;if(y&&l&&(e=(await l({objectName:n,methodName:f,params:p,errSubject:_,errCode:w,errMsg:k})).errMsg||k),d)if("toast"===i.type)u({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(((o,i)=>{h({title:e,content:t,showCancel:n,cancelText:s,confirmText:r,success(e){o(e)},fail(){o({confirm:!1,cancel:!0})}})}))}({title:"提示",content:e,showCancel:i.retry,cancelText:"取消",confirmText:i.retry?"重试":"确定"});if(i.retry&&t)return r(...p)}}const t=new ge({subject:_,code:w,message:k,requestId:g.requestId});throw t.detail=g.result,he(te,{type:ie,content:t}),t}return he(te,{type:ie,content:g.result}),g.result},interceptorName:"callObject",getCallbackArgs:function({params:e}={}){return{objectName:n,methodName:f,params:e}}})})}}(e),e.initSecureNetworkByWeixin=function(e){return function({openid:t,callLoginByWeixin:n=!1}={}){return Bn.call(e,{openid:t,callLoginByWeixin:n})}}(e)}(t),["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach((e=>{if(!t[e])return;const n=t[e];var s,r;t[e]=function(){return n.apply(t,Array.from(arguments))},t[e]=(s=t[e],r=e,function(e){let t=!1;if("callFunction"===r){const n=e&&e.type||E;t=n!==E}const n="callFunction"===r&&!t,o=this._initPromiseHub.exec();e=e||{};const{success:i,fail:a,complete:c}=pe(e),u=o.then((()=>t?Promise.resolve():Y(X(r,"invoke"),e))).then((()=>s.call(this,e))).then((e=>t?Promise.resolve(e):Y(X(r,"success"),e).then((()=>Y(X(r,"complete"),e))).then((()=>(n&&he(te,{type:oe,content:e}),Promise.resolve(e))))),(e=>t?Promise.reject(e):Y(X(r,"fail"),e).then((()=>Y(X(r,"complete"),e))).then((()=>(he(te,{type:oe,content:e}),Promise.reject(e))))));if(!(i||a||c))return u;u.then((e=>{i&&i(e),c&&c(e),n&&he(te,{type:oe,content:e})}),(e=>{a&&a(e),c&&c(e),n&&he(te,{type:oe,content:e})}))}).bind(t)})),t.init=this.init,t}};(()=>{const e=B;let t={};if(e&&1===e.length)t=e[0],Hn=Hn.init(t),Hn._isDefault=!0;else{const t=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","database","getCurrentUSerInfo","importObject"];let n;n=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":"uni-app cli项目内使用uniCloud需要使用HBuilderX的运行菜单运行项目,且需要在uniCloud目录关联服务空间",t.forEach((e=>{Hn[e]=function(){return console.error(n),Promise.reject(new ge({code:"SYS_ERR",message:n}))}}))}Object.assign(Hn,{get mixinDatacom(){return jn(Hn)}}),Un(Hn),Hn.addInterceptor=Q,Hn.removeInterceptor=G,Hn.interceptObject=Z})();var Jn=Hn;export{Jn as L};