import{a3 as S,a4 as w,r as g,L as M,k as b}from"./index-D92x6h1h.js";const O=100,d=new Map;function q(h,p,y){const c=`status:${h}`;let o=d.get(c);return o||(o=S(c,()=>{const s=g([]),a=g(!1),u=g(null);let l=0,m;function E(n,e){const t=new Map;for(const r of n)t.set(r[y],r);const i=[];for(const r of e){const T=r[y],f=t.get(T);f?(Object.assign(f,r),i.push(f)):i.push(r)}return i}async function v(n={}){const e=++l;n.silent||(a.value=!0),u.value=null;try{const t=await M(h);if(e!==l)return;s.value=E(s.value,t.entries??[])}catch(t){if(e!==l)return;u.value=t instanceof Error?t:new Error(String(t)),s.value=[]}finally{e===l&&!n.silent&&(a.value=!1)}}w.on(p,n=>{const e=n;!e.reload&&!e.updateEntry&&!e.update&&(e.create?.length??0)===0&&(e.change?.length??0)===0&&(e.delete?.length??0)===0||(clearTimeout(m),m=globalThis.setTimeout(()=>{v({silent:!0})},O))});const C=b(()=>!a.value&&s.value.length===0);return{entries:s,loading:a,error:u,isEmpty:C,fetch:v}}),d.set(c,o)),o()}export{q as u};
