import{Tt as e}from"./vue-vendor-DMUmTARL.js";import{Ct as t,Dt as n,y as r}from"./index-y6crcKNt.js";function i(i,a,o,s={}){let c=r(),{cacheKey:l,successMessage:u=`保存成功`,afterLoad:d,ready:f}=s,p=e(null),{loading:m,refresh:h}=n(i,{cacheKey:l?`${l}:${t.zfileVersion}`:void 0,ready:f,onSuccess(e){p.value=d?d(e.data):e.data}}),{loading:g,runAsync:_}=n(async e=>a?a(e):Promise.resolve(),{manual:!0,onSuccess(){c.success(u)}});return{configData:p,configLoading:m,reloadConfig:h,saveData:async(e,t)=>{let n=t??p.value;return!n||o?.value&&!await new Promise(t=>{o.value?.validate((n,r)=>{if(n){t(!0);return}if(e===!0&&r)for(let e in r){let t=r[e].map(e=>e.message||``).join(`, `);t&&c.warning(t)}t(!1)})})?!1:(await _(n),!0)},saveLoading:g}}export{i as t};