import{C as y,Kc as m,M as p,Nc as w,O as c,X as g,aa as i,g as v,ia as a,ta as l}from"./chunk-5ONOZUNN.js";import{a as b,b as f}from"./chunk-C6Q5SG76.js";function h(r,e){let t=!e?.manualCleanup;t&&!e?.injector&&i(h);let u=t?e?.injector?.get(a)??g(a):null,s=k(e?.equal),o;e?.requireSync?o=l({kind:0},{equal:s}):o=l({kind:1,value:e?.initialValue},{equal:s});let d=r.subscribe({next:n=>o.set({kind:1,value:n}),error:n=>{if(e?.rejectErrors)throw n;o.set({kind:2,error:n})}});if(e?.requireSync&&o().kind===0)throw new c(601,!1);return u?.onDestroy(d.unsubscribe.bind(d)),m(()=>{let n=o();switch(n.kind){case 1:return n.value;case 2:throw n.error;case 0:throw new c(601,!1)}},{equal:e?.equal})}function k(r=Object.is){return(e,t)=>e.kind===1&&t.kind===1&&r(e.value,t.value)}function x(r){return r?.injector||i(x),w(f(b({},r),{loader:e=>{let t=new v;return e.abortSignal.addEventListener("abort",()=>t.next()),new Promise((u,s)=>{r.loader(e).pipe(y(1),p(t)).subscribe({next:u,error:s,complete:()=>s(new Error("Resource completed before producing a value"))})})}}))}export{h as a,x as b};
