uni-data-select.384665cf.js 82.5 KB
import{a1 as e,a2 as t,a3 as n,a4 as s,a5 as r,a6 as i,T as o,S as a,D as c,a7 as u,a8 as l,a9 as h,aa as d,ab as f,x as p,q as g,ac as m,ad as y,ae as _,a0 as w,af as v,G as k,ag as T,ah as b,ai as S,aj as P,ak as I,Q as A,o as x,c as C,w as O,e as R,t as E,h as D,f as L,j as U,g as N,K as F,F as q,C as M,z as j,k as B,W as $}from"./index-f4fdb118.js";import{_ as K}from"./_plugin-vue_export-helper.1b428a4d.js";const W={easycom:{autoscan:!0,custom:{"^n-(.*)":"@/ty/components/n-$1/n-$1.vue","^nu-(.*)":"@/ty/ui/nu-$1/nu-$1.vue"}},pages:[{path:"pages/index/index",aliasPath:"/",style:{navigationBarTitleText:"首页",enablePullDownRefresh:!1},meta:{auth:!1,sync:!0,title:"首页",group:"模板"}},{path:"pages/me/index",style:{navigationBarTitleText:"个人中心",enablePullDownRefresh:!1},meta:{auth:!0,sync:!0,title:"我的",group:"模板"}},{path:"pages/myOrder/myOrder",style:{navigationBarTitleText:"我的订单",enablePullDownRefresh:!1,onReachBottomDistance:20}},{path:"pages/activity/activity",style:{navigationBarTitleText:"举办活动",enablePullDownRefresh:!1},meta:{auth:!1,sync:!0,title:"举办活动"}},{path:"pages/me/apply/apply",style:{navigationBarTitleText:"申请代理人",enablePullDownRefresh:!1}},{path:"pages/orderDetail/orderDetail",style:{navigationBarTitleText:"订单详情",enablePullDownRefresh:!0}},{path:"pages/achievement/achievement",style:{navigationBarTitleText:"个人业绩",enablePullDownRefresh:!1}},{path:"pages/achievement/searchachievement",style:{navigationBarTitleText:"个人业绩",enablePullDownRefresh:!1}},{path:"pages/map/map",style:{navigationBarTitleText:"地图",enablePullDownRefresh:!1}},{path:"pages/myGift/myGift",style:{navigationBarTitleText:"我的礼品",enablePullDownRefresh:!0}},{path:"pages/useCoupon/useCoupon",style:{navigationBarTitleText:"用卷",enablePullDownRefresh:!1}},{path:"pages/invite/invite",style:{navigationBarTitleText:"邀请有礼",enablePullDownRefresh:!1}},{path:"pages/verification/verification",style:{navigationBarTitleText:"扫码核销",enablePullDownRefresh:!1}},{path:"pages/me/envelope/envelope",style:{navigationBarTitleText:"我的红包",enablePullDownRefresh:!1}},{path:"pages/me/order/order",style:{navigationBarTitleText:"订单管理",enablePullDownRefresh:!1}},{path:"pages/me/order/orderdetail",style:{navigationBarTitleText:"订单管理",enablePullDownRefresh:!1}},{path:"pages/verification/allverification",style:{navigationBarTitleText:"核销记录",enablePullDownRefresh:!1}},{path:"pages/me/user/user",style:{navigationBarTitleText:"用户角色",enablePullDownRefresh:!1}},{path:"pages/businesscenter/businesscenter",style:{navigationBarTitleText:"商家中心",enablePullDownRefresh:!1}}],subPackages:[{root:"pages/login",pages:[{path:"login",aliasPath:"/",style:{navigationBarTitleText:"登录",navigationBarBackgroundColor:"#FFFFFF"}}]}],globalStyle:{navigationBarTextStyle:"black",navigationBarTitleText:"通用模板",navigationBarBackgroundColor:"#F8F8F8",backgroundColor:"#F8F8F8"},tabBar:{borderStyle:"white",selectedColor:"#1F78FF",backgroundColor:"#FFFFFF",color:"#999999",list:[{pagePath:"pages/index/index",iconPath:"static/images/tabbar/flowerg.png",selectedIconPath:"static/images/tabbar/flower.png",text:"精选活动"},{pagePath:"pages/myOrder/myOrder",iconPath:"static/images/tabbar/order.png",selectedIconPath:"static/images/tabbar/orderb.png",text:"我的订单"},{pagePath:"pages/me/index",iconPath:"static/images/tabbar/user.png",selectedIconPath:"static/images/tabbar/userb.png",text:"个人中心"}]}};function J(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 z=J((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,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,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){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(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},h=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 h=s.splice(0,c);n.sigBytes-=u}return new o.init(h,u)},clone:function(){var e=i.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});r.Hasher=h.extend({cfg:i.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.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 d.HMAC.init(e,n).finalize(t)}}});var d=s.algo={};return s}(Math),n)})),H=z,V=(J((function(e,t){var n;e.exports=(n=H,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],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],v=e[t+9],k=e[t+10],T=e[t+11],b=e[t+12],S=e[t+13],P=e[t+14],I=e[t+15],A=i[0],x=i[1],C=i[2],O=i[3];A=u(A,x,C,O,o,7,a[0]),O=u(O,A,x,C,c,12,a[1]),C=u(C,O,A,x,f,17,a[2]),x=u(x,C,O,A,p,22,a[3]),A=u(A,x,C,O,g,7,a[4]),O=u(O,A,x,C,m,12,a[5]),C=u(C,O,A,x,y,17,a[6]),x=u(x,C,O,A,_,22,a[7]),A=u(A,x,C,O,w,7,a[8]),O=u(O,A,x,C,v,12,a[9]),C=u(C,O,A,x,k,17,a[10]),x=u(x,C,O,A,T,22,a[11]),A=u(A,x,C,O,b,7,a[12]),O=u(O,A,x,C,S,12,a[13]),C=u(C,O,A,x,P,17,a[14]),A=l(A,x=u(x,C,O,A,I,22,a[15]),C,O,c,5,a[16]),O=l(O,A,x,C,y,9,a[17]),C=l(C,O,A,x,T,14,a[18]),x=l(x,C,O,A,o,20,a[19]),A=l(A,x,C,O,m,5,a[20]),O=l(O,A,x,C,k,9,a[21]),C=l(C,O,A,x,I,14,a[22]),x=l(x,C,O,A,g,20,a[23]),A=l(A,x,C,O,v,5,a[24]),O=l(O,A,x,C,P,9,a[25]),C=l(C,O,A,x,p,14,a[26]),x=l(x,C,O,A,w,20,a[27]),A=l(A,x,C,O,S,5,a[28]),O=l(O,A,x,C,f,9,a[29]),C=l(C,O,A,x,_,14,a[30]),A=h(A,x=l(x,C,O,A,b,20,a[31]),C,O,m,4,a[32]),O=h(O,A,x,C,w,11,a[33]),C=h(C,O,A,x,T,16,a[34]),x=h(x,C,O,A,P,23,a[35]),A=h(A,x,C,O,c,4,a[36]),O=h(O,A,x,C,g,11,a[37]),C=h(C,O,A,x,_,16,a[38]),x=h(x,C,O,A,k,23,a[39]),A=h(A,x,C,O,S,4,a[40]),O=h(O,A,x,C,o,11,a[41]),C=h(C,O,A,x,p,16,a[42]),x=h(x,C,O,A,y,23,a[43]),A=h(A,x,C,O,v,4,a[44]),O=h(O,A,x,C,b,11,a[45]),C=h(C,O,A,x,I,16,a[46]),A=d(A,x=h(x,C,O,A,f,23,a[47]),C,O,o,6,a[48]),O=d(O,A,x,C,_,10,a[49]),C=d(C,O,A,x,P,15,a[50]),x=d(x,C,O,A,m,21,a[51]),A=d(A,x,C,O,b,6,a[52]),O=d(O,A,x,C,p,10,a[53]),C=d(C,O,A,x,k,15,a[54]),x=d(x,C,O,A,c,21,a[55]),A=d(A,x,C,O,w,6,a[56]),O=d(O,A,x,C,I,10,a[57]),C=d(C,O,A,x,y,15,a[58]),x=d(x,C,O,A,S,21,a[59]),A=d(A,x,C,O,g,6,a[60]),O=d(O,A,x,C,T,10,a[61]),C=d(C,O,A,x,f,15,a[62]),x=d(x,C,O,A,v,21,a[63]),i[0]=i[0]+A|0,i[1]=i[1]+x|0,i[2]=i[2]+C|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 h(e,t,n,s,r,i,o){var a=e+(t^n^s)+r+o;return(a<<i|a>>>32-i)+t}function d(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)})),J((function(e,t){var n,s,r;e.exports=(s=(n=H).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 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=s,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))}})))})),J((function(e,t){e.exports=H.HmacMD5}))),Q=J((function(e,t){e.exports=H.enc.Utf8})),G=J((function(e,t){var n,s,r;e.exports=(r=(s=n=H).lib.WordArray,s.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,s=this._reverseMap;if(!s){s=this._reverseMap=[];for(var i=0;i<n.length;i++)s[n.charCodeAt(i)]=i}var o=n.charAt(64);if(o){var a=e.indexOf(o);-1!==a&&(t=a)}return function(e,t,n){for(var s=[],i=0,o=0;o<t;o++)if(o%4){var a=n[e.charCodeAt(o-1)]<<o%4*2,c=n[e.charCodeAt(o)]>>>6-o%4*2;s[i>>>2]|=(a|c)<<24-i%4*8,i++}return r.create(s,i)}(e,t,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},n.enc.Base64)}));const Y="FUNCTION",X="pending",Z="rejected";function ee(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function te(e){return"object"===ee(e)}function ne(e){return"function"==typeof e}function se(e){return function(){try{return e.apply(e,arguments)}catch(t){console.error(t)}}}const re="REJECTED",ie="NOT_PENDING";class oe{constructor({createPromise:e,retryRule:t=re}={}){this.createPromise=e,this.status=null,this.promise=null,this.retryRule=t}get needRetry(){if(!this.status)return!0;switch(this.retryRule){case re:return this.status===Z;case ie: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=Z,Promise.reject(e)))),this.promise):this.promise}}function ae(e){return e&&"string"==typeof e?JSON.parse(e):e}const ce=ae([]);ae("");const ue=ae("[]")||[];let le="";try{le="__UNI__BE10900"}catch(et){}let he={};function de(e,t={}){var n,s;return n=he,s=e,Object.prototype.hasOwnProperty.call(n,s)||(he[e]=t),he[e]}const fe=["invoke","success","fail","complete"],pe=de("_globalUniCloudInterceptor");function ge(e,t){pe[e]||(pe[e]={}),te(t)&&Object.keys(t).forEach((n=>{fe.indexOf(n)>-1&&function(e,t,n){let s=pe[e][t];s||(s=pe[e][t]=[]),-1===s.indexOf(n)&&ne(n)&&s.push(n)}(e,n,t[n])}))}function me(e,t){pe[e]||(pe[e]={}),te(t)?Object.keys(t).forEach((n=>{fe.indexOf(n)>-1&&function(e,t,n){const s=pe[e][t];if(!s)return;const r=s.indexOf(n);r>-1&&s.splice(r,1)}(e,n,t[n])})):delete pe[e]}function ye(e,t){return e&&0!==e.length?e.reduce(((e,n)=>e.then((()=>n(t)))),Promise.resolve()):Promise.resolve()}function _e(e,t){return pe[e]&&pe[e][t]||[]}function we(e){ge("callObject",e)}const ve=de("_globalUniCloudListener"),ke="response",Te="needLogin",be="refreshToken",Se="clientdb",Pe="cloudfunction",Ie="cloudobject";function Ae(e){return ve[e]||(ve[e]=[]),ve[e]}function xe(e,t){const n=Ae(e);n.includes(t)||n.push(t)}function Ce(e,t){const n=Ae(e),s=n.indexOf(t);-1!==s&&n.splice(s,1)}function Oe(e,t){const n=Ae(e);for(let s=0;s<n.length;s++)(0,n[s])(t)}let Re,Ee=!1;function De(){return Re||(Re=new Promise((e=>{Ee&&e(),function t(){if("function"==typeof s){const t=s();t&&t[0]&&(Ee=!0,e())}Ee||setTimeout((()=>{t()}),30)}()})),Re)}function Le(e){const t={};for(const n in e){const s=e[n];ne(s)&&(t[n]=se(s))}return t}class Ue 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 Ne={request:e=>d(e),uploadFile:e=>f(e),setStorageSync:(e,t)=>p(e,t),getStorageSync:e=>g(e),removeStorageSync:e=>m(e),clearStorageSync:()=>y()};function Fe(e){return e&&Fe(e.__v_raw)||e}function qe(){return{token:Ne.getStorageSync("uni_id_token")||Ne.getStorageSync("uniIdToken"),tokenExpired:Ne.getStorageSync("uni_id_token_expired")}}function Me({token:e,tokenExpired:t}={}){e&&Ne.setStorageSync("uni_id_token",e),t&&Ne.setStorageSync("uni_id_token_expired",t)}let je,Be;function $e(){return je||(je=_()),je}function Ke(){let e,t;try{if(I){if(I.toString().indexOf("not yet implemented")>-1)return;const{scene:n,channel:s}=I();e=s,t=n}}catch(n){}return{channel:e,scene:t}}function We(){const e=P&&P()||"en";if(Be)return{...Be,locale:e,LOCALE:e};const t=$e(),{deviceId:n,osName:s,uniPlatform:r,appId:i}=t,o=["pixelRatio","brand","model","system","language","version","platform","host","SDKVersion","swanNativeVersion","app","AppPlatform","fontSizeSetting"];for(let a=0;a<o.length;a++)delete t[o[a]];return Be={PLATFORM:r,OS:s,APPID:i,DEVICEID:n,...Ke(),...t},{...Be,locale:e,LOCALE:e}}var Je=function(e,t){let n="";return Object.keys(e).sort().forEach((function(t){e[t]&&(n=n+"&"+t+"="+e[t])})),n=n.slice(1),V(n,t).toString()},ze=function(e,t){return new Promise(((n,s)=>{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 Ue({code:"SYS_ERR",message:e.errMsg||"request:fail",requestId:t}));const r=e.data;if(r.error)return s(new Ue({code:r.error.code,message:r.error.message,requestId:t}));r.result=r.data,r.requestId=t,delete r.data,n(r)}}))}))},He=function(e){return G.stringify(Q.parse(e))},Ve={"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"};const{t:Qe}=e({"zh-Hans":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},"zh-Hant":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},en:Ve,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:Ve},"zh-Hans");var Ge=class{constructor(e){["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(Qe("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=Ne,this._getAccessTokenPromiseHub=new oe({createPromise:()=>this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>{if(!e.result||!e.result.accessToken)throw new Ue({code:"AUTH_FAILED",message:"获取accessToken失败"});this.setAccessToken(e.result.accessToken)})),retryRule:ie})}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return ze(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"]=Je(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"]=Je(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: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 Ue({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new Ue({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",onUploadProgress:s,config:r}){if("string"!==ee(t))throw new Ue({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new Ue({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new Ue({code:"INVALID_PARAM",message:"cloudPath不合法"});const i=r&&r.envType||this.config.envType,o=(await this.getOSSUploadOptionsFromPath({env:i,filename:t})).result,a="https://"+o.cdnDomain+"/"+o.ossPath,{securityToken:c,accessKeyId:u,signature:l,host:h,ossPath:d,id:f,policy:p,ossCallbackUrl:g}=o,m={"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:u,Signature:l,host:h,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=He(e)}const y={url:"https://"+o.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 Ue({code:"UPLOAD_FAILED",message:"文件上传失败"})}getTempFileURL({fileList:e}={}){return new Promise(((t,n)=>{Array.isArray(e)&&0!==e.length||n(new Ue({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 Ue({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}}},Ye={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 Xe="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var Ze,et;(et=Ze||(Ze={})).local="local",et.none="none",et.session="session";var tt=function(){};const nt=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new Ue({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 st(e){return void 0===e}function rt(e){return"[object Null]"===Object.prototype.toString.call(e)}var it;!function(e){e.WEB="web",e.WX_MP="wx_mp"}(it||(it={}));const ot={adapter:null,runtime:void 0},at=["anonymousUuidKey"];class ct extends tt{constructor(){super(),ot.adapter.root.tcbObject||(ot.adapter.root.tcbObject={})}setItem(e,t){ot.adapter.root.tcbObject[e]=t}getItem(e){return ot.adapter.root.tcbObject[e]}removeItem(e){delete ot.adapter.root.tcbObject[e]}clear(){delete ot.adapter.root.tcbObject}}function ut(e,t){switch(e){case"local":return t.localStorage||new ct;case"none":return new ct;default:return t.sessionStorage||new ct}}class lt{constructor(e){if(!this._storage){this._persistence=ot.adapter.primaryStorage||e.persistence,this._storage=ut(this._persistence,ot.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=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s,anonymousUuidKey:r,loginTypeKey:i,userInfoKey:o}}}updatePersistence(e){if(e===this._persistence)return;const t="local"===this._persistence;this._persistence=e;const n=ut(e,ot.adapter);for(const s in this.keys){const e=this.keys[s];if(t&&at.includes(s))continue;const r=this._storage.getItem(e);st(r)||rt(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(i){throw i}}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 ht={},dt={};function ft(e){return ht[e]}class pt{constructor(e,t){this.data=t||null,this.name=e}}class gt extends pt{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const mt=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 gt)return console.error(e.error),this;const n="string"==typeof e?new pt(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 yt(e,t){mt.on(e,t)}function _t(e,t={}){mt.fire(e,t)}function wt(e,t){mt.off(e,t)}const vt="loginStateChanged",kt="loginStateExpire",Tt="loginTypeChanged",bt="anonymousConverted",St="refreshAccessToken";var Pt;!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"}(Pt||(Pt={}));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 xt(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 t in r)o.append(t,r[t])})(),t.headers={...t.headers||{},...i},s.call(e,t)}}function Ct(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...At,"x-seqid":e}}}class Ot{constructor(e={}){var t;this.config=e,this._reqClass=new ot.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=ft(this.config.env),this._localCache=(t=this.config.env,dt[t]),xt(this._reqClass,"post",[Ct]),xt(this._reqClass,"upload",[Ct]),xt(this._reqClass,"download",[Ct])}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 i=this._cache.getStore(n);if(!i)throw new Ue({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)===Pt.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()}_t(kt),this._cache.removeStore(n)}throw new Ue({code:a.data.code,message:`刷新access token失败:${a.data.code}`})}if(a.data.access_token)return _t(St),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 Ue({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};if(-1===It.indexOf(e)){const{refreshTokenKey:e}=this._cache.keys;this._cache.getStore(e)&&(i.access_token=(await this.getAccessToken()).accessToken)}let o;if("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.onUploadProgress&&(a.onUploadProgress=n.onUploadProgress);const c=this._localCache.getStore(s);c&&(a.headers["X-TCB-Trace"]=c);const{parse:u,inQuery:l,search:h}=t;let d={env:this.config.env};u&&(d.parse=!0),l&&(d={...l,...d});let f=function(e,t,n={}){const s=/\?/.test(t);let r="";for(let i in n)""===r?!s&&(t+="?"):r+="&",r+=`${i}=${encodeURIComponent(n[i])}`;return/^http(s)?\:\/\//.test(t+=r)?t:`${e}${t}`}(Xe,"//tcb-api.tencentcloudapi.com/web",d);h&&(f+=h);const p=await this.post({url:f,data:o,...a}),g=p.header&&p.header["x-tcb-trace"];if(g&&this._localCache.setStore(s,g),200!==Number(p.status)&&200!==Number(p.statusCode)||!p.data)throw new Ue({code:"NETWORK_ERROR",message:"network request error"});return p}async send(e,t={}){const n=await this.request(e,t,{onUploadProgress:t.onUploadProgress});if("ACCESS_TOKEN_EXPIRED"===n.data.code&&-1===It.indexOf(e)){await this.refreshAccessToken();const n=await this.request(e,t,{onUploadProgress:t.onUploadProgress});if(n.data.code)throw new Ue({code:n.data.code,message:n.data.message});return n.data}if(n.data.code)throw new Ue({code:n.data.code,message:n.data.message});return n.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 Rt={};function Et(e){return Rt[e]}class Dt{constructor(e){this.config=e,this._cache=ft(e.env),this._request=Et(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 Lt{constructor(e){if(!e)throw new Ue({code:"PARAM_ERROR",message:"envId is not defined"});this._envId=e,this._cache=ft(this._envId),this._request=Et(this._envId),this.setUserInfo()}linkWithTicket(e){if("string"!=typeof e)throw new Ue({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 Ue({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{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 Ut{constructor(e){if(!e)throw new Ue({code:"PARAM_ERROR",message:"envId is not defined"});this._cache=ft(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 Lt(e)}get isAnonymousAuth(){return this.loginType===Pt.ANONYMOUS}get isCustomAuth(){return this.loginType===Pt.CUSTOM}get isWeixinAuth(){return this.loginType===Pt.WECHAT||this.loginType===Pt.WECHAT_OPEN||this.loginType===Pt.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class Nt extends Dt{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(),_t(vt),_t(Tt,{env:this.config.env,loginType:Pt.ANONYMOUS,persistence:"local"});const e=new Ut(this.config.env);return await e.user.refresh(),e}throw new Ue({message:"匿名登录失败"})}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(),_t(bt,{env:this.config.env}),_t(Tt,{loginType:Pt.CUSTOM,persistence:"local"}),{credential:{refreshToken:i.refresh_token}};throw new Ue({message:"匿名转化失败"})}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(n,Pt.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class Ft extends Dt{async signIn(e){if("string"!=typeof e)throw new Ue({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(),_t(vt),_t(Tt,{env:this.config.env,loginType:Pt.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new Ut(this.config.env);throw new Ue({message:"自定义登录失败"})}}class qt extends Dt{async signIn(e,t){if("string"!=typeof e)throw new Ue({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(),_t(vt),_t(Tt,{env:this.config.env,loginType:Pt.EMAIL,persistence:this.config.persistence}),new Ut(this.config.env);throw s.code?new Ue({code:s.code,message:`邮箱登录失败: ${s.message}`}):new Ue({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 Mt extends Dt{async signIn(e,t){if("string"!=typeof e)throw new Ue({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:Pt.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(),_t(vt),_t(Tt,{env:this.config.env,loginType:Pt.USERNAME,persistence:this.config.persistence}),new Ut(this.config.env);throw s.code?new Ue({code:s.code,message:`用户名密码登录失败: ${s.message}`}):new Ue({message:"用户名密码登录失败"})}}class jt{constructor(e){this.config=e,this._cache=ft(e.env),this._request=Et(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),yt(Tt,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 Nt(this.config)}customAuthProvider(){return new Ft(this.config)}emailAuthProvider(){return new qt(this.config)}usernameAuthProvider(){return new Mt(this.config)}async signInAnonymously(){return new Nt(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new qt(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new Mt(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){return this._anonymousAuthProvider||(this._anonymousAuthProvider=new Nt(this.config)),yt(bt,this._onAnonymousConverted),await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===Pt.ANONYMOUS)throw new Ue({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),_t(vt),_t(Tt,{env:this.config.env,loginType:Pt.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){yt(vt,(()=>{const t=this.hasLoginState();e.call(this,t)}));const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){yt(kt,e.bind(this))}onAccessTokenRefreshed(e){yt(St,e.bind(this))}onAnonymousConverted(e){yt(bt,e.bind(this))}onLoginTypeChanged(e){yt(Tt,(()=>{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 Ut(this.config.env):null}async isUsernameRegistered(e){if("string"!=typeof e)throw new Ue({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 Ft(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 Bt=function(e,t){t=t||nt();const n=Et(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:h},requestId:d}=e,f={key:s,signature:c,"x-cos-meta-fileid":h,success_action_status:"201","x-cos-security-token":u};n.upload({url:a,data:f,file:r,name:s,fileType:o,onUploadProgress:i}).then((e=>{201===e.statusCode?t(null,{fileID:l,requestId:d}):t(new Ue({code:"STORAGE_REQUEST_FAIL",message:`STORAGE_REQUEST_FAIL: ${e.data}`}))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},$t=function(e,t){t=t||nt();const n=Et(this.config.env),{cloudPath:s}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},Kt=function({fileList:e},t){if(t=t||nt(),!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 Et(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},Wt=function({fileList:e},t){t=t||nt(),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 Et(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},Jt=async function({fileID:e},t){const n=(await Wt.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==n.code)return t?t(n):new Promise((e=>{e(n)}));const s=Et(this.config.env);let r=n.download_url;if(r=encodeURI(r),!t)return s.download({url:r});t(await s.download({url:r}))},zt=function({name:e,data:t,query:n,parse:s,search:r},i){const o=i||nt();let a;try{a=t?JSON.stringify(t):""}catch(u){return Promise.reject(u)}if(!e)return Promise.reject(new Ue({code:"PARAM_ERROR",message:"函数名不能为空"}));const c={inQuery:n,parse:s,search:r,function_name:e,request_data:a};return Et(this.config.env).send("functions.invokeFunction",c).then((e=>{if(e.code)o(null,e);else{let n=e.data.response_data;if(s)o(null,{result:n,requestId:e.requestId});else try{n=JSON.parse(e.data.response_data),o(null,{result:n,requestId:e.requestId})}catch(t){o(new Ue({message:"response data must be json"}))}}return o.promise})).catch((e=>{o(e)})),o.promise},Ht={timeout:15e3,persistence:"session"},Vt={};class Qt{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(ot.adapter||(this.requestClient=new ot.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...Ht,...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 Qt(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||ot.adapter.primaryStorage||Ht.persistence;var n;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;ht[t]=new lt(e),dt[t]=new lt({...e,persistence:"local"})}(this.config),n=this.config,Rt[n.env]=new Ot(n),this.authObj=new jt(this.config),this.authObj}on(e,t){return yt.apply(this,[e,t])}off(e,t){return wt.apply(this,[e,t])}callFunction(e,t){return zt.apply(this,[e,t])}deleteFile(e,t){return Kt.apply(this,[e,t])}getTempFileURL(e,t){return Wt.apply(this,[e,t])}downloadFile(e,t){return Jt.apply(this,[e,t])}uploadFile(e,t){return Bt.apply(this,[e,t])}getUploadMetadata(e,t){return $t.apply(this,[e,t])}registerExtension(e){Vt[e.name]=e}async invokeExtension(e,t){const n=Vt[e];if(!n)throw new Ue({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&&(ot.adapter=t),n&&(ot.runtime=n)}}var Gt=new Qt;function Yt(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 Xt{post(e){const{url:t,data:n,headers:s}=e;return new Promise(((e,r)=>{Ne.request({url:Yt("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:i,headers:o,fileType:a}=e,c=Ne.uploadFile({url:Yt("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 Zt={setItem(e,t){Ne.setStorageSync(e,t)},getItem:e=>Ne.getStorageSync(e),removeItem(e){Ne.removeStorageSync(e)},clear(){Ne.clearStorageSync()}};var en={genAdapter:function(){return{root:{},reqClass:Xt,localStorage:Zt,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};Gt.useAdapters(en);const tn=Gt,nn=tn.init;tn.init=function(e){e.env=e.spaceId;const t=nn.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}=Le(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 sn=tn,rn=class extends Ge{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"]=Je(n,this.config.clientSecret);const r=We();s["x-client-info"]=encodeURIComponent(JSON.stringify(r));const{token:i}=qe();return s["x-client-token"]=i,{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:i}){return new Promise(((o,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:r,success(e){e&&e.statusCode<400?o(e):a(new Ue({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new Ue({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})}))}))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s}){if(!t)throw new Ue({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});let r;return this.getOSSUploadOptionsFromPath({cloudPath:t}).then((t=>{const{url:i,formData:o,name:a}=t.result;r=t.result.fileUrl;const c={url:i,formData:o,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 Ue({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 Ue({code:"DELETE_FILE_FAILED",message:"删除文件失败"})}))}getTempFileURL({fileList:e}={}){if(!Array.isArray(e)||0===e.length)throw new Ue({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 Ue({code:"GET_TEMP_FILE_URL_FAILED",message:"获取临时文件链接失败"})}))}},on={init(e){const t=new rn(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 an({data:e}){let t;t=We();const n=JSON.parse(JSON.stringify(e||{}));if(Object.assign(n,{clientInfo:t}),!n.uniIdToken){const{token:e}=qe();e&&(n.uniIdToken=e)}return n}const cn=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var un=/[\\^$.*+?()[\]{}|]/g,ln=RegExp(un.source);function hn(e,t,n){return e.replace(new RegExp((s=t)&&ln.test(s)?s.replace(un,"\\$&"):s,"g"),n);var s}const dn=2e4,fn={code:20101,message:"Invalid client"};function pn(e){const{errSubject:t,subject:n,errCode:s,errMsg:r,code:i,message:o,cause:a}=e||{};return new Ue({subject:t||n||"uni-secure-network",code:s||i||dn,message:r||o,cause:a})}let gn;function mn({secretType:e}={}){return"request"===e||"response"===e||"both"===e}function yn({functionName:e,result:t,logPvd:n}){}function _n(e){const t=e.callFunction,n=function(n){const s=n.name;n.data=an.call(e,{data:n.data});const r={aliyun:"aliyun",tencent:"tcb",tcb:"tcb"}[this.config.provider],i=mn(n)||false;return t.call(this,n).then((e=>(e.errCode=0,!i&&yn.call(this,{functionName:s,result:e,logPvd:r}),Promise.resolve(e))),(e=>(!i&&yn.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=hn(c,`{$${e}}`,a[e]);for(const e in t)c=hn(c,`{${e}}`,t[e]);return"replace"===o?c:e+c}return e}({message:`[${n.name}]: ${e.message}`,formatter:cn,extraInfo:{functionName:s}})),Promise.reject(e))))};e.callFunction=function(t){const{provider:s,spaceId:r}=e.config,i=t.name;let o,a;return t.data=t.data||{},o=n,o=o.bind(e),a=mn(t)?new gn({secretType:t.secretType,uniCloudIns:e}).wrapEncryptDataCallFunction(n.bind(e))(t):function({provider:e,spaceId:t,functionName:n}={}){const{appId:s,uniPlatform:r,osName:i}=$e();let o=r;"app"===r&&(o=i);const a=function({provider:e,spaceId:t}={}){if(!ce)return{};var n;e="tencent"===(n=e)?"tcb":n;const s=ce.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`),pn(fn)}({provider:s,spaceId:r,functionName:i})?new gn({secretType:t.secretType,uniCloudIns:e}).wrapVerifyClientCallFunction(n.bind(e))(t):o(t),Object.defineProperty(a,"result",{get:()=>(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),a}}gn=class{constructor(){throw pn({message:"Platform web is not supported by secure network"})}};const wn=Symbol("CLIENT_DB_INTERNAL");function vn(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=wn,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 kn(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 bn(e,t){return Tn.indexOf(`${e}.${t}`)>-1}function Sn(e){switch(ee(e=Fe(e))){case"array":return e.map((e=>Sn(e)));case"object":return e._internalType===wn||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 Pn(e){return e&&e.content&&e.content.$method}class In{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)})))}}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=Pn(e),n=Pn(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"===Pn(e))return!0;e=e.prevStage}return!1}get isAggregateCommand(){let e=this;for(;e;){const t=Pn(e),n=Pn(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 vn(new In(e,t,n),{get(e,t){let s="db";return e&&e.content&&(s=e.content.$method),bn(s,t)?An({$method:t},e,n):function(){return An({$method:t,$param:Sn(Array.from(arguments))},e,n)}}})}function xn({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 Cn(e,t={}){return vn(new e(t),{get:(e,t)=>bn("db",t)?An({$method:t},null,e):function(){return An({$method:t,$param:Sn(Array.from(arguments))},null,e)}})}class On extends class{constructor({uniClient:e={},isJQL:t=!1}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e._isDefault&&(this._dbCallBacks=de("_globalUniCloudDatabaseCallback")),t||(this.auth=kn(this._authCallBacks)),this._isJQL=t,Object.assign(this,kn(this._dbCallBacks)),this.env=vn({},{get:(e,t)=>({$env:t})}),this.Geo=vn({},{get:(e,t)=>xn({path:["Geo"],method:t})}),this.serverDate=xn({path:[],method:"serverDate"}),this.RegExp=xn({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;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]),ye(_e(o,"fail"),e).then((()=>ye(_e(o,"complete"),e))).then((()=>(r(null,e),Oe(ke,{type:Se,content:e}),Promise.reject(e))))}const c=ye(_e(o,"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<u.length;r++){const{level:e,message:t,detail:n}=u[r],s=console[e]||console.log;let i="[System Info]"+t;n&&(i=`${i}\n详细信息:${n}`),s(i)}if(t)return a(new Ue({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&&(Me({token:s,tokenExpired:c}),this._callbackAuth("refreshToken",[{token:s,tokenExpired:c}]),this._callback("refreshToken",[{token:s,tokenExpired:c}]),Oe(be,{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 r=0;r<l.length;r++){const{prop:t,tips:n}=l[r];if(t in e.result){const s=e.result[t];Object.defineProperty(e.result,t,{get:()=>(console.warn(n),s)})}}return h=e,ye(_e(o,"success"),h).then((()=>ye(_e(o,"complete"),h))).then((()=>{r(h,null);const e=i._parseResult(h);return Oe(ke,{type:Se,content:e}),Promise.resolve(e)}));var h}),(e=>(/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化,请在web控制台保存一次schema以开启clientDB"),a(new Ue({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId})))))}}const Rn="token无效,跳转登录页面",En="token过期,跳转登录页面",Dn={TOKEN_INVALID_TOKEN_EXPIRED:En,TOKEN_INVALID_INVALID_CLIENTID:Rn,TOKEN_INVALID:Rn,TOKEN_INVALID_WRONG_TOKEN:Rn,TOKEN_INVALID_ANONYMOUS_USER:Rn},Ln={"uni-id-token-expired":En,"uni-id-check-token-failed":Rn,"uni-id-token-not-exist":Rn,"uni-id-check-device-feature-failed":Rn};function Un(e,t){let n="";return n=e?`${e}/${t}`:t,n.replace(/^\//,"")}function Nn(e=[],t=""){const n=[],s=[];return e.forEach((e=>{!0===e.needLogin?n.push(Un(t,e.path)):!1===e.needLogin&&s.push(Un(t,e.path))})),{needLoginPage:n,notNeedLoginPage:s}}function Fn(e){return e.split("?")[0].replace(/^\//,"")}function qn(){return function(e){let t=e&&e.$page&&e.$page.fullPath||"";return t?("/"!==t.charAt(0)&&(t="/"+t),t):t}(function(){const e=s();return e[e.length-1]}())}function Mn(){return Fn(qn())}function jn(e="",t={}){if(!e)return!1;if(!(t&&t.list&&t.list.length))return!1;const n=t.list,s=Fn(e);return n.some((e=>e.pagePath===s))}const Bn=!!W.uniIdRouter,{loginPage:$n,routerNeedLogin:Kn,resToLogin:Wn,needLoginPage:Jn,notNeedLoginPage:zn,loginPageInTabBar:Hn}=function({pages:e=[],subPackages:t=[],uniIdRouter:n={},tabBar:s={}}=W){const{loginPage:r,needLogin:i=[],resToLogin:o=!0}=n,{needLoginPage:a,notNeedLoginPage:c}=Nn(e),{needLoginPage:u,notNeedLoginPage:l}=function(e=[]){const t=[],n=[];return e.forEach((e=>{const{root:s,pages:r=[]}=e,{needLoginPage:i,notNeedLoginPage:o}=Nn(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:jn(r,s)}}();if(Jn.indexOf($n)>-1)throw new Error(`Login page [${$n}] should not be "needLogin", please check your pages.json`);function Vn(e){const t=Mn();if("/"===e.charAt(0))return e;const[n,s]=e.split("?"),r=n.replace(/^\//,"").split("/"),i=t.split("/");i.pop();for(let o=0;o<r.length;o++){const e=r[o];".."===e?i.pop():"."!==e&&i.push(e)}return""===i[0]&&i.shift(),"/"+i.join("/")+(s?"?"+s:"")}function Qn({redirect:e}){const t=Fn(e),n=Fn($n);return Mn()!==n&&t!==n}function Gn({api:e,redirect:t}={}){if(!t||!Qn({redirect:t}))return;const n=(r=t,"/"!==(s=$n).charAt(0)&&(s="/"+s),r?s.indexOf("?")>-1?s+`&uniIdRedirectUrl=${encodeURIComponent(r)}`:s+`?uniIdRedirectUrl=${encodeURIComponent(r)}`:s);var s,r;Hn?"navigateTo"!==e&&"redirectTo"!==e||(e="switchTab"):"switchTab"===e&&(e="navigateTo");const i={navigateTo:w,redirectTo:v,switchTab:k,reLaunch:T};setTimeout((()=>{i[e]({url:n})}))}function Yn({url:e}={}){const t={abortLoginPageJump:!1,autoToLoginPage:!1},n=function(){const{token:e,tokenExpired:t}=qe();let n;if(e){if(t<Date.now()){const e="uni-id-token-expired";n={errCode:e,errMsg:Ln[e]}}}else{const e="uni-id-check-token-failed";n={errCode:e,errMsg:Ln[e]}}return n}();if(function(e){const t=Fn(Vn(e));return!(zn.indexOf(t)>-1)&&(Jn.indexOf(t)>-1||Kn.some((t=>{return n=e,new RegExp(t).test(n);var n})))}(e)&&n){if(n.uniIdRedirectUrl=e,Ae(Te).length>0)return setTimeout((()=>{Oe(Te,n)}),0),t.abortLoginPageJump=!0,t;t.autoToLoginPage=!0}return t}function Xn(){!function(){const e=qn(),{abortLoginPageJump:t,autoToLoginPage:n}=Yn({url:e});t||n&&Gn({api:"redirectTo",redirect:e})}();const e=["navigateTo","redirectTo","reLaunch","switchTab"];for(let t=0;t<e.length;t++){const n=e[t];r(n,{invoke(e){const{abortLoginPageJump:t,autoToLoginPage:s}=Yn({url:e.url});return t?e:s?(Gn({api:n,redirect:Vn(e.url)}),!1):e}})}}function Zn(){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 Ln}(n);break;case"clientdb":s=function(e){if("object"!=typeof e)return!1;const{errCode:t}=e||{};return t in Dn}(n)}s&&function(e={}){const t=Ae(Te);De().then((()=>{const n=qn();if(n&&Qn({redirect:n}))return t.length>0?Oe(Te,Object.assign({uniIdRedirectUrl:n},e)):void($n&&Gn({api:"navigateTo",redirect:n}))}))}(n)}))}function es(e){var t;(t=e).onResponse=function(e){xe(ke,e)},t.offResponse=function(e){Ce(ke,e)},function(e){e.onNeedLogin=function(e){xe(Te,e)},e.offNeedLogin=function(e){Ce(Te,e)},Bn&&(de("_globalUniCloudStatus").needLoginInit||(de("_globalUniCloudStatus").needLoginInit=!0,De().then((()=>{Xn.call(e)})),Wn&&Zn.call(e)))}(e),function(e){e.onRefreshToken=function(e){xe(be,e)},e.offRefreshToken=function(e){Ce(be,e)}}(e)}let ts;const ns="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ss=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function rs(){const e=qe().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(ts(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}ts="function"!=typeof atob?function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!ss.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=ns.indexOf(e.charAt(i++))<<18|ns.indexOf(e.charAt(i++))<<12|(n=ns.indexOf(e.charAt(i++)))<<6|(s=ns.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}:atob;var is=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(J((function(e,s){Object.defineProperty(s,"__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 i=t.tempFiles,o=i.length;let a=0;return new Promise((r=>{for(;a<n;)c();function c(){const n=a++;if(n>=o)return void(!i.find((e=>!e.url&&!e.errMsg))&&r(t));const u=i[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<o&&c()})).catch((e=>{u.errMsg=e.errMsg||e.message,n<o&&c()}))}}))}(e,t,5,s)))}s.initChooseAndUploadFile=function(e){return function(s={type:"all"}){return"image"===s.type?c(e,function(e){const{count:n,sizeType:s,sourceType:r=["album","camera"],extension:i}=e;return new Promise(((e,c)=>{t({count:n,sizeType:s,sourceType:r,extension:i,success(t){e(a(t,"image"))},fail(e){c({errMsg:e.errMsg.replace("chooseImage:fail",o)})}})}))}(s),s):"video"===s.type?c(e,function(e){const{camera:t,compressed:s,maxDuration:r,sourceType:i=["album","camera"],extension:c}=e;return new Promise(((e,u)=>{n({camera:t,compressed:s,maxDuration:r,sourceType:i,extension:c,success(t){const{tempFilePath:n,duration:s,size:r,height:i,width:o}=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:o,height:i,duration:s,fileType:"video",cloudPath:""}]},"video"))},fail(e){u({errMsg:e.errMsg.replace("chooseVideo:fail",o)})}})}))}(s),s):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)})}})}))}(s),s)}}})));function os(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<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.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,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 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 h=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*(h-1)).limit(d).get(m),n}}}}function as(e){return de("_globalUniCloudSecureNetworkCache__{spaceId}".replace("{spaceId}",e.config.spaceId))}async function cs({openid:e,callLoginByWeixin:t=!1}={}){throw as(this),new Error("[SecureNetwork] API `initSecureNetworkByWeixin` is not supported on platform `web`")}async function us(e){const t=as(this);return t.initPromise||(t.initPromise=cs.call(this,e)),t.initPromise}function ls(e){const t={getSystemInfo:b,getPushClientId:S};return function(n){return new Promise(((s,r)=>{t[e]({...n,success(e){s(e)},fail(e){r(e)}})}))}}class hs 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 s=0;s<n.length;s++)n[s](...t)}}{constructor(){super(),this._uniPushMessageCallback=this._receivePushMessage.bind(this),this._currentMessageId=-1,this._payloadQueue=[]}init(){return Promise.all([ls("getSystemInfo")(),ls("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(){l(this._uniPushMessageCallback)}_destroy(){h(this._uniPushMessageCallback)}toJSON(){return{appId:this._appId,pushClientId:this._pushClientId,seqId:this._seqId}}close(){this._destroy(),this.emit("close")}}const ds={tcb:sn,tencent:sn,aliyun:Ye,private:on};let fs=new class{init(e){let t={};const n=ds[e.provider];if(!n)throw new Error("未提供正确的provider参数");var s;return t=n.init(e),function(e){e._initPromiseHub||(e._initPromiseHub=new oe({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),_n(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=Cn(On,{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=Cn(On,{uniClient:s,isJQL:!0});return this._databaseForJQL=t,t},function(e){e.getCurrentUserInfo=rs,e.chooseAndUploadFile=is.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return os(e)}}),e.SSEChannel=hs,e.initSecureNetworkByWeixin=function(e){return function({openid:t,callLoginByWeixin:n=!1}={}){return us.call(e,{openid:t,callLoginByWeixin:n})}}(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:i,errorOptions:l,parseSystemError:h}=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 i,o;try{return await ye(_e(t,"invoke"),{...r}),i=await e(...s),await ye(_e(t,"success"),{...r,result:i}),i}catch(a){throw o=a,await ye(_e(t,"fail"),{...r,error:o}),o}finally{await ye(_e(t,"complete"),o?{...r,error:o}:{...r,result:i})}}}({fn:async function r(...p){let g;d&&o({title:i.title,mask:i.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 Ue(e)}}const{errSubject:_,errCode:w,errMsg:v,newToken:k}=g.result||{};if(d&&a(),k&&k.token&&k.tokenExpired&&(Me(k),Oe(be,{...k})),w){let e=v;if(y&&h&&(e=(await h({objectName:n,methodName:f,params:p,errSubject:_,errCode:w,errMsg:v})).errMsg||v),d)if("toast"===l.type)c({title:e,icon:"none"});else{if("modal"!==l.type)throw new Error(`Invalid errorOptions.type: ${l.type}`);{const{confirm:t}=await async function({title:e,content:t,showCancel:n,cancelText:s,confirmText:r}={}){return new Promise(((i,o)=>{u({title:e,content:t,showCancel:n,cancelText:s,confirmText:r,success(e){i(e)},fail(){i({confirm:!1,cancel:!0})}})}))}({title:"提示",content:e,showCancel:l.retry,cancelText:"取消",confirmText:l.retry?"重试":"确定"});if(l.retry&&t)return r(...p)}}const t=new Ue({subject:_,code:w,message:v,requestId:g.requestId});throw t.detail=g.result,Oe(ke,{type:Ie,content:t}),t}return Oe(ke,{type:Ie,content:g.result}),g.result},interceptorName:"callObject",getCallbackArgs:function({params:e}={}){return{objectName:n,methodName:f,params:e}}})})}}(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||Y;t=n!==Y}const n="callFunction"===r&&!t,i=this._initPromiseHub.exec();e=e||{};const{success:o,fail:a,complete:c}=Le(e),u=i.then((()=>t?Promise.resolve():ye(_e(r,"invoke"),e))).then((()=>s.call(this,e))).then((e=>t?Promise.resolve(e):ye(_e(r,"success"),e).then((()=>ye(_e(r,"complete"),e))).then((()=>(n&&Oe(ke,{type:Pe,content:e}),Promise.resolve(e))))),(e=>t?Promise.reject(e):ye(_e(r,"fail"),e).then((()=>ye(_e(r,"complete"),e))).then((()=>(Oe(ke,{type:Pe,content:e}),Promise.reject(e))))));if(!(o||a||c))return u;u.then((e=>{o&&o(e),c&&c(e),n&&Oe(ke,{type:Pe,content:e})}),(e=>{a&&a(e),c&&c(e),n&&Oe(ke,{type:Pe,content:e})}))}).bind(t)})),t.init=this.init,t}};(()=>{const e=ue;let t={};if(e&&1===e.length)t=e[0],fs=fs.init(t),fs._isDefault=!0;else{const t=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","database","getCurrentUSerInfo","importObject"];let n;n=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":"应用未关联服务空间,请在uniCloud目录右键关联服务空间",t.forEach((e=>{fs[e]=function(){return console.error(n),Promise.reject(new Ue({code:"SYS_ERR",message:n}))}}))}Object.assign(fs,{get mixinDatacom(){return os(fs)}}),es(fs),fs.addInterceptor=ge,fs.removeInterceptor=me,fs.interceptObject=we})();const ps=K({name:"uni-data-select",mixins:[fs.mixinDatacom||{}],props:{localdata:{type:Array,default:()=>[]},value:{type:[String,Number],default:""},modelValue:{type:[String,Number],default:""},label:{type:String,default:""},placeholder:{type:String,default:"请选择"},emptyTips:{type:String,default:"无选项"},clear:{type:Boolean,default:!0},defItem:{type:Number,default:0},disabled:{type:Boolean,default:!1},format:{type:String,default:""}},data:()=>({showSelector:!1,current:"",mixinDatacomResData:[],apps:[],channels:[],cacheKey:"uni-data-select-lastSelectedValue"}),created(){this.debounceGet=this.debounce((()=>{this.query()}),300),this.collection&&!this.localdata.length&&this.debounceGet()},computed:{typePlaceholder(){const e=this.placeholder,t={"opendb-stat-app-versions":"版本","opendb-app-channels":"渠道","opendb-app-list":"应用"}[this.collection];return t?e+t:e},valueCom(){return this.modelValue}},watch:{localdata:{immediate:!0,handler(e,t){Array.isArray(e)&&t!==e&&(this.mixinDatacomResData=e)}},valueCom(e,t){this.initDefVal()},mixinDatacomResData:{immediate:!0,handler(e){e.length&&this.initDefVal()}}},methods:{debounce(e,t=100){let n=null;return function(...s){n&&clearTimeout(n),n=setTimeout((()=>{e.apply(this,s)}),t)}},query(){this.mixinDatacomEasyGet()},onMixinDatacomPropsChange(){this.collection&&this.debounceGet()},initDefVal(){let e="";if(!this.valueCom&&0!==this.valueCom||this.isDisabled(this.valueCom)){let t;if(this.collection&&(t=this.getCache()),t||0===t)e=t;else{let t="";this.defItem>0&&this.defItem<=this.mixinDatacomResData.length&&(t=this.mixinDatacomResData[this.defItem-1].value),e=t}(e||0===e)&&this.emit(e)}else e=this.valueCom;const t=this.mixinDatacomResData.find((t=>t.value===e));this.current=t?this.formatItemName(t):""},isDisabled(e){let t=!1;return this.mixinDatacomResData.forEach((n=>{n.value===e&&(t=n.disable)})),t},clearVal(){this.emit(""),this.collection&&this.removeCache()},change(e){e.disable||(this.showSelector=!1,this.current=this.formatItemName(e),this.emit(e.value))},emit(e){this.$emit("input",e),this.$emit("update:modelValue",e),this.$emit("change",e),this.collection&&this.setCache(e)},toggleSelector(){this.disabled||(this.showSelector=!this.showSelector)},formatItemName(e){let{text:t,value:n,channel_code:s}=e;if(s=s?`(${s})`:"",this.format){let t="";t=this.format;for(let n in e)t=t.replace(new RegExp(`{${n}}`,"g"),e[n]);return t}return this.collection.indexOf("app-list")>0?`${t}(${n})`:t||`未命名${s}`},getLoadData(){return this.mixinDatacomResData},getCurrentCacheKey(){return this.collection},getCache(e=this.getCurrentCacheKey()){return(g(this.cacheKey)||{})[e]},setCache(e,t=this.getCurrentCacheKey()){let n=g(this.cacheKey)||{};n[t]=e,p(this.cacheKey,n)},removeCache(e=this.getCurrentCacheKey()){let t=g(this.cacheKey)||{};delete t[e],p(this.cacheKey,t)}}},[["render",function(e,t,n,s,r,i){const o=j,a=A("uni-icons"),c=B,u=$;return x(),C(o,{class:"uni-stat__select"},{default:O((()=>[n.label?(x(),R("span",{key:0,class:"uni-label-text hide-on-phone"},E(n.label+":"),1)):D("",!0),L(o,{class:U(["uni-stat-box",{"uni-stat__actived":r.current}])},{default:O((()=>[L(o,{class:U(["uni-select",{"uni-select--disabled":n.disabled}])},{default:O((()=>[L(o,{class:"uni-select__input-box",onClick:i.toggleSelector},{default:O((()=>[r.current?(x(),C(o,{key:0,class:"uni-select__input-text"},{default:O((()=>[N(E(r.current),1)])),_:1})):(x(),C(o,{key:1,class:"uni-select__input-text uni-select__input-placeholder"},{default:O((()=>[N(E(i.typePlaceholder),1)])),_:1})),r.current&&n.clear&&!n.disabled?(x(),C(o,{key:2,onClick:F(i.clearVal,["stop"])},{default:O((()=>[L(a,{type:"clear",color:"#c0c4cc",size:"24"})])),_:1},8,["onClick"])):(x(),C(o,{key:3},{default:O((()=>[L(a,{type:r.showSelector?"top":"bottom",size:"14",color:"#999"},null,8,["type"])])),_:1}))])),_:1},8,["onClick"]),r.showSelector?(x(),C(o,{key:0,class:"uni-select--mask",onClick:i.toggleSelector},null,8,["onClick"])):D("",!0),r.showSelector?(x(),C(o,{key:1,class:"uni-select__selector"},{default:O((()=>[L(o,{class:"uni-popper__arrow"}),L(u,{"scroll-y":"true",class:"uni-select__selector-scroll"},{default:O((()=>[0===r.mixinDatacomResData.length?(x(),C(o,{key:0,class:"uni-select__selector-empty"},{default:O((()=>[L(c,null,{default:O((()=>[N(E(n.emptyTips),1)])),_:1})])),_:1})):(x(!0),R(q,{key:1},M(r.mixinDatacomResData,((e,t)=>(x(),C(o,{class:"uni-select__selector-item",key:t,onClick:t=>i.change(e)},{default:O((()=>[L(c,{class:U({"uni-select__selector__disabled":e.disable})},{default:O((()=>[N(E(i.formatItemName(e)),1)])),_:2},1032,["class"])])),_:2},1032,["onClick"])))),128))])),_:1})])),_:1})):D("",!0)])),_:1},8,["class"])])),_:1},8,["class"])])),_:1})}],["__scopeId","data-v-12b91366"]]);export{ps as _};