import"./COfxcSTK.js";import{E as I,a as H}from"./CRUlBoqP.js";import"./BN7fr1Nn.js";import"./DedMas4Y.js";import{aE as $,f as F,aC as w,a3 as G,aF as C,g as W,aG as J,K as Y,H as Z,k as j,aH as Q,r as X,s as L,aq as x,as as K,aI as k,h as A,aJ as ee,I as z,aK as ae,aL as te,Y as se,Z as ne,$ as re}from"#entry";import{c as ie}from"./BdITQT5f.js";const oe=[1779033703,-1150833019,1013904242,-1521486534,1359893119,-1694144372,528734635,1541459225],ce=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998],le="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",P=[];class ue{_data=new R;_hash=new R([...oe]);_nDataBytes=0;_minBufferSize=0;finalize(e){e&&this._append(e);const s=this._nDataBytes*8,a=this._data.sigBytes*8;return this._data.words[a>>>5]|=128<<24-a%32,this._data.words[(a+64>>>9<<4)+14]=Math.floor(s/4294967296),this._data.words[(a+64>>>9<<4)+15]=s,this._data.sigBytes=this._data.words.length*4,this._process(),this._hash}_doProcessBlock(e,s){const a=this._hash.words;let n=a[0],i=a[1],r=a[2],f=a[3],c=a[4],y=a[5],o=a[6],l=a[7];for(let u=0;u<64;u++){if(u<16)P[u]=e[s+u]|0;else{const d=P[u-15],_=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,p=P[u-2],B=(p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10;P[u]=_+P[u-7]+B+P[u-16]}const m=c&y^~c&o,h=n&i^n&r^i&r,D=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),g=(c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25),v=l+g+m+ce[u]+P[u],b=D+h;l=o,o=y,y=c,c=f+v|0,f=r,r=i,i=n,n=v+b|0}a[0]=a[0]+n|0,a[1]=a[1]+i|0,a[2]=a[2]+r|0,a[3]=a[3]+f|0,a[4]=a[4]+c|0,a[5]=a[5]+y|0,a[6]=a[6]+o|0,a[7]=a[7]+l|0}_append(e){typeof e=="string"&&(e=R.fromUtf8(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes}_process(e){let s,a=this._data.sigBytes/64;e?a=Math.ceil(a):a=Math.max((a|0)-this._minBufferSize,0);const n=a*16,i=Math.min(n*4,this._data.sigBytes);if(n){for(let r=0;r<n;r+=16)this._doProcessBlock(this._data.words,r);s=this._data.words.splice(0,n),this._data.sigBytes-=i}return new R(s,i)}}class R{words;sigBytes;constructor(e,s){e=this.words=e||[],this.sigBytes=s===void 0?e.length*4:s}static fromUtf8(e){const s=unescape(encodeURIComponent(e)),a=s.length,n=[];for(let i=0;i<a;i++)n[i>>>2]|=(s.charCodeAt(i)&255)<<24-i%4*8;return new R(n,a)}toBase64(){const e=[];for(let s=0;s<this.sigBytes;s+=3){const a=this.words[s>>>2]>>>24-s%4*8&255,n=this.words[s+1>>>2]>>>24-(s+1)%4*8&255,i=this.words[s+2>>>2]>>>24-(s+2)%4*8&255,r=a<<16|n<<8|i;for(let f=0;f<4&&s*8+f*6<this.sigBytes*8;f++)e.push(le.charAt(r>>>6*(3-f)&63))}return e.join("")}concat(e){if(this.words[this.sigBytes>>>2]&=4294967295<<32-this.sigBytes%4*8,this.words.length=Math.ceil(this.sigBytes/4),this.sigBytes%4)for(let s=0;s<e.sigBytes;s++){const a=e.words[s>>>2]>>>24-s%4*8&255;this.words[this.sigBytes+s>>>2]|=a<<24-(this.sigBytes+s)%4*8}else for(let s=0;s<e.sigBytes;s+=4)this.words[this.sigBytes+s>>>2]=e.words[s>>>2];this.sigBytes+=e.sigBytes}}function fe(t){return new ue().finalize(t).toBase64()}function E(t){return fe($(t))}const de={trailing:!0};function he(t,e=25,s={}){if(s={...de,...s},!Number.isFinite(e))throw new TypeError("Expected `wait` to be a finite number");let a,n,i=[],r,f;const c=(l,u)=>(r=_e(t,l,u),r.finally(()=>{if(r=null,s.trailing&&f&&!n){const m=c(l,f);return f=null,m}}),r),y=function(...l){return s.trailing&&(f=l),r||new Promise(u=>{const m=!n&&s.leading;clearTimeout(n),n=setTimeout(()=>{n=null;const h=s.leading?a:c(this,l);f=null;for(const D of i)D(h);i=[]},e),m?(a=c(this,l),u(a)):i.push(u)})},o=l=>{l&&(clearTimeout(l),n=null)};return y.isPending=()=>!!n,y.cancel=()=>{o(n),i=[],f=null},y.flush=()=>{if(o(n),!f||r)return;const l=f;return f=null,c(this,l)},y}async function _e(t,e,s){return await t.apply(e,s)}const ye=t=>t==="defer"||t===!1;function me(...t){const e=typeof t[t.length-1]=="string"?t.pop():void 0;ge(t[0],t[1])&&t.unshift(e);let[s,a,n={}]=t;const i=F(()=>w(s));if(typeof i.value!="string")throw new TypeError("[nuxt] [useAsyncData] key must be a string.");if(typeof a!="function")throw new TypeError("[nuxt] [useAsyncData] handler must be a function.");const r=G();n.server??=!0,n.default??=De,n.getCachedData??=N,n.lazy??=!1,n.immediate??=!0,n.deep??=C.deep,n.dedupe??="cancel",n._functionName,r._asyncData[i.value];const f={cause:"initial",dedupe:n.dedupe};r._asyncData[i.value]?._init||(f.cachedData=n.getCachedData(i.value,r,{cause:"initial"}),r._asyncData[i.value]=U(r,i.value,a,n,f.cachedData));const c=r._asyncData[i.value];c._deps++;const y=()=>r._asyncData[i.value].execute(f),o=n.server!==!1&&r.payload.serverRendered;{let m=function(d){const _=r._asyncData[d];_?._deps&&(_._deps--,_._deps===0&&_?._off())};const h=W();if(h&&o&&n.immediate&&!h.sp&&(h.sp=[]),h&&!h._nuxtOnBeforeMountCbs){h._nuxtOnBeforeMountCbs=[];const d=h._nuxtOnBeforeMountCbs;J(()=>{d.forEach(_=>{_()}),d.splice(0,d.length)}),Y(()=>d.splice(0,d.length))}const D=h&&(h._nuxtClientOnly||Z(ie,!1));o&&r.isHydrating&&(c.error.value||c.data.value!=null)?(c.pending.value=!1,c.status.value=c.error.value?"error":"success"):h&&(!D&&r.payload.serverRendered&&r.isHydrating||n.lazy)&&n.immediate?h._nuxtOnBeforeMountCbs.push(y):n.immediate&&y();const g=ee(),v=j(i,(d,_)=>{if((d||_)&&d!==_){const p=r._asyncData[_]?.data.value!==C.value,B=r._asyncDataPromises[_]!==void 0;_&&m(_);const O={cause:"initial",dedupe:n.dedupe};if(!r._asyncData[d]?._init){let T;_&&p?T=r._asyncData[_]?.data.value:(T=n.getCachedData(d,r,{cause:"initial"}),O.cachedData=T),r._asyncData[d]=U(r,d,a,n,T)}r._asyncData[d]._deps++,(n.immediate||p||B)&&r._asyncData[d].execute(O)}},{flush:"sync"}),b=n.watch?j(n.watch,()=>{c._execute({cause:"watch",dedupe:n.dedupe})}):()=>{};g&&Q(()=>{v(),b(),m(i.value)})}const l={data:S(()=>r._asyncData[i.value]?.data),pending:S(()=>r._asyncData[i.value]?.pending),status:S(()=>r._asyncData[i.value]?.status),error:S(()=>r._asyncData[i.value]?.error),refresh:(...m)=>r._asyncData[i.value].execute(...m),execute:(...m)=>r._asyncData[i.value].execute(...m),clear:()=>V(r,i.value)},u=Promise.resolve(r._asyncDataPromises[i.value]).then(()=>l);return Object.assign(u,l),u}function S(t){return F({get(){return t()?.value},set(e){const s=t();s&&(s.value=e)}})}function ge(t,e){return!(typeof t=="string"||typeof t=="object"&&t!==null||typeof t=="function"&&typeof e=="function")}function V(t,e){e in t.payload.data&&(t.payload.data[e]=void 0),e in t.payload._errors&&(t.payload._errors[e]=C.errorValue),t._asyncData[e]&&(t._asyncData[e].data.value=void 0,t._asyncData[e].error.value=C.errorValue,t._asyncData[e].pending.value=!1,t._asyncData[e].status.value="idle"),e in t._asyncDataPromises&&(t._asyncDataPromises[e]&&(t._asyncDataPromises[e].cancelled=!0),t._asyncDataPromises[e]=void 0)}function ve(t,e){const s={};for(const a of e)s[a]=t[a];return s}function U(t,e,s,a,n){t.payload._errors[e]??=C.errorValue;const i=a.getCachedData!==N,r=s,f=a.deep?X:L,c=n!=null,y=t.hook("app:data:refresh",async l=>{(!l||l.includes(e))&&await o.execute({cause:"refresh:hook"})}),o={data:f(c?n:a.default()),pending:L(!c),error:x(t.payload._errors,e),status:L("idle"),execute:(...l)=>{const[u,m=void 0]=l,h=u&&m===void 0&&typeof u=="object"?u:{};if(t._asyncDataPromises[e]){if(ye(h.dedupe??a.dedupe))return t._asyncDataPromises[e];t._asyncDataPromises[e].cancelled=!0}if(h.cause==="initial"||t.isHydrating){const g="cachedData"in h?h.cachedData:a.getCachedData(e,t,{cause:h.cause??"refresh:manual"});if(g!=null)return t.payload.data[e]=o.data.value=g,o.error.value=C.errorValue,o.status.value="success",Promise.resolve(g)}o.pending.value=!0,o.status.value="pending";const D=new Promise((g,v)=>{try{g(r(t))}catch(b){v(b)}}).then(async g=>{if(D.cancelled)return t._asyncDataPromises[e];let v=g;a.transform&&(v=await a.transform(g)),a.pick&&(v=ve(v,a.pick)),t.payload.data[e]=v,o.data.value=v,o.error.value=C.errorValue,o.status.value="success"}).catch(g=>{if(D.cancelled)return t._asyncDataPromises[e];o.error.value=k(g),o.data.value=A(a.default()),o.status.value="error"}).finally(()=>{D.cancelled||(o.pending.value=!1,delete t._asyncDataPromises[e])});return t._asyncDataPromises[e]=D,t._asyncDataPromises[e]},_execute:he((...l)=>o.execute(...l),0,{leading:!0}),_default:a.default,_deps:0,_init:!0,_hash:void 0,_off:()=>{y(),t._asyncData[e]?._init&&(t._asyncData[e]._init=!1),i||K(()=>{t._asyncData[e]?._init||(V(t,e),o.execute=()=>Promise.resolve(),o.data.value=C.value)})}};return o}const De=()=>C.value,N=(t,e,s)=>{if(e.isHydrating)return e.payload.data[t];if(s.cause!=="refresh:manual"&&s.cause!=="refresh:hook")return e.static.data[t]};function we(t,e,s){const[a={},n]=typeof e=="string"?[{},e]:[e,s],i=F(()=>w(t)),r=F(()=>w(a.key)||"$f"+E([n,typeof i.value=="string"?i.value:"",...be(a)]));if(!a.baseURL&&typeof i.value=="string"&&i.value[0]==="/"&&i.value[1]==="/")throw new Error('[nuxt] [useFetch] the request URL must not start with "//".');const{server:f,lazy:c,default:y,transform:o,pick:l,watch:u,immediate:m,getCachedData:h,deep:D,dedupe:g,...v}=a,b=z({...ae,...v,cache:typeof a.cache=="boolean"?void 0:a.cache}),d={server:f,lazy:c,default:y,transform:o,pick:l,immediate:m,getCachedData:h,deep:D,dedupe:g,watch:u===!1?[]:[...u||[],b]};if(!m){let B=function(){d.immediate=!0};j(r,B,{flush:"sync",once:!0}),j([...u||[],b],B,{flush:"sync",once:!0})}let _;return me(u===!1?r.value:r,()=>{_?.abort?.(new DOMException("Request aborted as another request to the same endpoint was initiated.","AbortError")),_=typeof AbortController<"u"?new AbortController:{};const B=w(a.timeout);let O;return B&&(O=setTimeout(()=>_.abort(new DOMException("Request aborted due to timeout.","AbortError")),B),_.signal.onabort=()=>clearTimeout(O)),(a.$fetch||globalThis.$fetch)(i.value,{signal:_.signal,...b}).finally(()=>{clearTimeout(O)})},d)}function be(t){const e=[w(t.method)?.toUpperCase()||"GET",w(t.baseURL)];for(const s of[t.params||t.query]){const a=w(s);if(!a)continue;const n={};for(const[i,r]of Object.entries(a))n[w(i)]=w(r);e.push(n)}if(t.body){const s=w(t.body);if(!s)e.push(E(s));else if(s instanceof ArrayBuffer)e.push(E(Object.fromEntries([...new Uint8Array(s).entries()].map(([a,n])=>[a,n.toString()]))));else if(s instanceof FormData){const a={};for(const n of s.entries()){const[i,r]=n;a[i]=r instanceof File?r.name:r}e.push(E(a))}else if(te(s))e.push(E(z(s)));else try{e.push(E(s))}catch{console.warn("[useFetch] Failed to hash body",s)}}return e}let q=null,M=0;const pe=()=>{M===0&&(q=H.service({fullscreen:!0,text:"加载中...",background:"rgba(0, 0, 0, 0.7)"})),M++},Be=()=>{M--,M<=0&&(q?.close(),M=0)},Me=async(t,e,s=!0)=>{pe();const a=se();let n=!0,i=0;const{data:r,status:f,refresh:c,error:y}=await we(t,{...e,immediate:!1,watch:!1,...a.token.value&&s?{headers:{Authorization:a.token.value}}:{}},"$_ee08VsBu3");return j(y,o=>{if(o?.statusCode===401&&i==0&&s){i=1;const l=ne();I.alert("登录已过期，请重新登录","提示",{showClose:!1,closeOnClickModal:!1,confirmButtonText:"OK",callback:()=>{re(l("/auth/login"))}})}}),n=!1,Be(),{data:r,status:f,refresh:c,error:y,loading:n}};export{Me as u};
