"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("vue");function b(t){return typeof t=="function"?t():l.unref(t)}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const F=()=>{};function q(t,a=!1,o="Timeout"){return new Promise((d,T)=>{setTimeout(a?()=>T(o):d,t)})}function x(t,a=!1){function o(e,{flush:n="sync",deep:r=!1,timeout:c,throwOnTimeout:p}={}){let s=null;const m=[new Promise(y=>{s=l.watch(t,f=>{e(f)!==a&&(s==null||s(),y(f))},{flush:n,deep:r,immediate:!0})})];return c!=null&&m.push(q(c,p).then(()=>b(t)).finally(()=>s==null?void 0:s())),Promise.race(m)}function d(e,n){if(!l.isRef(e))return o(f=>f===e,n);const{flush:r="sync",deep:c=!1,timeout:p,throwOnTimeout:s}=n??{};let i=null;const y=[new Promise(f=>{i=l.watch([t,e],([u,g])=>{a!==(u===g)&&(i==null||i(),f(u))},{flush:r,deep:c,immediate:!0})})];return p!=null&&y.push(q(p,s).then(()=>b(t)).finally(()=>(i==null||i(),b(t)))),Promise.race(y)}function T(e){return o(n=>!!n,e)}function P(e){return d(null,e)}function S(e){return d(void 0,e)}function B(e){return o(Number.isNaN,e)}function A(e,n){return o(r=>{const c=Array.from(r);return c.includes(e)||c.includes(b(e))},n)}function v(e){return h(1,e)}function h(e=1,n){let r=-1;return o(()=>(r+=1,r>=e),n)}return Array.isArray(b(t))?{toMatch:o,toContains:A,changed:v,changedTimes:h,get not(){return x(t,!a)}}:{toMatch:o,toBe:d,toBeTruthy:T,toBeNull:P,toBeNaN:B,toBeUndefined:S,changed:v,changedTimes:h,get not(){return x(t,!a)}}}function E(t){return x(t)}function N(t){const{initialData:a,shallow:o,onSuccess:d=F,onError:T=F,immediate:P,resetOnExecute:S=!1,queryFn:B,queryKey:A}=t,v=(o?l.shallowRef:l.ref)(a),h=l.ref(!1),e=l.ref(!1),n=l.ref(!1),r=l.shallowRef(),c=u=>{e.value=u,h.value=!u},p=()=>{S&&(v.value=a)},s=()=>new Promise((u,g)=>{E(h).toBe(!0).then(()=>r.value?g(r.value):u(f))}),i={then:(...u)=>s().then(...u),catch:(...u)=>s().catch(...u)};let m=0;const y=u=>{if(r.value=void 0,e.value)return i;if(B===void 0)return h.value=!0,i;p(),c(!0),m+=1;const g=m;return B(u).then(w=>{const C=w;v.value=C,d(C)}).catch(w=>{r.value=w,T(w)}).finally(()=>{var w;(w=t.onFinish)==null||w.call(t),g===m&&c(!1)}),i};P&&y();const f={data:v,error:r,isFinished:h,isLoading:e,isAborted:n,isCanceled:n,execute:y};return{...f,...i}}exports.useHttp=N;
//# sourceMappingURL=useHttp.js.map
