import { DestroyRef, Injector, Observable, ReplaySubject, RuntimeError, assertInInjectionContext, assertNotInReactiveContext, computed, effect, getOutputDestroyRef, inject, signal, takeUntil, untracked } from "./chunk-G3VQHART.js"; // node_modules/@angular/core/fesm2022/rxjs-interop.mjs function takeUntilDestroyed(destroyRef) { if (!destroyRef) { assertInInjectionContext(takeUntilDestroyed); destroyRef = inject(DestroyRef); } const destroyed$ = new Observable((observer) => { const unregisterFn = destroyRef.onDestroy(observer.next.bind(observer)); return unregisterFn; }); return (source) => { return source.pipe(takeUntil(destroyed$)); }; } function outputToObservable(ref) { const destroyRef = getOutputDestroyRef(ref); return new Observable((observer) => { destroyRef?.onDestroy(() => observer.complete()); const subscription = ref.subscribe((v) => observer.next(v)); return () => subscription.unsubscribe(); }); } function toObservable(source, options) { !options?.injector && assertInInjectionContext(toObservable); const injector = options?.injector ?? inject(Injector); const subject = new ReplaySubject(1); const watcher = effect(() => { let value; try { value = source(); } catch (err) { untracked(() => subject.error(err)); return; } untracked(() => subject.next(value)); }, { injector, manualCleanup: true }); injector.get(DestroyRef).onDestroy(() => { watcher.destroy(); subject.complete(); }); return subject.asObservable(); } function toSignal(source, options) { ngDevMode && assertNotInReactiveContext(toSignal, "Invoking `toSignal` causes new subscriptions every time. Consider moving `toSignal` outside of the reactive context and read the signal value where needed."); const requiresCleanup = !options?.manualCleanup; requiresCleanup && !options?.injector && assertInInjectionContext(toSignal); const cleanupRef = requiresCleanup ? options?.injector?.get(DestroyRef) ?? inject(DestroyRef) : null; const equal = makeToSignalEqual(options?.equal); let state; if (options?.requireSync) { state = signal({ kind: 0 /* StateKind.NoValue */ }, { equal }); } else { state = signal({ kind: 1, value: options?.initialValue }, { equal }); } const sub = source.subscribe({ next: (value) => state.set({ kind: 1, value }), error: (error) => { state.set({ kind: 2, error }); } // Completion of the Observable is meaningless to the signal. Signals don't have a concept of // "complete". }); if (options?.requireSync && state().kind === 0) { throw new RuntimeError(601, (typeof ngDevMode === "undefined" || ngDevMode) && "`toSignal()` called with `requireSync` but `Observable` did not emit synchronously."); } cleanupRef?.onDestroy(sub.unsubscribe.bind(sub)); return computed(() => { const current = state(); switch (current.kind) { case 1: return current.value; case 2: throw current.error; case 0: throw new RuntimeError(601, (typeof ngDevMode === "undefined" || ngDevMode) && "`toSignal()` called with `requireSync` but `Observable` did not emit synchronously."); } }, { equal: options?.equal }); } function makeToSignalEqual(userEquality = Object.is) { return (a, b) => a.kind === 1 && b.kind === 1 && userEquality(a.value, b.value); } export { takeUntilDestroyed, outputToObservable, toObservable, toSignal }; /*! Bundled license information: @angular/core/fesm2022/rxjs-interop.mjs: (** * @license Angular v0.0.0 * (c) 2010-2025 Google LLC. https://angular.io/ * License: MIT *) */ //# sourceMappingURL=chunk-CQN6KW2R.js.map