{"version":3,"file":"_resource-chunk.mjs","sources":["../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/authoring/output/output_emitter_ref.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/hydration/cache.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/render3/reactivity/computed.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/render3/reactivity/untracked.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/resource/api.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/render3/reactivity/linked_signal.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/resource/resource.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {setActiveConsumer} from '../../../primitives/signals';\n\nimport {inject} from '../../di/injector_compatibility';\nimport {ErrorHandler} from '../../error_handler';\nimport {formatRuntimeError, RuntimeError, RuntimeErrorCode} from '../../errors';\nimport {DestroyRef} from '../../linker/destroy_ref';\n\nimport {OutputRef, OutputRefSubscription} from './output_ref';\n\n/**\n * An `OutputEmitterRef` is created by the `output()` function and can be\n * used to emit values to consumers of your directive or component.\n *\n * Consumers of your directive/component can bind to the output and\n * subscribe to changes via the bound event syntax. For example:\n *\n * ```html\n * <my-comp (valueChange)=\"processNewValue($event)\" />\n * ```\n *\n * @see [Custom events with outputs](guide/components/outputs)\n *\n * @publicAPI\n */\nexport class OutputEmitterRef<T> implements OutputRef<T> {\n  private destroyed = false;\n  private listeners: Array<((value: T) => void) | null> | null = null;\n  private errorHandler = inject(ErrorHandler, {optional: true});\n  private isEmitting = false;\n  private hasNullListeners = false;\n\n  /** @internal */\n  destroyRef: DestroyRef = inject(DestroyRef);\n\n  constructor() {\n    // Clean-up all listeners and mark as destroyed upon destroy.\n    this.destroyRef.onDestroy(() => {\n      this.destroyed = true;\n      this.listeners = null;\n    });\n  }\n\n  subscribe(callback: (value: T) => void): OutputRefSubscription {\n    if (this.destroyed) {\n      throw new RuntimeError(\n        RuntimeErrorCode.OUTPUT_REF_DESTROYED,\n        ngDevMode &&\n          'Unexpected subscription to destroyed `OutputRef`. ' +\n            'The owning directive/component is destroyed.',\n      );\n    }\n\n    (this.listeners ??= []).push(callback);\n\n    return {\n      unsubscribe: () => {\n        const index = this.listeners ? this.listeners.indexOf(callback) : -1;\n        if (index > -1) {\n          // If we try to unsubscribe while an `emit` is happening, we can throw off the loop.\n          // Replace the listener with null so we can clean it up later. Note that it would be\n          // simpler to clone the array when iterating over it, but we're trying to avoid cloning\n          // since unsubscribing from within the event should be fairly uncommon.\n          if (this.isEmitting) {\n            this.hasNullListeners = true;\n            this.listeners![index] = null;\n          } else {\n            this.listeners!.splice(index, 1);\n          }\n        }\n      },\n    };\n  }\n\n  /** Emits a new value to the output. */\n  emit(value: T): void {\n    if (this.destroyed) {\n      console.warn(\n        formatRuntimeError(\n          RuntimeErrorCode.OUTPUT_REF_DESTROYED,\n          ngDevMode &&\n            'Unexpected emit for destroyed `OutputRef`. ' +\n              'The owning directive/component is destroyed.',\n        ),\n      );\n      return;\n    }\n\n    if (this.listeners === null) {\n      return;\n    }\n\n    this.isEmitting = true;\n    const previousConsumer = setActiveConsumer(null);\n    try {\n      for (const listenerFn of this.listeners) {\n        try {\n          if (listenerFn !== null) {\n            listenerFn(value);\n          }\n        } catch (err: unknown) {\n          this.errorHandler?.handleError(err);\n        }\n      }\n    } finally {\n      if (this.hasNullListeners) {\n        this.hasNullListeners = false;\n        this.listeners && removeNullValues(this.listeners);\n      }\n      setActiveConsumer(previousConsumer);\n      this.isEmitting = false;\n    }\n  }\n}\n\nfunction removeNullValues(arr: unknown[]): void {\n  let i = arr.length - 1;\n\n  while (i > -1) {\n    if (arr[i] === null) {\n      arr.splice(i, 1);\n    }\n    i--;\n  }\n}\n\n/** Gets the owning `DestroyRef` for the given output. */\nexport function getOutputDestroyRef(ref: OutputRef<unknown>): DestroyRef | undefined {\n  return ref.destroyRef;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {InjectionToken} from '../di';\n\n/**\n * Token used to the determine if the transfer cache should be used, for example for resources.\n */\nexport const CACHE_ACTIVE = new InjectionToken<{isActive: boolean}>(\n  typeof ngDevMode !== 'undefined' && ngDevMode ? 'STATE_CACHE_ACTIVE' : '',\n);\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {createComputed, SIGNAL} from '../../../primitives/signals';\n\nimport {Signal, ValueEqualityFn} from './api';\n\n/**\n * Options passed to the `computed` creation function.\n */\nexport interface CreateComputedOptions<T> {\n  /**\n   * A comparison function which defines equality for computed values.\n   */\n  equal?: ValueEqualityFn<T>;\n\n  /**\n   * A debug name for the computed signal. Used in Angular DevTools to identify the signal.\n   */\n  debugName?: string;\n}\n\n/**\n * Create a computed `Signal` which derives a reactive value from an expression.\n * @see [Computed signals](guide/signals#computed-signals)\n */\nexport function computed<T>(computation: () => T, options?: CreateComputedOptions<T>): Signal<T> {\n  const getter = createComputed(computation, options?.equal);\n\n  if (typeof ngDevMode !== 'undefined' && ngDevMode) {\n    const debugName = options?.debugName;\n    getter[SIGNAL].debugName = debugName;\n    getter.toString = () => `[Computed${debugName ? ' (' + debugName + ')' : ''}: ${getter()}]`;\n  }\n\n  return getter;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {untracked as untrackedPrimitive} from '../../../primitives/signals';\n\n/**\n * Execute an arbitrary function in a non-reactive (non-tracking) context. The executed function\n * can, optionally, return a value.\n * @see [Reading without tracking dependencies](guide/signals#reading-without-tracking-dependencies)\n */\nexport function untracked<T>(nonReactiveReadsFn: () => T): T {\n  return untrackedPrimitive(nonReactiveReadsFn);\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Injector} from '../di/injector';\nimport {Signal, ValueEqualityFn} from '../render3/reactivity/api';\nimport {WritableSignal} from '../render3/reactivity/signal';\n\n/** Error thrown when a `Resource` dependency of another resource errors. */\nexport class ResourceDependencyError extends Error {\n  /** The dependency that errored. */\n  readonly dependency: Resource<unknown>;\n\n  constructor(dependency: Resource<unknown>) {\n    super('Dependency error', {cause: dependency.error()});\n    this.name = 'ResourceDependencyError';\n    this.dependency = dependency;\n  }\n}\n\n/**\n * Special status codes that can be thrown from a resource's `params` or `request` function to\n * indicate that the resource should transition to that status.\n */\nexport class ResourceParamsStatus extends Error {\n  private readonly _brand: undefined;\n  private constructor(msg: string) {\n    super(msg);\n  }\n\n  /** Status code that transitions the resource to `idle` status. */\n  static readonly IDLE = new ResourceParamsStatus('IDLE');\n\n  /** Status code that transitions the resource to `loading` status. */\n  static readonly LOADING = new ResourceParamsStatus('LOADING');\n}\n\n/**\n * Context received by a resource's `params` or `request` function.\n *\n * @see [Chaining resources](guide/signals/resource#chaining-resources)\n */\nexport interface ResourceParamsContext {\n  /**\n   * Chains the current params off of the value of another resource, returning the value\n   * of the other resource only when its status is `resolved` or `local`, or propagating status to\n   * the current resource by throwing the appropriate status code when the value is not available.\n   */\n  readonly chain: <T>(resource: Resource<T>) => T;\n}\n\n/**\n * String value capturing the status of a `Resource`.\n *\n * Possible statuses are:\n *\n * `idle` - The resource has no valid request and will not perform any loading. `value()` will be\n * `undefined`.\n *\n * `loading` - The resource is currently loading a new value as a result of a change in its reactive\n * dependencies. `value()` will be `undefined`.\n *\n * `reloading` - The resource is currently reloading a fresh value for the same reactive\n * dependencies. `value()` will continue to return the previously fetched value during the reloading\n * operation.\n *\n * `error` - Loading failed with an error. `value()` will be `undefined`.\n *\n * `resolved` - Loading has completed and the resource has the value returned from the loader.\n *\n * `local` - The resource's value was set locally via `.set()` or `.update()`.\n *\n * @publicApi 22.0\n */\nexport type ResourceStatus = 'idle' | 'error' | 'loading' | 'reloading' | 'resolved' | 'local';\n\n/**\n * A Resource is an asynchronous dependency (for example, the results of an API call) that is\n * managed and delivered through signals.\n *\n * The usual way of creating a `Resource` is through the `resource` function, but various other APIs\n * may present `Resource` instances to describe their own concepts.\n *\n * @publicApi 22.0\n */\nexport interface Resource<T> {\n  /**\n   * The current value of the `Resource`, or throws an error if the resource is in an error state.\n   */\n  readonly value: Signal<T>;\n\n  /**\n   * The current status of the `Resource`, which describes what the resource is currently doing and\n   * what can be expected of its `value`.\n   */\n  readonly status: Signal<ResourceStatus>;\n\n  /**\n   * When in the `error` state, this returns the last known error from the `Resource`.\n   */\n  readonly error: Signal<Error | undefined>;\n\n  /**\n   * Whether this resource is loading a new value (or reloading the existing one).\n   */\n  readonly isLoading: Signal<boolean>;\n\n  /**\n   * The current state of this resource, represented as a `ResourceSnapshot`.\n   */\n  readonly snapshot: Signal<ResourceSnapshot<T>>;\n\n  /**\n   * Whether this resource has a valid current value.\n   *\n   * This function is reactive.\n   */\n  hasValue(this: T extends undefined ? this : never): this is Resource<Exclude<T, undefined>>;\n\n  hasValue(): boolean;\n}\n\n/**\n * A `Resource` with a mutable value.\n *\n * Overwriting the value of a resource sets it to the 'local' state.\n *\n * @publicApi 22.0\n */\nexport interface WritableResource<T> extends Resource<T> {\n  readonly value: WritableSignal<T>;\n  hasValue(\n    this: T extends undefined ? this : never,\n  ): this is WritableResource<Exclude<T, undefined>>;\n\n  hasValue(): boolean;\n\n  /**\n   * Convenience wrapper for `value.set`.\n   */\n  set(value: T): void;\n\n  /**\n   * Convenience wrapper for `value.update`.\n   */\n  update(updater: (value: T) => T): void;\n  asReadonly(): Resource<T>;\n\n  /**\n   * Instructs the resource to re-load any asynchronous dependency it may have.\n   *\n   * Note that the resource will not enter its reloading state until the actual backend request is\n   * made.\n   *\n   * @returns true if a reload was initiated, false if a reload was unnecessary or unsupported\n   */\n  reload(): boolean;\n}\n\n/**\n * A `WritableResource` created through the `resource` function.\n *\n * @publicApi 22.0\n */\nexport interface ResourceRef<T> extends WritableResource<T> {\n  hasValue(this: T extends undefined ? this : never): this is ResourceRef<Exclude<T, undefined>>;\n\n  hasValue(): boolean;\n  /**\n   * Manually destroy the resource, which cancels pending requests and returns it to `idle` state.\n   */\n  destroy(): void;\n}\n\n/**\n * Parameter to a `ResourceLoader` which gives the request and other options for the current loading\n * operation.\n *\n * @publicApi 22.0\n */\nexport interface ResourceLoaderParams<R> {\n  params: NoInfer<Exclude<R, undefined>>;\n  abortSignal: AbortSignal;\n  previous: {\n    status: ResourceStatus;\n  };\n}\n\n/**\n * Loading function for a `Resource`.\n *\n * @publicApi 22.0\n */\nexport type ResourceLoader<T, R> = (param: ResourceLoaderParams<R>) => PromiseLike<T>;\n\n/**\n * Streaming loader for a `Resource`.\n *\n * @publicApi 22.0\n */\nexport type ResourceStreamingLoader<T, R> = (\n  param: ResourceLoaderParams<R>,\n) => Signal<ResourceStreamItem<T>> | PromiseLike<Signal<ResourceStreamItem<T>>> | undefined;\n\n/**\n * Options to the `resource` function, for creating a resource.\n *\n * @publicApi 22.0\n */\nexport interface BaseResourceOptions<T, R> {\n  /**\n   * A reactive function which determines the request to be made. Whenever the request changes, the\n   * loader will be triggered to fetch a new value for the resource.\n   *\n   * If a params function isn't provided, the loader won't rerun unless the resource is reloaded.\n   */\n  params?: (ctx: ResourceParamsContext) => R;\n\n  /**\n   * The value which will be returned from the resource when a server value is unavailable, such as\n   * when the resource is still loading.\n   */\n  defaultValue?: NoInfer<T>;\n\n  /**\n   * Equality function used to compare the return value of the loader.\n   */\n  equal?: ValueEqualityFn<T>;\n\n  /**\n   * Overrides the `Injector` used by `resource`.\n   */\n  injector?: Injector;\n\n  /**\n   * Identifier used to cache the resource data in the `TransferState` during server-side rendering and to retrieve it on the client side.\n   * This value value needs to be identical for both the client and server.\n   */\n  id?: string;\n}\n\n/**\n * Options to the `resource` function, for creating a resource.\n *\n * @publicApi 22.0\n */\nexport interface PromiseResourceOptions<T, R> extends BaseResourceOptions<T, R> {\n  /**\n   * Loading function which returns a `Promise` of the resource's value for a given request.\n   */\n  loader: ResourceLoader<T, R>;\n\n  /**\n   * Cannot specify `stream` and `loader` at the same time.\n   */\n  stream?: never;\n}\n\n/**\n * Options to the `resource` function, for creating a resource.\n *\n * @publicApi 22.0\n */\nexport interface StreamingResourceOptions<T, R> extends BaseResourceOptions<T, R> {\n  /**\n   * Loading function which returns a `Promise` of a signal of the resource's value for a given\n   * request, which can change over time as new values are received from a stream.\n   */\n  stream: ResourceStreamingLoader<T, R>;\n\n  /**\n   * Cannot specify `stream` and `loader` at the same time.\n   */\n  loader?: never;\n}\n\n/**\n * @publicApi 22.0\n */\nexport type ResourceOptions<T, R> = (\n  | PromiseResourceOptions<T, R>\n  | StreamingResourceOptions<T, R>\n) & {\n  /**\n   * A debug name for the reactive node. Used in Angular DevTools to identify the node.\n   */\n  debugName?: string;\n};\n\n/**\n * @publicApi 22.0\n */\nexport type ResourceStreamItem<T> = {value: T} | {error: Error};\n\n/**\n * An explicit representation of a resource's state.\n *\n * @publicApi 22.0\n * @see [Resource composition with snapshots](guide/signals/resource#resource-composition-with-snapshots)\n */\nexport type ResourceSnapshot<T> =\n  | {readonly status: 'idle'; readonly value: T}\n  | {readonly status: 'loading' | 'reloading'; readonly value: T}\n  | {readonly status: 'resolved' | 'local'; readonly value: T}\n  | {readonly status: 'error'; readonly error: Error};\n\n/**\n * Options for `debounced`.\n *\n * @see [Debouncing signals with `debounced`](guide/signals/debounced)\n *\n * @experimental 22.0\n */\nexport interface DebouncedOptions<T> {\n  /** The `Injector` to use for the debounced resource. */\n  injector?: Injector;\n  /** The equality function to use for comparing values. */\n  equal?: ValueEqualityFn<T>;\n}\n\n/**\n * Represents the wait condition for item debouncing.\n * Can be a number of milliseconds or a function that returns a Promise.\n *\n * @see [Debouncing signals with `debounced`](guide/signals/debounced)\n *\n * @experimental 22.0\n */\nexport type DebounceTimer<T> =\n  | number\n  | ((value: T, lastValue: ResourceSnapshot<T>) => Promise<void> | void);\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n  ComputationFn,\n  createLinkedSignal,\n  LinkedSignalGetter,\n  LinkedSignalNode,\n  linkedSignalSetFn,\n  linkedSignalUpdateFn,\n  SIGNAL,\n} from '../../../primitives/signals';\nimport {Signal, ValueEqualityFn} from './api';\nimport {signalAsReadonlyFn, WritableSignal} from './signal';\nimport {untracked} from './untracked';\n\nconst identityFn = <T>(v: T) => v;\n\n/**\n * Creates a writable signal whose value is initialized and reset by the linked, reactive computation.\n *\n * @publicApi 20.0\n */\nexport function linkedSignal<D>(\n  computation: () => D,\n  options?: {\n    equal?: ValueEqualityFn<NoInfer<D>>;\n    debugName?: string;\n    set?: (value: NoInfer<D>, rawSet: (value: NoInfer<D>) => void) => void;\n  },\n): WritableSignal<D>;\n\n/**\n * Creates a writable signal whose value is initialized and reset by the linked, reactive computation.\n * This is an advanced API form where the computation has access to the previous value of the signal and the computation result.\n *\n * Note: The computation is reactive, meaning the linked signal will automatically update whenever any of the signals used within the computation change.\n *\n * @publicApi 20.0\n * @see [Dependent state with linkedSignal](guide/signals/linked-signal)\n */\nexport function linkedSignal<S, D>(options: {\n  source: () => S;\n  computation: (source: NoInfer<S>, previous?: {source: NoInfer<S>; value: NoInfer<D>}) => D;\n  equal?: ValueEqualityFn<NoInfer<D>>;\n  debugName?: string;\n  set?: (value: NoInfer<D>, rawSet: (value: NoInfer<D>) => void) => void;\n}): WritableSignal<D>;\n\nexport function linkedSignal<S, D>(\n  optionsOrComputation:\n    | {\n        source: () => S;\n        computation: ComputationFn<S, D>;\n        equal?: ValueEqualityFn<D>;\n        debugName?: string;\n        set?: (value: D, rawSet: (value: D) => void) => void;\n      }\n    | (() => D),\n  options?: {\n    equal?: ValueEqualityFn<D>;\n    debugName?: string;\n    set?: (value: D, rawSet: (value: D) => void) => void;\n  },\n): WritableSignal<D> {\n  if (typeof optionsOrComputation === 'function') {\n    const getter = createLinkedSignal<D, D>(\n      optionsOrComputation,\n      identityFn<D>,\n      options?.equal,\n    ) as LinkedSignalGetter<D, D> & WritableSignal<D>;\n    return upgradeLinkedSignalGetter(getter, options?.debugName, options?.set);\n  } else {\n    const getter = createLinkedSignal<S, D>(\n      optionsOrComputation.source,\n      optionsOrComputation.computation,\n      optionsOrComputation.equal,\n    );\n    return upgradeLinkedSignalGetter(\n      getter,\n      optionsOrComputation.debugName,\n      optionsOrComputation.set,\n    );\n  }\n}\n\nfunction upgradeLinkedSignalGetter<S, D>(\n  getter: LinkedSignalGetter<S, D>,\n  debugName?: string,\n  customSet?: (value: D, rawSet: (value: D) => void) => void,\n): WritableSignal<D> {\n  if (typeof ngDevMode !== 'undefined' && ngDevMode) {\n    getter[SIGNAL].debugName = debugName;\n    getter.toString = () => `[LinkedSignal${debugName ? ' (' + debugName + ')' : ''}: ${getter()}]`;\n  }\n\n  const node = getter[SIGNAL] as LinkedSignalNode<S, D>;\n  const upgradedGetter = getter as LinkedSignalGetter<S, D> & WritableSignal<D>;\n\n  if (customSet !== undefined) {\n    const rawSet = (newValue: D) => linkedSignalSetFn(node, newValue);\n    upgradedGetter.set = (newValue: D) => customSet(newValue, rawSet);\n    upgradedGetter.update = (updateFn: (value: D) => D) =>\n      customSet(updateFn(untracked(getter)), rawSet);\n  } else {\n    upgradedGetter.set = (newValue: D) => linkedSignalSetFn(node, newValue);\n    upgradedGetter.update = (updateFn: (value: D) => D) => linkedSignalUpdateFn(node, updateFn);\n  }\n  upgradedGetter.asReadonly = signalAsReadonlyFn.bind(getter as any) as () => Signal<D>;\n\n  return upgradedGetter;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {isSignal, Signal, ValueEqualityFn} from '../render3/reactivity/api';\nimport {computed} from '../render3/reactivity/computed';\nimport {effect, EffectRef} from '../render3/reactivity/effect';\nimport {signal, signalAsReadonlyFn, WritableSignal} from '../render3/reactivity/signal';\nimport {untracked} from '../render3/reactivity/untracked';\nimport {\n  Resource,\n  ResourceDependencyError,\n  ResourceOptions,\n  ResourceParamsStatus,\n  ResourceSnapshot,\n  ResourceStatus,\n  ResourceStreamingLoader,\n  ResourceStreamItem,\n  StreamingResourceOptions,\n  type ResourceParamsContext,\n  type ResourceRef,\n  type WritableResource,\n} from './api';\n\nimport {assertInInjectionContext} from '../di/contextual';\nimport {Injector} from '../di/injector';\nimport {inject} from '../di/injector_compatibility';\nimport {RuntimeError, RuntimeErrorCode} from '../errors';\nimport {CACHE_ACTIVE} from '../hydration/cache';\nimport {DestroyRef} from '../linker/destroy_ref';\nimport {PendingTasks} from '../pending_tasks';\nimport {linkedSignal} from '../render3/reactivity/linked_signal';\nimport {StateKey, TransferState} from '../transfer_state';\n\n/**\n * Constructs a `Resource` that projects a reactive request to an asynchronous operation defined by\n * a loader function, which exposes the result of the loading operation via signals.\n *\n * Note that `resource` is intended for _read_ operations, not operations which perform mutations.\n * `resource` will cancel in-progress loads via the `AbortSignal` when destroyed or when a new\n * request object becomes available, which could prematurely abort mutations.\n *\n * @see [Async reactivity with resources](guide/signals/resource)\n *\n * @publicApi 22.0\n */\nexport function resource<T, R>(\n  options: ResourceOptions<T, R> & {defaultValue: NoInfer<T>},\n): ResourceRef<T>;\n\n/**\n * Constructs a `Resource` that projects a reactive request to an asynchronous operation defined by\n * a loader function, which exposes the result of the loading operation via signals.\n *\n * Note that `resource` is intended for _read_ operations, not operations which perform mutations.\n * `resource` will cancel in-progress loads via the `AbortSignal` when destroyed or when a new\n * request object becomes available, which could prematurely abort mutations.\n *\n * @publicApi 22.0\n * @see [Async reactivity with resources](guide/signals/resource)\n */\nexport function resource<T, R>(options: ResourceOptions<T, R>): ResourceRef<T | undefined>;\nexport function resource<T, R>(options: ResourceOptions<T, R>): ResourceRef<T | undefined> {\n  if (ngDevMode && !options?.injector) {\n    assertInInjectionContext(resource);\n  }\n\n  const oldNameForParams = (\n    options as ResourceOptions<T, R> & {request: ResourceOptions<T, R>['params']}\n  ).request;\n  const params = options.params ?? oldNameForParams ?? (() => null!);\n  return new ResourceImpl<T | undefined, R>(\n    params,\n    getLoader(options),\n    options.defaultValue,\n    options.equal ? wrapEqualityFn(options.equal) : undefined,\n    options.debugName,\n    options.injector ?? inject(Injector),\n    options.id as StateKey<T>,\n  );\n}\n\ntype ResourceInternalStatus = 'idle' | 'loading' | 'resolved' | 'local';\n\n/**\n * Internal state of a resource.\n */\ninterface ResourceProtoState<T> {\n  extRequest: WrappedRequest;\n\n  // For simplicity, status is internally tracked as a subset of the public status enum.\n  // Reloading and Error statuses are projected from Loading and Resolved based on other state.\n  status: ResourceInternalStatus;\n}\n\ninterface ResourceState<T> extends ResourceProtoState<T> {\n  previousStatus: ResourceStatus;\n  stream: Signal<ResourceStreamItem<T>> | undefined;\n}\n\ntype WrappedRequest = {\n  request?: unknown;\n  reload: number;\n  status?: ResourceInternalStatus;\n  error?: Error;\n};\n\n/**\n * Base class which implements `.value` as a `WritableSignal` by delegating `.set` and `.update`.\n */\nabstract class BaseWritableResource<T> implements WritableResource<T> {\n  readonly value: WritableSignal<T>;\n  abstract readonly status: Signal<ResourceStatus>;\n  abstract readonly error: Signal<Error | undefined>;\n\n  abstract reload(): boolean;\n\n  readonly isLoading: Signal<boolean>;\n\n  constructor(value: Signal<T>, debugName: string | undefined) {\n    this.value = value as WritableSignal<T>;\n    this.value.set = this.set.bind(this);\n    this.value.update = this.update.bind(this);\n    this.value.asReadonly = signalAsReadonlyFn;\n\n    this.isLoading = computed(\n      () => this.status() === 'loading' || this.status() === 'reloading',\n      ngDevMode ? createDebugNameObject(debugName, 'isLoading') : undefined,\n    );\n  }\n\n  abstract set(value: T): void;\n\n  private readonly isError = computed(() => this.status() === 'error');\n\n  update(updateFn: (value: T) => T): void {\n    this.set(updateFn(untracked(this.value)));\n  }\n\n  // Use a computed here to avoid triggering reactive consumers if the value changes while staying\n  // either defined or undefined.\n  private readonly isValueDefined = computed(() => {\n    // Check if it's in an error state first to prevent the error from bubbling up.\n    if (this.isError()) {\n      return false;\n    }\n\n    return this.value() !== undefined;\n  });\n\n  private _snapshot: Signal<ResourceSnapshot<T>> | undefined;\n  get snapshot(): Signal<ResourceSnapshot<T>> {\n    return (this._snapshot ??= computed(() => {\n      const status = this.status();\n      if (status === 'error') {\n        return {status: 'error', error: this.error()!};\n      } else {\n        return {status, value: this.value()};\n      }\n    }));\n  }\n\n  hasValue(): this is ResourceRef<Exclude<T, undefined>> {\n    return this.isValueDefined();\n  }\n\n  asReadonly(): Resource<T> {\n    return this;\n  }\n}\n\n/**\n * Implementation for `resource()` which uses a `linkedSignal` to manage the resource's state.\n */\nexport class ResourceImpl<T, R> extends BaseWritableResource<T> implements ResourceRef<T> {\n  private readonly pendingTasks: PendingTasks;\n\n  /**\n   * The current state of the resource. Status, value, and error are derived from this.\n   */\n  private readonly state: WritableSignal<ResourceState<T>>;\n\n  /**\n   * Combines the current request with a reload counter which allows the resource to be reloaded on\n   * imperative command.\n   */\n  protected readonly extRequest: WritableSignal<WrappedRequest>;\n  private readonly effectRef: EffectRef;\n\n  private pendingController: AbortController | undefined;\n  private resolvePendingTask: (() => void) | undefined = undefined;\n  private destroyed = false;\n  private unregisterOnDestroy: () => void;\n\n  override readonly status: Signal<ResourceStatus>;\n  override readonly error: Signal<Error | undefined>;\n  private readonly transferState: TransferState | undefined;\n\n  constructor(\n    request: (ctx: ResourceParamsContext) => R,\n    private readonly loaderFn: ResourceStreamingLoader<T, R>,\n    defaultValue: T,\n    private readonly equal: ValueEqualityFn<T> | undefined,\n    private readonly debugName: string | undefined,\n    injector: Injector,\n    private transferCacheKey: StateKey<T> | undefined,\n    getInitialStream?: (request: R) => Signal<ResourceStreamItem<T>> | undefined,\n  ) {\n    if (isInParamsFunction()) {\n      throw invalidResourceCreationInParams();\n    }\n\n    super(\n      // Feed a computed signal for the value to `BaseWritableResource`, which will upgrade it to a\n      // `WritableSignal` that delegates to `ResourceImpl.set`.\n      computed(\n        () => {\n          const streamValue = this.state().stream?.();\n\n          if (!streamValue) {\n            return defaultValue;\n          }\n\n          // Prevents `hasValue()` from throwing an error when a reload happened in the error state\n          if (this.state().status === 'loading' && this.error()) {\n            return defaultValue;\n          }\n\n          if (!isResolved(streamValue)) {\n            throw new ResourceValueError(this.error()!);\n          }\n\n          return streamValue.value;\n        },\n        {equal, ...(ngDevMode ? createDebugNameObject(debugName, 'value') : undefined)},\n      ),\n      debugName,\n    );\n\n    const cacheState = injector.get(CACHE_ACTIVE, undefined, {optional: true}) ?? {isActive: false};\n\n    this.transferState = injector.get(TransferState, undefined, {optional: true}) ?? undefined;\n\n    this.extRequest = linkedSignal<WrappedRequest>(\n      () => {\n        try {\n          setInParamsFunction(true);\n          return {request: request(paramsContext), reload: 0};\n        } catch (error) {\n          rethrowFatalErrors(error);\n          if (error === ResourceParamsStatus.IDLE) {\n            return {status: 'idle', reload: 0};\n          } else if (error === ResourceParamsStatus.LOADING) {\n            return {status: 'loading', reload: 0};\n          }\n          return {error: error as Error, reload: 0};\n        } finally {\n          setInParamsFunction(false);\n        }\n      },\n      ngDevMode ? createDebugNameObject(debugName, 'extRequest') : undefined,\n    );\n\n    // The main resource state is managed in a `linkedSignal`, which allows the resource to change\n    // state instantaneously when the request signal changes.\n    this.state = linkedSignal<WrappedRequest, ResourceState<T>>({\n      // Whenever the request changes,\n      source: this.extRequest,\n      // Compute the state of the resource given a change in status.\n      computation: (extRequest, previous) => {\n        let {request, status, error} = extRequest;\n        let stream: Signal<ResourceStreamItem<T>> | undefined;\n\n        if (error) {\n          status = 'resolved';\n          stream = signal(\n            {error: encapsulateResourceError(error)},\n            ngDevMode ? createDebugNameObject(this.debugName, 'stream') : undefined,\n          );\n        } else if (!status) {\n          if (!previous) {\n            const transferState = this.transferState;\n            const cacheKey = this.transferCacheKey;\n            if (cacheState.isActive && cacheKey && transferState && request !== undefined) {\n              const key = this.transferCacheKey;\n              if (transferState.hasKey(cacheKey)) {\n                stream = signal(\n                  {value: transferState.get(cacheKey, defaultValue)},\n                  ngDevMode ? createDebugNameObject(this.debugName, 'stream') : undefined,\n                );\n              }\n            }\n\n            if (!stream) {\n              stream = getInitialStream?.(extRequest.request as R);\n            }\n            // Clear getInitialStream so it doesn't hold onto memory\n            getInitialStream = undefined;\n            status = request === undefined ? 'idle' : stream ? 'resolved' : 'loading';\n          } else {\n            status = request === undefined ? 'idle' : 'loading';\n            if (previous.value.extRequest.request === request) {\n              stream = previous.value.stream;\n            }\n          }\n        }\n\n        return {\n          extRequest,\n          status,\n          previousStatus: previous ? projectStatusOfState(previous.value) : 'idle',\n          stream,\n        };\n      },\n      ...(ngDevMode ? createDebugNameObject(debugName, 'state') : undefined),\n    });\n\n    this.effectRef = effect(this.loadEffect.bind(this), {\n      injector,\n      manualCleanup: true,\n      ...(ngDevMode ? createDebugNameObject(debugName, 'loadEffect') : undefined),\n    });\n\n    this.pendingTasks = injector.get(PendingTasks);\n\n    // Cancel any pending request when the resource itself is destroyed.\n    this.unregisterOnDestroy = injector.get(DestroyRef).onDestroy(() => this.destroy());\n\n    this.status = computed(\n      () => projectStatusOfState(this.state()),\n      ngDevMode ? createDebugNameObject(debugName, 'status') : undefined,\n    );\n\n    this.error = computed(\n      () => {\n        const stream = this.state().stream?.();\n        return stream && !isResolved(stream) ? stream.error : undefined;\n      },\n      ngDevMode ? createDebugNameObject(debugName, 'error') : undefined,\n    );\n  }\n\n  /**\n   * Called either directly via `WritableResource.set` or via `.value.set()`.\n   */\n  override set(value: T): void {\n    if (this.destroyed) {\n      return;\n    }\n\n    const error = untracked(this.error);\n    const state = untracked(this.state);\n\n    if (!error) {\n      const current = untracked(this.value);\n      if (\n        state.status === 'local' &&\n        (this.equal ? this.equal(current, value) : current === value)\n      ) {\n        return;\n      }\n    }\n\n    // Enter Local state with the user-defined value.\n    this.state.set({\n      extRequest: state.extRequest,\n      status: 'local',\n      previousStatus: 'local',\n      stream: signal(\n        {value},\n        ngDevMode ? createDebugNameObject(this.debugName, 'stream') : undefined,\n      ),\n    });\n\n    // We're departing from whatever state the resource was in previously, so cancel any in-progress\n    // loading operations.\n    this.abortInProgressLoad();\n  }\n\n  override reload(): boolean {\n    // We don't want to restart in-progress loads.\n    const {status} = untracked(this.state);\n    if (status === 'idle' || status === 'loading') {\n      return false;\n    }\n\n    // Increment the request reload to trigger the `state` linked signal to switch us to `Reload`\n    this.extRequest.update(({request, reload}) => ({request, reload: reload + 1}));\n    return true;\n  }\n\n  destroy(): void {\n    this.destroyed = true;\n    this.unregisterOnDestroy();\n    this.effectRef.destroy();\n    this.abortInProgressLoad();\n\n    // Destroyed resources enter Idle state.\n    this.state.set({\n      extRequest: {request: undefined, reload: 0},\n      status: 'idle',\n      previousStatus: 'idle',\n      stream: undefined,\n    });\n  }\n\n  private async loadEffect(): Promise<void> {\n    const extRequest = this.extRequest();\n\n    // Capture the previous status before any state transitions. Note that this is `untracked` since\n    // we do not want the effect to depend on the state of the resource, only on the request.\n    const {status: currentStatus, previousStatus} = untracked(this.state);\n\n    if (extRequest.request === undefined) {\n      // Nothing to load (and we should already be in a non-loading state).\n      return;\n    } else if (currentStatus !== 'loading') {\n      // We're not in a loading or reloading state, so this loading request is stale.\n      return;\n    }\n\n    // Cancel any previous loading attempts.\n    this.abortInProgressLoad();\n\n    // Capturing _this_ load's pending task in a local variable is important here. We may attempt to\n    // resolve it twice:\n    //\n    //  1. when the loading function promise resolves/rejects\n    //  2. when cancelling the loading operation\n    //\n    // After the loading operation is cancelled, `this.resolvePendingTask` no longer represents this\n    // particular task, but this `await` may eventually resolve/reject. Thus, when we cancel in\n    // response to (1) below, we need to cancel the locally saved task.\n    let resolvePendingTask: (() => void) | undefined = (this.resolvePendingTask =\n      this.pendingTasks.add());\n\n    const {signal: abortSignal} = (this.pendingController = new AbortController());\n\n    try {\n      // The actual loading is run through `untracked` - only the request side of `resource` is\n      // reactive. This avoids any confusion with signals tracking or not tracking depending on\n      // which side of the `await` they are.\n      const stream = untracked(() => {\n        return this.loaderFn({\n          params: extRequest.request as Exclude<R, undefined>,\n          abortSignal,\n          previous: {\n            status: previousStatus,\n          },\n        });\n      });\n\n      // If this request has been aborted, or the current request no longer\n      // matches this load, then we should ignore this resolution.\n      const shouldDiscard = () => abortSignal.aborted || untracked(this.extRequest) !== extRequest;\n\n      if (isSignal(stream)) {\n        if (shouldDiscard()) {\n          return;\n        }\n\n        this.state.set({\n          extRequest,\n          status: 'resolved',\n          previousStatus: 'resolved',\n          stream,\n        });\n\n        const result = untracked(stream);\n        if (typeof ngServerMode !== 'undefined' && ngServerMode) {\n          saveToTransferState(result, this.transferCacheKey, this.transferState);\n        }\n      } else {\n        const resolvedStream = await stream;\n        if (shouldDiscard()) {\n          return;\n        }\n\n        this.state.set({\n          extRequest,\n          status: 'resolved',\n          previousStatus: 'resolved',\n          stream: resolvedStream,\n        });\n\n        // Use a local variable for the result so TypeScript can narrow `resolvedStream` correctly.\n        const result = resolvedStream ? untracked(resolvedStream) : undefined;\n        if (typeof ngServerMode !== 'undefined' && ngServerMode) {\n          saveToTransferState(result, this.transferCacheKey, this.transferState);\n        }\n      }\n    } catch (err) {\n      rethrowFatalErrors(err);\n      if (abortSignal.aborted || untracked(this.extRequest) !== extRequest) {\n        return;\n      }\n\n      this.state.set({\n        extRequest,\n        status: 'resolved',\n        previousStatus: 'error',\n        stream: signal(\n          {error: encapsulateResourceError(err)},\n          ngDevMode ? createDebugNameObject(this.debugName, 'stream') : undefined,\n        ),\n      });\n    } finally {\n      // Resolve the pending task now that the resource has a value.\n      resolvePendingTask?.();\n      resolvePendingTask = undefined;\n    }\n  }\n\n  private abortInProgressLoad(): void {\n    untracked(() => this.pendingController?.abort());\n    this.pendingController = undefined;\n\n    // Once the load is aborted, we no longer want to block stability on its resolution.\n    this.resolvePendingTask?.();\n    this.resolvePendingTask = undefined;\n  }\n}\n\nfunction saveToTransferState<R, T>(\n  result: ResourceStreamItem<T> | undefined,\n  transferCacheKey: StateKey<T> | undefined,\n  transferState: TransferState | undefined,\n): void {\n  if (transferCacheKey && transferState && result && isResolved(result)) {\n    transferState.set(transferCacheKey, result.value);\n  }\n}\n\n/**\n * Wraps an equality function to handle either value being `undefined`.\n */\nfunction wrapEqualityFn<T>(equal: ValueEqualityFn<T>): ValueEqualityFn<T | undefined> {\n  return (a, b) => (a === undefined || b === undefined ? a === b : equal(a, b));\n}\n\nfunction getLoader<T, R>(options: ResourceOptions<T, R>): ResourceStreamingLoader<T, R> {\n  if (isStreamingResourceOptions(options)) {\n    return options.stream;\n  }\n\n  return async (params) => {\n    try {\n      return signal(\n        {value: await options.loader(params)},\n        ngDevMode ? createDebugNameObject(options.debugName, 'stream') : undefined,\n      );\n    } catch (err) {\n      return signal(\n        {error: encapsulateResourceError(err)},\n        ngDevMode ? createDebugNameObject(options.debugName, 'stream') : undefined,\n      );\n    }\n  };\n}\n\nfunction isStreamingResourceOptions<T, R>(\n  options: ResourceOptions<T, R>,\n): options is StreamingResourceOptions<T, R> {\n  return !!(options as StreamingResourceOptions<T, R>).stream;\n}\n\n/**\n * Project from a state with `ResourceInternalStatus` to the user-facing `ResourceStatus`\n */\nfunction projectStatusOfState(state: ResourceState<unknown>): ResourceStatus {\n  switch (state.status) {\n    case 'loading':\n      return state.extRequest.reload === 0 ? 'loading' : 'reloading';\n    case 'resolved':\n      return isResolved(state.stream!()) ? 'resolved' : 'error';\n    default:\n      return state.status;\n  }\n}\n\nfunction isResolved<T>(state: ResourceStreamItem<T>): state is {value: T} {\n  return (state as {error: unknown}).error === undefined;\n}\n\n/**\n * Creates a debug name object for an internal signal.\n */\nfunction createDebugNameObject(\n  resourceDebugName: string | undefined,\n  internalSignalDebugName: string,\n): {debugName?: string} {\n  return {\n    debugName: `Resource${resourceDebugName ? '#' + resourceDebugName : ''}.${internalSignalDebugName}`,\n  };\n}\n\nexport function encapsulateResourceError(error: unknown): Error {\n  if (isErrorLike(error)) {\n    return error;\n  }\n\n  return new ResourceWrappedError(error);\n}\n\nexport function isErrorLike(error: unknown): error is Error {\n  return (\n    error instanceof Error ||\n    (typeof error === 'object' &&\n      typeof (error as Error).name === 'string' &&\n      typeof (error as Error).message === 'string')\n  );\n}\n\nexport class ResourceValueError extends Error {\n  constructor(error: Error) {\n    super(\n      ngDevMode\n        ? `Resource is currently in an error state (see Error.cause for details): ${error.message}`\n        : error.message,\n      {cause: error},\n    );\n  }\n}\n\nclass ResourceWrappedError extends Error {\n  constructor(error: unknown) {\n    super(\n      ngDevMode\n        ? `Resource returned an error that's not an Error instance: ${String(error)}. Check this error's .cause for the actual error.`\n        : String(error),\n      {cause: error},\n    );\n  }\n}\n\n/**\n * Chains the current params off of the value of another resource, returning the value\n * of the other resource only when its status is `resolved` or `local`, or propagating status to\n * the current resource by throwing the appropriate status code when the value is not available.\n */\nexport function chain<T>(resource: Resource<T>): T {\n  switch (resource.status()) {\n    case 'idle':\n      throw ResourceParamsStatus.IDLE;\n    case 'error':\n      throw new ResourceDependencyError(resource);\n    case 'loading':\n    case 'reloading':\n      throw ResourceParamsStatus.LOADING;\n  }\n  return resource.value();\n}\n\nexport const paramsContext: ResourceParamsContext = {\n  chain,\n};\n\nlet inParamsFunction = false;\n\nexport function isInParamsFunction() {\n  return inParamsFunction;\n}\n\nexport function setInParamsFunction(value: boolean) {\n  inParamsFunction = value;\n}\n\nexport function invalidResourceCreationInParams(): Error {\n  return new RuntimeError(\n    RuntimeErrorCode.INVALID_RESOURCE_CREATION_IN_PARAMS,\n    ngDevMode && `Cannot create a resource inside the \\`params\\` of another resource`,\n  );\n}\n\nexport function rethrowFatalErrors(error: unknown) {\n  if (\n    error instanceof RuntimeError &&\n    error.code === RuntimeErrorCode.INVALID_RESOURCE_CREATION_IN_PARAMS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