WXL
6 天以前 b76de9a566e4435146a970aa22333a58f87b485b
1
import{a9 as e,_ as t,aa as s,ab as i,a as n,c as o,w as r,ac as a,J as c,l,i as u,G as h,H as d,ad as p,e as f,d as g,ae as m,af as y,ag as _,ah as w,ai as k,aj as v,v as b,x as T,A as x,N as S,ak as I,al as P,M as A,am as C,a6 as O,Q as F,z as E,O as L,an as R,n as U,E as D,s as N,j as $,ao as M,ap as j,aq as q,q as B,ar as K,a2 as z,f as H,F as V,h as W,X as J,b as G,m as Y,as as Q,t as X,k as Z,L as ee,D as te,r as se,R as ie,a7 as ne,a3 as oe,a4 as re,W as ae}from"./index-Cv1VfHUB.js";import{_ as ce}from"./uni-icons.DdnRzdYz.js";class le{constructor(t,s){this.options=t,this.animation=e({...t}),this.currentStepAnimates={},this.next=0,this.$=s}_nvuePushAnimates(e,t){let s=this.currentStepAnimates[this.next],i={};if(i=s||{styles:{},config:{}},ue.includes(e)){i.styles.transform||(i.styles.transform="");let s="";"rotate"===e&&(s="deg"),i.styles.transform+=`${e}(${t+s}) `}else i.styles[e]=`${t}`;this.currentStepAnimates[this.next]=i}_animateRun(e={},t={}){let s=this.$.$refs.ani.ref;if(s)return new Promise((i,n)=>{nvueAnimation.transition(s,{styles:e,...t},e=>{i()})})}_nvueNextAnimate(e,t=0,s){let i=e[t];if(i){let{styles:n,config:o}=i;this._animateRun(n,o).then(()=>{t+=1,this._nvueNextAnimate(e,t,s)})}else this.currentStepAnimates={},"function"==typeof s&&s(),this.isEnd=!0}step(e={}){return this.animation.step(e),this}run(e){this.$.animationData=this.animation.export(),this.$.timer=setTimeout(()=>{"function"==typeof e&&e()},this.$.durationTime)}}const ue=["matrix","matrix3d","rotate","rotate3d","rotateX","rotateY","rotateZ","scale","scale3d","scaleX","scaleY","scaleZ","skew","skewX","skewY","translate","translate3d","translateX","translateY","translateZ"];function he(e,t){if(t)return clearTimeout(t.timer),new le(e,t)}ue.concat(["opacity","backgroundColor"],["width","height","left","right","top","bottom"]).forEach(e=>{le.prototype[e]=function(...t){return this.animation[e](...t),this}});const de=t({name:"uniTransition",emits:["click","change"],props:{show:{type:Boolean,default:!1},modeClass:{type:[Array,String],default:()=>"fade"},duration:{type:Number,default:300},styles:{type:Object,default:()=>({})},customClass:{type:String,default:""},onceRender:{type:Boolean,default:!1}},data:()=>({isShow:!1,transform:"",opacity:0,animationData:{},durationTime:300,config:{}}),watch:{show:{handler(e){e?this.open():this.isShow&&this.close()},immediate:!0}},computed:{stylesObject(){let e={...this.styles,"transition-duration":this.duration/1e3+"s"},t="";for(let s in e){t+=this.toLine(s)+":"+e[s]+";"}return t},transformStyles(){return"transform:"+this.transform+";opacity:"+this.opacity+";"+this.stylesObject}},created(){this.config={duration:this.duration,timingFunction:"ease",transformOrigin:"50% 50%",delay:0},this.durationTime=this.duration},methods:{init(e={}){e.duration&&(this.durationTime=e.duration),this.animation=he(Object.assign(this.config,e),this)},onClick(){this.$emit("click",{detail:this.isShow})},step(e,t={}){return this.animation?(Object.keys(e).forEach(t=>{const s=e[t];"function"==typeof this.animation[t]&&(Array.isArray(s)?this.animation[t](...s):this.animation[t](s))}),this.animation.step(t),this):this},run(e){this.animation&&this.animation.run(e)},open(){clearTimeout(this.timer),this.isShow=!0,this.transform=this.styleInit(!1).transform||"",this.opacity=this.styleInit(!1).opacity||0,this.$nextTick(()=>{this.timer=setTimeout(()=>{this.animation=he(this.config,this),this.tranfromInit(!1).step(),this.animation.run(()=>{this.transform="",this.opacity=this.styleInit(!1).opacity||1,this.$emit("change",{detail:this.isShow})})},80)})},close(e){this.animation&&this.tranfromInit(!0).step().run(()=>{this.isShow=!1,this.animationData=null,this.animation=null;let{opacity:e,transform:t}=this.styleInit(!1);this.opacity=e||1,this.transform=t,this.$emit("change",{detail:this.isShow})})},styleInit(e){let t={transform:"",opacity:1};const s=(e,s)=>{const i=this.animationType(e)[s];s.startsWith("fade")?t.opacity=i:t.transform+=i+" "};return"string"==typeof this.modeClass?s(e,this.modeClass):this.modeClass.forEach(t=>s(e,t)),t},tranfromInit(e){let t=(e,t)=>{let s=null;"fade"===t?s=e?0:1:(s=e?"-100%":"0","zoom-in"===t&&(s=e?.8:1),"zoom-out"===t&&(s=e?1.2:1),"slide-right"===t&&(s=e?"100%":"0"),"slide-bottom"===t&&(s=e?"100%":"0")),this.animation[this.animationMode()[t]](s)};return"string"==typeof this.modeClass?t(e,this.modeClass):this.modeClass.forEach(s=>{t(e,s)}),this.animation},animationType:e=>({fade:e?1:0,"slide-top":`translateY(${e?"0":"-100%"})`,"slide-right":`translateX(${e?"0":"100%"})`,"slide-bottom":`translateY(${e?"0":"100%"})`,"slide-left":`translateX(${e?"0":"-100%"})`,"zoom-in":`scaleX(${e?1:.8}) scaleY(${e?1:.8})`,"zoom-out":`scaleX(${e?1:1.2}) scaleY(${e?1:1.2})`}),animationMode:()=>({fade:"opacity","slide-top":"translateY","slide-right":"translateX","slide-bottom":"translateY","slide-left":"translateX","zoom-in":"scale","zoom-out":"scale"}),toLine:e=>e.replace(/([A-Z])/g,"-$1").toLowerCase()}},[["render",function(e,t,h,d,p,f){const g=u;return s((n(),o(g,{ref:"ani",animation:p.animationData,class:c(h.customClass),style:l(f.transformStyles),onClick:f.onClick},{default:r(()=>[a(e.$slots,"default")]),_:3},8,["animation","class","style","onClick"])),[[i,p.isShow]])}]]),pe={name:"uniPopup",components:{keypress:{name:"Keypress",props:{disable:{type:Boolean,default:!1}},mounted(){const e={esc:["Esc","Escape"],tab:"Tab",enter:"Enter",space:[" ","Spacebar"],up:["Up","ArrowUp"],left:["Left","ArrowLeft"],right:["Right","ArrowRight"],down:["Down","ArrowDown"],delete:["Backspace","Delete","Del"]};document.addEventListener("keyup",t=>{if(this.disable)return;const s=Object.keys(e).find(s=>{const i=t.key,n=e[s];return n===i||Array.isArray(n)&&n.includes(i)});s&&setTimeout(()=>{this.$emit(s,{})},0)})},render:()=>{}}},emits:["change","maskClick"],props:{animation:{type:Boolean,default:!0},type:{type:String,default:"center"},isMaskClick:{type:Boolean,default:null},maskClick:{type:Boolean,default:null},backgroundColor:{type:String,default:"none"},safeArea:{type:Boolean,default:!0},maskBackgroundColor:{type:String,default:"rgba(0, 0, 0, 0.4)"},borderRadius:{type:String}},watch:{type:{handler:function(e){this.config[e]&&this[this.config[e]](!0)},immediate:!0},isDesktop:{handler:function(e){this.config[e]&&this[this.config[this.type]](!0)},immediate:!0},maskClick:{handler:function(e){this.mkclick=e},immediate:!0},isMaskClick:{handler:function(e){this.mkclick=e},immediate:!0},showPopup(e){document.getElementsByTagName("body")[0].style.overflow=e?"hidden":"visible"}},data(){return{duration:300,ani:[],showPopup:!1,showTrans:!1,popupWidth:0,popupHeight:0,config:{top:"top",bottom:"bottom",center:"center",left:"left",right:"right",message:"top",dialog:"center",share:"bottom"},maskClass:{position:"fixed",bottom:0,top:0,left:0,right:0,backgroundColor:"rgba(0, 0, 0, 0.4)"},transClass:{backgroundColor:"transparent",borderRadius:this.borderRadius||"0",position:"fixed",left:0,right:0},maskShow:!0,mkclick:!0,popupstyle:"top"}},computed:{getStyles(){let e={backgroundColor:this.bg};return this.borderRadius,e=Object.assign(e,{borderRadius:this.borderRadius}),e},isDesktop(){return this.popupWidth>=500&&this.popupHeight>=500},bg(){return""===this.backgroundColor||"none"===this.backgroundColor?"transparent":this.backgroundColor}},mounted(){(()=>{const{windowWidth:e,windowHeight:t,windowTop:s,safeArea:i,screenHeight:n,safeAreaInsets:o}=m();this.popupWidth=e,this.popupHeight=t+(s||0),i&&this.safeArea?this.safeAreaInsets=o.bottom:this.safeAreaInsets=0})()},unmounted(){this.setH5Visible()},activated(){this.setH5Visible(!this.showPopup)},deactivated(){this.setH5Visible(!0)},created(){null===this.isMaskClick&&null===this.maskClick?this.mkclick=!0:this.mkclick=null!==this.isMaskClick?this.isMaskClick:this.maskClick,this.animation?this.duration=300:this.duration=0,this.messageChild=null,this.clearPropagation=!1,this.maskClass.backgroundColor=this.maskBackgroundColor},methods:{setH5Visible(e=!0){document.getElementsByTagName("body")[0].style.overflow=e?"visible":"hidden"},closeMask(){this.maskShow=!1},disableMask(){this.mkclick=!1},clear(e){e.stopPropagation(),this.clearPropagation=!0},open(e){if(this.showPopup)return;e&&-1!==["top","center","bottom","left","right","message","dialog","share"].indexOf(e)||(e=this.type),this.config[e]?(this[this.config[e]](),this.$emit("change",{show:!0,type:e})):console.error("缺少类型:",e)},close(e){this.showTrans=!1,this.$emit("change",{show:!1,type:this.type}),clearTimeout(this.timer),this.timer=setTimeout(()=>{this.showPopup=!1},300)},touchstart(){this.clearPropagation=!1},onTap(){this.clearPropagation?this.clearPropagation=!1:(this.$emit("maskClick"),this.mkclick&&this.close())},top(e){this.popupstyle=this.isDesktop?"fixforpc-top":"top",this.ani=["slide-top"],this.transClass={position:"fixed",left:0,right:0,backgroundColor:this.bg,borderRadius:this.borderRadius||"0"},e||(this.showPopup=!0,this.showTrans=!0,this.$nextTick(()=>{this.showPoptrans(),this.messageChild&&"message"===this.type&&this.messageChild.timerClose()}))},bottom(e){this.popupstyle="bottom",this.ani=["slide-bottom"],this.transClass={position:"fixed",left:0,right:0,bottom:0,paddingBottom:this.safeAreaInsets+"px",backgroundColor:this.bg,borderRadius:this.borderRadius||"0"},e||this.showPoptrans()},center(e){this.popupstyle="center",this.ani=["zoom-out","fade"],this.transClass={position:"fixed",display:"flex",flexDirection:"column",bottom:0,left:0,right:0,top:0,justifyContent:"center",alignItems:"center",borderRadius:this.borderRadius||"0"},e||this.showPoptrans()},left(e){this.popupstyle="left",this.ani=["slide-left"],this.transClass={position:"fixed",left:0,bottom:0,top:0,backgroundColor:this.bg,borderRadius:this.borderRadius||"0",display:"flex",flexDirection:"column"},e||this.showPoptrans()},right(e){this.popupstyle="right",this.ani=["slide-right"],this.transClass={position:"fixed",bottom:0,right:0,top:0,backgroundColor:this.bg,borderRadius:this.borderRadius||"0",display:"flex",flexDirection:"column"},e||this.showPoptrans()},showPoptrans(){this.$nextTick(()=>{this.showPopup=!0,this.showTrans=!0})}}};const fe=t(pe,[["render",function(e,t,s,i,m,y){const _=h(d("uni-transition"),de),w=u,k=p("keypress");return m.showPopup?(n(),o(w,{key:0,class:c(["uni-popup",[m.popupstyle,y.isDesktop?"fixforpc-z-index":""]])},{default:r(()=>[f(w,{onTouchstart:y.touchstart},{default:r(()=>[m.maskShow?(n(),o(_,{key:"1",name:"mask","mode-class":"fade",styles:m.maskClass,duration:m.duration,show:m.showTrans,onClick:y.onTap},null,8,["styles","duration","show","onClick"])):g("",!0),f(_,{key:"2","mode-class":m.ani,name:"content",styles:m.transClass,duration:m.duration,show:m.showTrans,onClick:y.onTap},{default:r(()=>[f(w,{class:c(["uni-popup__wrapper",[m.popupstyle]]),style:l(y.getStyles),onClick:y.clear},{default:r(()=>[a(e.$slots,"default",{},void 0,!0)]),_:3},8,["style","class","onClick"])]),_:3},8,["mode-class","styles","duration","show","onClick"])]),_:3},8,["onTouchstart"]),m.maskShow?(n(),o(k,{key:0,onEsc:y.onTap},null,8,["onEsc"])):g("",!0)]),_:3},8,["class"])):g("",!0)}],["__scopeId","data-v-c96125a2"]]),ge={pages:[{path:"pages/index/index",style:{navigationBarTitleText:"青大附院OPO管理平台",enablePullDownRefresh:!0}},{path:"pages/login/Login",style:{navigationBarTitleText:"登录",navigationStyle:"custom"}},{path:"pages/login/Register",style:{navigationBarTitleText:"注册",navigationStyle:"custom"}},{path:"pages/my/index",style:{navigationBarTitleText:"个人中心"}}],subPackages:[{root:"pagesSub/case",name:"案例上报模块",pages:[{path:"index",style:{navigationBarTitleText:"我的上报"}},{path:"CaseDetails",style:{navigationBarTitleText:"上报案例"}},{path:"CaseInfo",style:{navigationBarTitleText:"案例详情"}},{path:"transfer",style:{navigationBarTitleText:"转运登记"}},{path:"transferinfo",style:{navigationBarTitleText:"登记单详情"}}]},{root:"pagesSub/ethicalReview",name:"伦理审查模块",pages:[{path:"ethicalInfo",style:{navigationBarTitleText:"伦理审查"}},{path:"index",style:{navigationBarTitleText:"审查记录"}}]},{root:"pagesSub/medical",name:"病历管理模块",pages:[{path:"my/cases",style:{navigationBarTitleText:"个人病例"}},{path:"my/case-detail",style:{navigationBarTitleText:"病例详情"}}]},{root:"pagesSub/my",name:"我的扩展模块",pages:[{path:"payment-method",style:{navigationBarTitleText:"支付方式"}},{path:"add-bank-card",style:{navigationBarTitleText:"添加银行卡"}},{path:"notification",style:{navigationBarTitleText:"消息通知"}},{path:"profile",style:{navigationBarTitleText:"个人信息"}},{path:"health-records",style:{navigationBarTitleText:"健康档案"}}]},{root:"pagesSub/featured",name:"特色医疗模块",pages:[{path:"project",style:{navigationBarTitleText:"项目详情"}},{path:"case",style:{navigationBarTitleText:"案例详情"}},{path:"all",style:{navigationBarTitleText:"全部特色医疗"}},{path:"bay-area",style:{navigationBarTitleText:"大湾区特色医疗"}}]},{root:"pagesSub/common",name:"通用功能模块",pages:[{path:"search/index",style:{navigationBarTitleText:"搜索"}},{path:"doctor/detail",style:{navigationBarTitleText:"医生详情"}},{path:"disease/detail",style:{navigationBarTitleText:"疾病详情"}},{path:"hospital/detail",style:{navigationBarTitleText:"医院详情"}},{path:"news/list",style:{navigationBarTitleText:"医院资讯"}},{path:"news/detail",style:{navigationBarTitleText:"资讯详情"}}]}],preloadRule:{"pages/index/index":{network:"wifi",packages:["pagesSub/my"]},"pages/login/Login":{network:"wifi",packages:["pagesSub/my"]},"pages/my/index":{network:"wifi",packages:["pagesSub/my","pagesSub/medical"]},"pagesSub/case/index":{network:"wifi",packages:["pagesSub/medical"]}},globalStyle:{navigationBarTextStyle:"white",navigationBarBackgroundColor:"#0f95b0",backgroundColor:"#F5F6FA"},uniIdRouter:{},tabBar:{color:"#999999",selectedColor:"#0f95b0",backgroundColor:"#FFFFFF",borderStyle:"black",list:[{pagePath:"pages/index/index",text:"首页",iconPath:"static/tabbar/home.png",selectedIconPath:"static/tabbar/home-active.png"},{pagePath:"pages/my/index",text:"我的",iconPath:"static/tabbar/my.png",selectedIconPath:"static/tabbar/my-active.png"}]},easycom:{autoscan:!0,custom:{"^uni-(.*)":"@dcloudio/uni-ui/lib/uni-$1/uni-$1","^u--(.*)":"@/uni_modules/uview-plus/components/u-$1/u-$1.vue","^up-(.*)":"@/uni_modules/uview-plus/components/u-$1/u-$1.vue","^u-([^-].*)":"@/uni_modules/uview-plus/components/u-$1/u-$1.vue"}}};function me(e,t,s){return e(s={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&s.path)}},s.exports),s.exports}var ye=me(function(e,t){var s;e.exports=(s=s||function(e){var t=Object.create||function(){function e(){}return function(t){var s;return e.prototype=t,s=new e,e.prototype=null,s}}(),s={},i=s.lib={},n=i.Base={extend:function(e){var s=t(this);return e&&s.mixIn(e),s.hasOwnProperty("init")&&this.init!==s.init||(s.init=function(){s.$super.init.apply(this,arguments)}),s.init.prototype=s,s.$super=this,s},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=i.WordArray=n.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,s=e.words,i=this.sigBytes,n=e.sigBytes;if(this.clamp(),i%4)for(var o=0;o<n;o++){var r=s[o>>>2]>>>24-o%4*8&255;t[i+o>>>2]|=r<<24-(i+o)%4*8}else for(o=0;o<n;o+=4)t[i+o>>>2]=s[o>>>2];return this.sigBytes+=n,this},clamp:function(){var t=this.words,s=this.sigBytes;t[s>>>2]&=4294967295<<32-s%4*8,t.length=e.ceil(s/4)},clone:function(){var e=n.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var s,i=[],n=function(t){var s=987654321,i=4294967295;return function(){var n=((s=36969*(65535&s)+(s>>16)&i)<<16)+(t=18e3*(65535&t)+(t>>16)&i)&i;return n/=4294967296,(n+=.5)*(e.random()>.5?1:-1)}},r=0;r<t;r+=4){var a=n(4294967296*(s||e.random()));s=987654071*a(),i.push(4294967296*a()|0)}return new o.init(i,t)}}),r=s.enc={},a=r.Hex={stringify:function(e){for(var t=e.words,s=e.sigBytes,i=[],n=0;n<s;n++){var o=t[n>>>2]>>>24-n%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,s=[],i=0;i<t;i+=2)s[i>>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new o.init(s,t/2)}},c=r.Latin1={stringify:function(e){for(var t=e.words,s=e.sigBytes,i=[],n=0;n<s;n++){var o=t[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(e){for(var t=e.length,s=[],i=0;i<t;i++)s[i>>>2]|=(255&e.charCodeAt(i))<<24-i%4*8;return new o.init(s,t)}},l=r.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)))}},u=i.BufferedBlockAlgorithm=n.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 s=this._data,i=s.words,n=s.sigBytes,r=this.blockSize,a=n/(4*r),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*r,l=e.min(4*c,n);if(c){for(var u=0;u<c;u+=r)this._doProcessBlock(i,u);var h=i.splice(0,c);s.sigBytes-=l}return new o.init(h,l)},clone:function(){var e=n.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});i.Hasher=u.extend({cfg:n.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){u.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,s){return new e.init(s).finalize(t)}},_createHmacHelper:function(e){return function(t,s){return new h.HMAC.init(e,s).finalize(t)}}});var h=s.algo={};return s}(Math),s)}),_e=ye,we=(me(function(e,t){var s;e.exports=(s=_e,function(e){var t=s,i=t.lib,n=i.WordArray,o=i.Hasher,r=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=r.MD5=o.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var s=0;s<16;s++){var i=t+s,n=e[i];e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var o=this._hash.words,r=e[t+0],c=e[t+1],p=e[t+2],f=e[t+3],g=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],w=e[t+8],k=e[t+9],v=e[t+10],b=e[t+11],T=e[t+12],x=e[t+13],S=e[t+14],I=e[t+15],P=o[0],A=o[1],C=o[2],O=o[3];P=l(P,A,C,O,r,7,a[0]),O=l(O,P,A,C,c,12,a[1]),C=l(C,O,P,A,p,17,a[2]),A=l(A,C,O,P,f,22,a[3]),P=l(P,A,C,O,g,7,a[4]),O=l(O,P,A,C,m,12,a[5]),C=l(C,O,P,A,y,17,a[6]),A=l(A,C,O,P,_,22,a[7]),P=l(P,A,C,O,w,7,a[8]),O=l(O,P,A,C,k,12,a[9]),C=l(C,O,P,A,v,17,a[10]),A=l(A,C,O,P,b,22,a[11]),P=l(P,A,C,O,T,7,a[12]),O=l(O,P,A,C,x,12,a[13]),C=l(C,O,P,A,S,17,a[14]),P=u(P,A=l(A,C,O,P,I,22,a[15]),C,O,c,5,a[16]),O=u(O,P,A,C,y,9,a[17]),C=u(C,O,P,A,b,14,a[18]),A=u(A,C,O,P,r,20,a[19]),P=u(P,A,C,O,m,5,a[20]),O=u(O,P,A,C,v,9,a[21]),C=u(C,O,P,A,I,14,a[22]),A=u(A,C,O,P,g,20,a[23]),P=u(P,A,C,O,k,5,a[24]),O=u(O,P,A,C,S,9,a[25]),C=u(C,O,P,A,f,14,a[26]),A=u(A,C,O,P,w,20,a[27]),P=u(P,A,C,O,x,5,a[28]),O=u(O,P,A,C,p,9,a[29]),C=u(C,O,P,A,_,14,a[30]),P=h(P,A=u(A,C,O,P,T,20,a[31]),C,O,m,4,a[32]),O=h(O,P,A,C,w,11,a[33]),C=h(C,O,P,A,b,16,a[34]),A=h(A,C,O,P,S,23,a[35]),P=h(P,A,C,O,c,4,a[36]),O=h(O,P,A,C,g,11,a[37]),C=h(C,O,P,A,_,16,a[38]),A=h(A,C,O,P,v,23,a[39]),P=h(P,A,C,O,x,4,a[40]),O=h(O,P,A,C,r,11,a[41]),C=h(C,O,P,A,f,16,a[42]),A=h(A,C,O,P,y,23,a[43]),P=h(P,A,C,O,k,4,a[44]),O=h(O,P,A,C,T,11,a[45]),C=h(C,O,P,A,I,16,a[46]),P=d(P,A=h(A,C,O,P,p,23,a[47]),C,O,r,6,a[48]),O=d(O,P,A,C,_,10,a[49]),C=d(C,O,P,A,S,15,a[50]),A=d(A,C,O,P,m,21,a[51]),P=d(P,A,C,O,T,6,a[52]),O=d(O,P,A,C,f,10,a[53]),C=d(C,O,P,A,v,15,a[54]),A=d(A,C,O,P,c,21,a[55]),P=d(P,A,C,O,w,6,a[56]),O=d(O,P,A,C,I,10,a[57]),C=d(C,O,P,A,y,15,a[58]),A=d(A,C,O,P,x,21,a[59]),P=d(P,A,C,O,g,6,a[60]),O=d(O,P,A,C,b,10,a[61]),C=d(C,O,P,A,p,15,a[62]),A=d(A,C,O,P,k,21,a[63]),o[0]=o[0]+P|0,o[1]=o[1]+A|0,o[2]=o[2]+C|0,o[3]=o[3]+O|0},_doFinalize:function(){var t=this._data,s=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;s[n>>>5]|=128<<24-n%32;var o=e.floor(i/4294967296),r=i;s[15+(n+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),s[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(s.length+1),this._process();for(var a=this._hash,c=a.words,l=0;l<4;l++){var u=c[l];c[l]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function l(e,t,s,i,n,o,r){var a=e+(t&s|~t&i)+n+r;return(a<<o|a>>>32-o)+t}function u(e,t,s,i,n,o,r){var a=e+(t&i|s&~i)+n+r;return(a<<o|a>>>32-o)+t}function h(e,t,s,i,n,o,r){var a=e+(t^s^i)+n+r;return(a<<o|a>>>32-o)+t}function d(e,t,s,i,n,o,r){var a=e+(s^(t|~i))+n+r;return(a<<o|a>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),s.MD5)}),me(function(e,t){var s,i,n;e.exports=(i=(s=_e).lib.Base,n=s.enc.Utf8,void(s.algo.HMAC=i.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=n.parse(t));var s=e.blockSize,i=4*s;t.sigBytes>i&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),r=this._iKey=t.clone(),a=o.words,c=r.words,l=0;l<s;l++)a[l]^=1549556828,c[l]^=909522486;o.sigBytes=r.sigBytes=i,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,s=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(s))}})))}),me(function(e,t){e.exports=_e.HmacMD5})),ke=me(function(e,t){e.exports=_e.enc.Utf8}),ve=me(function(e,t){var s,i,n;e.exports=(n=(i=s=_e).lib.WordArray,i.enc.Base64={stringify:function(e){var t=e.words,s=e.sigBytes,i=this._map;e.clamp();for(var n=[],o=0;o<s;o+=3)for(var r=(t[o>>>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<s;a++)n.push(i.charAt(r>>>6*(3-a)&63));var c=i.charAt(64);if(c)for(;n.length%4;)n.push(c);return n.join("")},parse:function(e){var t=e.length,s=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o<s.length;o++)i[s.charCodeAt(o)]=o}var r=s.charAt(64);if(r){var a=e.indexOf(r);-1!==a&&(t=a)}return function(e,t,s){for(var i=[],o=0,r=0;r<t;r++)if(r%4){var a=s[e.charCodeAt(r-1)]<<r%4*2,c=s[e.charCodeAt(r)]>>>6-r%4*2;i[o>>>2]|=(a|c)<<24-o%4*8,o++}return n.create(i,o)}(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},s.enc.Base64)});const be="uni_id_token",Te="uni_id_token_expired",xe="FUNCTION",Se="OBJECT",Ie="CLIENT_DB",Pe="pending",Ae="rejected";function Ce(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function Oe(e){return"object"===Ce(e)}function Fe(e){return"function"==typeof e}function Ee(e){return function(){try{return e.apply(e,arguments)}catch(t){console.error(t)}}}const Le="REJECTED",Re="NOT_PENDING";class Ue{constructor({createPromise:e,retryRule:t=Le}={}){this.createPromise=e,this.status=null,this.promise=null,this.retryRule=t}get needRetry(){if(!this.status)return!0;switch(this.retryRule){case Le:return this.status===Ae;case Re:return this.status!==Pe}}exec(){return this.needRetry?(this.status=Pe,this.promise=this.createPromise().then(e=>(this.status="fulfilled",Promise.resolve(e)),e=>(this.status=Ae,Promise.reject(e))),this.promise):this.promise}}class De{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 s=this._callback[e];if(!s)return;const i=function(e,t){for(let s=e.length-1;s>=0;s--)if(e[s]===t)return s;return-1}(s,t);s.splice(i,1)}off(e,t){return this.removeListener(e,t)}removeAllListener(e){delete this._callback[e]}emit(e,...t){const s=this._callback[e];if(s)for(let i=0;i<s.length;i++)s[i](...t)}}function Ne(e){return e&&"string"==typeof e?JSON.parse(e):e}const $e=Ne([]),Me="web";Ne("");const je=Ne("[]")||[];let qe="";try{qe="__UNI__90996F2"}catch(Ft){}let Be,Ke={};function ze(e,t={}){var s,i;return s=Ke,i=e,Object.prototype.hasOwnProperty.call(s,i)||(Ke[e]=t),Ke[e]}const He=["invoke","success","fail","complete"],Ve=ze("_globalUniCloudInterceptor");function We(e,t){Ve[e]||(Ve[e]={}),Oe(t)&&Object.keys(t).forEach(s=>{He.indexOf(s)>-1&&function(e,t,s){let i=Ve[e][t];i||(i=Ve[e][t]=[]),-1===i.indexOf(s)&&Fe(s)&&i.push(s)}(e,s,t[s])})}function Je(e,t){Ve[e]||(Ve[e]={}),Oe(t)?Object.keys(t).forEach(s=>{He.indexOf(s)>-1&&function(e,t,s){const i=Ve[e][t];if(!i)return;const n=i.indexOf(s);n>-1&&i.splice(n,1)}(e,s,t[s])}):delete Ve[e]}function Ge(e,t){return e&&0!==e.length?e.reduce((e,s)=>e.then(()=>s(t)),Promise.resolve()):Promise.resolve()}function Ye(e,t){return Ve[e]&&Ve[e][t]||[]}function Qe(e){We("callObject",e)}const Xe=ze("_globalUniCloudListener"),Ze="response",et="needLogin",tt="refreshToken",st="clientdb",it="cloudfunction",nt="cloudobject";function ot(e){return Xe[e]||(Xe[e]=[]),Xe[e]}function rt(e,t){const s=ot(e);s.includes(t)||s.push(t)}function at(e,t){const s=ot(e),i=s.indexOf(t);-1!==i&&s.splice(i,1)}function ct(e,t){const s=ot(e);for(let i=0;i<s.length;i++)(0,s[i])(t)}let lt,ut=!1;function ht(){return lt||(lt=new Promise(e=>{ut&&e(),function t(){if("function"==typeof w){const t=w();t&&t[0]&&(ut=!0,e())}ut||setTimeout(()=>{t()},30)}()}),lt)}function dt(e){const t={};for(const s in e){const i=e[s];Fe(i)&&(t[s]=Ee(i))}return t}class pt extends Error{constructor(e){const t=e.message||e.errMsg||"unknown system error";super(t),this.errMsg=t,this.code=this.errCode=e.code||e.errCode||"SYSTEM_ERROR",this.errSubject=this.subject=e.subject||e.errSubject,this.cause=e.cause,this.requestId=e.requestId}toJson(e=0){if(!(e>=10))return e++,{errCode:this.errCode,errMsg:this.errMsg,errSubject:this.errSubject,cause:this.cause&&this.cause.toJson?this.cause.toJson(e):this.cause}}}var ft={request:e=>A(e),uploadFile:e=>C(e),setStorageSync:(e,t)=>O(e,t),getStorageSync:e=>F(e),removeStorageSync:e=>E(e),clearStorageSync:()=>L(),connectSocket:e=>R(e)};function gt(e){return e&&gt(e.__v_raw)||e}function mt(){return{token:ft.getStorageSync(be)||ft.getStorageSync("uniIdToken"),tokenExpired:ft.getStorageSync(Te)}}function yt({token:e,tokenExpired:t}={}){e&&ft.setStorageSync(be,e),t&&ft.setStorageSync(Te,t)}let _t,wt;function kt(){return _t||(_t=m()),_t}function vt(){let e,t;try{if(B){if(B.toString().indexOf("not yet implemented")>-1)return;const{scene:s,channel:i}=B();e=i,t=s}}catch(s){}return{channel:e,scene:t}}let bt={};function Tt(){const e=q&&q()||"en";if(wt)return{...bt,...wt,locale:e,LOCALE:e};const t=kt(),{deviceId:s,osName:i,uniPlatform:n,appId:o}=t,r=["appId","appLanguage","appName","appVersion","appVersionCode","appWgtVersion","browserName","browserVersion","deviceBrand","deviceId","deviceModel","deviceType","osName","osVersion","romName","romVersion","ua","hostName","hostVersion","uniPlatform","uniRuntimeVersion","uniRuntimeVersionCode","uniCompilerVersion","uniCompilerVersionCode"];for(const a in t)Object.hasOwnProperty.call(t,a)&&-1===r.indexOf(a)&&delete t[a];return wt={PLATFORM:n,OS:i,APPID:o,DEVICEID:s,...vt(),...t},{...bt,...wt,locale:e,LOCALE:e}}var xt=function(e,t){let s="";return Object.keys(e).sort().forEach(function(t){e[t]&&(s=s+"&"+t+"="+e[t])}),s=s.slice(1),we(s,t).toString()},St=function(e,t){return new Promise((s,i)=>{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){const s=e.data&&e.data.error&&e.data.error.code||"SYS_ERR",n=e.data&&e.data.error&&e.data.error.message||e.errMsg||"request:fail";return i(new pt({code:s,message:n,requestId:t}))}const n=e.data;if(n.error)return i(new pt({code:n.error.code,message:n.error.message,requestId:t}));n.result=n.data,n.requestId=t,delete n.data,s(n)}}))})},It=function(e){return ve.stringify(ke.parse(e))},Pt=class{constructor(e){["spaceId","clientSecret"].forEach(t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(`${t} required`)}),this.config=Object.assign({},{endpoint:0===e.spaceId.indexOf("mp-")?"https://api.next.bspapp.com":"https://api.bspapp.com"},e),this.config.provider="aliyun",this.config.requestUrl=this.config.endpoint+"/client",this.config.envType=this.config.envType||"public",this.config.accessTokenKey="access_token_"+this.config.spaceId,this.adapter=ft,this._getAccessTokenPromiseHub=new Ue({createPromise:()=>this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then(e=>{if(!e.result||!e.result.accessToken)throw new pt({code:"AUTH_FAILED",message:"获取accessToken失败"});this.setAccessToken(e.result.accessToken)}),retryRule:Re})}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return St(e,this.adapter.request)}requestAuth(e){return this.requestWrapped(e)}request(e,t){return Promise.resolve().then(()=>this.hasAccessToken?t?this.requestWrapped(e):this.requestWrapped(e).catch(t=>new Promise((e,s)=>{!t||"GATEWAY_INVALID_TOKEN"!==t.code&&"InvalidParameter.InvalidToken"!==t.code?s(t):e()}).then(()=>this.getAccessToken()).then(()=>{const t=this.rebuildRequest(e);return this.request(t,!0)})):this.getAccessToken().then(()=>{const t=this.rebuildRequest(e);return this.request(t,!0)}))}rebuildRequest(e){const t=Object.assign({},e);return t.data.token=this.accessToken,t.header["x-basement-token"]=this.accessToken,t.header["x-serverless-sign"]=xt(t.data,this.config.clientSecret),t}setupRequest(e,t){const s=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),i={"Content-Type":"application/json"};return"auth"!==t&&(s.token=this.accessToken,i["x-basement-token"]=this.accessToken),i["x-serverless-sign"]=xt(s,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:s,dataType:"json",header:i}}getAccessToken(){return this._getAccessTokenPromiseHub.exec()}async authorize(){await this.getAccessToken()}callFunction(e){const t={method:"serverless.function.runtime.invoke",params:JSON.stringify({functionTarget:e.name,functionArgs:e.data||{}})};return this.request({...this.setupRequest(t),timeout:e.timeout})}getOSSUploadOptionsFromPath(e){const t={method:"serverless.file.resource.generateProximalSign",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFileToOSS({url:e,formData:t,name:s,filePath:i,fileType:n,onUploadProgress:o}){return new Promise((r,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:s,filePath:i,fileType:n,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?r(e):a(new pt({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new pt({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:s="image",cloudPathAsRealPath:i=!1,onUploadProgress:n,config:o}){if("string"!==Ce(t))throw new pt({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new pt({code:"INVALID_PARAM",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new pt({code:"INVALID_PARAM",message:"cloudPath不合法"});const r=o&&o.envType||this.config.envType;if(i&&("/"!==t[0]&&(t="/"+t),t.indexOf("\\")>-1))throw new pt({code:"INVALID_PARAM",message:"使用cloudPath作为路径时,cloudPath不可包含“\\”"});const a=(await this.getOSSUploadOptionsFromPath({env:r,filename:i?t.split("/").pop():t,fileId:i?t:void 0})).result,c="https://"+a.cdnDomain+"/"+a.ossPath,{securityToken:l,accessKeyId:u,signature:h,host:d,ossPath:p,id:f,policy:g,ossCallbackUrl:m}=a,y={"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:u,Signature:h,host:d,id:f,key:p,policy:g,success_action_status:200};if(l&&(y["x-oss-security-token"]=l),m){const e=JSON.stringify({callbackUrl:m,callbackBody:JSON.stringify({fileId:f,spaceId:this.config.spaceId}),callbackBodyType:"application/json"});y.callback=It(e)}const _={url:"https://"+a.host,formData:y,fileName:"file",name:"file",filePath:e,fileType:s};if(await this.uploadFileToOSS(Object.assign({},_,{onUploadProgress:n})),m)return{success:!0,filePath:e,fileID:c};if((await this.reportOSSUpload({id:f})).success)return{success:!0,filePath:e,fileID:c};throw new pt({code:"UPLOAD_FAILED",message:"文件上传失败"})}getTempFileURL({fileList:e}={}){return new Promise((t,s)=>{Array.isArray(e)&&0!==e.length||s(new pt({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),this.getFileInfo({fileList:e}).then(s=>{t({fileList:e.map((e,t)=>{const i=s.fileList[t];return{fileID:e,tempFileURL:i&&i.url||e}})})})})}async getFileInfo({fileList:e}={}){if(!Array.isArray(e)||0===e.length)throw new pt({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}}},At={init(e){const t=new Pt(e),s={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return s},t.customAuth=t.auth,t}};const Ct="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var Ot,Ft;(Ft=Ot||(Ot={})).local="local",Ft.none="none",Ft.session="session";var Et=function(){},Lt=me(function(e,t){var s;e.exports=(s=_e,function(e){var t=s,i=t.lib,n=i.WordArray,o=i.Hasher,r=t.algo,a=[],c=[];!function(){function t(t){for(var s=e.sqrt(t),i=2;i<=s;i++)if(!(t%i))return!1;return!0}function s(e){return 4294967296*(e-(0|e))|0}for(var i=2,n=0;n<64;)t(i)&&(n<8&&(a[n]=s(e.pow(i,.5))),c[n]=s(e.pow(i,1/3)),n++),i++}();var l=[],u=r.SHA256=o.extend({_doReset:function(){this._hash=new n.init(a.slice(0))},_doProcessBlock:function(e,t){for(var s=this._hash.words,i=s[0],n=s[1],o=s[2],r=s[3],a=s[4],u=s[5],h=s[6],d=s[7],p=0;p<64;p++){if(p<16)l[p]=0|e[t+p];else{var f=l[p-15],g=(f<<25|f>>>7)^(f<<14|f>>>18)^f>>>3,m=l[p-2],y=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;l[p]=g+l[p-7]+y+l[p-16]}var _=i&n^i&o^n&o,w=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),k=d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&u^~a&h)+c[p]+l[p];d=h,h=u,u=a,a=r+k|0,r=o,o=n,n=i,i=k+(w+_)|0}s[0]=s[0]+i|0,s[1]=s[1]+n|0,s[2]=s[2]+o|0,s[3]=s[3]+r|0,s[4]=s[4]+a|0,s[5]=s[5]+u|0,s[6]=s[6]+h|0,s[7]=s[7]+d|0},_doFinalize:function(){var t=this._data,s=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return s[n>>>5]|=128<<24-n%32,s[14+(n+64>>>9<<4)]=e.floor(i/4294967296),s[15+(n+64>>>9<<4)]=i,t.sigBytes=4*s.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=o._createHelper(u),t.HmacSHA256=o._createHmacHelper(u)}(Math),s.SHA256)}),Rt=Lt,Ut=me(function(e,t){e.exports=_e.HmacSHA256});const Dt=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new pt({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,s)=>{e=(e,i)=>e?s(e):t(i)});return e.promise=t,e};function Nt(e){return void 0===e}function $t(e){return"[object Null]"===Object.prototype.toString.call(e)}function Mt(e=""){return e.replace(/([\s\S]+)\s+(请前往云开发AI小助手查看问题:.*)/,"$1")}function jt(e=32){let t="";for(let s=0;s<e;s++)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return t}var qt;!function(e){e.WEB="web",e.WX_MP="wx_mp"}(qt||(qt={}));const Bt={adapter:null,runtime:void 0},Kt=["anonymousUuidKey"];class zt extends Et{constructor(){super(),Bt.adapter.root.tcbObject||(Bt.adapter.root.tcbObject={})}setItem(e,t){Bt.adapter.root.tcbObject[e]=t}getItem(e){return Bt.adapter.root.tcbObject[e]}removeItem(e){delete Bt.adapter.root.tcbObject[e]}clear(){delete Bt.adapter.root.tcbObject}}function Ht(e,t){switch(e){case"local":return t.localStorage||new zt;case"none":return new zt;default:return t.sessionStorage||new zt}}class Vt{constructor(e){if(!this._storage){this._persistence=Bt.adapter.primaryStorage||e.persistence,this._storage=Ht(this._persistence,Bt.adapter);const t=`access_token_${e.env}`,s=`access_token_expire_${e.env}`,i=`refresh_token_${e.env}`,n=`anonymous_uuid_${e.env}`,o=`login_type_${e.env}`,r="device_id",a=`token_type_${e.env}`,c=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:s,refreshTokenKey:i,anonymousUuidKey:n,loginTypeKey:o,userInfoKey:c,deviceIdKey:r,tokenTypeKey:a}}}updatePersistence(e){if(e===this._persistence)return;const t="local"===this._persistence;this._persistence=e;const s=Ht(e,Bt.adapter);for(const i in this.keys){const e=this.keys[i];if(t&&Kt.includes(i))continue;const n=this._storage.getItem(e);Nt(n)||$t(n)||(s.setItem(e,n),this._storage.removeItem(e))}this._storage=s}setStore(e,t,s){if(!this._storage)return;const i={version:s||"localCachev1",content:t},n=JSON.stringify(i);try{this._storage.setItem(e,n)}catch(o){throw o}}getStore(e,t){try{if(!this._storage)return}catch(i){return""}t=t||"localCachev1";const s=this._storage.getItem(e);return s&&s.indexOf(t)>=0?JSON.parse(s).content:""}removeStore(e){this._storage.removeItem(e)}}const Wt={},Jt={};function Gt(e){return Wt[e]}class Yt{constructor(e,t){this.data=t||null,this.name=e}}class Qt extends Yt{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const Xt=new class{constructor(){this._listeners={}}on(e,t){return s=e,i=t,(n=this._listeners)[s]=n[s]||[],n[s].push(i),this;var s,i,n}off(e,t){return function(e,t,s){if(s&&s[e]){const i=s[e].indexOf(t);-1!==i&&s[e].splice(i,1)}}(e,t,this._listeners),this}fire(e,t){if(e instanceof Qt)return console.error(e.error),this;const s="string"==typeof e?new Yt(e,t||{}):e,i=s.name;if(this._listens(i)){s.target=this;const e=this._listeners[i]?[...this._listeners[i]]:[];for(const t of e)t.call(this,s)}return this}_listens(e){return this._listeners[e]&&this._listeners[e].length>0}};function Zt(e,t){Xt.on(e,t)}function es(e,t={}){Xt.fire(e,t)}function ts(e,t){Xt.off(e,t)}const ss="loginStateChanged",is="loginStateExpire",ns="loginTypeChanged",os="anonymousConverted",rs="refreshAccessToken";var as;!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"}(as||(as={}));class cs{constructor(){this._fnPromiseMap=new Map}async run(e,t){let s=this._fnPromiseMap.get(e);return s||(s=new Promise(async(s,i)=>{try{await this._runIdlePromise();const e=t();s(await e)}catch(n){i(n)}finally{this._fnPromiseMap.delete(e)}}),this._fnPromiseMap.set(e,s)),s}_runIdlePromise(){return Promise.resolve()}}class ls{constructor(e){this._singlePromise=new cs,this._cache=Gt(e.env),this._baseURL=`https://${e.env}.ap-shanghai.tcb-api.tencentcloudapi.com`,this._reqClass=new Bt.adapter.reqClass({timeout:e.timeout,timeoutMsg:`请求在${e.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]})}_getDeviceId(){if(this._deviceID)return this._deviceID;const{deviceIdKey:e}=this._cache.keys;let t=this._cache.getStore(e);return"string"==typeof t&&t.length>=16&&t.length<=48||(t=jt(),this._cache.setStore(e,t)),this._deviceID=t,t}async _request(e,t,s={}){const i={"x-request-id":jt(),"x-device-id":this._getDeviceId()};if(s.withAccessToken){const{tokenTypeKey:e}=this._cache.keys,t=await this.getAccessToken(),s=this._cache.getStore(e);i.authorization=`${s} ${t}`}return this._reqClass["get"===s.method?"get":"post"]({url:`${this._baseURL}${e}`,data:t,headers:i})}async _fetchAccessToken(){const{loginTypeKey:e,accessTokenKey:t,accessTokenExpireKey:s,tokenTypeKey:i}=this._cache.keys,n=this._cache.getStore(e);if(n&&n!==as.ANONYMOUS)throw new pt({code:"INVALID_OPERATION",message:"非匿名登录不支持刷新 access token"});const o=await this._singlePromise.run("fetchAccessToken",async()=>(await this._request("/auth/v1/signin/anonymously",{},{method:"post"})).data),{access_token:r,expires_in:a,token_type:c}=o;return this._cache.setStore(i,c),this._cache.setStore(t,r),this._cache.setStore(s,Date.now()+1e3*a),r}isAccessTokenExpired(e,t){let s=!0;return e&&t&&(s=t<Date.now()),s}async getAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t}=this._cache.keys,s=this._cache.getStore(e),i=this._cache.getStore(t);return this.isAccessTokenExpired(s,i)?this._fetchAccessToken():s}async refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,loginTypeKey:s}=this._cache.keys;return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.setStore(s,as.ANONYMOUS),this.getAccessToken()}async getUserInfo(){return this._singlePromise.run("getUserInfo",async()=>(await this._request("/auth/v1/user/me",{},{withAccessToken:!0,method:"get"})).data)}}const us=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],hs={"X-SDK-Version":"1.3.5"};function ds(e,t,s){const i=e[t];e[t]=function(t){const n={},o={};s.forEach(s=>{const{data:i,headers:r}=s.call(e,t);Object.assign(n,i),Object.assign(o,r)});const r=t.data;return r&&(()=>{var e;if(e=r,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...r,...n};else for(const t in n)r.append(t,n[t])})(),t.headers={...t.headers||{},...o},i.call(e,t)}}function ps(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...hs,"x-seqid":e}}}class fs{constructor(e={}){var t;this.config=e,this._reqClass=new Bt.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=Gt(this.config.env),this._localCache=(t=this.config.env,Jt[t]),this.oauth=new ls(this.config),ds(this._reqClass,"post",[ps]),ds(this._reqClass,"upload",[ps]),ds(this._reqClass,"download",[ps])}async post(e){return await this._reqClass.post(e)}async upload(e){return await this._reqClass.upload(e)}async download(e){return await this._reqClass.download(e)}async refreshAccessToken(){let e,t;this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken());try{e=await this._refreshAccessTokenPromise}catch(s){t=s}if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return e}async _refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:s,loginTypeKey:i,anonymousUuidKey:n}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);let o=this._cache.getStore(s);if(!o)throw new pt({message:"未登录CloudBase"});const r={refresh_token:o},a=await this.request("auth.fetchAccessTokenWithRefreshToken",r);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(i)===as.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){const e=this._cache.getStore(n),t=this._cache.getStore(s),i=await this.send("auth.signInAnonymously",{anonymous_uuid:e,refresh_token:t});return this.setRefreshToken(i.refresh_token),this._refreshAccessToken()}es(is),this._cache.removeStore(s)}throw new pt({code:a.data.code,message:`刷新access token失败:${a.data.code}`})}if(a.data.access_token)return es(rs),this._cache.setStore(e,a.data.access_token),this._cache.setStore(t,a.data.access_token_expire+Date.now()),{accessToken:a.data.access_token,accessTokenExpire:a.data.access_token_expire};a.data.refresh_token&&(this._cache.removeStore(s),this._cache.setStore(s,a.data.refresh_token),this._refreshAccessToken())}async getAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:s}=this._cache.keys;if(!this._cache.getStore(s))throw new pt({message:"refresh token不存在,登录状态异常"});let i=this._cache.getStore(e),n=this._cache.getStore(t),o=!0;return this._shouldRefreshAccessTokenHook&&!(await this._shouldRefreshAccessTokenHook(i,n))&&(o=!1),(!i||!n||n<Date.now())&&o?this.refreshAccessToken():{accessToken:i,accessTokenExpire:n}}async request(e,t,s){const i=`x-tcb-trace_${this.config.env}`;let n="application/x-www-form-urlencoded";const o={action:e,env:this.config.env,dataVersion:"2019-08-16",...t};let r;if(-1===us.indexOf(e)&&(this._cache.keys,o.access_token=await this.oauth.getAccessToken()),"storage.uploadFile"===e){r=new FormData;for(let e in r)r.hasOwnProperty(e)&&void 0!==r[e]&&r.append(e,o[e]);n="multipart/form-data"}else{n="application/json",r={};for(let e in o)void 0!==o[e]&&(r[e]=o[e])}let a={headers:{"content-type":n}};s&&s.timeout&&(a.timeout=s.timeout),s&&s.onUploadProgress&&(a.onUploadProgress=s.onUploadProgress);const c=this._localCache.getStore(i);c&&(a.headers["X-TCB-Trace"]=c);const{parse:l,inQuery:u,search:h}=t;let d={env:this.config.env};l&&(d.parse=!0),u&&(d={...u,...d});let p=function(e,t,s={}){const i=/\?/.test(t);let n="";for(let o in s)""===n?!i&&(t+="?"):n+="&",n+=`${o}=${encodeURIComponent(s[o])}`;return/^http(s)?\:\/\//.test(t+=n)?t:`${e}${t}`}(Ct,"//tcb-api.tencentcloudapi.com/web",d);h&&(p+=h);const f=await this.post({url:p,data:r,...a}),g=f.header&&f.header["x-tcb-trace"];if(g&&this._localCache.setStore(i,g),200!==Number(f.status)&&200!==Number(f.statusCode)||!f.data)throw new pt({code:"NETWORK_ERROR",message:"network request error"});return f}async send(e,t={},s={}){const i=await this.request(e,t,{...s,onUploadProgress:t.onUploadProgress});if(("ACCESS_TOKEN_DISABLED"===i.data.code||"ACCESS_TOKEN_EXPIRED"===i.data.code)&&-1===us.indexOf(e)){await this.oauth.refreshAccessToken();const i=await this.request(e,t,{...s,onUploadProgress:t.onUploadProgress});if(i.data.code)throw new pt({code:i.data.code,message:Mt(i.data.message)});return i.data}if(i.data.code)throw new pt({code:i.data.code,message:Mt(i.data.message)});return i.data}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:s,refreshTokenKey:i}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(s),this._cache.setStore(i,e)}}const gs={};function ms(e){return gs[e]}class ys{constructor(e){this.config=e,this._cache=Gt(e.env),this._request=ms(e.env)}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:s,refreshTokenKey:i}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(s),this._cache.setStore(i,e)}setAccessToken(e,t){const{accessTokenKey:s,accessTokenExpireKey:i}=this._cache.keys;this._cache.setStore(s,e),this._cache.setStore(i,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 _s{constructor(e){if(!e)throw new pt({code:"PARAM_ERROR",message:"envId is not defined"});this._envId=e,this._cache=Gt(this._envId),this._request=ms(this._envId),this.setUserInfo()}linkWithTicket(e){if("string"!=typeof e)throw new pt({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 pt({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:s}=e;return s.forEach(e=>{e.wxOpenId&&e.wxPublicId&&(t=!0)}),{users:s,hasPrimaryUid:t}}setPrimaryUid(e){return this._request.send("auth.setPrimaryUid",{uid:e})}unlink(e){return this._request.send("auth.unlink",{platform:e})}async update(e){const{nickName:t,gender:s,avatarUrl:i,province:n,country:o,city:r}=e,{data:a}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:s,avatarUrl:i,province:n,country:o,city:r});this.setLocalUserInfo(a)}async refresh(){const e=await this._request.oauth.getUserInfo();return this.setLocalUserInfo(e),e}setUserInfo(){const{userInfoKey:e}=this._cache.keys,t=this._cache.getStore(e);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl"].forEach(e=>{this[e]=t[e]}),this.location={country:t.country,province:t.province,city:t.city}}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e),this.setUserInfo()}}class ws{constructor(e){if(!e)throw new pt({code:"PARAM_ERROR",message:"envId is not defined"});this._cache=Gt(e);const{refreshTokenKey:t,accessTokenKey:s,accessTokenExpireKey:i}=this._cache.keys,n=this._cache.getStore(t),o=this._cache.getStore(s),r=this._cache.getStore(i);this.credential={refreshToken:n,accessToken:o,accessTokenExpire:r},this.user=new _s(e)}get isAnonymousAuth(){return this.loginType===as.ANONYMOUS}get isCustomAuth(){return this.loginType===as.CUSTOM}get isWeixinAuth(){return this.loginType===as.WECHAT||this.loginType===as.WECHAT_OPEN||this.loginType===as.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class ks extends ys{async signIn(){this._cache.updatePersistence("local"),await this._request.oauth.getAccessToken(),es(ss),es(ns,{env:this.config.env,loginType:as.ANONYMOUS,persistence:"local"});const e=new ws(this.config.env);return await e.user.refresh(),e}async linkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:s}=this._cache.keys,i=this._cache.getStore(t),n=this._cache.getStore(s),o=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:i,refresh_token:n,ticket:e});if(o.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(o.refresh_token),await this._request.refreshAccessToken(),es(os,{env:this.config.env}),es(ns,{loginType:as.CUSTOM,persistence:"local"}),{credential:{refreshToken:o.refresh_token}};throw new pt({message:"匿名转化失败"})}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:s}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(s,as.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class vs extends ys{async signIn(e){if("string"!=typeof e)throw new pt({code:"PARAM_ERROR",message:"ticket must be a string"});const{refreshTokenKey:t}=this._cache.keys,s=await this._request.send("auth.signInWithTicket",{ticket:e,refresh_token:this._cache.getStore(t)||""});if(s.refresh_token)return this.setRefreshToken(s.refresh_token),await this._request.refreshAccessToken(),es(ss),es(ns,{env:this.config.env,loginType:as.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new ws(this.config.env);throw new pt({message:"自定义登录失败"})}}class bs extends ys{async signIn(e,t){if("string"!=typeof e)throw new pt({code:"PARAM_ERROR",message:"email must be a string"});const{refreshTokenKey:s}=this._cache.keys,i=await this._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(s)||""}),{refresh_token:n,access_token:o,access_token_expire:r}=i;if(n)return this.setRefreshToken(n),o&&r?this.setAccessToken(o,r):await this._request.refreshAccessToken(),await this.refreshUserInfo(),es(ss),es(ns,{env:this.config.env,loginType:as.EMAIL,persistence:this.config.persistence}),new ws(this.config.env);throw i.code?new pt({code:i.code,message:`邮箱登录失败: ${i.message}`}):new pt({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 Ts extends ys{async signIn(e,t){if("string"!=typeof e)throw new pt({code:"PARAM_ERROR",message:"username must be a string"});"string"!=typeof t&&(t="",console.warn("password is empty"));const{refreshTokenKey:s}=this._cache.keys,i=await this._request.send("auth.signIn",{loginType:as.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(s)||""}),{refresh_token:n,access_token_expire:o,access_token:r}=i;if(n)return this.setRefreshToken(n),r&&o?this.setAccessToken(r,o):await this._request.refreshAccessToken(),await this.refreshUserInfo(),es(ss),es(ns,{env:this.config.env,loginType:as.USERNAME,persistence:this.config.persistence}),new ws(this.config.env);throw i.code?new pt({code:i.code,message:`用户名密码登录失败: ${i.message}`}):new pt({message:"用户名密码登录失败"})}}class xs{constructor(e){this.config=e,this._cache=Gt(e.env),this._request=ms(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),Zt(ns,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 ks(this.config)}customAuthProvider(){return new vs(this.config)}emailAuthProvider(){return new bs(this.config)}usernameAuthProvider(){return new Ts(this.config)}async signInAnonymously(){return new ks(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new bs(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new Ts(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){return this._anonymousAuthProvider||(this._anonymousAuthProvider=new ks(this.config)),Zt(os,this._onAnonymousConverted),await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===as.ANONYMOUS)throw new pt({message:"匿名用户不支持登出操作"});const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:s}=this._cache.keys,i=this._cache.getStore(e);if(!i)return;const n=await this._request.send("auth.logout",{refresh_token:i});return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(s),es(ss),es(ns,{env:this.config.env,loginType:as.NULL,persistence:this.config.persistence}),n}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){Zt(ss,()=>{const t=this.hasLoginState();e.call(this,t)});const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){Zt(is,e.bind(this))}onAccessTokenRefreshed(e){Zt(rs,e.bind(this))}onAnonymousConverted(e){Zt(os,e.bind(this))}onLoginTypeChanged(e){Zt(ns,()=>{const t=this.hasLoginState();e.call(this,t)})}async getAccessToken(){return{accessToken:(await this._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{accessTokenKey:e,accessTokenExpireKey:t}=this._cache.keys,s=this._cache.getStore(e),i=this._cache.getStore(t);return this._request.oauth.isAccessTokenExpired(s,i)?null:new ws(this.config.env)}async isUsernameRegistered(e){if("string"!=typeof e)throw new pt({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 vs(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,s=this._cache.getStore(e);return{"x-cloudbase-credentials":this._cache.getStore(t)+"/@@/"+s}}_onAnonymousConverted(e){const{env:t}=e.data;t===this.config.env&&this._cache.updatePersistence(this.config.persistence)}_onLoginTypeChanged(e){const{loginType:t,persistence:s,env:i}=e.data;i===this.config.env&&(this._cache.updatePersistence(s),this._cache.setStore(this._cache.keys.loginTypeKey,t))}}const Ss=function(e,t){t=t||Dt();const s=ms(this.config.env),{cloudPath:i,filePath:n,onUploadProgress:o,fileType:r="image"}=e;return s.send("storage.getUploadMetadata",{path:i}).then(e=>{const{data:{url:a,authorization:c,token:l,fileId:u,cosFileId:h},requestId:d}=e,p={key:i,signature:c,"x-cos-meta-fileid":h,success_action_status:"201","x-cos-security-token":l};s.upload({url:a,data:p,file:n,name:i,fileType:r,onUploadProgress:o}).then(e=>{201===e.statusCode?t(null,{fileID:u,requestId:d}):t(new pt({code:"STORAGE_REQUEST_FAIL",message:`STORAGE_REQUEST_FAIL: ${e.data}`}))}).catch(e=>{t(e)})}).catch(e=>{t(e)}),t.promise},Is=function(e,t){t=t||Dt();const s=ms(this.config.env),{cloudPath:i}=e;return s.send("storage.getUploadMetadata",{path:i}).then(e=>{t(null,e)}).catch(e=>{t(e)}),t.promise},Ps=function({fileList:e},t){if(t=t||Dt(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(let i of e)if(!i||"string"!=typeof i)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};const s={fileid_list:e};return ms(this.config.env).send("storage.batchDeleteFile",s).then(e=>{e.code?t(null,e):t(null,{fileList:e.data.delete_list,requestId:e.requestId})}).catch(e=>{t(e)}),t.promise},As=function({fileList:e},t){t=t||Dt(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});let s=[];for(let n of e)"object"==typeof n?(n.hasOwnProperty("fileID")&&n.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),s.push({fileid:n.fileID,max_age:n.maxAge})):"string"==typeof n?s.push({fileid:n}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});const i={file_list:s};return ms(this.config.env).send("storage.batchGetDownloadUrl",i).then(e=>{e.code?t(null,e):t(null,{fileList:e.data.download_list,requestId:e.requestId})}).catch(e=>{t(e)}),t.promise},Cs=async function({fileID:e},t){const s=(await As.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==s.code)return t?t(s):new Promise(e=>{e(s)});const i=ms(this.config.env);let n=s.download_url;if(n=encodeURI(n),!t)return i.download({url:n});t(await i.download({url:n}))},Os=function({name:e,data:t,query:s,parse:i,search:n,timeout:o},r){const a=r||Dt();let c;try{c=t?JSON.stringify(t):""}catch(u){return Promise.reject(u)}if(!e)return Promise.reject(new pt({code:"PARAM_ERROR",message:"函数名不能为空"}));const l={inQuery:s,parse:i,search:n,function_name:e,request_data:c};return ms(this.config.env).send("functions.invokeFunction",l,{timeout:o}).then(e=>{if(e.code)a(null,e);else{let s=e.data.response_data;if(i)a(null,{result:s,requestId:e.requestId});else try{s=JSON.parse(e.data.response_data),a(null,{result:s,requestId:e.requestId})}catch(t){a(new pt({message:"response data must be json"}))}}return a.promise}).catch(e=>{a(e)}),a.promise},Fs={timeout:15e3,persistence:"session"},Es=6e5,Ls={};class Rs{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(Bt.adapter||(this.requestClient=new Bt.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...Fs,...e},!0){case this.config.timeout>Es:console.warn("timeout大于可配置上限[10分钟],已重置为上限数值"),this.config.timeout=Es;break;case this.config.timeout<100:console.warn("timeout小于可配置下限[100ms],已重置为下限数值"),this.config.timeout=100}return new Rs(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||Bt.adapter.primaryStorage||Fs.persistence;var s;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;Wt[t]=new Vt(e),Jt[t]=new Vt({...e,persistence:"local"})}(this.config),s=this.config,gs[s.env]=new fs(s),this.authObj=new xs(this.config),this.authObj}on(e,t){return Zt.apply(this,[e,t])}off(e,t){return ts.apply(this,[e,t])}callFunction(e,t){return Os.apply(this,[e,t])}deleteFile(e,t){return Ps.apply(this,[e,t])}getTempFileURL(e,t){return As.apply(this,[e,t])}downloadFile(e,t){return Cs.apply(this,[e,t])}uploadFile(e,t){return Ss.apply(this,[e,t])}getUploadMetadata(e,t){return Is.apply(this,[e,t])}registerExtension(e){Ls[e.name]=e}async invokeExtension(e,t){const s=Ls[e];if(!s)throw new pt({message:`扩展${e} 必须先注册`});return await s.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:s}=function(e){const t=(s=e,"[object Array]"===Object.prototype.toString.call(s)?e:[e]);var s;for(const i of t){const{isMatch:e,genAdapter:t,runtime:s}=i;if(e())return{adapter:t(),runtime:s}}}(e)||{};t&&(Bt.adapter=t),s&&(Bt.runtime=s)}}var Us=new Rs;function Ds(e,t,s){void 0===s&&(s={});var i=/\?/.test(t),n="";for(var o in s)""===n?!i&&(t+="?"):n+="&",n+=o+"="+encodeURIComponent(s[o]);return/^http(s)?:\/\//.test(t+=n)?t:""+e+t}class Ns{get(e){const{url:t,data:s,headers:i,timeout:n}=e;return new Promise((e,o)=>{ft.request({url:Ds("https:",t),data:s,method:"GET",header:i,timeout:n,success(t){e(t)},fail(e){o(e)}})})}post(e){const{url:t,data:s,headers:i,timeout:n}=e;return new Promise((e,o)=>{ft.request({url:Ds("https:",t),data:s,method:"POST",header:i,timeout:n,success(t){e(t)},fail(e){o(e)}})})}upload(e){return new Promise((t,s)=>{const{url:i,file:n,data:o,headers:r,fileType:a}=e,c=ft.uploadFile({url:Ds("https:",i),name:"file",formData:Object.assign({},o),filePath:n,fileType:a,header:r,success(e){const s={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&o.success_action_status&&(s.statusCode=parseInt(o.success_action_status,10)),t(s)},fail(e){s(new Error(e.errMsg||"uploadFile:fail"))}});"function"==typeof e.onUploadProgress&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate(t=>{e.onUploadProgress({loaded:t.totalBytesSent,total:t.totalBytesExpectedToSend})})})}}const $s={setItem(e,t){ft.setStorageSync(e,t)},getItem:e=>ft.getStorageSync(e),removeItem(e){ft.removeStorageSync(e)},clear(){ft.clearStorageSync()}};var Ms={genAdapter:function(){return{root:{},reqClass:Ns,localStorage:$s,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};Us.useAdapters(Ms);const js=Us,qs=js.init;js.init=function(e){e.env=e.spaceId;const t=qs.call(this,e);t.config.provider="tencent",t.config.spaceId=e.spaceId;const s=t.auth;return t.auth=function(e){const t=s.call(this,e);return["linkAndRetrieveDataWithTicket","signInAnonymously","signOut","getAccessToken","getLoginState","signInWithTicket","getUserInfo"].forEach(e=>{var s;t[e]=(s=t[e],function(e){e=e||{};const{success:t,fail:i,complete:n}=dt(e);if(!(t||i||n))return s.call(this,e);s.call(this,e).then(e=>{t&&t(e),n&&n(e)},e=>{i&&i(e),n&&n(e)})}).bind(t)}),t},t.customAuth=t.auth,t};var Bs=js;async function Ks(e,t){const s=`http://${e}:${t}/system/ping`;try{const e=await(i={url:s,timeout:500},new Promise((e,t)=>{ft.request({...i,success(t){e(t)},fail(e){t(e)}})}));return!(!e.data||0!==e.data.code)}catch(n){return!1}var i}const zs={"serverless.file.resource.generateProximalSign":"storage/generate-proximal-sign","serverless.file.resource.report":"storage/report","serverless.file.resource.delete":"storage/delete","serverless.file.resource.getTempFileURL":"storage/get-temp-file-url"};var Hs=class{constructor(e){if(["spaceId","clientSecret"].forEach(t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(`${t} required`)}),!e.endpoint)throw new Error("集群空间未配置ApiEndpoint,配置后需要重新关联服务空间后生效");this.config=Object.assign({},e),this.config.provider="dcloud",this.config.requestUrl=this.config.endpoint+"/client",this.config.envType=this.config.envType||"public",this.adapter=ft}async request(e,t=!0){return e=this.setupRequest(e),Promise.resolve().then(()=>St(e,this.adapter.request))}requestLocal(e){return new Promise((t,s)=>{this.adapter.request(Object.assign(e,{complete(e){if(e||(e={}),!e.statusCode||e.statusCode>=400){const t=e.data&&e.data.code||"SYS_ERR",i=e.data&&e.data.message||"request:fail";return s(new pt({code:t,message:i}))}t({success:!0,result:e.data})}}))})}setupRequest(e){const t=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};s["x-serverless-sign"]=xt(t,this.config.clientSecret);const i=Tt();s["x-client-info"]=encodeURIComponent(JSON.stringify(i));const{token:n}=mt();return s["x-client-token"]=n,{url:this.config.requestUrl,method:"POST",data:t,dataType:"json",header:JSON.parse(JSON.stringify(s))}}async setupLocalRequest(e){const t=Tt(),{token:s}=mt(),i=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now(),clientInfo:t,token:s}),{address:n,servePort:o}=this.__dev__&&this.__dev__.debugInfo||{},{address:r}=await async function(e,t){let s;for(let i=0;i<e.length;i++){const n=e[i];if(await Ks(n,t)){s=n;break}}return{address:s,port:t}}(n,o);return{url:`http://${r}:${o}/${zs[e.method]}`,method:"POST",data:i,dataType:"json",header:JSON.parse(JSON.stringify({"Content-Type":"application/json"}))}}callFunction(e){const t={method:"serverless.function.runtime.invoke",params:JSON.stringify({functionTarget:e.name,functionArgs:e.data||{}})};return this.request(t,!1)}getUploadFileOptions(e){const t={method:"serverless.file.resource.generateProximalSign",params:JSON.stringify(e)};return this.request(t)}reportUploadFile(e){const t={method:"serverless.file.resource.report",params:JSON.stringify(e)};return this.request(t)}uploadFile({filePath:e,cloudPath:t,fileType:s="image",onUploadProgress:i}){if(!t)throw new pt({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});let n;return this.getUploadFileOptions({cloudPath:t}).then(t=>{const{url:o,formData:r,name:a}=t.result;return n=t.result.fileUrl,new Promise((t,n)=>{const c=this.adapter.uploadFile({url:o,formData:r,name:a,filePath:e,fileType:s,success(e){e&&e.statusCode<400?t(e):n(new pt({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){n(new pt({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})})})}).then(()=>this.reportUploadFile({cloudPath:t})).then(t=>new Promise((s,i)=>{t.success?s({success:!0,filePath:e,fileID:n}):i(new pt({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({fileList:e})};return this.request(t).then(e=>{if(e.success)return e.result;throw new pt({code:"DELETE_FILE_FAILED",message:"删除文件失败"})})}getTempFileURL({fileList:e,maxAge:t}={}){if(!Array.isArray(e)||0===e.length)throw new pt({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"});const s={method:"serverless.file.resource.getTempFileURL",params:JSON.stringify({fileList:e,maxAge:t})};return this.request(s).then(e=>{if(e.success)return{fileList:e.result.fileList.map(e=>({fileID:e.fileID,tempFileURL:e.tempFileURL}))};throw new pt({code:"GET_TEMP_FILE_URL_FAILED",message:"获取临时文件链接失败"})})}},Vs={init(e){const t=new Hs(e),s={signInAnonymously:function(){return Promise.resolve()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return s},t.customAuth=t.auth,t}},Ws=me(function(e,t){e.exports=_e.enc.Hex});function Js(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function Gs(e="",t={}){const{data:s,functionName:i,method:n,headers:o,signHeaderKeys:r=[],config:a}=t,c=String(Date.now()),l=Js(),u=Object.assign({},o,{"x-from-app-id":a.spaceAppId,"x-from-env-id":a.spaceId,"x-to-env-id":a.spaceId,"x-from-instance-id":c,"x-from-function-name":i,"x-client-timestamp":c,"x-alipay-source":"client","x-request-id":l,"x-alipay-callid":l,"x-trace-id":l}),h=["x-from-app-id","x-from-env-id","x-to-env-id","x-from-instance-id","x-from-function-name","x-client-timestamp"].concat(r),[d="",p=""]=e.split("?")||[],f=function(e){const t="HMAC-SHA256",s=e.signedHeaders.join(";"),i=e.signedHeaders.map(t=>`${t.toLowerCase()}:${e.headers[t]}\n`).join(""),n=Rt(e.body).toString(Ws),o=`${e.method.toUpperCase()}\n${e.path}\n${e.query}\n${i}\n${s}\n${n}\n`,r=Rt(o).toString(Ws),a=`${t}\n${e.timestamp}\n${r}\n`,c=Ut(a,e.secretKey).toString(Ws);return`${t} Credential=${e.secretId}, SignedHeaders=${s}, Signature=${c}`}({path:d,query:p,method:n,headers:u,timestamp:c,body:JSON.stringify(s),secretId:a.accessKey,secretKey:a.secretKey,signedHeaders:h.sort()});return{url:`${a.endpoint}${e}`,headers:Object.assign({},u,{Authorization:f})}}function Ys({url:e,data:t,method:s="POST",headers:i={},timeout:n}){return new Promise((o,r)=>{ft.request({url:e,method:s,data:"object"==typeof t?JSON.stringify(t):t,header:i,dataType:"json",timeout:n,complete:(e={})=>{const t=i["x-trace-id"]||"";if(!e.statusCode||e.statusCode>=400){const{message:s,errMsg:i,trace_id:n}=e.data||{};return r(new pt({code:"SYS_ERR",message:s||i||"request:fail",requestId:n||t}))}o({status:e.statusCode,data:e.data,headers:e.header,requestId:t})}})})}function Qs(e,t){const{path:s,data:i,method:n="GET"}=e,{url:o,headers:r}=Gs(s,{functionName:"",data:i,method:n,headers:{"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":Date.now()+6e4},signHeaderKeys:["x-data-api-type","x-expire-timestamp"],config:t});return Ys({url:o,data:i,method:n,headers:r}).then(e=>{const t=e.data||{};if(!t.success)throw new pt({code:e.errCode,message:e.errMsg,requestId:e.requestId});return t.data||{}}).catch(e=>{throw new pt({code:e.errCode,message:e.errMsg,requestId:e.requestId})})}function Xs(e=""){const t=e.trim().replace(/^cloud:\/\//,""),s=t.indexOf("/");if(s<=0)throw new pt({code:"INVALID_PARAM",message:"fileID不合法"});const i=t.substring(0,s),n=t.substring(s+1);return i!==this.config.spaceId&&console.warn("file ".concat(e," does not belong to env ").concat(this.config.spaceId)),n}function Zs(e=""){return"cloud://".concat(this.config.spaceId,"/").concat(e.replace(/^\/+/,""))}class ei{constructor(e){this.config=e}signedURL(e,t={}){const s=`/ws/function/${e}`,i=this.config.wsEndpoint.replace(/^ws(s)?:\/\//,""),n=Object.assign({},t,{accessKeyId:this.config.accessKey,signatureNonce:Js(),timestamp:""+Date.now()}),o=[s,["accessKeyId","authorization","signatureNonce","timestamp"].sort().map(function(e){return n[e]?"".concat(e,"=").concat(n[e]):null}).filter(Boolean).join("&"),`host:${i}`].join("\n"),r=["HMAC-SHA256",Rt(o).toString(Ws)].join("\n"),a=Ut(r,this.config.secretKey).toString(Ws),c=Object.keys(n).map(e=>`${e}=${encodeURIComponent(n[e])}`).join("&");return`${this.config.wsEndpoint}${s}?${c}&signature=${a}`}}var ti=class{constructor(e){if(["spaceId","spaceAppId","accessKey","secretKey"].forEach(t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(`${t} required`)}),e.endpoint){if("string"!=typeof e.endpoint)throw new Error("endpoint must be string");if(!/^https:\/\//.test(e.endpoint))throw new Error("endpoint must start with https://");e.endpoint=e.endpoint.replace(/\/$/,"")}this.config=Object.assign({},e,{endpoint:e.endpoint||`https://${e.spaceId}.api-hz.cloudbasefunction.cn`,wsEndpoint:e.wsEndpoint||`wss://${e.spaceId}.api-hz.cloudbasefunction.cn`}),this._websocket=new ei(this.config)}callFunction(e){return function(e,t){const{name:s,data:i,async:n=!1,timeout:o}=e,r="POST",a={"x-to-function-name":s};n&&(a["x-function-invoke-type"]="async");const{url:c,headers:l}=Gs("/functions/invokeFunction",{functionName:s,data:i,method:r,headers:a,signHeaderKeys:["x-to-function-name"],config:t});return Ys({url:c,data:i,method:r,headers:l,timeout:o}).then(e=>{let t=0;if(n){const s=e.data||{};t="200"===s.errCode?0:s.errCode,e.data=s.data||{},e.errMsg=s.errMsg}if(0!==t)throw new pt({code:t,message:e.errMsg,requestId:e.requestId});return{errCode:t,success:0===t,requestId:e.requestId,result:e.data}}).catch(e=>{throw new pt({code:e.errCode,message:e.errMsg,requestId:e.requestId})})}(e,this.config)}uploadFileToOSS({url:e,filePath:t,fileType:s,formData:i,onUploadProgress:n}){return new Promise((o,r)=>{const a=ft.uploadFile({url:e,filePath:t,fileType:s,formData:i,name:"file",success(e){e&&e.statusCode<400?o(e):r(new pt({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){r(new pt({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof n&&a&&"function"==typeof a.onProgressUpdate&&a.onProgressUpdate(e=>{n({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})})})}async uploadFile({filePath:e,cloudPath:t="",fileType:s="image",onUploadProgress:i}){if("string"!==Ce(t))throw new pt({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new pt({code:"INVALID_PARAM",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new pt({code:"INVALID_PARAM",message:"cloudPath不合法"});const n=await Qs({path:"/".concat(t.replace(/^\//,""),"?post_url")},this.config),{file_id:o,upload_url:r,form_data:a}=n,c=a&&a.reduce((e,t)=>(e[t.key]=t.value,e),{});return this.uploadFileToOSS({url:r,filePath:e,fileType:s,formData:c,onUploadProgress:i}).then(()=>({fileID:o}))}async getTempFileURL({fileList:e}){return new Promise((t,s)=>{(!e||e.length<0)&&t({code:"INVALID_PARAM",message:"fileList不能为空数组"}),e.length>50&&t({code:"INVALID_PARAM",message:"fileList数组长度不能超过50"});const i=[];for(const o of e){let e;"string"!==Ce(o)&&t({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"});try{e=Xs.call(this,o)}catch(n){console.warn(n.errCode,n.errMsg),e=o}i.push({file_id:e,expire:600})}Qs({path:"/?download_url",data:{file_list:i},method:"POST"},this.config).then(e=>{const{file_list:s=[]}=e;t({fileList:s.map(e=>({fileID:Zs.call(this,e.file_id),tempFileURL:e.download_url}))})}).catch(e=>s(e))})}async connectWebSocket(e){const{name:t,query:s}=e;return ft.connectSocket({url:this._websocket.signedURL(t,s),complete:()=>{}})}},si={init:e=>{e.provider="alipay";const t=new ti(e);return t.auth=function(){return{signInAnonymously:function(){return Promise.resolve()},getLoginState:function(){return Promise.resolve(!0)}}},t}};function ii({data:e}){let t;t=Tt();const s=JSON.parse(JSON.stringify(e||{}));if(Object.assign(s,{clientInfo:t}),!s.uniIdToken){const{token:e}=mt();e&&(s.uniIdToken=e)}return s}const ni=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var oi=/[\\^$.*+?()[\]{}|]/g,ri=RegExp(oi.source);function ai(e,t,s){return e.replace(new RegExp((i=t)&&ri.test(i)?i.replace(oi,"\\$&"):i,"g"),s);var i}const ci="request",li="response",ui="both",hi="_globalUniCloudStatus",di={code:2e4,message:"System error"},pi={code:20101,message:"Invalid client"};function fi(e){const{errSubject:t,subject:s,errCode:i,errMsg:n,code:o,message:r,cause:a}=e||{};return new pt({subject:t||s||"uni-secure-network",code:i||o||di.code,message:n||r,cause:a})}let gi;function mi({secretType:e}={}){return e===ci||e===li||e===ui}function yi({functionName:e,result:t,logPvd:s}){}function _i(e){const t=e.callFunction,s=function(s){const i=s.name;s.data=ii.call(e,{data:s.data});const n={aliyun:"aliyun",tencent:"tcb",tcb:"tcb",alipay:"alipay",dcloud:"dcloud"}[this.config.provider],o=mi(s)||false;return t.call(this,s).then(e=>(e.errCode=0,!o&&yi.call(this,{functionName:i,result:e,logPvd:n}),Promise.resolve(e)),e=>(!o&&yi.call(this,{functionName:i,result:e,logPvd:n}),e&&e.message&&(e.message=function({message:e="",extraInfo:t={},formatter:s=[]}={}){for(let i=0;i<s.length;i++){const{rule:n,content:o,mode:r}=s[i],a=e.match(n);if(!a)continue;let c=o;for(let e=1;e<a.length;e++)c=ai(c,`{$${e}}`,a[e]);for(const e in t)c=ai(c,`{${e}}`,t[e]);return"replace"===r?c:e+c}return e}({message:`[${s.name}]: ${e.message}`,formatter:ni,extraInfo:{functionName:i}})),Promise.reject(e)))};e.callFunction=function(t){const{provider:i,spaceId:n}=e.config,o=t.name;let r,a;return t.data=t.data||{},r=s,r=r.bind(e),a=mi(t)?new gi({secretType:t.secretType,uniCloudIns:e}).wrapEncryptDataCallFunction(s.bind(e))(t):function({provider:e,spaceId:t,functionName:s}={}){const{appId:i,uniPlatform:n,osName:o}=kt();let r=n;"app"===n&&(r=o);const a=function({provider:e,spaceId:t}={}){const s=$e;if(!s)return{};e=function(e){return"tencent"===e?"tcb":e}(e);const i=s.find(s=>s.provider===e&&s.spaceId===t);return i&&i.config}({provider:e,spaceId:t});if(!a||!a.accessControl||!a.accessControl.enable)return!1;const c=a.accessControl.function||{},l=Object.keys(c);if(0===l.length)return!0;const u=function(e,t){let s,i,n;for(let o=0;o<e.length;o++){const r=e[o];r!==t?"*"!==r?r.split(",").map(e=>e.trim()).indexOf(t)>-1&&(i=r):n=r:s=r}return s||i||n}(l,s);if(!u)return!1;if((c[u]||[]).find((e={})=>e.appId===i&&(e.platform||"").toLowerCase()===r.toLowerCase()))return!0;throw console.error(`此应用[appId: ${i}, platform: ${r}]不在云端配置的允许访问的应用列表内,参考:https://uniapp.dcloud.net.cn/uniCloud/secure-network.html#verify-client`),fi(pi)}({provider:i,spaceId:n,functionName:o})?new gi({secretType:t.secretType,uniCloudIns:e}).wrapVerifyClientCallFunction(s.bind(e))(t):r(t),Object.defineProperty(a,"result",{get:()=>(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),a.then(e=>e)}}gi=class{constructor(){throw fi({message:`Platform ${Me} is not supported by secure network`})}};const wi=Symbol("CLIENT_DB_INTERNAL");function ki(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=wi,e.inspect=null,e.__v_raw=void 0,new Proxy(e,{get(e,s,i){if("_uniClient"===s)return null;if("symbol"==typeof s)return e[s];if(s in e||"string"!=typeof s){const t=e[s];return"function"==typeof t?t.bind(e):t}return t.get(e,s,i)}})}function vi(e){return{on:(t,s)=>{e[t]=e[t]||[],e[t].indexOf(s)>-1||e[t].push(s)},off:(t,s)=>{e[t]=e[t]||[];const i=e[t].indexOf(s);-1!==i&&e[t].splice(i,1)}}}const bi=["db.Geo","db.command","command.aggregate"];function Ti(e,t){return bi.indexOf(`${e}.${t}`)>-1}function xi(e){switch(Ce(e=gt(e))){case"array":return e.map(e=>xi(e));case"object":return e._internalType===wi||Object.keys(e).forEach(t=>{e[t]=xi(e[t])}),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:return e}}function Si(e){return e&&e.content&&e.content.$method}class Ii{constructor(e,t,s){this.content=e,this.prevStage=t||null,this.udb=null,this._database=s}toJSON(){let e=this;const t=[e.content];for(;e.prevStage;)e=e.prevStage,t.push(e.content);return{$db:t.reverse().map(e=>({$method:e.$method,$param:xi(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=Si(e),s=Si(e.prevStage);if("aggregate"===t&&"collection"===s||"pipeline"===t)return!0;e=e.prevStage}return!1}get isCommand(){let e=this;for(;e;){if("command"===Si(e))return!0;e=e.prevStage}return!1}get isAggregateCommand(){let e=this;for(;e;){const t=Si(e),s=Si(e.prevStage);if("aggregate"===t&&"command"===s)return!0;e=e.prevStage}return!1}getNextStageFn(e){const t=this;return function(){return Pi({$method:e,$param:xi(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 s=this.getAction(),i=this.getCommand();return i.$db.push({$method:e,$param:xi(t)}),this._database._callCloudFunction({action:s,command:i})}}function Pi(e,t,s){return ki(new Ii(e,t,s),{get(e,t){let i="db";return e&&e.content&&(i=e.content.$method),Ti(i,t)?Pi({$method:t},e,s):function(){return Pi({$method:t,$param:xi(Array.from(arguments))},e,s)}}})}function Ai({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())}}}class Ci{constructor({uniClient:e={},isJQL:t=!1}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e._isDefault&&(this._dbCallBacks=ze("_globalUniCloudDatabaseCallback")),t||(this.auth=vi(this._authCallBacks)),this._isJQL=t,Object.assign(this,vi(this._dbCallBacks)),this.env=ki({},{get:(e,t)=>({$env:t})}),this.Geo=ki({},{get:(e,t)=>Ai({path:["Geo"],method:t})}),this.serverDate=Ai({path:[],method:"serverDate"}),this.RegExp=Ai({path:[],method:"RegExp"})}getCloudEnv(e){if("string"!=typeof e||!e.trim())throw new Error("getCloudEnv参数错误");return{$env:e.replace("$cloudEnv_","")}}_callback(e,t){const s=this._dbCallBacks;s[e]&&s[e].forEach(e=>{e(...t)})}_callbackAuth(e,t){const s=this._authCallBacks;s[e]&&s[e].forEach(e=>{e(...t)})}multiSend(){const e=Array.from(arguments),t=e.map(e=>{const t=e.getAction(),s=e.getCommand();if("getTemp"!==s.$db[s.$db.length-1].$method)throw new Error("multiSend只支持子命令内使用getTemp");return{action:t,command:s}});return this._callCloudFunction({multiCommand:t,queryList:e})}}function Oi(e,t={}){return ki(new e(t),{get:(e,t)=>Ti("db",t)?Pi({$method:t},null,e):function(){return Pi({$method:t,$param:xi(Array.from(arguments))},null,e)}})}class Fi extends Ci{_parseResult(e){return this._isJQL?e.result:e}_callCloudFunction({action:e,command:t,multiCommand:s,queryList:i}){function n(e,t){if(s&&i)for(let s=0;s<i.length;s++){const n=i[s];n.udb&&"function"==typeof n.udb.setResult&&(t?n.udb.setResult(t):n.udb.setResult(e.result.dataList[s]))}}const o=this,r=this._isJQL?"databaseForJQL":"database";function a(e){return o._callback("error",[e]),Ge(Ye(r,"fail"),e).then(()=>Ge(Ye(r,"complete"),e)).then(()=>(n(null,e),ct(Ze,{type:st,content:e}),Promise.reject(e)))}const c=Ge(Ye(r,"invoke")),l=this._uniClient;return c.then(()=>l.callFunction({name:"DCloud-clientDB",type:Ie,data:{action:e,command:t,multiCommand:s}})).then(e=>{const{code:t,message:s,token:i,tokenExpired:c,systemInfo:l=[]}=e.result;if(l)for(let n=0;n<l.length;n++){const{level:e,message:t,detail:s}=l[n];let i="[System Info]"+t;s&&(i=`${i}\n详细信息:${s}`),(console[e]||console.log)(i)}if(t)return a(new pt({code:t,message:s,requestId:e.requestId}));e.result.errCode=e.result.errCode||e.result.code,e.result.errMsg=e.result.errMsg||e.result.message,i&&c&&(yt({token:i,tokenExpired:c}),this._callbackAuth("refreshToken",[{token:i,tokenExpired:c}]),this._callback("refreshToken",[{token:i,tokenExpired:c}]),ct(tt,{token:i,tokenExpired:c}));const u=[{prop:"affectedDocs",tips:"affectedDocs不再推荐使用,请使用inserted/deleted/updated/data.length替代"},{prop:"code",tips:"code不再推荐使用,请使用errCode替代"},{prop:"message",tips:"message不再推荐使用,请使用errMsg替代"}];for(let n=0;n<u.length;n++){const{prop:t,tips:s}=u[n];if(t in e.result){const i=e.result[t];Object.defineProperty(e.result,t,{get:()=>(console.warn(s),i)})}}return h=e,Ge(Ye(r,"success"),h).then(()=>Ge(Ye(r,"complete"),h)).then(()=>{n(h,null);const e=o._parseResult(h);return ct(Ze,{type:st,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 pt({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId}))))}}const Ei="token无效,跳转登录页面",Li="token过期,跳转登录页面",Ri={TOKEN_INVALID_TOKEN_EXPIRED:Li,TOKEN_INVALID_INVALID_CLIENTID:Ei,TOKEN_INVALID:Ei,TOKEN_INVALID_WRONG_TOKEN:Ei,TOKEN_INVALID_ANONYMOUS_USER:Ei},Ui={"uni-id-token-expired":Li,"uni-id-check-token-failed":Ei,"uni-id-token-not-exist":Ei,"uni-id-check-device-feature-failed":Ei},Di={...Ri,...Ui,default:"用户未登录或登录状态过期,自动跳转登录页面"};function Ni(e,t){let s="";return s=e?`${e}/${t}`:t,s.replace(/^\//,"")}function $i(e=[],t=""){const s=[],i=[];return e.forEach(e=>{!0===e.needLogin?s.push(Ni(t,e.path)):!1===e.needLogin&&i.push(Ni(t,e.path))}),{needLoginPage:s,notNeedLoginPage:i}}function Mi(e){return e.split("?")[0].replace(/^\//,"")}function ji(){return function(e){let t=e&&e.$page&&e.$page.fullPath;return t?("/"!==t.charAt(0)&&(t="/"+t),t):""}(function(){const e=w();return e[e.length-1]}())}function qi(){return Mi(ji())}function Bi(e="",t={}){if(!e)return!1;if(!(t&&t.list&&t.list.length))return!1;const s=t.list,i=Mi(e);return s.some(e=>e.pagePath===i)}const Ki=!!ge.uniIdRouter,{loginPage:zi,routerNeedLogin:Hi,resToLogin:Vi,needLoginPage:Wi,notNeedLoginPage:Ji,loginPageInTabBar:Gi}=function({pages:e=[],subPackages:t=[],uniIdRouter:s={},tabBar:i={}}=ge){const{loginPage:n,needLogin:o=[],resToLogin:r=!0}=s,{needLoginPage:a,notNeedLoginPage:c}=$i(e),{needLoginPage:l,notNeedLoginPage:u}=function(e=[]){const t=[],s=[];return e.forEach(e=>{const{root:i,pages:n=[]}=e,{needLoginPage:o,notNeedLoginPage:r}=$i(n,i);t.push(...o),s.push(...r)}),{needLoginPage:t,notNeedLoginPage:s}}(t);return{loginPage:n,routerNeedLogin:o,resToLogin:r,needLoginPage:[...a,...l],notNeedLoginPage:[...c,...u],loginPageInTabBar:Bi(n,i)}}();if(Wi.indexOf(zi)>-1)throw new Error(`Login page [${zi}] should not be "needLogin", please check your pages.json`);function Yi(e){const t=qi();if("/"===e.charAt(0))return e;const[s,i]=e.split("?"),n=s.replace(/^\//,"").split("/"),o=t.split("/");o.pop();for(let r=0;r<n.length;r++){const e=n[r];".."===e?o.pop():"."!==e&&o.push(e)}return""===o[0]&&o.shift(),"/"+o.join("/")+(i?"?"+i:"")}function Qi({redirect:e}){const t=Mi(e),s=Mi(zi);return qi()!==s&&t!==s}function Xi({api:e,redirect:t}={}){if(!t||!Qi({redirect:t}))return;const s=(n=t,"/"!==(i=zi).charAt(0)&&(i="/"+i),n?i.indexOf("?")>-1?i+`&uniIdRedirectUrl=${encodeURIComponent(n)}`:i+`?uniIdRedirectUrl=${encodeURIComponent(n)}`:i);var i,n;Gi?"navigateTo"!==e&&"redirectTo"!==e||(e="switchTab"):"switchTab"===e&&(e="navigateTo");const o={navigateTo:U,redirectTo:D,switchTab:N,reLaunch:$};setTimeout(()=>{o[e]({url:s})},0)}function Zi({url:e}={}){const t={abortLoginPageJump:!1,autoToLoginPage:!1},s=function(){const{token:e,tokenExpired:t}=mt();let s;if(e){if(t<Date.now()){const e="uni-id-token-expired";s={errCode:e,errMsg:Di[e]}}}else{const e="uni-id-check-token-failed";s={errCode:e,errMsg:Di[e]}}return s}();if(function(e){const t=Mi(Yi(e));return!(Ji.indexOf(t)>-1)&&(Wi.indexOf(t)>-1||Hi.some(t=>{return s=e,new RegExp(t).test(s);var s}))}(e)&&s){if(s.uniIdRedirectUrl=e,ot(et).length>0)return setTimeout(()=>{ct(et,s)},0),t.abortLoginPageJump=!0,t;t.autoToLoginPage=!0}return t}function en(){!function(){const e=ji(),{abortLoginPageJump:t,autoToLoginPage:s}=Zi({url:e});t||s&&Xi({api:"redirectTo",redirect:e})}();const e=["navigateTo","redirectTo","reLaunch","switchTab"];for(let t=0;t<e.length;t++){const s=e[t];k(s,{invoke(e){const{abortLoginPageJump:t,autoToLoginPage:i}=Zi({url:e.url});return t?e:i?(Xi({api:s,redirect:Yi(e.url)}),!1):e}})}}function tn(){this.onResponse(e=>{const{type:t,content:s}=e;let i=!1;switch(t){case"cloudobject":i=function(e){if("object"!=typeof e)return!1;const{errCode:t}=e||{};return t in Di}(s);break;case"clientdb":i=function(e){if("object"!=typeof e)return!1;const{errCode:t}=e||{};return t in Ri}(s)}i&&function(e={}){const t=ot(et);ht().then(()=>{const s=ji();if(s&&Qi({redirect:s}))return t.length>0?ct(et,Object.assign({uniIdRedirectUrl:s},e)):void(zi&&Xi({api:"navigateTo",redirect:s}))})}(s)})}function sn(e){var t;(t=e).onResponse=function(e){rt(Ze,e)},t.offResponse=function(e){at(Ze,e)},function(e){e.onNeedLogin=function(e){rt(et,e)},e.offNeedLogin=function(e){at(et,e)},Ki&&(ze(hi).needLoginInit||(ze(hi).needLoginInit=!0,ht().then(()=>{en.call(e)}),Vi&&tn.call(e)))}(e),function(e){e.onRefreshToken=function(e){rt(tt,e)},e.offRefreshToken=function(e){at(tt,e)}}(e)}let nn;const on="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",rn=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function an(){const e=mt().token||"",t=e.split(".");if(!e||3!==t.length)return{uid:null,role:[],permission:[],tokenExpired:0};let s;try{s=JSON.parse((i=t[1],decodeURIComponent(nn(i).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join(""))))}catch(n){throw new Error("获取当前用户信息出错,详细错误信息为:"+n.message)}var i;return s.tokenExpired=1e3*s.exp,delete s.exp,delete s.iat,s}nn="function"!=typeof atob?function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!rn.test(e))throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var s,i,n="",o=0;o<e.length;)t=on.indexOf(e.charAt(o++))<<18|on.indexOf(e.charAt(o++))<<12|(s=on.indexOf(e.charAt(o++)))<<6|(i=on.indexOf(e.charAt(o++))),n+=64===s?String.fromCharCode(t>>16&255):64===i?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return n}:atob;var cn=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(me(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const s="chooseAndUploadFile:ok",i="chooseAndUploadFile:fail";function n(e,t){return e.tempFiles.forEach((e,s)=>{e.name||(e.name=e.path.substring(e.path.lastIndexOf("/")+1)),t&&(e.fileType=t),e.cloudPath=Date.now()+"_"+s+e.name.substring(e.name.lastIndexOf("."))}),e.tempFilePaths||(e.tempFilePaths=e.tempFiles.map(e=>e.path)),e}function o(e,t,{onChooseFile:i,onUploadProgress:n}){return t.then(e=>{if(i){const t=i(e);if(void 0!==t)return Promise.resolve(t).then(t=>void 0===t?e:t)}return e}).then(t=>!1===t?{errMsg:s,tempFilePaths:[],tempFiles:[]}:function(e,t,i=5,n){(t=Object.assign({},t)).errMsg=s;const o=t.tempFiles,r=o.length;let a=0;return new Promise(s=>{for(;a<i;)c();function c(){const i=a++;if(i>=r)return void(!o.find(e=>!e.url&&!e.errMsg)&&s(t));const l=o[i];e.uploadFile({provider:l.provider,filePath:l.path,cloudPath:l.cloudPath,fileType:l.fileType,cloudPathAsRealPath:l.cloudPathAsRealPath,onUploadProgress(e){e.index=i,e.tempFile=l,e.tempFilePath=l.path,n&&n(e)}}).then(e=>{l.url=e.fileID,i<r&&c()}).catch(e=>{l.errMsg=e.errMsg||e.message,i<r&&c()})}})}(e,t,5,n))}t.initChooseAndUploadFile=function(e){return function(t={type:"all"}){return"image"===t.type?o(e,function(e){const{count:t,sizeType:s,sourceType:o=["album","camera"],extension:r}=e;return new Promise((e,a)=>{y({count:t,sizeType:s,sourceType:o,extension:r,success(t){e(n(t,"image"))},fail(e){a({errMsg:e.errMsg.replace("chooseImage:fail",i)})}})})}(t),t):"video"===t.type?o(e,function(e){const{camera:t,compressed:s,maxDuration:o,sourceType:r=["album","camera"],extension:a}=e;return new Promise((e,c)=>{_({camera:t,compressed:s,maxDuration:o,sourceType:r,extension:a,success(t){const{tempFilePath:s,duration:i,size:o,height:r,width:a}=t;e(n({errMsg:"chooseVideo:ok",tempFilePaths:[s],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:s,size:o,type:t.tempFile&&t.tempFile.type||"",width:a,height:r,duration:i,fileType:"video",cloudPath:""}]},"video"))},fail(e){c({errMsg:e.errMsg.replace("chooseVideo:fail",i)})}})})}(t),t):o(e,function(e){const{count:t,extension:s}=e;return new Promise((e,o)=>{let r=v;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(r=wx.chooseMessageFile),"function"!=typeof r)return o({errMsg:i+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});r({type:"all",count:t,extension:s,success(t){e(n(t))},fail(e){o({errMsg:e.errMsg.replace("chooseFile:fail",i)})}})})}(t),t)}}}));const ln="manual";function un(e){return{props:{localdata:{type:Array,default:()=>[]},options:{type:[Object,Array],default:()=>({})},spaceInfo:{type:Object,default:()=>({})},collection:{type:[String,Array],default:""},action:{type:String,default:""},field:{type:String,default:""},orderby:{type:String,default:""},where:{type:[String,Object],default:""},pageData:{type:String,default:"add"},pageCurrent:{type:Number,default:1},pageSize:{type:Number,default:20},getcount:{type:[Boolean,String],default:!1},gettree:{type:[Boolean,String],default:!1},gettreepath:{type:[Boolean,String],default:!1},startwith:{type:String,default:""},limitlevel:{type:Number,default:10},groupby:{type:String,default:""},groupField:{type:String,default:""},distinct:{type:[Boolean,String],default:!1},foreignKey:{type:String,default:""},loadtime:{type:String,default:"auto"},manual:{type:Boolean,default:!1}},data:()=>({mixinDatacomLoading:!1,mixinDatacomHasMore:!1,mixinDatacomResData:[],mixinDatacomErrorMessage:"",mixinDatacomPage:{},mixinDatacomError:null}),created(){this.mixinDatacomPage={current:this.pageCurrent,size:this.pageSize,count:0},this.$watch(()=>{var e=[];return["pageCurrent","pageSize","localdata","collection","action","field","orderby","where","getont","getcount","gettree","groupby","groupField","distinct"].forEach(t=>{e.push(this[t])}),e},(e,t)=>{if(this.loadtime===ln)return;let s=!1;const i=[];for(let n=2;n<e.length;n++)e[n]!==t[n]&&(i.push(e[n]),s=!0);e[0]!==t[0]&&(this.mixinDatacomPage.current=this.pageCurrent),this.mixinDatacomPage.size=this.pageSize,this.onMixinDatacomPropsChange(s,i)})},methods:{onMixinDatacomPropsChange(e,t){},mixinDatacomEasyGet({getone:e=!1,success:t,fail:s}={}){this.mixinDatacomLoading||(this.mixinDatacomLoading=!0,this.mixinDatacomErrorMessage="",this.mixinDatacomError=null,this.mixinDatacomGet().then(s=>{this.mixinDatacomLoading=!1;const{data:i,count:n}=s.result;this.getcount&&(this.mixinDatacomPage.count=n),this.mixinDatacomHasMore=i.length<this.pageSize;const o=e?i.length?i[0]:void 0:i;this.mixinDatacomResData=o,t&&t(o)}).catch(e=>{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,this.mixinDatacomError=e,s&&s(e)}))},mixinDatacomGet(t={}){let s;t=t||{},s="undefined"!=typeof __uniX&&__uniX?e.databaseForJQL(this.spaceInfo):e.database(this.spaceInfo);const i=t.action||this.action;i&&(s=s.action(i));const n=t.collection||this.collection;s=Array.isArray(n)?s.collection(...n):s.collection(n);const o=t.where||this.where;o&&Object.keys(o).length&&(s=s.where(o));const r=t.field||this.field;r&&(s=s.field(r));const a=t.foreignKey||this.foreignKey;a&&(s=s.foreignKey(a));const c=t.groupby||this.groupby;c&&(s=s.groupBy(c));const l=t.groupField||this.groupField;l&&(s=s.groupField(l)),!0===(void 0!==t.distinct?t.distinct:this.distinct)&&(s=s.distinct());const u=t.orderby||this.orderby;u&&(s=s.orderBy(u));const h=void 0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,d=void 0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,p=void 0!==t.getcount?t.getcount:this.getcount,f=void 0!==t.gettree?t.gettree:this.gettree,g=void 0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:p},y={limitLevel:void 0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void 0!==t.startwith?t.startwith:this.startwith};return f&&(m.getTree=y),g&&(m.getTreePath=y),s=s.skip(d*(h-1)).limit(d).get(m),s}}}}function hn(e){return ze("_globalUniCloudSecureNetworkCache__{spaceId}".replace("{spaceId}",e.config.spaceId))}async function dn({openid:e,callLoginByWeixin:t=!1}={}){throw hn(this),new Error(`[SecureNetwork] API \`initSecureNetworkByWeixin\` is not supported on platform \`${Me}\``)}async function pn(e){const t=hn(this);return t.initPromise||(t.initPromise=dn.call(this,e).then(e=>e).catch(e=>{throw delete t.initPromise,e})),t.initPromise}function fn(e){bt=e}function gn(e){const t={getAppBaseInfo:M,getPushClientId:j};return function(s){return new Promise((i,n)=>{t[e]({...s,success(e){i(e)},fail(e){n(e)}})})}}class mn extends De{constructor(){super(),this._uniPushMessageCallback=this._receivePushMessage.bind(this),this._currentMessageId=-1,this._payloadQueue=[]}init(){return Promise.all([gn("getAppBaseInfo")(),gn("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:s,messageId:i,message:n}=t;this._payloadQueue.push({action:s,messageId:i,message:n}),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:s,message:i}=e;"end"===t?this._end({messageId:s,message:i}):"message"===t&&this._appendMessage({messageId:s,message:i})}_appendMessage({messageId:e,message:t}={}){this.emit("message",t)}_end({messageId:e,message:t}={}){this.emit("end",t),this.close()}_initMessageListener(){I(this._uniPushMessageCallback)}_destroy(){P(this._uniPushMessageCallback)}toJSON(){return{appId:this._appId,pushClientId:this._pushClientId,seqId:this._seqId}}close(){this._destroy(),this.emit("close")}}const yn={tcb:Bs,tencent:Bs,aliyun:At,private:Vs,dcloud:Vs,alipay:si};let _n=new class{init(e){let t={};const s=yn[e.provider];if(!s)throw new Error("未提供正确的provider参数");var i;return t=s.init(e),function(e){e._initPromiseHub||(e._initPromiseHub=new Ue({createPromise:function(){let t=Promise.resolve();t=new Promise(e=>{setTimeout(()=>{e()},1)});const s=e.auth();return t.then(()=>s.getLoginState()).then(e=>e?Promise.resolve():s.signInAnonymously())}}))}(t),_i(t),function(e){const t=e.uploadFile;e.uploadFile=function(e){return t.call(this,e)}}(t),(i=t).database=function(e){if(e&&Object.keys(e).length>0)return i.init(e).database();if(this._database)return this._database;const t=Oi(Fi,{uniClient:i});return this._database=t,t},i.databaseForJQL=function(e){if(e&&Object.keys(e).length>0)return i.init(e).databaseForJQL();if(this._databaseForJQL)return this._databaseForJQL;const t=Oi(Fi,{uniClient:i,isJQL:!0});return this._databaseForJQL=t,t},function(e){e.getCurrentUserInfo=an,e.chooseAndUploadFile=cn.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return un(e)}}),e.SSEChannel=mn,e.initSecureNetworkByWeixin=function(e){return function({openid:t,callLoginByWeixin:s=!1}={}){return pn.call(e,{openid:t,callLoginByWeixin:s})}}(e),e.setCustomClientInfo=fn,e.importObject=function(t){return function(s,i={}){i=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}},i);const{customUI:n,loadingOptions:o,errorOptions:r,parseSystemError:a}=i,c=!n;return new Proxy({},{get(n,l){switch(l){case"toString":return"[object UniCloudObject]";case"toJSON":return{}}return function({fn:e,interceptorName:t,getCallbackArgs:s}={}){return async function(...i){const n=s?s({params:i}):{};let o,r;try{return await Ge(Ye(t,"invoke"),{...n}),o=await e(...i),await Ge(Ye(t,"success"),{...n,result:o}),o}catch(a){throw r=a,await Ge(Ye(t,"fail"),{...n,error:r}),r}finally{await Ge(Ye(t,"complete"),r?{...n,error:r}:{...n,result:o})}}}({fn:async function n(...u){let h;c&&b({title:o.title,mask:o.mask});const d={name:s,type:Se,data:{method:l,params:u}};"object"==typeof i.secretMethods&&function(e,t){const s=t.data.method,i=e.secretMethods||{},n=i[s]||i["*"];n&&(t.secretType=n)}(i,d);let p=!1;try{h=await t.callFunction(d)}catch(e){p=!0,h={result:new pt(e)}}const{errSubject:f,errCode:g,errMsg:m,newToken:y}=h.result||{};if(c&&T(),y&&y.token&&y.tokenExpired&&(yt(y),ct(tt,{...y})),g){let e=m;if(p&&a&&(e=(await a({objectName:s,methodName:l,params:u,errSubject:f,errCode:g,errMsg:m})).errMsg||m),c)if("toast"===r.type)x({title:e,icon:"none"});else{if("modal"!==r.type)throw new Error(`Invalid errorOptions.type: ${r.type}`);{const{confirm:t}=await async function({title:e,content:t,showCancel:s,cancelText:i,confirmText:n}={}){return new Promise((o,r)=>{S({title:e,content:t,showCancel:s,cancelText:i,confirmText:n,success(e){o(e)},fail(){o({confirm:!1,cancel:!0})}})})}({title:"提示",content:e,showCancel:r.retry,cancelText:"取消",confirmText:r.retry?"重试":"确定"});if(r.retry&&t)return n(...u)}}const t=new pt({subject:f,code:g,message:m,requestId:h.requestId});throw t.detail=h.result,ct(Ze,{type:nt,content:t}),t}return ct(Ze,{type:nt,content:h.result}),h.result},interceptorName:"callObject",getCallbackArgs:function({params:e}={}){return{objectName:s,methodName:l,params:e}}})}})}}(e)}(t),["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach(e=>{if(!t[e])return;const s=t[e];t[e]=function(){return s.apply(t,Array.from(arguments))},t[e]=function(e,t){return function(s){let i=!1;if("callFunction"===t){const e=s&&s.type||xe;i=e!==xe}const n="callFunction"===t&&!i,o=this._initPromiseHub.exec();s=s||{};const{success:r,fail:a,complete:c}=dt(s),l=o.then(()=>i?Promise.resolve():Ge(Ye(t,"invoke"),s)).then(()=>e.call(this,s)).then(e=>i?Promise.resolve(e):Ge(Ye(t,"success"),e).then(()=>Ge(Ye(t,"complete"),e)).then(()=>(n&&ct(Ze,{type:it,content:e}),Promise.resolve(e))),e=>i?Promise.reject(e):Ge(Ye(t,"fail"),e).then(()=>Ge(Ye(t,"complete"),e)).then(()=>(ct(Ze,{type:it,content:e}),Promise.reject(e))));if(!(r||a||c))return l;l.then(e=>{r&&r(e),c&&c(e),n&&ct(Ze,{type:it,content:e})},e=>{a&&a(e),c&&c(e),n&&ct(Ze,{type:it,content:e})})}}(t[e],e).bind(t)}),t.init=this.init,t}};(()=>{const e=je;let t={};if(e&&1===e.length)t=e[0],_n=_n.init(t),_n._isDefault=!0;else{const t=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile"],s=["database","getCurrentUserInfo","importObject"];let i;i=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":"应用未关联服务空间,请在uniCloud目录右键关联服务空间",[...t,...s].forEach(e=>{_n[e]=function(){if(console.error(i),-1===s.indexOf(e))return Promise.reject(new pt({code:"SYS_ERR",message:i}));console.error(i)}})}Object.assign(_n,{get mixinDatacom(){return un(_n)}}),sn(_n),_n.addInterceptor=We,_n.removeInterceptor=Je,_n.interceptObject=Qe;{const e=Be||(Be=function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;function e(){return this}return void 0!==e()?e():new Function("return this")()}(),Be);e.uniCloud=_n,e.UniCloudError=pt}})();var wn=_n;const kn="chooseAndUploadFile:fail";function vn(e,t){return e.tempFiles.forEach((e,s)=>{e.name||(e.name=e.path.substring(e.path.lastIndexOf("/")+1)),t&&(e.fileType=t),e.cloudPath=Date.now()+"_"+s+e.name.substring(e.name.lastIndexOf("."))}),e.tempFilePaths||(e.tempFilePaths=e.tempFiles.map(e=>e.path)),e}function bn(e,t=5,s){const i=(e=JSON.parse(JSON.stringify(e))).length;let n=0,o=this;return new Promise(r=>{for(;n<t;)a();function a(){let t=n++;if(t>=i)return void(!e.find(e=>!e.url&&!e.errMsg)&&r(e));const c=e[t],l=o.files.findIndex(e=>e.uuid===c.uuid);c.url="",delete c.errMsg,wn.uploadFile({filePath:c.path,cloudPath:c.cloudPath,fileType:c.fileType,onUploadProgress:e=>{e.index=l,s&&s(e)}}).then(e=>{c.url=e.fileID,c.index=l,t<i&&a()}).catch(e=>{c.errMsg=e.errMsg||e.message,c.index=l,t<i&&a()})}})}function Tn(e,{onChooseFile:t,onUploadProgress:s}){return e.then(e=>{if(t){const s=t(e);if(void 0!==s)return Promise.resolve(s).then(t=>void 0===t?e:t)}return e}).then(e=>!1===e?{errMsg:"chooseAndUploadFile:ok",tempFilePaths:[],tempFiles:[]}:e)}function xn(e={type:"all"}){return"image"===e.type?Tn(function(e){const{count:t,sizeType:s=["original","compressed"],sourceType:i,extension:n}=e;return new Promise((e,o)=>{y({count:t,sizeType:s,sourceType:i,extension:n,success(t){e(vn(t,"image"))},fail(e){o({errMsg:e.errMsg.replace("chooseImage:fail",kn)})}})})}(e),e):"video"===e.type?Tn(function(e){const{count:t,camera:s,compressed:i,maxDuration:n,sourceType:o,extension:r}=e;return new Promise((e,t)=>{_({camera:s,compressed:i,maxDuration:n,sourceType:o,extension:r,success(t){const{tempFilePath:s,duration:i,size:n,height:o,width:r}=t;e(vn({errMsg:"chooseVideo:ok",tempFilePaths:[s],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:s,size:n,type:t.tempFile&&t.tempFile.type||"",width:r,height:o,duration:i,fileType:"video",cloudPath:""}]},"video"))},fail(e){t({errMsg:e.errMsg.replace("chooseVideo:fail",kn)})}})})}(e),e):Tn(function(e){const{count:t,extension:s}=e;return new Promise((e,i)=>{let n=v;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(n=wx.chooseMessageFile),"function"!=typeof n)return i({errMsg:kn+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});n({type:"all",count:t,extension:s,success(t){e(vn(t))},fail(e){i({errMsg:e.errMsg.replace("chooseFile:fail",kn)})}})})}(e),e)}const Sn=e=>{const t=e.lastIndexOf("."),s=e.length;return{name:e.substring(0,t),ext:e.substring(t+1,s)}},In=e=>{if(Array.isArray(e))return e;return e.replace(/(\[|\])/g,"").split(",")},Pn=async(e,t="image")=>{const s=Sn(e.name).ext.toLowerCase();let i={name:e.name,uuid:e.uuid,extname:s||"",cloudPath:e.cloudPath,fileType:e.fileType,thumbTempFilePath:e.thumbTempFilePath,url:e.path||e.path,size:e.size,image:{},path:e.path,video:{}};if("image"===t){const t=await(n=e.path,new Promise((e,t)=>{K({src:n,success(t){e(t)},fail(e){t(e)}})}));delete i.video,i.image.width=t.width,i.image.height=t.height,i.image.location=t.path}else delete i.image;var n;return i};const An=t({name:"uniFilePicker",components:{uploadImage:t({name:"uploadImage",emits:["uploadFiles","choose","delFile"],props:{filesList:{type:Array,default:()=>[]},disabled:{type:Boolean,default:!1},disablePreview:{type:Boolean,default:!1},limit:{type:[Number,String],default:9},imageStyles:{type:Object,default:()=>({width:"auto",height:"auto",border:{}})},delIcon:{type:Boolean,default:!0},readonly:{type:Boolean,default:!1}},computed:{styles(){return Object.assign({width:"auto",height:"auto",border:{}},this.imageStyles)},boxStyle(){const{width:e="auto",height:t="auto"}=this.styles;let s={};"auto"===t?"auto"!==e?(s.height=this.value2px(e),s["padding-top"]=0):s.height=0:(s.height=this.value2px(t),s["padding-top"]=0),s.width="auto"===e?"auto"!==t?this.value2px(t):"33.3%":this.value2px(e);let i="";for(let n in s)i+=`${n}:${s[n]};`;return i},borderStyle(){let{border:e}=this.styles,t={};if("boolean"==typeof e)t.border=e?"1px #eee solid":"none";else{let s=e&&e.width||1;s=this.value2px(s);let i=e&&e.radius||3;i=this.value2px(i),t={"border-width":s,"border-style":e&&e.style||"solid","border-color":e&&e.color||"#eee","border-radius":i}}let s="";for(let i in t)s+=`${i}:${t[i]};`;return s}},methods:{uploadFiles(e,t){this.$emit("uploadFiles",e)},choose(){this.readonly||this.$emit("choose")},delFile(e){this.readonly||this.$emit("delFile",e)},prviewImage(e,t){if(this.readonly)return;let s=[];1===Number(this.limit)&&this.disablePreview&&!this.disabled&&this.$emit("choose"),this.disablePreview||(this.filesList.forEach(e=>{s.push(e.url)}),z({urls:s,current:t}))},value2px:e=>("number"==typeof e?e+="px":-1===e.indexOf("%")&&(e=-1!==e.indexOf("px")?e:e+"px"),e)}},[["render",function(e,t,s,i,c,h){const d=Y,p=u,m=Q;return n(),o(p,{class:"uni-file-picker__container"},{default:r(()=>[(n(!0),H(V,null,W(s.filesList,(e,t)=>(n(),o(p,{class:"file-picker__box",key:t,style:l(h.boxStyle)},{default:r(()=>[f(p,{class:"file-picker__box-content",style:l(h.borderStyle)},{default:r(()=>[f(d,{class:"file-image",src:e.url,mode:"aspectFill",onClick:J(s=>h.prviewImage(e,t),["stop"])},null,8,["src","onClick"]),s.delIcon&&!s.readonly?(n(),o(p,{key:0,class:"icon-del-box",onClick:J(e=>h.delFile(t),["stop"])},{default:r(()=>[f(p,{class:"icon-del"}),f(p,{class:"icon-del rotate"})]),_:2},1032,["onClick"])):g("",!0),e.progress&&100!==e.progress||0===e.progress?(n(),o(p,{key:1,class:"file-picker__progress"},{default:r(()=>[f(m,{class:"file-picker__progress-item",percent:-1===e.progress?0:e.progress,"stroke-width":"4",backgroundColor:e.errMsg?"#ff5a5f":"#EBEBEB"},null,8,["percent","backgroundColor"])]),_:2},1024)):g("",!0),e.errMsg?(n(),o(p,{key:2,class:"file-picker__mask",onClick:J(s=>h.uploadFiles(e,t),["stop"])},{default:r(()=>[G(" 点击重试 ")]),_:2},1032,["onClick"])):g("",!0)]),_:2},1032,["style"])]),_:2},1032,["style"]))),128)),s.filesList.length<s.limit?(n(),o(p,{key:0,class:"file-picker__box",style:l(h.boxStyle)},{default:r(()=>[f(p,{class:"file-picker__box-content is-add",style:l(h.borderStyle),onClick:h.choose},{default:r(()=>[a(e.$slots,"default",{},void 0,!0)]),_:3},8,["style","onClick"])]),_:3},8,["style"])):g("",!0)]),_:3})}],["__scopeId","data-v-423cbc90"]]),uploadFile:t({name:"uploadFile",emits:["uploadFiles","choose","delFile"],props:{filesList:{type:Array,default:()=>[]},delIcon:{type:Boolean,default:!0},limit:{type:[Number,String],default:9},showType:{type:String,default:""},listStyles:{type:Object,default:()=>({border:!0,dividline:!0,borderStyle:{}})},readonly:{type:Boolean,default:!1}},computed:{list(){let e=[];return this.filesList.forEach(t=>{e.push(t)}),e},styles(){return Object.assign({border:!0,dividline:!0,"border-style":{}},this.listStyles)},borderStyle(){let{borderStyle:e,border:t}=this.styles,s={};if(t){let t=e&&e.width||1;t=this.value2px(t);let i=e&&e.radius||5;i=this.value2px(i),s={"border-width":t,"border-style":e&&e.style||"solid","border-color":e&&e.color||"#eee","border-radius":i}}else s.border="none";let i="";for(let n in s)i+=`${n}:${s[n]};`;return i},borderLineStyle(){let e={},{borderStyle:t}=this.styles;if(t&&t.color&&(e["border-color"]=t.color),t&&t.width){let s=t&&t.width||1,i=t&&t.style||0;"number"==typeof s?s+="px":s=s.indexOf("px")?s:s+"px",e["border-width"]=s,"number"==typeof i?i+="px":i=i.indexOf("px")?i:i+"px",e["border-top-style"]=i}let s="";for(let i in e)s+=`${i}:${e[i]};`;return s}},methods:{uploadFiles(e,t){this.$emit("uploadFiles",{item:e,index:t})},choose(){this.$emit("choose")},delFile(e){this.$emit("delFile",e)},value2px:e=>("number"==typeof e?e+="px":e=-1!==e.indexOf("px")?e:e+"px",e)}},[["render",function(e,t,s,i,h,d){const p=u,m=Q;return n(),o(p,{class:"uni-file-picker__files"},{default:r(()=>[s.readonly?g("",!0):(n(),o(p,{key:0,class:"files-button",onClick:d.choose},{default:r(()=>[a(e.$slots,"default",{},void 0,!0)]),_:3},8,["onClick"])),d.list.length>0?(n(),o(p,{key:1,class:"uni-file-picker__lists is-text-box",style:l(d.borderStyle)},{default:r(()=>[(n(!0),H(V,null,W(d.list,(e,t)=>(n(),o(p,{class:c(["uni-file-picker__lists-box",{"files-border":0!==t&&d.styles.dividline}]),key:t,style:l(0!==t&&d.styles.dividline&&d.borderLineStyle)},{default:r(()=>[f(p,{class:"uni-file-picker__item"},{default:r(()=>[f(p,{class:"files__name"},{default:r(()=>[G(X(e.name),1)]),_:2},1024),s.delIcon&&!s.readonly?(n(),o(p,{key:0,class:"icon-del-box icon-files",onClick:e=>d.delFile(t)},{default:r(()=>[f(p,{class:"icon-del icon-files"}),f(p,{class:"icon-del rotate"})]),_:2},1032,["onClick"])):g("",!0)]),_:2},1024),e.progress&&100!==e.progress||0===e.progress?(n(),o(p,{key:0,class:"file-picker__progress"},{default:r(()=>[f(m,{class:"file-picker__progress-item",percent:-1===e.progress?0:e.progress,"stroke-width":"4",backgroundColor:e.errMsg?"#ff5a5f":"#EBEBEB"},null,8,["percent","backgroundColor"])]),_:2},1024)):g("",!0),"error"===e.status?(n(),o(p,{key:1,class:"file-picker__mask",onClick:J(s=>d.uploadFiles(e,t),["stop"])},{default:r(()=>[G(" 点击重试 ")]),_:2},1032,["onClick"])):g("",!0)]),_:2},1032,["class","style"]))),128))]),_:1},8,["style"])):g("",!0)]),_:3})}],["__scopeId","data-v-14279b92"]])},options:{virtualHost:!0},emits:["select","success","fail","progress","delete","update:modelValue","input"],props:{modelValue:{type:[Array,Object],default:()=>[]},value:{type:[Array,Object],default:()=>[]},disabled:{type:Boolean,default:!1},disablePreview:{type:Boolean,default:!1},delIcon:{type:Boolean,default:!0},autoUpload:{type:Boolean,default:!0},limit:{type:[Number,String],default:9},mode:{type:String,default:"grid"},fileMediatype:{type:String,default:"image"},fileExtname:{type:[Array,String],default:()=>[]},title:{type:String,default:""},listStyles:{type:Object,default:()=>({border:!0,dividline:!0,borderStyle:{}})},imageStyles:{type:Object,default:()=>({width:"auto",height:"auto"})},readonly:{type:Boolean,default:!1},returnType:{type:String,default:"array"},sizeType:{type:Array,default:()=>["original","compressed"]},sourceType:{type:Array,default:()=>["album","camera"]},provider:{type:String,default:""},dir:{type:String,default:""}},data:()=>({files:[],localValue:[],dirPath:""}),watch:{value:{handler(e,t){this.setValue(e,t)},immediate:!0},modelValue:{handler(e,t){this.setValue(e,t)},immediate:!0},dir:{handler(e){this.dirPath=e},immediate:!0}},computed:{filesList(){let e=[];return this.files.forEach(t=>{e.push(t)}),e},showType(){return"image"===this.fileMediatype?this.mode:"list"},limitLength(){return"object"===this.returnType?1:this.limit?this.limit>=9?9:this.limit:1}},created(){wn.config&&wn.config.provider||(this.noSpace=!0,wn.chooseAndUploadFile=xn),this.form=this.getForm("uniForms"),this.formItem=this.getForm("uniFormsItem"),this.form&&this.formItem&&this.formItem.name&&(this.rename=this.formItem.name,this.form.inputChildrens.push(this))},methods:{clearFiles(e){0===e||e?this.files.splice(e,1):(this.files=[],this.$nextTick(()=>{this.setEmit()})),this.$nextTick(()=>{this.setEmit()})},upload(){let e=[];return this.files.forEach((t,s)=>{"ready"!==t.status&&"error"!==t.status||e.push(Object.assign({},t))}),this.uploadFiles(e)},async setValue(e,t){const s=async e=>{let t="";return t=e.fileID?e.fileID:e.url,/cloud:\/\/([\w.]+\/?)\S*/.test(t)&&(e.fileID=t,e.url=await this.getTempFileURL(t)),e.url&&(e.path=e.url),e};if("object"===this.returnType)e?await s(e):e={};else{e||(e=[]);for(let t=0;t<e.length;t++){let i=e[t];await s(i)}}this.localValue=e,this.form&&this.formItem&&!this.is_reset&&(this.is_reset=!1,this.formItem.setValue(this.localValue));let i=Object.keys(e).length>0?e:[];this.files=[].concat(i)},choose(){this.disabled||(this.files.length>=Number(this.limitLength)&&"grid"!==this.showType&&"array"===this.returnType?x({title:`您最多选择 ${this.limitLength} 个文件`,icon:"none"}):this.chooseFiles())},chooseFiles(){const e=In(this.fileExtname);wn.chooseAndUploadFile({type:this.fileMediatype,compressed:!1,sizeType:this.sizeType,sourceType:this.sourceType,extension:e.length>0?e:void 0,count:this.limitLength-this.files.length,onChooseFile:this.chooseFileCallback,onUploadProgress:e=>{this.setProgress(e,e.index)}}).then(e=>{this.setSuccessAndError(e.tempFiles)}).catch(e=>{console.log("选择失败",e)})},async chooseFileCallback(e){const t=In(this.fileExtname);(1===Number(this.limitLength)&&this.disablePreview&&!this.disabled||"object"===this.returnType)&&(this.files=[]);let{filePaths:s,files:i}=((e,t)=>{let s=[],i=[];return t&&0!==t.length?(e.tempFiles.forEach(e=>{const n=Sn(e.name).ext.toLowerCase();-1!==t.indexOf(n)&&(i.push(e),s.push(e.path))}),i.length!==e.tempFiles.length&&x({title:`当前选择了${e.tempFiles.length}个文件 ,${e.tempFiles.length-i.length} 个文件格式不正确`,icon:"none",duration:5e3}),{filePaths:s,files:i}):{filePaths:s,files:i}})(e,t);t&&t.length>0||(s=e.tempFilePaths,i=e.tempFiles);let n=[];for(let o=0;o<i.length&&!(this.limitLength-this.files.length<=0);o++){i[o].uuid=Date.now();let e=await Pn(i[o],this.fileMediatype);e.progress=0,e.status="ready";let t={...e,file:i[o]};this.files.push(t),n.push(t)}return this.$emit("select",{tempFiles:n,tempFilePaths:s}),e.tempFiles=i,this.autoUpload&&!this.noSpace||(e.tempFiles=[]),e.tempFiles.map((e,t)=>{this.provider&&(e.provider=this.provider);const s=e.name.split("."),i=s.pop(),n=s.join(".").replace(/[\s\/\?<>\\:\*\|":]/g,"_");let o=this.dirPath||"";return o&&"/"!==o[o.length-1]&&(o+="/"),e.cloudPath=o+n+"_"+Date.now()+"_"+t+"."+i,e.cloudPathAsRealPath=!0,e}),e},uploadFiles(e){return e=[].concat(e),bn.call(this,e,5,e=>{this.setProgress(e,e.index,!0)}).then(e=>(this.setSuccessAndError(e),e)).catch(e=>{console.log(e)})},async setSuccessAndError(e,t){let s=[],i=[],n=[],o=[];for(let r=0;r<e.length;r++){const t=e[r],a=t.uuid?this.files.findIndex(e=>e.uuid===t.uuid):t.index;if(-1===a||!this.files)break;if("request:fail"===t.errMsg)this.files[a].url=t.path,this.files[a].status="error",this.files[a].errMsg=t.errMsg,i.push(this.files[a]),o.push(this.files[a].url);else{this.files[a].errMsg="",this.files[a].fileID=t.url;/cloud:\/\/([\w.]+\/?)\S*/.test(t.url)?this.files[a].url=await this.getTempFileURL(t.url):this.files[a].url=t.url,this.files[a].status="success",this.files[a].progress+=1,s.push(this.files[a]),n.push(this.files[a].fileID)}}s.length>0&&(this.setEmit(),this.$emit("success",{tempFiles:this.backObject(s),tempFilePaths:n})),i.length>0&&this.$emit("fail",{tempFiles:this.backObject(i),tempFilePaths:o})},setProgress(e,t,s){this.files.length;const i=Math.round(100*e.loaded/e.total);let n=t;s||(n=this.files.findIndex(t=>t.uuid===e.tempFile.uuid)),-1!==n&&this.files[n]&&(this.files[n].progress=i-1,this.$emit("progress",{index:n,progress:parseInt(i),tempFile:this.files[n]}))},delFile(e){this.$emit("delete",{index:e,tempFile:this.files[e],tempFilePath:this.files[e].url}),this.files.splice(e,1),this.$nextTick(()=>{this.setEmit()})},getFileExt(e){const t=e.lastIndexOf("."),s=e.length;return{name:e.substring(0,t),ext:e.substring(t+1,s)}},setEmit(){let e=[];"object"===this.returnType?(e=this.backObject(this.files)[0],this.localValue=e||null):(e=this.backObject(this.files),this.localValue||(this.localValue=[]),this.localValue=[...e]),this.$emit("update:modelValue",this.localValue)},backObject(e){let t=[];return e.forEach(e=>{t.push({extname:e.extname,fileType:e.fileType,image:e.image,name:e.name,path:e.path,size:e.size,fileID:e.fileID,url:e.url,uuid:e.uuid,status:e.status,cloudPath:e.cloudPath})}),t},async getTempFileURL(e){e={fileList:[].concat(e)};return(await wn.getTempFileURL(e)).fileList[0].tempFileURL||""},getForm(e="uniForms"){let t=this.$parent,s=t.$options.name;for(;s!==e;){if(t=t.$parent,!t)return!1;s=t.$options.name}return t}}},[["render",function(e,t,s,i,c,l){const h=Z,d=u,m=p("upload-image"),y=ee,_=p("upload-file");return n(),o(d,{class:"uni-file-picker"},{default:r(()=>[s.title?(n(),o(d,{key:0,class:"uni-file-picker__header"},{default:r(()=>[f(h,{class:"file-title"},{default:r(()=>[G(X(s.title),1)]),_:1}),f(h,{class:"file-count"},{default:r(()=>[G(X(l.filesList.length)+"/"+X(l.limitLength),1)]),_:1})]),_:1})):g("",!0),"image"===s.fileMediatype&&"grid"===l.showType?(n(),o(m,{key:1,readonly:s.readonly,"image-styles":s.imageStyles,"files-list":l.filesList,limit:l.limitLength,disablePreview:s.disablePreview,delIcon:s.delIcon,onUploadFiles:l.uploadFiles,onChoose:l.choose,onDelFile:l.delFile},{default:r(()=>[a(e.$slots,"default",{},()=>[f(d,{class:"icon-add"}),f(d,{class:"icon-add rotate"})],!0)]),_:3},8,["readonly","image-styles","files-list","limit","disablePreview","delIcon","onUploadFiles","onChoose","onDelFile"])):g("",!0),"image"!==s.fileMediatype||"grid"!==l.showType?(n(),o(_,{key:2,readonly:s.readonly,"list-styles":s.listStyles,"files-list":l.filesList,showType:l.showType,delIcon:s.delIcon,onUploadFiles:l.uploadFiles,onChoose:l.choose,onDelFile:l.delFile},{default:r(()=>[a(e.$slots,"default",{},()=>[f(y,{type:"primary",size:"mini"},{default:r(()=>[G("选择文件")]),_:1})],!0)]),_:3},8,["readonly","list-styles","files-list","showType","delIcon","onUploadFiles","onChoose","onDelFile"])):g("",!0)]),_:3})}],["__scopeId","data-v-5d4d501e"]]),Cn={__name:"index",props:{files:{type:Array,default:()=>[]},gradesFiles:{type:Array,default:()=>[]},readonly:{type:Boolean,default:!1},position:{type:Object,default:()=>({right:"30rpx",bottom:"200rpx"})},bgColor:{type:String,default:"#67AFAB"},maxCount:{type:Number,default:9},showGradeSlip:{type:Boolean,default:!1},isGradeRequired:{type:Boolean,default:!1}},emits:["update:files","update:gradesFiles","upload","preview","upload-grade","upload-base"],setup(e,{expose:t,emit:s}){const i=te(),a=e,p=s,m=se(null),y=se(null),_=se([]),w=se([]),k=se(!0),v=se("#67AFAB"),S=i.baseUrlHt,I=se("base"),P=ie(()=>a.showGradeSlip?"base"===I.value?_.value:w.value:_.value),A=ie(()=>_.value.length+w.value.length);ne(()=>a.files,e=>{_.value=[...e]},{immediate:!0}),ne(()=>a.gradesFiles,e=>{w.value=[...e]},{immediate:!0});const O=e=>{if(!e)return"";if(e.startsWith("http://")||e.startsWith("https://"))try{const t=new URL(e);return`${S}${t.pathname}${t.search}${t.hash}`}catch(t){console.error("解析URL失败:",e,t);const s=e.match(/^(https?:\/\/[^\/]+)(\/.*)?$/);return s?`${S}${s[2]||""}`:e}return`${S}${e.startsWith("/")?"":"/"}${e}`},E={width:120,height:120,border:!1},L=["image/jpeg","image/png","image/gif","image/webp","image/bmp","image/svg+xml"],R=e=>{k.value=!e.show},U=e=>e&&L.includes(e)?"image":e&&e.includes("pdf")?"paperclip":e&&e.includes("word")?"file-word":e&&e.includes("excel")?"file-excel":e&&e.includes("powerpoint")?"file-ppt":"file",D=e=>e&&L.includes(e)?v.value:e&&e.includes("pdf")?"#ff4d4f":e&&e.includes("word")?"#2b579a":e&&e.includes("excel")?"#217346":e&&e.includes("powerpoint")?"#b7472a":"#666",N=e=>e?e<1024?`${e}B`:e<1048576?`${(e/1024).toFixed(1)}KB`:`${(e/1048576).toFixed(1)}MB`:"",$=()=>{m.value&&m.value.open()},M=()=>{m.value&&m.value.close()},j=()=>{var e;null==(e=y.value)||e.choose()},q=e=>{if(!e)return"application/octet-stream";return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",SVG:"image/svg+xml",pdf:"application/pdf"}[e.split(".").pop().toLowerCase()]||"application/octet-stream"},B=e=>{const t=a.showGradeSlip&&"grade"===I.value,s=t?w.value:_.value,i=e.tempFiles.filter(e=>{const t=e.name?e.name.split(".").pop().toLowerCase():"",s=L.includes(e.type)||["jpg","jpeg","png","gif","webp","bmp","svg"].includes(t),i=e.type&&e.type.includes("pdf")||"pdf"===t;return s||i}).map(e=>({name:e.name,url:e.path||e.url,type:e.type||q(e.name),size:e.size,file:e,status:"pending",attachmentType:t?"grade":"base"}));s.length+i.length>a.maxCount?x({title:`最多只能上传${a.maxCount}个文件`,icon:"none"}):t?(w.value=[...w.value,...i],p("update:gradesFiles",w.value)):(_.value=[..._.value,...i],p("update:files",_.value))},K=()=>[..._.value,...w.value],J=(e,t,s)=>{s&&s.stopPropagation(),"grade"===e?(w.value.splice(t,1),p("update:gradesFiles",w.value)):(_.value.splice(t,1),p("update:files",_.value))},Y=e=>{console.log(e,"file");const t=O(e.url);if(e.type&&L.includes(e.type)){const e=K();z({urls:e.filter(e=>e.type&&L.includes(e.type)).map(e=>O(e.url)),current:t})}else e.type&&e.type.includes("pdf")?oe({url:t,success:e=>{const t=e.tempFilePath;re({filePath:t,fileType:"pdf",success:()=>console.log("打开PDF成功"),fail:e=>{console.error("打开PDF失败",e),x({title:"打开PDF失败",icon:"none"})}})},fail:e=>{console.error("下载PDF失败",e),x({title:"下载PDF失败",icon:"none"})}}):p("preview",e)},Q=(e,t)=>new Promise((t,s)=>{const i=F("token");C({url:"/api/common/upload",filePath:e.path||e.url,name:"file",header:{Authorization:`Bearer ${i}`},success:e=>{if(200===e.statusCode){const i=JSON.parse(e.data);console.log(i,"文件"),200===i.code?t({...i,fileName:i.fileName}):s(new Error(i.msg||"上传失败"))}else s(new Error(`上传失败,状态码: ${e.statusCode}`))},fail:e=>{s(e)}})}),le=async()=>{if(a.showGradeSlip&&a.isGradeRequired&&0===w.value.length)return x({title:"请上传成绩单附件",icon:"none"}),void(I.value="grade");if(0!==K().length){b({title:"上传中",mask:!0});try{const t=_.value.filter(e=>!e.url||"pending"===e.status),s=w.value.filter(e=>!e.url||"pending"===e.status);for(const i of t)try{i.status="uploading";const e=await Q(i.file);Object.assign(i,{url:e.url,fileName:e.name,newFileName:e.newFileName,originalFilename:e.originalFilename,status:"success",size:e.size}),p("upload-base",i)}catch(e){console.error("上传失败:",e),i.status="error",x({title:`文件 ${i.name} 上传失败`,icon:"none"})}for(const i of s)try{i.status="uploading";const e=await Q(i.file);Object.assign(i,{url:e.fileName,fileName:e.fileName,newFileName:e.newFileName,originalFilename:e.originalFilename,status:"success"}),p("upload-grade",i)}catch(e){console.error("成绩单附件上传失败:",e),i.status="error",x({title:`文件 ${i.name} 上传失败`,icon:"none"})}console.log(_.value,"1"),console.log(w.value,"2"),p("update:files",_.value),p("update:gradesFiles",w.value),x({title:"上传完成",icon:"success"}),M()}catch(e){console.error("上传出错:",e),x({title:"上传出错",icon:"none"})}finally{T()}}else x({title:"请先添加附件",icon:"none"})};return t({getFilesByType:e=>"grade"===e?w.value:_.value,getAllFiles:K}),(t,s)=>{const i=Z,a=u,p=h(d("uni-icons"),ce),b=ae,T=ee,x=h(d("uni-popup"),fe),S=h(d("uni-file-picker"),An);return n(),o(a,{class:"attachment-upload"},{default:r(()=>[f(a,{class:"attachment-btn",style:l({right:e.position.right,bottom:e.position.bottom,backgroundColor:e.bgColor,display:k.value?"flex":"none"}),onClick:$},{default:r(()=>[f(i,null,{default:r(()=>[G("附件")]),_:1}),A.value>0?(n(),o(i,{key:0,class:"badge"},{default:r(()=>[G(X(A.value),1)]),_:1})):g("",!0)]),_:1},8,["style"]),f(x,{ref_key:"popup",ref:m,type:"bottom","safe-area":!1,onChange:R},{default:r(()=>[f(a,{class:"attachment-popup"},{default:r(()=>[f(a,{class:"popup-header"},{default:r(()=>[f(i,{class:"title"},{default:r(()=>[G("附件管理")]),_:1}),e.readonly?g("",!0):(n(),o(p,{key:0,type:"plus",size:"24",color:v.value,onClick:j},null,8,["color"])),f(p,{type:"close",size:"24",color:"#999",onClick:M})]),_:1}),e.showGradeSlip?(n(),o(a,{key:0,class:"attachment-tabs"},{default:r(()=>[f(a,{class:c(["tab-item",{active:"base"===I.value}]),onClick:s[0]||(s[0]=e=>I.value="base")},{default:r(()=>[f(i,null,{default:r(()=>[G("基础附件")]),_:1})]),_:1},8,["class"]),f(a,{class:c(["tab-item",{active:"grade"===I.value}]),onClick:s[1]||(s[1]=e=>I.value="grade")},{default:r(()=>[f(i,null,{default:r(()=>[G("成绩单附件")]),_:1}),e.isGradeRequired?(n(),o(i,{key:0,class:"required-mark"},{default:r(()=>[G("*")]),_:1})):g("",!0)]),_:1},8,["class"])]),_:1})):g("",!0),f(b,{"scroll-y":"",class:"file-list"},{default:r(()=>["base"!==I.value&&e.showGradeSlip?g("",!0):(n(!0),H(V,{key:0},W(_.value,(t,s)=>(n(),o(a,{class:"file-item",key:"base-"+s},{default:r(()=>[f(a,{class:"file-icon",onClick:e=>Y(t)},{default:r(()=>[f(p,{type:U(t.type),size:"24",color:D(t.type)},null,8,["type","color"])]),_:2},1032,["onClick"]),f(a,{class:"file-info",onClick:e=>Y(t)},{default:r(()=>[f(i,{class:"file-name"},{default:r(()=>[G(X(t.originalFilename||t.name),1)]),_:2},1024),f(i,{class:"file-size"},{default:r(()=>[G(X(N(t.size)),1)]),_:2},1024),"uploading"===t.status?(n(),o(i,{key:0,class:"file-status"},{default:r(()=>[G("上传中...")]),_:1})):"error"===t.status?(n(),o(i,{key:1,class:"file-status error"},{default:r(()=>[G("上传失败")]),_:1})):g("",!0)]),_:2},1032,["onClick"]),e.readonly?g("",!0):(n(),o(p,{key:0,type:"trash",size:"20",color:"#ff4d4f",onClick:e=>J("base",s,e)},null,8,["onClick"]))]),_:2},1024))),128)),"grade"===I.value&&e.showGradeSlip?(n(!0),H(V,{key:1},W(w.value,(t,s)=>(n(),o(a,{class:"file-item",key:"grade-"+s},{default:r(()=>[f(a,{class:"file-icon",onClick:e=>Y(t)},{default:r(()=>[f(p,{type:U(t.type),size:"24",color:D(t.type)},null,8,["type","color"])]),_:2},1032,["onClick"]),f(a,{class:"file-info",onClick:e=>Y(t)},{default:r(()=>[f(i,{class:"file-name"},{default:r(()=>[G(X(t.originalFilename||t.name),1)]),_:2},1024),f(i,{class:"file-size"},{default:r(()=>[G(X(N(t.size)),1)]),_:2},1024),"uploading"===t.status?(n(),o(i,{key:0,class:"file-status"},{default:r(()=>[G("上传中...")]),_:1})):"error"===t.status?(n(),o(i,{key:1,class:"file-status error"},{default:r(()=>[G("上传失败")]),_:1})):g("",!0)]),_:2},1032,["onClick"]),e.readonly?g("",!0):(n(),o(p,{key:0,type:"trash",size:"20",color:"#ff4d4f",onClick:e=>J("grade",s,e)},null,8,["onClick"]))]),_:2},1024))),128)):g("",!0),0===P.value.length?(n(),o(a,{key:2,class:"empty"},{default:r(()=>[f(p,{type:"info",size:"24",color:"#999"}),"base"!==I.value&&e.showGradeSlip?"grade"===I.value?(n(),o(i,{key:1},{default:r(()=>[G("暂无成绩单附件")]),_:1})):g("",!0):(n(),o(i,{key:0},{default:r(()=>[G("暂无附件")]),_:1}))]),_:1})):g("",!0)]),_:1}),e.readonly?g("",!0):(n(),o(a,{key:1,class:"popup-footer"},{default:r(()=>[f(T,{class:"btn",onClick:j},{default:r(()=>[G("添加")]),_:1}),f(T,{class:"btn primary",onClick:le},{default:r(()=>[G("确认上传")]),_:1})]),_:1}))]),_:1})]),_:1},512),e.readonly?g("",!0):(n(),o(S,{key:0,ref_key:"filePicker",ref:y,"auto-upload":!1,"file-mediatype":"all",limit:e.maxCount-P.value.length,"image-styles":E,onSelect:B,onDelete:t.onFileDelete,style:{display:"none"}},null,8,["limit","onDelete"]))]),_:1})}}},On=t(Cn,[["__scopeId","data-v-83ab2406"]]);export{On as a};