import{Ha as u,Ia as y,ba as m,bb as h,cb as l,db as d,e as b,ea as v,j as g,lb as s,mb as w,na as a}from"./chunk-FWZCAEAJ.js";function f(r){r||(u(f),r=a(s));let e=new b(t=>r.onDestroy(t.next.bind(t)));return t=>t.pipe(m(e))}function j(r,e){!e?.injector&&u(j);let t=e?.injector??a(y),i=new g(1),o=w(()=>{let c;try{c=r()}catch(n){d(()=>i.error(n));return}d(()=>i.next(c))},{injector:t,manualCleanup:!0});return t.get(s).onDestroy(()=>{o.destroy(),i.complete()}),i.asObservable()}function S(r,e){let t=!e?.manualCleanup;t&&!e?.injector&&u(S);let i=t?e?.injector?.get(s)??a(s):null,o;e?.requireSync?o=l({kind:0}):o=l({kind:1,value:e?.initialValue});let c=r.subscribe({next:n=>o.set({kind:1,value:n}),error:n=>{if(e?.rejectErrors)throw n;o.set({kind:2,error:n})}});return i?.onDestroy(c.unsubscribe.bind(c)),h(()=>{let n=o();switch(n.kind){case 1:return n.value;case 2:throw n.error;case 0:throw new v(601,"`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.")}})}export{f as a,j as b,S as c};
