"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("vue"),L={create:()=>Promise.resolve({data:null}),deleteOne:()=>Promise.resolve({data:null}),getList:()=>Promise.resolve({data:Array.from({length:30}).map((e,n)=>({name:n,id:n})),total:20}),getMany:()=>Promise.resolve({data:[]}),getManyReference:()=>Promise.resolve({data:[],total:0}),getOne:()=>Promise.resolve({data:null}),update:()=>Promise.resolve({data:null})},E=new WeakMap,D=(...e)=>{var n;const r=e[0],a=(n=u.getCurrentInstance())==null?void 0:n.proxy;if(a==null)throw new Error("injectLocal must be called in setup");return E.has(a)&&r in E.get(a)?E.get(a)[r]:u.inject(...e)};function _(e){return typeof e=="function"?e():u.unref(e)}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const b=()=>{};function R(e,n=!1,r="Timeout"){return new Promise((a,T)=>{setTimeout(n?()=>T(r):a,e)})}function F(e,n=!1){function r(t,{flush:o="sync",deep:s=!1,timeout:f,throwOnTimeout:g}={}){let d=null;const y=[new Promise(P=>{d=u.watch(e,m=>{t(m)!==n&&(d==null||d(),P(m))},{flush:o,deep:s,immediate:!0})})];return f!=null&&y.push(R(f,g).then(()=>_(e)).finally(()=>d==null?void 0:d())),Promise.race(y)}function a(t,o){if(!u.isRef(t))return r(m=>m===t,o);const{flush:s="sync",deep:f=!1,timeout:g,throwOnTimeout:d}=o??{};let i=null;const P=[new Promise(m=>{i=u.watch([e,t],([l,S])=>{n!==(l===S)&&(i==null||i(),m(l))},{flush:s,deep:f,immediate:!0})})];return g!=null&&P.push(R(g,d).then(()=>_(e)).finally(()=>(i==null||i(),_(e)))),Promise.race(P)}function T(t){return r(o=>!!o,t)}function A(t){return a(null,t)}function v(t){return a(void 0,t)}function w(t){return r(Number.isNaN,t)}function C(t,o){return r(s=>{const f=Array.from(s);return f.includes(t)||f.includes(_(t))},o)}function h(t){return c(1,t)}function c(t=1,o){let s=-1;return r(()=>(s+=1,s>=t),o)}return Array.isArray(_(e))?{toMatch:r,toContains:C,changed:h,changedTimes:c,get not(){return F(e,!n)}}:{toMatch:r,toBe:a,toBeTruthy:T,toBeNull:A,toBeNaN:w,toBeUndefined:v,changed:h,changedTimes:c,get not(){return F(e,!n)}}}function N(e){return F(e)}const B=Symbol("DATA_PROVIDER_CONTEXT"),M=()=>D(B,L),x={rowKey:"id",title:"Fast Start",routerMode:"hash",basename:"/"},X=Symbol("FAST_START_CONTEXT"),j=()=>D(X,x),k={};function q(e){const{initialData:n,shallow:r,onSuccess:a=b,onError:T=b,immediate:A,resetOnExecute:v=!1,queryFn:w,queryKey:C}=e,h=(r?u.shallowRef:u.ref)(n),c=u.ref(!1),t=u.ref(!1),o=u.ref(!1),s=u.shallowRef(),f=l=>{t.value=l,c.value=!l},g=()=>{v&&(h.value=n)},d=()=>new Promise((l,S)=>{N(c).toBe(!0).then(()=>s.value?S(s.value):l(m))}),i={then:(...l)=>d().then(...l),catch:(...l)=>d().catch(...l)};let y=0;const P=l=>{if(s.value=void 0,t.value)return i;if(w===void 0)return c.value=!0,i;g(),f(!0),y+=1;const S=y;return w(l).then(p=>{const O=p;h.value=O,a(O)}).catch(p=>{s.value=p,T(p)}).finally(()=>{var p;(p=e.onFinish)==null||p.call(e),S===y&&f(!1)}),i};A&&P();const m={data:h,error:s,isFinished:c,isLoading:t,isAborted:o,isCanceled:o,execute:P};return{...m,...i}}const G=(e,n={},r)=>{const{pagination:a={page:1,perPage:20},filter:T=k}=n,A=M();j();const v=q({immediate:r,queryFn:()=>new Promise((h,c)=>{A.getList(e,{pagination:a,filter:T}).then(({data:t,total:o})=>({data:t,total:o})).then(h).catch(c)}),initialData:{data:[],total:0}}),w=u.computed(()=>v.data.value.data),C=u.computed(()=>v.data.value.total);return{...v,data:w,total:C}};exports.useGetList=G;
//# sourceMappingURL=useGetList.js.map
