import{Eb as l,Ka as a,Sa as f,Ua as u,c as b,h as y,ia as h,jd as g,kd as d,ld as v,ma as p,va as c}from"./chunk-IYD54RT7.js";function m(r){r||(a(m),r=c(u));let e=new b(t=>r.onDestroy(t.next.bind(t)));return t=>t.pipe(h(e))}function w(r,e){!e?.injector&&a(w);let t=e?.injector??c(f),s=new y(1),o=v(()=>{let i;try{i=r()}catch(n){d(()=>s.error(n));return}d(()=>s.next(i))},{injector:t,manualCleanup:!0});return t.get(u).onDestroy(()=>{o.destroy(),s.complete()}),s.asObservable()}function j(r,e){let t=!e?.manualCleanup;t&&!e?.injector&&a(j);let s=t?e?.injector?.get(u)??c(u):null,o;e?.requireSync?o=l({kind:0}):o=l({kind:1,value:e?.initialValue});let i=r.subscribe({next:n=>o.set({kind:1,value:n}),error:n=>{if(e?.rejectErrors)throw n;o.set({kind:2,error:n})}});return s?.onDestroy(i.unsubscribe.bind(i)),g(()=>{let n=o();switch(n.kind){case 1:return n.value;case 2:throw n.error;case 0:throw new p(601,"`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.")}})}export{m as a,w as b,j as c};
