import{W as e,X as t,O as s,Y as a,Z as n,K as i,L as o,D as r,G as l,$ as c,a0 as u,E as d,a1 as h,a2 as p,T as f,U as g,H as m,a3 as y,a4 as v,n as _,v as b,s as w,j as T,a5 as k,a6 as x,a7 as I,a8 as S,a9 as P,_ as A,Q as C,a as O,c as F,w as L,f as E,F as U,h as D,l as N,e as R,p as M,d as $,b as B,aa as q,m as j,i as V,ab as K,B as z,t as H,ac as W,k as J,x as G,C as Q,r as Y,J as X,ad as Z,z as ee,A as te,ae as se,af as ae,S as ne,o as ie,y as oe,ag as re,ah as le,ai as ce,aj as ue,ak as de,al as he,am as pe,M as fe,V as ge}from"./index-DF3kK8Jo.js";import{_ as me}from"./uni-icons.C-z8SA-V.js";import{_ as ye}from"./uni-popup.Df-Bes22.js";import{u as ve}from"./dict.ynCYXp4j.js";const _e={pages:[{path:"pages/index/index",style:{navigationBarTitleText:"青附院OPO管理平台",enablePullDownRefresh:!0}},{path:"pages/appointment/index",style:{navigationBarTitleText:"预约挂号"}},{path:"pages/login/Login",style:{navigationBarTitleText:"登录",navigationStyle:"custom"}},{path:"pages/login/Register",style:{navigationBarTitleText:"注册",navigationStyle:"custom"}},{path:"pages/my/index",style:{navigationBarTitleText:"个人中心"}},{path:"pages/vaccine/index",style:{navigationBarTitleText:"疫苗接种"}},{path:"pages/vaccine/book",style:{navigationBarTitleText:"疫苗预约"}},{path:"pages/appointment/doctor",style:{navigationBarTitleText:"选择医生"}},{path:"pages/appointment/schedule",style:{navigationBarTitleText:"选择时间"}},{path:"pages/appointment/record",style:{navigationBarTitleText:"预约记录"}},{path:"pages/payment/index",style:{navigationBarTitleText:"支付"}},{path:"pages/department/index",style:{navigationBarTitleText:"选择科室"}},{path:"pages/department/guide",style:{navigationBarTitleText:"科室导航"}},{path:"pages/department/list",style:{navigationBarTitleText:"科室列表"}},{path:"pages/department/detail",style:{navigationBarTitleText:"科室详情"}},{path:"pages/department/search",style:{navigationBarTitleText:"搜索结果"}},{path:"pages/hospital/detail",style:{navigationBarTitleText:"医院详情"}},{path:"pages/records/medical",style:{navigationBarTitleText:"就医记录"}},{path:"pages/records/detail",style:{navigationBarTitleText:"就医详情"}},{path:"pages/records/report",style:{navigationBarTitleText:"检查报告"}},{path:"pages/my/cases",style:{navigationBarTitleText:"个人病例"}},{path:"pages/my/case-detail",style:{navigationBarTitleText:"病例详情"}},{path:"pages/records/reports",style:{navigationBarTitleText:"检查报告列表"}},{path:"pages/records/report-detail",style:{navigationBarTitleText:"检查报告详情"}},{path:"pages/appointment/patient",style:{navigationBarTitleText:"选择就诊人"}},{path:"pages/appointment/confirm",style:{navigationBarTitleText:"确认预约"}},{path:"pages/vaccine/list",style:{navigationBarTitleText:"疫苗列表"}},{path:"pages/vaccine/detail",style:{navigationBarTitleText:"疫苗详情"}},{path:"pages/vaccine/record",style:{navigationBarTitleText:"接种记录"}},{path:"pages/case/index",style:{navigationBarTitleText:"我的上报"}},{path:"pages/case/CaseDetails",style:{navigationBarTitleText:"上报案例"}},{path:"pages/case/CaseInfo",style:{navigationBarTitleText:"案例详情"}},{path:"pages/case/transfer",style:{navigationBarTitleText:"转运登记"}},{path:"pages/case/transferinfo",style:{navigationBarTitleText:"登记单详情"}},{path:"pages/payment/record",style:{navigationBarTitleText:"缴费记录"}},{path:"pages/payment/detail",style:{navigationBarTitleText:"缴费详情"}},{path:"pages/payment/result",style:{navigationBarTitleText:"支付结果"}},{path:"pages/payment/refund",style:{navigationBarTitleText:"申请退款"}},{path:"pages/payment/invoice",style:{navigationBarTitleText:"电子发票"}},{path:"pages/patient/list",style:{navigationBarTitleText:"就诊人管理"}},{path:"pages/patient/add",style:{navigationBarTitleText:"添加就诊人"}},{path:"pages/patient/edit",style:{navigationBarTitleText:"编辑就诊人"}},{path:"pages/my/payment-method",style:{navigationBarTitleText:"支付方式"}},{path:"pages/my/add-bank-card",style:{navigationBarTitleText:"添加银行卡"}},{path:"pages/my/notification",style:{navigationBarTitleText:"消息通知"}},{path:"pages/search/index",style:{navigationBarTitleText:"搜索",navigationStyle:"custom"}},{path:"pages/doctor/detail",style:{navigationBarTitleText:"医生详情"}},{path:"pages/disease/detail",style:{navigationBarTitleText:"疾病详情"}},{path:"pages/appointment/department",style:{navigationBarTitleText:"选择科室"}},{path:"pages/news/list",style:{navigationBarTitleText:"医院资讯"}},{path:"pages/news/detail",style:{navigationBarTitleText:"资讯详情"}},{path:"pages/featured/tcm",style:{navigationBarTitleText:"中医特色诊疗"}},{path:"pages/featured/project",style:{navigationBarTitleText:"项目详情"}},{path:"pages/featured/case",style:{navigationBarTitleText:"案例详情"}},{path:"pages/featured/index",style:{navigationBarTitleText:"特色医疗"}},{path:"pages/featured/cross-border",style:{navigationBarTitleText:"跨境医疗服务"}},{path:"pages/featured/expert",style:{navigationBarTitleText:"专家门诊"}},{path:"pages/featured/all",style:{navigationBarTitleText:"全部特色医疗"}},{path:"pages/featured/bay-area",style:{navigationBarTitleText:"大湾区特色医疗"}},{path:"pages/my/profile",style:{navigationBarTitleText:"个人信息"}},{path:"pages/consultation/index",style:{navigationBarTitleText:"在线问诊"}},{path:"pages/consultation/chat",style:{navigationBarTitleText:"医生问诊"}},{path:"pages/consultation/ai",style:{navigationBarTitleText:"AI问诊助手"}},{path:"pages/my/health-records",style:{navigationBarTitleText:"健康档案",enablePullDownRefresh:!0}}],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/appointment/index",text:"挂号",iconPath:"static/tabbar/appointment.png",selectedIconPath:"static/tabbar/appointment-active.png"},{pagePath:"pages/consultation/index",text:"问诊",iconPath:"static/tabbar/consultation.png",selectedIconPath:"static/tabbar/consultation-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 be(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 we=be(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={},a=s.lib={},n=a.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)}},i=a.WordArray=n.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||r).stringify(this)},concat:function(e){var t=this.words,s=e.words,a=this.sigBytes,n=e.sigBytes;if(this.clamp(),a%4)for(var i=0;i<n;i++){var o=s[i>>>2]>>>24-i%4*8&255;t[a+i>>>2]|=o<<24-(a+i)%4*8}else for(i=0;i<n;i+=4)t[a+i>>>2]=s[i>>>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,a=[],n=function(t){var s=987654321,a=4294967295;return function(){var n=((s=36969*(65535&s)+(s>>16)&a)<<16)+(t=18e3*(65535&t)+(t>>16)&a)&a;return n/=4294967296,(n+=.5)*(e.random()>.5?1:-1)}},o=0;o<t;o+=4){var r=n(4294967296*(s||e.random()));s=987654071*r(),a.push(4294967296*r()|0)}return new i.init(a,t)}}),o=s.enc={},r=o.Hex={stringify:function(e){for(var t=e.words,s=e.sigBytes,a=[],n=0;n<s;n++){var i=t[n>>>2]>>>24-n%4*8&255;a.push((i>>>4).toString(16)),a.push((15&i).toString(16))}return a.join("")},parse:function(e){for(var t=e.length,s=[],a=0;a<t;a+=2)s[a>>>3]|=parseInt(e.substr(a,2),16)<<24-a%8*4;return new i.init(s,t/2)}},l=o.Latin1={stringify:function(e){for(var t=e.words,s=e.sigBytes,a=[],n=0;n<s;n++){var i=t[n>>>2]>>>24-n%4*8&255;a.push(String.fromCharCode(i))}return a.join("")},parse:function(e){for(var t=e.length,s=[],a=0;a<t;a++)s[a>>>2]|=(255&e.charCodeAt(a))<<24-a%4*8;return new i.init(s,t)}},c=o.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},u=a.BufferedBlockAlgorithm=n.extend({reset:function(){this._data=new i.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=c.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var s=this._data,a=s.words,n=s.sigBytes,o=this.blockSize,r=n/(4*o),l=(r=t?e.ceil(r):e.max((0|r)-this._minBufferSize,0))*o,c=e.min(4*l,n);if(l){for(var u=0;u<l;u+=o)this._doProcessBlock(a,u);var d=a.splice(0,l);s.sigBytes-=c}return new i.init(d,c)},clone:function(){var e=n.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});a.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 d.HMAC.init(e,s).finalize(t)}}});var d=s.algo={};return s}(Math),s)}),Te=we,ke=(be(function(e,t){var s;e.exports=(s=Te,function(e){var t=s,a=t.lib,n=a.WordArray,i=a.Hasher,o=t.algo,r=[];!function(){for(var t=0;t<64;t++)r[t]=4294967296*e.abs(e.sin(t+1))|0}();var l=o.MD5=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var s=0;s<16;s++){var a=t+s,n=e[a];e[a]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var i=this._hash.words,o=e[t+0],l=e[t+1],p=e[t+2],f=e[t+3],g=e[t+4],m=e[t+5],y=e[t+6],v=e[t+7],_=e[t+8],b=e[t+9],w=e[t+10],T=e[t+11],k=e[t+12],x=e[t+13],I=e[t+14],S=e[t+15],P=i[0],A=i[1],C=i[2],O=i[3];P=c(P,A,C,O,o,7,r[0]),O=c(O,P,A,C,l,12,r[1]),C=c(C,O,P,A,p,17,r[2]),A=c(A,C,O,P,f,22,r[3]),P=c(P,A,C,O,g,7,r[4]),O=c(O,P,A,C,m,12,r[5]),C=c(C,O,P,A,y,17,r[6]),A=c(A,C,O,P,v,22,r[7]),P=c(P,A,C,O,_,7,r[8]),O=c(O,P,A,C,b,12,r[9]),C=c(C,O,P,A,w,17,r[10]),A=c(A,C,O,P,T,22,r[11]),P=c(P,A,C,O,k,7,r[12]),O=c(O,P,A,C,x,12,r[13]),C=c(C,O,P,A,I,17,r[14]),P=u(P,A=c(A,C,O,P,S,22,r[15]),C,O,l,5,r[16]),O=u(O,P,A,C,y,9,r[17]),C=u(C,O,P,A,T,14,r[18]),A=u(A,C,O,P,o,20,r[19]),P=u(P,A,C,O,m,5,r[20]),O=u(O,P,A,C,w,9,r[21]),C=u(C,O,P,A,S,14,r[22]),A=u(A,C,O,P,g,20,r[23]),P=u(P,A,C,O,b,5,r[24]),O=u(O,P,A,C,I,9,r[25]),C=u(C,O,P,A,f,14,r[26]),A=u(A,C,O,P,_,20,r[27]),P=u(P,A,C,O,x,5,r[28]),O=u(O,P,A,C,p,9,r[29]),C=u(C,O,P,A,v,14,r[30]),P=d(P,A=u(A,C,O,P,k,20,r[31]),C,O,m,4,r[32]),O=d(O,P,A,C,_,11,r[33]),C=d(C,O,P,A,T,16,r[34]),A=d(A,C,O,P,I,23,r[35]),P=d(P,A,C,O,l,4,r[36]),O=d(O,P,A,C,g,11,r[37]),C=d(C,O,P,A,v,16,r[38]),A=d(A,C,O,P,w,23,r[39]),P=d(P,A,C,O,x,4,r[40]),O=d(O,P,A,C,o,11,r[41]),C=d(C,O,P,A,f,16,r[42]),A=d(A,C,O,P,y,23,r[43]),P=d(P,A,C,O,b,4,r[44]),O=d(O,P,A,C,k,11,r[45]),C=d(C,O,P,A,S,16,r[46]),P=h(P,A=d(A,C,O,P,p,23,r[47]),C,O,o,6,r[48]),O=h(O,P,A,C,v,10,r[49]),C=h(C,O,P,A,I,15,r[50]),A=h(A,C,O,P,m,21,r[51]),P=h(P,A,C,O,k,6,r[52]),O=h(O,P,A,C,f,10,r[53]),C=h(C,O,P,A,w,15,r[54]),A=h(A,C,O,P,l,21,r[55]),P=h(P,A,C,O,_,6,r[56]),O=h(O,P,A,C,S,10,r[57]),C=h(C,O,P,A,y,15,r[58]),A=h(A,C,O,P,x,21,r[59]),P=h(P,A,C,O,g,6,r[60]),O=h(O,P,A,C,T,10,r[61]),C=h(C,O,P,A,p,15,r[62]),A=h(A,C,O,P,b,21,r[63]),i[0]=i[0]+P|0,i[1]=i[1]+A|0,i[2]=i[2]+C|0,i[3]=i[3]+O|0},_doFinalize:function(){var t=this._data,s=t.words,a=8*this._nDataBytes,n=8*t.sigBytes;s[n>>>5]|=128<<24-n%32;var i=e.floor(a/4294967296),o=a;s[15+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),s[14+(n+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t.sigBytes=4*(s.length+1),this._process();for(var r=this._hash,l=r.words,c=0;c<4;c++){var u=l[c];l[c]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return r},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});function c(e,t,s,a,n,i,o){var r=e+(t&s|~t&a)+n+o;return(r<<i|r>>>32-i)+t}function u(e,t,s,a,n,i,o){var r=e+(t&a|s&~a)+n+o;return(r<<i|r>>>32-i)+t}function d(e,t,s,a,n,i,o){var r=e+(t^s^a)+n+o;return(r<<i|r>>>32-i)+t}function h(e,t,s,a,n,i,o){var r=e+(s^(t|~a))+n+o;return(r<<i|r>>>32-i)+t}t.MD5=i._createHelper(l),t.HmacMD5=i._createHmacHelper(l)}(Math),s.MD5)}),be(function(e,t){var s,a,n;e.exports=(a=(s=Te).lib.Base,n=s.enc.Utf8,void(s.algo.HMAC=a.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=n.parse(t));var s=e.blockSize,a=4*s;t.sigBytes>a&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),r=i.words,l=o.words,c=0;c<s;c++)r[c]^=1549556828,l[c]^=909522486;i.sigBytes=o.sigBytes=a,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))}})))}),be(function(e,t){e.exports=Te.HmacMD5})),xe=be(function(e,t){e.exports=Te.enc.Utf8}),Ie=be(function(e,t){var s,a,n;e.exports=(n=(a=s=Te).lib.WordArray,a.enc.Base64={stringify:function(e){var t=e.words,s=e.sigBytes,a=this._map;e.clamp();for(var n=[],i=0;i<s;i+=3)for(var o=(t[i>>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,r=0;r<4&&i+.75*r<s;r++)n.push(a.charAt(o>>>6*(3-r)&63));var l=a.charAt(64);if(l)for(;n.length%4;)n.push(l);return n.join("")},parse:function(e){var t=e.length,s=this._map,a=this._reverseMap;if(!a){a=this._reverseMap=[];for(var i=0;i<s.length;i++)a[s.charCodeAt(i)]=i}var o=s.charAt(64);if(o){var r=e.indexOf(o);-1!==r&&(t=r)}return function(e,t,s){for(var a=[],i=0,o=0;o<t;o++)if(o%4){var r=s[e.charCodeAt(o-1)]<<o%4*2,l=s[e.charCodeAt(o)]>>>6-o%4*2;a[i>>>2]|=(r|l)<<24-i%4*8,i++}return n.create(a,i)}(e,t,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},s.enc.Base64)});const Se="uni_id_token",Pe="uni_id_token_expired",Ae="FUNCTION",Ce="OBJECT",Oe="CLIENT_DB",Fe="pending",Le="rejected";function Ee(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function Ue(e){return"object"===Ee(e)}function De(e){return"function"==typeof e}function Ne(e){return function(){try{return e.apply(e,arguments)}catch(t){console.error(t)}}}const Re="REJECTED",Me="NOT_PENDING";class $e{constructor({createPromise:e,retryRule:t=Re}={}){this.createPromise=e,this.status=null,this.promise=null,this.retryRule=t}get needRetry(){if(!this.status)return!0;switch(this.retryRule){case Re:return this.status===Le;case Me:return this.status!==Fe}}exec(){return this.needRetry?(this.status=Fe,this.promise=this.createPromise().then(e=>(this.status="fulfilled",Promise.resolve(e)),e=>(this.status=Le,Promise.reject(e))),this.promise):this.promise}}class Be{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 a=function(e,t){for(let s=e.length-1;s>=0;s--)if(e[s]===t)return s;return-1}(s,t);s.splice(a,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 a=0;a<s.length;a++)s[a](...t)}}function qe(e){return e&&"string"==typeof e?JSON.parse(e):e}const je=qe([]),Ve="web";qe("");const Ke=qe("[]")||[];let ze="";try{ze="__UNI__46B5420"}catch(Dt){}let He,We={};function Je(e,t={}){var s,a;return s=We,a=e,Object.prototype.hasOwnProperty.call(s,a)||(We[e]=t),We[e]}const Ge=["invoke","success","fail","complete"],Qe=Je("_globalUniCloudInterceptor");function Ye(e,t){Qe[e]||(Qe[e]={}),Ue(t)&&Object.keys(t).forEach(s=>{Ge.indexOf(s)>-1&&function(e,t,s){let a=Qe[e][t];a||(a=Qe[e][t]=[]),-1===a.indexOf(s)&&De(s)&&a.push(s)}(e,s,t[s])})}function Xe(e,t){Qe[e]||(Qe[e]={}),Ue(t)?Object.keys(t).forEach(s=>{Ge.indexOf(s)>-1&&function(e,t,s){const a=Qe[e][t];if(!a)return;const n=a.indexOf(s);n>-1&&a.splice(n,1)}(e,s,t[s])}):delete Qe[e]}function Ze(e,t){return e&&0!==e.length?e.reduce((e,s)=>e.then(()=>s(t)),Promise.resolve()):Promise.resolve()}function et(e,t){return Qe[e]&&Qe[e][t]||[]}function tt(e){Ye("callObject",e)}const st=Je("_globalUniCloudListener"),at="response",nt="needLogin",it="refreshToken",ot="clientdb",rt="cloudfunction",lt="cloudobject";function ct(e){return st[e]||(st[e]=[]),st[e]}function ut(e,t){const s=ct(e);s.includes(t)||s.push(t)}function dt(e,t){const s=ct(e),a=s.indexOf(t);-1!==a&&s.splice(a,1)}function ht(e,t){const s=ct(e);for(let a=0;a<s.length;a++)(0,s[a])(t)}let pt,ft=!1;function gt(){return pt||(pt=new Promise(e=>{ft&&e(),function t(){if("function"==typeof s){const t=s();t&&t[0]&&(ft=!0,e())}ft||setTimeout(()=>{t()},30)}()}),pt)}function mt(e){const t={};for(const s in e){const a=e[s];De(a)&&(t[s]=Ne(a))}return t}class yt 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 vt={request:e=>d(e),uploadFile:e=>h(e),setStorageSync:(e,t)=>p(e,t),getStorageSync:e=>f(e),removeStorageSync:e=>g(e),clearStorageSync:()=>m(),connectSocket:e=>y(e)};function _t(e){return e&&_t(e.__v_raw)||e}function bt(){return{token:vt.getStorageSync(Se)||vt.getStorageSync("uniIdToken"),tokenExpired:vt.getStorageSync(Pe)}}function wt({token:e,tokenExpired:t}={}){e&&vt.setStorageSync(Se,e),t&&vt.setStorageSync(Pe,t)}let Tt,kt;function xt(){return Tt||(Tt=v()),Tt}function It(){let e,t;try{if(S){if(S.toString().indexOf("not yet implemented")>-1)return;const{scene:s,channel:a}=S();e=a,t=s}}catch(s){}return{channel:e,scene:t}}let St={};function Pt(){const e=I&&I()||"en";if(kt)return{...St,...kt,locale:e,LOCALE:e};const t=xt(),{deviceId:s,osName:a,uniPlatform:n,appId:i}=t,o=["appId","appLanguage","appName","appVersion","appVersionCode","appWgtVersion","browserName","browserVersion","deviceBrand","deviceId","deviceModel","deviceType","osName","osVersion","romName","romVersion","ua","hostName","hostVersion","uniPlatform","uniRuntimeVersion","uniRuntimeVersionCode","uniCompilerVersion","uniCompilerVersionCode"];for(const r in t)Object.hasOwnProperty.call(t,r)&&-1===o.indexOf(r)&&delete t[r];return kt={PLATFORM:n,OS:a,APPID:i,DEVICEID:s,...It(),...t},{...St,...kt,locale:e,LOCALE:e}}var At=function(e,t){let s="";return Object.keys(e).sort().forEach(function(t){e[t]&&(s=s+"&"+t+"="+e[t])}),s=s.slice(1),ke(s,t).toString()},Ct=function(e,t){return new Promise((s,a)=>{t(Object.assign(e,{complete(e){e||(e={});const t=e.data&&e.data.header&&e.data.header["x-serverless-request-id"]||e.header&&e.header["request-id"];if(!e.statusCode||e.statusCode>=400){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 a(new yt({code:s,message:n,requestId:t}))}const n=e.data;if(n.error)return a(new yt({code:n.error.code,message:n.error.message,requestId:t}));n.result=n.data,n.requestId=t,delete n.data,s(n)}}))})},Ot=function(e){return Ie.stringify(xe.parse(e))},Ft=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=vt,this._getAccessTokenPromiseHub=new $e({createPromise:()=>this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then(e=>{if(!e.result||!e.result.accessToken)throw new yt({code:"AUTH_FAILED",message:"获取accessToken失败"});this.setAccessToken(e.result.accessToken)}),retryRule:Me})}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return Ct(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"]=At(t.data,this.config.clientSecret),t}setupRequest(e,t){const s=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),a={"Content-Type":"application/json"};return"auth"!==t&&(s.token=this.accessToken,a["x-basement-token"]=this.accessToken),a["x-serverless-sign"]=At(s,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:s,dataType:"json",header:a}}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:a,fileType:n,onUploadProgress:i}){return new Promise((o,r)=>{const l=this.adapter.uploadFile({url:e,formData:t,name:s,filePath:a,fileType:n,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?o(e):r(new yt({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){r(new yt({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof i&&l&&"function"==typeof l.onProgressUpdate&&l.onProgressUpdate(e=>{i({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})})})}reportOSSUpload(e){const t={method:"serverless.file.resource.report",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}async uploadFile({filePath:e,cloudPath:t,fileType:s="image",cloudPathAsRealPath:a=!1,onUploadProgress:n,config:i}){if("string"!==Ee(t))throw new yt({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new yt({code:"INVALID_PARAM",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new yt({code:"INVALID_PARAM",message:"cloudPath不合法"});const o=i&&i.envType||this.config.envType;if(a&&("/"!==t[0]&&(t="/"+t),t.indexOf("\\")>-1))throw new yt({code:"INVALID_PARAM",message:"使用cloudPath作为路径时,cloudPath不可包含“\\”"});const r=(await this.getOSSUploadOptionsFromPath({env:o,filename:a?t.split("/").pop():t,fileId:a?t:void 0})).result,l="https://"+r.cdnDomain+"/"+r.ossPath,{securityToken:c,accessKeyId:u,signature:d,host:h,ossPath:p,id:f,policy:g,ossCallbackUrl:m}=r,y={"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:u,Signature:d,host:h,id:f,key:p,policy:g,success_action_status:200};if(c&&(y["x-oss-security-token"]=c),m){const e=JSON.stringify({callbackUrl:m,callbackBody:JSON.stringify({fileId:f,spaceId:this.config.spaceId}),callbackBodyType:"application/json"});y.callback=Ot(e)}const v={url:"https://"+r.host,formData:y,fileName:"file",name:"file",filePath:e,fileType:s};if(await this.uploadFileToOSS(Object.assign({},v,{onUploadProgress:n})),m)return{success:!0,filePath:e,fileID:l};if((await this.reportOSSUpload({id:f})).success)return{success:!0,filePath:e,fileID:l};throw new yt({code:"UPLOAD_FAILED",message:"文件上传失败"})}getTempFileURL({fileList:e}={}){return new Promise((t,s)=>{Array.isArray(e)&&0!==e.length||s(new yt({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),this.getFileInfo({fileList:e}).then(s=>{t({fileList:e.map((e,t)=>{const a=s.fileList[t];return{fileID:e,tempFileURL:a&&a.url||e}})})})})}async getFileInfo({fileList:e}={}){if(!Array.isArray(e)||0===e.length)throw new yt({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}}},Lt={init(e){const t=new Ft(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 Et="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var Ut,Dt;(Dt=Ut||(Ut={})).local="local",Dt.none="none",Dt.session="session";var Nt=function(){},Rt=be(function(e,t){var s;e.exports=(s=Te,function(e){var t=s,a=t.lib,n=a.WordArray,i=a.Hasher,o=t.algo,r=[],l=[];!function(){function t(t){for(var s=e.sqrt(t),a=2;a<=s;a++)if(!(t%a))return!1;return!0}function s(e){return 4294967296*(e-(0|e))|0}for(var a=2,n=0;n<64;)t(a)&&(n<8&&(r[n]=s(e.pow(a,.5))),l[n]=s(e.pow(a,1/3)),n++),a++}();var c=[],u=o.SHA256=i.extend({_doReset:function(){this._hash=new n.init(r.slice(0))},_doProcessBlock:function(e,t){for(var s=this._hash.words,a=s[0],n=s[1],i=s[2],o=s[3],r=s[4],u=s[5],d=s[6],h=s[7],p=0;p<64;p++){if(p<16)c[p]=0|e[t+p];else{var f=c[p-15],g=(f<<25|f>>>7)^(f<<14|f>>>18)^f>>>3,m=c[p-2],y=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;c[p]=g+c[p-7]+y+c[p-16]}var v=a&n^a&i^n&i,_=(a<<30|a>>>2)^(a<<19|a>>>13)^(a<<10|a>>>22),b=h+((r<<26|r>>>6)^(r<<21|r>>>11)^(r<<7|r>>>25))+(r&u^~r&d)+l[p]+c[p];h=d,d=u,u=r,r=o+b|0,o=i,i=n,n=a,a=b+(_+v)|0}s[0]=s[0]+a|0,s[1]=s[1]+n|0,s[2]=s[2]+i|0,s[3]=s[3]+o|0,s[4]=s[4]+r|0,s[5]=s[5]+u|0,s[6]=s[6]+d|0,s[7]=s[7]+h|0},_doFinalize:function(){var t=this._data,s=t.words,a=8*this._nDataBytes,n=8*t.sigBytes;return s[n>>>5]|=128<<24-n%32,s[14+(n+64>>>9<<4)]=e.floor(a/4294967296),s[15+(n+64>>>9<<4)]=a,t.sigBytes=4*s.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(u),t.HmacSHA256=i._createHmacHelper(u)}(Math),s.SHA256)}),Mt=Rt,$t=be(function(e,t){e.exports=Te.HmacSHA256});const Bt=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new yt({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,a)=>e?s(e):t(a)});return e.promise=t,e};function qt(e){return void 0===e}function jt(e){return"[object Null]"===Object.prototype.toString.call(e)}function Vt(e=""){return e.replace(/([\s\S]+)\s+(请前往云开发AI小助手查看问题:.*)/,"$1")}function Kt(e=32){let t="";for(let s=0;s<e;s++)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return t}var zt;!function(e){e.WEB="web",e.WX_MP="wx_mp"}(zt||(zt={}));const Ht={adapter:null,runtime:void 0},Wt=["anonymousUuidKey"];class Jt extends Nt{constructor(){super(),Ht.adapter.root.tcbObject||(Ht.adapter.root.tcbObject={})}setItem(e,t){Ht.adapter.root.tcbObject[e]=t}getItem(e){return Ht.adapter.root.tcbObject[e]}removeItem(e){delete Ht.adapter.root.tcbObject[e]}clear(){delete Ht.adapter.root.tcbObject}}function Gt(e,t){switch(e){case"local":return t.localStorage||new Jt;case"none":return new Jt;default:return t.sessionStorage||new Jt}}class Qt{constructor(e){if(!this._storage){this._persistence=Ht.adapter.primaryStorage||e.persistence,this._storage=Gt(this._persistence,Ht.adapter);const t=`access_token_${e.env}`,s=`access_token_expire_${e.env}`,a=`refresh_token_${e.env}`,n=`anonymous_uuid_${e.env}`,i=`login_type_${e.env}`,o="device_id",r=`token_type_${e.env}`,l=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:s,refreshTokenKey:a,anonymousUuidKey:n,loginTypeKey:i,userInfoKey:l,deviceIdKey:o,tokenTypeKey:r}}}updatePersistence(e){if(e===this._persistence)return;const t="local"===this._persistence;this._persistence=e;const s=Gt(e,Ht.adapter);for(const a in this.keys){const e=this.keys[a];if(t&&Wt.includes(a))continue;const n=this._storage.getItem(e);qt(n)||jt(n)||(s.setItem(e,n),this._storage.removeItem(e))}this._storage=s}setStore(e,t,s){if(!this._storage)return;const a={version:s||"localCachev1",content:t},n=JSON.stringify(a);try{this._storage.setItem(e,n)}catch(i){throw i}}getStore(e,t){try{if(!this._storage)return}catch(a){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 Yt={},Xt={};function Zt(e){return Yt[e]}class es{constructor(e,t){this.data=t||null,this.name=e}}class ts extends es{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const ss=new class{constructor(){this._listeners={}}on(e,t){return s=e,a=t,(n=this._listeners)[s]=n[s]||[],n[s].push(a),this;var s,a,n}off(e,t){return function(e,t,s){if(s&&s[e]){const a=s[e].indexOf(t);-1!==a&&s[e].splice(a,1)}}(e,t,this._listeners),this}fire(e,t){if(e instanceof ts)return console.error(e.error),this;const s="string"==typeof e?new es(e,t||{}):e,a=s.name;if(this._listens(a)){s.target=this;const e=this._listeners[a]?[...this._listeners[a]]:[];for(const t of e)t.call(this,s)}return this}_listens(e){return this._listeners[e]&&this._listeners[e].length>0}};function as(e,t){ss.on(e,t)}function ns(e,t={}){ss.fire(e,t)}function is(e,t){ss.off(e,t)}const os="loginStateChanged",rs="loginStateExpire",ls="loginTypeChanged",cs="anonymousConverted",us="refreshAccessToken";var ds;!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"}(ds||(ds={}));class hs{constructor(){this._fnPromiseMap=new Map}async run(e,t){let s=this._fnPromiseMap.get(e);return s||(s=new Promise(async(s,a)=>{try{await this._runIdlePromise();const e=t();s(await e)}catch(n){a(n)}finally{this._fnPromiseMap.delete(e)}}),this._fnPromiseMap.set(e,s)),s}_runIdlePromise(){return Promise.resolve()}}class ps{constructor(e){this._singlePromise=new hs,this._cache=Zt(e.env),this._baseURL=`https://${e.env}.ap-shanghai.tcb-api.tencentcloudapi.com`,this._reqClass=new Ht.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=Kt(),this._cache.setStore(e,t)),this._deviceID=t,t}async _request(e,t,s={}){const a={"x-request-id":Kt(),"x-device-id":this._getDeviceId()};if(s.withAccessToken){const{tokenTypeKey:e}=this._cache.keys,t=await this.getAccessToken(),s=this._cache.getStore(e);a.authorization=`${s} ${t}`}return this._reqClass["get"===s.method?"get":"post"]({url:`${this._baseURL}${e}`,data:t,headers:a})}async _fetchAccessToken(){const{loginTypeKey:e,accessTokenKey:t,accessTokenExpireKey:s,tokenTypeKey:a}=this._cache.keys,n=this._cache.getStore(e);if(n&&n!==ds.ANONYMOUS)throw new yt({code:"INVALID_OPERATION",message:"非匿名登录不支持刷新 access token"});const i=await this._singlePromise.run("fetchAccessToken",async()=>(await this._request("/auth/v1/signin/anonymously",{},{method:"post"})).data),{access_token:o,expires_in:r,token_type:l}=i;return this._cache.setStore(a,l),this._cache.setStore(t,o),this._cache.setStore(s,Date.now()+1e3*r),o}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),a=this._cache.getStore(t);return this.isAccessTokenExpired(s,a)?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,ds.ANONYMOUS),this.getAccessToken()}async getUserInfo(){return this._singlePromise.run("getUserInfo",async()=>(await this._request("/auth/v1/user/me",{},{withAccessToken:!0,method:"get"})).data)}}const fs=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],gs={"X-SDK-Version":"1.3.5"};function ms(e,t,s){const a=e[t];e[t]=function(t){const n={},i={};s.forEach(s=>{const{data:a,headers:o}=s.call(e,t);Object.assign(n,a),Object.assign(i,o)});const o=t.data;return o&&(()=>{var e;if(e=o,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...o,...n};else for(const t in n)o.append(t,n[t])})(),t.headers={...t.headers||{},...i},a.call(e,t)}}function ys(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...gs,"x-seqid":e}}}class vs{constructor(e={}){var t;this.config=e,this._reqClass=new Ht.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=Zt(this.config.env),this._localCache=(t=this.config.env,Xt[t]),this.oauth=new ps(this.config),ms(this._reqClass,"post",[ys]),ms(this._reqClass,"upload",[ys]),ms(this._reqClass,"download",[ys])}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:a,anonymousUuidKey:n}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);let i=this._cache.getStore(s);if(!i)throw new yt({message:"未登录CloudBase"});const o={refresh_token:i},r=await this.request("auth.fetchAccessTokenWithRefreshToken",o);if(r.data.code){const{code:e}=r.data;if("SIGN_PARAM_INVALID"===e||"REFRESH_TOKEN_EXPIRED"===e||"INVALID_REFRESH_TOKEN"===e){if(this._cache.getStore(a)===ds.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){const e=this._cache.getStore(n),t=this._cache.getStore(s),a=await this.send("auth.signInAnonymously",{anonymous_uuid:e,refresh_token:t});return this.setRefreshToken(a.refresh_token),this._refreshAccessToken()}ns(rs),this._cache.removeStore(s)}throw new yt({code:r.data.code,message:`刷新access token失败:${r.data.code}`})}if(r.data.access_token)return ns(us),this._cache.setStore(e,r.data.access_token),this._cache.setStore(t,r.data.access_token_expire+Date.now()),{accessToken:r.data.access_token,accessTokenExpire:r.data.access_token_expire};r.data.refresh_token&&(this._cache.removeStore(s),this._cache.setStore(s,r.data.refresh_token),this._refreshAccessToken())}async getAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:s}=this._cache.keys;if(!this._cache.getStore(s))throw new yt({message:"refresh token不存在,登录状态异常"});let a=this._cache.getStore(e),n=this._cache.getStore(t),i=!0;return this._shouldRefreshAccessTokenHook&&!(await this._shouldRefreshAccessTokenHook(a,n))&&(i=!1),(!a||!n||n<Date.now())&&i?this.refreshAccessToken():{accessToken:a,accessTokenExpire:n}}async request(e,t,s){const a=`x-tcb-trace_${this.config.env}`;let n="application/x-www-form-urlencoded";const i={action:e,env:this.config.env,dataVersion:"2019-08-16",...t};let o;if(-1===fs.indexOf(e)&&(this._cache.keys,i.access_token=await this.oauth.getAccessToken()),"storage.uploadFile"===e){o=new FormData;for(let e in o)o.hasOwnProperty(e)&&void 0!==o[e]&&o.append(e,i[e]);n="multipart/form-data"}else{n="application/json",o={};for(let e in i)void 0!==i[e]&&(o[e]=i[e])}let r={headers:{"content-type":n}};s&&s.timeout&&(r.timeout=s.timeout),s&&s.onUploadProgress&&(r.onUploadProgress=s.onUploadProgress);const l=this._localCache.getStore(a);l&&(r.headers["X-TCB-Trace"]=l);const{parse:c,inQuery:u,search:d}=t;let h={env:this.config.env};c&&(h.parse=!0),u&&(h={...u,...h});let p=function(e,t,s={}){const a=/\?/.test(t);let n="";for(let i in s)""===n?!a&&(t+="?"):n+="&",n+=`${i}=${encodeURIComponent(s[i])}`;return/^http(s)?\:\/\//.test(t+=n)?t:`${e}${t}`}(Et,"//tcb-api.tencentcloudapi.com/web",h);d&&(p+=d);const f=await this.post({url:p,data:o,...r}),g=f.header&&f.header["x-tcb-trace"];if(g&&this._localCache.setStore(a,g),200!==Number(f.status)&&200!==Number(f.statusCode)||!f.data)throw new yt({code:"NETWORK_ERROR",message:"network request error"});return f}async send(e,t={},s={}){const a=await this.request(e,t,{...s,onUploadProgress:t.onUploadProgress});if(("ACCESS_TOKEN_DISABLED"===a.data.code||"ACCESS_TOKEN_EXPIRED"===a.data.code)&&-1===fs.indexOf(e)){await this.oauth.refreshAccessToken();const a=await this.request(e,t,{...s,onUploadProgress:t.onUploadProgress});if(a.data.code)throw new yt({code:a.data.code,message:Vt(a.data.message)});return a.data}if(a.data.code)throw new yt({code:a.data.code,message:Vt(a.data.message)});return a.data}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:s,refreshTokenKey:a}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(s),this._cache.setStore(a,e)}}const _s={};function bs(e){return _s[e]}class ws{constructor(e){this.config=e,this._cache=Zt(e.env),this._request=bs(e.env)}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:s,refreshTokenKey:a}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(s),this._cache.setStore(a,e)}setAccessToken(e,t){const{accessTokenKey:s,accessTokenExpireKey:a}=this._cache.keys;this._cache.setStore(s,e),this._cache.setStore(a,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 Ts{constructor(e){if(!e)throw new yt({code:"PARAM_ERROR",message:"envId is not defined"});this._envId=e,this._cache=Zt(this._envId),this._request=bs(this._envId),this.setUserInfo()}linkWithTicket(e){if("string"!=typeof e)throw new yt({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 yt({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:a,province:n,country:i,city:o}=e,{data:r}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:s,avatarUrl:a,province:n,country:i,city:o});this.setLocalUserInfo(r)}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 ks{constructor(e){if(!e)throw new yt({code:"PARAM_ERROR",message:"envId is not defined"});this._cache=Zt(e);const{refreshTokenKey:t,accessTokenKey:s,accessTokenExpireKey:a}=this._cache.keys,n=this._cache.getStore(t),i=this._cache.getStore(s),o=this._cache.getStore(a);this.credential={refreshToken:n,accessToken:i,accessTokenExpire:o},this.user=new Ts(e)}get isAnonymousAuth(){return this.loginType===ds.ANONYMOUS}get isCustomAuth(){return this.loginType===ds.CUSTOM}get isWeixinAuth(){return this.loginType===ds.WECHAT||this.loginType===ds.WECHAT_OPEN||this.loginType===ds.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class xs extends ws{async signIn(){this._cache.updatePersistence("local"),await this._request.oauth.getAccessToken(),ns(os),ns(ls,{env:this.config.env,loginType:ds.ANONYMOUS,persistence:"local"});const e=new ks(this.config.env);return await e.user.refresh(),e}async linkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:s}=this._cache.keys,a=this._cache.getStore(t),n=this._cache.getStore(s),i=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:a,refresh_token:n,ticket:e});if(i.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(i.refresh_token),await this._request.refreshAccessToken(),ns(cs,{env:this.config.env}),ns(ls,{loginType:ds.CUSTOM,persistence:"local"}),{credential:{refreshToken:i.refresh_token}};throw new yt({message:"匿名转化失败"})}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:s}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(s,ds.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class Is extends ws{async signIn(e){if("string"!=typeof e)throw new yt({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(),ns(os),ns(ls,{env:this.config.env,loginType:ds.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new ks(this.config.env);throw new yt({message:"自定义登录失败"})}}class Ss extends ws{async signIn(e,t){if("string"!=typeof e)throw new yt({code:"PARAM_ERROR",message:"email must be a string"});const{refreshTokenKey:s}=this._cache.keys,a=await this._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(s)||""}),{refresh_token:n,access_token:i,access_token_expire:o}=a;if(n)return this.setRefreshToken(n),i&&o?this.setAccessToken(i,o):await this._request.refreshAccessToken(),await this.refreshUserInfo(),ns(os),ns(ls,{env:this.config.env,loginType:ds.EMAIL,persistence:this.config.persistence}),new ks(this.config.env);throw a.code?new yt({code:a.code,message:`邮箱登录失败: ${a.message}`}):new yt({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 Ps extends ws{async signIn(e,t){if("string"!=typeof e)throw new yt({code:"PARAM_ERROR",message:"username must be a string"});"string"!=typeof t&&(t="",console.warn("password is empty"));const{refreshTokenKey:s}=this._cache.keys,a=await this._request.send("auth.signIn",{loginType:ds.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(s)||""}),{refresh_token:n,access_token_expire:i,access_token:o}=a;if(n)return this.setRefreshToken(n),o&&i?this.setAccessToken(o,i):await this._request.refreshAccessToken(),await this.refreshUserInfo(),ns(os),ns(ls,{env:this.config.env,loginType:ds.USERNAME,persistence:this.config.persistence}),new ks(this.config.env);throw a.code?new yt({code:a.code,message:`用户名密码登录失败: ${a.message}`}):new yt({message:"用户名密码登录失败"})}}class As{constructor(e){this.config=e,this._cache=Zt(e.env),this._request=bs(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),as(ls,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 xs(this.config)}customAuthProvider(){return new Is(this.config)}emailAuthProvider(){return new Ss(this.config)}usernameAuthProvider(){return new Ps(this.config)}async signInAnonymously(){return new xs(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new Ss(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new Ps(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){return this._anonymousAuthProvider||(this._anonymousAuthProvider=new xs(this.config)),as(cs,this._onAnonymousConverted),await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===ds.ANONYMOUS)throw new yt({message:"匿名用户不支持登出操作"});const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:s}=this._cache.keys,a=this._cache.getStore(e);if(!a)return;const n=await this._request.send("auth.logout",{refresh_token:a});return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(s),ns(os),ns(ls,{env:this.config.env,loginType:ds.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){as(os,()=>{const t=this.hasLoginState();e.call(this,t)});const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){as(rs,e.bind(this))}onAccessTokenRefreshed(e){as(us,e.bind(this))}onAnonymousConverted(e){as(cs,e.bind(this))}onLoginTypeChanged(e){as(ls,()=>{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),a=this._cache.getStore(t);return this._request.oauth.isAccessTokenExpired(s,a)?null:new ks(this.config.env)}async isUsernameRegistered(e){if("string"!=typeof e)throw new yt({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 Is(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:a}=e.data;a===this.config.env&&(this._cache.updatePersistence(s),this._cache.setStore(this._cache.keys.loginTypeKey,t))}}const Cs=function(e,t){t=t||Bt();const s=bs(this.config.env),{cloudPath:a,filePath:n,onUploadProgress:i,fileType:o="image"}=e;return s.send("storage.getUploadMetadata",{path:a}).then(e=>{const{data:{url:r,authorization:l,token:c,fileId:u,cosFileId:d},requestId:h}=e,p={key:a,signature:l,"x-cos-meta-fileid":d,success_action_status:"201","x-cos-security-token":c};s.upload({url:r,data:p,file:n,name:a,fileType:o,onUploadProgress:i}).then(e=>{201===e.statusCode?t(null,{fileID:u,requestId:h}):t(new yt({code:"STORAGE_REQUEST_FAIL",message:`STORAGE_REQUEST_FAIL: ${e.data}`}))}).catch(e=>{t(e)})}).catch(e=>{t(e)}),t.promise},Os=function(e,t){t=t||Bt();const s=bs(this.config.env),{cloudPath:a}=e;return s.send("storage.getUploadMetadata",{path:a}).then(e=>{t(null,e)}).catch(e=>{t(e)}),t.promise},Fs=function({fileList:e},t){if(t=t||Bt(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(let a of e)if(!a||"string"!=typeof a)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};const s={fileid_list:e};return bs(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},Ls=function({fileList:e},t){t=t||Bt(),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 a={file_list:s};return bs(this.config.env).send("storage.batchGetDownloadUrl",a).then(e=>{e.code?t(null,e):t(null,{fileList:e.data.download_list,requestId:e.requestId})}).catch(e=>{t(e)}),t.promise},Es=async function({fileID:e},t){const s=(await Ls.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==s.code)return t?t(s):new Promise(e=>{e(s)});const a=bs(this.config.env);let n=s.download_url;if(n=encodeURI(n),!t)return a.download({url:n});t(await a.download({url:n}))},Us=function({name:e,data:t,query:s,parse:a,search:n,timeout:i},o){const r=o||Bt();let l;try{l=t?JSON.stringify(t):""}catch(u){return Promise.reject(u)}if(!e)return Promise.reject(new yt({code:"PARAM_ERROR",message:"函数名不能为空"}));const c={inQuery:s,parse:a,search:n,function_name:e,request_data:l};return bs(this.config.env).send("functions.invokeFunction",c,{timeout:i}).then(e=>{if(e.code)r(null,e);else{let s=e.data.response_data;if(a)r(null,{result:s,requestId:e.requestId});else try{s=JSON.parse(e.data.response_data),r(null,{result:s,requestId:e.requestId})}catch(t){r(new yt({message:"response data must be json"}))}}return r.promise}).catch(e=>{r(e)}),r.promise},Ds={timeout:15e3,persistence:"session"},Ns=6e5,Rs={};class Ms{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(Ht.adapter||(this.requestClient=new Ht.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...Ds,...e},!0){case this.config.timeout>Ns:console.warn("timeout大于可配置上限[10分钟],已重置为上限数值"),this.config.timeout=Ns;break;case this.config.timeout<100:console.warn("timeout小于可配置下限[100ms],已重置为下限数值"),this.config.timeout=100}return new Ms(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||Ht.adapter.primaryStorage||Ds.persistence;var s;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;Yt[t]=new Qt(e),Xt[t]=new Qt({...e,persistence:"local"})}(this.config),s=this.config,_s[s.env]=new vs(s),this.authObj=new As(this.config),this.authObj}on(e,t){return as.apply(this,[e,t])}off(e,t){return is.apply(this,[e,t])}callFunction(e,t){return Us.apply(this,[e,t])}deleteFile(e,t){return Fs.apply(this,[e,t])}getTempFileURL(e,t){return Ls.apply(this,[e,t])}downloadFile(e,t){return Es.apply(this,[e,t])}uploadFile(e,t){return Cs.apply(this,[e,t])}getUploadMetadata(e,t){return Os.apply(this,[e,t])}registerExtension(e){Rs[e.name]=e}async invokeExtension(e,t){const s=Rs[e];if(!s)throw new yt({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 a of t){const{isMatch:e,genAdapter:t,runtime:s}=a;if(e())return{adapter:t(),runtime:s}}}(e)||{};t&&(Ht.adapter=t),s&&(Ht.runtime=s)}}var $s=new Ms;function Bs(e,t,s){void 0===s&&(s={});var a=/\?/.test(t),n="";for(var i in s)""===n?!a&&(t+="?"):n+="&",n+=i+"="+encodeURIComponent(s[i]);return/^http(s)?:\/\//.test(t+=n)?t:""+e+t}class qs{get(e){const{url:t,data:s,headers:a,timeout:n}=e;return new Promise((e,i)=>{vt.request({url:Bs("https:",t),data:s,method:"GET",header:a,timeout:n,success(t){e(t)},fail(e){i(e)}})})}post(e){const{url:t,data:s,headers:a,timeout:n}=e;return new Promise((e,i)=>{vt.request({url:Bs("https:",t),data:s,method:"POST",header:a,timeout:n,success(t){e(t)},fail(e){i(e)}})})}upload(e){return new Promise((t,s)=>{const{url:a,file:n,data:i,headers:o,fileType:r}=e,l=vt.uploadFile({url:Bs("https:",a),name:"file",formData:Object.assign({},i),filePath:n,fileType:r,header:o,success(e){const s={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&i.success_action_status&&(s.statusCode=parseInt(i.success_action_status,10)),t(s)},fail(e){s(new Error(e.errMsg||"uploadFile:fail"))}});"function"==typeof e.onUploadProgress&&l&&"function"==typeof l.onProgressUpdate&&l.onProgressUpdate(t=>{e.onUploadProgress({loaded:t.totalBytesSent,total:t.totalBytesExpectedToSend})})})}}const js={setItem(e,t){vt.setStorageSync(e,t)},getItem:e=>vt.getStorageSync(e),removeItem(e){vt.removeStorageSync(e)},clear(){vt.clearStorageSync()}};var Vs={genAdapter:function(){return{root:{},reqClass:qs,localStorage:js,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};$s.useAdapters(Vs);const Ks=$s,zs=Ks.init;Ks.init=function(e){e.env=e.spaceId;const t=zs.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:a,complete:n}=mt(e);if(!(t||a||n))return s.call(this,e);s.call(this,e).then(e=>{t&&t(e),n&&n(e)},e=>{a&&a(e),n&&n(e)})}).bind(t)}),t},t.customAuth=t.auth,t};var Hs=Ks;async function Ws(e,t){const s=`http://${e}:${t}/project/ping`;try{const e=await(a={url:s,timeout:500},new Promise((e,t)=>{vt.request({...a,success(t){e(t)},fail(e){t(e)}})}));return!(!e.data||0!==e.data.code)}catch(n){return!1}var a}const Js={"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 Gs=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=vt}async request(e,t=!0){return e=this.setupRequest(e),Promise.resolve().then(()=>Ct(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",a=e.data&&e.data.message||"request:fail";return s(new yt({code:t,message:a}))}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"]=At(t,this.config.clientSecret);const a=Pt();s["x-client-info"]=encodeURIComponent(JSON.stringify(a));const{token:n}=bt();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=Pt(),{token:s}=bt(),a=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now(),clientInfo:t,token:s}),{address:n,servePort:i}=this.__dev__&&this.__dev__.debugInfo||{},{address:o}=await async function(e,t){let s;for(let a=0;a<e.length;a++){const n=e[a];if(await Ws(n,t)){s=n;break}}return{address:s,port:t}}(n,i);return{url:`http://${o}:${i}/${Js[e.method]}`,method:"POST",data:a,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:a}){if(!t)throw new yt({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});let n;return this.getUploadFileOptions({cloudPath:t}).then(t=>{const{url:i,formData:o,name:r}=t.result;return n=t.result.fileUrl,new Promise((t,n)=>{const l=this.adapter.uploadFile({url:i,formData:o,name:r,filePath:e,fileType:s,success(e){e&&e.statusCode<400?t(e):n(new yt({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){n(new yt({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof a&&l&&"function"==typeof l.onProgressUpdate&&l.onProgressUpdate(e=>{a({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})})})}).then(()=>this.reportUploadFile({cloudPath:t})).then(t=>new Promise((s,a)=>{t.success?s({success:!0,filePath:e,fileID:n}):a(new yt({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 yt({code:"DELETE_FILE_FAILED",message:"删除文件失败"})})}getTempFileURL({fileList:e,maxAge:t}={}){if(!Array.isArray(e)||0===e.length)throw new yt({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 yt({code:"GET_TEMP_FILE_URL_FAILED",message:"获取临时文件链接失败"})})}},Qs={init(e){const t=new Gs(e),s={signInAnonymously:function(){return Promise.resolve()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return s},t.customAuth=t.auth,t}},Ys=be(function(e,t){e.exports=Te.enc.Hex});function Xs(){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 Zs(e="",t={}){const{data:s,functionName:a,method:n,headers:i,signHeaderKeys:o=[],config:r}=t,l=String(Date.now()),c=Xs(),u=Object.assign({},i,{"x-from-app-id":r.spaceAppId,"x-from-env-id":r.spaceId,"x-to-env-id":r.spaceId,"x-from-instance-id":l,"x-from-function-name":a,"x-client-timestamp":l,"x-alipay-source":"client","x-request-id":c,"x-alipay-callid":c,"x-trace-id":c}),d=["x-from-app-id","x-from-env-id","x-to-env-id","x-from-instance-id","x-from-function-name","x-client-timestamp"].concat(o),[h="",p=""]=e.split("?")||[],f=function(e){const t="HMAC-SHA256",s=e.signedHeaders.join(";"),a=e.signedHeaders.map(t=>`${t.toLowerCase()}:${e.headers[t]}\n`).join(""),n=Mt(e.body).toString(Ys),i=`${e.method.toUpperCase()}\n${e.path}\n${e.query}\n${a}\n${s}\n${n}\n`,o=Mt(i).toString(Ys),r=`${t}\n${e.timestamp}\n${o}\n`,l=$t(r,e.secretKey).toString(Ys);return`${t} Credential=${e.secretId}, SignedHeaders=${s}, Signature=${l}`}({path:h,query:p,method:n,headers:u,timestamp:l,body:JSON.stringify(s),secretId:r.accessKey,secretKey:r.secretKey,signedHeaders:d.sort()});return{url:`${r.endpoint}${e}`,headers:Object.assign({},u,{Authorization:f})}}function ea({url:e,data:t,method:s="POST",headers:a={},timeout:n}){return new Promise((i,o)=>{vt.request({url:e,method:s,data:"object"==typeof t?JSON.stringify(t):t,header:a,dataType:"json",timeout:n,complete:(e={})=>{const t=a["x-trace-id"]||"";if(!e.statusCode||e.statusCode>=400){const{message:s,errMsg:a,trace_id:n}=e.data||{};return o(new yt({code:"SYS_ERR",message:s||a||"request:fail",requestId:n||t}))}i({status:e.statusCode,data:e.data,headers:e.header,requestId:t})}})})}function ta(e,t){const{path:s,data:a,method:n="GET"}=e,{url:i,headers:o}=Zs(s,{functionName:"",data:a,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 ea({url:i,data:a,method:n,headers:o}).then(e=>{const t=e.data||{};if(!t.success)throw new yt({code:e.errCode,message:e.errMsg,requestId:e.requestId});return t.data||{}}).catch(e=>{throw new yt({code:e.errCode,message:e.errMsg,requestId:e.requestId})})}function sa(e=""){const t=e.trim().replace(/^cloud:\/\//,""),s=t.indexOf("/");if(s<=0)throw new yt({code:"INVALID_PARAM",message:"fileID不合法"});const a=t.substring(0,s),n=t.substring(s+1);return a!==this.config.spaceId&&console.warn("file ".concat(e," does not belong to env ").concat(this.config.spaceId)),n}function aa(e=""){return"cloud://".concat(this.config.spaceId,"/").concat(e.replace(/^\/+/,""))}class na{constructor(e){this.config=e}signedURL(e,t={}){const s=`/ws/function/${e}`,a=this.config.wsEndpoint.replace(/^ws(s)?:\/\//,""),n=Object.assign({},t,{accessKeyId:this.config.accessKey,signatureNonce:Xs(),timestamp:""+Date.now()}),i=[s,["accessKeyId","authorization","signatureNonce","timestamp"].sort().map(function(e){return n[e]?"".concat(e,"=").concat(n[e]):null}).filter(Boolean).join("&"),`host:${a}`].join("\n"),o=["HMAC-SHA256",Mt(i).toString(Ys)].join("\n"),r=$t(o,this.config.secretKey).toString(Ys),l=Object.keys(n).map(e=>`${e}=${encodeURIComponent(n[e])}`).join("&");return`${this.config.wsEndpoint}${s}?${l}&signature=${r}`}}var ia=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 na(this.config)}callFunction(e){return function(e,t){const{name:s,data:a,async:n=!1,timeout:i}=e,o="POST",r={"x-to-function-name":s};n&&(r["x-function-invoke-type"]="async");const{url:l,headers:c}=Zs("/functions/invokeFunction",{functionName:s,data:a,method:o,headers:r,signHeaderKeys:["x-to-function-name"],config:t});return ea({url:l,data:a,method:o,headers:c,timeout:i}).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 yt({code:t,message:e.errMsg,requestId:e.requestId});return{errCode:t,success:0===t,requestId:e.requestId,result:e.data}}).catch(e=>{throw new yt({code:e.errCode,message:e.errMsg,requestId:e.requestId})})}(e,this.config)}uploadFileToOSS({url:e,filePath:t,fileType:s,formData:a,onUploadProgress:n}){return new Promise((i,o)=>{const r=vt.uploadFile({url:e,filePath:t,fileType:s,formData:a,name:"file",success(e){e&&e.statusCode<400?i(e):o(new yt({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){o(new yt({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof n&&r&&"function"==typeof r.onProgressUpdate&&r.onProgressUpdate(e=>{n({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})})})}async uploadFile({filePath:e,cloudPath:t="",fileType:s="image",onUploadProgress:a}){if("string"!==Ee(t))throw new yt({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new yt({code:"INVALID_PARAM",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new yt({code:"INVALID_PARAM",message:"cloudPath不合法"});const n=await ta({path:"/".concat(t.replace(/^\//,""),"?post_url")},this.config),{file_id:i,upload_url:o,form_data:r}=n,l=r&&r.reduce((e,t)=>(e[t.key]=t.value,e),{});return this.uploadFileToOSS({url:o,filePath:e,fileType:s,formData:l,onUploadProgress:a}).then(()=>({fileID:i}))}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 a=[];for(const i of e){let e;"string"!==Ee(i)&&t({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"});try{e=sa.call(this,i)}catch(n){console.warn(n.errCode,n.errMsg),e=i}a.push({file_id:e,expire:600})}ta({path:"/?download_url",data:{file_list:a},method:"POST"},this.config).then(e=>{const{file_list:s=[]}=e;t({fileList:s.map(e=>({fileID:aa.call(this,e.file_id),tempFileURL:e.download_url}))})}).catch(e=>s(e))})}async connectWebSocket(e){const{name:t,query:s}=e;return vt.connectSocket({url:this._websocket.signedURL(t,s),complete:()=>{}})}},oa={init:e=>{e.provider="alipay";const t=new ia(e);return t.auth=function(){return{signInAnonymously:function(){return Promise.resolve()},getLoginState:function(){return Promise.resolve(!0)}}},t}};function ra({data:e}){let t;t=Pt();const s=JSON.parse(JSON.stringify(e||{}));if(Object.assign(s,{clientInfo:t}),!s.uniIdToken){const{token:e}=bt();e&&(s.uniIdToken=e)}return s}const la=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var ca=/[\\^$.*+?()[\]{}|]/g,ua=RegExp(ca.source);function da(e,t,s){return e.replace(new RegExp((a=t)&&ua.test(a)?a.replace(ca,"\\$&"):a,"g"),s);var a}const ha="request",pa="response",fa="both",ga="_globalUniCloudStatus",ma={code:2e4,message:"System error"},ya={code:20101,message:"Invalid client"};function va(e){const{errSubject:t,subject:s,errCode:a,errMsg:n,code:i,message:o,cause:r}=e||{};return new yt({subject:t||s||"uni-secure-network",code:a||i||ma.code,message:n||o,cause:r})}let _a;function ba({secretType:e}={}){return e===ha||e===pa||e===fa}function wa({functionName:e,result:t,logPvd:s}){}function Ta(e){const t=e.callFunction,s=function(s){const a=s.name;s.data=ra.call(e,{data:s.data});const n={aliyun:"aliyun",tencent:"tcb",tcb:"tcb",alipay:"alipay",dcloud:"dcloud"}[this.config.provider],i=ba(s)||false;return t.call(this,s).then(e=>(e.errCode=0,!i&&wa.call(this,{functionName:a,result:e,logPvd:n}),Promise.resolve(e)),e=>(!i&&wa.call(this,{functionName:a,result:e,logPvd:n}),e&&e.message&&(e.message=function({message:e="",extraInfo:t={},formatter:s=[]}={}){for(let a=0;a<s.length;a++){const{rule:n,content:i,mode:o}=s[a],r=e.match(n);if(!r)continue;let l=i;for(let e=1;e<r.length;e++)l=da(l,`{$${e}}`,r[e]);for(const e in t)l=da(l,`{${e}}`,t[e]);return"replace"===o?l:e+l}return e}({message:`[${s.name}]: ${e.message}`,formatter:la,extraInfo:{functionName:a}})),Promise.reject(e)))};e.callFunction=function(t){const{provider:a,spaceId:n}=e.config,i=t.name;let o,r;return t.data=t.data||{},o=s,o=o.bind(e),r=ba(t)?new _a({secretType:t.secretType,uniCloudIns:e}).wrapEncryptDataCallFunction(s.bind(e))(t):function({provider:e,spaceId:t,functionName:s}={}){const{appId:a,uniPlatform:n,osName:i}=xt();let o=n;"app"===n&&(o=i);const r=function({provider:e,spaceId:t}={}){const s=je;if(!s)return{};e=function(e){return"tencent"===e?"tcb":e}(e);const a=s.find(s=>s.provider===e&&s.spaceId===t);return a&&a.config}({provider:e,spaceId:t});if(!r||!r.accessControl||!r.accessControl.enable)return!1;const l=r.accessControl.function||{},c=Object.keys(l);if(0===c.length)return!0;const u=function(e,t){let s,a,n;for(let i=0;i<e.length;i++){const o=e[i];o!==t?"*"!==o?o.split(",").map(e=>e.trim()).indexOf(t)>-1&&(a=o):n=o:s=o}return s||a||n}(c,s);if(!u)return!1;if((l[u]||[]).find((e={})=>e.appId===a&&(e.platform||"").toLowerCase()===o.toLowerCase()))return!0;throw console.error(`此应用[appId: ${a}, platform: ${o}]不在云端配置的允许访问的应用列表内,参考:https://uniapp.dcloud.net.cn/uniCloud/secure-network.html#verify-client`),va(ya)}({provider:a,spaceId:n,functionName:i})?new _a({secretType:t.secretType,uniCloudIns:e}).wrapVerifyClientCallFunction(s.bind(e))(t):o(t),Object.defineProperty(r,"result",{get:()=>(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),r.then(e=>e)}}_a=class{constructor(){throw va({message:`Platform ${Ve} is not supported by secure network`})}};const ka=Symbol("CLIENT_DB_INTERNAL");function xa(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=ka,e.inspect=null,e.__v_raw=void 0,new Proxy(e,{get(e,s,a){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,a)}})}function Ia(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 a=e[t].indexOf(s);-1!==a&&e[t].splice(a,1)}}}const Sa=["db.Geo","db.command","command.aggregate"];function Pa(e,t){return Sa.indexOf(`${e}.${t}`)>-1}function Aa(e){switch(Ee(e=_t(e))){case"array":return e.map(e=>Aa(e));case"object":return e._internalType===ka||Object.keys(e).forEach(t=>{e[t]=Aa(e[t])}),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:return e}}function Ca(e){return e&&e.content&&e.content.$method}class Oa{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:Aa(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=Ca(e),s=Ca(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"===Ca(e))return!0;e=e.prevStage}return!1}get isAggregateCommand(){let e=this;for(;e;){const t=Ca(e),s=Ca(e.prevStage);if("aggregate"===t&&"command"===s)return!0;e=e.prevStage}return!1}getNextStageFn(e){const t=this;return function(){return Fa({$method:e,$param:Aa(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(),a=this.getCommand();return a.$db.push({$method:e,$param:Aa(t)}),this._database._callCloudFunction({action:s,command:a})}}function Fa(e,t,s){return xa(new Oa(e,t,s),{get(e,t){let a="db";return e&&e.content&&(a=e.content.$method),Pa(a,t)?Fa({$method:t},e,s):function(){return Fa({$method:t,$param:Aa(Array.from(arguments))},e,s)}}})}function La({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 Ea{constructor({uniClient:e={},isJQL:t=!1}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e._isDefault&&(this._dbCallBacks=Je("_globalUniCloudDatabaseCallback")),t||(this.auth=Ia(this._authCallBacks)),this._isJQL=t,Object.assign(this,Ia(this._dbCallBacks)),this.env=xa({},{get:(e,t)=>({$env:t})}),this.Geo=xa({},{get:(e,t)=>La({path:["Geo"],method:t})}),this.serverDate=La({path:[],method:"serverDate"}),this.RegExp=La({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 Ua(e,t={}){return xa(new e(t),{get:(e,t)=>Pa("db",t)?Fa({$method:t},null,e):function(){return Fa({$method:t,$param:Aa(Array.from(arguments))},null,e)}})}class Da extends Ea{_parseResult(e){return this._isJQL?e.result:e}_callCloudFunction({action:e,command:t,multiCommand:s,queryList:a}){function n(e,t){if(s&&a)for(let s=0;s<a.length;s++){const n=a[s];n.udb&&"function"==typeof n.udb.setResult&&(t?n.udb.setResult(t):n.udb.setResult(e.result.dataList[s]))}}const i=this,o=this._isJQL?"databaseForJQL":"database";function r(e){return i._callback("error",[e]),Ze(et(o,"fail"),e).then(()=>Ze(et(o,"complete"),e)).then(()=>(n(null,e),ht(at,{type:ot,content:e}),Promise.reject(e)))}const l=Ze(et(o,"invoke")),c=this._uniClient;return l.then(()=>c.callFunction({name:"DCloud-clientDB",type:Oe,data:{action:e,command:t,multiCommand:s}})).then(e=>{const{code:t,message:s,token:a,tokenExpired:l,systemInfo:c=[]}=e.result;if(c)for(let n=0;n<c.length;n++){const{level:e,message:t,detail:s}=c[n];let a="[System Info]"+t;s&&(a=`${a}\n详细信息:${s}`),(console[e]||console.log)(a)}if(t)return r(new yt({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,a&&l&&(wt({token:a,tokenExpired:l}),this._callbackAuth("refreshToken",[{token:a,tokenExpired:l}]),this._callback("refreshToken",[{token:a,tokenExpired:l}]),ht(it,{token:a,tokenExpired:l}));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 a=e.result[t];Object.defineProperty(e.result,t,{get:()=>(console.warn(s),a)})}}return d=e,Ze(et(o,"success"),d).then(()=>Ze(et(o,"complete"),d)).then(()=>{n(d,null);const e=i._parseResult(d);return ht(at,{type:ot,content:e}),Promise.resolve(e)});var d},e=>(/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化,请在web控制台保存一次schema以开启clientDB"),r(new yt({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId}))))}}const Na="token无效,跳转登录页面",Ra="token过期,跳转登录页面",Ma={TOKEN_INVALID_TOKEN_EXPIRED:Ra,TOKEN_INVALID_INVALID_CLIENTID:Na,TOKEN_INVALID:Na,TOKEN_INVALID_WRONG_TOKEN:Na,TOKEN_INVALID_ANONYMOUS_USER:Na},$a={"uni-id-token-expired":Ra,"uni-id-check-token-failed":Na,"uni-id-token-not-exist":Na,"uni-id-check-device-feature-failed":Na},Ba={...Ma,...$a,default:"用户未登录或登录状态过期,自动跳转登录页面"};function qa(e,t){let s="";return s=e?`${e}/${t}`:t,s.replace(/^\//,"")}function ja(e=[],t=""){const s=[],a=[];return e.forEach(e=>{!0===e.needLogin?s.push(qa(t,e.path)):!1===e.needLogin&&a.push(qa(t,e.path))}),{needLoginPage:s,notNeedLoginPage:a}}function Va(e){return e.split("?")[0].replace(/^\//,"")}function Ka(){return function(e){let t=e&&e.$page&&e.$page.fullPath;return t?("/"!==t.charAt(0)&&(t="/"+t),t):""}(function(){const e=s();return e[e.length-1]}())}function za(){return Va(Ka())}function Ha(e="",t={}){if(!e)return!1;if(!(t&&t.list&&t.list.length))return!1;const s=t.list,a=Va(e);return s.some(e=>e.pagePath===a)}const Wa=!!_e.uniIdRouter,{loginPage:Ja,routerNeedLogin:Ga,resToLogin:Qa,needLoginPage:Ya,notNeedLoginPage:Xa,loginPageInTabBar:Za}=function({pages:e=[],subPackages:t=[],uniIdRouter:s={},tabBar:a={}}=_e){const{loginPage:n,needLogin:i=[],resToLogin:o=!0}=s,{needLoginPage:r,notNeedLoginPage:l}=ja(e),{needLoginPage:c,notNeedLoginPage:u}=function(e=[]){const t=[],s=[];return e.forEach(e=>{const{root:a,pages:n=[]}=e,{needLoginPage:i,notNeedLoginPage:o}=ja(n,a);t.push(...i),s.push(...o)}),{needLoginPage:t,notNeedLoginPage:s}}(t);return{loginPage:n,routerNeedLogin:i,resToLogin:o,needLoginPage:[...r,...c],notNeedLoginPage:[...l,...u],loginPageInTabBar:Ha(n,a)}}();if(Ya.indexOf(Ja)>-1)throw new Error(`Login page [${Ja}] should not be "needLogin", please check your pages.json`);function en(e){const t=za();if("/"===e.charAt(0))return e;const[s,a]=e.split("?"),n=s.replace(/^\//,"").split("/"),i=t.split("/");i.pop();for(let o=0;o<n.length;o++){const e=n[o];".."===e?i.pop():"."!==e&&i.push(e)}return""===i[0]&&i.shift(),"/"+i.join("/")+(a?"?"+a:"")}function tn({redirect:e}){const t=Va(e),s=Va(Ja);return za()!==s&&t!==s}function sn({api:e,redirect:t}={}){if(!t||!tn({redirect:t}))return;const s=(n=t,"/"!==(a=Ja).charAt(0)&&(a="/"+a),n?a.indexOf("?")>-1?a+`&uniIdRedirectUrl=${encodeURIComponent(n)}`:a+`?uniIdRedirectUrl=${encodeURIComponent(n)}`:a);var a,n;Za?"navigateTo"!==e&&"redirectTo"!==e||(e="switchTab"):"switchTab"===e&&(e="navigateTo");const i={navigateTo:_,redirectTo:b,switchTab:w,reLaunch:T};setTimeout(()=>{i[e]({url:s})},0)}function an({url:e}={}){const t={abortLoginPageJump:!1,autoToLoginPage:!1},s=function(){const{token:e,tokenExpired:t}=bt();let s;if(e){if(t<Date.now()){const e="uni-id-token-expired";s={errCode:e,errMsg:Ba[e]}}}else{const e="uni-id-check-token-failed";s={errCode:e,errMsg:Ba[e]}}return s}();if(function(e){const t=Va(en(e));return!(Xa.indexOf(t)>-1)&&(Ya.indexOf(t)>-1||Ga.some(t=>{return s=e,new RegExp(t).test(s);var s}))}(e)&&s){if(s.uniIdRedirectUrl=e,ct(nt).length>0)return setTimeout(()=>{ht(nt,s)},0),t.abortLoginPageJump=!0,t;t.autoToLoginPage=!0}return t}function nn(){!function(){const e=Ka(),{abortLoginPageJump:t,autoToLoginPage:s}=an({url:e});t||s&&sn({api:"redirectTo",redirect:e})}();const e=["navigateTo","redirectTo","reLaunch","switchTab"];for(let t=0;t<e.length;t++){const s=e[t];a(s,{invoke(e){const{abortLoginPageJump:t,autoToLoginPage:a}=an({url:e.url});return t?e:a?(sn({api:s,redirect:en(e.url)}),!1):e}})}}function on(){this.onResponse(e=>{const{type:t,content:s}=e;let a=!1;switch(t){case"cloudobject":a=function(e){if("object"!=typeof e)return!1;const{errCode:t}=e||{};return t in Ba}(s);break;case"clientdb":a=function(e){if("object"!=typeof e)return!1;const{errCode:t}=e||{};return t in Ma}(s)}a&&function(e={}){const t=ct(nt);gt().then(()=>{const s=Ka();if(s&&tn({redirect:s}))return t.length>0?ht(nt,Object.assign({uniIdRedirectUrl:s},e)):void(Ja&&sn({api:"navigateTo",redirect:s}))})}(s)})}function rn(e){var t;(t=e).onResponse=function(e){ut(at,e)},t.offResponse=function(e){dt(at,e)},function(e){e.onNeedLogin=function(e){ut(nt,e)},e.offNeedLogin=function(e){dt(nt,e)},Wa&&(Je(ga).needLoginInit||(Je(ga).needLoginInit=!0,gt().then(()=>{nn.call(e)}),Qa&&on.call(e)))}(e),function(e){e.onRefreshToken=function(e){ut(it,e)},e.offRefreshToken=function(e){dt(it,e)}}(e)}let ln;const cn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",un=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function dn(){const e=bt().token||"",t=e.split(".");if(!e||3!==t.length)return{uid:null,role:[],permission:[],tokenExpired:0};let s;try{s=JSON.parse((a=t[1],decodeURIComponent(ln(a).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join(""))))}catch(n){throw new Error("获取当前用户信息出错,详细错误信息为:"+n.message)}var a;return s.tokenExpired=1e3*s.exp,delete s.exp,delete s.iat,s}ln="function"!=typeof atob?function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!un.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,a,n="",i=0;i<e.length;)t=cn.indexOf(e.charAt(i++))<<18|cn.indexOf(e.charAt(i++))<<12|(s=cn.indexOf(e.charAt(i++)))<<6|(a=cn.indexOf(e.charAt(i++))),n+=64===s?String.fromCharCode(t>>16&255):64===a?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return n}:atob;var hn=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(be(function(s,a){Object.defineProperty(a,"__esModule",{value:!0});const i="chooseAndUploadFile:ok",o="chooseAndUploadFile:fail";function r(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 l(e,t,{onChooseFile:s,onUploadProgress:a}){return t.then(e=>{if(s){const t=s(e);if(void 0!==t)return Promise.resolve(t).then(t=>void 0===t?e:t)}return e}).then(t=>!1===t?{errMsg:i,tempFilePaths:[],tempFiles:[]}:function(e,t,s=5,a){(t=Object.assign({},t)).errMsg=i;const n=t.tempFiles,o=n.length;let r=0;return new Promise(i=>{for(;r<s;)l();function l(){const s=r++;if(s>=o)return void(!n.find(e=>!e.url&&!e.errMsg)&&i(t));const c=n[s];e.uploadFile({provider:c.provider,filePath:c.path,cloudPath:c.cloudPath,fileType:c.fileType,cloudPathAsRealPath:c.cloudPathAsRealPath,onUploadProgress(e){e.index=s,e.tempFile=c,e.tempFilePath=c.path,a&&a(e)}}).then(e=>{c.url=e.fileID,s<o&&l()}).catch(e=>{c.errMsg=e.errMsg||e.message,s<o&&l()})}})}(e,t,5,a))}a.initChooseAndUploadFile=function(s){return function(a={type:"all"}){return"image"===a.type?l(s,function(t){const{count:s,sizeType:a,sourceType:n=["album","camera"],extension:i}=t;return new Promise((t,l)=>{e({count:s,sizeType:a,sourceType:n,extension:i,success(e){t(r(e,"image"))},fail(e){l({errMsg:e.errMsg.replace("chooseImage:fail",o)})}})})}(a),a):"video"===a.type?l(s,function(e){const{camera:s,compressed:a,maxDuration:n,sourceType:i=["album","camera"],extension:l}=e;return new Promise((e,c)=>{t({camera:s,compressed:a,maxDuration:n,sourceType:i,extension:l,success(t){const{tempFilePath:s,duration:a,size:n,height:i,width:o}=t;e(r({errMsg:"chooseVideo:ok",tempFilePaths:[s],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:s,size:n,type:t.tempFile&&t.tempFile.type||"",width:o,height:i,duration:a,fileType:"video",cloudPath:""}]},"video"))},fail(e){c({errMsg:e.errMsg.replace("chooseVideo:fail",o)})}})})}(a),a):l(s,function(e){const{count:t,extension:s}=e;return new Promise((e,a)=>{let i=n;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(i=wx.chooseMessageFile),"function"!=typeof i)return a({errMsg:o+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});i({type:"all",count:t,extension:s,success(t){e(r(t))},fail(e){a({errMsg:e.errMsg.replace("chooseFile:fail",o)})}})})}(a),a)}}}));const pn="manual";function fn(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===pn)return;let s=!1;const a=[];for(let n=2;n<e.length;n++)e[n]!==t[n]&&(a.push(e[n]),s=!0);e[0]!==t[0]&&(this.mixinDatacomPage.current=this.pageCurrent),this.mixinDatacomPage.size=this.pageSize,this.onMixinDatacomPropsChange(s,a)})},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:a,count:n}=s.result;this.getcount&&(this.mixinDatacomPage.count=n),this.mixinDatacomHasMore=a.length<this.pageSize;const i=e?a.length?a[0]:void 0:a;this.mixinDatacomResData=i,t&&t(i)}).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 a=t.action||this.action;a&&(s=s.action(a));const n=t.collection||this.collection;s=Array.isArray(n)?s.collection(...n):s.collection(n);const i=t.where||this.where;i&&Object.keys(i).length&&(s=s.where(i));const o=t.field||this.field;o&&(s=s.field(o));const r=t.foreignKey||this.foreignKey;r&&(s=s.foreignKey(r));const l=t.groupby||this.groupby;l&&(s=s.groupBy(l));const c=t.groupField||this.groupField;c&&(s=s.groupField(c)),!0===(void 0!==t.distinct?t.distinct:this.distinct)&&(s=s.distinct());const u=t.orderby||this.orderby;u&&(s=s.orderBy(u));const d=void 0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,h=void 0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,p=void 0!==t.getcount?t.getcount:this.getcount,f=void 0!==t.gettree?t.gettree:this.gettree,g=void 0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:p},y={limitLevel:void 0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void 0!==t.startwith?t.startwith:this.startwith};return f&&(m.getTree=y),g&&(m.getTreePath=y),s=s.skip(h*(d-1)).limit(h).get(m),s}}}}function gn(e){return Je("_globalUniCloudSecureNetworkCache__{spaceId}".replace("{spaceId}",e.config.spaceId))}async function mn({openid:e,callLoginByWeixin:t=!1}={}){throw gn(this),new Error(`[SecureNetwork] API \`initSecureNetworkByWeixin\` is not supported on platform \`${Ve}\``)}async function yn(e){const t=gn(this);return t.initPromise||(t.initPromise=mn.call(this,e).then(e=>e).catch(e=>{throw delete t.initPromise,e})),t.initPromise}function vn(e){St=e}function _n(e){const t={getAppBaseInfo:k,getPushClientId:x};return function(s){return new Promise((a,n)=>{t[e]({...s,success(e){a(e)},fail(e){n(e)}})})}}class bn extends Be{constructor(){super(),this._uniPushMessageCallback=this._receivePushMessage.bind(this),this._currentMessageId=-1,this._payloadQueue=[]}init(){return Promise.all([_n("getAppBaseInfo")(),_n("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:a,message:n}=t;this._payloadQueue.push({action:s,messageId:a,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:a}=e;"end"===t?this._end({messageId:s,message:a}):"message"===t&&this._appendMessage({messageId:s,message:a})}_appendMessage({messageId:e,message:t}={}){this.emit("message",t)}_end({messageId:e,message:t}={}){this.emit("end",t),this.close()}_initMessageListener(){c(this._uniPushMessageCallback)}_destroy(){u(this._uniPushMessageCallback)}toJSON(){return{appId:this._appId,pushClientId:this._pushClientId,seqId:this._seqId}}close(){this._destroy(),this.emit("close")}}const wn={tcb:Hs,tencent:Hs,aliyun:Lt,private:Qs,dcloud:Qs,alipay:oa};let Tn=new class{init(e){let t={};const s=wn[e.provider];if(!s)throw new Error("未提供正确的provider参数");var a;return t=s.init(e),function(e){e._initPromiseHub||(e._initPromiseHub=new $e({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),Ta(t),function(e){const t=e.uploadFile;e.uploadFile=function(e){return t.call(this,e)}}(t),(a=t).database=function(e){if(e&&Object.keys(e).length>0)return a.init(e).database();if(this._database)return this._database;const t=Ua(Da,{uniClient:a});return this._database=t,t},a.databaseForJQL=function(e){if(e&&Object.keys(e).length>0)return a.init(e).databaseForJQL();if(this._databaseForJQL)return this._databaseForJQL;const t=Ua(Da,{uniClient:a,isJQL:!0});return this._databaseForJQL=t,t},function(e){e.getCurrentUserInfo=dn,e.chooseAndUploadFile=hn.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return fn(e)}}),e.SSEChannel=bn,e.initSecureNetworkByWeixin=function(e){return function({openid:t,callLoginByWeixin:s=!1}={}){return yn.call(e,{openid:t,callLoginByWeixin:s})}}(e),e.setCustomClientInfo=vn,e.importObject=function(t){return function(s,a={}){a=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}},a);const{customUI:n,loadingOptions:c,errorOptions:u,parseSystemError:d}=a,h=!n;return new Proxy({},{get(n,p){switch(p){case"toString":return"[object UniCloudObject]";case"toJSON":return{}}return function({fn:e,interceptorName:t,getCallbackArgs:s}={}){return async function(...a){const n=s?s({params:a}):{};let i,o;try{return await Ze(et(t,"invoke"),{...n}),i=await e(...a),await Ze(et(t,"success"),{...n,result:i}),i}catch(r){throw o=r,await Ze(et(t,"fail"),{...n,error:o}),o}finally{await Ze(et(t,"complete"),o?{...n,error:o}:{...n,result:i})}}}({fn:async function n(...f){let g;h&&i({title:c.title,mask:c.mask});const m={name:s,type:Ce,data:{method:p,params:f}};"object"==typeof a.secretMethods&&function(e,t){const s=t.data.method,a=e.secretMethods||{},n=a[s]||a["*"];n&&(t.secretType=n)}(a,m);let y=!1;try{g=await t.callFunction(m)}catch(e){y=!0,g={result:new yt(e)}}const{errSubject:v,errCode:_,errMsg:b,newToken:w}=g.result||{};if(h&&o(),w&&w.token&&w.tokenExpired&&(wt(w),ht(it,{...w})),_){let e=b;if(y&&d&&(e=(await d({objectName:s,methodName:p,params:f,errSubject:v,errCode:_,errMsg:b})).errMsg||b),h)if("toast"===u.type)r({title:e,icon:"none"});else{if("modal"!==u.type)throw new Error(`Invalid errorOptions.type: ${u.type}`);{const{confirm:t}=await async function({title:e,content:t,showCancel:s,cancelText:a,confirmText:n}={}){return new Promise((i,o)=>{l({title:e,content:t,showCancel:s,cancelText:a,confirmText:n,success(e){i(e)},fail(){i({confirm:!1,cancel:!0})}})})}({title:"提示",content:e,showCancel:u.retry,cancelText:"取消",confirmText:u.retry?"重试":"确定"});if(u.retry&&t)return n(...f)}}const t=new yt({subject:v,code:_,message:b,requestId:g.requestId});throw t.detail=g.result,ht(at,{type:lt,content:t}),t}return ht(at,{type:lt,content:g.result}),g.result},interceptorName:"callObject",getCallbackArgs:function({params:e}={}){return{objectName:s,methodName:p,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 a=!1;if("callFunction"===t){const e=s&&s.type||Ae;a=e!==Ae}const n="callFunction"===t&&!a,i=this._initPromiseHub.exec();s=s||{};const{success:o,fail:r,complete:l}=mt(s),c=i.then(()=>a?Promise.resolve():Ze(et(t,"invoke"),s)).then(()=>e.call(this,s)).then(e=>a?Promise.resolve(e):Ze(et(t,"success"),e).then(()=>Ze(et(t,"complete"),e)).then(()=>(n&&ht(at,{type:rt,content:e}),Promise.resolve(e))),e=>a?Promise.reject(e):Ze(et(t,"fail"),e).then(()=>Ze(et(t,"complete"),e)).then(()=>(ht(at,{type:rt,content:e}),Promise.reject(e))));if(!(o||r||l))return c;c.then(e=>{o&&o(e),l&&l(e),n&&ht(at,{type:rt,content:e})},e=>{r&&r(e),l&&l(e),n&&ht(at,{type:rt,content:e})})}}(t[e],e).bind(t)}),t.init=this.init,t}};(()=>{const e=Ke;let t={};if(e&&1===e.length)t=e[0],Tn=Tn.init(t),Tn._isDefault=!0;else{const t=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile"],s=["database","getCurrentUserInfo","importObject"];let a;a=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":"应用未关联服务空间,请在uniCloud目录右键关联服务空间",[...t,...s].forEach(e=>{Tn[e]=function(){if(console.error(a),-1===s.indexOf(e))return Promise.reject(new yt({code:"SYS_ERR",message:a}));console.error(a)}})}Object.assign(Tn,{get mixinDatacom(){return fn(Tn)}}),rn(Tn),Tn.addInterceptor=Ye,Tn.removeInterceptor=Xe,Tn.interceptObject=tt;{const e=He||(He=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")()}(),He);e.uniCloud=Tn,e.UniCloudError=yt}})();var kn=Tn;const xn="chooseAndUploadFile:fail";function In(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 Sn(e,t=5,s){const a=(e=JSON.parse(JSON.stringify(e))).length;let n=0,i=this;return new Promise(o=>{for(;n<t;)r();function r(){let t=n++;if(t>=a)return void(!e.find(e=>!e.url&&!e.errMsg)&&o(e));const l=e[t],c=i.files.findIndex(e=>e.uuid===l.uuid);l.url="",delete l.errMsg,kn.uploadFile({filePath:l.path,cloudPath:l.cloudPath,fileType:l.fileType,onUploadProgress:e=>{e.index=c,s&&s(e)}}).then(e=>{l.url=e.fileID,l.index=c,t<a&&r()}).catch(e=>{l.errMsg=e.errMsg||e.message,l.index=c,t<a&&r()})}})}function Pn(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 An(s={type:"all"}){return"image"===s.type?Pn(function(t){const{count:s,sizeType:a=["original","compressed"],sourceType:n,extension:i}=t;return new Promise((t,o)=>{e({count:s,sizeType:a,sourceType:n,extension:i,success(e){t(In(e,"image"))},fail(e){o({errMsg:e.errMsg.replace("chooseImage:fail",xn)})}})})}(s),s):"video"===s.type?Pn(function(e){const{count:s,camera:a,compressed:n,maxDuration:i,sourceType:o,extension:r}=e;return new Promise((e,s)=>{t({camera:a,compressed:n,maxDuration:i,sourceType:o,extension:r,success(t){const{tempFilePath:s,duration:a,size:n,height:i,width:o}=t;e(In({errMsg:"chooseVideo:ok",tempFilePaths:[s],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:s,size:n,type:t.tempFile&&t.tempFile.type||"",width:o,height:i,duration:a,fileType:"video",cloudPath:""}]},"video"))},fail(e){s({errMsg:e.errMsg.replace("chooseVideo:fail",xn)})}})})}(s),s):Pn(function(e){const{count:t,extension:s}=e;return new Promise((e,a)=>{let i=n;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(i=wx.chooseMessageFile),"function"!=typeof i)return a({errMsg:xn+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});i({type:"all",count:t,extension:s,success(t){e(In(t))},fail(e){a({errMsg:e.errMsg.replace("chooseFile:fail",xn)})}})})}(s),s)}const Cn=e=>{const t=e.lastIndexOf("."),s=e.length;return{name:e.substring(0,t),ext:e.substring(t+1,s)}},On=e=>{if(Array.isArray(e))return e;return e.replace(/(\[|\])/g,"").split(",")},Fn=async(e,t="image")=>{const s=Cn(e.name).ext.toLowerCase();let a={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)=>{P({src:n,success(t){e(t)},fail(e){t(e)}})}));delete a.video,a.image.width=t.width,a.image.height=t.height,a.image.location=t.path}else delete a.image;var n;return a};const Ln=A({name:"uniFilePicker",components:{uploadImage:A({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 a="";for(let n in s)a+=`${n}:${s[n]};`;return a},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 a=e&&e.radius||3;a=this.value2px(a),t={"border-width":s,"border-style":e&&e.style||"solid","border-color":e&&e.color||"#eee","border-radius":a}}let s="";for(let a in t)s+=`${a}:${t[a]};`;return s}},methods:{uploadFiles(e,t){this.$emit("uploadFiles",e)},choose(){this.$emit("choose")},delFile(e){this.$emit("delFile",e)},prviewImage(e,t){let s=[];1===Number(this.limit)&&this.disablePreview&&!this.disabled&&this.$emit("choose"),this.disablePreview||(this.filesList.forEach(e=>{s.push(e.url)}),C({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,a,n,i){const o=j,r=V,l=K;return O(),F(r,{class:"uni-file-picker__container"},{default:L(()=>[(O(!0),E(U,null,D(s.filesList,(e,t)=>(O(),F(r,{class:"file-picker__box",key:t,style:N(i.boxStyle)},{default:L(()=>[R(r,{class:"file-picker__box-content",style:N(i.borderStyle)},{default:L(()=>[R(o,{class:"file-image",src:e.url,mode:"aspectFill",onClick:M(s=>i.prviewImage(e,t),["stop"])},null,8,["src","onClick"]),s.delIcon&&!s.readonly?(O(),F(r,{key:0,class:"icon-del-box",onClick:M(e=>i.delFile(t),["stop"])},{default:L(()=>[R(r,{class:"icon-del"}),R(r,{class:"icon-del rotate"})]),_:2},1032,["onClick"])):$("",!0),e.progress&&100!==e.progress||0===e.progress?(O(),F(r,{key:1,class:"file-picker__progress"},{default:L(()=>[R(l,{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)):$("",!0),e.errMsg?(O(),F(r,{key:2,class:"file-picker__mask",onClick:M(s=>i.uploadFiles(e,t),["stop"])},{default:L(()=>[B(" 点击重试 ")]),_:2},1032,["onClick"])):$("",!0)]),_:2},1032,["style"])]),_:2},1032,["style"]))),128)),s.filesList.length<s.limit&&!s.readonly?(O(),F(r,{key:0,class:"file-picker__box",style:N(i.boxStyle)},{default:L(()=>[R(r,{class:"file-picker__box-content is-add",style:N(i.borderStyle),onClick:i.choose},{default:L(()=>[q(e.$slots,"default",{},()=>[R(r,{class:"icon-add"}),R(r,{class:"icon-add rotate"})],!0)]),_:3},8,["style","onClick"])]),_:3},8,["style"])):$("",!0)]),_:3})}],["__scopeId","data-v-80aafbd1"]]),uploadFile:A({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 a=e&&e.radius||5;a=this.value2px(a),s={"border-width":t,"border-style":e&&e.style||"solid","border-color":e&&e.color||"#eee","border-radius":a}}else s.border="none";let a="";for(let n in s)a+=`${n}:${s[n]};`;return a},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,a=t&&t.style||0;"number"==typeof s?s+="px":s=s.indexOf("px")?s:s+"px",e["border-width"]=s,"number"==typeof a?a+="px":a=a.indexOf("px")?a:a+"px",e["border-top-style"]=a}let s="";for(let a in e)s+=`${a}:${e[a]};`;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,a,n,i){const o=V,r=K;return O(),F(o,{class:"uni-file-picker__files"},{default:L(()=>[s.readonly?$("",!0):(O(),F(o,{key:0,class:"files-button",onClick:i.choose},{default:L(()=>[q(e.$slots,"default",{},void 0,!0)]),_:3},8,["onClick"])),i.list.length>0?(O(),F(o,{key:1,class:"uni-file-picker__lists is-text-box",style:N(i.borderStyle)},{default:L(()=>[(O(!0),E(U,null,D(i.list,(e,t)=>(O(),F(o,{class:z(["uni-file-picker__lists-box",{"files-border":0!==t&&i.styles.dividline}]),key:t,style:N(0!==t&&i.styles.dividline&&i.borderLineStyle)},{default:L(()=>[R(o,{class:"uni-file-picker__item"},{default:L(()=>[R(o,{class:"files__name"},{default:L(()=>[B(H(e.name),1)]),_:2},1024),s.delIcon&&!s.readonly?(O(),F(o,{key:0,class:"icon-del-box icon-files",onClick:e=>i.delFile(t)},{default:L(()=>[R(o,{class:"icon-del icon-files"}),R(o,{class:"icon-del rotate"})]),_:2},1032,["onClick"])):$("",!0)]),_:2},1024),e.progress&&100!==e.progress||0===e.progress?(O(),F(o,{key:0,class:"file-picker__progress"},{default:L(()=>[R(r,{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)):$("",!0),"error"===e.status?(O(),F(o,{key:1,class:"file-picker__mask",onClick:M(s=>i.uploadFiles(e,t),["stop"])},{default:L(()=>[B(" 点击重试 ")]),_:2},1032,["onClick"])):$("",!0)]),_:2},1032,["class","style"]))),128))]),_:1},8,["style"])):$("",!0)]),_:3})}],["__scopeId","data-v-42261a33"]])},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:""}},data:()=>({files:[],localValue:[]}),watch:{value:{handler(e,t){this.setValue(e,t)},immediate:!0},modelValue:{handler(e,t){this.setValue(e,t)},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(){kn.config&&kn.config.provider||(this.noSpace=!0,kn.chooseAndUploadFile=An),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 a=e[t];await s(a)}}this.localValue=e,this.form&&this.formItem&&!this.is_reset&&(this.is_reset=!1,this.formItem.setValue(this.localValue));let a=Object.keys(e).length>0?e:[];this.files=[].concat(a)},choose(){this.disabled||(this.files.length>=Number(this.limitLength)&&"grid"!==this.showType&&"array"===this.returnType?r({title:`您最多选择 ${this.limitLength} 个文件`,icon:"none"}):this.chooseFiles())},chooseFiles(){const e=On(this.fileExtname);kn.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=On(this.fileExtname);(1===Number(this.limitLength)&&this.disablePreview&&!this.disabled||"object"===this.returnType)&&(this.files=[]);let{filePaths:s,files:a}=((e,t)=>{let s=[],a=[];return t&&0!==t.length?(e.tempFiles.forEach(e=>{const n=Cn(e.name).ext.toLowerCase();-1!==t.indexOf(n)&&(a.push(e),s.push(e.path))}),a.length!==e.tempFiles.length&&r({title:`当前选择了${e.tempFiles.length}个文件 ,${e.tempFiles.length-a.length} 个文件格式不正确`,icon:"none",duration:5e3}),{filePaths:s,files:a}):{filePaths:s,files:a}})(e,t);t&&t.length>0||(s=e.tempFilePaths,a=e.tempFiles);let n=[];for(let i=0;i<a.length&&!(this.limitLength-this.files.length<=0);i++){a[i].uuid=Date.now();let e=await Fn(a[i],this.fileMediatype);e.progress=0,e.status="ready",this.files.push(e),n.push({...e,file:a[i]})}this.$emit("select",{tempFiles:n,tempFilePaths:s}),e.tempFiles=a,this.autoUpload&&!this.noSpace||(e.tempFiles=[]),e.tempFiles.forEach((e,t)=>{this.provider&&(e.provider=this.provider);const s=e.name.split("."),a=s.pop(),n=s.join(".").replace(/[\s\/\?<>\\:\*\|":]/g,"_");e.cloudPath=n+"_"+Date.now()+"_"+t+"."+a})},uploadFiles(e){return e=[].concat(e),Sn.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=[],a=[],n=[],i=[];for(let o=0;o<e.length;o++){const t=e[o],r=t.uuid?this.files.findIndex(e=>e.uuid===t.uuid):t.index;if(-1===r||!this.files)break;if("request:fail"===t.errMsg)this.files[r].url=t.path,this.files[r].status="error",this.files[r].errMsg=t.errMsg,a.push(this.files[r]),i.push(this.files[r].url);else{this.files[r].errMsg="",this.files[r].fileID=t.url;/cloud:\/\/([\w.]+\/?)\S*/.test(t.url)?this.files[r].url=await this.getTempFileURL(t.url):this.files[r].url=t.url,this.files[r].status="success",this.files[r].progress+=1,s.push(this.files[r]),n.push(this.files[r].fileID)}}s.length>0&&(this.setEmit(),this.$emit("success",{tempFiles:this.backObject(s),tempFilePaths:n})),a.length>0&&this.$emit("fail",{tempFiles:this.backObject(a),tempFilePaths:i})},setProgress(e,t,s){this.files.length;const a=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=a-1,this.$emit("progress",{index:n,progress:parseInt(a),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 kn.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,a,n,i){const o=J,r=V,l=W("upload-image"),c=G,u=W("upload-file");return O(),F(r,{class:"uni-file-picker"},{default:L(()=>[s.title?(O(),F(r,{key:0,class:"uni-file-picker__header"},{default:L(()=>[R(o,{class:"file-title"},{default:L(()=>[B(H(s.title),1)]),_:1}),R(o,{class:"file-count"},{default:L(()=>[B(H(i.filesList.length)+"/"+H(i.limitLength),1)]),_:1})]),_:1})):$("",!0),"image"===s.fileMediatype&&"grid"===i.showType?(O(),F(l,{key:1,readonly:s.readonly,"image-styles":s.imageStyles,"files-list":i.filesList,limit:i.limitLength,disablePreview:s.disablePreview,delIcon:s.delIcon,onUploadFiles:i.uploadFiles,onChoose:i.choose,onDelFile:i.delFile},{default:L(()=>[q(e.$slots,"default",{},()=>[R(r,{class:"is-add"},{default:L(()=>[R(r,{class:"icon-add"}),R(r,{class:"icon-add rotate"})]),_:1})],!0)]),_:3},8,["readonly","image-styles","files-list","limit","disablePreview","delIcon","onUploadFiles","onChoose","onDelFile"])):$("",!0),"image"!==s.fileMediatype||"grid"!==i.showType?(O(),F(u,{key:2,readonly:s.readonly,"list-styles":s.listStyles,"files-list":i.filesList,showType:i.showType,delIcon:s.delIcon,onUploadFiles:i.uploadFiles,onChoose:i.choose,onDelFile:i.delFile},{default:L(()=>[q(e.$slots,"default",{},()=>[R(c,{type:"primary",size:"mini"},{default:L(()=>[B("选择文件")]),_:1})],!0)]),_:3},8,["readonly","list-styles","files-list","showType","delIcon","onUploadFiles","onChoose","onDelFile"])):$("",!0)]),_:3})}],["__scopeId","data-v-c0483ce0"]]),En={__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 a=Q(),n=e,l=s,c=Y(null),u=Y(null),d=Y([]),p=Y([]),g=Y(!0),m=Y("#67AFAB"),y=a.baseUrlHt,v=Y("base"),_=X(()=>n.showGradeSlip?"base"===v.value?d.value:p.value:d.value),b=X(()=>d.value.length+p.value.length);Z(()=>n.files,e=>{d.value=[...e]},{immediate:!0}),Z(()=>n.gradesFiles,e=>{p.value=[...e]},{immediate:!0});const w=e=>e?e.startsWith("http://")||e.startsWith("https://")?e:`${y}${e.startsWith("/")?"":"/"}${e}`:"",T={width:120,height:120,border:!1},k=["image/jpeg","image/png","image/gif","image/webp","image/bmp","image/svg+xml"],x=e=>{g.value=!e.show},I=e=>e&&k.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",S=e=>e&&k.includes(e)?m.value:e&&e.includes("pdf")?"#ff4d4f":e&&e.includes("word")?"#2b579a":e&&e.includes("excel")?"#217346":e&&e.includes("powerpoint")?"#b7472a":"#666",P=e=>e?e<1024?`${e}B`:e<1048576?`${(e/1024).toFixed(1)}KB`:`${(e/1048576).toFixed(1)}MB`:"",A=()=>{c.value&&c.value.open()},M=()=>{c.value&&c.value.close()},q=()=>{var e;null==(e=u.value)||e.choose()},j=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"},K=e=>{const t=n.showGradeSlip&&"grade"===v.value,s=t?p.value:d.value,a=e.tempFiles.filter(e=>{const t=e.name?e.name.split(".").pop().toLowerCase():"",s=k.includes(e.type)||["jpg","jpeg","png","gif","webp","bmp","svg"].includes(t),a=e.type&&e.type.includes("pdf")||"pdf"===t;return s||a}).map(e=>({name:e.name,url:e.path||e.url,type:e.type||j(e.name),size:e.size,file:e,status:"pending",attachmentType:t?"grade":"base"}));s.length+a.length>n.maxCount?r({title:`最多只能上传${n.maxCount}个文件`,icon:"none"}):t?(p.value=[...p.value,...a],l("update:gradesFiles",p.value)):(d.value=[...d.value,...a],l("update:files",d.value))},W=()=>[...d.value,...p.value],ie=(e,t,s)=>{s&&s.stopPropagation(),"grade"===e?(p.value.splice(t,1),l("update:gradesFiles",p.value)):(d.value.splice(t,1),l("update:files",d.value))},oe=e=>{const t=w(e.url);if(e.type&&k.includes(e.type)){const e=W();C({urls:e.filter(e=>e.type&&k.includes(e.type)).map(e=>w(e.url)),current:t})}else e.type&&e.type.includes("pdf")?se({url:t,success:e=>{const t=e.tempFilePath;ae({filePath:t,fileType:"pdf",success:()=>console.log("打开PDF成功"),fail:e=>{console.error("打开PDF失败",e),r({title:"打开PDF失败",icon:"none"})}})},fail:e=>{console.error("下载PDF失败",e),r({title:"下载PDF失败",icon:"none"})}}):l("preview",e)},re=(e,t)=>new Promise((t,s)=>{const a=f("token");h({url:"/api/common/upload",filePath:e.path||e.url,name:"file",header:{Authorization:`Bearer ${a}`},success:e=>{if(200===e.statusCode){const a=JSON.parse(e.data);200===a.code?t({...a,fileName:a.fileName}):s(new Error(a.msg||"上传失败"))}else s(new Error(`上传失败,状态码: ${e.statusCode}`))},fail:e=>{s(e)}})}),le=async()=>{if(n.showGradeSlip&&n.isGradeRequired&&0===p.value.length)return r({title:"请上传成绩单附件",icon:"none"}),void(v.value="grade");if(0!==W().length){i({title:"上传中",mask:!0});try{const t=d.value.filter(e=>!e.url||"pending"===e.status),s=p.value.filter(e=>!e.url||"pending"===e.status);for(const a of t)try{a.status="uploading";const e=await re(a.file);Object.assign(a,{url:e.fileName,fileName:e.fileName,newFileName:e.newFileName,originalFilename:e.originalFilename,status:"success"}),l("upload-base",a)}catch(e){console.error("基础附件上传失败:",e),a.status="error",r({title:`文件 ${a.name} 上传失败`,icon:"none"})}for(const a of s)try{a.status="uploading";const e=await re(a.file);Object.assign(a,{url:e.fileName,fileName:e.fileName,newFileName:e.newFileName,originalFilename:e.originalFilename,status:"success"}),l("upload-grade",a)}catch(e){console.error("成绩单附件上传失败:",e),a.status="error",r({title:`文件 ${a.name} 上传失败`,icon:"none"})}console.log(d.value,"1"),console.log(p.value,"2"),l("update:files",d.value),l("update:gradesFiles",p.value),r({title:"上传完成",icon:"success"}),M()}catch(e){console.error("上传出错:",e),r({title:"上传出错",icon:"none"})}finally{o()}}else r({title:"请先添加附件",icon:"none"})};return t({getFilesByType:e=>"grade"===e?p.value:d.value,getAllFiles:W}),(t,s)=>{const a=J,n=V,i=ee(te("uni-icons"),me),o=ne,r=G,l=ee(te("uni-popup"),ye),h=ee(te("uni-file-picker"),Ln);return O(),F(n,{class:"attachment-upload"},{default:L(()=>[R(n,{class:"attachment-btn",style:N({right:e.position.right,bottom:e.position.bottom,backgroundColor:e.bgColor,display:g.value?"flex":"none"}),onClick:A},{default:L(()=>[R(a,null,{default:L(()=>[B("附件")]),_:1}),b.value>0?(O(),F(a,{key:0,class:"badge"},{default:L(()=>[B(H(b.value),1)]),_:1})):$("",!0)]),_:1},8,["style"]),R(l,{ref_key:"popup",ref:c,type:"bottom","safe-area":!1,onChange:x},{default:L(()=>[R(n,{class:"attachment-popup"},{default:L(()=>[R(n,{class:"popup-header"},{default:L(()=>[R(a,{class:"title"},{default:L(()=>[B("附件管理")]),_:1}),e.readonly?$("",!0):(O(),F(i,{key:0,type:"plus",size:"24",color:m.value,onClick:q},null,8,["color"])),R(i,{type:"close",size:"24",color:"#999",onClick:M})]),_:1}),e.showGradeSlip?(O(),F(n,{key:0,class:"attachment-tabs"},{default:L(()=>[R(n,{class:z(["tab-item",{active:"base"===v.value}]),onClick:s[0]||(s[0]=e=>v.value="base")},{default:L(()=>[R(a,null,{default:L(()=>[B("基础附件")]),_:1})]),_:1},8,["class"]),R(n,{class:z(["tab-item",{active:"grade"===v.value}]),onClick:s[1]||(s[1]=e=>v.value="grade")},{default:L(()=>[R(a,null,{default:L(()=>[B("成绩单附件")]),_:1}),e.isGradeRequired?(O(),F(a,{key:0,class:"required-mark"},{default:L(()=>[B("*")]),_:1})):$("",!0)]),_:1},8,["class"])]),_:1})):$("",!0),R(o,{"scroll-y":"",class:"file-list"},{default:L(()=>["base"!==v.value&&e.showGradeSlip?$("",!0):(O(!0),E(U,{key:0},D(d.value,(t,s)=>(O(),F(n,{class:"file-item",key:"base-"+s},{default:L(()=>[R(n,{class:"file-icon",onClick:e=>oe(t)},{default:L(()=>[R(i,{type:I(t.type),size:"24",color:S(t.type)},null,8,["type","color"])]),_:2},1032,["onClick"]),R(n,{class:"file-info",onClick:e=>oe(t)},{default:L(()=>[R(a,{class:"file-name"},{default:L(()=>[B(H(t.originalFilename||t.name),1)]),_:2},1024),R(a,{class:"file-size"},{default:L(()=>[B(H(P(t.size)),1)]),_:2},1024),"uploading"===t.status?(O(),F(a,{key:0,class:"file-status"},{default:L(()=>[B("上传中...")]),_:1})):"error"===t.status?(O(),F(a,{key:1,class:"file-status error"},{default:L(()=>[B("上传失败")]),_:1})):$("",!0)]),_:2},1032,["onClick"]),e.readonly?$("",!0):(O(),F(i,{key:0,type:"trash",size:"20",color:"#ff4d4f",onClick:e=>ie("base",s,e)},null,8,["onClick"]))]),_:2},1024))),128)),"grade"===v.value&&e.showGradeSlip?(O(!0),E(U,{key:1},D(p.value,(t,s)=>(O(),F(n,{class:"file-item",key:"grade-"+s},{default:L(()=>[R(n,{class:"file-icon",onClick:e=>oe(t)},{default:L(()=>[R(i,{type:I(t.type),size:"24",color:S(t.type)},null,8,["type","color"])]),_:2},1032,["onClick"]),R(n,{class:"file-info",onClick:e=>oe(t)},{default:L(()=>[R(a,{class:"file-name"},{default:L(()=>[B(H(t.originalFilename||t.name),1)]),_:2},1024),R(a,{class:"file-size"},{default:L(()=>[B(H(P(t.size)),1)]),_:2},1024),"uploading"===t.status?(O(),F(a,{key:0,class:"file-status"},{default:L(()=>[B("上传中...")]),_:1})):"error"===t.status?(O(),F(a,{key:1,class:"file-status error"},{default:L(()=>[B("上传失败")]),_:1})):$("",!0)]),_:2},1032,["onClick"]),e.readonly?$("",!0):(O(),F(i,{key:0,type:"trash",size:"20",color:"#ff4d4f",onClick:e=>ie("grade",s,e)},null,8,["onClick"]))]),_:2},1024))),128)):$("",!0),0===_.value.length?(O(),F(n,{key:2,class:"empty"},{default:L(()=>[R(i,{type:"info",size:"24",color:"#999"}),"base"!==v.value&&e.showGradeSlip?"grade"===v.value?(O(),F(a,{key:1},{default:L(()=>[B("暂无成绩单附件")]),_:1})):$("",!0):(O(),F(a,{key:0},{default:L(()=>[B("暂无基础附件")]),_:1}))]),_:1})):$("",!0)]),_:1}),e.readonly?$("",!0):(O(),F(n,{key:1,class:"popup-footer"},{default:L(()=>[R(r,{class:"btn",onClick:q},{default:L(()=>[B("添加"+H("grade"===v.value?"成绩单":"基础")+"附件",1)]),_:1}),R(r,{class:"btn primary",onClick:le},{default:L(()=>[B("确认上传")]),_:1})]),_:1}))]),_:1})]),_:1},512),e.readonly?$("",!0):(O(),F(h,{key:0,ref_key:"filePicker",ref:u,"auto-upload":!1,"file-mediatype":"all",limit:e.maxCount-_.value.length,"image-styles":T,onSelect:K,onDelete:t.onFileDelete,style:{display:"none"}},null,8,["limit","onDelete"]))]),_:1})}}},Un=A(En,[["__scopeId","data-v-ce983ffd"]]),Dn={__name:"CaseDetails",setup(e){const t=Y({}),s=Q(),a=Y(!1),n=Y(null),c=Y({caseNo:"",treatmenthospitalname:"",treatmentdeptname:"",name:"",nation:"",nationality:"中国",idcardtype:"",idcardno:"",sex:"",birthday:"",age:"",ageunit:"",inpatientno:"",diagnosisname:"",bloodtype:"",rhyin:"",infoname:"",infophone:"",reportername:s.name||"",reporterno:s.userId||"",reporterphone:"",reporttime:"",contactperson:"",education:"",illnessoverview:"",infectious:"",infectiousOther:"",isTransport:"1",nativeplace:"",occupation:"",patientstate:"",phone:"",registeraddress:"",registerprovince:"",registerprovincename:"",registercityname:"",registertownname:"",registercommunityname:"",residenceaddress:"",residenceprovince:"",residenceprovincename:"",residencecountycode:"",residencecountyname:"",residencetownname:"",residencecommunity:"",residencecommunityname:"",remark:"",reportStatus:"1",terminationCase:0,annexfilesList:[]}),u=Y([]),d=Y([]),h=Y(!1),p=Y(null),f=Y(!1),g=Y(!1),m=Y(!1);Y(!1);const y=Y(!1),v=Y(!1),_=Y(0),b=Y([{label:"青岛镜湖医院",value:"qdhospital1"},{label:"青岛科大医院",value:"qdhospital2"},{label:"青岛大学附属医院",value:"qdhospital3"},{label:"青岛市立医院",value:"qdhospital4"}]),w=Y([[{label:"神经外科",value:"neurosurgery"},{label:"心血管内科",value:"cardiology"},{label:"重症医学科",value:"icu"},{label:"急诊科",value:"emergency"},{label:"神经内科",value:"neurology"},{label:"呼吸内科",value:"respiratory"},{label:"消化内科",value:"gastroenterology"},{label:"肾内科",value:"nephrology"}]]),T=Y([{label:"汉族",value:"han"},{label:"回族",value:"hui"},{label:"满族",value:"man"},{label:"蒙古族",value:"menggu"}]),k=Y([{label:"居民身份证",value:"idcard"},{label:"护照",value:"passport"},{label:"军官证",value:"officer"}]),x=Y([{label:"男",value:"1"},{label:"女",value:"2"}]),I=Y([{label:"A型",value:"A"},{label:"B型",value:"B"},{label:"O型",value:"O"},{label:"AB型",value:"AB"}]),S=Y([{label:"阳性",value:"positive"},{label:"阴性",value:"negative"}]),P=Y([{label:"张医生",value:"doctor1"},{label:"李医生",value:"doctor2"}]),A=Y(!1),N=Y(""),M=Y("#f5f5f7"),q=X(()=>c.value.name&&c.value.idcardno&&c.value.diagnosisname),j=Y(-1),K=Y(-1),W=Y(-1),G=Y(-1),Z=X(()=>b.value.map(e=>e.label)),me=X(()=>c.value.age&&c.value.ageunit?`${c.value.age}${c.value.ageunit}`:"自动计算"),ye=X(()=>w.value[0].map(e=>e.label)),_e=X(()=>T.value.map(e=>e.label)),be=X(()=>k.value.map(e=>e.label)),we=X(()=>j.value>=0?Z.value[j.value]:"请选择医疗机构"),Te=X(()=>K.value>=0?ye.value[K.value]:"请选择科室"),ke=X(()=>W.value>=0?_e.value[W.value]:"请选择民族"),xe=X(()=>G.value>=0?be.value[G.value]:"请选择证件类型"),Ie=e=>{const t=parseInt(e.detail.value);j.value=t,c.value.treatmenthospitalname=b.value[t].label},Se=e=>{const t=parseInt(e.detail.value);K.value=t,c.value.treatmentdeptname=w.value[0][t].label},Pe=e=>{const t=parseInt(e.detail.value);W.value=t,c.value.nation=T.value[t].label},Ae=e=>{const t=parseInt(e.detail.value);G.value=t,c.value.idcardtype=k.value[t].value},Ce=e=>{c.value.birthday=e.detail.value,Ne()},Oe=e=>{const t=new Date(e.value);c.value.birthday=`${t.getFullYear()}-${(t.getMonth()+1).toString().padStart(2,"0")}-${t.getDate().toString().padStart(2,"0")}`,Ne(),y.value=!1},Fe=Y(""),Le=()=>c.value.idcardno?18!==c.value.idcardno.length?(Fe.value="请输入18位身份证号码",!1):(Fe.value="",!0):(Fe.value="请输入证件号码",!1);ie(()=>{setInterval(Ue,1e3)}),oe(async e=>{p.value=e.id,e.id?(n.value=e.id,a.value=!0,await Je(e.id)):(a.value=!1,De()),t.value=await ve("sys_IDType","sys_user_sex","sys_BloodType","sys_Infectious","sys_AgeUnit","sys_education","sys_nation","sys_occupation"),Ee(),Ue()});const Ee=()=>{d.value=t.value.sys_Infectious||[],k.value=t.value.sys_IDType||[]},Ue=()=>{const e=(new Date).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});N.value=e.replace(/\//g,"-"),c.value.reporttime=N.value},De=()=>{(new Date).getTime().toString().slice(-6)},Ne=()=>{if(!c.value.birthday)return c.value.age="",void(c.value.ageunit="");const e=new Date(c.value.birthday),t=new Date;if(isNaN(e.getTime()))return c.value.age="",void(c.value.ageunit="");const s=t.getTime()-e.getTime(),a=Math.floor(s/864e5);if(a<0)return c.value.age="",void(c.value.ageunit="");const n=t.getFullYear()-e.getFullYear(),i=t.getMonth()-e.getMonth(),o=t.getDate()-e.getDate();let r,l;if(n>=1){let e=n;(i<0||0===i&&o<0)&&(e=n-1),r=e.toString(),l="岁"}else if(a>=30){let e=12*n+i;o<0&&e--,r=Math.max(1,e).toString(),l="个月"}else r=Math.max(1,a).toString(),l="天";c.value.age=r,c.value.ageunit=l},Re=e=>{console.log("基础附件上传成功:",e)},Me=e=>{formData.attachments=e.map(e=>({...e,url:e.url.startsWith("http")?e.url.replace(baseUrlHt,""):e.url}))},$e=e=>{const t=e.url.startsWith("http")?e.url:baseUrlHt+(e.url.startsWith("/")?"":"/")+e.url;e.type.includes("image")?C({urls:formData.attachments.filter(e=>e.type.includes("image")).map(e=>e.url.startsWith("http")?e.url:baseUrlHt+(e.url.startsWith("/")?"":"/")+e.url),current:t}):e.type.includes("pdf")?se({url:t,success:e=>{ae({filePath:e.tempFilePath,fileType:"pdf",showMenu:!0})},fail:e=>{console.error("打开文档失败:",e),r({title:"打开文件失败",icon:"none"})}}):r({title:"暂不支持此文件类型预览",icon:"none"})},Be=e=>{e.value&&e.value[0]&&(c.value.treatmentdeptname=e.value[0].label),f.value=!1},qe=e=>{e.value&&e.value[0]&&(c.value.treatmenthospitalname=e.value[0].label),g.value=!1},je=e=>{e.value&&e.value[0]&&(c.value.nation=e.value[0].label),m.value=!1},Ve=e=>{e.value&&e.value[0]&&(c.value.reporterno=e.value[0].label),v.value=!1},Ke=()=>{l({title:"确认重置",content:"确定要清空所有已填写的内容吗?",success:e=>{e.confirm&&(Object.keys(c.value).forEach(e=>{["id","caseNo"].includes(e)||(c.value[e]="")}),j.value=-1,K.value=-1,W.value=-1,G.value=-1,u.value=[],c.value.nationality="中国",c.value.isTransport="1",c.value.terminationCase=0,c.value.reportStatus="1",a.value||De(),r({title:"表单已重置",icon:"success"}))}})},ze=async()=>{if(q.value)try{i({title:a.value?"修改中...":"提交中..."});const e={...c.value,age:parseInt(c.value.age)||0,annexfilesList:u.value.map(e=>({url:e.url,name:e.name,type:e.type})),phone:c.value.infophone,isTransport:c.value.isTransport||"1",terminationCase:c.value.terminationCase||0,reportStatus:c.value.reportStatus||"1"};let t;if(t=a.value?await uni.$uapi.post("/project/donatebaseinforeport/edit",e):await uni.$uapi.post("/project/donatebaseinforeport/add",e),o(),200!==t.code)throw new Error(t.msg||"操作失败");r({title:a.value?"修改成功":"上报成功",icon:"success"}),He(),setTimeout(()=>{fe()},1500)}catch(e){console.error("操作失败:",e),r({title:e.message||(a.value?"修改失败":"上报失败"),icon:"none"})}finally{A.value=!1}else r({title:"请填写姓名、证件号码和疾病诊断",icon:"none"})},He=()=>{localStorage.removeItem("caseReportDraft")},We=()=>{fe()},Je=async e=>{try{A.value=!0;const t=await uni.$uapi.get(`/project/donatebaseinforeport/getInfo/${e}`);if(200!==t.code||!t.data)throw new Error(t.msg||"数据加载失败");Object.keys(c.value).forEach(e=>{void 0!==t.data[e]&&null!==t.data[e]&&(c.value[e]=t.data[e])}),Ge(),t.data.annexfilesList&&(u.value=t.data.annexfilesList),r({title:"数据加载成功",icon:"success"})}catch(t){console.error("加载案例数据失败:",t),r({title:"数据加载失败,请重试",icon:"none"})}finally{A.value=!1}},Ge=()=>{const e=b.value.findIndex(e=>e.label===c.value.treatmenthospitalname);-1!==e&&(e.value=e);const t=w.value[0].findIndex(e=>e.label===c.value.treatmentdeptname);-1!==t&&(t.value=t);const s=T.value.findIndex(e=>e.label===c.value.nation);-1!==s&&(s.value=s);const a=k.value.findIndex(e=>e.value===c.value.idcardtype);-1!==a&&(a.value=a)};return(e,t)=>{const s=J,n=V,i=ee(te("u-input"),re),o=ge,r=ee(te("u-textarea"),le),l=ee(te("u-button"),ce),p=ne,k=ee(te("u-picker"),ue),C=ee(te("u-datetime-picker"),de),Q=ee(te("u-loading-icon"),he);return O(),F(n,{class:"case-report-container"},{default:L(()=>[R(p,{"scroll-y":"",class:"form-scroll","show-scrollbar":!1},{default:L(()=>[R(n,{class:"form-content"},{default:L(()=>[R(n,{class:"page-header"},{default:L(()=>[R(s,{class:"page-title"},{default:L(()=>[B(H(a.value?"修改案例":"上报案例"),1)]),_:1})]),_:1}),R(n,{class:"form-section"},{default:L(()=>[R(n,{class:"section-header"},{default:L(()=>[R(n,{class:"section-icon"},{default:L(()=>[B("📋")]),_:1}),R(s,{class:"section-title"},{default:L(()=>[B("捐献案例基本信息")]),_:1})]),_:1}),R(n,{class:"form-grid"},{default:L(()=>[R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("案例编号")]),_:1}),R(i,{modelValue:c.value.caseNo,"onUpdate:modelValue":t[0]||(t[0]=e=>c.value.caseNo=e),placeholder:"上报后自动生成",disabled:"",disabledColor:M.value,border:"none"},null,8,["modelValue","disabledColor"])]),_:1}),R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("医疗机构")]),_:1}),R(o,{mode:"selector",range:Z.value,value:j.value,onChange:Ie},{default:L(()=>[R(n,{class:"picker"},{default:L(()=>[R(s,null,{default:L(()=>[B(H(we.value),1)]),_:1}),R(s,{class:"icon-arrow"},{default:L(()=>[B("›")]),_:1})]),_:1})]),_:1},8,["range","value"])]),_:1}),R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("科室")]),_:1}),R(o,{mode:"selector",range:ye.value,value:K.value,onChange:Se},{default:L(()=>[R(n,{class:"picker"},{default:L(()=>[R(s,null,{default:L(()=>[B(H(Te.value),1)]),_:1}),R(s,{class:"icon-arrow"},{default:L(()=>[B("›")]),_:1})]),_:1})]),_:1},8,["range","value"])]),_:1}),R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label required"},{default:L(()=>[B("姓名")]),_:1}),R(i,{type:"text",modelValue:c.value.name,"onUpdate:modelValue":t[1]||(t[1]=e=>c.value.name=e),placeholder:"请输入姓名",maxlength:"20",class:"custom-input"},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),R(n,{class:"form-section"},{default:L(()=>[R(n,{class:"section-header"},{default:L(()=>[R(n,{class:"section-icon"},{default:L(()=>[B("👤")]),_:1}),R(s,{class:"section-title"},{default:L(()=>[B("捐献人信息")]),_:1})]),_:1}),R(n,{class:"form-grid"},{default:L(()=>[R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("民族")]),_:1}),R(o,{mode:"selector",range:_e.value,value:W.value,onChange:Pe},{default:L(()=>[R(n,{class:"picker"},{default:L(()=>[R(s,null,{default:L(()=>[B(H(ke.value),1)]),_:1}),R(s,{class:"icon-arrow"},{default:L(()=>[B("›")]),_:1})]),_:1})]),_:1},8,["range","value"])]),_:1}),R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("国籍")]),_:1}),R(i,{type:"text",modelValue:c.value.nationality,"onUpdate:modelValue":t[2]||(t[2]=e=>c.value.nationality=e),placeholder:"请输入国籍",class:"custom-input"},null,8,["modelValue"])]),_:1}),R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("证件类型")]),_:1}),R(o,{mode:"selector",range:be.value,value:G.value,onChange:Ae},{default:L(()=>[R(n,{class:"picker"},{default:L(()=>[R(s,null,{default:L(()=>[B(H(xe.value),1)]),_:1}),R(s,{class:"icon-arrow"},{default:L(()=>[B("›")]),_:1})]),_:1})]),_:1},8,["range","value"])]),_:1}),R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label required"},{default:L(()=>[B("证件号码")]),_:1}),R(i,{type:"idcard",modelValue:c.value.idcardno,"onUpdate:modelValue":t[3]||(t[3]=e=>c.value.idcardno=e),placeholder:"请输入证件号码",maxlength:"18",class:"custom-input",onBlur:Le},null,8,["modelValue"]),Fe.value?(O(),F(s,{key:0,class:"error-text"},{default:L(()=>[B(H(Fe.value),1)]),_:1})):$("",!0)]),_:1}),R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("性别")]),_:1}),R(n,{class:"radio-options"},{default:L(()=>[(O(!0),E(U,null,D(x.value,e=>(O(),F(n,{key:e.value,class:z(["option-item",{active:c.value.sex===e.value}]),onClick:t=>c.value.sex=e.value},{default:L(()=>[R(s,{class:"radio-dot"}),R(s,{class:"option-label"},{default:L(()=>[B(H(e.label),1)]),_:2},1024)]),_:2},1032,["class","onClick"]))),128))]),_:1})]),_:1}),R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("出生日期")]),_:1}),R(o,{mode:"date",value:c.value.birthday,onChange:Ce},{default:L(()=>[R(n,{class:"picker"},{default:L(()=>[R(s,null,{default:L(()=>[B(H(c.value.birthday||"选择出生日期"),1)]),_:1}),R(s,{class:"icon-arrow"},{default:L(()=>[B("›")]),_:1})]),_:1})]),_:1},8,["value"])]),_:1}),R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("年龄")]),_:1}),R(i,{modelValue:me.value,"onUpdate:modelValue":t[4]||(t[4]=e=>me.value=e),placeholder:"自动计算",disabled:"",disabledColor:M.value,border:"none"},null,8,["modelValue","disabledColor"])]),_:1})]),_:1})]),_:1}),R(n,{class:"form-section"},{default:L(()=>[R(n,{class:"section-header"},{default:L(()=>[R(n,{class:"section-icon"},{default:L(()=>[B("🏥")]),_:1}),R(s,{class:"section-title"},{default:L(()=>[B("医疗信息")]),_:1})]),_:1}),R(n,{class:"form-grid"},{default:L(()=>[R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("住院号")]),_:1}),R(i,{modelValue:c.value.inpatientno,"onUpdate:modelValue":t[5]||(t[5]=e=>c.value.inpatientno=e),placeholder:"请输入住院号",border:"none"},null,8,["modelValue"])]),_:1}),R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("GCS评分")]),_:1}),R(i,{modelValue:c.value.gscScore,"onUpdate:modelValue":t[6]||(t[6]=e=>c.value.gscScore=e),placeholder:"请输入GCS评分",border:"none"},null,8,["modelValue"])]),_:1}),R(n,{class:"form-item full-width"},{default:L(()=>{return[R(s,{class:"item-label required"},{default:L(()=>[B("疾病诊断")]),_:1}),R(r,{modelValue:c.value.diagnosisname,"onUpdate:modelValue":t[7]||(t[7]=e=>c.value.diagnosisname=e),placeholder:"请输入疾病诊断名称",count:"",maxlength:"200",customStyle:(e=!c.value.diagnosisname,e?"border: 2rpx solid #ff4757; border-radius: 12rpx; min-height: 120rpx; padding: 20rpx 24rpx;":"border: 2rpx solid #e5e5e7; border-radius: 12rpx; min-height: 120rpx; padding: 20rpx 24rpx;")},null,8,["modelValue","customStyle"])];var e}),_:1}),R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("血型")]),_:1}),R(n,{class:"radio-group horizontal"},{default:L(()=>[(O(!0),E(U,null,D(I.value,e=>(O(),F(n,{key:e.value,class:"radio-item",onClick:t=>c.value.bloodtype=e.value},{default:L(()=>[R(n,{class:z(["radio-dot",{active:c.value.bloodtype===e.value}])},null,8,["class"]),R(s,{class:"radio-label"},{default:L(()=>[B(H(e.label),1)]),_:2},1024)]),_:2},1032,["onClick"]))),128))]),_:1})]),_:1}),R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("传染病")]),_:1}),R(n,{class:"radio-group horizontal"},{default:L(()=>[(O(!0),E(U,null,D(d.value,e=>(O(),F(n,{key:e.value,class:"radio-item",onClick:t=>c.value.infectious=e.value},{default:L(()=>[R(n,{class:z(["radio-dot",{active:c.value.bloodtype===e.value}])},null,8,["class"]),R(s,{class:"radio-label"},{default:L(()=>[B(H(e.label),1)]),_:2},1024)]),_:2},1032,["onClick"]))),128))]),_:1})]),_:1}),R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("其他")]),_:1}),R(i,{modelValue:c.value.infectiousOther,"onUpdate:modelValue":t[8]||(t[8]=e=>c.value.infectiousOther=e),placeholder:"请输入住院号",border:"none"},null,8,["modelValue"])]),_:1}),R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("Rh(D)")]),_:1}),R(n,{class:"radio-group horizontal"},{default:L(()=>[(O(!0),E(U,null,D(S.value,e=>(O(),F(n,{key:e.value,class:"radio-item",onClick:t=>c.value.rhyin=e.value},{default:L(()=>[R(n,{class:z(["radio-dot",{active:c.value.rhyin===e.value}])},null,8,["class"]),R(s,{class:"radio-label"},{default:L(()=>[B(H(e.label),1)]),_:2},1024)]),_:2},1032,["onClick"]))),128))]),_:1})]),_:1})]),_:1})]),_:1}),R(n,{class:"form-section"},{default:L(()=>[R(n,{class:"section-header"},{default:L(()=>[R(n,{class:"section-icon"},{default:L(()=>[B("📞")]),_:1}),R(s,{class:"section-title"},{default:L(()=>[B("联系信息")]),_:1})]),_:1}),R(n,{class:"form-grid"},{default:L(()=>[R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("信息员")]),_:1}),R(i,{modelValue:c.value.infoname,"onUpdate:modelValue":t[9]||(t[9]=e=>c.value.infoname=e),placeholder:"请输入信息员",border:"none"},null,8,["modelValue"])]),_:1}),R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("联系电话")]),_:1}),R(i,{modelValue:c.value.infophone,"onUpdate:modelValue":t[10]||(t[10]=e=>c.value.infophone=e),placeholder:"请输入联系电话",type:"number",border:"none"},null,8,["modelValue"])]),_:1}),R(n,{class:"form-item"},{default:L(()=>[R(s,{class:"item-label"},{default:L(()=>[B("报告时间")]),_:1}),R(i,{modelValue:N.value,"onUpdate:modelValue":t[11]||(t[11]=e=>N.value=e),disabled:"",disabledColor:M.value,border:"none"},null,8,["modelValue","disabledColor"])]),_:1})]),_:1})]),_:1}),R(n,{class:"action-buttons"},{default:L(()=>[R(l,{class:"btn secondary",onClick:We},{default:L(()=>[B("取消")]),_:1}),R(l,{class:"btn secondary",onClick:Ke},{default:L(()=>[B("重置表单")]),_:1}),R(l,{class:"btn primary",disabled:!q.value||A.value,onClick:ze},{default:L(()=>[B(H(A.value?"提交中...":a.value?"保存修改":"提交上报"),1)]),_:1},8,["disabled"])]),_:1}),R(pe(Un),{ref:"attachment",files:u.value,readonly:h.value,maxCount:5,"onUpdate:files":Me,onUploadBase:Re,onPreview:$e},null,8,["files","readonly"])]),_:1})]),_:1}),R(k,{show:f.value,columns:w.value,keyName:"label",onConfirm:Be,onCancel:t[12]||(t[12]=e=>f.value=!1),title:"请选择科室",ref:"uPicker"},null,8,["show","columns"]),R(k,{show:g.value,columns:[b.value],keyName:"label",onConfirm:qe,onCancel:t[13]||(t[13]=e=>g.value=!1),title:"请选择医疗机构"},null,8,["show","columns"]),R(k,{show:m.value,columns:[T.value],keyName:"label",onConfirm:je,onCancel:t[14]||(t[14]=e=>m.value=!1),title:"请选择民族"},null,8,["show","columns"]),R(C,{show:y.value,modelValue:_.value,"onUpdate:modelValue":t[15]||(t[15]=e=>_.value=e),mode:"date",onConfirm:Oe,onCancel:t[16]||(t[16]=e=>y.value=!1),title:"选择出生日期"},null,8,["show","modelValue"]),R(k,{show:v.value,columns:[P.value],keyName:"label",onConfirm:Ve,onCancel:t[17]||(t[17]=e=>v.value=!1),title:"请选择报告人"},null,8,["show","columns"]),R(Q,{show:A.value,text:"提交中..."},null,8,["show"])]),_:1})}}},Nn=A(Dn,[["__scopeId","data-v-16a395db"]]);export{Nn as default};
|