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