import{r as b,az as C,w as A,b_ as B,b$ as z,c0 as D,n as S,b8 as P,ac as F,c as G}from"./index-BT5eY4j5.js";function N(n){return z()?(D(n),!0):!1}const U=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const E=()=>{};function k(n,u=!1,o="Timeout"){return new Promise((c,y)=>{setTimeout(u?()=>y(o):c,n)})}function x(n,u=!1){function o(e,{flush:t="sync",deep:a=!1,timeout:l,throwOnTimeout:v}={}){let m=null;const w=[new Promise(T=>{m=A(n,f=>{e(f)!==u&&(m?m():S(()=>m?.()),T(f))},{flush:t,deep:a,immediate:!0})})];return l!=null&&w.push(k(l,v).then(()=>B(n)).finally(()=>m?.())),Promise.race(w)}function c(e,t){if(!C(e))return o(f=>f===e,t);const{flush:a="sync",deep:l=!1,timeout:v,throwOnTimeout:m}=t??{};let i=null;const T=[new Promise(f=>{i=A([n,e],([I,W])=>{u!==(I===W)&&(i?i():S(()=>i?.()),f(I))},{flush:a,deep:l,immediate:!0})})];return v!=null&&T.push(k(v,m).then(()=>B(n)).finally(()=>(i?.(),B(n)))),Promise.race(T)}function y(e){return o(t=>!!t,e)}function s(e){return c(null,e)}function h(e){return c(void 0,e)}function g(e){return o(Number.isNaN,e)}function p(e,t){return o(a=>{const l=Array.from(a);return l.includes(e)||l.includes(B(e))},t)}function d(e){return r(1,e)}function r(e=1,t){let a=-1;return o(()=>(a+=1,a>=e),t)}return Array.isArray(B(n))?{toMatch:o,toContains:p,changed:d,changedTimes:r,get not(){return x(n,!u)}}:{toMatch:o,toBe:c,toBeTruthy:y,toBeNull:s,toBeNaN:g,toBeUndefined:h,changed:d,changedTimes:r,get not(){return x(n,!u)}}}function L(n){return x(n)}function R(n,u=1e3,o={}){const{immediate:c=!0,immediateCallback:y=!1}=o;let s=null;const h=b(!1);function g(){s&&(clearInterval(s),s=null)}function p(){h.value=!1,g()}function d(){const r=B(u);r<=0||(h.value=!0,y&&n(),g(),h.value&&(s=setInterval(n,r)))}if(c&&U&&d(),C(u)||typeof u=="function"){const r=A(u,()=>{h.value&&U&&d()});N(r)}return N(p),{isActive:h,pause:p,resume:d}}function V(n,u,o){let c;C(o)?c={evaluating:o}:c={};const{lazy:y=!1,evaluating:s=void 0,shallow:h=!0,onError:g=E}=c,p=b(!y),d=h?P(u):b(u);let r=0;return F(async e=>{if(!p.value)return;r++;const t=r;let a=!1;s&&Promise.resolve().then(()=>{s.value=!0});try{const l=await n(v=>{e(()=>{s&&(s.value=!1),a||v()})});t===r&&(d.value=l)}catch(l){g(l)}finally{s&&t===r&&(s.value=!1),a=!0}}),y?G(()=>(p.value=!0,d.value)):d}function _(n,u,o){const{immediate:c=!0,delay:y=0,onError:s=E,onSuccess:h=E,resetOnExecute:g=!0,shallow:p=!0,throwError:d}=o??{},r=p?P(u):b(u),e=b(!1),t=b(!1),a=P(void 0);async function l(i=0,...w){g&&(r.value=u),a.value=void 0,e.value=!1,t.value=!0,i>0&&await k(i);const T=typeof n=="function"?n(...w):n;try{const f=await T;r.value=f,e.value=!0,h(f)}catch(f){if(a.value=f,s(f),d)throw f}finally{t.value=!1}return r.value}c&&l(y);const v={state:r,isReady:e,isLoading:t,error:a,execute:l};function m(){return new Promise((i,w)=>{L(t).toBe(!1).then(()=>i(v)).catch(w)})}return{...v,then(i,w){return m().then(i,w)}}}export{R as a,V as c,_ as u};
